There is old bug where some expressions are evaluated in floating
point arithmetic instead of exact evaluation (for example see
http://sourceforge.net/tracker/?func=detail&aid=2974970&group_id=200168&atid=972421)

The patch below should fix this problem.  The 'isApproximate' function
is somewhat ad-hoc, ideally we would declare such information in
algebra.  However, ATM we do not have a way to propagate such
information where needed.  OTOH the problem is getting urgent
because I want to add numerical routines for more special
functions.  Currently Gamma, digamma and bessel function have
problems.  Elementary functions are not affected, because
numerical versions are defined in Float (and not in a separate
package), but I really do not want to put all numerical
routines in Float to avoid this problem.  And beside special
functions we sometimes got numerical evaluation for polynomials
so the change fixes more problem.


--- ../ppn33/trunk/src/interp/i-funsel.boot     2011-01-04 18:32:17.000000000 
-0500
+++ i-funsel.boot       2010-11-29 17:41:08.000000000 -0500
@@ -605,6 +605,13 @@
     mmS := [mm,:mmS]
   nreverse mmS
 
+isApproximate(t) ==
+    op := CAR(t)
+    member(op, ["Float", "DoubleFloat"]) => true
+    member(op, ["Complex", "Expression", "List", "Polynomial",
+                "Matrix", "Vector"]) => isApproximate(CAR(CDR(t)))
+    false
+
 mmCost(name, sig,cond,tar,args1,args2) ==
   cost := mmCost0(name, sig,cond,tar,args1,args2)
   res := CADR sig
@@ -628,6 +635,8 @@
   -- modemaps with the wrong number of arguments if we want to the one
   -- with no arguments and the name is overloaded. Thus check for this.
 
+  nargs := #args1
+
   if args1 then
     for x1 in args1 for x2 in args2 for x3 in sigArgs repeat
       n := n +
@@ -637,6 +646,8 @@
         topcon = topcon2 => 3
         CAR topcon2 = 'Mapping => 2
         4
+      if isApproximate(x1) ~= isApproximate(x3) then
+          n := n + 10*nargs
   else if sigArgs then n := n + 100000000000
 
   res := CADR sig
-- 
                              Waldek Hebisch
[email protected] 

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en.

Reply via email to