On Tue, May 14, 2024 at 03:04:15PM +0200, Ralf Hemmecke wrote:
> 
> In fact, the value xx is one of radicalRoots(pp) where
> 
> pp := 
> x^4-2729960418308000*x^3-395258439243352250000*x^2-55499520947716391500000000*x-345363656226658026765625000000
> 
> Interestingly, when I put xx into Mathematica, I get a much nicer
> expressions.
> 
> In[15]:= p1 = Root[pp, 1] // ToRadicals
> 
> Out[15]= 250 (2729960418308 + 1930373524352 Sqrt[2] -
>    23569 Sqrt[2 (13416226688183641 + 9486704869150589 Sqrt[2])])
> 
> In[25]:= p3 = Root[pp, 3] // ToRadicals
> 
> Out[25]= 250 (2729960418308 - 1930373524352 Sqrt[2] -
>    23569 I Sqrt[2 (-13416226688183641 + 9486704869150589 Sqrt[2])])
> 
> Can I somehow "convince" FriCAS to return similarly "simple" radical
> expresssions?

With the attached patch I get:

(2) -> radical_solve(univariate(pp))

   (2)
   [
        +--------------------------------------------------------------------+
        |                                +-+
       \|658730414260118770166403625000 \|2  + 931585485794307216540975125000
     + 
                        +-+
       482593381088000 \|2  + 682490104577000
     ,

          +--------------------------------------------------------------------+
          |                                +-+
       - \|658730414260118770166403625000 \|2  + 931585485794307216540975125000
     + 
                        +-+
       482593381088000 \|2  + 682490104577000
     ,

          +---+
         \|- 1
      *
        +--------------------------------------------------------------------+
        |                                +-+
       \|658730414260118770166403625000 \|2  - 931585485794307216540975125000
     + 
                          +-+
       - 482593381088000 \|2  + 682490104577000
     ,

       -
             +---+
            \|- 1
         *
            ROOT
                                                 +-+
                 658730414260118770166403625000 \|2
               + 
                 - 931585485794307216540975125000
     + 
                          +-+
       - 482593381088000 \|2  + 682490104577000
     ]
                                   Type: Union(List(Expression(Integer)),...)


The result looks more complicated, but this is because FriCAS does
not pull squares outside square roots.

I would be easy to hook this into 'radicalSolve' so that such result
is obtainde by default.

-- 

                              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/ZkYGNdknTVOqpxEs%40fricas.org.
--- ../fr-build123/src/algebra/ROOTUT.spad	2024-05-14 21:03:24.609019133 +0000
+++ ROOTUT.spad	2024-05-16 13:04:03.656821580 +0000
@@ -14,6 +14,10 @@
       ++ complex_roots(p) computes roots of p in terms of radicals
       ++ separating real and complex roots.
       ++ Returns "failed" when unsuccessful.
+    radical_solve : UP -> Union(List(F), "failed")
+      ++ radical_solve(p) tries to solve polynomial p in terms
+      ++ of radicals.
+      ++ Returns "failed" when unsuccessful.
     quartic2 : (UP, F) -> Union(r_rec, "failed")
       ++ quartic2(p) should be local but conditional
     my_sqrt : F -> F
@@ -33,6 +37,8 @@
 
     root_pair(a : F, b : F) : C_rec == [a, b]
 
+    my_imag := sqrt(-1)
+
     root4(a : F) : F ==
         rec := froot(a, 4)$PolynomialRoots(IndexedExponents(K), K, R, P, F)
         p1 := monomial(1, rec.exponent)$UP - rec.radicand::UP
@@ -249,4 +254,14 @@
         (d = 4) => quartic(p)
         "failed"
 
+    radical_solve(p : UP) : Union(List(F), "failed") ==
+        r1u := complex_roots(p)
+        r1u case "failed" => "failed"
+        r1 := r1u@r_rec
+        res := reverse!(r1.reals)
+        for c1 in r1.complexes repeat
+            res := cons(c1.real + my_imag*c1.imag, res)
+            res := cons(c1.real - my_imag*c1.imag, res)
+        reverse!(res)
+
 

Reply via email to