Average Error: 25.3 → 0.8
Time: 2.1s
Precision: 64
\[x \cdot \sqrt{y \cdot y - z \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \le -4.17286658231481322 \cdot 10^{-249}:\\ \;\;\;\;x \cdot \left(-1 \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array}\]
x \cdot \sqrt{y \cdot y - z \cdot z}
\begin{array}{l}
\mathbf{if}\;y \le -4.17286658231481322 \cdot 10^{-249}:\\
\;\;\;\;x \cdot \left(-1 \cdot y\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r737006 = x;
        double r737007 = y;
        double r737008 = r737007 * r737007;
        double r737009 = z;
        double r737010 = r737009 * r737009;
        double r737011 = r737008 - r737010;
        double r737012 = sqrt(r737011);
        double r737013 = r737006 * r737012;
        return r737013;
}

double f(double x, double y, double __attribute__((unused)) z) {
        double r737014 = y;
        double r737015 = -4.172866582314813e-249;
        bool r737016 = r737014 <= r737015;
        double r737017 = x;
        double r737018 = -1.0;
        double r737019 = r737018 * r737014;
        double r737020 = r737017 * r737019;
        double r737021 = r737017 * r737014;
        double r737022 = r737016 ? r737020 : r737021;
        return r737022;
}

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

Original25.3
Target0.6
Herbie0.8
\[\begin{array}{l} \mathbf{if}\;y \lt 2.58160964882516951 \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 < -4.172866582314813e-249

    1. Initial program 24.8

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

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

    if -4.172866582314813e-249 < y

    1. Initial program 25.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -4.17286658231481322 \cdot 10^{-249}:\\ \;\;\;\;x \cdot \left(-1 \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array}\]

Reproduce

herbie shell --seed 2020065 +o rules:numerics
(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)))))