Re: Can I force arbitary precision

• To: mathgroup at smc.vnet.net
• Subject: [mg25579] Re: Can I force arbitary precision
• From: "Allan Hayes" <hay at haystack.demon.co.uk>
• Date: Mon, 9 Oct 2000 01:16:43 -0400 (EDT)
• References: <8rou5r\$5e6@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```

"wkuang" <wkuang at usc.edu> wrote in message news:8rou5r\$5e6 at smc.vnet.net...
> Hi,
>
> I am doing a little numerical calculation on Mathematica. The problem is
> that if I input a number as 1.7341421*^-9, mathematica automatically
> trim it to machine precision number. Yes, I can force the number as 200
> digit precision, but efficiency sacrificed. And I have to try different
> precision to make sure that it runs as fast and as accurate. My question
> is: can I force an arbitary precision so that I could throw the
> precision and accuracy problem to mathematica? thanks
>
> --
> Wan Kuang
> Electric Engineering - Electrophysics
> University of Southern California
> Los Angeles, CA 90007
>

An important feature for numerical work is that if expr is an exact numeric
expression (built up from integers, rationals, constants like Pi and E,
complex numbers with such real and imaginary parts, and functions having the
attribute NumericFunction), then,  if p>\$MachinePrecision,
N[expr,p] will increase its working precision to try to return an output
with precision p (this increase in working precision can only be up to
\$MachinePrecision + \$MaxExtraPrecision (default value 50 but can be set by
the user)). The values obtained are cached; the cache can be cleared with
Developer`ClearCache["Numeric"].

Example

Sin[1.7341421*^40]

0.

But

Make the input exact numeric.

SetPrecision[Hold[Sin[1.7341421*^40]], Infinity]

Hold[Sin[17341421000000000320853483483622264537088]]

Now use N.

N[#, \$MachinePrecision + 1] & @@ %

-0.64770457507226401

Precision[%]

17

For more see Stan Wagon: Mathematica in Education and Research, Volume 7, No
2, Programming Tips, Bending Plot to Your Needs
--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

```

• Prev by Date: Re: Complex Function Plot
• Next by Date: Re: making a function linear
• Previous by thread: Can I force arbitary precision
• Next by thread: 3-D HDF Importing and displaying