From: Richard F. <fa...@be...> - 2018-06-04 20:41:48
|
On 6/4/2018 1:03 PM, Stavros Macrakis (Σταῦρος Μακράκης) wrote: > I am not sure what the problem is that you want to solve. > > float(v) loses precision: v-rationalize(float(v)) => -1, so it's not > surprising that cos(v) is what it is: > > fpprintprec:3$ > fpprec:1000$ > cos(bfloat(float(v))) => -0.84 > > Similarly, for fpprec < 16, bfloat(v) loses digits. For example, > > v: 18190586279576483$ > fpprec:15$ > v-rationalize(bfloat(v)) => 3 > > So it's not surprising that cos(v) is not accurate. > > For fpprec > 15, cos(v) is consistently very accurate: > > cv1000: block([fpprec:1000],bfloat(cos(v)))$ > makelist(block([fpprec:3*i],[fpprec,(cv1000-bfloat(cos(v)))/10^-fpprec]),i,1,20) > => > [- 9.7b2, 3.12b5, 8.12b8, - 8.86b11, - 1.41b14, > - 2.63b-4, - 6.13b-4, 1.72b-4, 2.11b-4, 5.1b-4, > 1.24b-4, 2.71b-4, 1.71b-4, 7.54b-5, 1.25b-4, > 4.0b-4, - 4.43b-5, 3.42b-4, 1.73b-4, 1.09b-4] > > So where exactly is the problem? > > -s > > <snip> I get different results on Maxima version: 5.40.0 Lisp: SBCL 1.3.12 running the same code as above, I get the error in the cosine routine to seem more like 28 decimal digits after fpprec:30 or more. I would expect the error to be more like 0.0b0; try the same experiment with, say, v=123456789123456890... (%i118) cv1000: block([fpprec:1000],bfloat(cos(v)))$ makelist(block([fpprec:3*i],[fpprec,(cv1000-bfloat(cos(v)))/10^-fpprec]),i,1,20); (%o118) [[3,4.65b2],[6,1.98b6],[9,6.46b8],[12,5.51b11],[15,2.84b14],[18,1.97b18],[21,-1.3b19],[24,6.82b23],[27,1.97b27],[30,1.4b29],[33,-3.93b28],[36,-8.57b28],[39,-5.4b28],[42,-2.38b28],[45,-3.94b28],[48,-1.26b29],[51,1.4b28],[54,-1.08b29],[57,-5.45b28],[60,-3.44b28]] |