Computing Roots of Equations
We have already seen that Maple provides two built-in functions for solving
equations: solve and fsolve. The key difference between the two is
that solve solves equations symbolically, whereas fsolve
solves them numerically.
When you solve equations, you probably solve them symbolically. In fact,
much of a typical high school algebra course is taken up with learning
techniques for symbolically solving equations. Examples of such techniques
include factoring, cancellation, and the quadratic formula. Symbolic equation
solving is fine when it works, but unfortunately it does not always work. For
example, you probably have no idea how to solve the equation
symbolically. Neither does Maple, as can be easily verified:
| solve(cos(x) = x); |
Computers have traditionally been used to apply numerical techniques for
solving equations, and fsolve uses a numerical approach. While there are
a variety of numerical techniques for solving equations, they are all
fundamentally alike. Beginning with a rough estimate for the solution, they
systematically come up with better and better estimates until they find one
that is sufficient accurate. This implies, of course, that numerical
approaches do not usually come up with exact solutions, just good
approximations.
In this lesson we will study a particularly simple numerical approach to
solving equations called the bisection method. Although much better
methods are known, learning about the bisection method will give you a good
appreciation for the general fashion with which numerical approaches operate.
As we study the bisection method, you will learn about control structures in
Maple. You already know about assignment, functions, and function calls. You
will see examples of conditionals, loops, procedures, and procedure calls.
These are exactly the ingredients that you will use to write C programs as we
move into the next phase of the course.
Our goal in studying these control structures is to prepare you for studying
C. We will not study them in great depth now, but will do so in the coming
weeks in the context of C programming.
Joseph L. Zachary
Hamlet Project
Department of Computer Science
University of Utah