Average Error: 27.1 → 22.1
Time: 17.5s
Precision: 64
\[\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -9.90673484959559262475315527380285767272 \cdot 10^{58}:\\ \;\;\;\;z - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;x \le -9.588938000751585214812673723602426983778 \cdot 10^{-101}:\\ \;\;\;\;\frac{\left(x + y\right) \cdot z + \left(t + y\right) \cdot a}{\left(x + t\right) + y} - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;x \le -1.474413654621038689074986787729516757403 \cdot 10^{-151}:\\ \;\;\;\;a - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;x \le -9.136456255023146814378536023232148937859 \cdot 10^{-237}:\\ \;\;\;\;\frac{a \cdot \left(t + y\right) + z \cdot y}{\left(x + t\right) + y} - \frac{y \cdot b}{\left(x + t\right) + y}\\ \mathbf{elif}\;x \le 1.528372702264325649511704853417831441363 \cdot 10^{-258}:\\ \;\;\;\;a - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;x \le 2.554548872028968323270505554471304009148 \cdot 10^{-191}:\\ \;\;\;\;\frac{a \cdot \left(t + y\right) + z \cdot y}{\left(x + t\right) + y} - \frac{y \cdot b}{\left(x + t\right) + y}\\ \mathbf{elif}\;x \le 5.499469799018470160582957919449407613613 \cdot 10^{-102}:\\ \;\;\;\;a - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;x \le 1.909498003160520689501532268761367270434 \cdot 10^{44}:\\ \;\;\;\;\frac{\left(x + y\right) \cdot z + \left(t + y\right) \cdot a}{\left(x + t\right) + y} - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{else}:\\ \;\;\;\;z - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \end{array}\]
\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}
\begin{array}{l}
\mathbf{if}\;x \le -9.90673484959559262475315527380285767272 \cdot 10^{58}:\\
\;\;\;\;z - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\

\mathbf{elif}\;x \le -9.588938000751585214812673723602426983778 \cdot 10^{-101}:\\
\;\;\;\;\frac{\left(x + y\right) \cdot z + \left(t + y\right) \cdot a}{\left(x + t\right) + y} - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\

\mathbf{elif}\;x \le -1.474413654621038689074986787729516757403 \cdot 10^{-151}:\\
\;\;\;\;a - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\

\mathbf{elif}\;x \le -9.136456255023146814378536023232148937859 \cdot 10^{-237}:\\
\;\;\;\;\frac{a \cdot \left(t + y\right) + z \cdot y}{\left(x + t\right) + y} - \frac{y \cdot b}{\left(x + t\right) + y}\\

\mathbf{elif}\;x \le 1.528372702264325649511704853417831441363 \cdot 10^{-258}:\\
\;\;\;\;a - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\

\mathbf{elif}\;x \le 2.554548872028968323270505554471304009148 \cdot 10^{-191}:\\
\;\;\;\;\frac{a \cdot \left(t + y\right) + z \cdot y}{\left(x + t\right) + y} - \frac{y \cdot b}{\left(x + t\right) + y}\\

\mathbf{elif}\;x \le 5.499469799018470160582957919449407613613 \cdot 10^{-102}:\\
\;\;\;\;a - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\

\mathbf{elif}\;x \le 1.909498003160520689501532268761367270434 \cdot 10^{44}:\\
\;\;\;\;\frac{\left(x + y\right) \cdot z + \left(t + y\right) \cdot a}{\left(x + t\right) + y} - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\

