15
5
I want to make use of Mathematica as the backend to solve some computations used in my LaTeX input file. As I have no knowledge to make it in Mathematica, I used Maxima as explained in the following steps that I got somewhere on the internet.
Step 1
Download and install Maxima.
Step 2
Create a batch file named cas.bat
(for example) as follows.
rem cas.bat
echo off
set PATH=%PATH%;"C:\Program Files (x86)\Maxima5.31.2\bin"
maxima veryquiet r %1 > solution.tex
Save the batch in the same directory in which your input file below exists. It is just for the sake of simplicity.
Step 3
Create the input file named main.tex
(for example) as follows.
% main.tex
\documentclass[preview,border=12pt,12pt]{standalone}
\usepackage{amsmath}
\def\f(#1){(#1)^25*(#1)+6}
\begin{document}
\section{Problem}
Evaluate $\f(x)$ for $x=\frac 1 2$.
\section{Solution}
\immediate\write18{cas "x: 1/2;tex(\f(x));"}
\input{solution}
\end{document}
Step 4
Compile the input file with pdflatex shellescape main
and you will get a nice output as follows.
Questions
Apparently the output of Maxima is as follows. I don't know how to make it cleaner.
solution.tex
1

2
$${{15}\over{4}}$$
false
Now, my questions are
 how to implement the scenario above in Mathematica?
 if Mathematica also produces the unnecessary texts, how to remove such texts?
 if Mathematica also produces the same output format, how to obtain just
\frac{15}{4}
without$$...$$
?
Perhaps not here, but http://stackoverflow.com/a/1688457/353410
– Dr. belisarius – 20131202T02:06:07.970@DonutE.Knot You can create a
– rm rf – 20131202T02:45:58.110MathematicaScript
. I don't have the time to do this now, but you can look at questions and answers here using this. How to use Mathematica functions in Python programs? and Reading from STDIN, or: how to pipe data into Mathematica might be of use.How to show
*
for multiplication inx^2 5 x+6
produced bySplice
? Some plotting macros (PSTricks) need the*
. – kiss my armpit – 20131202T03:20:45.4301Underused indeed. I do not recall ever having used it, but it is a very good match for this question. +1! – Sjoerd C. de Vries – 20131202T10:34:51.753
+1 for a very useful post. As of Version 10
– gwr – 20150925T15:16:05.570Splice
has been superseded byFileTemplate
as the documentation tells me.Could you explain how to use
FileTemplate
in spite ofSplice
that has been superseded? – Money Oriented Programmer – 20160806T16:23:36.393