Average Error: 20.4 → 20.4
Time: 7.1s
Precision: binary64
\[[x, y, z]=\mathsf{sort}([x, y, z])\]
\[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z} \]
\[2 \cdot \sqrt{\mathsf{fma}\left(y, x, z \cdot \left(y + x\right)\right)} \]
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
2 \cdot \sqrt{\mathsf{fma}\left(y, x, z \cdot \left(y + x\right)\right)}
(FPCore (x y z)
 :precision binary64
 (* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z)))))
(FPCore (x y z) :precision binary64 (* 2.0 (sqrt (fma y x (* z (+ y x))))))
double code(double x, double y, double z) {
	return 2.0 * sqrt(((x * y) + (x * z)) + (y * z));
}
double code(double x, double y, double z) {
	return 2.0 * sqrt(fma(y, x, (z * (y + x))));
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original20.4
Target11.5
Herbie20.4
\[\begin{array}{l} \mathbf{if}\;z < 7.636950090573675 \cdot 10^{+176}:\\ \;\;\;\;2 \cdot \sqrt{\left(x + y\right) \cdot z + x \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(0.25 \cdot \left(\left({y}^{-0.75} \cdot \left({z}^{-0.75} \cdot x\right)\right) \cdot \left(y + z\right)\right) + {z}^{0.25} \cdot {y}^{0.25}\right) \cdot \left(0.25 \cdot \left(\left({y}^{-0.75} \cdot \left({z}^{-0.75} \cdot x\right)\right) \cdot \left(y + z\right)\right) + {z}^{0.25} \cdot {y}^{0.25}\right)\right) \cdot 2\\ \end{array} \]

Derivation

  1. Initial program 20.4

    \[2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z} \]
  2. Simplified20.4

    \[\leadsto \color{blue}{2 \cdot \sqrt{\mathsf{fma}\left(x, y + z, y \cdot z\right)}} \]
  3. Taylor expanded in x around 0 20.4

    \[\leadsto 2 \cdot \sqrt{\color{blue}{y \cdot x + \left(y \cdot z + z \cdot x\right)}} \]
  4. Simplified20.4

    \[\leadsto 2 \cdot \sqrt{\color{blue}{\mathsf{fma}\left(y, x, z \cdot \left(y + x\right)\right)}} \]
  5. Final simplification20.4

    \[\leadsto 2 \cdot \sqrt{\mathsf{fma}\left(y, x, z \cdot \left(y + x\right)\right)} \]

Reproduce

herbie shell --seed 2022039 
(FPCore (x y z)
  :name "Diagrams.TwoD.Apollonian:descartes from diagrams-contrib-1.3.0.5"
  :precision binary64

  :herbie-target
  (if (< z 7.636950090573675e+176) (* 2.0 (sqrt (+ (* (+ x y) z) (* x y)))) (* (* (+ (* 0.25 (* (* (pow y -0.75) (* (pow z -0.75) x)) (+ y z))) (* (pow z 0.25) (pow y 0.25))) (+ (* 0.25 (* (* (pow y -0.75) (* (pow z -0.75) x)) (+ y z))) (* (pow z 0.25) (pow y 0.25)))) 2.0))

  (* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z)))))