mathematica 8.0 and psfrag - latex

I recently updated from mathematica 7.0 to 8.0, and have now encountered problem with replacing my plot labels with LaTeX code using the psfrag package. Everything worked perfectly with the earlier version and the exact same plots, but now psfrag leaves all the labels unchanged. I use Kile on Ubuntu 11.04 for LaTeX editing.
For example, in Mathematica:
plot = Plot[x, {x, -0.1, 0.1},
AxesLabel -> {eps, SUM}, BaseStyle -> {FontSize -> 10}]
Export["plot.eps", plot]
and then in LaTeX:
\begin{figure}
\psfrag{eps}{$\epsilon$}
\psfrag{SUM}{$\Sigma$}
\includegraphics{plot.eps}
\end{figure}
This should now replace labels with LaTeX typesetting, but nothing happens. Any suggestions how to solve this? Does anyone know if there is a difference in how Mathematica 8 encodes text in eps files compared to earlier versions?

There's no difference in how the EPS is encoded. The problem is that the PS code that makes the text in the v7 output (note that Mma uses bind def to create shortcuts for a lot of PS code, see the top of the generated EPS files for details):
%%IncludeResource: font Times-Roman-MISO
%%IncludeFont: Times-Roman-MISO
10 /Times-Roman-MISO Msf
0 8 m
(SUM) N
has been replaced in v8 with
%%IncludeResource: font Times-Roman-MISO
%%IncludeFont: Times-Roman-MISO
10 /Times-Roman-MISO Msf
p
0.75 9 m
(S) N
P
p
6 9 m
(U) N
P
p
14.25 9 m
(M) N
This means that psfrag can not grab hold of the tags.
I can't find how to fix this in the Mma export options.
At the moment, the only work-around I can think of (and I've tested that works) is to use single letter tags for the axes labels, e.g.
plot = Plot[x, {x, -0.1, 0.1}, AxesLabel -> {"e", "s"},
BaseStyle -> {FontSize -> 10}]
Export["plot8.eps", plot]
\begin{figure}[h]
\psfrag{e}{$\epsilon$}
\psfrag{s}{$\Sigma$}
\includegraphics{plot8.eps}
\end{figure}
Note:
The reasons for maybe wanting to use psfrag are well stated in http://www.reimeika.ca/marco/prettyplots/
Now, those tags don’t look too good
(and make little sense to boot).
However the idea is to ultimately
include the plot in a paper or report
made with LaTeX, and so the real point
to the tags is to use them as markers
for the psfrag package which allows to
replace text within EPS graphs. This
way of labeling has three big
advantages over hardcoding the tags
into the figure. First is consistency,
as the fonts will be the same as those
in the article. Second is the fact
that LaTeX's mathematical engine can
be used to the fullest extent within
the plot. Last but not least, it
allows changing notation easily within
the .tex file, as opposed to having to
recreate the plot from scratch.
Addendum:
The package psfrag only works with EPS graphics and thus only with latex.
If you want to use psfrag and pdflatex, then see the tex.SE question
Using psfrag with pdflatex

Tried both 7.0.1 and 8.0.1 and worked well for me. Hence, I cannot reproduce your error. (Maybe just a typo, case sensitivity etc.). Anyway, I agree that LateX modification is almost obligatory for publications. First I also used PSFrag, but very often I also don't like the positioning of the labels, especially if you place more complex expressions. Therefore I suggest an intermediate step via PSTricks. This looks something like this:
\documentclass[floatfig,isolatin,amsthm,amsmath,amsfont,amstext,12pt,fullpage,pslatex,amsref]{scrartcl}
\usepackage{amstext}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{graphicx}
\usepackage{float}
\usepackage{epic}
\usepackage{eepic}
\usepackage{color}
\pagestyle{empty}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}(0,0)(13.0,7.8)
%\psgrid(0,0)(0,0)(13,7.8)
% need the grid only in the beginning for positioning
\rput[c](10.7,3.8){\includegraphics{plot.eps}}
% put labels.
\rput[c]{90}(9.5,4){\Large{$\frac{E^2_\text{tot}}{V M_\mathrm{S}}$}}
\rput[c]{0}(6,6.0){$x/h$}
% also to put extra lines, arrows, comments, etc. in LaTeX style, e.g.:
% \psline[linecolor=green,linewidth=2pt,linestyle=dashed]{->}(3.5,3.05)(9.1,3.05)
\end{pspicture}
\end{document}
So there is some work you have to do by hand, but usually it is worth the time as the result really looks better, especially if it is for publication. However, keep in mind that in standard settings LaTeX uses the Computer Modern Font for formulae. This is not identical with e.g. Times New Roman, the typical choice for text. You can change this with the mathptmx package.

