Group Abstract Group Abstract

Message Boards Message Boards

Overflow problem implementing Euler's method

I tried to solve the following problem by the recursive method using the following code of the improved Euler's method, but it returns me a message ''Overflow occurred in computation''

$$X'=Z+(Y-\alpha)X$$ $$Y'=1-\beta Y-X^2$$ $$Z'=-X-\gamma Z$$ with initial conditions $(X(0),Y(0),Z(0)=(1,2,3)$.

Where

X: interest rate

Υ:investment demand

Z: price index

$\alpha$: savings, $\beta$: cost per investment, $\gamma$: the absolute value of the elasticity of demand

I tried to solve by the recursive method using the following code of the improved Euler's method

Q[a_, b_, h_, N_] := (u[0] = a; v[0] = b; 
  Do[{u[n + 1] = 
     u[n] + h*
       F[u[n] + (h/2)*F[u[n], v[n]], 
        v[n] + (h/2)*
          G[u[n], v[
            n]]],                                                     \

    v[n + 1] = 
     v[n] + h*
       G[u[n] + (h/2)*F[u[n], v[n]], v[n] + (h/2)*G[u[n], v[n]]]}, {n,
     0, N}])

15 Replies

I can not do the comparison of two graphs like that

Amazing!!! Could I do the same for the

Plot[{X[t],Y[t],Z[t]},{t,0,200},PlotLegends->"Expressions"]

Here is another idea, using AnimationVideo. Same MakePlot function, but with an explicit PlotRange to keep that constant for any parameter choice:

MakePlot[{\[Alpha]_, \[Beta]_, \[Gamma]_}, {a_, b_, c_}, h_, 
  max_Integer] := Module[{u, if},
  f[{x_, y_, z_}] := {z + (y - \[Alpha])*x, 
    1 - \[Beta]*y - x^2, -x - \[Gamma]*z};
  u[0] = {a, b, c};
  Do[u[n + 1] = u[n] + h*f[u[n] + h/2*f[u[n]]], {n, 0, max}];
  if = Interpolation[Table[{n, u[n]}, {n, 0, max/h}]];
  ParametricPlot3D[if[t], {t, 0, 2000}, 
   PlotRange -> {{-3, 3}, {-3, 3}, {-3, 3}}]
  ]

Then:

AnimationVideo[
 MakePlot[{0.9, 0.2, t}, {1, 1, 1}, 0.02, 1000],
 {t, 0.0, 2.0}]

Generates this video:

https://www.wolframcloud.com/obj/2d831a2f-4c28-4881-82bc-3bc95c88bbad

POSTED BY: Arnoud Buzing
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard
Be respectful. Review our Community Guidelines to understand your role and responsibilities. Community Terms of Use