In "sqrt2", instead of factoring expression manually, we can use existing
"froot":

--- a/src/algebra/solvefor.spad
+++ b/src/algebra/solvefor.spad
@@ -64,14 +64,10 @@
         -- we will return both roots later.
         sqrt2(s : F) : F ==
             if F is Expression RR then
-                smpsqfr := squareFree numer s
-                a : F := coerce("*"/[f.factor^(f.exponent quo 2) for f in
factorList smpsqfr])
-                b : F := coerce("*"/[f.factor^(f.exponent rem 2) for f in
factorList smpsqfr])
-                u : RR := retract(coerce(unit smpsqfr)@F)
-                sqfru := squareFree u
-                ua := "*"/[f.factor^(f.exponent quo 2) for f in factorList
sqfru]
-                ub := "*"/[f.factor^(f.exponent rem 2) for f in factorList
sqfru]
-                ua*a*sqrt(ub*b)
+                K ==> Kernel F
+                PP ==> SparseMultivariatePolynomial(RR, K)
+                res := froot(s, 2)$PolynomialRoots(IndexedExponents K, K,
RR, PP, F)
+                res.coef * (res.radicand)^(1/res.exponent)
             else
                 s^(1/2)

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/CAGBJN93gf%3Du2J8MkDi3QPvNC7wVn2BHAfEnXUcM6-UHM_7DZWA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to