Average Error: 1.9 → 2.1
Time: 3.2s
Precision: binary64
\[\frac{x}{y} \cdot \left(z - t\right) + t\]
\[\begin{array}{l} \mathbf{if}\;t \leq 2.033649833623086 \cdot 10^{-302} \lor \neg \left(t \leq 6.1238839299412234 \cdot 10^{-80}\right):\\ \;\;\;\;\frac{x}{y} \cdot z + \left(t - t \cdot \frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;t + \frac{x \cdot \left(z - t\right)}{y}\\ \end{array}\]
\frac{x}{y} \cdot \left(z - t\right) + t
\begin{array}{l}
\mathbf{if}\;t \leq 2.033649833623086 \cdot 10^{-302} \lor \neg \left(t \leq 6.1238839299412234 \cdot 10^{-80}\right):\\
\;\;\;\;\frac{x}{y} \cdot z + \left(t - t \cdot \frac{x}{y}\right)\\

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

\end{array}
(FPCore (x y z t) :precision binary64 (+ (* (/ x y) (- z t)) t))
(FPCore (x y z t)
 :precision binary64
 (if (or (<= t 2.033649833623086e-302) (not (<= t 6.1238839299412234e-80)))
   (+ (* (/ x y) z) (- t (* t (/ x y))))
   (+ t (/ (* x (- z t)) y))))
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 tmp;
	if ((t <= 2.033649833623086e-302) || !(t <= 6.1238839299412234e-80)) {
		tmp = ((x / y) * z) + (t - (t * (x / y)));
	} else {
		tmp = t + ((x * (z - t)) / y);
	}
	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

Original1.9
Target2.2
Herbie2.1
\[\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 2 regimes
  2. if t < 2.0336498336230861e-302 or 6.1238839299412234e-80 < t

    1. Initial program 1.4

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

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

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

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

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

    if 2.0336498336230861e-302 < t < 6.1238839299412234e-80

    1. Initial program 3.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq 2.033649833623086 \cdot 10^{-302} \lor \neg \left(t \leq 6.1238839299412234 \cdot 10^{-80}\right):\\ \;\;\;\;\frac{x}{y} \cdot z + \left(t - t \cdot \frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;t + \frac{x \cdot \left(z - t\right)}{y}\\ \end{array}\]

Reproduce

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