maxima book chapter 6

Upload: prakushprakush

Post on 04-Jun-2018

221 views

Category:

Documents


1 download

TRANSCRIPT

  • 8/13/2019 Maxima Book Chapter 6

    1/35

    Calculus applications in MaximaIn this chapter we present examples of functions included in theCalculus menu in the wxMaxima interface, as well as other calculusapplications.

    Calculus functions in the Calculus menuThe Calculus menu in the wxMaxima interface is shown inthe figure to the right. In this section we presentsexamples of most of the items in this menu. However, itshould be pointed out that the last five items in themenu, namely, from Greatest common divisor... toContinued fraction , were addressed in Chapter 3 of thisbook. Therefore, we will only present examples of theremaining items in the Calculus menu.

    Integrate...The Calculus > Integrate ... item produces a dialogueform as shown below

    Indefinite integral - The integrand,corresponding to the Integrate: field, isset, by default, to the last entry ! % ", but

    it can be replaced by any expression. Thevariable of integration is set, by default,

    to x . #ext, there is an option to selectDefinite integration, the default being anindefinite integral. $s a first exampleconsider the case of a indefinite integralfor the expression 1 !1"x#$ , by entering

    that expression in the Integrate: field, and pressing the % &' ( button. The result is thefollowing input and output

    This is to say,

    dx1 x2

    = atan x .

    6-1 Gilberto E. Urroz, 2008

  • 8/13/2019 Maxima Book Chapter 6

    2/35

    If you want to show the integral before and after evaluation, use the apostrophe !)" beforethe integrate command, then use ev !% ,nouns ", as illustrated in the following example

    Definite integral * Consider now the definite integral defined in the following inputdialogue form for the menu item Calculus > Integrate...

    $fter pressing the % &' ( button the result is the following !after entering &ositive at the+uestion issued by Maxima "

    This definite integral can also be entered directly into the wxMaxima I'()* line as follows

    6-2 Gilberto E. Urroz, 2008

  • 8/13/2019 Maxima Book Chapter 6

    3/35

    The following example shows a definite integral with numeric limits

    This produces the result

    $n alternative way to enter this expression directly into the I'()* line, so that theintegral, and the result are both shown, is the following

    6-3 Gilberto E. Urroz, 2008

  • 8/13/2019 Maxima Book Chapter 6

    4/35

    Im&ro&er integrals * #otice that in the dialogue form shown above there is a button labeled+&ecial attached to each of the limits fields. Clicking on this button provides access to thespecial values shown below

    These entries can be used, for example, to generate the following dialogue entry form

    which produces the following result

    $lternatively, you can enter the improper integral as follows

    6-4 Gilberto E. Urroz, 2008

  • 8/13/2019 Maxima Book Chapter 6

    5/35

    'umerical integration * ou may also have noticed that the definite integral dialogue formallows for numerical integration, including one of the following two functions !or methods"

    Consider the following numerical integration

    The result is the following call to function uad ags

    The outputs from this function call are four numbers representing

    -. The numerical value of the integral. The estimated absolute error of the numerical integration3. The number of integrand evaluations re+uired to produce the numerical value/. $n error code representing the following options

    6-5 Gilberto E. Urroz, 2008

    Error code Meaning0 No problems encountered1 Too many sub-intervals tried2 Excessive roundoff error detected3 Extremely bad integrand behavior

    !nput is invalid

  • 8/13/2019 Maxima Book Chapter 6

    6/35

    The numerical integration shown above can also be accomplished by entering the following

    If you want to show the integral before evaluation use

    #&T0 uad functions - 1unction uad ags , used in this numerical integration example,belongs to a family of numerical integration functions that includes also functionsuad ag, uad agi, uad awc, uad awo, and uad aws . 2etails on the operationof these functions can be found in the Maxima Manual , available in the menu item el& >Maxima /el&. 2o a search for 0 uad0 in the +earc/ tag of the Maxima Manual window, tocheck the individual functions.

    'umerical integration of an im&ro&er integral * electing, for example, a numerical

    integration with infinite limits, with the uad option selected, results in the activation offunction uad agi

    6-6 Gilberto E. Urroz, 2008

  • 8/13/2019 Maxima Book Chapter 6

    7/35

    om2erg integration 3 Consider the following numerical integration using the 4ombergmethod !reference, e.g., http 55en.wikipedia.org5wiki54omberg)s6method ".

    The result is

    4isch integration...The isc/ integration... menu item activates function risc/ which is used to calculateindefinite integrals by the 4isch approach ! http 55en.wikipedia.org5wiki54isch6algorithm ".The following is an example of this application

    The result is the following

    6-7 Gilberto E. Urroz, 2008

    http://en.wikipedia.org/wiki/Romberg's_methodhttp://en.wikipedia.org/wiki/Risch_algorithmhttp://en.wikipedia.org/wiki/Risch_algorithmhttp://en.wikipedia.org/wiki/Romberg's_method
  • 8/13/2019 Maxima Book Chapter 6

    8/35

    Change variable...This menu item from the Calculus menu can be used to produce change of variables in asymbolic integral or summation. 7hen this menu item is activated you get the followingdialogue form

    The Integral sum field, which is set by default to the last entry ! % ", must refer to an

    integral or summation. The reference to the old varia2le and new varia2le fields isstraightforward !the form suggests that old variable is x and new variable 4 ", however, thesuggested value in the e uation field is misleading. Instead of an e+uation of the form 4 5

    x , the entry in this field should be of the form 4 3 x , i.e., a relationship of the form f!x,4 ,such that f!x,4 5 6 .8efore trying the following example, cancel the dialogue form, and enter the followingsymbolic !non evaluated" integral

    Then, activate the menu item Calculus > C/ange varia2le ... , and enter the followingvalues in the dialogue form

    6-8 Gilberto E. Urroz, 2008

  • 8/13/2019 Maxima Book Chapter 6

    9/35

    This results in the integral

    In the resulting integrand you may recogni9e the trigonometric identity, sec $ 5 1" tan $ ,which would transform this integral into

    $n example of a indefinite integral is shown next

    The following change of variable on an indefinite integral uses a trigonometric substitution

    6-9 Gilberto E. Urroz, 2008

  • 8/13/2019 Maxima Book Chapter 6

    10/35

    These change of variables are useful if you are learning how to simplify and calculateintegrals by hand. :sing Maxima there is no need to use these substitutions to calculatethe integrals as illustrated by the following examples

    2ifferentiate...The Calculus menu option Differentiate... produces a dialogue form conducive tocalculating derivatives, e.g.,

    6-10 Gilberto E. Urroz, 2008

  • 8/13/2019 Maxima Book Chapter 6

    11/35

    This action produces the command

    Thus, the command diff!f!x ,x produces the derivative df dx. 1or higher*orderderivatives, say, derivative of order n, d n f dx n, the corresponding command isdiff!f!x ,x,n , for example,

    &r you can use the Calculus > Differentiate... menu item, e.g.,

    To show the differentiation operation and its result use, for example,

    1ind limit...Calculus menu item 7ind limit... allows the calculation of limits of functions. The menuitem produces a dialogue form that allows the user to define the function of interest, andthe point where the limit is calculated. The dialogue also allows to select if the limit isfrom the left, from the right, or from both sides. $n option exists also to use the Taylorseries expansion of the function in calculating the limit. The following figure illustratestwo cases of limit calculations

    6-11 Gilberto E. Urroz, 2008

  • 8/13/2019 Maxima Book Chapter 6

    12/35

    The limit expression can be made visible, for the first case only, if we use an apostrophe !)"for the limit command. 1unction ev is then used to evaluate the corresponding limit

    0xamples of limits from the left and the right are shown next

    6-12 Gilberto E. Urroz, 2008

  • 8/13/2019 Maxima Book Chapter 6

    13/35

    ;)Hopital)s rule. ;)Hopital)s rule is automatically incorporated in the calculation of limits,e.g.,

    This is a case in which, without any simplification, both the numerator and denominatorlimits are 9ero as x goes to 1. ;)Hopital)s rule indicates that the following is true

    0valuating the derivatives before the limit we get

    The limit is calculated as

  • 8/13/2019 Maxima Book Chapter 6

    14/35

    The resulting Maxima input and output is shown below

    If the option (ower series is activated in the +eries dialogue form, the result, for the samefunction as above, is as follows

    The following example shows the Taylor series expansion for the function log!x" about x = -up to a power of order >

    :sing the option (ower series in the dialogue form produces the following infinite series

    ?ade approximation...$ ?ad@ approximation of a Taylor series consists of a fraction in which both the numeratorand the denominator are powers of x . ince a Taylor series is re+uired, we first set up aTaylor series for the function sin!x about x 5 6 up to a power of order 8, i.e.,

    Then, we activate the Calculus menu item (ade a&&roximation... which produces thefollowing dialogue form

    6-14 Gilberto E. Urroz, 2008

  • 8/13/2019 Maxima Book Chapter 6

    15/35

  • 8/13/2019 Maxima Book Chapter 6

    16/35

    Calculate sum...The Calculate sum... item in the Calculus menu produces a dialogue form as follows

    1or this example, we select the summation of the term 1 $, from 5 1 to 5 166 . 7iththe +im&lif4 option on, to produce

    The floating*point value of this result is calculated with function float

    7ith the 'usum option selected

    the previous summation produces the same result as above

    6-16 Gilberto E. Urroz, 2008

  • 8/13/2019 Maxima Book Chapter 6

    17/35

    $n infinite sum example is shown below

    This sum produces the following result

    7ith the +im&lif4 option selected, the value of the summation is calculated as

    electing the option 'usum in the +um dialogue form produces an infinite !incorrect"result. This is so because a numerical approximation to an infinite sum is not anappropriate operation.

    6-17 Gilberto E. Urroz, 2008

  • 8/13/2019 Maxima Book Chapter 6

    18/35

    Calculate product...The dialogue form for the Calculate &roduct... item in the Calculus menu is similar to thatof the summation calculations shown above, except that there are no options to choose,ust entering the parameters of the product, e.g.,

    This entry represents the product to n elements of the +uantity 1 , i.e.,

    4eplacing the upper limit with a specific value !i.e., 5 16 " produces

    Here is the product of all integers from - to D

    which is, by definition, the factorial of D

    6-18 Gilberto E. Urroz, 2008

  • 8/13/2019 Maxima Book Chapter 6

    19/35

    ;aplace transform...;aplace transforms are a type of integral transforms used in the solution of ordinarydifferential e+uations !see http 55en.wikipedia.org5wiki5;aplace6transform ". The Calculus> ;a&lace transform... menu item produces the following dialogue interface.

    This example represents the ;aplace transform of the sine function, i.e.,

    Inverse ;aplace transform...$s the name indicates, the inverse ;aplace transform is the opposite operation to the;aplace transform ! http 55en.wikipedia.org5wiki5Inverse6;aplace6transform ". The Calculus> Inverse ;a&lace transform... menu item produces the following dialogue interface

    This example shows that the negative exponential function e -t is the inverse ;aplacetransform of the fraction 1 !s"1

    #&T0 The ;aplace transform and its inverse belong in a Chapter on differential e+uations!&20s". They were included here for the sake of completeness in describing the functionsavailable in the Calculus menu. The < uations menu includes an item on solving ordinarydifferential e+uations with ;aplace transforms ! < uations > +olve =D< wit/ ;a&lace... ".ee a simple application in Chapter -. The solution of &20s will be addressed in asubse+uent chapter.

    6-19 Gilberto E. Urroz, 2008

    http://en.wikipedia.org/wiki/Laplace_transformhttp://en.wikipedia.org/wiki/Inverse_Laplace_transformhttp://en.wikipedia.org/wiki/Laplace_transformhttp://en.wikipedia.org/wiki/Inverse_Laplace_transform
  • 8/13/2019 Maxima Book Chapter 6

    20/35

    Examples of applications in calculusThe following examples show specific applications of the different calculus functionspresented above.

    The limit of sin!x x as x approaches ero Consider the limit of function f!x 5 sin!x x as x approaches 9ero. 2irect evaluation of this

    function at x 5 6 is an undefined value !E5E", however, the limit is e+ual to -

    The limit is, of course, the same whether 9ero is approached from the left or from theright

    $pplication of the ;)Hopital)s rule ustifies this result

    The plot of the function shows that the value of f!6 is indeed -

    6-20 Gilberto E. Urroz, 2008

  • 8/13/2019 Maxima Book Chapter 6

    21/35

    The derivative as a limit8y definition the derivative of a function f!x is the following limit

    df dx

    = lim x 0

    f x h f xh

    ;et)s try some examples 0xample - F f!x 5 sin!x , f0!x 5 cos!x

    0xample F f!x 5 x , f0!x 5

    6-21 Gilberto E. Urroz, 2008

  • 8/13/2019 Maxima Book Chapter 6

    22/35

    0xample 3 F f!x 51 x

    , f0!x 5 12x3 / 2

    Implicit differentiation1unction diff can be used to produce implicit differentiation in an e+uation as illustrated inthe following example. 1irst, define and e+uation

    #ext, apply diff to the entire e+uation to give you the implicit derivatives

    1inally, solve for the derivative

    6-22 Gilberto E. Urroz, 2008

  • 8/13/2019 Maxima Book Chapter 6

    23/35

    1inding maxima, minima, and points of inflectionGaxima and minima !critical points" of a function 4 5 f!x can be found by making d4 dx 56 . The points thus found are maxima if d $4 dx $ > 6, or minima if d $4 dx $ > 6 . ?oints ofinflection are found where d $4 dx $ 5 6 .

    Consider the following example

    The e+uation corresponding to df dx 5 6 is < MM

    whose solutions are

    7e extract these solutions into variables x1, x$, and x?

    Then, evaluate the second derivative, f$ , for each of the points found above.

    The critical points !maxima and minima" are found at the following coordinates, x; = list of x values, 4; 5 list of 4 values

    6-23 Gilberto E. Urroz, 2008

  • 8/13/2019 Maxima Book Chapter 6

    24/35

    This results suggest that ! x; 1,4; 1" = !E.> 3, D.E-E" is a maximum, while the other two pointsare minima. ;et)s check these results using a plot of the function.

    1rom the resulting figure it is clear that point ! x; ?,4; ?" = !-1.8$$,-1?.@1 " is indeed a relativeminimum, but it)s hard to see the relative position of the other two points. 1ocusing in thearea for these two points we produce the following graph

    6-24 Gilberto E. Urroz, 2008

  • 8/13/2019 Maxima Book Chapter 6

    25/35

    1rom this second graph it is obvious that point ! x; 1,4; 1" = !6.8$?, @.616 " is indeed a relativemaximum, while point !x;$,4;$ = !1.666,@.666 " is a relative minimum.

    To determine the points of inflection we can use

    The location of these points is discernible in the previous two graphs.

    2ifferential e+uationsThe apostrophe !)" before function diff can be used to write differential e+uations, e.g.,

    This result could be used, for example, to solve the ordinary differential e+uation !&20"using the menu item < uations > +olve =D

  • 8/13/2019 Maxima Book Chapter 6

    26/35

    ummations as approximation to integralsThe formal definition of an integral, i.e., a 4iemann integral is illustrated in the figureshown below. !1or details, see http 55en.wikipedia.org5wiki54iemann6integral ".

    The figure shows a partition of the interval a x 2 , where a 5 x 1, and 2 5 x n"1 . $ partition isthe set of values % a 5 x 1, x $, ..., x , ..., x n, x n"1 = 2(, so that % x 1,x $( limit the - st sub*interval,% x $,x ?(, the second sub*interval, and so on. 1or the -t/ sub*interval, % x ,x "1 (, we identify avalue k , such that, x k x "1 . Identifying similar values for each of the n sub*intervalsin the partition, the integral of the function 4 5 f!x in the interval a x 2 is defined as

    I =a

    b

    f x dx= limn

    k = 1

    n

    f k xk .

    7hile the sub*intervals in the partition need not be of the same si9e, to make thecalculation of an integral systematic, we make the partition be e+ually*spaced, so that,

    x1= x2= ...= xk = ... = xn= x

    and x1= a , x 2= a x , x3= a 2 x , ... , xk = a k 1 x , ... , b= xn 1= a n x .

  • 8/13/2019 Maxima Book Chapter 6

    27/35

    x= b an

    .

    The selection of the value in % x , x "1 ( is arbitrary, however, to make it systematic we canselect one of the following options

    -. The left limit of the sub*interval, i.e., 5 x 5 a k 1 x .

    . The mid*point of the sub*interval, i.e., k = xk xk 1

    2 = a k 1

    2 x .

    3. The right limit of the sub*interval, i.e., 5 x "1 5 a k x .

    ;et)s call the value of the integral calculated by these three selections I; , I C, and I ,respectively, thus, we have

    -. $ left integral calculated as

    I L= limn

    k = 1

    n

    f a k 1 b an b an = limn k = 1

    n

    sLk = limn

    SL , with

    sLk = f a k 1b a

    n b an , and SL= k = 1n

    sLk .

    . $ center integral calculated as

    I C = limn k = 1n

    f a k 12

    b an

    b an = limn k = 1

    n

    sC k = limn SC , with

    sC k = f a k 12

    b an b an , and SC = k = 1

    n

    sC k .

    3. $ right integral calculated as

    I R= limn

    k = 1

    n

    f a k b an b an = limn k = 1

    n

    sRk = limn

    SR , with

    sRk = f a k 1b a

    n b an , and SR= k = 1n

    sRk .

    These three combinations of summations and limits can be calculated using Maxima asillustrated in the example below.

    6-27 Gilberto E. Urroz, 2008

  • 8/13/2019 Maxima Book Chapter 6

    28/35

  • 8/13/2019 Maxima Book Chapter 6

    29/35

    Compare with the integral value calculated using function integrate

  • 8/13/2019 Maxima Book Chapter 6

    30/35

    Tables of derivatives and integrals1unctions diff and integrate can be used as tables of derivatives and integrals, respectively.1or example, to remember the formulas for the derivative of a product or a +uotient use

    The chain rule for derivatives can be illustrated by the following examples

    ome examples of integration formulas are presented next

    6-30 Gilberto E. Urroz, 2008

  • 8/13/2019 Maxima Book Chapter 6

    31/35

    Gultiple integralsThe following examples show cases of double and triple integrals.

    Dou2le integrals 3 :se two nested integrate commands to produce a double integral, e.g.,

    $lternatively, you can enter the following command to skip showing the double integral

    The following are two more examples of double integrals

    2ouble integrals may have infinite limits, e.g.,

    6-31 Gilberto E. Urroz, 2008

  • 8/13/2019 Maxima Book Chapter 6

    32/35

    *ri&le integrals F $n example of a triple integral is shown below

    Infinite series prove 2e Goivre)s e+uation

    2e Goivre)s e+uation states that e i = cos theta i sin theta . 7e can check that thisstatement is true !to order E" by using Taylor series expansions of the three functionsinvolved

    0- = expansion of e i

    6-32 Gilberto E. Urroz, 2008

  • 8/13/2019 Maxima Book Chapter 6

    33/35

    4eal part of 0-

    Compare with the expansion of cos!

    Imaginary part of 0-

    Compare with the expansion of sin!

    6-33 Gilberto E. Urroz, 2008

  • 8/13/2019 Maxima Book Chapter 6

    34/35

    Some items of interest related to multivariate calculusome items of interest in multivariate calculus include plots of bivariate functions,multiple integrals, and partial derivatives.

    The issue of plotting multivariate functions is addressed by function &lot?d !seeChapter /".

    The issue of multiple integrals was addressed earlier in this Chapter when discussingthe integrate command. 4egarding partial derivatives we should point out that function diff provides for the

    calculation of both ordinary and partial derivatives. Thus, the partial derivative x

    x2 z y sin x is calculated in Maxima using, for example, the menu itemCalculus > Differentiate, which produces the dialog box

    $fter entering the

  • 8/13/2019 Maxima Book Chapter 6

    35/35

    0xample of a second*order derivative

    0xample of a second*order cross derivative