\mathbf{else}:\\
\;\;\;\;z - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r586800 = x;
        double r586801 = y;
        double r586802 = r586800 + r586801;
        double r586803 = z;
        double r586804 = r586802 * r586803;
        double r586805 = t;
        double r586806 = r586805 + r586801;
        double r586807 = a;
        double r586808 = r586806 * r586807;
        double r586809 = r586804 + r586808;
        double r586810 = b;
        double r586811 = r586801 * r586810;
        double r586812 = r586809 - r586811;
        double r586813 = r586800 + r586805;
        double r586814 = r586813 + r586801;
        double r586815 = r586812 / r586814;
        return r586815;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r586816 = x;
        double r586817 = -9.906734849595593e+58;
        bool r586818 = r586816 <= r586817;
        double r586819 = z;
        double r586820 = y;
        double r586821 = t;
        double r586822 = r586816 + r586821;
        double r586823 = r586822 + r586820;
        double r586824 = b;
        double r586825 = r586823 / r586824;
        double r586826 = r586820 / r586825;
        double r586827 = r586819 - r586826;
        double r586828 = -9.588938000751585e-101;
        bool r586829 = r586816 <= r586828;
        double r586830 = r586816 + r586820;
        double r586831 = r586830 * r586819;
        double r586832 = r586821 + r586820;
        double r586833 = a;
        double r586834 = r586832 * r586833;
        double r586835 = r586831 + r586834;
        double r586836 = r586835 / r586823;
        double r586837 = r586836 - r586826;
        double r586838 = -1.4744136546210387e-151;
        bool r586839 = r586816 <= r586838;
        double r586840 = r586833 - r586826;
        double r586841 = -9.136456255023147e-237;
        bool r586842 = r586816 <= r586841;
        double r586843 = r586833 * r586832;
        double r586844 = r586819 * r586820;
        double r586845 = r586843 + r586844;
        double r586846 = r586845 / r586823;
        double r586847 = r586820 * r586824;
        double r586848 = r586847 / r586823;
        double r586849 = r586846 - r586848;
        double r586850 = 1.5283727022643256e-258;
        bool r586851 = r586816 <= r586850;
        double r586852 = 2.5545488720289683e-191;
        bool r586853 = r586816 <= r586852;
        double r586854 = 5.49946979901847e-102;
        bool r586855 = r586816 <= r586854;
        double r586856 = 1.9094980031605207e+44;
        bool r586857 = r586816 <= r586856;
        double r586858 = r586857 ? r586837 : r586827;
        double r586859 = r586855 ? r586840 : r586858;
        double r586860 = r586853 ? r586849 : r586859;
        double r586861 = r586851 ? r586840 : r586860;
        double r586862 = r586842 ? r586849 : r586861;
        double r586863 = r586839 ? r586840 : r586862;
        double r586864 = r586829 ? r586837 : r586863;
        double r586865 = r586818 ? r586827 : r586864;
        return r586865;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Bits error versus b

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original27.1
Target11.2
Herbie22.1
\[\begin{array}{l} \mathbf{if}\;\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y} \lt -3.581311708415056427521064305370896655752 \cdot 10^{153}:\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{elif}\;\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y} \lt 1.228596430831560895857110658734089400289 \cdot 10^{82}:\\ \;\;\;\;\frac{1}{\frac{\left(x + t\right) + y}{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}}\\ \mathbf{else}:\\ \;\;\;\;\left(z + a\right) - b\\ \end{array}\]

