solution of differential equation
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Gennaro Arguzzi
il 29 Mag 2016
Modificato: Gennaro Arguzzi
il 5 Giu 2016
Hi everyone, how could I solve dx/dt + x = sqrts(sin^2(t)) on Matlab? I tried with statements:
close all clear all t=[0:0.001:10]; s1=dsolve('Dx + x = abs(sin(t))','t'); pretty(s1)
but it evaluates a wrong solution. This is wrong:
C3*exp(-t) - (2^(1/2)*cos(pi/4 + t))/2
This is right:
Sqrt[Sin[t]^2]/2 - (Cot[t]*Sqrt[Sin[t]^2])/2 + C/exp(t)
Thank you for your help.
1 Commento
John D'Errico
il 5 Giu 2016
I see that you changed the problem, adding a sqrt where one was not before. Worse, you did not even change the solution that DOES result from the original problem as posed.
So, have you tried to solve this problem? See that solve generates a completely different solution, assuming that you really intended sqrt instead of the syntactically invalid sqrts?
Risposta accettata
John D'Errico
il 29 Mag 2016
Modificato: John D'Errico
il 29 Mag 2016
Really? It is wrong? So, I guess this must be a bug of some kind?
syms t C3
x = C3*exp(-t) - (2^(1 /2)*cos(pi/4 + t))/2;
simplify(diff(x,t) + x)
ans =
sin(t)
It must be time to send dsolve (as well as simplify) back to school then. Possibly there are two ways to write that expression, both of which are mathematically equivalent. :)
Personally, I prefer that which dsolve generated, though I have not tested your alternative to see if it also solves the given problem.
By the way, there is no need to pre-define t as a numeric vector in this problem, when you then immediately use t as a symbolic variable. In fact, the two different uses of t will become confusing to you at some point, and probably cause a bug for you in the future.
0 Commenti
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!