Average Error: 16.7 → 11.4
Time: 4.4s
Precision: 64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;t \le -6.0989892354218388 \cdot 10^{126}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \le 1.26285112774994464 \cdot 10^{220}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{a - t} \cdot y, t - z, x + y\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array}\]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
\mathbf{if}\;t \le -6.0989892354218388 \cdot 10^{126}:\\
\;\;\;\;x\\

\mathbf{elif}\;t \le 1.26285112774994464 \cdot 10^{220}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{a - t} \cdot y, t - z, x + y\right)\\

\mathbf{else}:\\
\;\;\;\;x\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r1105686 = x;
        double r1105687 = y;
        double r1105688 = r1105686 + r1105687;
        double r1105689 = z;
        double r1105690 = t;
        double r1105691 = r1105689 - r1105690;
        double r1105692 = r1105691 * r1105687;
        double r1105693 = a;
        double r1105694 = r1105693 - r1105690;
        double r1105695 = r1105692 / r1105694;
        double r1105696 = r1105688 - r1105695;
        return r1105696;
}

double f(double x, double y, double z, double t, double a) {
        double r1105697 = t;
        double r1105698 = -6.098989235421839e+126;
        bool r1105699 = r1105697 <= r1105698;
        double r1105700 = x;
        double r1105701 = 1.2628511277499446e+220;
        bool r1105702 = r1105697 <= r1105701;
        double r1105703 = 1.0;
        double r1105704 = a;
        double r1105705 = r1105704 - r1105697;
        double r1105706 = r1105703 / r1105705;
        double r1105707 = y;
        double r1105708 = r1105706 * r1105707;
        double r1105709 = z;
        double r1105710 = r1105697 - r1105709;
        double r1105711 = r1105700 + r1105707;
        double r1105712 = fma(r1105708, r1105710, r1105711);
        double r1105713 = r1105702 ? r1105712 : r1105700;
        double r1105714 = r1105699 ? r1105700 : r1105713;
        return r1105714;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original16.7
Target8.5
Herbie11.4
\[\begin{array}{l} \mathbf{if}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \lt -1.3664970889390727 \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.47542934445772333 \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 t < -6.098989235421839e+126 or 1.2628511277499446e+220 < t

    1. Initial program 32.8

      \[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
    2. Simplified24.0

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{a - t}, t - z, x + y\right)}\]
    3. Taylor expanded around 0 21.1

      \[\leadsto \color{blue}{x}\]

    if -6.098989235421839e+126 < t < 1.2628511277499446e+220

    1. Initial program 11.1

      \[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
    2. Simplified8.0

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{a - t}, t - z, x + y\right)}\]
    3. Using strategy rm
    4. Applied clear-num8.1

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{\frac{a - t}{y}}}, t - z, x + y\right)\]
    5. Using strategy rm
    6. Applied div-inv8.1

      \[\leadsto \mathsf{fma}\left(\frac{1}{\color{blue}{\left(a - t\right) \cdot \frac{1}{y}}}, t - z, x + y\right)\]
    7. Applied add-cube-cbrt8.1

      \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\left(a - t\right) \cdot \frac{1}{y}}, t - z, x + y\right)\]
    8. Applied times-frac8.0

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{a - t} \cdot \frac{\sqrt[3]{1}}{\frac{1}{y}}}, t - z, x + y\right)\]
    9. Simplified8.0

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{a - t}} \cdot \frac{\sqrt[3]{1}}{\frac{1}{y}}, t - z, x + y\right)\]
    10. Simplified8.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -6.0989892354218388 \cdot 10^{126}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \le 1.26285112774994464 \cdot 10^{220}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{a - t} \cdot y, t - z, x + y\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array}\]

Reproduce

herbie shell --seed 2020025 +o rules:numerics
(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))))