|
Analytical Computing The Synergy of Symbolic and Numeric Computing
In his paper "Analytical Computing", recently published in Dr. Dobbs, the journal for professional software developers, Laurent Bernardin argues the necessity of incorporating both symbolic and numeric capabilities into mathematics software packages. He illustrates this point with the problem of generating the Fibonacci sequence. Solving this problem efficiently requires both symbolic and numeric techniques, and a mathematics software package that does not house both will perform poorly.
The Fibonacci sequence can be defined as:
fib(n)=fib(n-1)+fib(n-2)
fib(0)=fib(1)=1
The purely numeric approach to generating the sequence is to write an iterative procedure, such as the following:
> fib:=proc(n)
> local r,s,i:
> r,s):=(1,1):
> for i from 2 to n do
> (r,s):=(s,r+s):
> end do:
> r:
> end proc;
Given n as input, this Maple procedure returns the nth term of the Fibonacci sequence. It works efficiently for moderate values of n but becomes labour intensive for larger values. The slow down occurs because the computational effort of an addition operation is proportional to the number of digits involved, which increases rapidly with each iteration of the above procedure. (The 100,000th term of the Fibonacci sequence has over 20,000 digits.)
By contrast, the purely symbolic approach to generating the sequence is to search for an explicit formula for the nth term. Maple does this quite handily with the rsolve()command:
> rsolve( {f(0)=1, f(1)=1,
> f(n)=f(n-1)+f(n-2)}, f(n));
Here we have the nth term of the Fibonacci sequence as a function of n. However, rounding this exact rational expression to an integer using symbolic techniques involves the time-consuming task of expanding terms raised to large exponents. Thus, neither the purely numeric nor the purely symbolic approaches generates the Fibonacci sequence efficiently.
The solution to this conundrum is a hybrid numeric-symbolic approach: evaluate the explicit function for the nth term numerically. Powers of rational expressions can be computed efficiently using log-arithms. This is, in fact, what Maple does.
This phenomenon of the Fibonacci sequence is a shadow of a more general theme: any problem class - be it differential equations, recurrence relations, or optimisa-tion - will have some instances best solved numerically, some best solved symbolically, and some best solved with a hybrid of the two. Thus, concludes Bernardin, even soft-ware packages that handle only narrow classes of problems must contain both sym-bolic and numeric capabilities. The combi-nation has been dubbed "analytical computing" and forms the basis for a whole new class of technical problem-solving software. |
|