Sie sind auf Seite 1von 2

FM 3004-Numerical Methods for Finance

Practical Assessment
Date:2014/05/30
Duration: 50 minutes
Instructions:
1) Create a folder with YOUR INDEX NUMBER on the desktop.
2) Set MATLAB path to this folder.
3) Save all the M-files and diary files* that you create in this folder.
*Diary files are special types of MATLAB files which enable you to record all the actions in a certain
session.
Creating Diary Files
1) Just after opening MATLAB command window type and enter the following command.
diary index_no.out
diary on
2) After finishing all the work (at the end of the exam) type and enter the following command.
diary off
If you follow above steps then your diary file will be automatically saved in the folder that you have
already created.
1) Consider the following system.


a) Find the condition number of the above system using suitable MATLAB function. Using
the value of the condition number, state whether the system is well-conditioned or ill-
conditioned.
b) Solve the system using Jacobi iteration method. (n=20 and



2) Consider the ODE

with the initial condition (0) =2.


a) Write a MATLAB function/s to solve the above ODE by using Eulers method when = 0.2
and .
b) Plot against .

Marking Scheme
1) a)
A=[4 2 1;1 3 1; 1 1 4 ];
cond(A,'fro') 2 marks

b)
function X=jacobi(A,B,P,n)
N=length(B);
for i=1:n
for j=1:N
X(j)=(B(j)-A(j,[1:j-1,j+1:N])*P([1:j-1,j+1:N]))/A(j,j)
end
P=X';

end 8 marks

2)
a) function

function X=func(x,y)
X=exp(x)-2*y; 2 marks

euler
function Y=eulermethod(h,x0,y0)
n=(5-0)/h;
x=x0;
y(1)=y0;
for k=1:n
y(k+1)=y(1,k)+h*func(x,y(k))
x=x+h;

end
y=y'
x=[0:h:5]';
plot(x,y) 6 marks


b)
2 marks total 20 marks

Das könnte Ihnen auch gefallen