ans =
Solving DE initial value problem symbolically in Matlab
Ältere Kommentare anzeigen
Hello, I'm trying to solve a differential equation IVP symbolically with MATLAB, but my answer is different than the actual answer. Am I doing something wrong?
syms x
dsolve('x*Dy+y=-sin(x)','y(pi/2)=0')
Gives the answer as:
exp(-t/x)*exp(pi/(2*x))*sin(x) - sin(x)
But the actual answer should be:
-(x*sin(x)-cos(x))/x^2
Akzeptierte Antwort
Weitere Antworten (1)
By default, y is assumed a function of t:
syms x y(t)
sol(t) = dsolve('x*Dy+y=-sin(x)','y(pi/2)=0')
simplify(x*diff(sol,t)+sol(t)+sin(x))
sol(pi/2)
... but you want y as a function of x:
syms y(x)
sol(x) = dsolve(x*diff(y,x)+y==-sin(x),y(pi/2)==0)
simplify(x*diff(sol,x)+sol+sin(x))
sol(pi/2)
Kategorien
Mehr zu Numeric Solvers finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
