Average Error: 6.6 → 1.0
Time: 8.1s
Precision: binary64
Cost: 2242
\[x + \frac{y \cdot \left(z - x\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;x + \frac{y \cdot \left(z - x\right)}{t} \leq -\infty:\\ \;\;\;\;x + y \cdot \frac{z - x}{t}\\ \mathbf{elif}\;x + \frac{y \cdot \left(z - x\right)}{t} \leq 1.446264612679845 \cdot 10^{+303}:\\ \;\;\;\;x + \frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z - x}}\\ \end{array}\]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
\mathbf{if}\;x + \frac{y \cdot \left(z - x\right)}{t} \leq -\infty:\\
\;\;\;\;x + y \cdot \frac{z - x}{t}\\

\mathbf{elif}\;x + \frac{y \cdot \left(z - x\right)}{t} \leq 1.446264612679845 \cdot 10^{+303}:\\
\;\;\;\;x + \frac{y \cdot \left(z - x\right)}{t}\\

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

\end{array}
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
(FPCore (x y z t)
 :precision binary64
 (if (<= (+ x (/ (* y (- z x)) t)) (- INFINITY))
   (+ x (* y (/ (- z x) t)))
   (if (<= (+ x (/ (* y (- z x)) t)) 1.446264612679845e+303)
     (+ x (/ (* y (- z x)) t))
     (+ x (/ y (/ t (- z x)))))))
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 tmp;
	if ((x + ((y * (z - x)) / t)) <= -((double) INFINITY)) {
		tmp = x + (y * ((z - x) / t));
	} else if ((x + ((y * (z - x)) / t)) <= 1.446264612679845e+303) {
		tmp = x + ((y * (z - x)) / t);
	} else {
		tmp = x + (y / (t / (z - x)));
	}
	return tmp;
}

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

Alternatives

Alternative 1
Error1.0
Cost1928
\[\begin{array}{l} \mathbf{if}\;x + \frac{y \cdot \left(z - x\right)}{t} \leq -\infty \lor \neg \left(x + \frac{y \cdot \left(z - x\right)}{t} \leq 1.446264612679845 \cdot 10^{+303}\right):\\ \;\;\;\;x + \frac{y}{\frac{t}{z - x}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot \left(z - x\right)}{t}\\ \end{array}\]
Alternative 2
Error4.5
Cost904
\[\begin{array}{l} \mathbf{if}\;y \leq -5.026611182633652 \cdot 10^{-85} \lor \neg \left(y \leq 1.111667110290758 \cdot 10^{-271}\right):\\ \;\;\;\;x + \frac{y}{\frac{t}{z - x}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \end{array}\]
Alternative 3
Error11.0
Cost2374
\[\begin{array}{l} \mathbf{if}\;z \leq -1.2328847118512386 \cdot 10^{-125}:\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \mathbf{elif}\;z \leq -2.2726686167378452 \cdot 10^{-163}:\\ \;\;\;\;\frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{elif}\;z \leq -6.699490179410647 \cdot 10^{-213}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;z \leq 1.2107636882196295 \cdot 10^{-116}:\\ \;\;\;\;x + \frac{y}{\frac{-t}{x}}\\ \mathbf{elif}\;z \leq 7.565506211054061 \cdot 10^{-79}:\\ \;\;\;\;\frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{elif}\;z \leq 9.569566529871754 \cdot 10^{-62}:\\ \;\;\;\;x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \end{array}\]
Alternative 4
Error10.1
Cost1732
\[\begin{array}{l} \mathbf{if}\;z \leq -4.4936408961461836 \cdot 10^{-125}:\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \mathbf{elif}\;z \leq -9.218321964634582 \cdot 10^{-167}:\\ \;\;\;\;\frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{elif}\;z \leq -6.699490179410647 \cdot 10^{-213}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;z \leq 3.711007259671276 \cdot 10^{-79}:\\ \;\;\;\;x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \end{array}\]
Alternative 5
Error10.6
Cost1732
\[\begin{array}{l} \mathbf{if}\;z \leq -1.2328847118512386 \cdot 10^{-125}:\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \mathbf{elif}\;z \leq -3.2300503804616212 \cdot 10^{-164}:\\ \;\;\;\;\frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{elif}\;z \leq -6.699490179410647 \cdot 10^{-213}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;z \leq 5.661579578006523 \cdot 10^{-81}:\\ \;\;\;\;x - \frac{x \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \end{array}\]
Alternative 6
Error10.5
Cost776
\[\begin{array}{l} \mathbf{if}\;t \leq -3.6498297679654513 \cdot 10^{-112} \lor \neg \left(t \leq 3.4193503751268194 \cdot 10^{-144}\right):\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot \left(z - x\right)}{t}\\ \end{array}\]
Alternative 7
Error12.6
Cost448
\[x + z \cdot \frac{y}{t}\]
Alternative 8
Error28.7
Cost1604
\[\begin{array}{l} \mathbf{if}\;t \leq -3.070535798668593 \cdot 10^{-39}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 2.747959266083649 \cdot 10^{-137}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;t \leq 1.1501813924542043 \cdot 10^{-61}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 2.783364133062069 \cdot 10^{-08}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array}\]
Alternative 9
Error28.9
Cost1101
\[\begin{array}{l} \mathbf{if}\;t \leq -4.77956212560203 \cdot 10^{-42}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 1.8867723340850387 \cdot 10^{-139} \lor \neg \left(t \leq 2.9806613133305926 \cdot 10^{-60}\right) \land t \leq 1.9006050264130434 \cdot 10^{-08}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array}\]
Alternative 10
Error31.8
Cost64
\[x\]
Alternative 11
Error61.8
Cost64
\[-1\]
Alternative 12
Error61.8
Cost64
\[1\]

Error

Derivation

  1. Split input into 3 regimes
  2. if (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < -inf.0

    1. Initial program 64.0

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

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

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

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

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

    if -inf.0 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < 1.44626461267984505e303

    1. Initial program 0.9

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

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

    if 1.44626461267984505e303 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t))

    1. Initial program 57.7

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

      \[\leadsto x + \color{blue}{\frac{y}{\frac{t}{z - x}}}\]
    4. Simplified3.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{y \cdot \left(z - x\right)}{t} \leq -\infty:\\ \;\;\;\;x + y \cdot \frac{z - x}{t}\\ \mathbf{elif}\;x + \frac{y \cdot \left(z - x\right)}{t} \leq 1.446264612679845 \cdot 10^{+303}:\\ \;\;\;\;x + \frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z - x}}\\ \end{array}\]

Reproduce

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