Anda di halaman 1dari 2

Assignment1

(Be sure to observe the rules about handing in homework)


1. The Maclaurin series expansion for cos x is
cos x 1

x 2 x 4 x 6 x8

2! 4! 6! 8!

a) (20 points) Write a MATLAB program to compute cos x using the series above. Inputs to your

program will be x (in radians) and s, the pre-specified approx. relative error (%). Your program
should print the final cos x value obtained along with the true and approximate errors. Your program
need to get the true value of cos x using the built-in cos(.) function in MATLAB. Submit your code.
b) (5 points) Run your program to estimate the value of cos( / 3) with less than 0.5% error. In other

words, choose your inputs as x = /3 and s=0.5%. Print your result along with the final error values
(true and approximate percent relative errors). You need to add the terms in the Maclaurin series until
the approx. percent relative error falls below 0.5%.
2. Derive the Taylor series expansion for f(x) = ln(x) using a base point at xi = 1 and analyze the
convergence properties with the help of MATLAB.
a. (10 points) Show all of the steps to obtain the following result (at least 5 terms):

ln( x ) ( x 1)

( x 1) 2 ( x 1)3 ( x 1) 4 ( x 1)5

...
2
3
4
5

b. (10 points) Write a MATLAB program which takes x as input and computes the series for up to 100
terms. Submit your source code.
c. (5 points) Run your program for x = 1.94 and report the result you get for ln(x=1.94).
How accurate is your result?
d. (5 points) Run your program for x = 2.1 and report the result you get for ln(x=2.1)
How accurate is your result?
e. (5 points) Comment about your findings
3. Locate the first nontrivial root of sin x = x3 where x is in radians.
a) (10 points) Use a graphical technique and
b) (20 points) Bisection method with the initial interval from 0.5 to 1. Perform the computation
until a is less than s 2% . Also perform an error check by substituting your final answer into
the original equation. For the bisection method, write the formulas used in your calculations
and fill out the following table.
i
1
2
3
4
5

xl

f(xl)
0.5

xu

f(xu)
1

xr

f(xr)

4. Determine the lowest positive root of: f(x)

= 8 e-x sin (x) - 1

(a) (10 pts) Using the Newton-Raphson method (three iterations, x0 = 0.3). Write all of the formulas used
in your calculations and fill out a table similar to the following:
i
0
1

xi
0.30

f(xi)

f(xi)

(b) (10 pts) Using the secant method (four iterations, x-1 = 0.5 and x0 = 0.4). Write all of the formulas used
in your calculations and fill out a table similar to the following:
i
0
1

xi1
0.50

f(xi1)

xi
0.40

f(xi)

(c) (10 pts) Using the modified secant method (three iterations, x0 = 0.3, = 0.01). Write all of the
formulas used in your calculations and fill out a table similar to the following:
i
0
1

xi
0.30

Anda mungkin juga menyukai