[PATCH] "sign" should support "a^b"

3 views
Skip to first unread message

oldk1331

unread,
Jan 23, 2019, 6:13:04 AM1/23/19
to fricas...@googlegroups.com
For expression "f := a^b", if "a" is non-negative,
then "f" is also non-negative.

Current code can handle "exp(x)".

After this patch, "sign(2^x)" returns "1".

diff --git a/src/algebra/limitps.spad b/src/algebra/limitps.spad
index 1ee8682a..41883470 100644
--- a/src/algebra/limitps.spad
+++ b/src/algebra/limitps.spad
@@ -893,6 +893,9 @@
           s::Z < 0 => "failed"
           s
         s
+      is?(op, '%power) =>
+          s::Z < 0 => "failed"
+          s
       "failed"

 --Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.

Waldek Hebisch

unread,
Jan 23, 2019, 9:51:10 AM1/23/19
to fricas...@googlegroups.com
oldk1331 wrote:
>
> For expression "f := a^b", if "a" is non-negative,
> then "f" is also non-negative.
>
> Current code can handle "exp(x)".
>
> After this patch, "sign(2^x)" returns "1".

OK, please add this as a test.

--
Waldek Hebisch
Reply all
Reply to author
Forward
0 new messages