Sorry, emails crossed...

Am Donnerstag, 5. Juli 2018 19:57:15 UTC+2 schrieb Ralf Hemmecke:
>
> >> Wouldn't it be wiser to add functions to Expression in order to 
> >> decompose an element. 
> > 
> > No, not in the case of the Sage interface to FriCAS. 
>
> Can you give a reason why? 
>
> A function that would enable to go step by step through an expression 
> tree in FriCAS wouln't be such a bad idea even though the representation 
> of Expression(INT) is a rational function, but still the idea is 
> "expression tree". 
>


As far as I understand, InputForm is achieving precisely this, except that 
it is not restricted to EXPR:

(2) -> integrate(sin(x^2), x)::INFORM

   (2)  (/ (fresnelS (* x (^ (/ 2 (pi)) (/ 1 2)))) (^ (/ 2 (pi)) (/ 1 2)))
                                                              Type: 
InputForm

is an expression tree.

(3) -> 1.23::INFORM

   (3)  (float 181515961685301987901 - 67 2)
                                                              Type: 
InputForm

Of course, some (type) information may be lost - not by design, but rather 
because of implementation details.  But in general, things work well:

(12) -> (matrix [[(i+j)::PF(2) for i in 1..3] for j in 1..3])::INFORM

   (12)
   (matrix

     (construct

       (construct  (($elt (PrimeField 2) index) 2)
        (($elt (PrimeField 2) index) 1)  (($elt (PrimeField 2) index) 2))


       (construct  (($elt (PrimeField 2) index) 1)
        (($elt (PrimeField 2) index) 2)  (($elt (PrimeField 2) index) 1))


       (construct  (($elt (PrimeField 2) index) 2)
        (($elt (PrimeField 2) index) 1)  (($elt (PrimeField 2) index) 2))
       )
     )
                                                              Type: 
InputForm
The sage interface uses this information:

sage: fricas("(matrix [[(i+j)::IntegerMod(2) for i in 1..3] for j in 
1..3])").sage().parent()
Full MatrixSpace of 3 by 3 dense matrices over Ring of integers modulo 2

just noticed a bug that PrimeField is not translated :-)

sage: fricas("(matrix [[(i+j)::PF(2) for i in 1..3] for j in 1..3])").sage()
...
NotImplementedError: The translation of FriCAS type (PrimeField 2) to sage 
is not yet implemented.

All the best,

Martin

-- 
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 post to this group, send email to fricas-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to