Changes between Version 17 and Version 18 of doc/maths/remez/tutorialexponential
 Timestamp:
 Jan 9, 2012, 11:18:27 PM (8 years ago)
Legend:
 Unmodified
 Added
 Removed
 Modified

doc/maths/remez/tutorialexponential
v17 v18 38 38 { 39 39 RemezSolver<4, real> solver; 40 solver.Run(1, 1, f, 30);40 solver.Run(1, 1, f, 40); 41 41 return 0; 42 42 } … … 47 47 * We declare function `f` which returns the exponential of `x`: this is the function we want to approximate. 48 48 * We create a `RemezSolver` object for '''4thdegree polynomials''' and '''real numbers'''. As of now, no other number types are supported. 49 * We run the solver on the '''[1,1] range''', approximating '''function `f`''' for '''30 iterations'''. More iterations mean more precise results, but you will find that 30 to 50 are usually enough.49 * We run the solver on the '''[1,1] range''', approximating '''function `f`''' to ''40 decimals of precision''. The larger the precision, the more iterations are necessary, but the process usually takes only a few seconds for small functions. 50 50 51 51 == Compilation == … … 68 68 69 69 {{{ 70 Final error: 5.462771976237482581009771665937582411463e470 Step 7 error: 5.466676005137979474524666548947155992203e4 71 71 Polynomial estimate: 72 x**0*1.000090 75676472575388736298779202530899673 +x**1*9.9730 86551667860566788019540269306006270e174 +x**2*4.9883 32174505582284710918757571761729419e175 +x**3*1.7734 62612793916519454714108029230813767e176 +x**4*4.415 666059995979611944324860870682575219e272 x**0*1.000090000102127639946253082819502265543 73 +x**1*9.973092516744464320538318907902496576588e1 74 +x**2*4.988351170902359155314941477995868737492e1 75 +x**3*1.773452743688412268810974931504564418976e1 76 +x**4*4.415551762288022300015839013797254330891e2 77 77 }}} 78 78 … … 85 85 double fastexp(double x) 86 86 { 87 const double a0 = 1.000090 756764725753887362987792025308996;88 const double a1 = 9.9730 86551667860566788019540269306006270e1;89 const double a2 = 4.9883 32174505582284710918757571761729419e1;90 const double a3 = 1.7734 62612793916519454714108029230813767e1;91 const double a4 = 4.415 666059995979611944324860870682575219e2;87 const double a0 = 1.000090000102127639946253082819502265543; 88 const double a1 = 9.973092516744464320538318907902496576588e1; 89 const double a2 = 4.988351170902359155314941477995868737492e1; 90 const double a3 = 1.773452743688412268810974931504564418976e1; 91 const double a4 = 4.415551762288022300015839013797254330891e2; 92 92 93 93 return a0 + x * (a1 + x * (a2 + x * (a3 + x * a4))); … … 101 101 [[Image(fastexp.png, nolink)]] 102 102 103 The curves are undistinguishable. Actually they differ by no more than 5.46 2772e4, which is the value the `./remez` output gave.103 The curves are undistinguishable. Actually they differ by no more than 5.46668e4, which is the value the `./remez` output gave. 104 104 105 105 It can be verified on the following error curve: