MATLAB Exercise
MATLAB Exercise
Develop an M-file to implement the bisection method. Using this program solve
the following problem.
The velocity of falling parachutist is given as
v (t )
gm
(1 e ( c / m )t ) .
c
gm
(1 e ( c / m )t ) .
c
Q4.
Develop an M-file to implement the modified secant method. Using this program
determine the loest positive root of f ( x) 8 sin( x ) e x 1 with an initial guess
of x0 0.3 and 0.01 . Iterate until a 0.000001% .
Q5.
e2 f 2 g 2
e3 f 3 g 3
.
.
x1
x2
x3
.
.
.
.
.
e n 1
.
f n 1
en
g n 1
f n
r1
r2
r3
. .
. .
. .
x n 1 rn 1
x n rn
Thomas Algorithm:
(i)
Decomposition:
e
ek k and
f k 1
f k f k ek . g k 1 , where k 2,3,4, , n .
(ii)
(iii)
Q7.
Forward substitution:
rk rk e k . rk 1 , where k 2,3,4, , n .
Back substitution:
r
xn n
fn
(rk g k . x k 1 )
and x k
, where k n 1, n 2, ,2,1 .
fk
Using your program, solve the following tridiagonal system.
x1 4.175
0.020875
2.01475
x
0.020875
2.01475
0.020875
0
0.020875
2.01475
0.020875
0
x3 =
0.020875
2.01475
2.0875
x
4
Develop a MATLAB script file to determine the solution of the following system
of linear equations using the Gauss-Seidel iteration method by performing first
seven iterations.
9 x1 2 x2 3x3 2 x4 54.5
2 x1 8 x2 2 x3 3x4 14
3x1 2 x 2 11x3 4 x4 12.5
2 x1 3x 2 2 x3 10 x 4 21
Q8.
0
0
1
0.5
2
0.8
3
0.9
4
0.941176
5
0.961538
For each estimate find the true percent relative error if the try function is given by
f ( x)
Q9.
x2
.
(1 x 2 )
z 2.5 z / H
200
dz
e
7 z
where z the elevation above the deck and H the height of the mast.
Compute F for the case where H 30 using
(i)
the M-file for Trapezoidal rule with the step size h 0.1 .
gm
(1 e ( c / m ) t ) .
c
v(t )dt ,
0
find the distance using Simpsons 1/3 rule for the segments 10, 20, 50, and 100.
Q11.
Develop an M-file for Eulers method to solve a first order ordinary differential
equation (ODE).
i(t)
E
The current around the circuit at time t is governed by the following differential
equation
3
di
2i 3e 2 t ,
dt
i (0) 2 .
Using your program, solve the above initial value problem over the interval from
t 0 to 2 with the step size h 0.1 .
Q12. Develop an M-file for Fourth-Order Runge-Kutta method to solve a first order
ordinary differential equation (ODE).
Using your program solve the following initial value problem over the interval
from x 0 to 2 with the step size h 0.2 .
dy
x2 y ,
dx
y (0) 0.8 .