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 r603417 = x;
        double r603418 = y;
        double r603419 = r603417 + r603418;
        double r603420 = z;
        double r603421 = t;
        double r603422 = r603420 - r603421;
        double r603423 = r603422 * r603418;
        double r603424 = a;
        double r603425 = r603424 - r603421;
        double r603426 = r603423 / r603425;
        double r603427 = r603419 - r603426;
        return r603427;
}

double f(double x, double y, double z, double t, double a) {
        double r603428 = a;
        double r603429 = -4.1525283229172323e-63;
        bool r603430 = r603428 <= r603429;
        double r603431 = 1.7574715544653617e-153;
        bool r603432 = r603428 <= r603431;
        double r603433 = !r603432;
        bool r603434 = r603430 || r603433;
        double r603435 = x;
        double r603436 = y;
        double r603437 = 1.0;
        double r603438 = z;
        double r603439 = t;
        double r603440 = r603438 - r603439;
        double r603441 = r603428 - r603439;
        double r603442 = r603440 / r603441;
        double r603443 = r603437 - r603442;
        double r603444 = r603436 * r603443;
        double r603445 = r603435 + r603444;
        double r603446 = r603438 / r603439;
        double r603447 = r603436 * r603446;
        double r603448 = r603435 + r603447;
        double r603449 = r603434 ? r603445 : r603448;
        return r603449;
}

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))))