ROOTS OF POLYNOMIAL USING MATLAB

As an engineer we have to solve many high order equations. Sometimes the order is so high that we can’t find the ROOTS of the equation even by using CALCULATORS. In such a situation MATLAB is very efficient and effective.

CODE:

p=input('ENTER THE COEFFICIENTS OF THE POLYNOMIAL');
f=roots(p);
disp('THE ROOTS OF THE EQUATION ARE:');
disp(f)

Examples:


For this polynomial input is:


          P=[1 -12 4 0 -5 -2 94 -32 -12 45]

OUTPUT:

              THE ROOTS OF THE EQUATION ARE:

  11.6598         
  -1.2030 + 0.8796i
  -1.2030 - 0.8796i
   0.4369 + 1.4779i
   0.4369 - 1.4779i
   1.5296         
  -0.7256         
   0.5342 + 0.6114i
   0.5342 - 0.6114i



For this polynomial input is:


           P=[15 84 4 -5 -2 94 -32 -12 45]

OUTPUT:

             THE ROOTS OF THE EQUATION ARE:

  -5.5489         
  -0.8019 + 0.8659i
  -0.8019 - 0.8659i
  -0.7011         
   0.4075 + 0.7577i
   0.4075 - 0.7577i
   0.7195 + 0.4800i
   0.7195 - 0.4800i


For this polynomial input is:


           P=[94 -15 -932 59 -132 -1267 45]

OUTPUT:

                THE ROOTS OF THE EQUATION ARE:

   3.2795         
  -3.0503         
   0.5016 + 0.9842i
   0.5016 - 0.9842i
  -1.1083         
   0.0354

0 comments:

Post a Comment

+