Thanks Waldek,

My principal problem would be to have a hook in the TeX formatter I think,
I already have the LaTeX string, it comes from the WolframEngine and I
can't know in advance which function it will return. I have no problem to
coerce to OutputForm rationals, integers etc. For numbers it is not a
problem, but I am also writing a parallel Expression domain, an interface
in fact, where for example LambertW is PolyLog.

An example:

(1) -> x:=jWSExpr("x")

   (1)  x
                                                      Type:
JuliaWSExpression
                           Time: 0.04 (IN) + 0.40 (EV) + 0.26 (OT) = 0.70
sec
(2) -> y:=jWSExpr("y")

   (2)  y
                                                      Type:
JuliaWSExpression
                                                   Time: 0.05 (OT) = 0.06
sec
(3) -> trigToExp(sin(x) * sinh(y)+sqrt(y))

   (3)  (I/4)*(E^((-I)*x) - E^(I*x))*(-E^(-y) + E^y) + sqrt(y)
                                                      Type:
JuliaWSExpression
                                       Time: 0.04 (EV) + 0.06 (OT) = 0.10
sec
(4) -> sin(x) * sinh(y)+sqrt(y)

   (4)  sqrt(y) + sin(x)*sinh(y)
                                                      Type:
JuliaWSExpression
                                                   Time: 0.05 (OT) = 0.06
sec
(5) -> jlPlot(x+->sinc(x), -5..5)
-- lot of time the first time
                                                                    Type:
Void
                           Time: 0.04 (IN) + 1.08 (EV) + 0.09 (OT) = 1.20
sec

(6) -> jlPlotTitle! jlLatex latex %%(3)
                                                                   Type:
Void
                                       Time: 0.02 (IN) + 0.33 (EV) = 0.36
sec

 (7) -> latex %%(3)

   (7)
  "\sqrt{y}+\frac{1}{4} i \left(e^{-i x}-e^{i x}\right)
\left(e^y-e^{-y}\right)
  "
                                                                 Type:
String
                                                                 Time: 0 sec

This is not the good title, it is just for illustration. For graph that's
easily possible to use the LaTeX string in my settings, but having it used
internally ')with set output tex on", I am stuck. Unless I dig into FriCAS
internals? Probably. Nevertheless I can use it with graph, it's just
saveFig("test.png") for this mail after it was displayed on a Window:

[image: test.png]

I looked at precondition but in this context my OutputForm is already a
formatted String, it can represent too many things in comparison with
FriCAS Expression domain. That's illusory and Wolfram™ has already done the
job to translate to LaTeX .It's common apparently with mathematical
software.

I am still continuing to better understand the OutputForm and its link to
other formatters. For example, part of MathML output seems coded sometimes
in domains themselves.

- Greg

PS: the FriCAS output in this mail is regex substituted before
(downcase and brackets to parens substitutions), normally my output in
FriCAS has the Wolfram language form: Sin[Cos[x]]



Le jeu. 30 mai 2024 à 17:14, Waldek Hebisch <de...@fricas.org> a écrit :

> On Thu, May 30, 2024 at 02:57:20PM +0200, Grégory Vanuxem wrote:
> >
> > time allows, my thoughts are vague and scattered. But think about sqrt(x)
> > or asin(x) in LaTeX, they may be formatted differently if you use \sqrt,
> > \asin or sin^1 (x), x^(1/2), negative power for rational numbers, etc.
> The
> > way OutputForm works doesn't allow a domain's coder to choose which
> > representation to display.
>
> OutputForm can represent each variant and domain's coder can use what
> is more appropriate, like:
>
> (2) -> y*(x::OutputForm)^(-1)
>
>            - 1
>    (2)  y x
>                                                              Type:
> OutputForm
>
> >
> > How to handle for example \asin or \sin ^{-1}(a) in LatTeX.
>
> Just produce right OutputForm:
>
> (4) -> )set output tex on
> (4) -> prefix((sin::OutputForm)^(-1), [a])
>
>            - 1
>    (4)  sin   (a)
> $$
> {{\sin} \sp {-1}}
> \left(
> {a}
> \right)
> \leqno(4)
> $$
>
>                                                              Type:
> OutputForm
>
> Both your wishes could be done by relatively simple transformation
> of OutputForm.  Currently before formattiong OutputForm is transformed
> by 'precondition' in OutputFormTools.  In principle 'precondition'
> could be replaced by a user function.
>
> --
>                               Waldek Hebisch
>
> --
> You received this message because you are subscribed to the Google Groups
> "FriCAS - computer algebra system" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to fricas-devel+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/fricas-devel/ZliX7cwIwPxmB7cN%40fricas.org
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fricas-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/CAHnU2dYJ11JDV8i4ZcbqpU3uKDwygkgk4xbPNTyGHdV1Fd1iEQ%40mail.gmail.com.

Reply via email to