Currently the code retracts FLOAT/DFLOAT to Fractions,
causing the result more complex.  For (x::EXPR FLOAT)^(a/b),
x is FLOAT and negative, a and b is Integer and b is even,
return '(x)^(a/b)' as-is is enough.

(1) -> sqrt(sqrt(1)-sqrt(2.0))

                                  +------------------------+
   (1)  0.0384615384_6153846153_9\|- 280.0083681642_1225299
                                                      Type: Expression(Float)

After patch:

(2) -> sqrt(sqrt(1)-sqrt(2.0))

         +------------------------+
   (2)  \|- 0.4142135623_730950488
                                                      Type: Expression(Float)

All tests passed.


--- a/src/algebra/algfunc.spad
+++ b/src/algebra/algfunc.spad
@@ -529,9 +529,14 @@
         if R has RadicalCategory then
           if R has imaginary : () -> R then iroot(r, n) == nthRoot(r, n)::F
           else
-            iroot(r, n) ==
-              odd? n or not(smaller?(r, 0)) => nthRoot(r, n)::F
-              iroot0(r, n)
+              if R has FloatingPointSystem then
+                  iroot(r, n) ==
+                      odd? n or not(smaller?(r, 0)) => nthRoot(r, n)::F
+                      hackroot(r::F, n)
+              else
+                  iroot(r, n) ==
+                      odd? n or not(smaller?(r, 0)) => nthRoot(r, n)::F
+                      iroot0(r, n)

         else iroot(r, n) == iroot0(r, n)

-- 
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