Math 149 Lab 2-Using derivatives to find properties of functions IntroductionDifferentiation is a process that for a broad class of functions may be performed using only a small set of rules. However, evenfor relatively simple functions, such as those in the examples and exercises that follow, the results may become rather compli-cated and unwieldy. As such, differentiation of elementary functions is very well suited to being performed by computersoftware.This laboratory will explore how to compute derivatives and use them to find global (absolute) maxima and minima, localmaxima and minima, intervals of increase or decrease, intervals of concavity, and points of inflection.Computing derivativesThe function f(x) = x2Secx may be defined with the “:=” assignment operator as follows.In[43]:=fx_ : x^2SecxTo see the results of the definition we may compute the value of the function by simplying typing the name of the function andenclosing the argument in [square brackets].In[44]:=fxOut[44]=x2 3 Sin2xThe first and second derivatives may be computed using the “D” function.In[45]:=Dfx,xOut[45]=2x 6 Cos2xIn[46]:=DDfx,x,xOut[46]=2 12 Sin2xTo find the n-th derivative we use the “D[f,{x,n}]” form of the command. For example, the fourth derivative may be com-puted as follows.In[47]:=Dfx, x, 4Out[47]=48 Sin2xThis is much more pleasant than repeatedly applying the differentiation rules for our function by hand four times!Finding absolute maxima and minimaFor a continuous function defined on a closed interval, from the Extreme Value Theorem we know that the function assumes itsabsolute maximum and absolute minimum values somewhere within the interval. Moreover, thanks to Fermat’s Theorem, weknow that we only need to consider the values of the function at the endpoints and and at the critical numbers where the deriva-tive is zero or does not exist.As an example, consider the function f(x) = x Cosx2 Sinx on the interval [0, p].In[48]:=ClearfIn[49]:=fx_ : Sinx x Cos x^2In[50]:=fxOut[50]=x Cosx2 SinxIn[51]:=Plotfx, x, 0, PiOut[51]=0.5 1.0 1.5 2.0 2.5 3.0-3-2-1123Place the cursor within the plot region and right-click twice to display a pull down menu from with the option Get Coordinatesmay be selected in order to find approximate values of the coordinates for the absolute maximum and minimum. Apparently theyoccur near (2.507, 3.11) and (2.087, - 3.023).Since this function has a derivative everywhere, the only critical points occur where the derivative vanishes.In[52]:=SolveDfx,x 0, xSolve::nsmet : This system cannot be solved with the methods available to Solve. àOut[52]=SolveCosx Cosx2 2x2Sinx2 0, xSince the “Solve” command cannot provide a solution will will need to approximate the zeroes of the derivative numericallywith the “FindRoot” command.In[53]:=X1 x . FindRootDfx,x, x, 0.9Out[53]=0.92011In[54]:=X2 x . FindRootDfx,x, x, 1.6Out[54]=1.824282 Using derivatives to find properties of functions.nbIn[55]:=X3 x . FindRootDfx,x, x, 2.5, WorkingPrecision 20Out[55]=2.5096823655698523433In[56]:=X4 x . FindRootDfx,x, x, 3.1, WorkingPrecision 20Out[56]=3.0869953834970000053In[57]:=fX1Out[57]=1.40527In[58]:=fX2,fX3,fX4Out[58]= 0.824633, 3.1000750940745536964, 3.015500542533563523In[59]:=f0,fPiOut[59]=0, Cos2In[60]:=NfPi,10Out[60]= 2.835869702Therefore the absolute maximum is f[X[3]] = 3.1000750940745536964 and the absolute miminum is f[X[4]] =-3.015500542533563523 .Derivatives and the shapes of graphsDerivatives may be used to tell where the graph of a function is increasing or decreasing because the derivative gives the slope ofthe tangents to the graph. Therefore the first derivative may be used to find where the function has local maxima (where thegraph goes from increasing to decreasing) and local minima (where the graph goes from decreasing to increasing). The secondderivative gives information on how graphs “bend”: if a curve always lies above its tangents throughout an interval, then it is saidto be “concave upward”, if below, then “concave downward”.As an example we study the function f(x) = x2 3 Sin2x on the closed interval [ -p , p ].ClearfIn[64]:=fx_ : x^2 3 Sin2x;fxOut[64]=x2 3 Sin2xFirst we plot a graph of the function:Using derivatives to find properties of functions.nb 3In[65]:=Plotfx, x, Pi, PiOut[65]=-3 -2 -1 1 2 3-2246810There appear to be two local minima, near 0.7 and 0.9 respectively, and one local maximum near 1.0, and possibly anotherlocal maximum near -3.0. At points where there is a local extremum the derivative is 0. We next compute the derivative anddraw the graphs of f(x) and f ’(x) on the same set of axes.In[66]:=Dfx,xOut[66]=2x 6 Cos2xIn[68]:=gx_ : 2x 6 Cos2x;gxOut[68]=2x 6 Cos2xIn[69]:=Plotfx,gx, x, Pi, Pi, PlotStyle Red, Green, ThickOut[69]=-3 -2 -1 1 2 3-5510In[71]:=X1 x . FindRootDfx,x, x, 0.67, WorkingPrecision 10Out[71]= 0.6723755227In[73]:=X2 x . FindRootDfx,x, x, 0.90, WorkingPrecision 10Out[73]=0.94575994824 Using derivatives to find properties of functions.nbIn[74]:=X3 x . FindRootDfx,x, x, 2.0, WorkingPrecision 10Out[74]=1.992913103To see if there is a solution near - 3.0, we may zoom in on the graph of the derivative.In[75]:=Plotgx, x, Pi, 2.9, PlotStyle Green, ThickOut[75]=-3.05 -3.00 -2.95 -2.90-0.40-0.35-0.30-0.25-0.20Since the graph of the derivative does not reach up to the X-axis where y = 0, there is no other local extremum.The graph of the derivative is negative from -p to X[1] and from X[2] to X[3], so f is decreasing on those intervals. Thederivative is positive from X[1] to
View Full Document