Average Error: 28.4 → 0.2
Time: 9.8s
Precision: 64
\[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\]
\[\frac{\left|z\right| + \mathsf{hypot}\left(x, y\right)}{\frac{2}{\frac{\mathsf{hypot}\left(x, y\right)}{y} - \frac{\left|z\right|}{y}}}\]
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\frac{\left|z\right| + \mathsf{hypot}\left(x, y\right)}{\frac{2}{\frac{\mathsf{hypot}\left(x, y\right)}{y} - \frac{\left|z\right|}{y}}}
double code(double x, double y, double z) {
	return ((((x * x) + (y * y)) - (z * z)) / (y * 2.0));
}
double code(double x, double y, double z) {
	return ((fabs(z) + hypot(x, y)) / (2.0 / ((hypot(x, y) / y) - (fabs(z) / y))));
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original28.4
Target0.2
Herbie0.2
\[y \cdot 0.5 - \left(\frac{0.5}{y} \cdot \left(z + x\right)\right) \cdot \left(z - x\right)\]

Derivation

  1. Initial program 28.4

    \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\]
  2. Using strategy rm
  3. Applied *-un-lft-identity28.4

    \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{\color{blue}{1 \cdot \left(y \cdot 2\right)}}\]
  4. Applied add-sqr-sqrt28.4

    \[\leadsto \frac{\left(x \cdot x + y \cdot y\right) - \color{blue}{\sqrt{z \cdot z} \cdot \sqrt{z \cdot z}}}{1 \cdot \left(y \cdot 2\right)}\]
  5. Applied add-sqr-sqrt28.4

    \[\leadsto \frac{\color{blue}{\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y}} - \sqrt{z \cdot z} \cdot \sqrt{z \cdot z}}{1 \cdot \left(y \cdot 2\right)}\]
  6. Applied difference-of-squares28.4

    \[\leadsto \frac{\color{blue}{\left(\sqrt{x \cdot x + y \cdot y} + \sqrt{z \cdot z}\right) \cdot \left(\sqrt{x \cdot x + y \cdot y} - \sqrt{z \cdot z}\right)}}{1 \cdot \left(y \cdot 2\right)}\]
  7. Applied times-frac28.3

    \[\leadsto \color{blue}{\frac{\sqrt{x \cdot x + y \cdot y} + \sqrt{z \cdot z}}{1} \cdot \frac{\sqrt{x \cdot x + y \cdot y} - \sqrt{z \cdot z}}{y \cdot 2}}\]
  8. Simplified28.3

    \[\leadsto \color{blue}{\left(\left|z\right| + \mathsf{hypot}\left(x, y\right)\right)} \cdot \frac{\sqrt{x \cdot x + y \cdot y} - \sqrt{z \cdot z}}{y \cdot 2}\]
  9. Simplified0.1

    \[\leadsto \left(\left|z\right| + \mathsf{hypot}\left(x, y\right)\right) \cdot \color{blue}{\frac{\frac{\mathsf{hypot}\left(x, y\right)}{y} - \frac{\left|z\right|}{y}}{2}}\]
  10. Using strategy rm
  11. Applied clear-num0.2

    \[\leadsto \left(\left|z\right| + \mathsf{hypot}\left(x, y\right)\right) \cdot \color{blue}{\frac{1}{\frac{2}{\frac{\mathsf{hypot}\left(x, y\right)}{y} - \frac{\left|z\right|}{y}}}}\]
  12. Applied un-div-inv0.2

    \[\leadsto \color{blue}{\frac{\left|z\right| + \mathsf{hypot}\left(x, y\right)}{\frac{2}{\frac{\mathsf{hypot}\left(x, y\right)}{y} - \frac{\left|z\right|}{y}}}}\]
  13. Final simplification0.2

    \[\leadsto \frac{\left|z\right| + \mathsf{hypot}\left(x, y\right)}{\frac{2}{\frac{\mathsf{hypot}\left(x, y\right)}{y} - \frac{\left|z\right|}{y}}}\]

Reproduce

herbie shell --seed 2020066 +o rules:numerics
(FPCore (x y z)
  :name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
  :precision binary64

  :herbie-target
  (- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x)))

  (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2)))