Average Error: 6.3 → 1.2
Time: 2.5s
Precision: binary64
\[x + \frac{y \cdot \left(z - x\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;t \leq -3881122855271.2124:\\ \;\;\;\;x + \frac{y}{\frac{t}{z - x}}\\ \mathbf{elif}\;t \leq 6.722683654093909 \cdot 10^{-21}:\\ \;\;\;\;x + \left(y \cdot \left(z - x\right)\right) \cdot \frac{1}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \left(z - x\right) \cdot \frac{y}{t}\\ \end{array}\]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
\mathbf{if}\;t \leq -3881122855271.2124:\\
\;\;\;\;x + \frac{y}{\frac{t}{z - x}}\\

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

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

\end{array}
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
(FPCore (x y z t)
 :precision binary64
 (if (<= t -3881122855271.2124)
   (+ x (/ y (/ t (- z x))))
   (if (<= t 6.722683654093909e-21)
     (+ x (* (* y (- z x)) (/ 1.0 t)))
     (+ x (* (- z x) (/ y t))))))
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 (t <= -3881122855271.2124) {
		tmp = x + (y / (t / (z - x)));
	} else if (t <= 6.722683654093909e-21) {
		tmp = x + ((y * (z - x)) * (1.0 / t));
	} else {
		tmp = x + ((z - x) * (y / t));
	}
	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.3
Target2.1
Herbie1.2
\[x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right)\]

Derivation

  1. Split input into 3 regimes
  2. if t < -3881122855271.2124

    1. Initial program 9.0

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

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

    if -3881122855271.2124 < t < 6.72268365409390877e-21

    1. Initial program 1.7

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

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

    if 6.72268365409390877e-21 < t

    1. Initial program 9.0

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

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

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

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

Reproduce

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