| ![]() |
|||||||||||||||||||||||||||||||||||||||
|
Programming
We have already seen several aspects of the improvements in Mathematica 4 when working with arrays of machine numbers. One reason that works efficiently is that many operations such as But another aspect of efficient programming is to have useful primitives that make it easy to express problems directly and have it work efficiently, i.e., programmer time is also a valuable commodity. Below we see some enhancements to functional and list-based programming that should make it easy to express many programs very succinctly. Functional Programming
In Mathematica 4 there are basic extensions of the functional programming approach in
The following program adds
It is then easy to combine this construction with other ones such as
List Programming
The extensions to list operations include new operations such as
One of course naturally associates Below is an example that performs multiplication of integer sequences in base b.
The functions
This works just fine even for quite large numbers, in this case 100,000 digit numbers.
But it is more efficient to work in a slightly larger base, in this case base
The same ideas apply to polynomial and series multiplication. Below is an example of polynomial multiplication that is quite efficient for certain types of polynomials. As can be seen, it basically mimics the number multiplication algorithm.
In this case we have to define a function that returns a polynomial expression from its coefficient tensor.
First a simple check that we have gotten the details right.
This defines a random dense polynomial of degree
Converted by Mathematica June 4, 2000 |