I put this patch for review again, with improvements from
the previous one.

The various detection should be made on the numerator
and denominator of (a/b), not on 'a' and 'b' directly.

Other than try to retract to Integer, it also tries to retract
to AlgebraicNumber.

No tests break:

https://travis-ci.org/oldk1331/fricas/builds/221237283

https://github.com/oldk1331/fricas/commit/4a05a42695e4974078a0b3734e9224c246739715.patch

or:

--- a/src/algebra/irexpand.spad
+++ b/src/algebra/irexpand.spad
@@ -102,13 +102,17 @@
 -- returns 2 atan(a/b) or 2 atan(-b/a) whichever looks better
 -- they differ by a constant so it's ok to do it from an IR
     tantrick(a, b) ==
-      retractIfCan(a)@Union(Q, "failed") case Q => 2 * atan(-b/a)
-      sb := sign b
-      if sb case Z then return 2 * atan(a/b)
-      sa := sign a
-      if sa case Z then return 2 * atan(-b/a)
-      -- print("potentially noncontinuous"::OutputForm)
-      2 * atan(a/b)
+        f := a/b
+        a := numerator(f)
+        b := denominator(f)
+        AN ==> AlgebraicNumber
+        TryRetract x ==> retractIfCan(x)@Union(Q, "failed") case Q or
+                             retractIfCan(x)@Union(AN, "failed") case AN
+        TryRetract(b) => 2 * atan(f)
+        TryRetract(a) => 2 * atan(-b/a)
+        sign(a) case Z => 2 * atan(-b/a)
+        -- print("potentially noncontinuous"::OutputForm)
+        2 * atan(f)

     var_kers(p : P, x : Symbol) : List(K) ==
         [k for k in variables(p) | D(k::F, x) ~= 0]

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