Page 17 - Numerical Analysis Using MATLAB and Excel
P. 17
Chapter 1 Introduction to MATLAB
Example 1.2
Find the roots of the polynomial
2
4
5
p x() = x – 7x + 16x + 25x + 52 (1.2)
2
Solution:
There is no cube term; therefore, we must enter zero as its coefficient. The roots are found with the
statements below where we have defined the polynomial as p2, and the roots of this polynomial as
roots_ p2.
p2=[1 −7 0 16 25 52]
p2 =
1 -7 0 16 25 52
roots_ p2=roots(p2)
roots_ p2 =
6.5014
2.7428
-1.5711
-0.3366 + 1.3202i
-0.3366 - 1.3202i
The result indicates that this polynomial has three real roots, and two complex roots. Of course,
*
complex roots always occur in complex conjugate pairs.
1.3 Polynomial Construction from Known Roots
We can compute the coefficients of a polynomial from a given set of roots with the poly(r) func-
tion where r is a row vector containing the roots.
Example 1.3
It is known that the roots of a polynomial are 123 and 4,,, . Compute the coefficients of this
polynomial.
Solution:
We first define a row vector, say r3 , with the given roots as elements of this vector; then, we find
the coefficients with the poly(r) function as shown below.
* By definition, the conjugate of a complex number A = a + jb is A∗ = ajb
–
1−4 Numerical Analysis Using MATLAB® and Excel®, Third Edition
Copyright © Orchard Publications