MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Precision and rounding

  • To: mathgroup at smc.vnet.net
  • Subject: [mg33231] Re: Precision and rounding
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Sat, 9 Mar 2002 18:05:15 -0500 (EST)
  • References: <a675kf$d14$1@smc.vnet.net> <a6ci84$ef6$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Numerics is not my area but the following may be of some help:

    NIntegrate[Sin[x+y],{x,0,7},{y,0,7}]//Timing

        {46.46 Second,0.323366}


    NIntegrate[Sin[x+y],{x,0,7},{y,0,7},
        PrecisionGoal->3]//Timing

        {0.61 Second,0.323366}

In some cases we can restrict the number of significant digits used in
internal calculations.
Default setting of $MaxPrecision is 10^6

    Block[{$MaxPrecision=3},
        NIntegrate[Sin[x+y],{x,0,7},{y,0,7}]
        ]//Timing

    NIntegrate::ploss: Numerical integration stopping due to loss of
precision. \
    Achieved neither the requested PrecisionGoal nor AccuracyGoal; suspect
one of \
    the following: highly oscillatory integrand or the true value of the
integral \
    is 0. If your integrand is oscillatory try using the option \
    Method->Oscillatory in NIntegrate.

        {0.11 Second,0.323368}

    Block[{$MaxPrecision=6},
        NIntegrate[Sin[x+y],{x,0,7},{y,0,7},
          PrecisionGoal->3]
        ]//Timing

        {0.99 Second,0.323366}
--
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


<bradamanteus at yahoo.com> wrote in message news:a6ci84$ef6$1 at smc.vnet.net...
> There must be a simple answer to this:
>
> I'm producing a large output file that takes a long time to compute, and I
> think this is partly becuase Mathematica always has my output as 14
decimal
> places, and I don't need such accuracy. Is there a way to reduce
calculation
> time by reducing the precision of all calculations in my model. Rounding
> with N doesn't work.
>
> Also, I'm told that I can reduce the time of my program by looking at a
> debugging tool that tells me how long the program spends on certain parts
of
> my code. What is this?
>
> thanks
>
> Leanne Ussher
>
>
>




  • Prev by Date: Re: Re: Bug in Simplify?
  • Next by Date: Electric Field Lines
  • Previous by thread: Precision and Rounding
  • Next by thread: Re: Precision and Rounding