0

This question asked about setting the output of tex1 for a numerical fraction (i.e. x where ratnump(x) = true); however, this does not seem to cover all objects that are printed as a fraction, e.g. 1/x or diff(ln(x),x)).

Following this answer, I tried using :lisp $x to query the lisp form, and I get ((MEXPT SIMP) $X -1) for 1/x and ((%DERIVATIVE SIMP) (($LN SIMP) $X) $X 1) for diff(ln(x),x); however, I have no idea how to use this info with texput to specify the desired formatting.

Although I don't think it is necessarily relevant to the question, I wanted to call on a different LaTeX function, instead of \frac (e.g. \tfrac).

Robert Dodier
  • 16,905
  • 2
  • 31
  • 48
Rax Adaam
  • 790
  • 3
  • 11

1 Answers1

1

It's a long story, but it turns out the operator to be displayed is MQUOTIENT. Try this:

texput (?mquotient, lambda([e], printf (false, "\\tfrac{~a}{~a}", tex1(num(e)), tex1(denom(e)))));

Then I get:

(%i12) tex1(1/x);
(%o12)                    \tfrac{1}{x}
(%i13) tex1(y/x);
(%o13)                    \tfrac{y}{x}
(%i14) tex1((1+a/b)/(1-c/d));
(%o14)       \tfrac{\tfrac{a}{b}+1}{1-\tfrac{c}{d}}

PS. ln isn't recognized by Maxima (unless you created a function named ln). The logarithm to the base e is log. Also log10 isn't recognized (again, unless you created such a function).

Robert Dodier
  • 16,905
  • 2
  • 31
  • 48
  • Thank you Robert! Not sure why, but my version of wxMax seems to handle ln(x) as expected. I guess I must’ve loaded a package without realizing it, but it would have to have been added in such a way that permanently added the definition, as I didn’t load anything at all when I ran these commands in a new session. – Rax Adaam Dec 19 '20 at 17:20
  • 1
    About `ln`, maybe that's something that's added by wxMaxima. Ordinary Maxima doesn't know about it. – Robert Dodier Dec 19 '20 at 18:41