# Re: Calculyx

On Sun, Nov 23, 2014 at 8:47 PM, aparsloe <apars...@clear.net.nz> wrote:
> I've written a LaTeX package called "calculyx" which numerically evaluates
> mathematical expressions in LyX "before one's eyes" using instant preview.
> It is written in the expl3 language of LaTeX3 but is used just like any
> other LaTeX package. There is a link at
> http://wiki.lyx.org/Examples/Calculyx to a zipped archive currently in a
> Dropbox folder, and a screenshot (.png format) of a one-page LaTeX document
> and the resulting pdf with a few example calculations at
> https://www.dropbox.com/s/7djkyjs44bpraol/Screenshot%202014-11-24%2013.52.07.png?dl=0.
> The LaTeX may look complicated, but using LyX, all that is as ever hidden.
> One simply enters expressions in the LyX math editor as usual.
>
> Calculyx requires the three LaTeX3 bundles l3kernel,  l3packages and
> l3experimental. Because a main routine uses a  command that was introduced
> to l3kernel on 18 July 2014, the version of l3kernel must be later than
> this. The calculational engine for calculyx is the floating point module
> l3fp in l3kernel.
>
> I have tried to ensure as much as possible that calculyx reads expressions
> as mathematicians write them. For instance it will "digest" \sin 3x - 3\sin
> x + 4\sin^{3} x (for a specified value of x, say \pi/6) without parentheses
> around the arguments and with the superscript in the "wrong" but familiar
> place. It will "digest" the common arithmetic operators, plus variants like
> \times and \div, the familiar trigonometric and hyperbolic functions and
> their inverses, the exponential and natural logarithm, fractions (\frac,
> \tfrac), square root and \surd, factorials ( using !), binomial coefficients
> (\binom, \tbinom), \gcd, sums and products (\sum, \prod) including
> "infinite" sums and products, limits (\lim), derivatives (1st and 2nd
> order), including Cartesian 2-d and 3-d Laplacians, and definite integrals
> in one variable. Results are generally presented in the form: expression =
> result. There is also a (multi-column) table creating command and another
> which will iterate a function (for the chaos theorists).
>
> The package contains a novelty that I think could be exploited more widely.
> Some calculations are computationally intensive. So as not to burden the
> compilation of the pdf with them, these calculations can be "parked" either
> in a LyX note or in an inactive branch. Instant preview works in both places
> (with a caveat for LyX notes). The result of the calculation can be saved to
> a LaTeX control sequence. Calculyx automatically saves such control
> sequences to a file. They are then available for inserting elsewhere in the
> document -- even at the start, long before the place where the calculation
> is performed. If you are prepared to set up a converter and copier, then the
> file containing the control sequences can be saved in the document directory
> -- or copied to other directories whereby the results of those "parked"
> calculations are made available to these other documents. By this means
> selected items in LyX notes or inactive branches can play a part in
> compilation to pdf.
>
> Andrew

This is a very cool idea, Andrew. Thanks for implementing that! I
don't have time right now to play with new toys but I look forward to
testing it someday.

Scott