Average Error: 24.8 → 0.9
Time: 13.4s
Precision: 64
\[x \cdot \sqrt{y \cdot y - z \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \le -1.650359340362325641012254610154623215362 \cdot 10^{-234}:\\ \;\;\;\;-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 -1.650359340362325641012254610154623215362 \cdot 10^{-234}:\\
\;\;\;\;-x \cdot y\\

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

\end{array}
double f(double x, double y, double z) {
        double r434836 = x;
        double r434837 = y;
        double r434838 = r434837 * r434837;
        double r434839 = z;
        double r434840 = r434839 * r434839;
        double r434841 = r434838 - r434840;
        double r434842 = sqrt(r434841);
        double r434843 = r434836 * r434842;
        return r434843;
}

double f(double x, double y, double __attribute__((unused)) z) {
        double r434844 = y;
        double r434845 = -1.6503593403623256e-234;
        bool r434846 = r434844 <= r434845;
        double r434847 = x;
        double r434848 = r434847 * r434844;
        double r434849 = -r434848;
        double r434850 = r434846 ? r434849 : r434848;
        return r434850;
}

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.8
Target0.6
Herbie0.9
\[\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 < -1.6503593403623256e-234

    1. Initial program 24.9

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

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

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

    if -1.6503593403623256e-234 < y

    1. Initial program 24.7

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

      \[\leadsto \color{blue}{x \cdot y}\]
    3. Simplified1.4

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

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

Reproduce

herbie shell --seed 2019179 +o rules:numerics
(FPCore (x y z)
  :name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, B"

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

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