|
Although compilation takes time, it can speed up a repetitive
computation overall. Mathematica's TAC determines when compilation will be
beneficial and applies it in just these cases.
|
|
When carrying out large repetitive numerical computations, either
requested by the user directly--for example creating a table--or
implicitly--solving a differential equation
numerically--Mathematica automatically generates optimized byte
code to speed up the computations, a process known as just-in-time
compilation.
The instructions created are chosen to be close to those found in the
machine code of a typical computer, and can thus be executed
quickly. For large expressions, compilation can speed up execution by
a factor of 20 or more. Many Mathematica functions, for
example NIntegrate, use compilation by default, while others,
for example the Table command, invoke compilation dynamically,
based on the type and complexity of the expression evaluated and the
number of evaluations requested.
| |