Average Error: 6.5 → 1.9
Time: 2.7s
Precision: 64
\[x + \frac{y \cdot \left(z - x\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.414379101552599 \cdot 10^{-259}:\\ \;\;\;\;x + \frac{z - x}{\frac{t}{y}}\\ \mathbf{elif}\;x \le 8.63246856154274614 \cdot 10^{-125}:\\ \;\;\;\;x + \left(y \cdot 1\right) \cdot \frac{z - x}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \left(z - x\right) \cdot \frac{y}{t}\\ \end{array}\]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
\mathbf{if}\;x \le -2.414379101552599 \cdot 10^{-259}:\\
\;\;\;\;x + \frac{z - x}{\frac{t}{y}}\\

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

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

\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 ((x <= -2.414379101552599e-259)) {
		VAR = ((double) (x + ((double) (((double) (z - x)) / ((double) (t / y))))));
	} else {
		double VAR_1;
		if ((x <= 8.632468561542746e-125)) {
			VAR_1 = ((double) (x + ((double) (((double) (y * 1.0)) * ((double) (((double) (z - x)) / t))))));
		} else {
			VAR_1 = ((double) (x + ((double) (((double) (z - x)) * ((double) (y / t))))));
		}
		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.9
\[x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right)\]

Derivation

  1. Split input into 3 regimes
  2. if x < -2.414379101552599e-259

    1. Initial program 6.5

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

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

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

    if -2.414379101552599e-259 < x < 8.632468561542746e-125

    1. Initial program 5.4

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

      \[\leadsto x + \color{blue}{\left(y \cdot \left(z - x\right)\right) \cdot \frac{1}{t}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity5.4

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

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

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

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

    if 8.632468561542746e-125 < x

    1. Initial program 7.2

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

      \[\leadsto x + \frac{y \cdot \left(z - x\right)}{\color{blue}{1 \cdot t}}\]
    4. Applied *-commutative7.2

      \[\leadsto x + \frac{\color{blue}{\left(z - x\right) \cdot y}}{1 \cdot t}\]
    5. Applied times-frac0.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.414379101552599 \cdot 10^{-259}:\\ \;\;\;\;x + \frac{z - x}{\frac{t}{y}}\\ \mathbf{elif}\;x \le 8.63246856154274614 \cdot 10^{-125}:\\ \;\;\;\;x + \left(y \cdot 1\right) \cdot \frac{z - x}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \left(z - x\right) \cdot \frac{y}{t}\\ \end{array}\]

Reproduce

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