Derivation

  1. Split input into 4 regimes
  2. if x < -9.906734849595593e+58 or 1.9094980031605207e+44 < x

    1. Initial program 33.1

      \[\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\]
    2. Using strategy rm
    3. Applied div-sub33.1

      \[\leadsto \color{blue}{\frac{\left(x + y\right) \cdot z + \left(t + y\right) \cdot a}{\left(x + t\right) + y} - \frac{y \cdot b}{\left(x + t\right) + y}}\]
    4. Using strategy rm
    5. Applied associate-/l*30.0

      \[\leadsto \frac{\left(x + y\right) \cdot z + \left(t + y\right) \cdot a}{\left(x + t\right) + y} - \color{blue}{\frac{y}{\frac{\left(x + t\right) + y}{b}}}\]
    6. Taylor expanded around inf 23.5

      \[\leadsto \color{blue}{z} - \frac{y}{\frac{\left(x + t\right) + y}{b}}\]

    if -9.906734849595593e+58 < x < -9.588938000751585e-101 or 5.49946979901847e-102 < x < 1.9094980031605207e+44

    1. Initial program 22.5

      \[\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\]
    2. Using strategy rm
    3. Applied div-sub22.5

      \[\leadsto \color{blue}{\frac{\left(x + y\right) \cdot z + \left(t + y\right) \cdot a}{\left(x + t\right) + y} - \frac{y \cdot b}{\left(x + t\right) + y}}\]
    4. Using strategy rm
    5. Applied associate-/l*20.0

      \[\leadsto \frac{\left(x + y\right) \cdot z + \left(t + y\right) \cdot a}{\left(x + t\right) + y} - \color{blue}{\frac{y}{\frac{\left(x + t\right) + y}{b}}}\]

    if -9.588938000751585e-101 < x < -1.4744136546210387e-151 or -9.136456255023147e-237 < x < 1.5283727022643256e-258 or 2.5545488720289683e-191 < x < 5.49946979901847e-102

    1. Initial program 23.2

      \[\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\]
    2. Using strategy rm
    3. Applied div-sub23.2

      \[\leadsto \color{blue}{\frac{\left(x + y\right) \cdot z + \left(t + y\right) \cdot a}{\left(x + t\right) + y} - \frac{y \cdot b}{\left(x + t\right) + y}}\]
    4. Using strategy rm
    5. Applied associate-/l*21.8

      \[\leadsto \frac{\left(x + y\right) \cdot z + \left(t + y\right) \cdot a}{\left(x + t\right) + y} - \color{blue}{\frac{y}{\frac{\left(x + t\right) + y}{b}}}\]
    6. Taylor expanded around 0 20.1

      \[\leadsto \color{blue}{a} - \frac{y}{\frac{\left(x + t\right) + y}{b}}\]

    if -1.4744136546210387e-151 < x < -9.136456255023147e-237 or 1.5283727022643256e-258 < x < 2.5545488720289683e-191

    1. Initial program 22.4

      \[\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\]
    2. Using strategy rm
    3. Applied div-sub22.3

      \[\leadsto \color{blue}{\frac{\left(x + y\right) \cdot z + \left(t + y\right) \cdot a}{\left(x + t\right) + y} - \frac{y \cdot b}{\left(x + t\right) + y}}\]
    4. Taylor expanded around inf 25.0

      \[\leadsto \frac{\color{blue}{z \cdot y + \left(a \cdot t + a \cdot y\right)}}{\left(x + t\right) + y} - \frac{y \cdot b}{\left(x + t\right) + y}\]
    5. Simplified25.0

      \[\leadsto \frac{\color{blue}{a \cdot \left(t + y\right) + z \cdot y}}{\left(x + t\right) + y} - \frac{y \cdot b}{\left(x + t\right) + y}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification22.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -9.90673484959559262475315527380285767272 \cdot 10^{58}:\\ \;\;\;\;z - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;x \le -9.588938000751585214812673723602426983778 \cdot 10^{-101}:\\ \;\;\;\;\frac{\left(x + y\right) \cdot z + \left(t + y\right) \cdot a}{\left(x + t\right) + y} - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;x \le -1.474413654621038689074986787729516757403 \cdot 10^{-151}:\\ \;\;\;\;a - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;x \le -9.136456255023146814378536023232148937859 \cdot 10^{-237}:\\ \;\;\;\;\frac{a \cdot \left(t + y\right) + z \cdot y}{\left(x + t\right) + y} - \frac{y \cdot b}{\left(x + t\right) + y}\\ \mathbf{elif}\;x \le 1.528372702264325649511704853417831441363 \cdot 10^{-258}:\\ \;\;\;\;a - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;x \le 2.554548872028968323270505554471304009148 \cdot 10^{-191}:\\ \;\;\;\;\frac{a \cdot \left(t + y\right) + z \cdot y}{\left(x + t\right) + y} - \frac{y \cdot b}{\left(x + t\right) + y}\\ \mathbf{elif}\;x \le 5.499469799018470160582957919449407613613 \cdot 10^{-102}:\\ \;\;\;\;a - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;x \le 1.909498003160520689501532268761367270434 \cdot 10^{44}:\\ \;\;\;\;\frac{\left(x + y\right) \cdot z + \left(t + y\right) \cdot a}{\left(x + t\right) + y} - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{else}:\\ \;\;\;\;z - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019297 
(FPCore (x y z t a b)
  :name "AI.Clustering.Hierarchical.Internal:ward from clustering-0.2.1"
  :precision binary64

  :herbie-target
  (if (< (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) -3.5813117084150564e153) (- (+ z a) b) (if (< (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) 1.2285964308315609e82) (/ 1 (/ (+ (+ x t) y) (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)))) (- (+ z a) b)))

  (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)))