Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a calculator with LaTeX-syntax?

People also ask

Does LaTeX have a calculator?

The calculator package allows us to use LATEX as a calculator, with which we can perform many of the common scientific calculations (with the limita- tion in accuracy imposed by the TEX arithmetic). The calculus package uses calculator to compute simultaneously a function and its derivative.

Can you do math in LaTeX?

For many people the most useful part of LaTeX is the ability to typeset complex mathematical formulas. for the sake of simplicity, LaTeX separates the tasks of typesetting mathematics and typesetting normal text. This is achieved by the use of two operating modes, paragraph and math mode.

How do you show formulas in LaTeX?

The inline mode uses one of the delimiters: \ ( \), $ $ or \begin{math} \end{math} and the display mode has two versions: numbered and unnumbered. To print equations in display mode one these delimiters are used: \[ \], $$ $$, \begin{displaymath} \end{displaymath} or \begin{equation} \end{equation}.


WolframAlpha can take input in TeX form.

http://blog.wolframalpha.com/2010/09/30/talk-to-wolframalpha-in-tex/


The LaTeXCalc project is designed to do just that. It will read a TeX file and do the computations. For more information check out the home page at http://latexcalc.sourceforge.net/


The calc package allows you to do some calculations in source, but only within commands like \setcounter and \addtolength. As far as I can tell, this is not what you want.

If you already use sage, then the sagetex package is pretty awesome (if not, it's overkill). It allows you get nicely formatted output from input like this:

The square of
$\begin{pmatrix}
1 & 2 \\
3 & 4
\end{pmatrix}$
is \sage{matrix([[1, 2], [3,4]])^2}.

The prime factorization of the current page number is \sage{factor(\thepage)}

As Andy says, the answer is yes there is a calculator that can understand most latex formulas: Emacs.

Try the following steps (assuming vanilla emacs):

  1. Open emacs
  2. Open your .tex file (or activate latex-mode)
  3. position the point somewhere between the two $$ or e.g. inside the begin/end environment of the formula (or even matrix).
  4. use calc embedded mode for maximum awesomeness

So with point in the formula you gave above:

$\frac{154,7}{25} - (289 - \frac{1337}{42})$

press C-x * d to duplicate the formula in the line below and enter calc-embedded mode which should already have activated a latex variant of calc for you. Your buffer now looks like this:

$\frac{154,7}{25} - (289 - \frac{1337}{42})$

$\frac{-37651}{150}$`

Note that the fraction as already been transformed as far as possible. Doing the same again (C-x * d) and pressing c f to convert the fractional into a floating point number yields the following buffer:

$\frac{154,7}{25} - (289 - \frac{1337}{42})$

$\frac{-37651}{150}$

$-251.006666667$

I used C-x * d to duplicate the formula and then enter embedded mode in order to have the intermediate values, however there is also C-x * e which avoids the duplication and simply enters embedded mode for the current formula.

If you are interested you should really have a look at the info page for Emacs Calc - Embedded Mode. And in general the help for the Gnu Emaca Calculator together with the awesome interactive tutorial.


You can run an R function called Sweave on a (mostly TeX with some R) file that can replace R expressions with their results in Tex.

A tutorial can be found here: http://www.scribd.com/doc/6451985/Learning-to-Sweave-in-APA-Style


My calculator can do that. To get the formatted output, double-click the result formula and press ctrl+c to copy it.

It can do fairly advanced stuff too (differentiation, easy integrals (and not that easy ones)...).

https://calculator-algebra.org/

A sample computation:

https://calculator-algebra.org:8166/#%7B%22currentPage%22%3A%22calculator%22%2C%22calculatorInput%22%3A%22%5C%5Cfrac%7B1%2B2%7D%7B3%7D%3B%20d%2Fdx(arctan%20(2x%2B3))%22%2C%22monitoring%22%3A%22true%22%7D


There is a way to do what you want just not quite how you describe.

You can use the fp package (\usepackage[options]{fp}) the floating point package will do anything you want; solving equations, adding dividing and many more. Unfortunately it will not read the LaTeX math you instead have to do something a little different, the documentation is very poor so I'll give an example here.

for instance if you want to do (2x3)/5 you would type:

\FPmul\p{2}{3}           % \p is the assignment of the operation 2x3
\FPupn\p{\p{} 7 round}   % upn evaluates the assignment \p and rounds to 7dp
\FPdiv\q{\p}{5}          % divides the assigned value p by 5 names result q
\FPupn\q{\q{} 4 round}   % rounds the result to 4 decimal places and evaluates
$\frac{2\times3}{5}=\FPprint\q$  % This will print the result of the calculations in the math.

the FP commands are always ibvisible, only FPprint prints the result associated with it so your documents will not be messy, FP commands can be placed wherever you wish (not verb) as long as they are before the associated FPprint.