Average Error: 6.5 → 1.5
Time: 2.6s
Precision: 64
\[x + \frac{y \cdot \left(z - x\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;t \le -8.7531850924869805 \cdot 10^{-259}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)\\ \mathbf{elif}\;t \le 59621164056.8936081:\\ \;\;\;\;x + \frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right) - \frac{x}{\frac{t}{y}}\\ \end{array}\]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
\mathbf{if}\;t \le -8.7531850924869805 \cdot 10^{-259}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right) - \frac{x}{\frac{t}{y}}\\

\end{array}
double code(double x, double y, double z, double t) {
	return ((double) (x + ((double) (((double) (y * ((double) (z - x)))) / t))));
}
double code(double x, double y, double z, double t) {
	double VAR;
	if ((t <= -8.75318509248698e-259)) {
		VAR = ((double) fma(((double) (y / t)), ((double) (z - x)), x));
	} else {
		double VAR_1;
		if ((t <= 59621164056.89361)) {
			VAR_1 = ((double) (x + ((double) (((double) (y * ((double) (z - x)))) / t))));
		} else {
			VAR_1 = ((double) (((double) fma(((double) (z / t)), y, x)) - ((double) (x / ((double) (t / y))))));
		}
		VAR = VAR_1;
	}
	return VAR;
}

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.5
Target1.9
Herbie1.5
\[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 < -8.75318509248698e-259

    1. Initial program 6.4

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

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

    if -8.75318509248698e-259 < t < 59621164056.89361

    1. Initial program 2.1

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

    if 59621164056.89361 < t

    1. Initial program 10.0

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

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

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

      \[\leadsto x + \color{blue}{\left(\frac{z}{\frac{t}{y}} - \frac{x}{\frac{t}{y}}\right)}\]
    7. Applied associate-+r-1.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -8.7531850924869805 \cdot 10^{-259}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)\\ \mathbf{elif}\;t \le 59621164056.8936081:\\ \;\;\;\;x + \frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right) - \frac{x}{\frac{t}{y}}\\ \end{array}\]

Reproduce

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