Average Error: 26.8 → 23.1
Time: 15.7s
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}\;z \le -3.4890061141715792 \cdot 10^{135}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \le 5.88177900967246461 \cdot 10^{139}:\\ \;\;\;\;\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{x + \left(t + y\right)}\\ \mathbf{else}:\\ \;\;\;\;z\\ \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}\;z \le -3.4890061141715792 \cdot 10^{135}:\\
\;\;\;\;z\\

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

\mathbf{else}:\\
\;\;\;\;z\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r1111211 = x;
        double r1111212 = y;
        double r1111213 = r1111211 + r1111212;
        double r1111214 = z;
        double r1111215 = r1111213 * r1111214;
        double r1111216 = t;
        double r1111217 = r1111216 + r1111212;
        double r1111218 = a;
        double r1111219 = r1111217 * r1111218;
        double r1111220 = r1111215 + r1111219;
        double r1111221 = b;
        double r1111222 = r1111212 * r1111221;
        double r1111223 = r1111220 - r1111222;
        double r1111224 = r1111211 + r1111216;
        double r1111225 = r1111224 + r1111212;
        double r1111226 = r1111223 / r1111225;
        return r1111226;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r1111227 = z;
        double r1111228 = -3.489006114171579e+135;
        bool r1111229 = r1111227 <= r1111228;
        double r1111230 = 5.881779009672465e+139;
        bool r1111231 = r1111227 <= r1111230;
        double r1111232 = x;
        double r1111233 = y;
        double r1111234 = r1111232 + r1111233;
        double r1111235 = r1111234 * r1111227;
        double r1111236 = t;
        double r1111237 = r1111236 + r1111233;
        double r1111238 = a;
        double r1111239 = r1111237 * r1111238;
        double r1111240 = r1111235 + r1111239;
        double r1111241 = b;
        double r1111242 = r1111233 * r1111241;
        double r1111243 = r1111240 - r1111242;
        double r1111244 = r1111232 + r1111237;
        double r1111245 = r1111243 / r1111244;
        double r1111246 = r1111231 ? r1111245 : r1111227;
        double r1111247 = r1111229 ? r1111227 : r1111246;
        return r1111247;
}

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

Original26.8
Target11.4
Herbie23.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.5813117084150564 \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.2285964308315609 \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 2 regimes
  2. if z < -3.489006114171579e+135 or 5.881779009672465e+139 < z

    1. Initial program 41.6

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

      \[\leadsto \color{blue}{\left(\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b\right) \cdot \frac{1}{\left(x + t\right) + y}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity41.7

      \[\leadsto \color{blue}{\left(1 \cdot \left(\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b\right)\right)} \cdot \frac{1}{\left(x + t\right) + y}\]
    6. Applied associate-*l*41.7

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

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

      \[\leadsto 1 \cdot \color{blue}{z}\]

    if -3.489006114171579e+135 < z < 5.881779009672465e+139

    1. Initial program 21.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-inv21.3

      \[\leadsto \color{blue}{\left(\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b\right) \cdot \frac{1}{\left(x + t\right) + y}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity21.3

      \[\leadsto \color{blue}{\left(1 \cdot \left(\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b\right)\right)} \cdot \frac{1}{\left(x + t\right) + y}\]
    6. Applied associate-*l*21.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -3.4890061141715792 \cdot 10^{135}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \le 5.88177900967246461 \cdot 10^{139}:\\ \;\;\;\;\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{x + \left(t + y\right)}\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array}\]

Reproduce

herbie shell --seed 2020042 
(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.5813117084150564e+153) (- (+ z a) b) (if (< (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) 1.2285964308315609e+82) (/ 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)))