Average Error: 2.2 → 2.3
Time: 5.2s
Precision: binary64
\[\frac{x - y}{z - y} \cdot t\]
\[\begin{array}{l} \mathbf{if}\;y \le -6.331642673845817 \cdot 10^{-16}:\\ \;\;\;\;\frac{1}{\frac{z - y}{x - y}} \cdot t\\ \mathbf{elif}\;y \le 1.20705658518626352 \cdot 10^{-250}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{t}{z - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{\frac{z - y}{x - y}}\\ \end{array}\]
\frac{x - y}{z - y} \cdot t
\begin{array}{l}
\mathbf{if}\;y \le -6.331642673845817 \cdot 10^{-16}:\\
\;\;\;\;\frac{1}{\frac{z - y}{x - y}} \cdot t\\

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

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

\end{array}
double code(double x, double y, double z, double t) {
	return ((double) (((double) (((double) (x - y)) / ((double) (z - y)))) * t));
}
double code(double x, double y, double z, double t) {
	double VAR;
	if ((y <= -6.331642673845817e-16)) {
		VAR = ((double) (((double) (1.0 / ((double) (((double) (z - y)) / ((double) (x - y)))))) * t));
	} else {
		double VAR_1;
		if ((y <= 1.2070565851862635e-250)) {
			VAR_1 = ((double) (((double) (x - y)) * ((double) (t / ((double) (z - y))))));
		} else {
			VAR_1 = ((double) (t / ((double) (((double) (z - y)) / ((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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.2
Target2.2
Herbie2.3
\[\frac{t}{\frac{z - y}{x - y}}\]

Derivation

  1. Split input into 3 regimes
  2. if y < -6.331642673845817e-16

    1. Initial program 0.1

      \[\frac{x - y}{z - y} \cdot t\]
    2. Using strategy rm
    3. Applied clear-num0.2

      \[\leadsto \color{blue}{\frac{1}{\frac{z - y}{x - y}}} \cdot t\]

    if -6.331642673845817e-16 < y < 1.20705658518626352e-250

    1. Initial program 5.5

      \[\frac{x - y}{z - y} \cdot t\]
    2. Using strategy rm
    3. Applied div-inv5.6

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

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

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

    if 1.20705658518626352e-250 < y

    1. Initial program 1.7

      \[\frac{x - y}{z - y} \cdot t\]
    2. Using strategy rm
    3. Applied clear-num1.9

      \[\leadsto \color{blue}{\frac{1}{\frac{z - y}{x - y}}} \cdot t\]
    4. Using strategy rm
    5. Applied associate-*l/1.7

      \[\leadsto \color{blue}{\frac{1 \cdot t}{\frac{z - y}{x - y}}}\]
    6. Simplified1.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -6.331642673845817 \cdot 10^{-16}:\\ \;\;\;\;\frac{1}{\frac{z - y}{x - y}} \cdot t\\ \mathbf{elif}\;y \le 1.20705658518626352 \cdot 10^{-250}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{t}{z - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{\frac{z - y}{x - y}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020171 
(FPCore (x y z t)
  :name "Numeric.Signal.Multichannel:$cput from hsignal-0.2.7.1"
  :precision binary64

  :herbie-target
  (/ t (/ (- z y) (- x y)))

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