|
From: | Przemek Klosowski |
Subject: | Re: Symbolica package warning: Using rat() heuristics for double-precision input (is this what you wanted?) |
Date: | Fri, 17 Feb 2017 14:02:02 -0500 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 |
On 02/17/2017 12:17 PM, Mike Miller
wrote:
No, there is something magic about the double value returned by pi. The function that converts numeric values has special code to test whether a given double value is exactly pi (to the extent of double precision), and replaces that with the string value "pi" for SymPy to evaluate. Interesting.. this made me look at the rats() heuristics. E.g.
sym(e) shows that e is crudely approximated by 1457/536, which is
even less accurate than rats(e)(*) Specifically, shouldn't the rat() heuristics also use more
significant digits instead of the default 9? I say that because it
looks like vpa() arithmetic uses 50 significant digits at least
for vpa(pi/2), so asking for 50 in the rat() conversion(**) would
be more consistent. Or is 50 just an accident in the case of pi/2? p
(*) rats(e) is 2721/1001, which is what results from rats(e,9);
you have to drop the precision to 8 to get what the sym(e) uses:
rats(e,8) = 1457/536 (**) I do realize that rats() does double precision comparisons,
so it probably doesn't make sense to ask for more than 15 digits,
but still it's better than 8 |
[Prev in Thread] | Current Thread | [Next in Thread] |