## Description

__Tutorial:__Read pages 12-31 in the tutorial. Pay attention to for loops, functions, plotting, and di er-ential equations. Reproduce results as you read. Take advantage of the \help” command in Scilab.

- Basic coding: Using the command window, solve problem 1 of section 1.4 in the text using these steps.

- Create a Scilab function for right hand side function f(t; y).

- De ne variables y0; t0; tN; dt; t where

y0 = y(0); t0 = t(0); tN = end time; dt = t; t = a vector containing all time points:

- Write a for loop which computes (forward) Euler’s method approximations using the above func-tion and variables. Store your solution in a new vector y which contains the Euler approximation at all time points.

- Plot y against t to visualize your approximation solution solution.

- Find the true solution. Add it to the approximate solution plot for comparison.

__Euler’s method:__In SciNotes de ne a function called \Euler” for solving the general rst order equation

dy | = f(t; y); y(0) = y_{0}; |
0 t t_{N} ;t = |
1 |

dt | N |

You should use your work from the previous problem.

- The inputs are \y0; t; f” as described in the previous problem.

- The output of the function is \y”, the Euler’s method approximation.

- Test your function on problems 1-4 in section 1.4 of the text with various choices of t.

- Reproduce the results in Tables 1.7/1.8 in the text. Use a matrix to store and print the results. Plot these two approximate solutions with the true solution.

- Instability and backwards Euler: In class we showed forward Euler is unstable when solving the sti

ODE

dy | = 100y; y(0) = 1: |

dt | |

That is, t has to be very small otherwise forward Euler blows up.

- Use forward Euler to solve this problem for 0 t
_{10}^{1}with various choices of t. How small does t have to be to see convergence? Graph your numerical solutions with the true solution.

- Backward Euler for any rst order equation
^{dy}_{dt}= f(t; y) is given by

^{y}n+1 ^{y}n |
= f(t_{n+1}; y_{n+1}): |

t | |

Note that you need to solve an equation for y_{n+1} at each step. Implement backward Euler for this problem with various choices of t.

- Improving Euler: Averaging forward and backward Euler gives centered Euler’s method. That is,

(a) Forward Euler: ^{y}^{n+1} ^{y}^{n} = fn

t

(b) Backward Euler: ^{y}^{n+1} ^{y}^{n} = fn+1

t

(c) Centered Euler: ^{y}^{n+1} ^{y}^{n} = __ ^{1}__ (fn + fn + 1)

t 2

Note, centered Euler is an implicit method (as was backward Euler). Implement centered Euler and compare it to backward Euler for the previous problem. Which is more accurate? Plot both solutions along with the true solution.

- (Bonus Problem!) Use Taylor series to nd the rate of convergence of backward and centered Euler.

- (Bonus Problem!) Show stability requirements of centered Euler as done in class for forward and backward Euler.

1