How can I force a non-trivial solution for a second order ODE

3 次查看(过去 30 天)
I am trying to solve the second order ODE x''=[ 9/4-(12/(5-3exp(2t)))exp(2t)] x(t), with ICs x'=x=0 at t=-1 for -1<=t<=0, using Runge-Kutta 4. Here is my MWE:
a = -1; b = 0; N = 1000;
t = zeros(1, N);
w1 = zeros(1, N);
w2 = zeros(1, N);
w1(1) = 0; w2(1) = 0;
h = (b - a)/N;
t(1) = a;
F1 = @(t, x1, x2) x2;
F2 = @(t, x1, x2) ((12*exp(2*t))/(3*exp(2*t) - 5) + 9/4)*x1;
for i = 1:(N-1)
K11 = h*(F1(t(i), w1(i), w2(i)));
K21 = h*(F2(t(i), w1(i), w2(i)));
K12 = h*(F1(t(i) + 0.5*h, w1(i) + 0.5*K11, w2(i)+ 0.5*K21));
K22 = h*(F2(t(i) + 0.5*h, w1(i) + 0.5*K11, w2(i)+ 0.5*K21));
K13 = h*(F1(t(i) + 0.5*h, w1(i) + 0.5*K12, w2(i)+ 0.5*K22));
K23 = h*(F2(t(i) + 0.5*h, w1(i) + 0.5*K12, w2(i)+ 0.5*K22));
K14 = h*(F1(t(i) + h, w1(i) + K13, w2(i)+ K23));
K24 = h*(F2(t(i) + h, w1(i) + K13, w2(i)+ K23));
w1(i+1) = w1(i) + (K11 + 2*K12 + 2*K13 + K14)/6;
w2(i+1) = w2(i) + (K21 + 2*K22 + 2*K23 + K24)/6;
t(i+1) = a + i*h;
end
My issue is that the trivial solution x=0 is returned. I have tried the code with various other second order ODEs that I know the solution for and I get the expected results. If I make the ICs tiny instead of zero (say 0.000001) it seems to force a correct-ish looking, but obviously incorrect, solution. Any help is appreciated. I am new to Matlab. I get the same thing using ode45. Perhaps there is no non-trivial solution but there should be.
  3 个评论
Sklarker
Sklarker 2019-4-18
Cheers John. I don't intend for the derivatives to be identcally zero, only at t=-1. For comparison I tried the simple example x''=-x+6t+t^3 also with x=x'=0 (but at t=0). The solution is x=t^3.
John D'Errico
John D'Errico 2019-4-18
编辑:John D'Errico 2019-4-18
But they ARE identically zero, for all t. That is so because they start out x1 = x2 = 0.
F1 = @(t, x1, x2) x2;
F2 = @(t, x1, x2) ((12*exp(2*t))/(3*exp(2*t) - 5) + 9/4)*x1;
So they are zero. When you try to move away for greater values of t, they stay zero. At any point, they are still zero. Anything times zero is still zero, even for F2. So you are trapped in that zero state, never escaping.
As Steve explains in your other case, as t grows beyond zero, the derivatives move away from zero, even if x is zero. But in the case you had a problem with, you MULTIPLY by X1 in F2.

请先登录,再进行评论。

采纳的回答

Steven Lord
Steven Lord 2019-4-18
Your equation is x''=[ 9/4-(12/(5-3exp(2t)))exp(2t)] x(t) with initial conditions x'=x=0. You are a racecar at the starting line (since x = 0), the car is not moving (since x' = 0 its speed is 0 miles [or kilometers] per hour), and your foot is off the accelerator (evaluating the right hand side gives x'' = 0 regardless of what value t has.)
Is your car ever going to move under those circumstances? It will when they bring the tow truck over to pull you out of the way so others can race, but that's outside the scope of this ODE.
As for your simpler example, with x'' = -x+6*t+t^3, that's different than this example. You're not multiplying by x.
A closer example would be x'' = (-x+6*t+t^3)*x and again, with the initial conditions x = 0 and x' = 0 you never start accelerating.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by