Average Error: 16.7 → 8.3
Time: 22.4s
Precision: 64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;t \le -1.384317655011651968640328382399140234507 \cdot 10^{125}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \mathbf{elif}\;t \le 1.033502621996504461309739448189431813585 \cdot 10^{135}:\\ \;\;\;\;y + \left(\frac{y}{\frac{a - t}{t - z}} + x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \end{array}\]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
\mathbf{if}\;t \le -1.384317655011651968640328382399140234507 \cdot 10^{125}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r35019794 = x;
        double r35019795 = y;
        double r35019796 = r35019794 + r35019795;
        double r35019797 = z;
        double r35019798 = t;
        double r35019799 = r35019797 - r35019798;
        double r35019800 = r35019799 * r35019795;
        double r35019801 = a;
        double r35019802 = r35019801 - r35019798;
        double r35019803 = r35019800 / r35019802;
        double r35019804 = r35019796 - r35019803;
        return r35019804;
}

double f(double x, double y, double z, double t, double a) {
        double r35019805 = t;
        double r35019806 = -1.384317655011652e+125;
        bool r35019807 = r35019805 <= r35019806;
        double r35019808 = z;
        double r35019809 = r35019808 / r35019805;
        double r35019810 = y;
        double r35019811 = x;
        double r35019812 = fma(r35019809, r35019810, r35019811);
        double r35019813 = 1.0335026219965045e+135;
        bool r35019814 = r35019805 <= r35019813;
        double r35019815 = a;
        double r35019816 = r35019815 - r35019805;
        double r35019817 = r35019805 - r35019808;
        double r35019818 = r35019816 / r35019817;
        double r35019819 = r35019810 / r35019818;
        double r35019820 = r35019819 + r35019811;
        double r35019821 = r35019810 + r35019820;
        double r35019822 = r35019814 ? r35019821 : r35019812;
        double r35019823 = r35019807 ? r35019812 : r35019822;
        return r35019823;
}

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.6
Herbie8.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 t < -1.384317655011652e+125 or 1.0335026219965045e+135 < t

    1. Initial program 31.6

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

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

      \[\leadsto \color{blue}{\frac{z \cdot y}{t} + x}\]
    4. Simplified11.6

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z}{t}, y, x\right)}\]

    if -1.384317655011652e+125 < t < 1.0335026219965045e+135

    1. Initial program 9.8

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

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

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

      \[\leadsto y + \mathsf{fma}\left(\frac{1}{\color{blue}{\left(a - t\right) \cdot \frac{1}{t - z}}}, y, x\right)\]
    7. Using strategy rm
    8. Applied fma-udef7.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -1.384317655011651968640328382399140234507 \cdot 10^{125}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \mathbf{elif}\;t \le 1.033502621996504461309739448189431813585 \cdot 10^{135}:\\ \;\;\;\;y + \left(\frac{y}{\frac{a - t}{t - z}} + x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019174 +o rules:numerics
(FPCore (x y z t a)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTick from plot-0.2.3.4, B"

  :herbie-target
  (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) -1.3664970889390727e-07) (- (+ y x) (* (* (- z t) (/ 1.0 (- 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.0 (- a t))) y))))

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