While writing patches for https://github.com/fricas/fricas/issues/149,
I found 2 other bugs in simplifyExp.

First is 'height' needs recalculation because 'simplifyExp' may cancel
kernels.

However, for 'newK', shall we use 'kernel' here to prevent evaluation
or use 'elt' to do evaluation?

Second is to recurse 'simplifyExp' on the first argument of '%power'.

- Qian

diff --git a/src/algebra/manip.spad b/src/algebra/manip.spad
index 68f5422f..873fd5bf 100644
--- a/src/algebra/manip.spad
+++ b/src/algebra/manip.spad
@@ -773,8 +773,8 @@ TranscendentalManipulations(R, F) : Exports == Implementation where
           exponent := exponent + d * first argument k
         else if not is?(k, POWER) then
           -- Expand arguments to functions as well ... MCD 23/1/97
-          --coef := coef * monomial(1, k, d)
- coef := coef * monomial(1, kernel(operator k, [simplifyExp u for u in argument k], height k), d) + newK : F := kernel(operator k, [simplifyExp u for u in argument k])
+          coef := coef * monomial(1, retract(newK)@K, d)
       coef::F * exp simplifyExp exponent * powersimp(p, lpow)

     expandPower f ==
@@ -790,7 +790,7 @@ TranscendentalManipulations(R, F) : Exports == Implementation where
       lk := select((z1 : K) : Boolean +-> a = first argument z1, rest l)
       for k0 in lk repeat
           exponent := exponent + degree(p, k0) * second argument k0
-      (a ^ simplifyExp exponent) * powersimp(p, setDifference(rest l, lk))
+ (simplifyExp a ^ simplifyExp exponent) * powersimp(p, setDifference(rest l, lk))

     t2t x         == sin(x) / cos(x)
     c2t x         == cos(x) / sin(x)
diff --git a/src/input/bugs2023.input b/src/input/bugs2023.input
index f60c37ed..07008c6a 100644
--- a/src/input/bugs2023.input
+++ b/src/input/bugs2023.input
@@ -114,4 +114,9 @@ testcase "initial coefficients of sparse univariate power series"

testEquals("st:=[[n,n+42]@Record(k:INT,c:INT) for n in 0..];s:=series(st)$InnerSparseUnivariatePowerSeries(INT);coefficient(s,0)", "42")

+testcase "simplifyExp"
+
+testEquals("height simplifyExp sin(exp(a)*exp(-a))", "1")
+testEquals("simplifyExp((exp(a)*exp(b))^c)", "(exp(a+b))^c")
+
 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/263a831a-941d-4d68-b9bc-0c6f16f4dbd6%40gmail.com.

Reply via email to