Average Error: 25.0 → 0.7
Time: 23.7s
Precision: 64
\[x \cdot \sqrt{y \cdot y - z \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \le -2.794570820839950878036101099737855872471 \cdot 10^{-243}:\\ \;\;\;\;-x \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array}\]
x \cdot \sqrt{y \cdot y - z \cdot z}
\begin{array}{l}
\mathbf{if}\;y \le -2.794570820839950878036101099737855872471 \cdot 10^{-243}:\\
\;\;\;\;-x \cdot y\\

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

\end{array}
double f(double x, double y, double z) {
        double r381159 = x;
        double r381160 = y;
        double r381161 = r381160 * r381160;
        double r381162 = z;
        double r381163 = r381162 * r381162;
        double r381164 = r381161 - r381163;
        double r381165 = sqrt(r381164);
        double r381166 = r381159 * r381165;
        return r381166;
}

double f(double x, double y, double __attribute__((unused)) z) {
        double r381167 = y;
        double r381168 = -2.794570820839951e-243;
        bool r381169 = r381167 <= r381168;
        double r381170 = x;
        double r381171 = r381170 * r381167;
        double r381172 = -r381171;
        double r381173 = r381169 ? r381172 : r381171;
        return r381173;
}

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.0
Target0.6
Herbie0.7
\[\begin{array}{l} \mathbf{if}\;y \lt 2.581609648825169508994985860317034908583 \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 < -2.794570820839951e-243

    1. Initial program 25.4

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

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

      \[\leadsto \color{blue}{-x \cdot y}\]

    if -2.794570820839951e-243 < y

    1. Initial program 24.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -2.794570820839950878036101099737855872471 \cdot 10^{-243}:\\ \;\;\;\;-x \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array}\]

Reproduce

herbie shell --seed 2019306 +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.58160964882516951e-278) (- (* x y)) (* x (* (sqrt (+ y z)) (sqrt (- y z)))))

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