r-cas / caracas

Computer algebra in R
GNU General Public License v2.0
24 stars 2 forks source link

tex() -> exp(1) instead of e #36

Open mikldk opened 3 years ago

mikldk commented 3 years ago

See inst/define_printers.py.

mikldk commented 3 years ago

Currently work in progress at SymPy so currently not possible for release version 1.7. See e.g.:

Also see https://github.com/sympy/sympy/blob/dd08a11b11a9cef066fb80b54a57f83887ccb852/sympy/core/parameters.py. Maybe at some point, instead of overwriting printers we can

from sympy.core.parameters import global_parameters as gp
gp.exp_is_pow = False
mikldk commented 3 years ago

@YiquanGu , thanks. I can only come up with being creative:

library(caracas)
x <- as_sym("-1/(theta-1)")
x
#> [caracas]:  -1  
#>            ─────
#>            θ - 1
tex(x)
#> [1] "- \\frac{1}{\\theta - 1}"

y <- 1/(1/x)
y
#> [caracas]:   1  
#>            ─────
#>            1 - θ
tex(y)
#> [1] "\\frac{1}{1 - \\theta}"