Average Error: 2.2 → 2.3
Time: 3.1s
Precision: 64
\[\frac{x}{y} \cdot \left(z - t\right) + t\]
\[\begin{array}{l} \mathbf{if}\;t \le -2.49327115381347073 \cdot 10^{-30}:\\ \;\;\;\;1 \cdot \frac{z - t}{\frac{y}{x}} + t\\ \mathbf{elif}\;t \le 1.97952534099318673 \cdot 10^{-91}:\\ \;\;\;\;x \cdot \frac{z - t}{y} + t\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \left(z - t\right) + t\\ \end{array}\]
\frac{x}{y} \cdot \left(z - t\right) + t
\begin{array}{l}
\mathbf{if}\;t \le -2.49327115381347073 \cdot 10^{-30}:\\
\;\;\;\;1 \cdot \frac{z - t}{\frac{y}{x}} + t\\

\mathbf{elif}\;t \le 1.97952534099318673 \cdot 10^{-91}:\\
\;\;\;\;x \cdot \frac{z - t}{y} + t\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \left(z - t\right) + t\\

\end{array}
double code(double x, double y, double z, double t) {
	return (((x / y) * (z - t)) + t);
}
double code(double x, double y, double z, double t) {
	double temp;
	if ((t <= -2.4932711538134707e-30)) {
		temp = ((1.0 * ((z - t) / (y / x))) + t);
	} else {
		double temp_1;
		if ((t <= 1.9795253409931867e-91)) {
			temp_1 = ((x * ((z - t) / y)) + t);
		} else {
			temp_1 = (((x / y) * (z - t)) + t);
		}
		temp = temp_1;
	}
	return temp;
}

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.4
Herbie2.3
\[\begin{array}{l} \mathbf{if}\;z \lt 2.7594565545626922 \cdot 10^{-282}:\\ \;\;\;\;\frac{x}{y} \cdot \left(z - t\right) + t\\ \mathbf{elif}\;z \lt 2.326994450874436 \cdot 10^{-110}:\\ \;\;\;\;x \cdot \frac{z - t}{y} + t\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \left(z - t\right) + t\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if t < -2.4932711538134707e-30

    1. Initial program 0.1

      \[\frac{x}{y} \cdot \left(z - t\right) + t\]
    2. Using strategy rm
    3. Applied *-un-lft-identity0.1

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

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

      \[\leadsto 1 \cdot \color{blue}{\frac{\left(z - t\right) \cdot x}{y}} + t\]
    6. Using strategy rm
    7. Applied associate-/l*0.1

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

    if -2.4932711538134707e-30 < t < 1.9795253409931867e-91

    1. Initial program 4.7

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

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

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

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

    if 1.9795253409931867e-91 < t

    1. Initial program 0.4

      \[\frac{x}{y} \cdot \left(z - t\right) + t\]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.3

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

Reproduce

herbie shell --seed 2020058 +o rules:numerics
(FPCore (x y z t)
  :name "Numeric.Signal.Multichannel:$cget from hsignal-0.2.7.1"
  :precision binary64

  :herbie-target
  (if (< z 2.759456554562692e-282) (+ (* (/ x y) (- z t)) t) (if (< z 2.326994450874436e-110) (+ (* x (/ (- z t) y)) t) (+ (* (/ x y) (- z t)) t)))

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