Changes between Version 17 and Version 18 of doc/maths/remez/tutorial-exponential


Ignore:
Timestamp:
Jan 9, 2012, 11:18:27 PM (8 years ago)
Author:
sam
Comment:

fix tutorial for upcoming LolRemez 0.2

Legend:

Unmodified
Added
Removed
Modified
  • doc/maths/remez/tutorial-exponential

    v17 v18  
    3838{
    3939    RemezSolver<4, real> solver;
    40     solver.Run(-1, 1, f, 30);
     40    solver.Run(-1, 1, f, 40);
    4141    return 0;
    4242}
     
    4747 * We declare function `f` which returns the exponential of `x`: this is the function we want to approximate.
    4848 * We create a `RemezSolver` object for '''4th-degree 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.
    5050
    5151== Compilation ==
     
    6868
    6969{{{
    70 Final error: 5.462771976237482581009771665937582411463e-4
     70Step 7 error: 5.466676005137979474524666548947155992203e-4
    7171Polynomial estimate:
    72 x**0*1.000090756764725753887362987792025308996
    73 +x**1*9.973086551667860566788019540269306006270e-1
    74 +x**2*4.988332174505582284710918757571761729419e-1
    75 +x**3*1.773462612793916519454714108029230813767e-1
    76 +x**4*4.415666059995979611944324860870682575219e-2
     72x**0*1.000090000102127639946253082819502265543
     73+x**1*9.973092516744464320538318907902496576588e-1
     74+x**2*4.988351170902359155314941477995868737492e-1
     75+x**3*1.773452743688412268810974931504564418976e-1
     76+x**4*4.415551762288022300015839013797254330891e-2
    7777}}}
    7878
     
    8585double fastexp(double x)
    8686{
    87     const double a0 = 1.000090756764725753887362987792025308996;
    88     const double a1 = 9.973086551667860566788019540269306006270e-1;
    89     const double a2 = 4.988332174505582284710918757571761729419e-1;
    90     const double a3 = 1.773462612793916519454714108029230813767e-1;
    91     const double a4 = 4.415666059995979611944324860870682575219e-2;
     87    const double a0 = 1.000090000102127639946253082819502265543;
     88    const double a1 = 9.973092516744464320538318907902496576588e-1;
     89    const double a2 = 4.988351170902359155314941477995868737492e-1;
     90    const double a3 = 1.773452743688412268810974931504564418976e-1;
     91    const double a4 = 4.415551762288022300015839013797254330891e-2;
    9292
    9393    return a0 + x * (a1 + x * (a2 + x * (a3 + x * a4)));
     
    101101[[Image(fastexp.png, nolink)]]
    102102
    103 The curves are undistinguishable. Actually they differ by no more than 5.462772e-4, which is the value the `./remez` output gave.
     103The curves are undistinguishable. Actually they differ by no more than 5.46668e-4, which is the value the `./remez` output gave.
    104104
    105105It can be verified on the following error curve: