Page 20 - Numerical Analysis Using MATLAB and Excel
P. 20

Evaluation of a Polynomial at Specified Values

                                                                            7
                                                              9
                                                                     8
                                     p Þ p =   2x 11  –  6x 10  –  8x + 34x + 18x –  24x 6
                                      1
                                          2
                                                    5    4      3        2
                                               – 74x 88x +–  78x +  166x +  174x +  108
               We can write MATLAB statements in one line if we separate them by commas or semicolons.
               Commas will display the results whereas semicolons will suppress the display.


               Example 1.7

               Let
                                                  7
                                                              3
                                                        5
                                          p =    x –  3x +  5x +  7x +  9                               (1.6)
                                            3
                                                   6
                                                                2
                                                         5
                                          p =    2x –  8x +  4x +   10x +  12
                                            4
               Compute the quotient p p   4  using the deconv(p,q) function.
                                        ⁄
                                       3
               Solution:
               p3=[1   0  −3    0  5   7    9];  p4=[2  −8   0    0  4  10  12];  [q,r]=deconv(p3,p4)
               q =
                   0.5000
               r =
                    0     4    -3     0     3     2     3
               Therefore, the quotient qx()  and remainder rx()  are

                                                                 5
                                                                       4
                                                                             2
                                    qx() =   0.5      r x() =  4x –  3x +  3x +  2x +  3

               Example 1.8
               Let
                                                                2
                                                         4
                                                   6
                                          p =    2x –  8x +  4x +   10x +  12                           (1.7)
                                            5
               Compute the derivative dp dx⁄   using the polyder(p) function.
                                          5
               Solution:

               p5=[2   0   −8   0   4   10   12];
               der_p5=polyder(p5)
               der_p5 =
                   12     0   -32     0     8    10
               Therefore,



               Numerical Analysis Using MATLAB® and Excel®, Third Edition                               1−7
               Copyright © Orchard Publications
   15   16   17   18   19   20   21   22   23   24   25