dsolve problem got error

3 ビュー (過去 30 日間)
지웅 장
지웅 장 2023 年 11 月 7 日
コメント済み: Sam Chak 2023 年 11 月 16 日
eqn = diff(theta,2) == 1- theta^2/2 %Taylor approx of cos(theta) thetaSol = dsolve(eqn,cond) %theta_0 and diff(theta) is zero. I want to get function of theta, but solution got error. How can I get answer of theta, when diff(theta,2) == 1- theta^2/2?
  2 件のコメント
Dyuman Joshi
Dyuman Joshi 2023 年 11 月 7 日
編集済み: Dyuman Joshi 2023 年 11 月 7 日
eqn = diff(theta,2) == 1- theta^2/2
Differentiation of theta with respect to what? which variable?
R
R 2023 年 11 月 14 日
Can you also share the error you are encountering?

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

回答 (2 件)

nick
nick 2023 年 11 月 16 日
Hi 지웅 장,
I understand that you are facing an issue with obtaining solution of the differential equation for the mentioned equation using 'dsolve'.
diff(theta,2) == 1- theta^2/2
'diff(theta,2)' computes the 2nd derivative of theta with respect to the symbolic scalar variable determined by symvar, which is 0. This leads to the input parameter to 'dsolve' function being, '0 == 1 - theta^2/2' , which is not a differential equation.
In any differential equation you need one or more dependent variable, 'theta' in this case, and an independent variable. You need to mention an independent variable to evaluate the differential equation by 'dsolve'. You may refer the following link to learn more about solving differential equation with 'dsolve' :
Hope it helps,
Regards,
Neelanshu Garg

Sam Chak
Sam Chak 2023 年 11 月 16 日
If dsolve() cannot return an analytical solution, then use ode45 solver to obtain a numerical solution.
However, WolframAlpha is able to return an analytical solution in terms of Weierstrass elliptic function, ℘.
% syms y(t)
% eqn = diff(y,t,2) == 1 - (y^2)/2;
% Dy = diff(y,t);
% cond = [y(0)==0, Dy(0)==1];
% ySol(t) = dsolve(eqn, cond, 'ExpansionPoint', 0)
tspan = linspace(0, 10, 1001);
y0 = [0; 1];
[t, y] = ode45(@odefcn, tspan, y0);
plot(y(:,1), y(:,2)), grid on
xlabel('y_{1}'), ylabel('y_{2}')
function dydt = odefcn(t, y)
dydt = zeros(2, 1);
dydt(1) = y(2);
dydt(2) = 1 - (y(1)^2)/2;
end
  1 件のコメント
Sam Chak
Sam Chak 2023 年 11 月 16 日
If the original cosine function is used, an analytical solution can be found, where is the Jacobi amplitude function. This solution is commonly encountered in the study of undamped pendulum responses within highly advanced pure mathematics topics, rather than in superficially simple engineering mathematics.
syms y(t)
eqn = diff(y,t,2) == cos(y);
Dy = diff(y,t);
ySol(t) = dsolve(eqn)
ySol(t) = 

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

カテゴリ

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