Average Error: 6.6 → 2.2
Time: 3.3s
Precision: 64
\[x + \frac{y \cdot \left(z - x\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;x \le -4.5398872775483471 \cdot 10^{-26} \lor \neg \left(x \le 4.1248528858694328 \cdot 10^{-151}\right):\\ \;\;\;\;\frac{y}{t} \cdot \left(z - x\right) + x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{t}{z - x}} + x\\ \end{array}\]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
\mathbf{if}\;x \le -4.5398872775483471 \cdot 10^{-26} \lor \neg \left(x \le 4.1248528858694328 \cdot 10^{-151}\right):\\
\;\;\;\;\frac{y}{t} \cdot \left(z - x\right) + x\\

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

\end{array}
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 temp;
	if (((x <= -4.539887277548347e-26) || !(x <= 4.124852885869433e-151))) {
		temp = (((y / t) * (z - x)) + x);
	} else {
		temp = ((y / (t / (z - x))) + x);
	}
	return temp;
}

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.6
Target2.4
Herbie2.2
\[x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right)\]

Derivation

  1. Split input into 2 regimes
  2. if x < -4.539887277548347e-26 or 4.124852885869433e-151 < x

    1. Initial program 7.6

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)}\]
    3. Using strategy rm
    4. Applied fma-udef0.5

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

    if -4.539887277548347e-26 < x < 4.124852885869433e-151

    1. Initial program 5.0

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)}\]
    3. Using strategy rm
    4. Applied fma-udef5.3

      \[\leadsto \color{blue}{\frac{y}{t} \cdot \left(z - x\right) + x}\]
    5. Using strategy rm
    6. Applied associate-*l/5.0

      \[\leadsto \color{blue}{\frac{y \cdot \left(z - x\right)}{t}} + x\]
    7. Using strategy rm
    8. Applied associate-/l*4.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -4.5398872775483471 \cdot 10^{-26} \lor \neg \left(x \le 4.1248528858694328 \cdot 10^{-151}\right):\\ \;\;\;\;\frac{y}{t} \cdot \left(z - x\right) + x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{t}{z - x}} + x\\ \end{array}\]

Reproduce

herbie shell --seed 2020058 +o rules:numerics
(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)))