Coding a system of differential equations

2 Ansichten (letzte 30 Tage)
James Sm.
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

Akzeptierte Antwort

Torsten
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
James Sm.
James Sm. am 9 Jan. 2022
ok ok i somewhat get it now
thank you
Torsten
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)];

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by