Hello, Le ven. 31 mai 2024 à 02:13, Waldek Hebisch <[email protected]> a écrit : > > On Fri, May 31, 2024 at 12:55:26AM +0200, Grégory Vanuxem wrote: > > 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. > > Well, I do not know what is your final goal.
I don't even know myself, death ? Bad joking aside, as I said earlier with WSLP the categories/domains I am writing are somewhat toy domains but they raise interesting coding questions for example with the JuliaWSExpression domain. But, first, having access to one of probably the best CASs in the world, heavily used, and well tested I guess, can help for testing and development purposes, comparisons in numerical analysis but also with symbolic manipulation. Furthermore it's usually very fast in large areas of computational mathematics. > From my point of view, > interface is useful if FriCAS can programtically construct and > analyse "foreign" objects. I mean, "foreign" objects may live in > their own world, that is OK. But we need some set of operations > on them. If all what interface can do is passing strings and getting > string output, then it is rather uninteresting to me. Of course, this is one aim I am pursuing. Right now I am doing the rotten job, adding usual routines, after that I can easily modify the internal rules used behind if necessary. I could even code a C wrapper, that should not be very difficult, but that does not enter into my intentions. > To put it > differently, for me interesting part is sending some FriCAS data > to "foreign" code and eventually getting back FriCAS data. This is the purpose of WSTP, but you know that I think: https://www.wolfram.com/wstp/ What you are mentioning is mentioned here: https://reference.wolfram.com/language/ref/LinkProtocol.html https://reference.wolfram.com/language/guide/WSTPAPI.html > AFAICS > this implies that writing convertion of "foreign" data to OutputForm > is more or less trivial. Not trivial for me. OutputForm is the root of the outputting system in FriCAS. For latex(): SetCategory() : Category == Join(BasicType, CoercibleTo OutputForm) with --operations latex : % -> String ++ latex(s) returns a LaTeX-printable output ++ representation of s. add latex(s : %) : String == of := s::OutputForm tf := of::TexFormat sl := tex(tf) reduce(concat, sl) and from my point of view it has a lot of hardcoded things in it. It's a "must to pass by it". Even the interpreter has operator knowledge from what I have read. So using OutputForm is using its "language" as you said. (ROOT 2) for a square root of 2 for example, not (^ 2 (/ 1 2)) . So if you want to use your personal representation in LaTeX here, that seems somewhat complicated. My first question is about that, for simple elements I do not understand why the domain coder could not give its representation to OutputForm and otherwise let OutputForm handle it. Expression(INT) -> Complex(INT -> %i I mean, to build OutputForm you need to > be able to dissect data into parts, recursively convert each part to > OutputForm and combinie then back. If this process of dissection > is too complicated, then what useful can you do with such data? I can do whatever I want, in fact at different levels, FriCAS, Lisp, Julia or the engine behind. I will do that later. I am at the "thinking about" stage. But basically and that raises interesting questions to me, I am not at all a big fan of rotten coding, I use a strictly formal way of representing my expressions, and they are _only_ evaluated at output time. That will change for some routines. I use simplify with an assumption below, I do not have in mind right now a better example without simplify, it's a pity. As far as the expression is not evaluated, FriCAS has it its full form in a String: (1) -> x:=jWSExpr("x") (1) x Type: JuliaWSExpression (2) -> x^(jWSRat 1/7)+sqrt(x^2) (2) x^(1/7) + Sqrt[x^2] Type: JuliaWSExpression (3) -> simplifiedEx:=simplify(%, "x<0") (3) x^(1/7) - x Type: JuliaWSExpression (4) -> string % (4) "W`Simplify[Plus[Power[x, Rational[1, 7]], Sqrt[Power[x, 2]]], Less[x, 0]]`" Type: String (5) -> jlSymbolic simplifiedEx (5) "Plus[Power[x, Rational[1, 7]], Times[-1, x]]" Type: String (6) -> toString simplifiedEx (6) "x^(1/7) - x" Type: JuliaWSExpression (7) -> toString(simplifiedEx,"InputForm") (7) "x^(1/7) - x" Type: JuliaWSExpression (8) -> jlSymbolic %%(2) (8) "Plus[Power[x, Rational[1, 7]], Power[Power[x, 2], Rational[1, 2]]]" Type: String (9) -> %%(2) (9) x^(1/7) + Sqrt[x^2] Type: JuliaWSExpression These output to string routines are useful to better know the different internal structures. Behind the scenes, in Julia, W"Sqrt" produces the Julia WS language symbol 'Sqrt' that can be applied to the symbol x when they are sent to the engine. - Greg > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/fricas-devel/ZlkWPiVbayDKhsiJ%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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/CAHnU2dbpURR4mmfec3nfBFB1S7B0jaS4OaGGy53pmXj1D08eSA%40mail.gmail.com.
