Average Error: 16.5 → 9.4
Time: 19.9s
Precision: 64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \le -1.907334337913707925874355176709465231659 \cdot 10^{-66}:\\ \;\;\;\;\mathsf{fma}\left(\left(t - z\right) \cdot \frac{1}{a - t}, y, x + y\right)\\ \mathbf{elif}\;a \le 5.93845824458850190638751899771742793178 \cdot 10^{-214}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \mathbf{elif}\;a \le 3.145583687882106769309382093157043839473 \cdot 10^{-109}:\\ \;\;\;\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\\ \mathbf{elif}\;a \le 1.1069999393996591737359769250128395545 \cdot 10^{-40}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(t - z\right) \cdot \frac{1}{a - t}, y, x + y\right)\\ \end{array}\]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
\mathbf{if}\;a \le -1.907334337913707925874355176709465231659 \cdot 10^{-66}:\\
\;\;\;\;\mathsf{fma}\left(\left(t - z\right) \cdot \frac{1}{a - t}, y, x + y\right)\\

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

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

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(t - z\right) \cdot \frac{1}{a - t}, y, x + y\right)\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r775832 = x;
        double r775833 = y;
        double r775834 = r775832 + r775833;
        double r775835 = z;
        double r775836 = t;
        double r775837 = r775835 - r775836;
        double r775838 = r775837 * r775833;
        double r775839 = a;
        double r775840 = r775839 - r775836;
        double r775841 = r775838 / r775840;
        double r775842 = r775834 - r775841;
        return r775842;
}

double f(double x, double y, double z, double t, double a) {
        double r775843 = a;
        double r775844 = -1.907334337913708e-66;
        bool r775845 = r775843 <= r775844;
        double r775846 = t;
        double r775847 = z;
        double r775848 = r775846 - r775847;
        double r775849 = 1.0;
        double r775850 = r775843 - r775846;
        double r775851 = r775849 / r775850;
        double r775852 = r775848 * r775851;
        double r775853 = y;
        double r775854 = x;
        double r775855 = r775854 + r775853;
        double r775856 = fma(r775852, r775853, r775855);
        double r775857 = 5.938458244588502e-214;
        bool r775858 = r775843 <= r775857;
        double r775859 = r775847 / r775846;
        double r775860 = fma(r775859, r775853, r775854);
        double r775861 = 3.145583687882107e-109;
        bool r775862 = r775843 <= r775861;
        double r775863 = r775847 - r775846;
        double r775864 = r775863 * r775853;
        double r775865 = r775864 / r775850;
        double r775866 = r775855 - r775865;
        double r775867 = 1.1069999393996592e-40;
        bool r775868 = r775843 <= r775867;
        double r775869 = r775868 ? r775860 : r775856;
        double r775870 = r775862 ? r775866 : r775869;
        double r775871 = r775858 ? r775860 : r775870;
        double r775872 = r775845 ? r775856 : r775871;
        return r775872;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original16.5
Target8.3
Herbie9.4
\[\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 3 regimes
  2. if a < -1.907334337913708e-66 or 1.1069999393996592e-40 < a

    1. Initial program 15.1

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

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

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

    if -1.907334337913708e-66 < a < 5.938458244588502e-214 or 3.145583687882107e-109 < a < 1.1069999393996592e-40

    1. Initial program 18.9

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

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

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

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

    if 5.938458244588502e-214 < a < 3.145583687882107e-109

    1. Initial program 19.1

      \[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification9.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -1.907334337913707925874355176709465231659 \cdot 10^{-66}:\\ \;\;\;\;\mathsf{fma}\left(\left(t - z\right) \cdot \frac{1}{a - t}, y, x + y\right)\\ \mathbf{elif}\;a \le 5.93845824458850190638751899771742793178 \cdot 10^{-214}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \mathbf{elif}\;a \le 3.145583687882106769309382093157043839473 \cdot 10^{-109}:\\ \;\;\;\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\\ \mathbf{elif}\;a \le 1.1069999393996591737359769250128395545 \cdot 10^{-40}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(t - z\right) \cdot \frac{1}{a - t}, y, x + y\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019351 +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))))