On Sat, Dec 02, 2023 at 09:42:03AM +0800, Qian Yun wrote:
> 
> On 12/1/23 08:58, Waldek Hebisch wrote:
> > 
> > I am not sure if you want to do them.  I could do first two and
> > third for rational coefficients.   Or maybe you want more general
> > code.
> > 
> > 
> 
> You should do them, and if possible, commit separately for
> different cases -- it's easier for me to testing against Nasser's
> list.

I prefer commit code when reasonably complete and ready.
If you want to test attached is my first shot at x^4 + a case
with negative a.  It seems to be rare, but it was easy and
will share most code with case of positive a.

Example:

(1) -> integrate(1/(x^4-2),x)

                                                    4+-+
               4+-+             4+-+               x\|8
        - log(x\|8  + 2) + log(x\|8  - 2) - 2 atan(-----)
                                                     2
   (1)  -------------------------------------------------
                                4+-+
                              4 \|8
                                         Type: Union(Expression(Integer),...)

(before there were two complex logs).

-- 
                              Waldek Hebisch

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/ZWvegkGhkOogWxgc%40fricas.org.
diff --git a/src/algebra/irexpand.spad b/src/algebra/irexpand.spad
index ead11d7f..7a929584 100644
--- a/src/algebra/irexpand.spad
+++ b/src/algebra/irexpand.spad
@@ -150,10 +150,35 @@ IntegrationResultToFunction(R, F) : Exports == Implementation where
       bb := -(r.coef1) k
       tantrick(aa * a + bb * b, g) + ilog0(aa, bb, r.coef2, -r.coef1, k)
 
+    -- Computes (a + b*%i)log(lg(a + b*%i)) + (a - b*%i)log(lg(a - b*%i)
+    -- using Rioboo transformation)
+    root_pair(lg : UP, a : F, b : F, x : Symbol) : F ==
+        lge := quadeval(lg, a, b, -1)
+        f := lge.ans1
+        g := lge.ans2
+        a*log(f*f + g*g) + b*ilog(f, g, x)
+
+    lg2cfunc2 : (UP, UP) -> F
+
+    quartic(p : UP, lg : UP, x : Symbol) : List(F) ==
+        ground?(rp := reductum(p)) =>
+            a := ground(rp)
+            s := sign(a)
+            s case "failed" => [lg2cfunc2(p, lg)]
+            si := s@Integer
+            si = 1 =>
+                [lg2cfunc2(p, lg)]
+            si = -1 =>
+                r1 := rootSimp(zeroOf(p))
+                [cmplex(r1, lg) + cmplex(-r1, lg) + root_pair(lg, 0, r1, x)]
+            error "impossible"
+        [lg2cfunc2(p, lg)]
+
     lg2func(lg, x) ==
       zero?(d := degree(p := lg.coeff)) => error "poly has degree 0"
       (d = 1) => [linear(p, lg.logand)]
       d = 2  => quadratic(p, lg.logand, x)
+      d = 4 => quartic(p, lg.logand, x)
       odd? d and
         ((r := retractIfCan(reductum p)@Union(F, "failed")) case F) =>
             pairsum([cmplex(alpha := rootSimp zeroOf p, lg.logand)],
@@ -162,8 +187,10 @@ IntegrationResultToFunction(R, F) : Exports == Implementation where
                       lg.logand], x))
       [lg2cfunc lg]
 
-    lg2cfunc lg ==
-      +/[cmplex(alpha, lg.logand) for alpha in zerosOf(lg.coeff)]
+    lg2cfunc(lg) == lg2cfunc2(lg.coeff, lg.logand)
+
+    lg2cfunc2(p : UP, lg : UP) ==
+        +/[cmplex(alpha, lg) for alpha in zerosOf(p)]
 
     mkRealFunc(l, x) ==
       ans := empty()$List(F)

Reply via email to