Average Error: 6.4 → 2.1
Time: 3.5s
Precision: binary64
\[x + \frac{\left(y - x\right) \cdot z}{t}\]
\[\begin{array}{l} \mathbf{if}\;t \leq -1.6504017164332703 \cdot 10^{+82}:\\ \;\;\;\;\left(x + \frac{y}{\frac{t}{z}}\right) - x \cdot \frac{z}{t}\\ \mathbf{elif}\;t \leq 4.6167735875353816 \cdot 10^{-91}:\\ \;\;\;\;x + \left(z \cdot \left(y - x\right)\right) \cdot \frac{1}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{y - x}{t}}{\frac{1}{z}}\\ \end{array}\]
x + \frac{\left(y - x\right) \cdot z}{t}
\begin{array}{l}
\mathbf{if}\;t \leq -1.6504017164332703 \cdot 10^{+82}:\\
\;\;\;\;\left(x + \frac{y}{\frac{t}{z}}\right) - x \cdot \frac{z}{t}\\

\mathbf{elif}\;t \leq 4.6167735875353816 \cdot 10^{-91}:\\
\;\;\;\;x + \left(z \cdot \left(y - x\right)\right) \cdot \frac{1}{t}\\

\mathbf{else}:\\
\;\;\;\;x + \frac{\frac{y - x}{t}}{\frac{1}{z}}\\

\end{array}
(FPCore (x y z t) :precision binary64 (+ x (/ (* (- y x) z) t)))
(FPCore (x y z t)
 :precision binary64
 (if (<= t -1.6504017164332703e+82)
   (- (+ x (/ y (/ t z))) (* x (/ z t)))
   (if (<= t 4.6167735875353816e-91)
     (+ x (* (* z (- y x)) (/ 1.0 t)))
     (+ x (/ (/ (- y x) t) (/ 1.0 z))))))
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 tmp;
	if (t <= -1.6504017164332703e+82) {
		tmp = (x + (y / (t / z))) - (x * (z / t));
	} else if (t <= 4.6167735875353816e-91) {
		tmp = x + ((z * (y - x)) * (1.0 / t));
	} else {
		tmp = x + (((y - x) / t) / (1.0 / z));
	}
	return tmp;
}

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.4
Target1.9
Herbie2.1
\[\begin{array}{l} \mathbf{if}\;x < -9.025511195533005 \cdot 10^{-135}:\\ \;\;\;\;x - \frac{z}{t} \cdot \left(x - y\right)\\ \mathbf{elif}\;x < 4.275032163700715 \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 t < -1.65040171643327031e82

    1. Initial program 11.3

      \[x + \frac{\left(y - x\right) \cdot z}{t}\]
    2. Using strategy rm
    3. Applied associate-/l*_binary641.5

      \[\leadsto x + \color{blue}{\frac{y - x}{\frac{t}{z}}}\]
    4. Using strategy rm
    5. Applied div-sub_binary641.5

      \[\leadsto x + \color{blue}{\left(\frac{y}{\frac{t}{z}} - \frac{x}{\frac{t}{z}}\right)}\]
    6. Applied associate-+r-_binary641.5

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

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

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

    if -1.65040171643327031e82 < t < 4.6167735875353816e-91

    1. Initial program 2.6

      \[x + \frac{\left(y - x\right) \cdot z}{t}\]
    2. Using strategy rm
    3. Applied div-inv_binary642.7

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

    if 4.6167735875353816e-91 < t

    1. Initial program 7.3

      \[x + \frac{\left(y - x\right) \cdot z}{t}\]
    2. Using strategy rm
    3. Applied associate-/l*_binary641.2

      \[\leadsto x + \color{blue}{\frac{y - x}{\frac{t}{z}}}\]
    4. Using strategy rm
    5. Applied div-inv_binary641.2

      \[\leadsto x + \frac{y - x}{\color{blue}{t \cdot \frac{1}{z}}}\]
    6. Applied associate-/r*_binary641.9

      \[\leadsto x + \color{blue}{\frac{\frac{y - x}{t}}{\frac{1}{z}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1.6504017164332703 \cdot 10^{+82}:\\ \;\;\;\;\left(x + \frac{y}{\frac{t}{z}}\right) - x \cdot \frac{z}{t}\\ \mathbf{elif}\;t \leq 4.6167735875353816 \cdot 10^{-91}:\\ \;\;\;\;x + \left(z \cdot \left(y - x\right)\right) \cdot \frac{1}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\frac{y - x}{t}}{\frac{1}{z}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020219 
(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)))