Docsity

MCEN 3030 Homework 3: Secant Method and Polynomial Root Finding, Assignments of Mechanical Engineering

Toggle sidebar
bg1
1
MCEN 3030: Homework 3 (80pts)
Due date: Friday, February 25th, 2006 at the beginning of the lecture.
Secant method (20pts)
Show that the iteration defined by :
x(k)=x(k−2) −
f(x(k−2))(x(k−1) −x(k−2))
f(x(k−1))−f(x(k−2))(1)
is equivalent to
x(k)=x(k−1) −
f(x(k−1))(x(k−1) −x(k−2))
f(x(k−1))−f(x(k−2)).(2)
Hints: multiply across the first equation by f(x(k−1))−f(x(k−2)) then use
the fact that 0 = f(x(k−1))x(k−1) −f(x(k−1))x(k−1) . There are other ways to
show this...
Polyalgorithms (50pts)
It is impossible to find a general closed form solution to polynomials of degree
higher than 4 (A young mathematician named Evariste Galois (1811 −1832)
proved this). Consequently, whenever we are faced with such a situation, we
need to use numerical methods to find the roots of a polynomial (unless the
polynomial has a special form).
In this section of the homework you will build a general ”root” finder for
polynomials in matlab. Is is easy to encode polynomials on a computer. It is
possible to write:
pN(x) =
N
X
j=0
ajxj(3)
such that only the vector a= (a0, a1, ..., aN)Tand a certain xare necessary
to evaluate the polynomial. Evaluating the polynomial in its summation form
is rather inefficient. Instead, we will use Horner’s method
given x and a(0),a(1),...a(N)
set: p = a(N)
do k=N-1,N-2,...,0
p=a(k) + x*p
end do
pf3
pf4

Partial preview of the text

Download MCEN 3030 Homework 3: Secant Method and Polynomial Root Finding and more Assignments Mechanical Engineering in PDF only on Docsity!

MCEN 3030: Homework 3 (80pts)

Due date: Friday, February 25th, 2006 at the beginning of the lecture.

Secant method (20pts)

Show that the iteration defined by :

x(k)^ = x(k−2)^ −

f (x(k−2))(x(k−1)^ − x(k−2)) f (x(k−1)) − f (x(k−2))

is equivalent to

x(k)^ = x(k−1)^ −

f (x(k−1))(x(k−1)^ − x(k−2)) f (x(k−1)) − f (x(k−2))

Hints: multiply across the first equation by f (x(k−1)) − f (x(k−2)) then use the fact that 0 = f (x(k−1))x(k−1)^ − f (x(k−1))x(k−1). There are other ways to show this...

Polyalgorithms (50pts)

It is impossible to find a general closed form solution to polynomials of degree higher than 4 (A young mathematician named Evariste Galois (1811 − 1832) proved this). Consequently, whenever we are faced with such a situation, we need to use numerical methods to find the roots of a polynomial (unless the polynomial has a special form). In this section of the homework you will build a general ”root” finder for polynomials in matlab. Is is easy to encode polynomials on a computer. It is possible to write:

pN (x) =

∑^ N

j=

aj xj^ (3)

such that only the vector a = (a 0 , a 1 , ..., aN )T^ and a certain x are necessary to evaluate the polynomial. Evaluating the polynomial in its summation form is rather inefficient. Instead, we will use Horner’s method

given x and a(0),a(1),...a(N)

set: p = a(N)

do k=N-1,N-2,..., p=a(k) + x*p end do

where at the end p will contain the value of the polynomial encoded with the ai evaluated at x. Since our root finding algorithm will be Newton-Raphson we will need a way to derive the polynomial. The following algorithm gives both in order N operations:

given x and a(0),a(1),...a(N)

set: pprime = 0. set: p = a(N)

do k=N-1,N-2,..., pprime=p + pprime * x p=a(k) + x*p end do

Once one of the roots rk is found, we need to divide the the polynomial pN (x) by x − rk. The pseudo code doing this is

given rk and a(0),a(1),...a(N)

set: b(N-1) = a(N)

do i = N-1,N-2,..., b(i-1) = a(i) + r1 * b(i) end do rem = a(0) + r1 * b(0)

where rem is not a music band but the remainder of the division and the bi=0, 1 ,...,N − 1 are encoding the new (deflated) polynomial. The last function that needs to be coded in matlab is the closed formula for the roots of a quadratic polynomial ax^2 + bx + c. I will assume that you know this formula and that you can code such a function in matlab. It is now possible to combine all these algorithms together to build a general polynomial root finder.

Code the vertices of a triangle (x 1 , y 1 ) = (0, 0), (x 2 , y 2 ) = (1, 0) and (x 3 , y 3 ) = (1/ 2 ,

3 /2). Given a maximum number of iterations M generate and keep the points given by the follow pseudo code:

given the 3 corners of the triangle and M set: iter= set: px(1)=x_ set: py(1)=y_

do while (iter < M) (x,y) = randomly select one of the corners of the triangle px(iter+1) = (px(iter) + x)/ py(iter+1) = (py(iter) + y)/ iter=iter+ end do

Generate 10000 points and plot the sequence using matlab (not lines). Hint: use floor(1+ 3*rand(1)) to get random integers [1, 2 , 3] for your triangle corners. Attach this ”m” file to the email with the other ”m” files.