Average Error: 16.4 → 9.9
Time: 4.9s
Precision: 64
\[\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \le -7.5452266175570577 \cdot 10^{-233}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \frac{1}{a - t}, t - z, x + y\right)\\ \mathbf{elif}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \le 0.0:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{t - z}{a - t} + \left(x + y\right)\\ \end{array}\]
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\begin{array}{l}
\mathbf{if}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \le -7.5452266175570577 \cdot 10^{-233}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot \frac{1}{a - t}, t - z, x + y\right)\\

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

\mathbf{else}:\\
\;\;\;\;y \cdot \frac{t - z}{a - t} + \left(x + y\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 ((((double) (((double) (x + y)) - ((double) (((double) (((double) (z - t)) * y)) / ((double) (a - t)))))) <= -7.545226617557058e-233)) {
		VAR = ((double) fma(((double) (y * ((double) (1.0 / ((double) (a - t)))))), ((double) (t - z)), ((double) (x + y))));
	} else {
		double VAR_1;
		if ((((double) (((double) (x + y)) - ((double) (((double) (((double) (z - t)) * y)) / ((double) (a - t)))))) <= 0.0)) {
			VAR_1 = x;
		} else {
			VAR_1 = ((double) (((double) (y * ((double) (((double) (t - z)) / ((double) (a - t)))))) + ((double) (x + y))));
		}
		VAR = VAR_1;
	}
	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.4
Target8.1
Herbie9.9
\[\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 3 regimes
  2. if (- (+ x y) (/ (* (- z t) y) (- a t))) < -7.545226617557058e-233

    1. Initial program 12.7

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

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

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

    if -7.545226617557058e-233 < (- (+ x y) (/ (* (- z t) y) (- a t))) < 0.0

    1. Initial program 58.3

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

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

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

    if 0.0 < (- (+ x y) (/ (* (- z t) y) (- a t)))

    1. Initial program 12.4

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

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

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

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

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

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

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

Reproduce

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