Average Error: 25.3 → 0.9
Time: 1.9s
Precision: 64
\[x \cdot \sqrt{y \cdot y - z \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \le -4.1007788905905145 \cdot 10^{-238}:\\ \;\;\;\;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.1007788905905145 \cdot 10^{-238}:\\
\;\;\;\;x \cdot \left(-1 \cdot y\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r2141008 = x;
        double r2141009 = y;
        double r2141010 = r2141009 * r2141009;
        double r2141011 = z;
        double r2141012 = r2141011 * r2141011;
        double r2141013 = r2141010 - r2141012;
        double r2141014 = sqrt(r2141013);
        double r2141015 = r2141008 * r2141014;
        return r2141015;
}

double f(double x, double y, double __attribute__((unused)) z) {
        double r2141016 = y;
        double r2141017 = -4.1007788905905145e-238;
        bool r2141018 = r2141016 <= r2141017;
        double r2141019 = x;
        double r2141020 = -1.0;
        double r2141021 = r2141020 * r2141016;
        double r2141022 = r2141019 * r2141021;
        double r2141023 = r2141019 * r2141016;
        double r2141024 = r2141018 ? r2141022 : r2141023;
        return r2141024;
}

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.7
Herbie0.9
\[\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.1007788905905145e-238

    1. Initial program 25.5

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

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

    if -4.1007788905905145e-238 < y

    1. Initial program 25.1

      \[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.9

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

Reproduce

herbie shell --seed 2020018 +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)))))