MATLAB: Second Order ODE with Power

second order ode

Hello,
I have this form of equation
x'' = A/x^2 *(B+C*(x')^2+C*(x')^4)
I wrote this script
syms x(t) A B C D vb b
v=diff(x,t,2)==(A/x)*(B+C*(diff(x,t))^2+(C*(diff(x,t))^4);
Dx=diff(x,t);
initial = [x(0)==b, Dx(0)==vb];
xSol(t) = dsolve(v,initial)
But I had this output
Warning: Unable to find explicit solution.
xSol(t) =
[ empty sym ]
I thought of solving it to some extent and apply numerical methods. I later came up with an equation of the form
integral ((A+B*X^a)/(C+D*X^a))dx, please note that constants A, B, C, and D here are different from the ones above.
This, I believe is a form of hypergeometric expression. I don't know how to move further from here.
Thank you.

Best Answer

The best way to integrate it numerically is something like this:
syms x(t) A B C D vb b Y t
v=diff(x,t,2)==(A/x)*(B+C*(diff(x,t))^2+(C*(diff(x,t))^4));
[VF,Subs] = odeToVectorField(v);
odefcn = matlabFunction(VF, 'Vars',{t,Y,A,B,C,D})
A = ...;
B = ...;
C = ...;
D = ...;
tspan = ...;
b = ...;
vb = ...;
ic = [b; vb];
[T,X] = ode45(@(t,Y)odefcn(t,Y,A,B,C,D), tspan, ic);
figure
plot(T,X)
legend(string(Subs))
I chose ode45 here because it usually works. If the constants vary by several orders-of-magnitude, the equation would likely be ‘stiff’ and a different solver, such as ode15s would be necessary.
Related Question