Compile
- To: mathgroup at yoda.physics.unc.edu
- Subject: Compile
- From: rubin at msu.edu (Paul A. Rubin)
- Date: Tue, 28 Jun 94 11:22:16 EDT
>Mathgroupers:
>
>I compile the simple expression (Version 2.2.2 on mac PPC 6100/60):
>
>f = Compile[ {{x, _Real}}, x/10^8 ]
>
>Evaluating it:
>
>f[1.0] -> "CompiledFunction::cfn: Numerical error encountered at
>instruction 6; proceeding with uncompiled evaluation."
>
>If I replace 10^8 by 10^7 it works.
Really? In version 2.2.2 on a Windoze machine, it doesn't (same error
message as with 10^8).
>If I replace 10^8 by 100000000 it works.
>If I define the function as 1.0/x and evaluate it at 10^8 it works.
>
>I assume it's a bug, or have I missed something ?
>
>Mike Burns
>Rowland Institute for Science
>
I'm not sure if it's a bug or a "feature." I tried
f = Compile[ {{x, _Real}}, x/10.^8 ]
and it worked. My guess is that there is an issue of the representation of
the denominator within the compiled function. 10.^8 will obviously be
stored as a machine real. 100000000 probably is initially considered an
integer, but it's too big to store as a machine integer, so my guess is that
Compile converts it to a machine real. I suspect that the 1.0/x version
works because Mma, knowing the argument x is supposed to be Real, converts
10^8 to a real before further processing. The original version (10^8),
though, may very well be coded as Power[ 10, 8 ], which does not yield a
machine real and, for whatever reason, is not converted. WRI wrote Compile
with the explicit provision that it would fall back on uncompiled code if
something proved not to be a machine real. I guess they figure you're
intending 10^8 to be infinite precision; otherwise, you would have written
"10.^8." (Of course, all this is conjecture.)
Paul
**************************************************************************
* Paul A. Rubin Phone: (517) 336-3509 *
* Department of Management Fax: (517) 336-1111 *
* Eli Broad Graduate School of Management Net: RUBIN at MSU.EDU *
* Michigan State University *
* East Lansing, MI 48824-1122 (USA) *
**************************************************************************
Mathematicians are like Frenchmen: whenever you say something to them,
they translate it into their own language, and at once it is something
entirely different. J. W. v. GOETHE