Answered step by step
Verified Expert Solution
Question
1 Approved Answer
MATLAB sessions: Laboratory 3 MAT 275 Laboratory 3 Numerical Solutions by Euler and Improved Euler Methods (scalar equations) In this session we look at basic
MATLAB sessions: Laboratory 3 MAT 275 Laboratory 3 Numerical Solutions by Euler and Improved Euler Methods (scalar equations) In this session we look at basic numerical methods to help us understand the fundamentals of numerical approximations. Our objective is as follows. 1. Implement Euler's method as well as an improved version to numerically solve an IVP. 2. Compare the accuracy and eciency of the methods with methods readily available in MATLAB. 3. Apply the methods to specic problems and investigate potential pitfalls of the methods. Instructions: For your lab write-up follow the instructions of LAB 1. Euler's Method To derive Euler's method start from y(t0 ) = y0 and consider a Taylor expansion at t1 = t0 + h: y(t1 ) = y(t0 ) + y (t0 )(t1 t0 ) + . . . = y0 + hf (t0 , y(t0 )) + . . . = y0 + hf (t0 , y0 ) + . . . For small enough h we get an approximation y1 for y(t1 ) by suppressing the . . ., namely y1 = y0 + hf (t0 , y0 ) (L3.1) The iteration (L3.1) is repeated to obtain y2 y(t2 ), . . . such that yn+1 tn+1 = = yn + hf (tn , yn ) tn + h Geometrically, the approximation made is equivalent to replacing the solution curve by the tangent line at (t0 , y0 ). From the gure we have y1 y0 f (t0 , y0 ) = f (t0 , y(t0 )) = y (t0 ) = tan = , h y(t1 ) y1 s s y0 .... ... ... .. from which (L3.1) follows. h As an example consider the IVP y = 2y = f (t, y) t0 t1 with y(0) = 3. Note that here f does not explicitly depend on t (the ODE is called autonomous), but does implicitly through y = y(t). To apply Euler's method we start with the initial condition and select a step size h. Since we are constructing arrays t and y without dimensionalizing them rst it is best to clear these names in case they have been used already in the same MATLAB work session. >> clear t y % no comma between t and y! type help clear for more info >> y(1)=3; t(1)=0; h=0.1; c 2011 Stefania Tracogna, SoMSS, ASU MATLAB sessions: Laboratory 3 Since f is simple enough we may use the inline syntax: >> f=inline('2*y','t','y') f = Inline function: f(t,y) = 2*y Note that the initialization y(1)=3 should not be interpreted as \"the value of y at 1 is 3\
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started