Differentials
1 Defining the Differential
We know that the differential for a function f(x) is given by df = f'(x)dx. So we must take the derivative of f(x), and then multiply it by dx. As it turns out, Maxima can do this automatically for us if we use the diff() command *without* giving the variable of
differentiation. For example:
--> | diff(x^2); |
The del(x) symbol is Maxima's symbol for the differential "dx". Note that if we had used a different variable, we would have:
--> | diff(s^3+2*s); |
If we had defined a function f(x) first, then:
--> |
f(x):=cos(x); diff(f(x)); |
2 Evaluating the Differential
Now let's attempt to find the differential of f(x)=x^2 for x=1 and dx=0.1. We know that the answer
should be: df = 2xdx = 2(1)(0.1) = 0.2. Here's how we do it:
--> | df:diff(x^2); |
--> | subst([del(x)=0.1,x=1],df); |
That's it! Or in one line:
--> | subst([del(x)=0.1,x=1],diff(x^2)); |
All that we did in the above is compute the differential, then substitute the values in for del(x) and x.
2.1 Caution: Order of Substitution Matters!
Maxima views del(x) as a compound expression of both del and x. So if we substitute x first, this
will cause problems:
--> | subst([x=1,del(x)=0.1],diff(x^2)); |
What?!! Note that because we put in the x value first as 1, del(x) → del(1), and there is no longer
a del(x) to be substituted for! To ensure that this doesn't happen, we must substitute for any
del() expressions first!
3 Differentials of Formulae
Suppose that we have a formula for volume that depends on two parameters, but only one of them
is playing the role of a variable, like:
--> | V(r):=%pi*r^2*h; |
This gives the volume of a cylinder of height h and radius r. Here h is a constant, but when we
compute:
--> | diff(V(r)); |
Maxima doesn't know that h is supposed to be a constant and includes it in the computation
of the differential. One way that we can tell Maxima that h is constant is to let it know that
h is not changing. That is, del(h)=0:
--> | subst(del(h)=0,diff(V(r))); |
This practical "hack" allows us to pinpoint only the variable quantity. For example,
let's say that the volume of a box has two dimensions fixed at a and b feet, while
the third side is variable and represented by s. We might encode this as:
--> | V(s):=s*a*b; |
To get the differential of V(s) relative only to s we compute:
--> | dV:subst([del(a)=0,del(b)=0],diff(V(s))); |
Now we can compute the differential when, for instance, s=3 and del(s)=-0.01:
--> | subst([del(s)=-0.01,s=3],dV); |
--> | kill(all); |
4 Related Rates
Suppose that we know that the radius of a cylinder is related to the height of the cylinder by way of: h(r)=(r^2+1)*cos(r):
--> | h(r):=(r^2+1)*cos(r); |
The volume of the cylinder is then:
--> | V(r):=%pi*r^2*h(r); |
We can then get the derivative of V(r) in the usual way:
--> | diff(V(r),r); |
But what if we *don't* know how h depends on r? We know that there is a connection, but we aren't sure what it is?
Maxima can handle this too. Let's clean up and start over:
--> | kill(all); |
--> | V(r):=%pi*r^2*h(r); |
Note that the above shows that h is a function of r, but we have not given it any explicit relationship yet.
Let's try differenting and see what happens:
--> | diff(V(r),r); |
Nice! We see that Maxima treats the unknown function h(r) as a function and correctly applies the chain rule.
We can now substitute or solve for any of the above quantities just like we would in a related rates problem.
For example, suppose that we want to find dh/dr when h=2, r=3, and dV/dr=5:
First, we solve for dh/dr:
--> | Eqn:solve(diff(V(r),r)=5,diff(h(r),r))[1]; |
Now we substitute to get the numerical value required:
--> | subst([h(r)=2,r=3],rhs(Eqn)); |
Note that the order in which we substituted above matters. Had we substituted r first
we would have arrived at:
--> | subst([r=3,h(r)=2],rhs(Eqn)); |
Since substituting r=3 turns h(r) into h(3), and there is no longer an h(r) to substitute for!
We could get around this by noting that: h(3)=2 and so:
--> | subst([r=3,h(3)=2],rhs(Eqn)); |
Just for kicks, we note that:
--> | is(-(12*%pi-5)/(9*%pi)<0); |
so that the height is decreasing under these circumstances.