floating-point problems with 5.22.1



Mostly unrelated: changing apply("+", ...) to tree_reduce("+",...) speeds up one of your
calculations by a factor of about 85 (37 seconds to 0.44 seconds) and doesn't change
the order the floats are added:

 (%i13) testf1(n) := float(apply("+",makelist(log(i)*(-1)^i,i,1,n)));
 Evaluation took 0.0000 seconds (0.0000 elapsed)
 (%o13) testf1(n):=float(apply("+",makelist(log(i)*(-1)^i,i,1,n)))

 (%i20) testf2(n) := float(tree_reduce("+",create_list(log(i)*(-1)^i,i,1,n)));
  Evaluation took 0.0000 seconds (0.0000 elapsed)

 (%o20) testf2(n):=float(tree_reduce("+",create_list(log(i)*(-1)^i,i,1,n)))
 (%i22) testf1(10000);
  Evaluation took 37.1600 seconds (37.1600 elapsed)
 (%o22) 4.83098653863282

 (%i23) testf2(10000);
 Evaluation took 0.4300 seconds (0.4300 elapsed)
 (%o23) 4.83098653863282

Sorry for the off-topic shameless plug (for tree_reduce).

--Barton

-----maxima-bounces at math.utexas.edu wrote: -----

>testf1(n)?:=?float(apply("+",create_list(log(i)*(-1)^i,i,1,n)));
>testf1c(n):=block([fpprec:30],bfloat(apply("+",create_list(log(i)*(-1)^i,i
>,1,n))));
>testf1f(n)?:=?apply("+",create_list(float(log(i))*(-1)^i,i,1,n));
>
>21:
>
>(%i24)?testf1(10000);
>Evaluation?took?79.0520?seconds?(125.7410?elapsed)