Changes between Version 6 and Version 7 of research/trig


Ignore:
Timestamp:
Oct 14, 2011, 12:16:42 PM (9 years ago)
Author:
sam
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • research/trig

    v6 v7  
    1414}}}
    1515
    16 We know sin(x) is an odd function, so instead we look for a polynomial Q(x) such that P(x) = xQ(x²):
     16We know sin(x) is an odd function, so instead we look for a polynomial Q(x) such that P(x) = xQ(x²), and we reduce the range to positive values:
    1717
    1818{{{
    1919#!latex
    20 \[\max_{x \in [-\pi/2, \pi/2]}{\big\vert\sin(x) - xQ(x^2)\big\vert} = E\]
     20\[\max_{x \in [0, \pi/2]}{\big\vert\sin(x) - xQ(x^2)\big\vert} = E\]
    2121}}}
    2222
    23 Substitute y for x² and reduce the range to positive values:
     23Substitute y for x²:
    2424
    2525{{{
     
    5353{{{
    5454#!cpp
    55 
    5655static real myfun(real const &y)
    5756{
     
    9291a6 = -7.36458957326227991327065122848667046e-13;
    9392}}}
     93
     94=== Relative error ===
     95
     96Searching for '''relative error''' instead:
     97
     98{{{
     99#!latex
     100\[\max_{x \in [-\pi/2, \pi/2]}{\dfrac{\big\vert\sin(x) - P(x)\big\vert}{|\sin(x)|}} = E\]
     101}}}
     102
     103Using the same method as for absolute error, we get:
     104
     105{{{
     106#!latex
     107\[\max_{x \in [0, \pi^2/4]}{\dfrac{\bigg\lvert\dfrac{\sin(\sqrt{y})-\sqrt{y}}{y\sqrt{y}} - R(y)\bigg\rvert}{\bigg\lvert\dfrac{\sin(y)}{y\sqrt{y}}\bigg\rvert}} = E\]
     108}}}
     109
     110{{{
     111#!cpp
     112static real myfun(real const &y)
     113{
     114    real x = sqrt(y);
     115    return (sin(x) - x) / (x * y);
     116}
     117
     118static real myerr(real const &y)
     119{
     120    real x = sqrt(y);
     121    return sin(x) / (x * y);
     122}
     123
     124RemezSolver<6> solver;
     125solver.Run(real::R_1 >> 400, real::R_PI_2 * real::R_PI_2, myfun, myerr, 15);
     126}}}
     127
     128{{{
     129#!cpp
     130a0 = -1.666666666666666587374325845020415990185e-1;
     131a1 = +8.333333333333133768001243698120735518527e-3;
     132a2 = -1.984126984109960366729319073763957206143e-4;
     133a3 = +2.755731915499171528179303925040423384803e-6;
     134a4 = -2.505209340355388148617179634180834358690e-8;
     135a5 = +1.605725287696319345779134635418774782711e-10;
     136a6 = -7.535968124281960435283756562793611388136e-13;
     137}}}