Average Error: 28.0 → 1.7
Time: 5.2s
Precision: binary64
\[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.3369798884979556 \cdot 10^{154}:\\ \;\;\;\;0.5 \cdot \left(\left(y + \frac{\frac{x}{y}}{\frac{1}{x}}\right) - \frac{{z}^{2}}{y}\right)\\ \mathbf{elif}\;x \le 9.96878875477082418 \cdot 10^{153}:\\ \;\;\;\;0.5 \cdot \left(\left(y + \frac{{x}^{2}}{y}\right) - z \cdot \frac{z}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\left(y + \frac{x}{\frac{y}{x}}\right) - \frac{{z}^{2}}{y}\right)\\ \end{array}\]
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\begin{array}{l}
\mathbf{if}\;x \le -1.3369798884979556 \cdot 10^{154}:\\
\;\;\;\;0.5 \cdot \left(\left(y + \frac{\frac{x}{y}}{\frac{1}{x}}\right) - \frac{{z}^{2}}{y}\right)\\

\mathbf{elif}\;x \le 9.96878875477082418 \cdot 10^{153}:\\
\;\;\;\;0.5 \cdot \left(\left(y + \frac{{x}^{2}}{y}\right) - z \cdot \frac{z}{y}\right)\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(y + \frac{x}{\frac{y}{x}}\right) - \frac{{z}^{2}}{y}\right)\\

\end{array}
double code(double x, double y, double z) {
	return ((double) (((double) (((double) (((double) (x * x)) + ((double) (y * y)))) - ((double) (z * z)))) / ((double) (y * 2.0))));
}
double code(double x, double y, double z) {
	double VAR;
	if ((x <= -1.3369798884979556e+154)) {
		VAR = ((double) (0.5 * ((double) (((double) (y + ((double) (((double) (x / y)) / ((double) (1.0 / x)))))) - ((double) (((double) pow(z, 2.0)) / y))))));
	} else {
		double VAR_1;
		if ((x <= 9.968788754770824e+153)) {
			VAR_1 = ((double) (0.5 * ((double) (((double) (y + ((double) (((double) pow(x, 2.0)) / y)))) - ((double) (z * ((double) (z / y))))))));
		} else {
			VAR_1 = ((double) (0.5 * ((double) (((double) (y + ((double) (x / ((double) (y / x)))))) - ((double) (((double) pow(z, 2.0)) / y))))));
		}
		VAR = VAR_1;
	}
	return VAR;
}

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.0
Target0.2
Herbie1.7
\[y \cdot 0.5 - \left(\frac{0.5}{y} \cdot \left(z + x\right)\right) \cdot \left(z - x\right)\]

