Average Error: 2.0 → 2.1
Time: 2.4s
Precision: 64
\[\frac{x - y}{z - y} \cdot t\]
\[\begin{array}{l} \mathbf{if}\;y \le -3.5529422832783068 \cdot 10^{-233}:\\ \;\;\;\;\frac{t}{\frac{z}{x - y} - \frac{y}{x - y}}\\ \mathbf{elif}\;y \le 1.37815582627985086 \cdot 10^{-70}:\\ \;\;\;\;\frac{\left(x - y\right) \cdot t}{z - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - y}{z - y} \cdot t\\ \end{array}\]
\frac{x - y}{z - y} \cdot t
\begin{array}{l}
\mathbf{if}\;y \le -3.5529422832783068 \cdot 10^{-233}:\\
\;\;\;\;\frac{t}{\frac{z}{x - y} - \frac{y}{x - y}}\\

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

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

\end{array}
double code(double x, double y, double z, double t) {
	return (((x - y) / (z - y)) * t);
}
double code(double x, double y, double z, double t) {
	double VAR;
	if ((y <= -3.552942283278307e-233)) {
		VAR = (t / ((z / (x - y)) - (y / (x - y))));
	} else {
		double VAR_1;
		if ((y <= 1.3781558262798509e-70)) {
			VAR_1 = (((x - y) * t) / (z - y));
		} else {
			VAR_1 = (((x - y) / (z - y)) * t);
		}
		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.0
Target2.0
Herbie2.1
\[\frac{t}{\frac{z - y}{x - y}}\]

Derivation

  1. Split input into 3 regimes
  2. if y < -3.552942283278307e-233

    1. Initial program 1.3

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

      \[\leadsto \color{blue}{\frac{1}{\frac{z - y}{x - y}}} \cdot t\]
    4. Applied associate-*l/1.3

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

      \[\leadsto \frac{\color{blue}{t}}{\frac{z - y}{x - y}}\]
    6. Using strategy rm
    7. Applied div-sub1.3

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

    if -3.552942283278307e-233 < y < 1.3781558262798509e-70

    1. Initial program 5.6

      \[\frac{x - y}{z - y} \cdot t\]
    2. Using strategy rm
    3. Applied associate-*l/5.8

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

    if 1.3781558262798509e-70 < y

    1. Initial program 0.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -3.5529422832783068 \cdot 10^{-233}:\\ \;\;\;\;\frac{t}{\frac{z}{x - y} - \frac{y}{x - y}}\\ \mathbf{elif}\;y \le 1.37815582627985086 \cdot 10^{-70}:\\ \;\;\;\;\frac{\left(x - y\right) \cdot t}{z - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - y}{z - y} \cdot t\\ \end{array}\]

Reproduce

herbie shell --seed 2020071 +o rules:numerics
(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))