float_to_round function?



Maybe something like:

   (%i24) round_some_floats(e) := scanmap(lambda([s], if floatnump(s) and 
abs(s-round(s)) * 10^6 < 1 then round(s) else s), e)$

   (%i26) round_some_floats(bessel(1.4,x) * bessel(42.0, 12) + 
sqrt(33.000001 * x + y) - bessel_j(1/2, 12));
   (%o26) sqrt(y+33*x)+bessel(1.4,x)*bessel(42,12)-bessel_j(1/2,12)

--Barton



From:   "Edwin Woollett" <woollett at charter.net>
To:     "maxima mailing list" <maxima at math.utexas.edu>
Date:   11/03/2011 01:55 PM
Subject:        Re: [Maxima] float_to_round function?
Sent by:        maxima-bounces at math.utexas.edu



On Nov. 3, 2011, I wrote:
----------------
>I would like to have a function
>float_to_round (expr) which parses the
>expression, and for each element z,
>if floatnump(z) is true, converts that
>element to round(z), and returns the expression.
----------------------------------

Let me refine the condition to:
if floatnump(z) is true and
abs (z - round(z)) < 1.0e-6 then
z is replaced by round(z).

Hence bessel_j(1/2,x) would not
be affected.

Ted Woollett

_______________________________________________
Maxima mailing list
Maxima at math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima