why power series plot is not matching with ode

t=1:20;
a(1)=1;
b(1)=1;
c(1)=1;
c1=10;
c2=28;
c3=8/3;
sumx=0;
sumy=0;
sumz=0;
for i=1:10
a(i+1)=(c1*(b(i)-a(i)))/(i+1);
b(i+1)=((c2-c(i))*a(i)-b(i))/(i+1);
c(i+1)=(a(i)*b(i)-c3*c(i))/(i+1);
sumx=sumx+a(i)*t^i;
sumy=sumy+b(i)*t^i;
sumz=sumy+c(i)*t^i;
x=sumx;
y=sumy;
z=sumz;
end
plot(t,x) not matching

8 Comments

pl solve the problem
We don't know what the problem is. So you will first need to describe it in order to get help.
What ODE are you talking about ? What is the deduced solution in the form of a power series ?
lorenz system of ode
equation
c1 = 10
c2 = 28
c3 = 8/3
dy(1) = c1*(y-x)
dy(2) = (c2-z)*x-y
dy(3) = x*y-c3*z
where x=y(1)
y=y(2)
z=y(3)
pl plot(t,x) using power series
t=1:20;
a(1)=1;
b(1)=1;
c(1)=1;
c1=10;
c2=28;
c3=8/3;
sumx=0;
sumy=0;
sumz=0;
for i=1:10
a(i+1)=(c1*(b(i)-a(i)))/(i+1);
b(i+1)=((c2-c(i))*a(i)-b(i))/(i+1);
c(i+1)=(a(i)*b(i)-c3*c(i))/(i+1);
sumx=sumx+a(i)*t^i;
sumy=sumy+b(i)*t^i;
sumz=sumy+c(i)*t^i;
x=sumx;
y=sumy;
z=sumz;
end
program of power series pl help to correct graph
According to
the coefficients of the power series for x(t), y(t) and z(t) of the Lorenz system are much more difficult than
a(i+1)=(c1*(b(i)-a(i)))/(i+1);
b(i+1)=((c2-c(i))*a(i)-b(i))/(i+1);
c(i+1)=(a(i)*b(i)-c3*c(i))/(i+1);

Sign in to comment.

Answers (2)

syms x
f = log(x+1)
f = 
xtay = taylor(f, x, 0, 'order', 10)
xtay = 
subplot(2,1,1); fplot(f, [-30 30])
subplot(2,1,2); fplot(xtay, [-30 30])
Just because you take a truncated taylor series doesn't mean that the truncated taylor series is at all accurate as you get away from the expansion point.

4 Comments

we have to use numerically
subplot(2,1,2); fplot(xtay, [-1+eps 1-eps])
instead of
subplot(2,1,2); fplot(xtay, [-30 30])
Taylor series is only convergent for | x|< 1
You have the complicated plot from https://www.mathworks.com/matlabcentral/answers/1655855-why-power-series-plot-is-not-matching-with-ode#comment_2000660 . If you count, it has about 50 inflection points -- places where the plot changes direction between up and down. That means that it has at least 50 places where the derivative is 0. But in order to have 50 places with derivative 0 expressed as a polynomial (which your power series expansion is), you need a polynomial of degree 50; a polynomial of degree 10 has no chance.
Also, you are plotting only 20 points; you cannot possibly see 50 changes of direction in only 20 points. You would need at least 101 points to see 50 changes of direction.
If you try to extend numerically to higher degrees, higher maximum i, then i = 15 is as high as your code can go before some of the coefficients overflow to infinity.
If you switch to symbolic computation and ask to go higher degree.. then it takes a long time. And you tend to get points evaluated to be on the order of 10^27000.
At this point you have several possibilities to consider:
  • that if you evaluated to a "high enough" degree symbolically, that you just might get a decent interpolation over t = 1 to t = 20
  • that, because the minimum degree for replicating the plot is at least 50, and you are evaluating out to t = 20, you are going to have constant * 20^50 ~~ 10^65 and you are hoping for final results in the order of +/- 20... you are going to need to evaluate symbolically to extra digits or else the values you want will disappear as noise
  • that since the system appears to have an infinite number of changes of direction (we can mentally interpolate that there will be many more peaks at increasing x), that any finite polynomial approximation might perhaps be too badly conditioned to be useful, calculations that might work in theory but are more like balancing on the edge of a pin numerically
  • your implementation for calculating the coefficients might be wrong. But as I have taken the equations and implemented them in a different software package, I know that even if you got a detail wrong, that the proper plot looks a lot like the first plot, and an order 10 series expansion for x looks a lot like what you plotted, so even if you got a detail wrong, the exact same challenges would be sure to happen even if you had the details perfect.

