Suppose that now we'd like to answer a question like: ``How long does
it take a $1000 investment drawing 6% interest, compounded daily, to
double in value?'' Answering this question involves setting up and
solving equations, and solving equations is something at which Maple
excels.
For example, let's solve a simple equation in one unknown:
| solve(2*x + 5 = 0, x); |
Notice that solve takes two parameters: the equation to be solved and
the unknown to be solved for. If one side of the equation is 0 and if the
equation only contains one unknown, there is a simpler form that saves typing:
| solve(2*x + 5); |
There is a related function called fsolve, that on the surface
works much like solve:
| fsolve(2*x + 5); |
Whereas solve tries to solve equations symbolically to obtain an
exact answer (much as you do), fsolve tries to solve them
numerically, obtaining an approximate floating-point answer. The
difference is probably a bit vague to you right now, but the important
thing to know is that fsolve will solve more equations more
efficiently, but not as accurately, than solve will.
It is worth illustrating this difference a bit. Below we use solve and
fsolve to attempt to solve the same simple equation. Can you explain
what happens?
| solve(cos(x) = x); |
| fsolve(cos(x) = x); |
Click here for the answer
Now back to the question we posed at the beginning of this section.
We can answer it quite easily by using solve:
| solve(intervals(1000, .06, years, 365) = 2000); |
It turns out that the amount of time that it takes an investment to double is
independent of the original investment. Below, we use the symbol balance
in place of the number 1000:
| solve(intervals(balance, .06, years, 365) = 2*balance, years); |
Let's compare that to the amount of time required for the investment
to double with only annual compounding:
| solve(compound(balance, .06, years) = 2*balance, years); |
Notice here that solve can deal with the functions
compound and intervals--which you defined--just as
easily as it can deal with the functions that it defines. And
so can you. Perhaps you've even forgotten at this point how the
functions were derived. It doesn't really matter. All that is
important is that you remember how to use them.
Joseph L. Zachary
Hamlet Project
Department of Computer Science
University of Utah