[fricas-devel] [PATCH v1] add a special case in lg2func; fix serval integrals

```Compare the result of
integrate(1/(x^8-1),x)
integrate(8*sqrt(2)/(x^8-1),x)
integrate(a/(x^8-1),x)```
```
The first is more complex than the second one.
Why? Because:
(1) -> factor(x^4+1)

4
(1)  x  + 1
Type: Factored(Polynomial(Integer))
(2) -> factor(x^4+4)

2            2
(2)  (x  - 2x + 2)(x  + 2x + 2)
Type: Factored(Polynomial(Integer))

The factorization of "x^4+r" depends on r, or else it will
introduce extra algebraic kernels.

In rational function integration, sum logs over roots of
"x^4+r=0" is pretty common, but "lg2func" doesn't deal
with this case.  So I manually facor "x^4+r" into quadratics.

This patch improves 1190a 1191a 1207a 1217a 1218a 1228a
of mapleok.input, making 1191a 1207a 1217a continuous.

I have to use "rootSimp" in the patch, I'm not sure if this
will causes trouble elsewhere.

index eb90a9c9..eaffa9e4 100644
@@ -84,6 +84,7 @@
zero?(delta := (b := coefficient(p, 1))^2 - 4 *
(a := coefficient(p, 2)) * (p0 := coefficient(p, 0))) =>
[linear(monomial(1, 1) + (b / a)::UP, lg)]
+      delta := rootSimp delta
e := (q := quadeval(lg, c := - b * (d := inv(2*a)), d, delta)).ans1
lgp  := c * log(nrm := (e^2 - delta * (f := q.ans2)^2))
s    := (sqr := insqrt delta).sqrt
@@ -152,8 +153,18 @@
--      one? d => [linear(p, lg.logand)]
(d = 1) => [linear(p, lg.logand)]
d = 2  => quadratic(p, lg.logand, x)
-      odd? d and
-        ((r := retractIfCan(reductum p)@Union(F, "failed")) case F) =>
+      r := retractIfCan(reductum p)@Union(F, "failed")
+      d = 4 and r case F =>
+          -- In this "p := ?^4 + r" case, we manually factor p into
+          -- "?^2 + sqrt(r) - ?*sqrt(2*sqrt(r))" and
+          -- "?^2 + sqrt(r) + ?*sqrt(2*sqrt(r))".
+          upx := monomial(1,1)\$UP
+          t : F := rootSimp sqrt(2 * rootSimp sqrt r)
+          -- because the sign of delta is fixed.
+          [first    quadratic(upx^2 + sqrt(r)::UP - upx*t, lg.logand, x)
+            + first quadratic(upx^2 + sqrt(r)::UP + upx*t, lg.logand, x)]
+      odd? d and r case F =>
pairsum([cmplex(alpha := rootSimp zeroOf p, lg.logand)],
lg2func([lg.scalar,
(p exquo (monomial(1, 1)\$UP - alpha::UP))::UP,

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