Derivation

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

    1. Initial program 64.0

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\]
    2. Taylor expanded around 0 64.0

      \[\leadsto \color{blue}{\left(0.5 \cdot y + 0.5 \cdot \frac{{x}^{2}}{y}\right) - 0.5 \cdot \frac{{z}^{2}}{y}}\]
    3. Simplified64.0

      \[\leadsto \color{blue}{0.5 \cdot \left(\left(y + \frac{{x}^{2}}{y}\right) - \frac{{z}^{2}}{y}\right)}\]
    4. Using strategy rm
    5. Applied unpow264.0

      \[\leadsto 0.5 \cdot \left(\left(y + \frac{\color{blue}{x \cdot x}}{y}\right) - \frac{{z}^{2}}{y}\right)\]
    6. Applied associate-/l*11.3

      \[\leadsto 0.5 \cdot \left(\left(y + \color{blue}{\frac{x}{\frac{y}{x}}}\right) - \frac{{z}^{2}}{y}\right)\]
    7. Using strategy rm
    8. Applied div-inv11.3

      \[\leadsto 0.5 \cdot \left(\left(y + \frac{x}{\color{blue}{y \cdot \frac{1}{x}}}\right) - \frac{{z}^{2}}{y}\right)\]
    9. Applied associate-/r*11.3

      \[\leadsto 0.5 \cdot \left(\left(y + \color{blue}{\frac{\frac{x}{y}}{\frac{1}{x}}}\right) - \frac{{z}^{2}}{y}\right)\]

    if -1.3369798884979556e154 < x < 9.96878875477082418e153

    1. Initial program 24.0

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\]
    2. Taylor expanded around 0 7.0

      \[\leadsto \color{blue}{\left(0.5 \cdot y + 0.5 \cdot \frac{{x}^{2}}{y}\right) - 0.5 \cdot \frac{{z}^{2}}{y}}\]
    3. Simplified7.0

      \[\leadsto \color{blue}{0.5 \cdot \left(\left(y + \frac{{x}^{2}}{y}\right) - \frac{{z}^{2}}{y}\right)}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity7.0

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

      \[\leadsto 0.5 \cdot \left(\left(y + \frac{{x}^{2}}{y}\right) - \frac{{\color{blue}{\left(\sqrt{z} \cdot \sqrt{z}\right)}}^{2}}{1 \cdot y}\right)\]
    7. Applied unpow-prod-down35.2

      \[\leadsto 0.5 \cdot \left(\left(y + \frac{{x}^{2}}{y}\right) - \frac{\color{blue}{{\left(\sqrt{z}\right)}^{2} \cdot {\left(\sqrt{z}\right)}^{2}}}{1 \cdot y}\right)\]
    8. Applied times-frac32.0

      \[\leadsto 0.5 \cdot \left(\left(y + \frac{{x}^{2}}{y}\right) - \color{blue}{\frac{{\left(\sqrt{z}\right)}^{2}}{1} \cdot \frac{{\left(\sqrt{z}\right)}^{2}}{y}}\right)\]
    9. Simplified32.0

      \[\leadsto 0.5 \cdot \left(\left(y + \frac{{x}^{2}}{y}\right) - \color{blue}{z} \cdot \frac{{\left(\sqrt{z}\right)}^{2}}{y}\right)\]
    10. Simplified0.7

      \[\leadsto 0.5 \cdot \left(\left(y + \frac{{x}^{2}}{y}\right) - z \cdot \color{blue}{\frac{z}{y}}\right)\]

    if 9.96878875477082418e153 < x

    1. Initial program 63.8

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\]
    2. Taylor expanded around 0 63.5

      \[\leadsto \color{blue}{\left(0.5 \cdot y + 0.5 \cdot \frac{{x}^{2}}{y}\right) - 0.5 \cdot \frac{{z}^{2}}{y}}\]
    3. Simplified63.5

      \[\leadsto \color{blue}{0.5 \cdot \left(\left(y + \frac{{x}^{2}}{y}\right) - \frac{{z}^{2}}{y}\right)}\]
    4. Using strategy rm
    5. Applied unpow263.5

      \[\leadsto 0.5 \cdot \left(\left(y + \frac{\color{blue}{x \cdot x}}{y}\right) - \frac{{z}^{2}}{y}\right)\]
    6. Applied associate-/l*11.2

      \[\leadsto 0.5 \cdot \left(\left(y + \color{blue}{\frac{x}{\frac{y}{x}}}\right) - \frac{{z}^{2}}{y}\right)\]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.3369798884979556 \cdot 10^{154}:\\ \;\;\;\;0.5 \cdot \left(\left(y + \frac{\frac{x}{y}}{\frac{1}{x}}\right) - \frac{{z}^{2}}{y}\right)\\ \mathbf{elif}\;x \le 9.96878875477082418 \cdot 10^{153}:\\ \;\;\;\;0.5 \cdot \left(\left(y + \frac{{x}^{2}}{y}\right) - z \cdot \frac{z}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\left(y + \frac{x}{\frac{y}{x}}\right) - \frac{{z}^{2}}{y}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020162 
(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.0)))