Average Error: 6.9 → 2.1
Time: 2.8s
Precision: binary64
\[x + \frac{y \cdot \left(z - x\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;x \leq 2.2492153083265635 \cdot 10^{-306}:\\ \;\;\;\;x + \frac{\frac{y}{t}}{\frac{1}{z - x}}\\ \mathbf{elif}\;x \leq 5.738594216140986 \cdot 10^{-14}:\\ \;\;\;\;x + \frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{t} \cdot \left(z - x\right)\\ \end{array}\]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
\mathbf{if}\;x \leq 2.2492153083265635 \cdot 10^{-306}:\\
\;\;\;\;x + \frac{\frac{y}{t}}{\frac{1}{z - x}}\\

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

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

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

Original6.9
Target2.0
Herbie2.1
\[x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right)\]

Derivation

  1. Split input into 3 regimes
  2. if x < 2.24921530832656348e-306

    1. Initial program 6.9

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

      \[\leadsto x + \color{blue}{\frac{y}{\frac{t}{z - x}}}\]
    4. Using strategy rm
    5. Applied div-inv_binary646.4

      \[\leadsto x + \frac{y}{\color{blue}{t \cdot \frac{1}{z - x}}}\]
    6. Applied associate-/r*_binary642.0

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

    if 2.24921530832656348e-306 < x < 5.7385942161409859e-14

    1. Initial program 4.2

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

    if 5.7385942161409859e-14 < x

    1. Initial program 9.6

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

      \[\leadsto x + \color{blue}{\frac{y}{\frac{t}{z - x}}}\]
    4. Using strategy rm
    5. Applied associate-/r/_binary640.1

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

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

Reproduce

herbie shell --seed 2020224 
(FPCore (x y z t)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D"
  :precision binary64

  :herbie-target
  (- x (+ (* x (/ y t)) (* (- z) (/ y t))))

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