Average Error: 17.0 → 11.5
Time: 4.7s
Precision: 64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;t \le -2.2415885201745266 \cdot 10^{195}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \frac{y}{a - t}, t - z, x + y\right)\\ \end{array}\]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
\mathbf{if}\;t \le -2.2415885201745266 \cdot 10^{195}:\\
\;\;\;\;x\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r534645 = x;
        double r534646 = y;
        double r534647 = r534645 + r534646;
        double r534648 = z;
        double r534649 = t;
        double r534650 = r534648 - r534649;
        double r534651 = r534650 * r534646;
        double r534652 = a;
        double r534653 = r534652 - r534649;
        double r534654 = r534651 / r534653;
        double r534655 = r534647 - r534654;
        return r534655;
}

double f(double x, double y, double z, double t, double a) {
        double r534656 = t;
        double r534657 = -2.2415885201745266e+195;
        bool r534658 = r534656 <= r534657;
        double r534659 = x;
        double r534660 = 1.0;
        double r534661 = y;
        double r534662 = a;
        double r534663 = r534662 - r534656;
        double r534664 = r534661 / r534663;
        double r534665 = r534660 * r534664;
        double r534666 = z;
        double r534667 = r534656 - r534666;
        double r534668 = r534659 + r534661;
        double r534669 = fma(r534665, r534667, r534668);
        double r534670 = r534658 ? r534659 : r534669;
        return r534670;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original17.0
Target8.5
Herbie11.5
\[\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 < -2.2415885201745266e+195

    1. Initial program 33.6

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

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

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

    if -2.2415885201745266e+195 < t

    1. Initial program 15.1

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

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

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

      \[\leadsto \mathsf{fma}\left(\frac{1}{\frac{a - t}{\color{blue}{1 \cdot y}}}, t - z, x + y\right)\]
    7. Applied *-un-lft-identity10.8

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

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

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

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

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

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

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

Reproduce

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