# Question:evalf[d] and Digits

## Question:evalf[d] and Digits

Maple

A fact that seems to be not documented. Probably it should be obvious.

Digits := d0
evalf[d](expr);

The toplevel float sub-expressions in expr  are computed with Digits=d0 but in procedures Digits is set to d.
Notice that the actual float parameters of the toplevel procedures are evalf-ed with Digits=d0.

 > restart;
 > g:=proc() convert(1/3., string) end: h:=proc() 1/3. end:
 > Digits:=3; evalf[10]([   1/3. = h(),   convert(1/3.,string) = g(),     fsolve(3*x=1) = add([1/3]),   fsolve(x/3=1/9.) # 1/9. being at top level is evalf-ed with Digits=3 ])
 (1)
 >
 > k:=proc(x) convert(x,string) end:
 > kernelopts(floatPi);
 (2)
 > 4.+Pi;
 (3)
 > evalf(k(1/3.+Pi)); # floatPi seems to be ignored inside actual parameters
 (4)
 > evalf(k(4+evalf(Pi)));
 (5)
 > evalf(k(4+Pi)); # 4 not being float (or "infected" by a float) is not evalf-ed
 (6)
 >
 > ### (this is documented)
 > `evalf/h` := proc() 7.777 end:
 > evalf(h(1/3));
 (7)
 > evalf('h'(1/3));
 (8)
 >

Download digits.mw

(edited)

﻿