Average Error: 21.3 → 0.2
Time: 2.1s
Precision: binary64
\[\]
\[\]
double code(double x, double y) {
	return ((double) sqrt(((double) (((double) (x * x)) + y))));
}
double code(double x, double y) {
	double VAR;
	if ((x <= -1.3538915016235814e+154)) {
		VAR = ((double) (((double) (y * ((double) (-0.5 / x)))) - x));
	} else {
		double VAR_1;
		if ((x <= 2.1816647917732645e+79)) {
			VAR_1 = ((double) sqrt(((double) (y + ((double) (x * x))))));
		} else {
			VAR_1 = ((double) (x + ((double) (y * ((double) (0.5 / x))))));
		}
		VAR = VAR_1;
	}
	return VAR;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original21.3
Target0.4
Herbie0.2
\[\]

Derivation

  1. Split input into 3 regimes
  2. if x < -1.35389150162358142e154

    1. Initial program 64.0

      \[\]
    2. Taylor expanded around -inf 0

      \[\leadsto \]
    3. Simplified0

      \[\leadsto \]

    if -1.35389150162358142e154 < x < 2.18166479177326452e79

    1. Initial program 0.0

      \[\]

    if 2.18166479177326452e79 < x

    1. Initial program 44.7

      \[\]
    2. Taylor expanded around inf 1.0

      \[\leadsto \]
    3. Simplified1.0

      \[\leadsto \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.2

    \[\leadsto \]

Reproduce

herbie shell --seed 2020191 
(FPCore (x y)
  :name "Linear.Quaternion:$clog from linear-1.19.1.3"
  :precision binary64

  :herbie-target
  (if (< x -1.5097698010472593e+153) (neg (+ (* 0.5 (/ y x)) x)) (if (< x 5.582399551122541e+57) (sqrt (+ (* x x) y)) (+ (* 0.5 (/ y x)) x)))

  (sqrt (+ (* x x) y)))