Average Error: 6.6 → 1.6
Time: 1.9s
Precision: 64
\[x + \frac{y \cdot \left(z - x\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;t \le -8.04065500205821708 \cdot 10^{99}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z - x}{t}, y, x\right)\\ \mathbf{elif}\;t \le 5.3464729145636056 \cdot 10^{-37}:\\ \;\;\;\;\frac{y \cdot \left(z - x\right)}{t} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{z - x}{\frac{t}{y}} + x\\ \end{array}\]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
\mathbf{if}\;t \le -8.04065500205821708 \cdot 10^{99}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - x}{t}, y, x\right)\\

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

\mathbf{else}:\\
\;\;\;\;\frac{z - x}{\frac{t}{y}} + 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 VAR;
	if ((t <= -8.040655002058217e+99)) {
		VAR = fma(((z - x) / t), y, x);
	} else {
		double VAR_1;
		if ((t <= 5.3464729145636056e-37)) {
			VAR_1 = (((y * (z - x)) / t) + x);
		} else {
			VAR_1 = (((z - x) / (t / y)) + x);
		}
		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.6
Target2.0
Herbie1.6
\[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.040655002058217e+99

    1. Initial program 11.8

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{z - x}}{\frac{t}{y}} + x\]
    9. Using strategy rm
    10. Applied associate-/r/1.3

      \[\leadsto \color{blue}{\frac{z - x}{t} \cdot y} + x\]
    11. Applied fma-def1.3

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

    if -8.040655002058217e+99 < t < 5.3464729145636056e-37

    1. Initial program 2.2

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

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

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

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

    if 5.3464729145636056e-37 < t

    1. Initial program 8.6

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

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

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

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

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

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

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

Reproduce

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