Average Error: 6.7 → 2.1
Time: 3.9s
Precision: 64
\[x + \frac{y \cdot \left(z - x\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;x \le 1.45494683705326644 \cdot 10^{-300} \lor \neg \left(x \le 5.69376695784929436 \cdot 10^{-84}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{z - x}{t} + x\\ \end{array}\]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
\mathbf{if}\;x \le 1.45494683705326644 \cdot 10^{-300} \lor \neg \left(x \le 5.69376695784929436 \cdot 10^{-84}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)\\

\mathbf{else}:\\
\;\;\;\;y \cdot \frac{z - x}{t} + 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 <= 1.4549468370532664e-300) || !(x <= 5.693766957849294e-84))) {
		temp = fma((y / t), (z - x), x);
	} else {
		temp = ((y * ((z - x) / t)) + 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.7
Target2.0
Herbie2.1
\[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 < 1.4549468370532664e-300 or 5.693766957849294e-84 < x

    1. Initial program 7.0

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

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

    if 1.4549468370532664e-300 < x < 5.693766957849294e-84

    1. Initial program 5.5

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

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

      \[\leadsto \color{blue}{\frac{y}{t} \cdot \left(z - x\right) + x}\]
    5. Using strategy rm
    6. Applied div-inv4.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 1.45494683705326644 \cdot 10^{-300} \lor \neg \left(x \le 5.69376695784929436 \cdot 10^{-84}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{z - x}{t} + x\\ \end{array}\]

Reproduce

herbie shell --seed 2020056 +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)))