Average Error: 18.6 → 18.0
Time: 12.9s
Precision: 64
\[2.0 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \le -4.514491771534835 \cdot 10^{+149}:\\ \;\;\;\;2.0 \cdot e^{\left(\log \left(\frac{-1}{y}\right) + \log \left(\frac{-1}{x}\right)\right) \cdot \frac{-1}{2}}\\ \mathbf{elif}\;y \le 6.205059017438556 \cdot 10^{+148}:\\ \;\;\;\;{\left(\mathsf{fma}\left(x + y, z, x \cdot y\right)\right)}^{\frac{1}{2}} \cdot 2.0\\ \mathbf{else}:\\ \;\;\;\;e^{\mathsf{fma}\left(\log y, \frac{1}{2}, \log x \cdot \frac{1}{2}\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}\;y \le -4.514491771534835 \cdot 10^{+149}:\\
\;\;\;\;2.0 \cdot e^{\left(\log \left(\frac{-1}{y}\right) + \log \left(\frac{-1}{x}\right)\right) \cdot \frac{-1}{2}}\\

\mathbf{elif}\;y \le 6.205059017438556 \cdot 10^{+148}:\\
\;\;\;\;{\left(\mathsf{fma}\left(x + y, z, x \cdot y\right)\right)}^{\frac{1}{2}} \cdot 2.0\\

\mathbf{else}:\\
\;\;\;\;e^{\mathsf{fma}\left(\log y, \frac{1}{2}, \log x \cdot \frac{1}{2}\right)} \cdot 2.0\\

\end{array}
double f(double x, double y, double z) {
        double r13261834 = 2.0;
        double r13261835 = x;
        double r13261836 = y;
        double r13261837 = r13261835 * r13261836;
        double r13261838 = z;
        double r13261839 = r13261835 * r13261838;
        double r13261840 = r13261837 + r13261839;
        double r13261841 = r13261836 * r13261838;
        double r13261842 = r13261840 + r13261841;
        double r13261843 = sqrt(r13261842);
        double r13261844 = r13261834 * r13261843;
        return r13261844;
}

double f(double x, double y, double z) {
        double r13261845 = y;
        double r13261846 = -4.514491771534835e+149;
        bool r13261847 = r13261845 <= r13261846;
        double r13261848 = 2.0;
        double r13261849 = -1.0;
        double r13261850 = r13261849 / r13261845;
        double r13261851 = log(r13261850);
        double r13261852 = x;
        double r13261853 = r13261849 / r13261852;
        double r13261854 = log(r13261853);
        double r13261855 = r13261851 + r13261854;
        double r13261856 = -0.5;
        double r13261857 = r13261855 * r13261856;
        double r13261858 = exp(r13261857);
        double r13261859 = r13261848 * r13261858;
        double r13261860 = 6.205059017438556e+148;
        bool r13261861 = r13261845 <= r13261860;
        double r13261862 = r13261852 + r13261845;
        double r13261863 = z;
        double r13261864 = r13261852 * r13261845;
        double r13261865 = fma(r13261862, r13261863, r13261864);
        double r13261866 = 0.5;
        double r13261867 = pow(r13261865, r13261866);
        double r13261868 = r13261867 * r13261848;
        double r13261869 = log(r13261845);
        double r13261870 = log(r13261852);
        double r13261871 = r13261870 * r13261866;
        double r13261872 = fma(r13261869, r13261866, r13261871);
        double r13261873 = exp(r13261872);
        double r13261874 = r13261873 * r13261848;
        double r13261875 = r13261861 ? r13261868 : r13261874;
        double r13261876 = r13261847 ? r13261859 : r13261875;
        return r13261876;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original18.6
Target18.0
Herbie18.0
\[\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 3 regimes
  2. if y < -4.514491771534835e+149

    1. Initial program 36.6

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

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

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

      \[\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\]

    if -4.514491771534835e+149 < y < 6.205059017438556e+148

    1. Initial program 12.5

      \[2.0 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}\]
    2. Simplified12.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/212.5

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

    if 6.205059017438556e+148 < y

    1. Initial program 36.0

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

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

      \[\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 35.0

      \[\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. Simplified35.0

      \[\leadsto \color{blue}{e^{\mathsf{fma}\left(\log y, \frac{1}{2}, \frac{1}{2} \cdot \log x\right)}} \cdot 2.0\]
  3. Recombined 3 regimes into one program.
  4. Final simplification18.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -4.514491771534835 \cdot 10^{+149}:\\ \;\;\;\;2.0 \cdot e^{\left(\log \left(\frac{-1}{y}\right) + \log \left(\frac{-1}{x}\right)\right) \cdot \frac{-1}{2}}\\ \mathbf{elif}\;y \le 6.205059017438556 \cdot 10^{+148}:\\ \;\;\;\;{\left(\mathsf{fma}\left(x + y, z, x \cdot y\right)\right)}^{\frac{1}{2}} \cdot 2.0\\ \mathbf{else}:\\ \;\;\;\;e^{\mathsf{fma}\left(\log y, \frac{1}{2}, \log x \cdot \frac{1}{2}\right)} \cdot 2.0\\ \end{array}\]

Reproduce

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