MATLAB Answers

Solving nonlinear implicit differential equation of the form F(t,y(t),y'(t),y''(t), y'''(t), ...)=0 in MATLAB using ode15i

18 views (last 30 days)
Saeid on 8 Jun 2020
Edited: Ameer Hamza on 13 Jun 2020
Is it possible to solve implicit differential equations of the form F(t,y(t),y'(t),y''(t), ..., y(n))=0 in Matlab? The specific case that I handle is:
a*(y")^2+y' * [y'''+ b*y"+c*y'] +d*(y’)^2+k*y*y" = 0
ode15i documentation refers only to and mentions examples of the case where y' appears in the equations, but is there a way I could solve implicit equations with higher derivatives of y?

Accepted Answer

Ameer Hamza
Ameer Hamza on 13 Jun 2020
Edited: Ameer Hamza on 13 Jun 2020
If you have symbolic toolbox. you can use odeToVectorField to convert the 3rd order-ODE to a system of 3 first-order ODE as long as there as no exponent over term. The following shows the solution to your ODE. Values of parameters are assumed randomly
syms y(t)
a = 1;
b = 0.3;
c = 0.5;
d = 0.9;
k = 2;
eq = a*diff(y,2)^2 + diff(y,1)*(diff(y,3) + b*diff(y,2) + c*diff(y,1)) + d*diff(y,1)^2 + k*y*diff(y,2) == 0;
eq = odeToVectorField(eq);
odefun = matlabFunction(eq, 'Vars', {'t', 'Y'});
tspan = [0 10];
ic = [1; 1; 0];
[t, y] = ode45(odefun, tspan, ic);
plot(t, y)
legend({'$y$', '$\dot{y}$', '$\ddot{y}$'}, ...
'FontSize', 18, ...
'Interpreter', 'latex', ...
'Location', 'best')
If you don't have the Symbolic toolbox, then you will need to manually convert the ODE into a system of first-order ODE. See this example:

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!