On Wed, Jul 12, 2023 at 09:06:39AM +0200, Ralf Hemmecke wrote:
> Does someone know a FriCAS function that returnss a from w?
> If possible it should also work over Expression(X) in particular when
> complex numbers are involved.
> 
> Of course, I could program something, but maybe it's already there and I am
> just not able to find it.
> 
> Thank you
> Ralf
> 
> 
> (233) -> a := 1+sqrt(2)
> 
>            +-+
>    (233)  \|2  + 1
>                                         Type: AlgebraicNumber
> (234) -> h := a^2
> 
>              +-+
>    (234)  2 \|2  + 3
>                                         Type: AlgebraicNumber
> (235) -> w := sqrt h
> 
>            +----------+
>            |   +-+
>    (235)  \|2 \|2  + 3
>                                         Type: AlgebraicNumber

No function doing what you want.  Using eqisting functionality
you can do:

(5) -> kw := kernels(w).1

         +----------+
         |   +-+
   (5)  \|2 \|2  + 3
                                                Type: Kernel(AlgebraicNumber)
(7) -> awe := (argument(kw).1)::EXPR(INT)

           +-+
   (7)  2 \|2  + 3
                                                    Type: Expression(Integer)
(8) -> eF := EFACTOR(INT, EXPR(INT))

   (8)  ExpressionFactorPolynomial(Integer,Expression(Integer))
                                                                   Type: Type
(9) -> factor(monomial(1, 2)$SUP(EXPR(INT)) - awe) 

              +-+           +-+
   (9)  (? - \|2  - 1)(? + \|2  + 1)
              Type: Factored(SparseUnivariatePolynomial(Expression(Integer)))

Given factorization you can produce denested root.  Of course, there is
still problem of choosing between a and -a.

That is easy to implement way of denesting, however it convers only
"trivial" cases, namely when argument to root is a power.  There
are denestings when argument is not a power ant that is much more
tricky.  Your case is made easier by fact that integers extended by
square root of 2 have unique factorization, but we do not have
this in general case.

Extra thing: I do not know why you want to simplify roots, but
some simplification, including this one, should be done by
normalize.  More precisely, normalize should detect "dependent
roots" and what you gave is one of simplest examples of dependent
roots.  OTOH some denstings are unrelated to dpendent roots.
Also, removal of squares (powers in general) from roots strictly
speaking is not necessary for normalize.  And once expression
is properly normalized you should be careful when transforming
kernels, well-intendend transformation can destroy effect of
normalization.

-- 
                              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/ZK6O/%2BpyxpHp2cio%40fricas.math.uni.wroc.pl.

Reply via email to