How to conclude cleaning Maxima?

I want to use Maxima as a backend to solve some of the calculations used in my LaTeX input file. I have taken the following steps.

Step 1

Download and install Maxima.

Step 2

Create a batch file with a name cas.bat(for example) as follows.

rem cas.bat
echo off
set PATH=%PATH%;"C:\Program Files (x86)\Maxima-5.31.2\bin"
maxima --very-quiet -r %1 > solution.tex

Save the package in the same directory as your input file below. It is just for simplicity.

Step 3

Create an input file with a name main.tex(for example) as follows.

% main.tex
\documentclass[preview,border=12pt,12pt]{standalone}
\usepackage{amsmath}

\def\f(#1){(#1)^2-5*(#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 -shell-escape main, and you will get a good output as follows.

! enter image description here

Step 5

Done.

Questions

Apparently, Maxima's output is as follows. I do not know how to make it cleaner.

solution.tex

                                       1
                                       -
                                       2
$${{15}\over{4}}$$
                                     false

Now, my question is:

  • How to delete such texts?
  • \frac{15}{4} $$...$$?
+4
3

(1) , (.. $) (.. ;).

(2) TeX-ified (.. $$), tex1 tex. , tex1 , ( tex ).

, , , :

"x: 1/2$ print(tex1(\f(x)))$"

, Maxima. [1] , ​​, . [2].

[1] http://maxima.sourceforge.net/maximalist.html [2] http://maxima.sourceforge.net/relatedprojects.html

+7

LaTeX, maxiplot. maxima, Maxima. LaTeX, Maxima. Maxima LaTeX, , Maxima.

, TeXmacs. - ( , ), Maxima, Mathematica . , LaTeX.

+3

Maxima. . perl script, .

#!/usr/bin/perl

use strict;

my $var = $ARGV[0];
my $expr = $ARGV[1];

sub do_maxima_to_tex {
  my $m = shift;
  my $c = "maxima --batch-string='exptdispflag:false; print(tex1($m))\$'";
  my $e = `$c`;
  my @x = split(/\(%i\d+\)/,$e); # output contains stuff like (%i1)
  my $f = pop @x;  # remove everything before the echo of the last input
  while ($f=~/\A /) {$f=~s/\A .*\n//} # remove echo of input, which may be more than one line
  $f =~ s/\\\n//g; # maxima breaks latex tokens in the middle at end of line; fix this
  $f =~ s/\n/ /g; # if multiple lines, get it into one line
  $f =~ s/\s+\Z//; # get rid of final whitespace
  return $f;
}

my $e1 = do_maxima_to_tex("diff($expr,$var,1)");
my $e2 = do_maxima_to_tex("diff($expr,$var,2)");

print <<TEX;
The first derivative is \$$e1\$. Differentiating a second time,
we get \$$e2\$.
TEX

script a.pl,

a.pl z 3*z^4

:

The first derivative is $12\,z^3$. Differentiating a second time,
we get $36\,z^2$.

OP, script, , , write18 .

+2

All Articles