1

I am using LaTeX to show the solution to some equations which requires a lot of tedious and repetitive changing of terms. There are plenty of online solvers that can actually solve the equations themselves. However, are there any tools (packages or otherwise) that take TeX equations as input, parse and solve them, and then output the step-by-step solution as TeX?

For example, if I give it the following input:

\[ \frac{x^2}{2} = 1 \]

I would like it to return

\[ x^2 = 2 \]
\[ x = \sqrt{2} \]
  • 3
    TeX is for presenting your data and results. It was not invented to make you, as the author, obsolete. – Johannes_B Jun 3 at 15:51
  • 7
    Solving and typesetting a series of equations are two rather separate endeavors. TeX and friends are planted firmly on the typesetting side. – Mico Jun 3 at 15:56
  • I understand. I didn't mean to restrict the tools to the TeX ecosystem - any kind of solution would do. – sloth Jun 3 at 16:20
  • 3
    The sagetex package lets you work with computer algebra system SAGE to solve such problems. You'd have to give the steps, such as in my answer here. With many cases, you could define a function to automate the process such as I did here. SAGE isn't part of LaTeX. Use Cocalc to get started. – DJP Jun 3 at 17:18
  • No, the last line of the result would be $$ x = \pm \sqrt2 $$. Note the \pm. – wipet Jun 4 at 12:25
2

The solution exists :-) but for me it is necessary one year :-)...before to understand and to build a code. You can try to use the calculator and calculus packages (see pag. 24).

I have only copy and past the code of the page 26 as example. For my humble opinion it is not very easy.

enter image description here

\documentclass[a4paper,12pt]{article}
\usepackage{mathtools,amssymb}
\usepackage{calculator,calculus}

\begin{document}
% exp(-t)
\SCALEVARIABLEfunction
{-1}{\EXPfunction}
{\NEGEXPfunction}
% exp(-t)cos(t)
\PRODUCTfunction
{\NEGEXPfunction}
{\COSfunction}
{\NEGEXPCOSfunction}
% 3t^2-2exp(-t)cos(t)
\LINEARCOMBINATIONfunction
{3}{\SQUAREfunction}
{-2}{\NEGEXPCOSfunction}
{\myfunction}
\myfunction{5}{\sol}{\Dsol}
If
\[
f(t)=3t^2-2\mathrm{e}^{-t}\cos t
\]
then
\[
\begin{gathered}
f(5)=\sol\\
f'(5)=\Dsol
\end{gathered}
\]


\end{document}

ADDENDUM:

If you use Mathematica 12, exist a package called latexalpha2 that execute the Wolfram Language (Mathematica) source codes in a LaTeX document. For example to pag. 4 there is a step to solve an equation of second degree.

enter image description here

| improve this answer | |
  • 1
    @ArtificialStupidity Spectacular....wow....+1. – Sebastiano Aug 1 at 16:23
  • 1
    @ArtificialStupidity ahahahah..my sincere compliments..... – Sebastiano Aug 1 at 16:29
1

A solution with Mathematica (not PSTricks) only for either fun or comparison purposes.