Sign in to comment.

dear sir this is the paper which is solve by power series method

12 Comments

page no 32 lorenz system
sorry not on page 32 but equation no 32 to 34 fig4 ,fig5
Equations (34) are different from what you define in the three lines
a(i+1)=(c1*(b(i)-a(i)))/(i+1);
b(i+1)=((c2-c(i))*a(i)-b(i))/(i+1);
c(i+1)=(a(i)*b(i)-c3*c(i))/(i+1);
same but we have use no Ti Zi in this equation simply using summation ai*t^i in place of u ,v ,w
t=1:20;
a(1)=1;
b(1)=0;
c(1)=1;
sigma=10;
r=28;
d=(8/3);
sumA=0;
sumC=0;
sumB=0;
sumS=0;
sumZ=0;
for i=1:30
for p=1:29;
sumS=sumS+(a(p).*c(i-p));
sumZ=sumZ+(a(p).*b(i-p));
a(i+1)=((sigma)/(i+1))*(a(i)-b(i));
b(i+1)=(1/(i+1))*(r*a(i)-b(i)-sumS);
c(i+1)=(1/(i+1))*(sumZ-d*c(i));
sumA=sumA+a(i).*(t^i);
sumB=sumB+b(i).*(t^i);
sumC=sumC+c(i).*(t^1);
end
end
plot(t,sumB)
tthese are the program
Have another look at your newest code here. Inside the for p loop, you have
sumS=sumS+(a(p).*c(i-p));
b(i+1)=(1/(i+1))*(r*a(i)-b(i)-sumS);
so the b coefficients depend upon a cumulative sum for S. Compare that to your previous code postings here, in which none of the terms are built around cumulative sums. That is a significant difference in your code, and needs to be validated.
Question: Your sumS and sumZ are initialized before the for i loop, so they are being added to for each i value and each p value. Are you sure that is correct? Or should they be reinitialized for each i value?
Question: your a(i+1) and so on, are being overwritten for each p value within each i value. Are you sure that is correct?
Quesiton: your sumA and so on, are being added to for for each p value within each i value. Are you sure that is correct?
use equation 34 fig 4 ,5 matching so i thik program is right
sir if you find error in code pl correct it
p=8/3;
r=25;
sigma=10;
npoints =5;
dt = 0.1;
a = zeros(npoints,1);
b = zeros(npoints,1);
c= zeros(npoints,1);
t = zeros(npoints,1);
t=1:dt:100;
a(1)=1;
b(1)=1;
c(1)=1;
suma=0;
sumb=0;
sumc=0;
sumS=0;
sumZ=0;
for i = 1:npoints-1
sumS=sumS+a(1)*c(i-1);
sumZ=sumZ+a(1)*b(i-1);
a(i+1)=((sigma)/(i+1))*(b(i)-a(i));
b(i+1)=(1/(i+1))*(r*a(i)-b(i)-sumS);
c(i+1)=(1/(i+1))*(sumZ-p*c(i));
suma=suma+a(i).*(t^i);
sumb=sumb+b(i).*(t^i);
sumc=sumc+c(i).*(t^i);
t(i+1) = t(i) + dt;
end;
plot(t,sumx)
lorenz power series program pl help to solve having minor problem in program
pl solve the lorenz system by power series
I have been working for about 18 hours. I need rest.

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Products

Release

R2021b

Asked:

on 22 Feb 2022

Commented:

on 24 Feb 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!