0% found this document useful (0 votes)
55 views

MATLAB Exercise

This document provides 12 questions asking the student to develop MATLAB code to implement various numerical methods and solve example problems using those methods. The methods include bisection, false position, Newton-Raphson, secant, Gaussian elimination, LU decomposition, Thomas algorithm, Gauss-Seidel iteration, Lagrange interpolation, Trapezoidal rule, Simpson's 1/3 rule, Euler's method, and 4th-order Runge-Kutta. Example problems involve finding roots of equations, solving systems of linear and tridiagonal equations, numerical integration, and solving ordinary differential equations.

Uploaded by

WenKhai Lim
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views

MATLAB Exercise

This document provides 12 questions asking the student to develop MATLAB code to implement various numerical methods and solve example problems using those methods. The methods include bisection, false position, Newton-Raphson, secant, Gaussian elimination, LU decomposition, Thomas algorithm, Gauss-Seidel iteration, Lagrange interpolation, Trapezoidal rule, Simpson's 1/3 rule, Euler's method, and 4th-order Runge-Kutta. Example problems involve finding roots of equations, solving systems of linear and tridiagonal equations, numerical integration, and solving ordinary differential equations.

Uploaded by

WenKhai Lim
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

Q1.

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

Where v(t ) = velocity of parachutist = 40 m / s ,


g = gravitational constant = 9.8 m / s 2 ,
m = the mass of the parachutist = 68.1 kg .
Find the drag coefficient, c at the time t 10 seconds using the initial bracket of
the root as [13, 16] and iterate until a 0.001 %.
Q2.

Develop an M-file to implement the falseposition 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

Where v(t ) = velocity of parachutist = 40 m / s ,


g = gravitational constant = 9.8 m / s 2 ,
m = the mass of the parachutist = 68.1 kg .
Find the drag coefficient, c at the time t 10 seconds using the initial bracket of
the root as [13, 16] and iterate until a 0.001 %.
Q3.

Locate the root of f ( x) 2 sin( x ) x


(a)
Using the MATLAB function fzero with an initial guess of
x0 2 .
(b)
Using Newton-Raphson method by writing a function M-file. Use an
initial guess of x 0 0.5 and iterate until a 0.001 %.

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.

Find the solution of the following set of linear algebraic equations


x 2 y 3z 1
3x 3 y 4 z 1
2 x 3 y 3z 2

(a) Using the left-division \.


(b) Using Gaussian elimination.

(c) Using the LU decomposition.


[Hint: Since [LU]x = b, let [U]x = y, so that [L]y = b. Now, first solve for
y and then for x.]
Q6.

Develop a function M-file


with the Thomas algorithm.
f1 g 1

e2 f 2 g 2

e3 f 3 g 3

.
.

Tridiag.m to solve the following tridiagonal system

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.

Develop a script M-file to estimate f ( 2.75) using Lagrange interpolating


polynomials of order 1, 2 and 3 for the following data.
x
f(x)

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 )

The force on a sailboat mast can be represented by the following function:


F

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 .

the MATLABtrapz function.


Q10. Develop an M-file to implement Simpsons 1/3 rule. Using your program solve
the following problem.
The velocity of falling parachutist is given as
v(t )

gm
(1 e ( c / m ) t ) .
c

Where v (t ) = velocity of parachutist,


g = gravitational constant = 9.8 m / s 2 ,
m = mass of the parachutist = 45 kg ,
c = the drag coefficient = 32.5 kg / s .
If the distance, d, traveled by the parachutist is given by
6

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 .

You might also like