examples/cadna/cadna_failures.cpp
/*
 * demonstration of error followed through a trigonometric function
 *
 * useful to showcase src's ability to follow error in transcendentalfunctions while others (Verrou, Cadna?, verificarlo?) just ignore them
 */
demonstration of error followed through a trigonometric function
useful to showcase src's ability to follow error in transcendentalfunctions while others (Verrou, Cadna?, verificarlo?) just ignore them
demonstration of error followed through a trigonometric function useful to showcase src ' s ability to follow error in transcendentalfunctions while others ( Verrou Cadna? verificarlo? ) just ignore them
void trigoTest()
{
  std::cout << "An example, using a trigonometric function, where CADNA overestimate the number of significative digits." << std::endl;
  double bigNum = 2e30;
  double epsi = 10;
  double result = cos(epsi);
  {
    double x = bigNum;
    double y = x + epsi;
    double sum1 = cos(x-y);
    double sum2 = cos(x)*cos(y) + sin(x)*sin(y);
    std::cout << "DOUBLE cos(x-y) = " << sum1 << " = " << sum2 << " (true result=" << result << ')' << std::endl;
  }
#ifdef CADNA
  {
    Cdouble x = bigNum;
    Cdouble y = x + epsi;
    Cdouble sum1 = cos(x-y);
    Cdouble sum2 = cos(x)*cos(y) + sin(x)*sin(y);
    std::cout << "CADNA  cos(x-y) = " << sum1 << " = " << sum2 << " (true result=" << result << ')' << std::endl;
  }
#endif
  {
    Sdouble x = bigNum;
    Sdouble y = x + epsi;
    Sdouble sum1 = cos(x-y);
    Sdouble sum2 = cos(x)*cos(y) + sin(x)*sin(y);
    std::cout << "SHAMAN cos(x-y) = " << sum1 << " = " << sum2 << " (true result=" << result << " estimated-true-result=" << (sum1.number+sum1.error) << ')' << std::endl;
  }
}
void trigoTest ( ) { std :: cout << " " << std :: endl ; double bigNum = 2e30 ; double epsi = 10 ; double result = cos ( epsi ) ; { double x = bigNum ; double y = x + epsi ; double sum1 = cos ( x - y ) ; double sum2 = cos ( x ) * cos ( y ) + sin ( x ) * sin ( y ) ; std :: cout << " " << sum1 << " " << sum2 << " " << result << ' ' << std :: endl ; } #ifdef CADNA { Cdouble x = bigNum ; Cdouble y = x + epsi ; Cdouble sum1 = cos ( x - y ) ; Cdouble sum2 = cos ( x ) * cos ( y ) + sin ( x ) * sin ( y ) ; std :: cout << " " << sum1 << " " << sum2 << " " << result << ' ' << std :: endl ; } #endif { Sdouble x = bigNum ; Sdouble y = x + epsi ; Sdouble sum1 = cos ( x - y ) ; Sdouble sum2 = cos ( x ) * cos ( y ) + sin ( x ) * sin ( y ) ; std :: cout << " " << sum1 << " " << sum2 << " " << result << " " << ( sum1 . number + sum1 . error ) << ' ' << std :: endl ; } }
demonstration of error followed through a trigonometric function
 useful to showcase src's ability to follow error in transcendentalfunctions while others (Verrou, Cadna?, verificarlo?)
demonstration of error followed through a trigonometric function useful to showcase src ' s ability to follow error in transcendentalfunctions while others ( Verrou Cadna? verificarlo? )
/*
   * 2e20 : no significativ digits, everybody is correct
   * 2e25 : there is one significative digit (pure luck),  src might detect it
   * 2e30 : no significative digits, cadna is optimistic by 2 digits, src is correct
   */ // double // cadna // src