It actually makes no sense to test the sign of a and b before
they divide. Because they can be of form such as "1/aa".
Since the purpose of 'tantrick' is to minimize zeros in
the denominator of "a/b" or "b/a", so it makes perfect sense
to do the division first, then check for signs.
I have compared results in src/input/ (by printing out the
infinite integrals), very few changes, but they are all
improvements, not regressions.
--- a/src/algebra/irexpand.spad
+++ b/src/algebra/irexpand.spad
@@ -102,6 +103,9 @@
-- 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) ==
+ c := a/b
+ a := numerator c
+ b := denominator c
retractIfCan(a)@Union(Q, "failed") case Q => 2 * atan(-b/a)
sb := sign b
if sb case Z then return 2 * atan(a/b)
See the following examples, the first one avoids a discontinuity at x=0;
the second one turns atan(1/largeExpression) into -atan(largeExpression)
which takes less printing space and potentially avoids discontinuity.
- Qian
integrate(1/(sqrt(10) - x^2)^(1/2), x) -- from integ.input
==== before
+----------+
| +--+ 2
\|\|10 - x
(1) - atan(-------------)
x
==== after
x
(1) atan(-------------)
+----------+
| +--+ 2
\|\|10 - x
in1854a:=integrate(1/(z-1)/(1/(z-I))^(1/2), z) -- from mapleok.input
==== before [part of result]
+-----+
| 1 +-----+ 1
- 2 |----- \|I - 1 atan(----------------) + 2
\|z - I +-----+
| 1 +-----+
|----- \|I - 1
\|z - I
----------------------------------------------]
+-----+
| 1
|-----
\|z - I
==== after [part of result]
+-----+ +-----+
| 1 +-----+ | 1 +-----+
2 |----- \|I - 1 atan( |----- \|I - 1 ) + 2
\|z - I \|z - I
--------------------------------------------]
+-----+
| 1
|-----
\|z - I
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/fricas-devel/a038011d-94d9-48a8-b6dc-66fe8f7d7b3e%40gmail.com.