Search code examples
rlatexrstudiosymbolic-mathyacas

Convert R yacas equation to LaTeX without solving it


I want to show step-by-step calculations that were made using 'TeXForm' in Ryacas.
To do that I must be able to obtain LaTeX from given equation. Issue is that yacas automatically solves them before converting to LaTeX form. If I try to apply 'TeXForm' on equation, I get simplified version of it. For example:

exp1<-'D(x)Sin(x^2+y^2)+D(y)Sin(x^2+y^2)'
TeXForm(exp1)

I got:

"$2 x \cos \left( x ^{2} + y ^{2}\right)  + 2 y \cos \left( x ^{2} + y ^{2}\right) $";

I tried to get non-simplified version:

 yacas('TeXForm(exp1)')

I got:

"$\mathrm{ exp1 }$";

I also tried:

yacas('D(x)Sin(x^2+y^2)+D(y)Sin(x^2+y^2)')

It didn`t work either.
How to get non-simplified LaTeX formula with all derivatives?


Solution

  • I found that TeXForm(deparse(x^2+x^2)) gives right result, but that doesn't work with derivatives.
    For derivatives: TeXForm(substitute("D(x) sin(x+y)")).