What Are the Correct Steps to Plot Stability Regions in Numerical Methods?

  • Context: MHB 
  • Thread starter Thread starter Ally1
  • Start date Start date
  • Tags Tags
    Plotting Stability
Click For Summary

Discussion Overview

The discussion revolves around the steps to plot stability regions in numerical methods, specifically focusing on Euler's Method and the Exponential Time Differencing-Runge-Kutta Method. Participants explore coding techniques and mathematical definitions related to stability analysis.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant provides a code snippet for plotting the stability region of Euler's Method, emphasizing the definition of Z as λ*h, where h is the step-size and λ is an eigenvalue.
  • Another participant suggests using the "hold on" and "hold off" commands to plot multiple regions on the same graph.
  • A participant expresses a specific concern about modifying the provided code to correctly implement Z = λ*h.
  • Another participant raises a question regarding the operator associated with the eigenvalue λ, indicating uncertainty about its identity.
  • A participant shares an example involving the Exponential Time Differencing-Runge-Kutta Method, noting issues with the code not producing correct stability regions.
  • The shared code includes complex calculations for stability analysis, but the participant indicates that the output does not match expectations.

Areas of Agreement / Disagreement

Participants express varying levels of concern about different aspects of the coding process and the mathematical definitions involved. There is no consensus on the correct implementation of the stability region plotting, and multiple viewpoints on the interpretation of eigenvalues and operators remain unresolved.

Contextual Notes

The discussion includes complex mathematical expressions and coding techniques that may depend on specific definitions and assumptions not fully articulated. The limitations of the provided code and its outputs are acknowledged but not resolved.

Ally1
Messages
3
Reaction score
0
In many cases one finds code such as
x = linspace(-3,1.5,200);
y = linspace(-3.5,3.5,200);
[X,Y] = meshgrid(x,y);
Z = X +Y*i;
%Euler's Method
M = abs(1+Z);
[c,h] = contour(X,Y,M,[1,1]);
set(h,'linewidth',2,'edgecolor','g')
to plot the stability region of the Euler's Method, where in fact the definition of is Z = lambda*h, where h is a step-size and lambda an eigenvalue.

1. How do I modify this program the above in terms of Z = lambda*h?

2. How do I plot different regions on same plot?

Thanking you in advance.
 
Physics news on Phys.org
Hi Ally,

For 2), you can plot different/multiple regions on the same plot by using the "hold on" and "hold off" command.
 
Ok thanks but I am more concern about point 1).
 
Ally said:
Ok thanks but I am more concern about point 1).

Well, if $\lambda$ is an eigenvalue, then it's the eigenvalue of some operator. I have one possibility in mind for what that operator is, but what do you think it is?
 
Thank for your respond.

To clear my question, let me take an example of the Exponential Time Differencing-Runge-Kutta Method [F. de la Hoz and F. Vadillo Computer Physics Communications 179 (2008) 449–456 ], I tried to code the stability regiong of this method as you can see below but the code is not giving me the correct regions within each other.
function stability_of_cancer_hiv(y)
%
ROOT = []; ROOT0 = []; lambda = 0.05; h = 0.6; z = lambda*h;
%
if y==0;
% y=-0.5*h;
c0 = exp(y);
c1 = 1 + y + 1/2*y^2 + 1/6*y^3 + 13/320*y^4 + 7/960*y^5;
c2 = 1/2 + 1/2*y + 1/4*y^2 + 247/2880*y^3 + 131/5760*y^4 + 479/96768*y^5;
c3=1/6+1/6*y+61/720*y^2+1/36*y^3+1441/241920*y^4+67/120960*y^5;
c4=1/24+1/32*y+7/640*y^2+19/11520*y^3-25/64512*y^4-311/860160*y^5;
else
c0=exp(y);
c1=-4/y^3+8*exp(y/2)/y^3-8*exp(3*y/2)/y^3+4*exp(2*y)/y^3-1/y^2+4*exp(y/2)/y^2-...
6*exp(y)/y^2+4*exp(3*y/2)/y^2-exp(2*y)/y^2;
c2=-8/y^4+16*exp(y/2)/y^4-16*exp(3*y/2)/y^4+8*exp(2*y)/y^4-5/y^3+12*exp(y/2)/y^3-...
10*exp(y)/y^3+4*exp(3*y/2)/y^3-exp(2*y)/y^3-1/y^2+4*exp(y/2)/y^2-3*exp(y)/y^2;
c3=4/y^5-16*exp(y/2)/y^5+16*exp(y)/y^5+8*exp(3*y/2)/y^5-20*exp(2*y)/y^5+8*exp(5*y/2)/y^5+...
2/y^4-10*exp(y/2)/y^4+16*exp(y)/y^4-12*exp(3*y/2)/y^4+6*exp(2*y)/y^4-2*exp(5*y/2)/y^4+...
4*exp(y)/y^3-2*exp(3*y/2)/y^3;
c4=8/y^6-24*exp(y/2)/y^6+16*exp(y)/y^6+16*exp(3*y/2)/y^6-24*exp(2*y)/y^6+8*exp(5*y/2)/y^6+...
6/y^5-18*exp(y/2)/y^5+20*exp(y)/y^5-12*exp(3*y/2)/y^5+6*exp(2*y)/y^5-2*exp(5*y/2)/y^5+...
2/y^4-6*exp(y/2)/y^4+6*exp(y)/y^4-2*exp(3*y/2)/y^4;
end
for theta = 1:200;
p0 = [z^4/24 z^3/6 z^2/2 z (1-exp(1i*theta))];
ROOT1 = roots(p0);
ROOT = [ROOT ROOT1];
%
p1 = [c4*z^4/24 c3*z^4/6 c2*z^4/2 c1*z c0*(1-exp(1i*theta))];
ROOT2 = roots(p1);
ROOT0 = [ROOT0 ROOT2];
end
% disp(ROOT);
figure(1); plot(real(ROOT),imag(ROOT),'k','linewidth',0.1);
figure(2); plot(real(ROOT0),imag(ROOT0),'k','linewidth',1);
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
5
Views
8K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K