Average Error: 2.0 → 1.8
Time: 3.2s
Precision: binary64
\[\frac{x}{y} \cdot \left(z - t\right) + t\]
\[\begin{array}{l} \mathbf{if}\;y \leq -2.4028729871282748 \cdot 10^{-228}:\\ \;\;\;\;\frac{x}{y} \cdot z + t \cdot \left(1 - \frac{x}{y}\right)\\ \mathbf{elif}\;y \leq 44607863226960.26:\\ \;\;\;\;t + \frac{x \cdot \left(z - t\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;t + x \cdot \frac{z - t}{y}\\ \end{array}\]
\frac{x}{y} \cdot \left(z - t\right) + t
\begin{array}{l}
\mathbf{if}\;y \leq -2.4028729871282748 \cdot 10^{-228}:\\
\;\;\;\;\frac{x}{y} \cdot z + t \cdot \left(1 - \frac{x}{y}\right)\\

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

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

\end{array}
(FPCore (x y z t) :precision binary64 (+ (* (/ x y) (- z t)) t))
(FPCore (x y z t)
 :precision binary64
 (if (<= y -2.4028729871282748e-228)
   (+ (* (/ x y) z) (* t (- 1.0 (/ x y))))
   (if (<= y 44607863226960.26)
     (+ t (/ (* x (- z t)) y))
     (+ t (* x (/ (- z t) y))))))
double code(double x, double y, double z, double t) {
	return ((double) (((double) ((x / y) * ((double) (z - t)))) + t));
}
double code(double x, double y, double z, double t) {
	double tmp;
	if ((y <= -2.4028729871282748e-228)) {
		tmp = ((double) (((double) ((x / y) * z)) + ((double) (t * ((double) (1.0 - (x / y)))))));
	} else {
		double tmp_1;
		if ((y <= 44607863226960.26)) {
			tmp_1 = ((double) (t + (((double) (x * ((double) (z - t)))) / y)));
		} else {
			tmp_1 = ((double) (t + ((double) (x * (((double) (z - t)) / y)))));
		}
		tmp = tmp_1;
	}
	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

Original2.0
Target2.3
Herbie1.8
\[\begin{array}{l} \mathbf{if}\;z < 2.759456554562692 \cdot 10^{-282}:\\ \;\;\;\;\frac{x}{y} \cdot \left(z - t\right) + t\\ \mathbf{elif}\;z < 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 y < -2.4028729871282748e-228

    1. Initial program 1.7

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

      \[\leadsto \frac{x}{y} \cdot \color{blue}{\left(z + \left(-t\right)\right)} + t\]
    4. Applied distribute-lft-in_binary641.7

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

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

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

      \[\leadsto \frac{x}{y} \cdot z + \left(\color{blue}{1 \cdot t} - \frac{x}{y} \cdot t\right)\]
    9. Applied distribute-rgt-out--_binary641.7

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

    if -2.4028729871282748e-228 < y < 44607863226960.2578

    1. Initial program 3.5

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

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

    if 44607863226960.2578 < y

    1. Initial program 1.3

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

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

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

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

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

Reproduce

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