我要加入 登录
声振论坛 返回首页

liliangbiao的个人空间 http://home.vibunion.com/?69372 [收藏] [复制] [分享] [RSS]

日志

Basin of attraction using Newton's method

已有 1847 次阅读2011-3-17 11:41 |个人分类:分叉

% Author: Thomas Lee
% basin of attraction
% using Newton's method to track initial values to
% convergence of the roots for z^3 -1
% 3 blocks for each root, z1=1,z2,z3 as following
x = -1:0.001:1; y = -1:0.001:1;
[xx, yy] = meshgrid(x,y);
n = 300;
z2 = -1./2. + i*sqrt(3.)/2.;
z3 = -1./2. - i*sqrt(3.)/2.;
for a = 1:length(y),
  for b = 1:length(x),
    z = xx(a,b) + i*yy(a,b);
    for loop = 1:100,
      z = z - (z.^3 - 1)./(3*z.^2);
      if abs(z - 1) < 1e-4,%just adjust it
      n(a,b) = loop; break,
    end,
  end,
 end,
end,
pcolor(xx,yy,n);
shading flat
for a = 1:length(y),
  for b = 1:length(x),
    z = xx(a,b) + i*yy(a,b);
    for loop = 101:200,
     z = z - (z.^3 - 1.)./(3*z.^2);
     if abs(z - z3) < 1e-4,
       n(a,b) = loop; break,
     end,
    end, 
  end,
end,
pcolor(xx,yy,n);
shading flat
for a = 1:length(y),
  for b = 1:length(x),
    z = xx(a,b) + i*yy(a,b);
    for loop = 201:300,
     z = z - (z.^3 - 1.)./(3*z.^2);
     if abs(z - z3) < 1e-4,
       n(a,b) = loop; break,
     end,
    end, 
  end,
end,
pcolor(xx,yy,n);
shading flat
    

Newton's Basins

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 我要加入

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-25 02:06 , Processed in 0.029399 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部