Average Error: 24.4 → 1.2
Time: 3.1s
Precision: binary64
\[x \cdot \sqrt{y \cdot y - z \cdot z} \]
\[\begin{array}{l} \mathbf{if}\;y \leq -3.7165584773607825 \cdot 10^{-270}:\\ \;\;\;\;0.5 \cdot \frac{z \cdot \left(z \cdot x\right)}{y} - y \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
x \cdot \sqrt{y \cdot y - z \cdot z}
\begin{array}{l}
\mathbf{if}\;y \leq -3.7165584773607825 \cdot 10^{-270}:\\
\;\;\;\;0.5 \cdot \frac{z \cdot \left(z \cdot x\right)}{y} - y \cdot x\\

\mathbf{else}:\\
\;\;\;\;y \cdot x\\


\end{array}
(FPCore (x y z) :precision binary64 (* x (sqrt (- (* y y) (* z z)))))
(FPCore (x y z)
 :precision binary64
 (if (<= y -3.7165584773607825e-270)
   (- (* 0.5 (/ (* z (* z x)) y)) (* y x))
   (* y x)))
double code(double x, double y, double z) {
	return x * sqrt((y * y) - (z * z));
}
double code(double x, double y, double z) {
	double tmp;
	if (y <= -3.7165584773607825e-270) {
		tmp = (0.5 * ((z * (z * x)) / y)) - (y * x);
	} else {
		tmp = y * x;
	}
	return tmp;
}

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

Original24.4
Target0.6
Herbie1.2
\[\begin{array}{l} \mathbf{if}\;y < 2.5816096488251695 \cdot 10^{-278}:\\ \;\;\;\;-x \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\sqrt{y + z} \cdot \sqrt{y - z}\right)\\ \end{array} \]

Derivation

  1. Split input into 2 regimes
  2. if y < -3.7165584773607825e-270

    1. Initial program 24.8

      \[x \cdot \sqrt{y \cdot y - z \cdot z} \]
    2. Taylor expanded in y around -inf 3.7

      \[\leadsto \color{blue}{0.5 \cdot \frac{{z}^{2} \cdot x}{y} - y \cdot x} \]
    3. Applied unpow2_binary643.7

      \[\leadsto 0.5 \cdot \frac{\color{blue}{\left(z \cdot z\right)} \cdot x}{y} - y \cdot x \]
    4. Applied associate-*l*_binary641.7

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

    if -3.7165584773607825e-270 < y

    1. Initial program 23.9

      \[x \cdot \sqrt{y \cdot y - z \cdot z} \]
    2. Taylor expanded in y around inf 0.7

      \[\leadsto x \cdot \color{blue}{y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.7165584773607825 \cdot 10^{-270}:\\ \;\;\;\;0.5 \cdot \frac{z \cdot \left(z \cdot x\right)}{y} - y \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]

Reproduce

herbie shell --seed 2021280 
(FPCore (x y z)
  :name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, B"
  :precision binary64

  :herbie-target
  (if (< y 2.5816096488251695e-278) (- (* x y)) (* x (* (sqrt (+ y z)) (sqrt (- y z)))))

  (* x (sqrt (- (* y y) (* z z)))))