Using ode15i

2 ビュー (過去 30 日間)
Inbar Maimon
Inbar Maimon 2018 年 11 月 7 日
編集済み: Inbar Maimon 2018 年 11 月 7 日
I tried to solve an implicit differential equation of the form f = c1*q^4 + c2*dqdt^2 - c3 (where c1,c2,c3>0) with ode15i. The wanted solution oscillates, but the solution that I get doesn't. It does, though, stop about where it is supposed to, but not exactly. How can I get it right?
---
Here is the relevant part of the code:
x0 = 0
v0 = 2
tspan=[0,6]
option = odeset('events', @condE);
[x0, v0] = decic(@diffE, tspan(1), x0, [], v0, []);
[t, xv, tf, xvf, ~] = ode15i(@diffE, tspan, x0, v0, option);
%% ODE function for energy equation
function f = diffE(~, q, dqdt)
% Assume: m = 1; k = 1; E = 1;
f = (m/2)*dqdt.^2 + (m*k/4)*q.^4 - E;
end
%% Event function for x0 = 0 for energy equation
function [val, ister, dir] = condE(~, ~, dxdt)
val = dxdt;
ister = 1;
dir = -1;
end
  1 件のコメント
Torsten
Torsten 2018 年 11 月 7 日
The code is incomplete.

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

回答 (1 件)

Torsten
Torsten 2018 年 11 月 7 日
Nothing oscillating can be seen:
https://www.wolframalpha.com/input/?i=Runge-Kutta+method,+dy%2Fdx+%3D+Sqrt(2-0.5*y(x)%5E4),+y(0)+%3D+0,+from+0+to+1.3,+h+%3D+.025
Best wishes
Torsten.
  1 件のコメント
Inbar Maimon
Inbar Maimon 2018 年 11 月 7 日
編集済み: Inbar Maimon 2018 年 11 月 7 日
When you differentiate you get the force eq. c2*d2q/dt2 = -4*c1*q^3, which oscillates.
I think it is reasonable, for there are only even powers in the conservation equation 0 = c1*q^4 + c2*dqdt^2 - c3 from which I began.
But yeah, that was exactly my problem. I tried taking the square root and realized that by doing so I force the solution to give only positive dq/dt.

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

カテゴリ

Help Center および File ExchangeNumerical Integration and Differential Equations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by