Average Error: 6.6 → 1.6
Time: 2.1s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot z}{t}\]
\[\begin{array}{l} \mathbf{if}\;x + \frac{\left(y - x\right) \cdot z}{t} \le -4.7151087056876726 \cdot 10^{104}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x - x \cdot \frac{z}{t}\right)\\ \mathbf{elif}\;x + \frac{\left(y - x\right) \cdot z}{t} \le 4.2848485185006545 \cdot 10^{293}:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(y - x\right) \cdot \frac{1}{t}, z, x\right)\\ \end{array}\]
x + \frac{\left(y - x\right) \cdot z}{t}
\begin{array}{l}
\mathbf{if}\;x + \frac{\left(y - x\right) \cdot z}{t} \le -4.7151087056876726 \cdot 10^{104}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x - x \cdot \frac{z}{t}\right)\\

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

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

\end{array}
double code(double x, double y, double z, double t) {
	return (x + (((y - x) * z) / t));
}
double code(double x, double y, double z, double t) {
	double VAR;
	if (((x + (((y - x) * z) / t)) <= -4.7151087056876726e+104)) {
		VAR = fma((z / t), y, (x - (x * (z / t))));
	} else {
		double VAR_1;
		if (((x + (((y - x) * z) / t)) <= 4.2848485185006545e+293)) {
			VAR_1 = (x + (((y - x) * z) / t));
		} else {
			VAR_1 = fma(((y - x) * (1.0 / t)), z, x);
		}
		VAR = VAR_1;
	}
	return VAR;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.6
Target1.9
Herbie1.6
\[\begin{array}{l} \mathbf{if}\;x \lt -9.0255111955330046 \cdot 10^{-135}:\\ \;\;\;\;x - \frac{z}{t} \cdot \left(x - y\right)\\ \mathbf{elif}\;x \lt 4.2750321637007147 \cdot 10^{-250}:\\ \;\;\;\;x + \frac{y - x}{t} \cdot z\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if (+ x (/ (* (- y x) z) t)) < -4.7151087056876726e+104

    1. Initial program 12.1

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(y - x\right) \cdot \frac{1}{t}}, z, x\right)\]
    5. Taylor expanded around 0 12.1

      \[\leadsto \color{blue}{\left(\frac{z \cdot y}{t} + x\right) - \frac{x \cdot z}{t}}\]
    6. Simplified9.4

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z}{t}, y, x - \frac{x \cdot z}{t}\right)}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity9.4

      \[\leadsto \mathsf{fma}\left(\frac{z}{t}, y, x - \frac{x \cdot z}{\color{blue}{1 \cdot t}}\right)\]
    9. Applied times-frac2.4

      \[\leadsto \mathsf{fma}\left(\frac{z}{t}, y, x - \color{blue}{\frac{x}{1} \cdot \frac{z}{t}}\right)\]
    10. Simplified2.4

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

    if -4.7151087056876726e+104 < (+ x (/ (* (- y x) z) t)) < 4.2848485185006545e+293

    1. Initial program 1.0

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

    if 4.2848485185006545e+293 < (+ x (/ (* (- y x) z) t))

    1. Initial program 49.6

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

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

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

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

Reproduce

herbie shell --seed 2020102 +o rules:numerics
(FPCore (x y z t)
  :name "Numeric.Histogram:binBounds from Chart-1.5.3"
  :precision binary64

  :herbie-target
  (if (< x -9.025511195533005e-135) (- x (* (/ z t) (- x y))) (if (< x 4.275032163700715e-250) (+ x (* (/ (- y x) t) z)) (+ x (/ (- y x) (/ t z)))))

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