Description
Please submit to CANVAS a .zip le that includes the following Matlab functions:
tridiag solver.m
AB3.m
solve ODE system.m
Exercise 1 Write a Matlab function that implements the Thomas algorithm to solve tridiagonal linear systems of equations in the form

^{2} a_{1}
c_{1}
0
._{. .}
6
e_{1}
.^{a}_{.}^{2}
.^{c}_{.}^{2}
._{.}
.
6
0
..
6
6
_{.}. ._{.}
.
an
1
6
.
6
6
6
0
0
e_{n}
1
4
0 
3 
2 
x_{1} 
3 
2 
b_{1} 
3 

0 
7 
x_{2} 
b_{2} 

0 
6 
_{.}. 
7 
= 
6 
_{.}. 
7 
(1) 

7 
. 
. 

7 
6 
7 
6 
7 

^{c}n 1 
7 ^{6} 
^{x}n 1 
7 
6 
^{b}n 1 
7 

7 
6 
7 
6 
7 

7 
6 
7 
6 
7 

a_{n} 
7 
6 
^{x}n 
7 
6 
^{b}n 
7 

7 
6 
7 
6 
7 

5 
4 
5 
4 
5 
The function should be in the form
function x = tridiag solver(e,a,c,b)
Input:
e=[e_{1} e_{2} e_{n} _{1}] a=[a_{1} a_{2} a_{n}] c=[c_{1} c_{2} c_{n} _{1}] b=[b_{1} b_{2} b_{n}]^{T}
Output:
x: solution to the linear system (1) (column vector)

Exercise 2 Consider the system of nonlinear ordinary di erential equations
8
_{dt} = f(y(t); t)
(2)
dy(t)
<
: y(0) = y_{0}
where f : R^{n} [0; T ] ! R^{n}, y : [0; T ] ! R^{n}. Write a Matlab function that solves the system (2) by using the thirdorder AdamsBashforth scheme. To startup the scheme ( rst two steps) use the
Heun scheme. The function should be of the form
function [y,t] = AB3(fun,y0,T,DT,IOSTEP)
Input:
fun: function handle representing f(y; t)
y0: column vector representing the initial condition
T: period of integration
DT: time step
IOSTEP: Input/output step. The solution is saved in the output matrix y every IOSTEP steps.
Output:
y: n S matrix collecting the time snapshots of the solution to (2). Note that the total number of snapshots S (including the initial condition) is floor(T/(IOSTEP*DT))+1.
t: vector collecting the time instants at which the solution is saved in the output matrix y.
Exercise 3 Consider the following nonlinear dynamical system
>

8
dy_{1}(t)
= y_{1}(t) + y_{2}(t)y_{3}(t)
dt
>
dy_{2}(t)
= y_{2}(t) + (y_{3}(t) 2)y_{1}(t)
(3)
>
>
dt
>
>
<
>
>
>
dy_{3}(t)
= 1 y_{1}(t)y_{2}(t)
dt
>
:
It is known that the solution to (3) is chaotic in time and it settles on a strange attractor. By using the function AB3.m you coded in Exercise 2, compute the numerical solution to (3). To this end, set NSTEPS=1000000, IOSTEP=50, DT= 1e3, y0=[1 2 3]^{T} , and write a function
function [y,t]=solve ODE system()
Output:
y: 3 S matrix collecting S time snapshots of the solution to (3). Here, S=floor(NSTEPS/IOSTEP)+1.
t: vector collecting the time instants at which the solution is saved in the output matrix y.
The function solve ODE system should also return the following items:

The plots of the trajectories y_{1}(t), y_{2}(t) and y_{3}(t) versus time in figure(1).

A threedimensional plot of the curve (y_{1}(t); y_{2}(t); y_{3}(t)) in figure(2) (use the command plot3()).
2