how to avoid numeric error

*To*: mathgroup at smc.vnet.net*Subject*: [mg20309] how to avoid numeric error*From*: "Atul Sharma" <atulksharma at yahoo.com>*Date*: Fri, 15 Oct 1999 20:20:40 -0400*Sender*: owner-wri-mathgroup at wolfram.com

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 of constants of integration in a WKB approximation, where I would get quite different results depending on how the constant was evaluated. I have localized the discrepancy to one 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 number, 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 either case, 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 component In[27]:= (-5.2)^1208. Out[27]= 8.55143720266536543174145`12.6535*^864 - 2.48026735232231456274073`12.6535*^852*I In[28]:=(-5.2)^1208 Out[28]= 8.55143720266675767908621`12.8725*^864 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 (work 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 a space inserted and interpreted as multiplication. The same error occured in 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 and could easily go undetected. Thanks in advance. A. Sharma -------------------------------------------------- Atul Sharma MD, FRCP(C) Pediatric Nephrologist, McGill University/Montreal Children's Hospital