Average Error: 16.1 → 7.4
Time: 5.7s
Precision: 64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \le -5.6621302881381 \cdot 10^{-188} \lor \neg \left(a \le 6.3541506798732285 \cdot 10^{-69}\right):\\ \;\;\;\;\mathsf{fma}\left(y, \left(t - z\right) \cdot \frac{1}{a - t}, y\right) + x\\ \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}\;a \le -5.6621302881381 \cdot 10^{-188} \lor \neg \left(a \le 6.3541506798732285 \cdot 10^{-69}\right):\\
\;\;\;\;\mathsf{fma}\left(y, \left(t - z\right) \cdot \frac{1}{a - t}, y\right) + x\\

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

\end{array}
double code(double x, double y, double z, double t, double a) {
	return ((double) (((double) (x + y)) - ((double) (((double) (((double) (z - t)) * y)) / ((double) (a - t))))));
}
double code(double x, double y, double z, double t, double a) {
	double VAR;
	if (((a <= -5.6621302881381e-188) || !(a <= 6.354150679873228e-69))) {
		VAR = ((double) (((double) fma(y, ((double) (((double) (t - z)) * ((double) (1.0 / ((double) (a - t)))))), y)) + x));
	} else {
		VAR = ((double) fma(((double) (z / t)), y, x));
	}
	return VAR;
}

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

Original16.1
Target8.1
Herbie7.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 a < -5.6621302881381e-188 or 6.354150679873228e-69 < a

    1. Initial program 14.9

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

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

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

      \[\leadsto \color{blue}{\left(y \cdot \frac{1}{a - t}\right)} \cdot \left(t - z\right) + \left(x + y\right)\]
    7. Applied associate-*l*8.6

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

      \[\leadsto y \cdot \color{blue}{\frac{t - z}{a - t}} + \left(x + y\right)\]
    9. Using strategy rm
    10. Applied +-commutative8.5

      \[\leadsto y \cdot \frac{t - z}{a - t} + \color{blue}{\left(y + x\right)}\]
    11. Applied associate-+r+5.9

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

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

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

    if -5.6621302881381e-188 < a < 6.354150679873228e-69

    1. Initial program 19.3

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

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

      \[\leadsto \color{blue}{\frac{y}{a - t} \cdot \left(t - z\right) + \left(x + y\right)}\]
    5. Using strategy rm
    6. Applied div-inv18.2

      \[\leadsto \color{blue}{\left(y \cdot \frac{1}{a - t}\right)} \cdot \left(t - z\right) + \left(x + y\right)\]
    7. Applied associate-*l*18.3

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

      \[\leadsto y \cdot \color{blue}{\frac{t - z}{a - t}} + \left(x + y\right)\]
    9. Using strategy rm
    10. Applied +-commutative18.3

      \[\leadsto y \cdot \frac{t - z}{a - t} + \color{blue}{\left(y + x\right)}\]
    11. Applied associate-+r+10.9

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

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

      \[\leadsto \color{blue}{\frac{z \cdot y}{t} + x}\]
    14. Simplified10.3

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

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

Reproduce

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