Average Error: 17.1 → 7.3
Time: 5.0s
Precision: 64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \le -4.152528322917232299148352171282481831203 \cdot 10^{-63} \lor \neg \left(a \le 1.757471554465361693971773316158416808742 \cdot 10^{-153}\right):\\ \;\;\;\;x + y \cdot \left(1 - \frac{z - t}{a - t}\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \end{array}\]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
\mathbf{if}\;a \le -4.152528322917232299148352171282481831203 \cdot 10^{-63} \lor \neg \left(a \le 1.757471554465361693971773316158416808742 \cdot 10^{-153}\right):\\
\;\;\;\;x + y \cdot \left(1 - \frac{z - t}{a - t}\right)\\

\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{z}{t}\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r700075 = x;
        double r700076 = y;
        double r700077 = r700075 + r700076;
        double r700078 = z;
        double r700079 = t;
        double r700080 = r700078 - r700079;
        double r700081 = r700080 * r700076;
        double r700082 = a;
        double r700083 = r700082 - r700079;
        double r700084 = r700081 / r700083;
        double r700085 = r700077 - r700084;
        return r700085;
}

double f(double x, double y, double z, double t, double a) {
        double r700086 = a;
        double r700087 = -4.1525283229172323e-63;
        bool r700088 = r700086 <= r700087;
        double r700089 = 1.7574715544653617e-153;
        bool r700090 = r700086 <= r700089;
        double r700091 = !r700090;
        bool r700092 = r700088 || r700091;
        double r700093 = x;
        double r700094 = y;
        double r700095 = 1.0;
        double r700096 = z;
        double r700097 = t;
        double r700098 = r700096 - r700097;
        double r700099 = r700086 - r700097;
        double r700100 = r700098 / r700099;
        double r700101 = r700095 - r700100;
        double r700102 = r700094 * r700101;
        double r700103 = r700093 + r700102;
        double r700104 = r700096 / r700097;
        double r700105 = r700094 * r700104;
        double r700106 = r700093 + r700105;
        double r700107 = r700092 ? r700103 : r700106;
        return r700107;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original17.1
Target9.0
Herbie7.3
\[\begin{array}{l} \mathbf{if}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \lt -1.366497088939072697550672266103566343531 \cdot 10^{-7}:\\ \;\;\;\;\left(y + x\right) - \left(\left(z - t\right) \cdot \frac{1}{a - t}\right) \cdot y\\ \mathbf{elif}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \lt 1.475429344457723334351036314450840066235 \cdot 10^{-239}:\\ \;\;\;\;\frac{y \cdot \left(a - z\right) - x \cdot t}{a - t}\\ \mathbf{else}:\\ \;\;\;\;\left(y + x\right) - \left(\left(z - t\right) \cdot \frac{1}{a - t}\right) \cdot y\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if a < -4.1525283229172323e-63 or 1.7574715544653617e-153 < a

    1. Initial program 15.6

      \[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
    2. Using strategy rm
    3. Applied associate-/l*9.3

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

      \[\leadsto \color{blue}{x + \left(y - \frac{z - t}{\frac{a - t}{y}}\right)}\]
    6. Using strategy rm
    7. Applied associate-/r/5.6

      \[\leadsto x + \left(y - \color{blue}{\frac{z - t}{a - t} \cdot y}\right)\]
    8. Applied *-un-lft-identity5.6

      \[\leadsto x + \left(\color{blue}{1 \cdot y} - \frac{z - t}{a - t} \cdot y\right)\]
    9. Applied distribute-rgt-out--5.6

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

    if -4.1525283229172323e-63 < a < 1.7574715544653617e-153

    1. Initial program 20.6

      \[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
    2. Using strategy rm
    3. Applied associate-/l*19.5

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

      \[\leadsto \color{blue}{x + \left(y - \frac{z - t}{\frac{a - t}{y}}\right)}\]
    6. Using strategy rm
    7. Applied associate-/r/12.0

      \[\leadsto x + \left(y - \color{blue}{\frac{z - t}{a - t} \cdot y}\right)\]
    8. Applied *-un-lft-identity12.0

      \[\leadsto x + \left(\color{blue}{1 \cdot y} - \frac{z - t}{a - t} \cdot y\right)\]
    9. Applied distribute-rgt-out--12.0

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

      \[\leadsto x + y \cdot \color{blue}{\frac{z}{t}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification7.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -4.152528322917232299148352171282481831203 \cdot 10^{-63} \lor \neg \left(a \le 1.757471554465361693971773316158416808742 \cdot 10^{-153}\right):\\ \;\;\;\;x + y \cdot \left(1 - \frac{z - t}{a - t}\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \end{array}\]

Reproduce

herbie shell --seed 2019353 
(FPCore (x y z t a)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTick from plot-0.2.3.4, B"
  :precision binary64

  :herbie-target
  (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) -1.3664970889390727e-07) (- (+ y x) (* (* (- z t) (/ 1 (- a t))) y)) (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) 1.4754293444577233e-239) (/ (- (* y (- a z)) (* x t)) (- a t)) (- (+ y x) (* (* (- z t) (/ 1 (- a t))) y))))

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