Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.maple > #354
| From | pluton <plutonesque@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.maple |
| Subject | strange behavior in a while loop |
| Date | 2012-02-08 00:02 -0800 |
| Organization | http://groups.google.com |
| Message-ID | <16524289.30.1328688155956.JavaMail.geo-discussion-forums@yqik15> (permalink) |
Hi,
I have the following code for a fixed point iteration in two dimensions:
Restart; with(linalg);
Gt:=matrix(2,1,[2-2*x2,1/2*sqrt((2-x1)*(2+x1))]);
#Maple command to get a vector as a function of x1 and x2;
G:=array@op@unapply([op](eval(Gt)),x1,x2):
# initial quantities
X0:=matrix(2,1,[0.5,0.5]);epsilon:=1e-12;Nor:=2;i:=1;
# loop
while Nor > epsilon do
X1:=G(X0[1,1],X0[2,1]);
Y:=evalm(X1-X0);
N:=evalm(transpose(Y)&*(Y));
Nor:=evalf(sqrt(N[1,1]));
X0:=X1;
i:=i+1;
end do:
If you run this, you'll see that from the second iteration, X0 and X1 are identical and I do not know why? It means that when X1:=G(X0[1,1],X0[2,1]); is performed (in loop 2) X0 gets the value of X1 right away and Y is then 0 and the procedure stops while it should not. I think there is some kind of a tricky thing happening inside Maple (13) but I am not sure what. I'd be happy to have your insight. Thanks
Back to comp.soft-sys.math.maple | Previous | Next — Next in thread | Find similar | Unroll thread
strange behavior in a while loop pluton <plutonesque@gmail.com> - 2012-02-08 00:02 -0800
Re: strange behavior in a while loop acer <maple@rogers.com> - 2012-02-08 00:37 -0800
Re: strange behavior in a while loop pluton <plutonesque@gmail.com> - 2012-02-08 11:58 -0800
csiph-web