Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.3K Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

Solve numerically a system of differential equations with 4 variables?

Posted 7 years ago

Hello dear colleagues. I need to solve numerically system of differential equations. The variables z1[t],z2[t],z3[t],z4[t] to be found. I have tried, but there are errors on the code. Any assistance in order to fix the mistake will be highly appreciated. Thanks a lot.

k = 0.01230002; 
m = k/(k + 1);
ksi = 1/2*(1 - 2*m);
t0 = 0;    h0 = 4.4;  s0 = -2.05;
x1[t_] = (1 - m)*Cos[t];
x3[t_] = -m*Cos[t];
y1[t_] = (1 - m)*Sin[t];
y3[t_] = -m*Sin[t];

delta21[t_] = Sqrt[(x1[t] - z1[t])^2 + (y1[t] - z3[t])^2];
delta23[t_] = Sqrt[(x3[t] - z1[t])^2 + (y3[t] - z3[t])^2];
q1 = z1'[t] == z2[t];

Eq2 = z2'[
t] == (m*(x1[t] - z1[t]))/
delta21[t]^3 + ((1 - m)*(x3[t] - z1[t]))/delta23[t]^3;

Eq3 = z3'[t] == z4[t];

Eq4 = z4'[t] == 
m*((y1[t] - z3[t]))/delta21[t]^3 + ((1 - m)*(y3[t] - z3[t]))/
delta23[t]^3;

sol = NDSolve[{Eq1, Eq2, Eq3, Eq4,
z1[0] == ksi*Cos[t0] - h0*Sin[t0],
z2[0] == -(ksi + s0)*Sin[t0] - h0*Cos[t0],
z3[0] == ksi*Sin[t0] + h0*Cos[t0],
z4[0] == (ksi + s0)*Cos[t0] - h0*Sin[t0]},
{z1[t], z2[t], z3[t], z4[t]}, {t, -20, 20}];

Plot[Evaluate[{z1[t], z2[t], z3[t], z4[t]} /. sol], {t, -20, 20}, 
PlotRange -> All]
POSTED BY: Torebek Zhumabek
Posted 7 years ago

Torebek,

Use SetDelayed rather than Set for all the function definitions. See this.

x1[t_] := (1 - m)*Cos[t];

Eq1 is not defined. q1 = z1'[t] == z2[t]; should be Eq1 = z1'[t] == z2[t];

POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard