Re: problems with precision

*To*: mathgroup at smc.vnet.net*Subject*: [mg7660] Re: [mg7646] problems with precision*From*: David Withoff <withoff>*Date*: Thu, 26 Jun 1997 01:36:47 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

> I am a french student doing a trainee on mathematica. There is another > team having the same project as I have but it's working with Maple. > We had to calculate with high accuracy (more than 20 digits) the solution > of a 2 dimensional non-linear system. The problem to solve was very easy. > But Maple and Mathematica agreed only on the 15 first digits. I used the > function SetPrecision. Is there another function to set calculus precision > ? > > Here is the listing of my routine in Mathematica : > > rr=Table[FindRoot[{x+Cos[y]*Sinh[x]==0,y+Sin[y]*Cosh[x]==0},{x,N[Abs[Cos[(2*p-1)*Pi+Pi/4]]Sqrt[((2*p-1)*Pi+Pi/4/Sin[(2*p-1)*Pi+Pi/4]^2)-1]]},{y,(2*p-1)*Pi+Pi/4}] > , {p, 1, 20, 1}] > > rr=SetPrecision[rr,20] > > ListPlot[{x, y} /. rr] > > r={x, y} /. rr; Here is an input that will give 20 digits of accuracy. rr=Table[FindRoot[{x+Cos[y]*Sinh[x]==0,y+Sin[y]*Cosh[x]==0}, {x,Abs[Cos[(2*p-1)*Pi+Pi/4]] * Sqrt[((2*p-1)*Pi+Pi/4/Sin[(2*p-1)*Pi+Pi/4]^2)-1]},{y,(2*p-1)*Pi+Pi/4}, AccuracyGoal -> 20, WorkingPrecision -> 26], {p, 1, 20, 1}] The SetPrecision function simply sets the number of significant digits to the specified value, without doing any additional calculations. In your program, the initial calculation is done using machine precision, which is about 16 digits, so SetPrecision[rr, 20] artificially raises the precision to 20, by padding the results with (effectively) random numbers. That is probably not what you wanted. Although there are important computational reasons to use SetPrecision (or SetAccuracy) to either raise or lower the number of significant digits in a result, it is rarely if ever mathematically useful to raise the precision of the result. To get a mathematically meaningful high-precision result, it is necessary to use high-precision inputs, and do a high-precision calculation. Dave Withoff Wolfram Research