Homework 6 Solution

$29.99 $18.99

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 Heun scheme. The function should be of the form function [y,t] = AB3(fun,y0,T,DT,IOSTEP) Input: fun:…

You’ll get a: . zip file solution

 

 
Categorys:
Tags:

Description

Rate this product

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

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

dy1(t)

= y1(t) + y2(t)y3(t)

dt

>

dy2(t)

= y2(t) + (y3(t) 2)y1(t)

(3)

>

>

dt

>

>

<

>

>

>

dy3(t)

= 1 y1(t)y2(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= 1e-3, 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:

  1. The plots of the trajectories y1(t), y2(t) and y3(t) versus time in figure(1).

  1. A three-dimensional plot of the curve (y1(t); y2(t); y3(t)) in figure(2) (use the command plot3()).

2