Average Error: 30.2 → 0
Time: 7.5s
Precision: 64
\[\sqrt{{x}^{2}}\]
\[\left|{x}^{\left(\frac{2}{2}\right)}\right|\]
\sqrt{{x}^{2}}
\left|{x}^{\left(\frac{2}{2}\right)}\right|
double f(double x) {
        double r1858567 = x;
        double r1858568 = 2.0;
        double r1858569 = pow(r1858567, r1858568);
        double r1858570 = sqrt(r1858569);
        return r1858570;
}

double f(double x) {
        double r1858571 = x;
        double r1858572 = 2.0;
        double r1858573 = 2.0;
        double r1858574 = r1858572 / r1858573;
        double r1858575 = pow(r1858571, r1858574);
        double r1858576 = fabs(r1858575);
        return r1858576;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 30.2

    \[\sqrt{{x}^{2}}\]
  2. Using strategy rm
  3. Applied sqr-pow30.2

    \[\leadsto \sqrt{\color{blue}{{x}^{\left(\frac{2}{2}\right)} \cdot {x}^{\left(\frac{2}{2}\right)}}}\]
  4. Applied rem-sqrt-square0

    \[\leadsto \color{blue}{\left|{x}^{\left(\frac{2}{2}\right)}\right|}\]
  5. Final simplification0

    \[\leadsto \left|{x}^{\left(\frac{2}{2}\right)}\right|\]

Reproduce

herbie shell --seed 1 
(FPCore (x)
  :name "sqrt(x^2)"
  :precision binary64
  (sqrt (pow x 2)))