Professional Documents
Culture Documents
LAB#4:
POLYNOMIALS IN MATLAB
Introduction:
A polynomial is an expression in which a finite number of constants and variables are
combined using addition subtraction multiplication and non-negative whole number
exponents (raise to power). Thus the following expressions are all considered polynomials.
2
x + 2 x−7
4 3
x −7 x
x
The MATLAB software provides built-in functions for standard operation on polynomials such
as arithmetic operation like multiplication and division etc., evaluation of roots,
differentiation, and integration and so on. In addition there are functions for more advance
applications such as curve fitting. Polynomials have a very significant role to play in
engineering system analysis. The polynomial functions are stored in a polyfun directory in
MATLAB.
Entering a Polynomial:
In MATLAB, a polynomial is represented by a row vector. Polynomials are entered with
variable term arranged in descending order of its power. Only the coefficient of variable terms
are entered i.e. variables are not entered. The left most term is the highest power term of the
variable and the right most term is the constant term with variables raise to the power zero.
The total number of term is always one more than the order of the polynomial. The coefficient
of polynomial is entered as an element of a row vector and can be separated from each other
by blank space or comma. For example:
p ( x ) =x 4 +3 x3 −15 x 2−2 x +9
MATLAB MANUAL 1
SESSION: 2018-2022 CIVIL ENGINEERING DEPARTMENT
MATLAB can interrupt a vector of length (n+1) as an nth order polynomial. Thus, if there are
missing terms, zeroes must be entered in the appropriate places in the vector.
e.g. y=x 3 +1
Two zeroes have been included in a vector to account for missing powers of x, i.e. x 2 and x .
Z = Dividend vector,
Division of Two y = Divisor vector,
[ x , r ]=deconv (z , y )
Polynomials x = Vector of quotients obtained,
r = vectors of remainders obtained.
MATLAB MANUAL 2
SESSION: 2018-2022 CIVIL ENGINEERING DEPARTMENT
ILLUSTRATIVE PROGRAMS:
Task#1:
Obtain the Values of the following Polynomials at x=-2, 4, 5 and 2+3i?
P(x) = x2 +4x +1.
P(x) = x2 + 1
P(x) = x2 +4x + 2.
Task#2:
Find the Roots of the following Polynomials?
P1 = x2 + 3x +2.
P2 = x4 + 4x3 + 9x +2.
P3 = x5 + 1.
P4 = x3 + 3x2 + 4x + 1.
Task#3:
Multiply the following Polynomials?
P1 = x + 3.
P2 = x + 6.
P3 = x2 + 4x +6.
Task#4:
Divide Polynomial P by q?
a) P = x3 + 4x +10. Q = x3 + 3x2 + 4x + 2.
b) P = 5x2 + 8x + 2. Q = x2 + x + 2.
c) P = 2x2 + 3x + 1. Q =x2 + x – 1.
Task#5:
Roots of Polynomial are given below find the Corresponding Polynomials?
a) r1 = 2, 4.
b) r2 = -2, -4.
MATLAB MANUAL 3
SESSION: 2018-2022 CIVIL ENGINEERING DEPARTMENT
c) r3 = -2, 4.
d) r4 = -2, 4, 6.
Task#6:
Find Polynomial of Degree 5 for a given Data, for x=12?
X: 2 5 7 9 11 13
Y: 24 156 384 580 650 780
Task#7:
Evaluate the Derivative and Integral of the following Polynomials?
P1 = x4 + 4x3 + 10x2 + 20x + 15, c = 1.
P2 = x3 + x + 10, c = 3.
P3 = x + 5, c = -3.
Task#8:
Express the following system of linear equations into Matrix form and obtain the solution of
the variables x, y, z.
x + y−z=2
−x +3 y−z=2
3 x+ 5 y −2 z =2
MATLAB MANUAL 4