Coding a system of differential equations
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
James Sm.
am 5 Jan. 2022
Kommentiert: Torsten
am 9 Jan. 2022
This is the system
dx/dt=y^2/x ,
dy/dt=x^2/y
with initial conditions x(0)=√ 2 , y(0)=0
i know how to do them separately but how do you put them in a system
0 Kommentare
Akzeptierte Antwort
Torsten
am 5 Jan. 2022
Bearbeitet: Torsten
am 5 Jan. 2022
Numerically solving the original system will make difficulties because of the singularity at t=0 for y.
So let's first rewrite the equations:
y^2 = x*dx/dt
-> 2*y*dy/dt = x*d^2x/dt^2 + (dx/dt)^2
-> 0.5*(x*d^2x/dt^2 + (dx/dt)^2) = x^2
-> x*d^2x/dt^2 + (dx/dt)^2 - 2*x^2 = 0
Thus solve
x*d^2x/dt^2 + (dx/dt)^2 - 2*x^2 = 0
x(0) = sqrt(2), dx/dt(0) = 0
and it follows that
y = sqrt(x*dx/dt) or y=-sqrt(x*dx/dt)
Since you said you know how to solve one equation, I think you need no further help.
6 Kommentare
Torsten
am 9 Jan. 2022
Remark:
The second-order ODE for x has to be rewritten as a system of two first-order ODEs where
x(1) = x and x(2) = dx/dt.
The system reads
dx(1)/dt = x(2)
dx(2)/dt = (-x(2)^2+2*x(1)^2)/x(1)
This is implemented in
fun = @(t,x)[x(2);(-x(2)^2+2*x(1)^2)/x(1)];
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!