フィルターのクリア

Simplifying solution of a differential equation

5 ビュー (過去 30 日間)
Aleem Andrew
Aleem Andrew 2021 年 1 月 14 日
コメント済み: Aleem Andrew 2021 年 1 月 14 日
The most simplified version of ySol(t), the solution to the differential equation below, is 1.5*sin(2t+0.7297), but the output of the following code is in terms of exponential functions. Can someone explain how the output can be further simplified?
syms y(t) m k
Dy = diff(y,t); Dy2 = diff(y,t,2);
ode = m*Dy2 + k*y == 0;
cond = [y(0) == 1,Dy(0) == sqrt(5)];
ySol(t) = dsolve(ode,cond)
ySol(t) = simplify(ySol(t),'steps',500)
pretty(ySol(t))
  4 件のコメント
Walter Roberson
Walter Roberson 2021 年 1 月 14 日
When m and k are symbolic, you get symbolic expressions for the coefficients, not numeric ones like you show as your desired output.
Aleem Andrew
Aleem Andrew 2021 年 1 月 14 日
That is because there is an additional equation relating k and m, sqrt(k/m) = 2, that I tried to include in the dsolve command to solve the system but got an error message when trying to solve a system of equations, [ode sqrt(k/m) == 2]. Instead the ode = m*Dy2 + k*y == 0; line can be modified to ode = (k/4)*Dy2 + k*y == 0; to obtain the numeric solution.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2021 年 1 月 14 日
m = rand(); k = rand();
syms y(t)
Dy = diff(y,t);
Dy2 = diff(y,t,2);
ode = m*Dy2 + k*y == 0;
cond = [y(0) == 1,Dy(0) == sqrt(5)];
ySol(t) = dsolve(ode,cond)
ySol(t) = 
ySol(t) = simplify(ySol(t),'steps',500)
ySol(t) = 
pretty(ySol(t))
/ sqrt(43198488722811199054095930230) t \ sqrt(8639697744562239810819186046) sin| ------------------------------------- | 5 / sqrt(43198488722811199054095930230) t \ \ 157178273090335 / cos| ------------------------------------- | + --------------------------------------------------------------------------------- \ 157178273090335 / 274837532398538
vpa(ySol(t), 5)
ans = 
  1 件のコメント
Aleem Andrew
Aleem Andrew 2021 年 1 月 14 日
Thank you for your answer

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEquation Solving についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by