nEqns = 250;
coeffs = {};
While[Length[coeffs] < nEqns, 
 candidate = {#1 #3, #2 #3 + #1 #4, #2 #4} & @@ 
   RandomInteger[{-10, 10}, 4];
 acceptable = (Not[MemberQ[coeffs, #]] && First[#] != 0 && 
      GCD @@ # == 1) &@candidate;
 If[acceptable, AppendTo[coeffs, candidate]];]

({x^2, x, 1}.# == 0) & /@ coeffs // TableForm // TeXForm

Output

All equations below can be factorized.

\begin{array}{c}
 -72 x^2+35 x+50=0 \\
 21 x^2+50 x+25=0 \\
 -x^2-19 x-90=0 \\
 70 x^2-33 x-4=0 \\
 14 x^2-19 x-3=0 \\
 60 x^2+32 x-7=0 \\
 -63 x^2-47 x+6=0 \\
 80 x^2+122 x+45=0 \\
 2 x^2+x-36=0 \\
 -4 x^2+49 x-90=0 \\
 21 x^2-52 x+7=0 \\
 35 x^2-18 x-81=0 \\
 -7 x^2+65 x-72=0 \\
 -21 x^2-79 x-30=0 \\
 42 x^2+13 x+1=0 \\
 36 x^2-77 x+40=0 \\
 10 x^2-79 x+63=0 \\
 5 x^2+31 x+6=0 \\
 -35 x^2+31 x-6=0 \\
 -10 x^2-31 x+63=0 \\
 27 x^2+102 x+40=0 \\
 6 x^2+23 x-35=0 \\
 -12 x^2+8 x-1=0 \\
 x^2+8 x+16=0 \\
 70 x^2+43 x-5=0 \\
 -50 x^2-55 x-14=0 \\
 7 x^2-15 x+8=0 \\
 -8 x^2+61 x-35=0 \\
 -35 x^2+58 x+9=0 \\
 -30 x^2-47 x+5=0 \\
 -10 x^2+101 x-10=0 \\
 35 x^2+82 x+48=0 \\
 9 x^2-9 x-40=0 \\
 -7 x^2-16 x+15=0 \\
 -6 x^2-5 x+4=0 \\
 -30 x^2+19 x+63=0 \\
 5 x^2+8 x-21=0 \\
 -10 x^2-29 x-18=0 \\
 -7 x^2+26 x-15=0 \\
 -x^2+x+20=0 \\
 2 x^2+7 x+5=0 \\
 -9 x^2-26 x-16=0 \\
 x^2+14 x+45=0 \\
 -2 x^2+11 x+63=0 \\
 -21 x^2-40 x+100=0 \\
 -8 x^2-79 x+10=0 \\
 10 x^2+79 x-8=0 \\
 7 x^2+52 x-32=0 \\
 -72 x^2+5 x+25=0 \\
 6 x^2-7 x-20=0 \\
 -18 x^2+39 x-20=0 \\
 -30 x^2-23 x+45=0 \\
 15 x^2-44 x-20=0 \\
 8 x^2+x-7=0 \\
 7 x^2+x-8=0 \\
 -21 x^2+67 x+10=0 \\
 63 x^2+58 x-16=0 \\
 -15 x^2-56 x-49=0 \\
 -36 x^2-48 x-7=0 \\
 x^2+9 x+18=0 \\
 -49 x^2+42 x+27=0 \\
 -2 x^2+15 x-27=0 \\
 6 x^2-37 x+56=0 \\
 6 x^2+41 x+30=0 \\
 -9 x^2+73 x-70=0 \\
 -10 x^2+17 x-3=0 \\
 -10 x^2-29 x+72=0 \\
 5 x^2-48 x+27=0 \\
 25 x^2+10 x-48=0 \\
 7 x^2+6 x-1=0 \\
 x^2+6 x-7=0 \\
 7 x^2-52 x+21=0 \\
 -4 x^2+45 x-50=0 \\
 16 x^2-34 x+15=0 \\
 -63 x^2-23 x+56=0 \\
 -3 x^2+2 x+1=0 \\
 28 x^2-39 x+5=0 \\
 90 x^2+31 x-4=0 \\
 -5 x^2-23 x-12=0 \\
 9 x^2-15 x-14=0 \\
 -21 x^2-5 x+4=0 \\
 100 x^2-80 x+7=0 \\
 -70 x^2+11 x+3=0 \\
 -35 x^2-38 x+9=0 \\
 -63 x^2-46 x-8=0 \\
 3 x^2-31 x+70=0 \\
 20 x^2-7 x-6=0 \\
 -10 x^2+31 x+63=0 \\
 -16 x^2-8 x+35=0 \\
 -20 x^2-27 x-9=0 \\
 18 x^2+21 x-49=0 \\
 -3 x^2+5 x+12=0 \\
 7 x^2+8 x+1=0 \\
 -20 x^2+27 x+8=0 \\
 -63 x^2+76 x+20=0 \\
 70 x^2+11 x-3=0 \\
 -9 x^2-41 x+20=0 \\
 -63 x^2-8 x+16=0 \\
 -4 x^2-19 x+5=0 \\
 50 x^2-45 x+9=0 \\
 10 x^2+19 x+7=0 \\
 -5 x^2+11 x+36=0 \\
 4 x^2-17 x-15=0 \\
 18 x^2+7 x-8=0 \\
 70 x^2+139 x+63=0 \\
 -14 x^2-43 x+90=0 \\
 2 x^2+x-10=0 \\
 10 x^2-7 x-6=0 \\
 -36 x^2-85 x-9=0 \\
 70 x^2+39 x-7=0 \\
 18 x^2+39 x-7=0 \\
 2 x^2-5 x+3=0 \\
 -72 x^2-13 x+20=0 \\
 -7 x^2-45 x-18=0 \\
 -12 x^2+16 x-5=0 \\
 8 x^2+13 x-6=0 \\
 -7 x^2-24 x-20=0 \\
 -24 x^2-58 x-35=0 \\
 -2 x^2+5 x-2=0 \\
 -35 x^2-17 x+36=0 \\
 -24 x^2-34 x-5=0 \\
 12 x^2+32 x+21=0 \\
 30 x^2-13 x+1=0 \\
 3 x^2+29 x-10=0 \\
 -35 x^2+34 x+21=0 \\
 12 x^2-55 x+50=0 \\
 21 x^2+44 x+15=0 \\
 30 x^2+29 x-35=0 \\
 8 x^2-13 x+5=0 \\
 -10 x^2-17 x+63=0 \\
 35 x^2+96 x+64=0 \\
 -30 x^2-89 x-24=0 \\
 18 x^2+51 x+8=0 \\
 -36 x^2-41 x-8=0 \\
 40 x^2-26 x-3=0 \\
 -8 x^2-39 x+54=0 \\
 14 x^2-33 x-56=0 \\
 -28 x^2+25 x+8=0 \\
 -30 x^2-47 x-14=0 \\
 -63 x^2-23 x-2=0 \\
 32 x^2+12 x-5=0 \\
 80 x^2-22 x-45=0 \\
 35 x^2+74 x+35=0 \\
 -3 x^2+40 x-100=0 \\
 6 x^2-17 x-28=0 \\
 -2 x^2-5 x+12=0 \\
 -4 x^2-16 x-15=0 \\
 6 x^2+x-7=0 \\
 -7 x^2-37 x-36=0 \\
 5 x^2+14 x+9=0 \\
 -21 x^2+x+2=0 \\
 18 x^2-29 x+10=0 \\
 -90 x^2-131 x-45=0 \\
 63 x^2-16 x+1=0 \\
 -24 x^2-59 x-7=0 \\
 45 x^2+61 x-36=0 \\
 4 x^2+11 x+6=0 \\
 7 x^2-19 x+10=0 \\
 -2 x^2+19 x-9=0 \\
 -40 x^2+51 x+7=0 \\
 -72 x^2+23 x+35=0 \\
 10 x^2-43 x+28=0 \\
 -7 x^2+66 x-27=0 \\
 -14 x^2-13 x+10=0 \\
 7 x^2-50 x+48=0 \\
 45 x^2+22 x-16=0 \\
 7 x^2-13 x+6=0 \\
 -36 x^2-59 x-24=0 \\
 -5 x^2-9 x+2=0 \\
 -3 x^2+29 x-18=0 \\
 20 x^2+24 x-9=0 \\
 -28 x^2-x+2=0 \\
 36 x^2+19 x-6=0 \\
 63 x^2+40 x-12=0 \\
 x^2-12 x+20=0 \\
 15 x^2-44 x+32=0 \\
 5 x^2+46 x+48=0 \\
 -4 x^2+x+18=0 \\
 -10 x^2-37 x-30=0 \\
 28 x^2-39 x-54=0 \\
 -x^2-2 x+8=0 \\
 -63 x^2+13 x+6=0 \\
 -9 x^2+11 x+14=0 \\
 -21 x^2-38 x-5=0 \\
 50 x^2-15 x-2=0 \\
 45 x^2-67 x-8=0 \\
 -5 x^2+59 x-90=0 \\
 32 x^2+12 x-27=0 \\
 12 x^2+8 x+1=0 \\
 -x^2-13 x-30=0 \\
 15 x^2+38 x+24=0 \\
 90 x^2+53 x-24=0 \\
 -6 x^2+13 x+15=0 \\
 30 x^2+103 x+10=0 \\
 -56 x^2+65 x-14=0 \\
 -6 x^2-35 x+49=0 \\
 42 x^2-19 x-35=0 \\
 -32 x^2+44 x+21=0 \\
 -16 x^2+40 x-21=0 \\
 6 x^2-59 x-10=0 \\
 9 x^2-100 x+100=0 \\
 7 x^2-30 x+8=0 \\
 -56 x^2-127 x-72=0 \\
 -15 x^2+67 x-72=0 \\
 25 x^2-90 x+81=0 \\
 x^2+11 x+30=0 \\
 30 x^2-71 x+42=0 \\
 -32 x^2+28 x+9=0 \\
 -7 x^2-4 x=0 \\
 -81 x^2-153 x-70=0 \\
 28 x^2+25 x-8=0 \\
 -4 x^2-29 x-30=0 \\
 14 x^2+29 x-15=0 \\
 54 x^2+57 x+10=0 \\
 -35 x^2+33 x+54=0 \\
 -24 x^2+10 x-1=0 \\
 -56 x^2+3 x+9=0 \\
 64 x^2-96 x+27=0 \\
 -2 x^2+25 x-72=0 \\
 50 x^2-65 x+6=0 \\
 -9 x^2-53 x-40=0 \\
 -3 x^2+14 x+80=0 \\
 -4 x^2+32 x-63=0 \\
 45 x^2-79 x+30=0 \\
 -25 x^2+20 x+21=0 \\
 -35 x^2+19 x+42=0 \\
 -15 x^2-46 x-16=0 \\
 -24 x^2-59 x+70=0 \\
 8 x^2+49 x+6=0 \\
 35 x^2+22 x-24=0 \\
 27 x^2-12 x-32=0 \\
 63 x^2+101 x+40=0 \\
 27 x^2+15 x-8=0 \\
 21 x^2+23 x-10=0 \\
 -8 x^2-87 x-70=0 \\
 4 x^2+31 x+21=0 \\
 5 x^2+34 x-7=0 \\
 -3 x^2+28 x-60=0 \\
 -8 x^2-26 x-21=0 \\
 21 x^2+38 x+5=0 \\
 63 x^2+146 x+80=0 \\
 -7 x^2+53 x+24=0 \\
 -40 x^2-29 x+18=0 \\
 28 x^2-15 x+2=0 \\
 -56 x^2-25 x+4=0 \\
 18 x^2-57 x-10=0 \\
 15 x^2+4 x-35=0 \\
 14 x^2+79 x+72=0 \\
 3 x^2-16 x+20=0 \\
 15 x^2-13 x-20=0 \\
\end{array}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.