# Solving a third order ODE in MATLAB

73 views (last 30 days)
Sergio Manzetti on 9 Feb 2018
Edited: Sergio Manzetti on 15 Feb 2018
syms a h Y(x) g x B E T
D3Y = diff(Y, 3)
eqn = a.*D3Y -0.5*x^2*Y == (abs(Y))
D2Y = diff(Y, 2)
DY = diff(Y)
cond1 = Y(0) == 1;
cond2 = DY(0) == 0;
cond3 = D2Y(0) == 0
Y(x) = dsolve(eqn, cond1, cond2, cond3)
latex(Y(x))
Is there a limit here for solving it? Thanks

Karan Gill on 12 Feb 2018
Do you not get this warning? If you got it, was the warning clear?
Warning: Unable to find explicit solution.
> In dsolve (line 201)
Y(x) =
[ empty sym ]
Try solving numerically using ode45 or similar.

Sergio Manzetti on 13 Feb 2018
Yes I did, but I was surprised, because it is readily solved using other methods. I will check out ode45, however I am not sure it will give an analytical solution.
Karan Gill on 13 Feb 2018
What do you mean by "other methods"?

Sergio Manzetti on 14 Feb 2018
Wolfram alpha, it solves it without any problems.

Sergio Manzetti on 14 Feb 2018
Thanks
Karan Gill on 14 Feb 2018
Is this what you tried? Didn't work for me.
Could you post your input to Wolfram?

Sergio Manzetti on 15 Feb 2018
Edited: Sergio Manzetti on 15 Feb 2018
I tried this on wolfram, which is the equivalent of this:
syms a h Y(x) g x B E T
D3Y = diff(Y, 3)
eqn = a.*D3Y -0.5*x^2*Y == Y
D2Y = diff(Y, 2)
DY = diff(Y)
cond1 = Y(0) == 1;
cond2 = DY(0) == 0;
cond3 = D2Y(0) == 1;
Y(x) = dsolve(eqn, cond1, cond2, cond3)
latex(Y(x))
and I got a result,Z = 1/3*(exp(x) + 2*exp(-x/2)*cos((sqrt(3)*x)/2)) , however, the result is now non-visible because of std computation time exceeded.

Torsten on 15 Feb 2018
You used
eqn = a.*D3Y -0.5*x^2*Y == Y
eqn = a.*D3Y -0.5*x^2*Y == abs(Y)
Best wishes
Torsten.
Karan Gill on 15 Feb 2018
Thanks for catching that. I also noticed the third condition is different.
Torsten on 15 Feb 2018
... and I'm surprised that the solution does not depend on "a".

Sergio Manzetti on 15 Feb 2018
It doesn't matter, abs(Y) did not yield results with either methods, while the former, Y, yielded result only in wolfram.