MathGroup Archive 1999

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

Search the Archive

Re: how to avoid numeric error

Thanks for the comment and function. I still am not clear on why the
floating point x1 doesn't force machine precision, regardless of whether the
exponent is a float or integer, since I had thought that even one floating
point parameter results in the entire expression being evaluated


BobHanlon at wrote in message <7ubq06$5q7$4 at>...
>8.551437202665365431742222523666`12.6535*^864 -
>  2.4803091328936406321397756468`12.6535*^852*I
>Despite its large magnitude, the magnitude of the imaginary part is small
>compared to the magnitude of the real part (differ by 12 orders of
>10^864*Chop[(-5.2)^1208./10^864] == (-5.2)^1208
>Extending the concept of Chop
>relativeChop[x_ , delta_:10^-10] /; (Abs[x] == 0) = 0;
>relativeChop[x_, delta_:10^-10] :=
>  Module[{mag = Abs[x]}, mag*Chop[x/mag, delta]]
>relativeChop[(-5.2)^1208.] == (-5.2)^1208
>Bob Hanlon
>In a message dated 10/16/1999 12:38:51 AM, atulksharma at writes:
>>I am at a loss to explain this behavior, though I perhaps
>>misunderstand how Mathematica implements it's machine precision routines.
>>This is a simple example of a problem that cropped up during evaluation
>>constants of integration
>>in a WKB approximation, where I would get quite different results
>>on how the constant was evaluated. I have localized the discrepancy to
>>term of the form shown below:
>>testParameters =
>>  {x1 -> 5.2, x2 -> 0.3, x3 -> 0.002, x4 -> -0.00025}
>>(-x1)^(-(x2 + x3)/x4) /. testParameters
>>In this case, as it turns out, x1 = -5.2, which is a floating point
>>and the exponent = 1208 (which may be integer or floating point, but is
>>floating point in this case).
>>I assumed that the result would be evaluated to machine precision in
>>since x1 is a float regardless. However, depending on whether the exponent
>>is integer or not, I get two different results, with a large imaginary
>>8.55143720266536543174145`12.6535*^864 -
>>  2.48026735232231456274073`12.6535*^852*I
>>I assume that this has some simple relationship to machine precision and
>>round-off error, but am I wrong in assuming that x1 should determine the
>>numeric precision of the entire operation?
>>I am using Mathematica 3.01.1 on a PC/Win95 platform.
>>I also encountered another problem, which bothers me because it's so
>>insidious. In moving a notebook from one machine to another by floppy
>>to home), a parsing error occurred buried deep inside about 30 pages of
>>code. A decimal number of the form 1.52356 was parsed as 1.5235 6 with
>>space inserted and interpreted as multiplication. The same error occured
>>the same place on several occasions (i.e. when I start getting bizarre
>>results, I know to go and correct this error).
>>I know these sound minor, but they have a large effect on the solution
>>could easily go undetected. Thanks in advance.

  • Prev by Date: Re: Solving trig equations - Tan[x] = Sqrt[3]
  • Next by Date: Re: Basic Laplace Transforms
  • Previous by thread: Re: how to avoid numeric error
  • Next by thread: Re: Re: how to avoid numeric error