1
$\begingroup$

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]$.

1. I gave a value for the function $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?

enter image description here

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]]
$\endgroup$
8
  • $\begingroup$ Your code doesn't make sense because your'e not treating h and g as parameters. $\endgroup$
    – Jens
    Aug 31 '16 at 18:34
  • $\begingroup$ Your $g$ and $h$ are boundary conditions. So you are using them to reconstruct $u(x)$, your last formulae depends on $g$ and $h$ $\endgroup$
    – BlacKow
    Aug 31 '16 at 19:29
  • $\begingroup$ The last formulae allows to build function $u(x)$ if you know $f(x), g, h$. What do you mean by having only boundary conditions??? You need equation to solve. $\endgroup$
    – BlacKow
    Aug 31 '16 at 19:40
  • $\begingroup$ I updated my answer... $\endgroup$
    – BlacKow
    Aug 31 '16 at 21:57
  • 5
    $\begingroup$ 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. $\endgroup$
    – Pirx
    Aug 31 '16 at 23:14
6
$\begingroup$

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

You take a known function, $u(x)$, then you calculate its derivatives. Then you calculate what would be your $g$ and $h$ 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)$. 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 \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.

$\endgroup$
2
  • $\begingroup$ To "validate" the method you take a real equation with unknown function $u$ and known $f(x), g, h$. You apply the method, you get your function $u$, you plug it in equation and see if it's valid. $\endgroup$
    – BlacKow
    Aug 31 '16 at 19:02
  • $\begingroup$ @LeandroMacieldeCarvalho On the other hand, the math of this method is so straightforward, that I don't think it needs much of validation. $\endgroup$
    – BlacKow
    Aug 31 '16 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.