Average Error: 18.5 → 17.8
Time: 17.3s
Precision: 64
\[2.0 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \le 3.324954788338667 \cdot 10^{+189}:\\ \;\;\;\;{\left(\mathsf{fma}\left(y + x, z, y \cdot x\right)\right)}^{\frac{1}{2}} \cdot 2.0\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{y} \cdot \sqrt{x}\right) \cdot 2.0\\ \end{array}\]
2.0 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\begin{array}{l}
\mathbf{if}\;x \le 3.324954788338667 \cdot 10^{+189}:\\
\;\;\;\;{\left(\mathsf{fma}\left(y + x, z, y \cdot x\right)\right)}^{\frac{1}{2}} \cdot 2.0\\

\mathbf{else}:\\
\;\;\;\;\left(\sqrt{y} \cdot \sqrt{x}\right) \cdot 2.0\\

\end{array}
double f(double x, double y, double z) {
        double r32518969 = 2.0;
        double r32518970 = x;
        double r32518971 = y;
        double r32518972 = r32518970 * r32518971;
        double r32518973 = z;
        double r32518974 = r32518970 * r32518973;
        double r32518975 = r32518972 + r32518974;
        double r32518976 = r32518971 * r32518973;
        double r32518977 = r32518975 + r32518976;
        double r32518978 = sqrt(r32518977);
        double r32518979 = r32518969 * r32518978;
        return r32518979;
}

double f(double x, double y, double z) {
        double r32518980 = x;
        double r32518981 = 3.324954788338667e+189;
        bool r32518982 = r32518980 <= r32518981;
        double r32518983 = y;
        double r32518984 = r32518983 + r32518980;
        double r32518985 = z;
        double r32518986 = r32518983 * r32518980;
        double r32518987 = fma(r32518984, r32518985, r32518986);
        double r32518988 = 0.5;
        double r32518989 = pow(r32518987, r32518988);
        double r32518990 = 2.0;
        double r32518991 = r32518989 * r32518990;
        double r32518992 = sqrt(r32518983);
        double r32518993 = sqrt(r32518980);
        double r32518994 = r32518992 * r32518993;
        double r32518995 = r32518994 * r32518990;
        double r32518996 = r32518982 ? r32518991 : r32518995;
        return r32518996;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original18.5
Target18.0
Herbie17.8
\[\begin{array}{l} \mathbf{if}\;z \lt 7.636950090573675 \cdot 10^{+176}:\\ \;\;\;\;2.0 \cdot \sqrt{\left(x + y\right) \cdot z + x \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\frac{1}{4} \cdot \left(\left({y}^{\frac{-3}{4}} \cdot \left({z}^{\frac{-3}{4}} \cdot x\right)\right) \cdot \left(y + z\right)\right) + {z}^{\frac{1}{4}} \cdot {y}^{\frac{1}{4}}\right) \cdot \left(\frac{1}{4} \cdot \left(\left({y}^{\frac{-3}{4}} \cdot \left({z}^{\frac{-3}{4}} \cdot x\right)\right) \cdot \left(y + z\right)\right) + {z}^{\frac{1}{4}} \cdot {y}^{\frac{1}{4}}\right)\right) \cdot 2.0\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if x < 3.324954788338667e+189

    1. Initial program 16.5

      \[2.0 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\]
    2. Simplified16.5

      \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x + y, z, y \cdot x\right)} \cdot 2.0}\]
    3. Using strategy rm
    4. Applied pow1/216.5

      \[\leadsto \color{blue}{{\left(\mathsf{fma}\left(x + y, z, y \cdot x\right)\right)}^{\frac{1}{2}}} \cdot 2.0\]

    if 3.324954788338667e+189 < x

    1. Initial program 38.1

      \[2.0 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\]
    2. Simplified38.1

      \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x + y, z, y \cdot x\right)} \cdot 2.0}\]
    3. Using strategy rm
    4. Applied pow1/238.1

      \[\leadsto \color{blue}{{\left(\mathsf{fma}\left(x + y, z, y \cdot x\right)\right)}^{\frac{1}{2}}} \cdot 2.0\]
    5. Taylor expanded around inf 33.8

      \[\leadsto \color{blue}{e^{\frac{-1}{2} \cdot \left(\log \left(\frac{1}{x}\right) + \log \left(\frac{1}{y}\right)\right)}} \cdot 2.0\]
    6. Simplified30.8

      \[\leadsto \color{blue}{\left(\sqrt{x} \cdot \sqrt{y}\right)} \cdot 2.0\]
  3. Recombined 2 regimes into one program.
  4. Final simplification17.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 3.324954788338667 \cdot 10^{+189}:\\ \;\;\;\;{\left(\mathsf{fma}\left(y + x, z, y \cdot x\right)\right)}^{\frac{1}{2}} \cdot 2.0\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{y} \cdot \sqrt{x}\right) \cdot 2.0\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< z 7.636950090573675e+176) (* 2.0 (sqrt (+ (* (+ x y) z) (* x y)))) (* (* (+ (* 1/4 (* (* (pow y -3/4) (* (pow z -3/4) x)) (+ y z))) (* (pow z 1/4) (pow y 1/4))) (+ (* 1/4 (* (* (pow y -3/4) (* (pow z -3/4) x)) (+ y z))) (* (pow z 1/4) (pow y 1/4)))) 2.0))

  (* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z)))))