Average Error: 6.2 → 1.0
Time: 7.3s
Precision: binary64
\[x + \frac{y \cdot \left(z - x\right)}{t} \]
\[\begin{array}{l} t_1 := x + \frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{if}\;t_1 \leq -9.239986894949125 \cdot 10^{+269}:\\ \;\;\;\;x + \left(z - x\right) \cdot \frac{y}{t}\\ \mathbf{elif}\;t_1 \leq 2.053381617302707 \cdot 10^{+261}:\\ \;\;\;\;x + \frac{\mathsf{fma}\left(y, z, y \cdot \left(-x\right)\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z - x}{\frac{t}{y}}\\ \end{array} \]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
t_1 := x + \frac{y \cdot \left(z - x\right)}{t}\\
\mathbf{if}\;t_1 \leq -9.239986894949125 \cdot 10^{+269}:\\
\;\;\;\;x + \left(z - x\right) \cdot \frac{y}{t}\\

\mathbf{elif}\;t_1 \leq 2.053381617302707 \cdot 10^{+261}:\\
\;\;\;\;x + \frac{\mathsf{fma}\left(y, z, y \cdot \left(-x\right)\right)}{t}\\

\mathbf{else}:\\
\;\;\;\;x + \frac{z - x}{\frac{t}{y}}\\


\end{array}
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (+ x (/ (* y (- z x)) t))))
   (if (<= t_1 -9.239986894949125e+269)
     (+ x (* (- z x) (/ y t)))
     (if (<= t_1 2.053381617302707e+261)
       (+ x (/ (fma y z (* y (- x))) t))
       (+ x (/ (- z x) (/ t y)))))))
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 t_1 = x + ((y * (z - x)) / t);
	double tmp;
	if (t_1 <= -9.239986894949125e+269) {
		tmp = x + ((z - x) * (y / t));
	} else if (t_1 <= 2.053381617302707e+261) {
		tmp = x + (fma(y, z, (y * -x)) / t);
	} else {
		tmp = x + ((z - x) / (t / y));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

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

Derivation

  1. Split input into 3 regimes
  2. if (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < -9.23998689494912477e269

    1. Initial program 34.5

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Applied egg-rr2.9

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

    if -9.23998689494912477e269 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < 2.053381617302707e261

    1. Initial program 0.8

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Applied egg-rr0.8

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

    if 2.053381617302707e261 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t))

    1. Initial program 34.2

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Applied egg-rr2.3

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

      \[\leadsto x + \color{blue}{\frac{z - x}{\frac{t}{y}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{y \cdot \left(z - x\right)}{t} \leq -9.239986894949125 \cdot 10^{+269}:\\ \;\;\;\;x + \left(z - x\right) \cdot \frac{y}{t}\\ \mathbf{elif}\;x + \frac{y \cdot \left(z - x\right)}{t} \leq 2.053381617302707 \cdot 10^{+261}:\\ \;\;\;\;x + \frac{\mathsf{fma}\left(y, z, y \cdot \left(-x\right)\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z - x}{\frac{t}{y}}\\ \end{array} \]

Reproduce

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