Re: Globally limiting precision or accuracy
- To: mathgroup at smc.vnet.net
- Subject: [mg61032] Re: [mg61010] Globally limiting precision or accuracy
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Sat, 8 Oct 2005 02:48:40 -0400 (EDT)
- References: <200510070737.DAA03251@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On 7 Oct 2005, at 16:37, Lee Newman wrote: > Dear Group, > > Situation > - I have a large neural network model (my own code, not Wolfram's > toolbox) that currently has a run time of about 20hours. > - I am in the process of trying to profile and optimize the code > (mostly matrix computations) to reduce the run time. > - All of the computationas that I do are numerical. > > Questions > (1) If I am not concerned about numerical accuracy beyond 3 decimal > places for any of the computations in the model, can I improve > performance by telling mathematica to globally restrict its > accuracy (or > precision) for all computations? > > (2) If so, how do I do this? Is it as simple as setting > $MachinePrecision=3? I don't think this can be done at all. You can of course Unprotect [$MachinePrecision] and set the global $MachinePrecision variable to 3, but this won't make any difference at all to machine precision calculations because (as the name tells you) that is decided by the "machine" i.e. your processor. I am pretty sure there is no way to improve on the performance of machine precision floating point computations by any Mathematica commands. In fact, I think, the only way to do that is to get a faster computer. On the other hand you should be aware that when you use machine precision arithmetic Mathematica does not attempt to keep any track of the precision of your computations. If you come across an ill- conditioned expression it will return nonsensical answers without any warning. You certainly cannot be sure that any machine precision computation is accurate even to three digits. To be sure of that you have to work with extended precision numbers, because only then Mathematica will keep track of precision. By using exact quantities as input in your expression and computing N[expr,3] you should normally get guaranteed three digits of precision in a relatively efficient way. E.g. N[Pi+23/234,3] 3.24 Precision[%] 3. This will always be slower than when you do this with MachinePrecision (which formally gives more digits of "precision" but without any guarantee. > Is there a global way (rather than local use of > N[]) to ensure that all computations are done numerically, and with > machine precision? > As long as the numbers in your input are machine precision numbers, e.g. 1.3 or 2.3456 etc, all computations will be done with machine precision, with all that it entails (including the possibility of nonsensical answers). In fact, usually it is enough that you expression involves a single machine precision number for the entire expression to be computed using machine precision as in 1.2*Pi+123 126.77 Precision[%] MachinePrecision Andrzej Kozlowski
- Follow-Ups:
- Re: Re: Globally limiting precision or accuracy
- From: Andrzej Kozlowski <akoz@mimuw.edu.pl>
- Re: Re: Globally limiting precision or accuracy
- References:
- Globally limiting precision or accuracy
- From: Lee Newman <leenewm@umich.edu>
- Globally limiting precision or accuracy