You are on page 1of 1

2nd Assigment

Numerical Computation (TKU 602/S-2)


Instructor: Dr.Eng. Sunu Wibirama, S.T., M.Eng.
You can use Bahasa Indonesia to answer this assignment. Dont forget to
put your name and your student number in the report. The report should
be submitted in hand-written (for pen-and-paper problem) and printed (for
programming problems) next week, direct submission to Dr. Sunu before the
class begins.

0.1

Pen-and-paper problem (F4 paper with line)

f (x) = (x+1)3 (x1) obviously has roots at x = 1 and x = +1. Using starting
values that differ from the roots by 0.1, compare the number of iterations taken
when Newtons method computes both of the roots until they are within 0.0001
of the correct values.

0.2

Programming problem (A4 paper)

1. Write a MATLAB user-defined function that solves for a root of a nonlinear equation f (x) = 0 using the bisection method. Name of the function
is: Xs = BisectionRoot(Fun,a,b)
The output argument Xs is the solution. The input argument Fun is a
name for the function that calculates f (x) for a given x (it is a dummy
name for the function that is imported into BisectionRoot); a and b are
two points that bracket the root. The iterations should stop when the
tolerance  in f (x) is smaller than 0.000001. Note that  is difference between true soluton f (XT S ) and numerical solution f (XN S ):
T oleranceInf = |f (XT S ) f (XN S )| = |0 | = ||
The program should check if points a and b are on opposite sides of the
solution. If not, the program should stop and display an error message.
2. Use the function BisectionRoot to determine the roots of
f (x) = x 2ex (start with a = 0 and b = 1). What is the result?

You might also like