I am reviewing some studies and found something about Finite Element Method.

The content I’m reading offers certain conditions to form the function of displacement u[x]u[x].

1. I gave a value for the function u(x)u(x) just to test the general solution. But using the general solution I did not get the original function again. Someone can tell me where I am going wrong?

u[x_] = -x^3 – x^2 – x + 5;

u1[x_] = D[u[x], x];

u2[x_] = D[u[x], {x, 2}];

f = -u2[x];

g = u[1];

h = -u1[0];

Expand[g + (1 – x)*h + Integrate[f, {y, x, 1}, {x, 0, y}

2. Through the DSolve tried to get the general function using the boundary conditions. But the general solution was not similar to the image. There are some dummy variables unknown to the utility. What did I do wrong?

Simplify[DSolve[{u”[x]+f[x]==0,u[1]==g,u'[0]==-h},u[x],x]]

=================

Your code doesn’t make sense because your’e not treating h and g as parameters.

– Jens

Aug 31 at 18:34

As it should be this kind of treatment?

– LMC

Aug 31 at 18:42

I believe it is very basic it, but do not know how to do it.

– LMC

Aug 31 at 18:44

Your gg and hh are boundary conditions. So you are using them to reconstruct u(x)u(x), your last formulae depends on gg and hh

– BlacKow

Aug 31 at 19:29

4

This is really not a Mathematica question. If you need to understand the Finite Element method, which is what seems to be the case, you should look for answers elsewhere.

– Pirx

Aug 31 at 23:14

=================

1 Answer

1

=================

If I understand correctly what you are trying to do, then …

You take a known function, u(x)u(x), then you calculate its derivatives. Then you calculate what would be your gg and hh for this known function.

After all that you check that the method described in your picture will actually bring you back to your original function u(x)u(x). And it does, if you fix couple of things in your definitions.

u[x_] := -x^3 – x^2 – x + 5;

u1[x_] := Evaluate@D[u[x], {x, 1}];

u2[x_] := Evaluate@D[u[x], {x, 2}];

f[x_] := -u2[x];

g = u[1];

h = -u1[0];

g + (1 – x)*h + Integrate[#, {y, x, 1}] &@Integrate[f[z], {z, 0, y}]

(* 5 – x – x^2 – x^3 *)

You can also put your double integral under one Integrate as Integrate[f[z], {y, x, 1}, {z, 0, y}]

That kinda solves question 2 and 3.

I don’t think this is a good website for your first question.

Edit

Now if you want to have a single Mathematica function to solve the same equation, you can add following to your definitions above:

DSolve[{v”[x] + f[x] == 0, v'[0] == u1[0], v[1] == u[1]}, v, x]

(* {{v -> Function[{x}, 5 – x – x^2 – x^3]}} *)

So, I guess, you can say now, that the method was validated by Mathematica.

And if you really want to see the same polynomial of x as your custom method, you have to extract it from solutions of DSolve:

(v /. First@DSolve[{v”[x] + f[x] == 0, v'[0] == u1[0], v[1] == u[1]}, v, x])[x]

(* 5 – x – x^2 – x^3 *)

Regarding your second question about general solution:

DSolve[{v”[x] + ff[x] == 0, v'[0] == a, v[1] == b}, v, x]

gives something similar to:

−x∫01−ff(K[1])dK[1]+∫x1(∫K[2]1−ff(K[1])dK[1])dK[2]+∫01−ff(K[1])dK[1]+ax−a+b-x \int_1^0 -\text{ff}(K[1]) \, dK[1]+\int_1^x \left(\int_1^{K[2]} -\text{ff}(K[1]) \, dK[1]\right) \, dK[2]+\int_1^0 -\text{ff}(K[1]) \, dK[1]+a x-a+b

which looks different compared to your general solution. But it is actually the same, if you pay attention to integration limits, you will see that your integral (with your limits) is equivalent to Mathematica’s output.

That’s right. I created any function only to test the method. I did this because I do not know how to validate the method through an undefined function.

– LMC

Aug 31 at 18:59

I’m glad you managed to get the original function.

– LMC

Aug 31 at 19:01

To “validate” the method you take a real equation with unknown function uu and known f(x),g,hf(x), g, h. You apply the method, you get your function uu, you plug it in equation and see if it’s valid.

– BlacKow

Aug 31 at 19:02

@LeandroMacieldeCarvalho On the other hand, the math of this method is so straightforward, that I don’t think it needs much of validation.

– BlacKow

Aug 31 at 19:04