Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Stability limits for Runge–Kutta methods in the complex ΩΔt-plane are needed to be plotted like this: enter image description here

For example, let P=1+z where z is complex. Under the stability condition |P|<=1, the plot line should be that of RK-1 in the given plot. Similarly, if P=1+z+1/2*z^2, then when |P|<=1 the plotting line is the corresponding of RK-2.

I am trying to code P=1+z like this:

Clear[yRe, yIm, w, NP, k, ϕ]
a = 1;
zexp = a*(Cos[ϕ] + I*Sin[ϕ]) + 1
xp[ϕ_Real, a_Real] = Abs@zexp*Cos[ϕ];
yp[ϕ_Real, a_Real] = Abs@zexp*Sin[ϕ]
NP = 30;
For[k = 1, k <= NP, k++,
 w = 2.*Pi*(k - 1)/NP;
 yRe[k] = xp[ϕ, a] /. {ϕ -> w};
 yIm[k] = yp[ϕ, a] /. {ϕ -> w};
 ]
yRe = Table[yRe[k], {k, 1, NP}];
yIm = Table[yIm[k], {k, 1, NP}];
pointsz = Transpose[{yRe, yIm }];

pic1 = ListPlot[pointsz, AxesOrigin -> {0, 0}, 
  PlotStyle -> Directive[Thick, Black, PointSize[Large]], 
  AxesStyle -> Directive[Black, 15], 
  AxesLabel -> {"Re(ωΔt)", 
    "Im(ωΔt)"}, AspectRatio -> Automatic]

The resulted plot as following is not correct. The truth is like RK-1 in the above figure. enter image description here

How can i get the correct plot lines of RK-1 and RK-2 using Mathematica? Thanks.

share|improve this question

1 Answer 1

Want to plot a region defined by an inequality? Just use RegionPlot.

z = x + I y;
p1 = 1 + z;
p2 = 1 + z + 1/2 z^2;
RegionPlot[{Abs[p1] <= 1, Abs[p2] <= 1}, {x, -2.5, 0.5}, {y, -2, 2}, 
 AspectRatio -> Automatic]

enter image description here

If you just want the boundary contours, use ContourPlot[{Abs[p1] == 1, Abs[p2] == 1}, ... instead.


Oh hey check it out:

p[z_, n_] := Normal@Series[Exp[w], {w, 0, n}] /. w -> z;
ContourPlot[Evaluate@Table[Abs[p[x + I y, n]] == 1, {n, 1, 5}], 
 {x, -4, 1}, {y, -4, 4}, AspectRatio -> Automatic, Frame -> False, Axes -> True]

enter image description here

share|improve this answer
    
Thanks Rahul Narain. That is what I want. –  Flymath Jul 31 at 12:54
    
@Flymath Don't forget to mark answer accepted. –  m0nhawk Jul 31 at 14:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.