Changeset 1312 for trunk/test_more


Ignore:
Timestamp:
Nov 21, 2008 4:09:54 AM (12 years ago)
Author:
bradbell
Message:

trunk: Use a much faster and simpler approximation for erf(x).

example/erf.cpp: change tolerances in erorr checking.
example.cpp: add tanh to test list (missing in previous commit).
whats_new_08.omh: users view of the changes.
erf.hpp: Much simplier approximation.
test_more/erf.cpp: change tolerance to less accurate routine.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test_more/erf.cpp

    r976 r1312  
    11/* --------------------------------------------------------------------------
    2 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-07 Bradley M. Bell
     2CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-08 Bradley M. Bell
    33
    44CppAD is distributed under multiple licenses. This distribution is under
     
    4040        x[0]  = 0.;
    4141        y = Erf.Forward(0, x); 
    42         ok &= NearEqual(0., y[0], 1e-10, 1e-10);
     42        ok &= NearEqual(0., y[0], 4e-4, 0.);
    4343
    4444        // check the derivative of error function
     
    4747        double factor = 2. / sqrt( pi );
    4848        int i;
    49         for(i = -30; i <= 30; i++)
     49        for(i = -10; i <= 10; i++)
    5050        {       x[0] = i / 4.;
    5151                y    = Erf.Forward(0, x);       
     
    5454                double derf = factor * exp( - x[0] * x[0] );
    5555                dy          = Erf.Forward(1, dx);
    56                 ok         &= NearEqual(derf, dy[0], 1e-10, 1e-10);
     56                ok         &= NearEqual(derf, dy[0], 0., 2e-3);
    5757
    5858                // test using erf with AD< AD<double> >
Note: See TracChangeset for help on using the changeset viewer.