New Reply

Taylor and Euler Matlab Comparison for Numerical Analysis.

 
Share Thread Thread Tools
Apr25-12, 01:55 AM   #1
 

Taylor and Euler Matlab Comparison for Numerical Analysis.


1. Solve y'=3t^2y^2 on [0, 3] , y0 = −1, using Euler method and Taylor method of
order 3. Compare your solutions to the exact solution. y(t)=(-1/((t^3)+1))


I DONT KNOW WHAT IS WRONG WITH MY PROGRAM! PLEASE HELP =D
2. Relevant equations

http://en.wikipedia.org/wiki/Euler_method
http://math.fullerton.edu/mathews/n2...ylorDEMod.html

3. The attempt at a solution
function Euler2(a,b,h,y0)
t0=a;
t(1)=t0;
y(1)=y0;
N=(b-a)/h;

for i=1:N
y(i+1)=y(i)+h*(func(t(i),y(i)));
t(i+1)=t(i)+h;
end
-----------------------------------------
function deriv=func(t,y)
deriv=3*t^2*y^2;
-----------------------------------------
function w=Taylor1(a,b,h)
t0=a;
y0=1;
t(1)=t0;
y(1)=y0;
N=(b-a)/h;
w(1)=1;

%2nd Order Taylor Method%
for i=2:N+1
w(i)= w(i-1)+h*(1-h+(h^2)/2);
t(i)= a+i*h;
end

%3rd Order Taylor Method%
for i=2:N+1
w(i)= w(i-1)*(1-h+(h^2)/2-(h^3)/6);
t(i)= a+i*h;
end
------------------------------------------------
a=0;
b=3;
y0=-1;
h=0.1;
t=a:h:b;

w1=Euler2(a,b,h);
w2=Taylor2(a,b,h);

plot(t,w1,'r')
hold on
plot(t,w2,'b')
hold on
plot(t,-1/(t^3+1),'g')
--------------------------------------
 
PhysOrg.com
PhysOrg
science news on PhysOrg.com

>> Hong Kong launches first electric taxis
>> Morocco to harness the wind in energy hunt
>> Galaxy's Ring of Fire
Apr25-12, 05:22 AM   #2
 
Recognitions:
Homework Helper Homework Help
Is there good agreement with the exact integral?
 
Apr25-12, 12:52 PM   #3
 
Oh I just don't know what is wrong with my program. I get the theory behind it!
 
New Reply

Tags
code, euler, matlab, numerical analysis, taylor
Thread Tools


Similar Threads for: Taylor and Euler Matlab Comparison for Numerical Analysis.
Thread Forum Replies
Matlab - Numerical Analysis Engineering, Comp Sci, & Technology Homework 1
numerical analysis w/euler's method Calculus & Beyond Homework 5
Numerical Analysis Euler's Method Calculus & Beyond Homework 3
Numerical Analysis: Taylor Polynomials, Error, Bounds Calculus & Beyond Homework 0