Average Error: 2.1 → 2.0
Time: 3.5s
Precision: binary64
\[\frac{x}{y} \cdot \left(z - t\right) + t\]
\[\begin{array}{l} \mathbf{if}\;x \leq 3.388947503812638 \cdot 10^{-96}:\\ \;\;\;\;t + \frac{x}{y} \cdot \left(z - t\right)\\ \mathbf{else}:\\ \;\;\;\;t + x \cdot \left(\frac{z}{y} - \frac{t}{y}\right)\\ \end{array}\]
\frac{x}{y} \cdot \left(z - t\right) + t
\begin{array}{l}
\mathbf{if}\;x \leq 3.388947503812638 \cdot 10^{-96}:\\
\;\;\;\;t + \frac{x}{y} \cdot \left(z - t\right)\\

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

\end{array}
(FPCore (x y z t) :precision binary64 (+ (* (/ x y) (- z t)) t))
(FPCore (x y z t)
 :precision binary64
 (if (<= x 3.388947503812638e-96)
   (+ t (* (/ x y) (- z t)))
   (+ t (* x (- (/ z y) (/ 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 (x <= 3.388947503812638e-96) {
		tmp = t + ((x / y) * (z - t));
	} else {
		tmp = t + (x * ((z / y) - (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

Original2.1
Target2.2
Herbie2.0
\[\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 x < 3.3889475038126382e-96

    1. Initial program 1.9

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

    if 3.3889475038126382e-96 < x

    1. Initial program 2.9

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

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

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

      \[\leadsto x \cdot \color{blue}{\frac{z - t}{y}} + t\]
    6. Using strategy rm
    7. Applied div-sub_binary64_145732.4

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

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

Reproduce

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