You can write the "typeset" form in Mathematica directly, then it'll be already in the .eps file and you can just include the .eps as is.
plot = Plot[x, {x, -0.1, 0.1}, AxesLabel -> {"[\eps], [\Sigma]}, BaseStyle -> {FontSize -> 10}]
Just do [esc]+"eps"+[esc] and you'll get an epsilon, or insert it from the toolbox. Same for the sigma.

Related

Latex/Miktex: Undefined citations

I am writing a latex script for my work, and I am having infinite trouble in getting the references in the PDF. My code is shown below, and I am using MikTex 2.9 on RStudio. Some background information that might be relevant:
I am using Mendeley for my references, which I have set up correctly (as it seems) to Enable bibtex syncing
The .bib file doesn't seem to look strange to me (Irungu is added below)
I am using the exact same script as my colleagues (apart from the different path referring to my articles), and they are having no issues compiling it into pdf.
The errors regarding citations are:
Citation Draganovic2013 on page 1 undefined on input line xx
Citation Irungu2019 on page 1 undefined on input line xx
There were undefined citations
I hope one of you is able to help me out!
Cheers!
#article{Irungu2019,
abstract = {A composite blend consisting of sunflower cake, maize germ, wheat bran, fresh water shrimps and cassava flour was extruded using a single-screw extruder to produce expanded fish feed pellets. The effects of temperature (80–120 °C), die diameter (2–4 mm), and feed pre-conditioning time (50–150 s; steam 400 kPa) on properties of the pellets (expansion ratio, bulk density, floatability, durability, water absorption, water solubility, water stability, and in-vitro protein digestibility) were investigated using response surface methodology. Regression equations describing the effect of each variable on the product responses were obtained. The pellets extruded using a factor combination of 120 °C extruder barrel temperature, 2 mm die diameter, and 100 s of feed pre-conditioning time gave most desirable pellet floatability (100{\%}), durability index (99{\%}), expansion ratio (2.64), water absorption index (4.12), water solubility index (9.31), water stability (87{\%}), bulk density (479 g/L), and in vitro protein digestibility (69.97{\%}) with a composite desirability of 0.88. Practical applications: Extrusion is a modern feed processing method whose use is fast gaining popularity among small feed processors in developing countries. However, extrusion is a process that involves many parameters that need to be optimized for desirable end properties. These findings guide fish feed manufacturers on the optimum conditions for single screw extruders for production of feeds with desirable properties especially for the fish types that are top feeders. In addition, the results offer important insights on how temperature, die diameter, and feed pre-conditioning, may be manipulated to influence properties of extruded aquafeed when using simple low-cost small-scale extruders.},
author = {Irungu, Francis Gichuho and Mutungi, Christopher and Faraj, Abdul and Affognon, Hippolyte and Ekesi, Sunday and Nakimbugwe, Dorothy and Fiaboe, Komi K.M.},
doi = {10.1111/jfpe.12980},
file = {:L$\backslash$:/Marjanne/ScientificArticles/Irungu2019.pdf:pdf},
issn = {17454530},
journal = {Journal of Food Process Engineering},
number = {2},
pages = {1--12},
title = {{Optimization of extruder cooking conditions for the manufacture of fish feeds using response surface methodology}},
volume = {42},
year = {2019}
}
\documentclass[10pt,a4paper]{article}
\usepackage{etoolbox}
\usepackage{mathpazo}
\renewcommand{\sfdefault}{lmss}
\renewcommand{\ttdefault}{lmtt}
\usepackage{geometry}
\usepackage[usenames,dvipsnames]{xcolor}
% \geometry{verbose,tmargin=2cm,bmargin=2cm,lmargin=2.5cm,rmargin=2.5cm}
\geometry{verbose,tmargin=2cm,bmargin=2cm,lmargin=2.5cm,rmargin=2.5cm}
\usepackage[margin=10pt,font=small,labelfont=bf,labelsep=colon]{caption}
\usepackage{amstext}
%% \usepackage{esint}
\usepackage[english]{babel}
\usepackage{eurosym}
\usepackage{booktabs}
\usepackage[parfill]{parskip}
\usepackage[round]{natbib}
%\usepackage{caption}
\usepackage{pdfpages}
\usepackage[figuresright]{rotating}
\usepackage{longtable}
\usepackage[version=4]{mhchem}
\usepackage{todonotes}
\usepackage{hyperref}
\usepackage{subfig}
\usepackage{array}
\usepackage{float}
\usepackage{lipsum}
\usepackage{lastpage}
\usetikzlibrary{patterns}
\usetikzlibrary{shapes.geometric}
\usepackage{textcomp}
\begin{document}
\title[Title of Document]
\begin{document}
\begin{titlepage}
\maketitle
\end{titlepage}
\section {Introduction}
Introduction is written here, but not relevant for this question.
\section {Background}
Here I write some text and refer to an article of Draganovic from 2013 \citep{Draganovic2013}. \\
In another section, I would like to refer to Irungu from 2019 \citep{Irungu2019}.\\
Current project will investigate the possibilities to re-evaluate Sustainable Fiber Technology's Wheat Straw Co-Product, by using it as a (partial) replacement of wheat gluten and/or starch in aquafeed. Being relatively high in lignin (20 - 40\% based on 30 - 50\% solids), the product is a potential excellent binder.
\section {Rest of the document}
Doesn't pose any significant errors.
\bibliographystyle{plainnat}
\bibliography{C://Users/Marjanne/Documents/April8/library}
\end{document}
I have not any problems with this LaTeX code (even if I use a Mac): there are anyway a couple of problems within your code:
The title is given as \title[Title of Document] and not as \title{Title of Document}
There are 2 \begin{document}: I do not know if this is just a typo when you copied your code here
Are you sure that the path of your .bib file is correct? I suggest to write just \bibliography{library} and put the library.bib file in the same directory of the tex file on which you are working on.
Moreover, have a look also at https://tex.stackexchange.com/ for questions about Tex, LaTeX.
EDIT: Make sure that you are compling your tex files with
pdflatex (or latex)
bibtex
pdflatex (or latex)
pdflatex (or latex)
run first pdflatex "file" -interaction=nonstopmode
then
biber "file"
then again
pdflatex "file" -interaction=nonstopmode
Should work
Even though the correct reference/citation was called from the bib file, the output generated a question mark in some cases. After making sure all files ended with .tex separately and in the main + checking if the reference file had a .bib extension, it worked however. In one case, simply renaming a file seemed to do the job.

Equation not displayed in latex

The equation below does not display in latex. Also, the introductory text does not display properly(all words together without space and in italics)
A common form of this potential is the 12-6 Lennard Jones (LJ) potential
expressed as equation 2.7
\begin{align}
U_{ij}= 4\epsilon_{ij}[(\frac{\sigma_{ij}}{r_{ij})^12-
(\frac{\sigma_{ij}}{r_{ij})^6]
\end{align}
Also, in the text below, all words are together without space and in italics.
Where \epsilon_{ij} and \sigma{ij} represent well depth and diameter of
the atom respectively. \epsilon_{ij} and \sigma_{ij} for unlike atoms
are determined using Lorentz-Berthelot combination rules [44] given in
equations 2.8 and 2.9
Your help is appreciated.
I attach here a picture of the output.
This is because you're not using inline math mode properly. In the image you posted
it shows that your text is preceded by (what looks like) \epsilon_{ij}. \epsilon requires a math font, and therefore you should use $\epsilon_{ij}$. The same goes for any inline math you want to typeset. This would be the suggested/proper coding:
A common form of this potential is the 12-6 Lennard Jones (LJ) potential
expressed as equation~\eqref{eq:lj-potential},
\begin{equation}
U_{ij} = 4 \epsilon_{ij} [ (\frac{\sigma_{ij}}{r_{ij})^{12}
- (\frac{\sigma_{ij}}{r_{ij})^6 ] \label{eq:lj-potential}
\end{equation}
where $\epsilon_{ij}$ and $\sigma{ij}$ represent well depth and diameter of
the atom respectively. $\epsilon_{ij}$ and $\sigma_{ij}$ for unlike atoms
are determined using Lorentz-Berthelot combination rules~\cite{lorentz-berthelot}
given in equations~\eqref{eq:epsilon} and~\eqref{eq:sigma}.
Note the following:
Use equation for a single-line numbered equation; align is for multi-line equations (that may require alignment).
No blank line (paragraph break) before equation.
Use \labels and \refs (or \eqref, since you're using amsmath) since equation numbers can change. Let TeX take care of storing and recalling these numbers.
Use \cite to reference something in a bibliography.
Use $...$ (or \(...\)) for inline math (already discussed above).
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
U_{ij}= 4\epsilon_{ij}[
(\frac{
\sigma_{ij}
}{
(r_{ij})^{12} -
\frac{
\sigma_{ij}
}{(r_{ij})^6
}
}]
\end{align}
\end{document}
three groups were not closed properly in the equation.
Read about amsmath package.
I suggest you try to write as clean as possible.
Output

Octave: saving figure with greek letters and subscripts

I'm currently trying to save a stress vs. strain curve using Octave. On this plot, I want to include text showing the equation for calculating engineering stress and engineering strain. Both of these require greek letters (\sigma and \epsilon respectively) as well as subscripts for the formulae.
Currently, using print with -deps, -dpng, or any other device, it creates a file, however the greek letters appear as the words "sigma" and "epsilon", and wherever I have a subscript, such as 0, it just appears as "_0". This looks very unprofessional.
Since I'm generating some 25 graphs, I don't want to have to go through and do a screenshot for each one. Does octave support saving the generated figure as displayed? I intend to use the generated files in a LaTeX document later (preferably as png so I can email them separately too).
I've also tried changing the "graphics_toolkit" option between fltk and gnuplot however it doesn't seem to help.
Attached to this post is a screenshot of the desired results and the actual results.
I am currently "not allowed" to post images, so I'll link them:
http://i.imgur.com/Tjt5Ecn.png (screenshot, desired result) and http://i.imgur.com/SP3hekd.png (directly saved, actual result)
Does anyone know a good way to print a figure from Octave which includes greek characters and subscripts in the titles?
Since you plan to use your graph in a Latex document, generating the graphs with -depslatex and converting them to pdf is a good idea . (Results look slightly better than direct -dpdflatex).
With -depslatex, you can include Latex code in your figures that will be written to a separate tex file.
Note that you need to use double backslashes \\ to export a single backslash.
graphics_toolkit("gnuplot");
...
legend("$\\varepsilon$");
print(sprintf("graph%s_%d.eps", name, type), '-depslatex', '-S200,270', '-F:9');
system(sprintf("epstopdf graph%s_%d.eps", name, type));
On the Latex side, you then \input the tex file generated by Octave. On the plus side, since you need 25 graphs, you can automatize this process on both sides Octave and Latex.
\newcommand{\mygraph}[1]{%
\graphicspath{{./figures/}}
\resizebox{0.495\linewidth}{!}{\relscale{1.0}\small%
\input{./figures/#1.tex}
}%
}
\mygraph{graph1_1}
Here, a Latex command \mygraph is defined to scale and include a figure located in a subfolder.
(I am using Octave 4.0.0 with gnuplot 4.4 on Ubuntu 12)

How do I break a long equation over lines?

I am trying to add an equation in a new line. The problem is that the equation is too long for the line, and I need to break it manually. Otherwise, it just overlaps to the right column, or to the right margins (and looks ugly...).
Is there a way LaTeX can brake the equation for me, so it seems nice?
I'm attaching my latex code:
\begin{align*}
f(n)-f(0) &= A(n)-B(n)-C(n)-D(n)\cdot d-\left(A(0)-B(0)-C(0)-D(0)\cdot d\right) \\
&= A(n)-0-X-D(n)\cdot d-\left(0-0-0-0\right) \\
&= A(n)-X-D(n)\cdot d
\end{align*}
The problematic line is the first line, which is too long.
The breqn package is designed to split long equations automatically. It works very well in the majority of situations, but it's not as mature as the amsmath package. Here's how you'd write your example equation:
\documentclass{article}
\usepackage{breqn}
\begin{document}
\begin{dmath}
f(n)-f(0) = A(n)-B(n)-C(n)-D(n)\cdot d-\left(A(0)-B(0)-C(0)-D(0)\cdot d\right)
= A(n)-0-X-D(n)\cdot d-\left(0-0-0-0\right)
= A(n)-X-D(n)\cdot d
\end{dmath}
\end{document}
Note there is no markup for alignment or newlines, but the output looks essentially the same as if you used align.
I usually prefer to handle this by using the amsmath package and using the split structure. There are a bunch of useful structures in there for splitting equations across lines, but that's usually the simplest to use.
Many TeX installations will already have the package, but you can also get it from the AMS website.
The standard approach I've used in the past is an eqnarray. See for example this page.
As far as I know, this is not possible. When working inside a display, you are responsible for line breaks. How to line break, and how to continue on the next line in case of brackets, is a tough question for humans (check, for instance, the relevant section in Grätzer, "Math into LaTeX"), let alone for a computer.
Example:
when you break the first line after \left(, you need a \right. at the end, and \left. at the beginning of the next line (otherwise you'll get an error). Moreover, you'd want the beginning of the next line to be further right than the bracket produced by \left(

Is there a calculator with LaTeX-syntax?

When I write math in LaTeX I often need to perform simple arithmetic on numbers in my LaTeX source, like 515.1544 + 454 = ???.
I usually copy-paste the LaTeX code into Google to get the result, but I still have to manually change the syntax, e.g.
\frac{154,7}{25} - (289 - \frac{1337}{42})
must be changed to
154,7/25 - (289 - 1337/42)
It seems trivial to write a program to do this for the most commonly used operations.
Is there a calculator which understand this syntax?
EDIT:
I know that doing this perfectly is impossible (because of the halting problem). Doing it for the simple cases I need is trivial. \frac, \cdot, \sqrt and a few other tags would do the trick. The program could just return an error for cases it does not understand.
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):
Open emacs
Open your .tex file (or activate latex-mode)
position the point somewhere between the two $$ or e.g. inside the begin/end environment of the formula (or even matrix).
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.
You could just paste it into symbolab which as a bonus has free step by step solutions. Also since symbolab uses mathquill it instantly formats your latex.
Considering that LaTeX itself is a Turing-complete markup language I strongly doubt you can build something like this that isn't built directly into LaTeX. Furthermore, LaTeX math matkup itself has next to no semantic meaning, it merely describes the visual appearance.
That being said, you can probably hack together something which recognizes a non-programmable subset of LaTeX math markup and spits out the result in the same way. If all you're interested in is simple arithmetics with fractions and integers (careful with decimal fractions, though, as they may appear as 3{,}141... in German texts :)) this shouldn't be too hard. But once you start with integrals, matrices, etc. I fear that LaTeX lacks expressiveness to accurately describe your intentions. It is a document preparation system, after all and thus not very suitable as input for computer algebra systems.
Side note: You can switch to Word which has—in its current version—a math markup language which is sufficiently LaTeX-like (by now it even supports LaTeX markup) and yet still Google-friendly for simpler terms:
With the free Microsoft Math add-in you can even let Word calculate expressions in-place:
There is none, because it is generally not possible.
LaTeX math mode markup is presentational markup and there are cases in which it does not provide enough information to calculate the expression.
That was one of the reasons MathML content markup was created and also why MathML is used in Mathematica. MathML actually is sort of two languages in one:
presentation markup
content markup
To accomplish what you are after you'll have to have MathML with comibned presentation and content markup (see MathML spec).
In my opinion your best bet is to use MathML (even if it is verbose) and convert to LaTeX when necessary. That said, I also like LaTeX syntax best and maybe what we need is a compact syntax for MathML (something similar in spirit to RelaxNG compact syntax).
For calculations with LaTeX you can use a CalcTeX package.
This package understand elements of LaTeX language and makes an calculations, for example your problem is avialble on
http://sg.bzip.pl/CalcTeX/examples/frac.tgz
or just please write
\noindent
For calculation please use following enviromentals
$515.1544 + 454$
or
\[ \frac{154.7}{25}-(289-\frac{1337}{42.})
\]
or
\begin{equation}
154.7/25-(289-1337/42.)
\end{equation}
For more info please visite project web site or contact author of this project.
For performing the math within your LaTeX itself, you might also look into the pgfmath package, which is more powerful and convenient than the calc package. You can find out how to use it from Part VI of The TikZ and PGF Packages Manual, which you can find here (version 2.10 currently): http://mirror.unl.edu/ctan/graphics/pgf/base/doc/generic/pgf/pgfmanual.pdf
Emacs calc-mode accepts latex-input. I use it daily. Press "d", followed by "L" to enter latex input mode. Press "'" to open a prompt where you can paste your tex.
Anyone saing it is not possible is wrong.
IIRC Mathematica can do it.
There is none, because it is generally not possible. LaTeX math mode
markup is presentational markup and there are cases in which it does
not provide enough information to calculate the expression.
You are right. LaTeX as it is does not provide enough info to make any calculations.Moreover, it does not represent any information to do it. But nobody prevents to wright in LaTeX format a text that contains such an information.
It is a difficult path, because you need to build a system of rules superimposed on what content ofthe text in Latex format needs to contain that it would be recognizable by your interpreter. And then convince the user that it is necessary to learn, etc. etc...
The easiest way to create a logical and intuitive calculator of mathematical expressions. And the expression is already possible to convert latex. It's almost like what you said. This is implemented in the program which I have pointed to. AnEasyCalc allows to type an expression as you type the plane text in any text editor. It checks, calculates and generate LateX string by its own then. Its very easy and rapid work. Just try and you will see that.
This is not exactly what you are asking for but it is a nice package
that you can include in a LaTeX document to do all kind of operations including arithmetic, calculus and even vectors and matrices:
The package name is "calculator"
http://mirror.unl.edu/ctan/macros/latex/contrib/calculator/calculator.pdf
The latex2sympy2 Python library can parse LaTeX math expressions.
from latex2sympy2 import latex2sympy
tex_str = r"""YOUR TEX MATH HERE"""
tex_str = r"\frac{9\pi}{\ln(12)}+22" # example TeX math
sympy_object = latex2sympy(tex_str)
evaluated_tex = float(sympy_object.evalf())
print(evaluated_tex)
This Python 3 code evaluates 9𝜋/ln(12)+22 (in its LaTeX from above) to 33.37842899841745.
The snippet above only handles basic algebraic simplification (math expressions without variables). Since the library converts LaTeX math to SymPy objects, the above code can easily be tweaked and extended to handle much more complicated LaTeX math (including solving derivatives, integrals, etc...).
The latex2sympy2 library can be installed via the pip command: pip install --user latex2sympy2
<>
try the AnEasyCalc program. It allows to get the latex formula very easy:
http://steamandwater.od.ua/AnEasyCalc/
:)

Resources