<< | Page list | >>
Back-of-envelope calculations using instant preview.
1. Numerica
The numerica
package enables the numerical evaluation of mathematical expressions in LyX 'before one's eyes' by means of the ‘mini LaTeX runs’ of the instant preview facility. The document does not need to be compiled to see the result of a calculation. The aim is to require as little change to the LaTeX form of a mathematical expression as possible. There should be no need to put the expression into a special calculator format. The package provides a command \eval
to wrap around a mathematical expression and, after evaluation, present either the bare result of the calculation or a display in the form expression = result. If the LyX math editor is used to create the mathematical expression (and instant preview is turned on), the result is displayed there 'immediately' (preview takes a moment or two to do its thing). Alternatively, the expression can be created in a TeX-code (or ERT) inset within a preview inset. Again, with instant preview on, the result is displayed 'immediately'.
1.1 Components and requirements.
numerica
is included in major TeX distributions like TeXLive or MiKTeX, or can be downloaded from CTAN. Supplementary packages numerica-plus
and numerica-tables
providing additional functionality are also available from the same sources. The package requires a number of LaTeX packages: amsmath
, mathtools
, and recent versions of the LaTeX3 bundles l3kernel
and l3packages
. (Much of l3kernel
is now part of standard LaTeX distributions.) numerica-tables
also requires the booktabs
package. The calculational engine used by numerica
is the LaTeX3 floating point module l3fp
included in l3kernel
(and now automatically in standard LaTeX distributions). l3fp
works to 16 significant figures.
1.2 Functionality
numerica
accepts (or tries to accept) LaTeX expressions 'as is', without requiring the insertion of asterisks for multiplication or extra parentheses to distinguish function arguments. If it is clear to a person what is meant, it should be clear to numerica
. It handles: numbers in decimal form or scientific notation; constants like \pi
, e
, \deg
; arithmetic operations +, -, *, /, ^ and LaTeX variants like \times
and \div
; \frac
, \tfrac
, \dfrac
; \sqrt
and \surd
; trigonometric and hyperbolic functions and inverses; logarithms and the exponential function; \max
, \min
and \gcd
; absolute values, ceiling and floor functions; binomial coefficients, factorials and double factorials; sums and products (including infinite sums and products); numerical comparisons; boolean operators; and a host of formatting commands. Although variables will generally be single letters from the roman or greek alphabets, they are not restricted to single tokens but can be primed or subscripted or distinguished by different fonts.
numerica-plus
provides a command to iterate functions or find fixed points; a command to find the zeros or local maxima or minima of functions; and a command to calculate the terms of recurrence relations like the Fibonacci sequence or orthogonal polynomials.
numerica-tables
provides a command to create mathematical tables in a wide variety of different styles within the overall constraints of the booktabs
package.
1.3 Categories
Category: numerica preview