1

I was trying to redefine the output for sqrt() in Maxima, using texput, but am getting an error that I can't make sense of.

This is the function I wrote for creating the desired string:

sqrt_tex:lambda([e], printf(false,"\\csqrt{~a}", tex1(e)))

When applied to an expression, it seems to behave as expected:

sqrt_tex(2);
   > \csqrt{2}

but after passing texput('sqrt, sqrt_tex, prefix); when I try:

tex1(sqrt(2))
    > Maxima encountered a Lisp error:
 ((LAMBDA SIMP) ((MLIST) $E) (($PRINTF) NIL "\\csqrt{~a}" $E)) is not a string designator.
Automatically continuing.
To enable the Lisp debugger set *debugger-hook* to nil.

I'm sure I'm missing something simple, but can't figure it out. Any help would be greatly appreciated!

Rax Adaam
  • 790
  • 3
  • 11

1 Answers1

0

On a whim, I removed prefix and that seems to work. I assumed sqrt was a prefix operator because sin and cos are (I believe) and I thought they'd be defined similarly.

Rax Adaam
  • 790
  • 3
  • 11
  • 2
    `texput(foo, "", prefix)` expects that `""` is going to be a string which `tex` will then put before the argument. When you supply a function, saying that it's prefix or postfix, etc., is not needed -- placement is handled by the function. – Robert Dodier Jan 21 '21 at 07:05
  • @RobertDodier - thank you, I think I understand it better, now. I thought the 3rd argument had to do with how Maxima defines the function (not sure why -- think I must've misunderstood the answer to an old question from the maxima-discuss list). Thanks for taking the time to clarify! – Rax Adaam Jan 21 '21 at 18:05