Lecture 06 Polynomial Handling -Computing Tools For Mathematics(COMP1118)

Computing Tools For Mathematics(COMP1118)
Instructor : Engineer Imran Ahmad
University Of Okara (Renala Campus)
Lecture 06
Polynomial Handling



Polynomial
 MATLAB inputs a polynomial of one variable x, as a row vector having as elements.
 The coefficients of the polynomial, real or complex arranged in descending power of x, placed in brackets.
 For example
 γ€–         𝑦(π‘₯)=3π‘₯γ€—^4+γ€–2π‘₯γ€—^3+π‘₯^2βˆ’π‘₯+5;
 Then the Y, MATLAB vector that represents the polynomial y(x) is given by:
  β‰«π‘Œ=[3 2 1 βˆ’1 5];


Polynomial REPRESENTATION IN matlab
 In general, if
y(π‘₯)=π‘Ž_𝑛 π‘₯^𝑛+"anβˆ’" 1"x nβˆ’1"+…+π‘Ž_1 π‘₯+π‘Ž_0
Then the polynomial expressed as a MATLAB vector Y is given by
π‘Œ=[π‘Ž_𝑛   "anβˆ’" 1〖…..   π‘Žγ€—_1 γ€–   π‘Žγ€—_0]
 When some coefficients of a polynomial are not present, then the missing coefficients are entered as zeros. For example:
 γ€–𝑦(π‘₯)=8π‘₯γ€—^7+γ€–6π‘₯γ€—^6+γ€–3π‘₯γ€—^4+π‘₯^2
 Y is given by: π‘Œ=[8 6 0 3 0 1 0 0 ]






Polynomial: roots
  Let p(x) be a polynomial of a single variable (x), define by a row MATLAB vector P.
 Then the MATLAB function r=roots(P) returns the column vector r with the roots of the polynomial p(x).
    Example:  γ€–𝑝(π‘₯)=8π‘₯γ€—^7+γ€–6π‘₯γ€—^6+γ€–3π‘₯γ€—^4+π‘₯^2
 P=[8 6 0 3 0 1 0 0 ];
 r=roots(P)


Evaluate a polynomial
 Let the polynomial p(x) be defined by a row vector P, then the MATLAB function polyval(P,k) return the polynomial p(x) evaluated at x=k

 Example:          π‘(𝑦)=γ€–2𝑦〗^3+3π‘¦βˆ’1

                              p=[2 0 3 -1]
                             
                              polyval(P,0)

Ans: -1




Addition/ Subtraction of Polynomial
MATLAB can perform the addition or subtraction of two polynomials represented by P and Q, only if the two (MATLAB) vectors (P and Q) have the same number of elements(length of size)
 Example:
 γ€–𝑝(π‘₯)=8π‘₯γ€—^4+γ€–6π‘₯γ€—^3+xβˆ’1
γ€–π‘ž(π‘₯)=10π‘₯γ€—^3βˆ’γ€–3π‘₯γ€—^2+6

MUNTIPLICATION OF POLYNOMIALS
 MATLAB function M=conv(P,Q) returns the row vector M consisting of the coefficients of the product of the two polyomials, p(x) by q(x) represented as row vectors P and Q.
 Example:
 p(x)= 5x+2
 q(x)= 2x+7

Partial fraction expansion of polynomial
 let H(x) be a rational function of the form H(x)=P(x)/Q(x) then the partial fraction expansion can be accomplished by using the MATLAB function [r , p ,k]=residue(P,Q)
    where r are the partial fraction coefficients, p the root of Q (also called poles) and k
    represents the gain or stand-alone term.
 Example :  γ€–𝑃(π‘₯)=9π‘₯γ€—^3+γ€–8π‘₯γ€—^2+7π‘₯+6
                〖𝑄(π‘₯)=5π‘₯γ€—^3+γ€–4π‘₯γ€—^2+3π‘₯+2

Polynomial solutions
 The MATLAB symbolic function y=solve(eq1), or solve (eq1,eq2,eq3…..) returns the symbolic solution of an equation or the system of equation given by eq1 , eq2,…..,eqn.
 Example:
A= π‘₯^2=9
B=     π‘₯βˆ’0.5𝑦+1.5z=5
          6π‘₯+4π‘¦βˆ’2𝑧=10
           π‘₯βˆ’π‘¦βˆ’π‘§=βˆ’1


Lecture 06 Polynomial Handling In Pdf File




Comments

Post a Comment

Popular posts from this blog

Zong Whatsapp Packages 2019

Lecture Notes on General Topology