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

Solutions to End−of−Chapter Exercises

                  We will use MATLAB to find the first and second derivatives of this expression.



                  syms t k1 k2 k3 k4 k5                    % Define symbolic variables
                  y0=k3*cos(2*t)+k4*sin(2*t)+k5;          % Assumed form of total solution
                  y1=diff(y0); f1=simple(y1)              % Compute and simplify first derivative
                   f1 =
                   -2*k3*sin(2*t)+2*k4*cos(2*t)
                   Thus, the first derivative of y F  is


                                               dy ⁄  dt =  – 2k sin 2t +  2k cos 2t
                                                             3
                                                                       4
                                                 F
                  y2=diff(y0,2); f2=simple(y2)            % Compute and simplify second derivative
                  f2 =
                  -4*k3*cos(2*t)-4*k4*sin(2*t)
                  and the second derivative of   is
                                              y

                                                      2
                                                2
                                               d y ⁄  dt =  – 4k cos 2t 4k sin 2t
                                                                    –
                                                                        4
                                                  F
                                                              3
                   f=y2+2*y1+y0; f=simple(f)       % Form and simplify the left side of the given ODE
                   f =
                   -3*k3*cos(2*t)-3*k4*sin(2*t)-4*k3*sin(2*t)+4*k4*cos(2*t)+k5
                   Simplifying this expression and equating with the right side of the given ODE we obtain:

                                     – (  3k +  4k )  4  cos 2t –  (  4k +  3k )  4  sin 2t + k =  cos 2t  1 -
                                                                                       --
                                                                               ------------- +
                                                           3
                                         3
                                                                           5
                                                                                       2
                                                                                 2
                  Equating like terms and solving for the   terms we obtain
                                                        k
                                                                     ⁄
                                                     –  3k + 4k =  12
                                                         3
                                                               4
                                                     – 4k – 3k =   0
                                                               4
                                                         3
                                                                     ⁄
                                                              k =  12
                                                               5
                                                                                         ⁄
                                                                                                         ⁄
                  Simultaneous solution of the first two equations above yields  k =  – 3 50  and  k =  450 .
                                                                                  3
                                                                                                   4
                   Therefore, the forced response is
                                                                      )
                                                                               ⁄
                                                                  ⁄
                                                    ⁄
                                                       )
                                           y =   – (  3 50 cos 2t +  (  4 50 sin 2t +  1 2
                                            F
                   and the total response is
                                                            t –
                                                    t –
                                                               -- –
                                            y =  k e +  k te +  1 -  3cos 2t – 4sin 2t
                                                                  ---------------------------------------
                                                        2
                                                 1
                                                                        50
                                                               2
                  Check with MATLAB:
               Numerical Analysis Using MATLAB® and Excel®, Third Edition                              5−51
               Copyright © Orchard Publications
   207   208   209   210   211   212   213   214   215   216   217