Average Error: 2.2 → 2.1
Time: 1.4min
Precision: binary64
\[\frac{x}{y} \cdot \left(z - t\right) + t \]
\[t + \frac{z - t}{\frac{y}{x}} \]
\frac{x}{y} \cdot \left(z - t\right) + t
t + \frac{z - t}{\frac{y}{x}}
(FPCore (x y z t) :precision binary64 (+ (* (/ x y) (- z t)) t))
(FPCore (x y z t) :precision binary64 (+ t (/ (- z t) (/ y x))))
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) {
	return t + ((z - t) / (y / x));
}

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.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. Initial program 2.2

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, z - t, t\right)} \]
  3. Taylor expanded in x around 0 6.4

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

    \[\leadsto \color{blue}{{\left(t + \frac{z - t}{\frac{y}{x}}\right)}^{1}} \]
  5. Final simplification2.1

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

Reproduce

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