solution of differential equation
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
John D'Errico
2016 年 6 月 5 日
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?
採用された回答
John D'Errico
2016 年 5 月 29 日
編集済み: John D'Errico
2016 年 5 月 29 日
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 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!