Learning Mathematica Basics—Calculus Operations I

Solve each of the following problems using Mathematica exclusively.

1.	The most fundamental idea of calculus is probably the limit concept.  Mathematica is capable of handling limits fairly competently.  The command you need is  Limit.  Go ahead and ask for the syntax of the command.

2.   Well, that looks pretty straightforward.  Go ahead and use the command to find the limit of the polynomial x^2 + 7x - 3 as x -> 2.

3.   OK, but that kind of limit is actually pretty easy, so we aren't very impressed yet.  Let's throw some more interesting limits at it.  First try taking the limit of (sin x)/x as x -> 0.

4.   So it handled that particular indeterminate form (i.e. 0/0) correctly.  Let's see how it deals with ∞/∞.  Try taking the limit of (2x^2 + 3x - 4)/(5x^2 - 8x) as x -> ∞.  (In Mathematica infinity is referred to as simply Infinity.)

5.   Now let's try one of those special limits, like the limit definition of the number e.  Try finding the limit as x -> ∞ of (1+1/x)^x.

6.   Impressive!  Finally let's try a complicated one.  Take the limit as x -> ∞ of 3 + e^(-x) sin x.

7.   So we've established that limits in Mathematica are well implemented, if not particularly fast.  Let's move on to the next most basic calculus operation—the taking of derivatives.  Ask for the syntax of Dt.

8.   Go ahead and take the derivative of x^7 + 10x^4 with respect to x.

9.   Well, that worked as expected.  Let's see how it handles some of the standard rules for taking derivatives.  First the product rule—take the derivative of e^x sin x with respect to x.

10.   Check that off the list.  Now the quotient rule—take the derivative of (tan x) / x^5 with respect to x.

11.  The output looks a little strange, but a careful check will reveal that the result is indeed correct.  Moving on, how about the chain rule?  Take the derivative of sec(t^6) with respect to t.

12.   Well, that concludes our little check-list of the basic derivative short-cuts.  Apparently Mathematica can handle all of them.  Now recall that the description of Dt's syntax mentioned the total differential as well as the total derivative.  The total differential is found by leaving out the variable which you are differentiating with respect to, (check back to problem 7 if you want to check the syntax again.)  Go ahead and find the total differential of the following function of two variables:

                                                     x^6 + 7x^2 y^3 + y^5

13.   So what are all those Dt[x]s and Dt[y]s?  Well in standard mathematical notation they would be written as dx and dy.  Your ability to understand what Mathematica actually did in this problem would depend on whether you've taken Calculus III or Differential Equations yet—courses where you learn about what the total differential is.

Anyway, let's move on.  How about higher order derivatives?  If you check the syntax of Dt back in problem 7 again you'll see that it describes how to do these too—the third part of the description.  Just in case the prior discussion is a little unclear to you here's an example:  the command to take the third derivative of e^x sin x would be Dt[E^x Sin[x], {x,3}].  Now you have a go—take the fourth derivative of x^3 cos 5x.

14.   Considering the result, how would you have liked to have done that one by hand?  Problems like the last one really emphasize the power of having a tool like Mathematica available to take care of the tedious details of long calculations.

Moving on again, let's consider implicit differentiation.  Recall that the idea behind taking an implicit derivative is to consider all variables except the independent one (the one you are differentiating with respect to) to be implicit (or implied) functions of the independent variable itself.  This means that when you take the derivative of such a variable, the chain rule is required. (If the previous explanation didn't bring you up to date on implicit derivatives then review the notes from your Calculus I class.)

Ask Mathematica to take the derivative of  x^6 + 7x^2 y^3 + y^5 with respect to x.

15.   Notice the presence of Dt[y, x] in the last two terms of the previous answer.  This factor is equivalent to the dy/dx factor in standard written calculus.  (Remember?)

Let's now do a typical problem from the section on implicit differentiation in Calculus I.  Find dy/dx  for the curve defined by the following equation:

                                                  x^4 + x^3 y^2 = sec y - y^3.
                                                  
To begin with, you should apply the Dt command to the above equation, not forgetting to use a double equals sign for the equation, and to differentiate with respect to x.

16.  Hopefully you now remember that the second step in solving a problem like this is to isolate the dy/dx factor.  In Mathematica we can achieve this by applying a Solve command to the previous output.  Don't forget to tell the command what to solve for—namely Dt[y,x].

17.  Now let's do one without the hand-holding.  Find dy/dx  for the curve defined by the following equation:

                                                  e^(xy) = x^2 tan y.
                                                  
(You could do it all in one command if you tried!)

18.   For our last investigation into derivatives, let's look at the partial derivative.  If you haven't taken Calculus III yet you may not have heard of these.  The basic idea here is that all variables in an expression are treated as constants, except for the one you are differentiating with respect to.  (This is almost the opposite of implicit derivatives, where all of the variables are treated as funcions of the same variable.)

The Mathematica command for partial derivatives is D.  Ask for its syntax.

19.   So, to take the derivative of x^2 + y^5 with respect to x the command would be D[x^2+y^5,x].  Go ahead and try it.

20.  Now take the derivative of the same function with respect to y.

21.   Just like ordinary derivatives, partial derivatives can also be higher order.  For example, you could take the derivative of cos(x^4 y^3) with respect to x first, then y, then y again, and then finally with respect to x again.  The command would be:

                                      D[Cos[x^4 y^3],x,y,y,x]

Go ahead and try it.

22.   Your turn.  Take the derivative of x^2 tan(x y) with respect to x first, and then y.

23.   Now take the derivative of the same original function, but reverse the order of the derivatives, i.e. with respect to y first, and then x.  What do you notice about the two results?

The two derivatives you just took in problems 22 and 23 are both called "mixed partials."  Mixed partials are almost always equal.  (You should [have] learn[ed] about the conditions which dictate this in Calculus III.)