From: landon donovan on 12 May 2010 00:36 Im using the next function to generate vectors according to the equation: x(i+1)=x(i) + 3*x(i)^2 - 2*x(i)^3 + 0.5*x(i-1) function [M] = generate(n) x1=rand(30,1); x2=rand(30,1); M(:,1)=x1; M(:,2)=x2; for i=2:n-1 M(:,i+1)=M(:,i)+3*(M(:,i)).^2-2*(M(:,i)).^3+0.5*M(:,i-1); end but when I try n=100 , the last 94 columns of M result in NaN. Is this normal when the entries of the column are of order 1e-100000... ? That is, too very small; or too big of the order 1e100000... ? or am I commiting some error? Please Help
From: Bruno Luong on 12 May 2010 01:53 "landon donovan" <lutobu(a)gmail.com> wrote in message <hsdb7j$mj9$1(a)fred.mathworks.com>... > Im using the next function to generate vectors according to the equation: > x(i+1)=x(i) + 3*x(i)^2 - 2*x(i)^3 + 0.5*x(i-1) > > function [M] = generate(n) > x1=rand(30,1); > x2=rand(30,1); > M(:,1)=x1; > M(:,2)=x2; > for i=2:n-1 > M(:,i+1)=M(:,i)+3*(M(:,i)).^2-2*(M(:,i)).^3+0.5*M(:,i-1); > end > > but when I try n=100 , the last 94 columns of M result in NaN. Is this normal when the entries of the column are of order 1e-100000... ? That is, too very small; or too big of the order 1e100000... ? or am I commiting some error? > Please Help Haven't tried your code, but it looks like the recursive scheme is unstable. That's why people spending their time studying stability, convergence, ... Bruno
From: James Tursa on 12 May 2010 02:11 "landon donovan" <lutobu(a)gmail.com> wrote in message <hsdb7j$mj9$1(a)fred.mathworks.com>... > Im using the next function to generate vectors according to the equation: > x(i+1)=x(i) + 3*x(i)^2 - 2*x(i)^3 + 0.5*x(i-1) > > function [M] = generate(n) > x1=rand(30,1); > x2=rand(30,1); > M(:,1)=x1; > M(:,2)=x2; > for i=2:n-1 > M(:,i+1)=M(:,i)+3*(M(:,i)).^2-2*(M(:,i)).^3+0.5*M(:,i-1); > end > > but when I try n=100 , the last 94 columns of M result in NaN. Is this normal when the entries of the column are of order 1e-100000... ? That is, too very small; or too big of the order 1e100000... ? or am I commiting some error? The individual pieces of your polynomial are becoming very large. Eventually they become too large for a finite value and become Infinity. And then at some point you do an Infinity - Infinity calculation and the result is NaN. This is not a stable way to generate whatever you are trying to generate. James Tursa
|
Pages: 1 Prev: usb 2 parallel converter problem Next: error using ==> open at 157 |