Page 290 - MATLAB an introduction with applications
P. 290

Optimization ———  275


                   >> x=A\b
                   x =
                          32.0000
                         –33.5000
                           9.5000
                   >> x=inv(A)*b
                   x =
                          32.0000
                         –33.5000
                           9.5000
                          a = 32
                           0
                          a  = –33.5
                           1
                          a = 9.5
                           2
                   >> x=[1 2 3];y=[8 3 17]; a2a1a0=polyfit(x,y,2)
                   a2a1a0 =
                          9.50000000000001     –33.50000000000002     32.00000000000003
                   and the function is
                          F(X) = 32 – 33.5X + 9.5X 2

                   For finding minimum of the function, we find the first derivative of the function
                    dF ()  =− 33.5 19X =  0; for a minima or maxima
                       X
                                +
                     dX
                   Thus,   X = 1.763
                                                                                   2
                                                                                  dF  ()
                                                                                      X
                   To check for minima or maxima, we find second derivative of the function    = 19 >  0; thus it’s a
                                                                                    dX  2
                   minimum.
                   The minimum value of F(X) at X is
                   F(X = 1.763) = 2.462


                   Example E5.4: Fit a polynomial by quadratic approximation and determine the values of X at which F(X) is
                   minimum.
                                  X      F(X)
                                  1       –7
                                  2        5
                                  3       14

                   Solution:

                                                      X             F (X)
                                                      1           –7
                                                      2            5
                                                      3           14
   285   286   287   288   289   290   291   292   293   294   295