Just found another bug in simplifyExp. In
    p1 := numer p

there is risk of losing information because 'smpexp' can return a value
with 'denom' not equal to 1.

- Qian

diff --git a/src/algebra/manip.spad b/src/algebra/manip.spad
index 873fd5bf..3e6c163e 100644
--- a/src/algebra/manip.spad
+++ b/src/algebra/manip.spad
@@ -831,30 +831,30 @@ TranscendentalManipulations(R, F) : Exports == Implementation where smp2htrigs p == map((k1 : K) : F +-> htrigs(k1::F), (r1 : R) : F +-> r1::F, p)

     simplifyExp x ==
-        p := smpexp numer x
-        q := smpexp denom x
-        not (monomial?(p1 := numer p) and monomial?(q1 := numer q)) => p/q
+        f := smpexp numer x / smpexp denom x
+        p := numer f
+        q := denom f
+        not (monomial? p and monomial? q) => f
         -- currently only fraction of monomials are simplified, e.g:
         -- (exp(a)*b^c*d^e*...)/(exp(f)*b^g*h^i*...)
-        lk1 := variables p1
-        lk2 := variables q1
-        term : F := 1
+        lk1 := variables p
+        lk2 := variables q
+        term : P := 1
         for k2 in lk2 repeat
-            -- assert!(degree(q1, k) = 1)
             op := operator k2
             args := argument k2
             h := height k2
             if op = opexp then
                 for k1 in lk1 repeat
                     if is?(k1, opexp) then
-                        term := term * kernel(op, [-(args.1)], h)::F
+                        term := term * kernel(op, [-(args.1)], h)::P
                         break
             if is?(op, POWER) then
                 for k1 in lk1 repeat
                     if is?(k1, POWER) and args.1 = first argument k1 then
- term := term * kernel(op, [args.1, -(args.2)], h)::F + term := term * kernel(op, [args.1, -(args.2)], h)::P
                         break
-        termexp(numer(p*term))/termexp(numer(q*term))
+        termexp(p*term)/termexp(q*term)

     htrigs f ==
       (m := mainKernel f) case "failed" => f
diff --git a/src/input/bugs2023.input b/src/input/bugs2023.input
index 07008c6a..acb205e4 100644
--- a/src/input/bugs2023.input
+++ b/src/input/bugs2023.input
@@ -118,5 +118,6 @@ testcase "simplifyExp"

 testEquals("height simplifyExp sin(exp(a)*exp(-a))", "1")
 testEquals("simplifyExp((exp(a)*exp(b))^c)", "(exp(a+b))^c")
+testEquals("simplifyExp(exp(a-1)*exp(-a))", "exp(-1)")

 statistics()

--
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/bca8e3aa-1024-4ad6-94e0-e959f604f59d%40gmail.com.

Reply via email to