Average Error: 6.6 → 1.9
Time: 4.0s
Precision: binary64
\[x + \frac{y \cdot \left(z - x\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;t \leq -2.6987007251188735 \cdot 10^{-160}:\\ \;\;\;\;x + \frac{y}{t} \cdot \left(z - x\right)\\ \mathbf{elif}\;t \leq 2.6649632399056567 \cdot 10^{+158}:\\ \;\;\;\;x + \frac{\left(z - x\right) \cdot \frac{y}{\sqrt[3]{t} \cdot \sqrt[3]{t}}}{\sqrt[3]{t}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{t} \cdot \left(z - x\right)\\ \end{array}\]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
\mathbf{if}\;t \leq -2.6987007251188735 \cdot 10^{-160}:\\
\;\;\;\;x + \frac{y}{t} \cdot \left(z - x\right)\\

\mathbf{elif}\;t \leq 2.6649632399056567 \cdot 10^{+158}:\\
\;\;\;\;x + \frac{\left(z - x\right) \cdot \frac{y}{\sqrt[3]{t} \cdot \sqrt[3]{t}}}{\sqrt[3]{t}}\\

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

\end{array}
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
(FPCore (x y z t)
 :precision binary64
 (if (<= t -2.6987007251188735e-160)
   (+ x (* (/ y t) (- z x)))
   (if (<= t 2.6649632399056567e+158)
     (+ x (/ (* (- z x) (/ y (* (cbrt t) (cbrt t)))) (cbrt 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 (t <= -2.6987007251188735e-160) {
		tmp = x + ((y / t) * (z - x));
	} else if (t <= 2.6649632399056567e+158) {
		tmp = x + (((z - x) * (y / (cbrt(t) * cbrt(t)))) / cbrt(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.1
Herbie1.9
\[x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right)\]

Derivation

  1. Split input into 2 regimes
  2. if t < -2.69870072511887347e-160 or 2.6649632399056567e158 < t

    1. Initial program 8.6

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

      \[\leadsto x + \frac{y \cdot \left(z - x\right)}{\color{blue}{\left(\sqrt[3]{t} \cdot \sqrt[3]{t}\right) \cdot \sqrt[3]{t}}}\]
    4. Applied associate-/r*_binary649.0

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

      \[\leadsto x + \frac{\color{blue}{\frac{y}{\sqrt[3]{t} \cdot \sqrt[3]{t}} \cdot \left(z - x\right)}}{\sqrt[3]{t}}\]
    6. Taylor expanded around -inf 8.6

      \[\leadsto x + \color{blue}{\left(\frac{x \cdot y}{t \cdot {\left(\sqrt[3]{-1}\right)}^{3}} - \frac{z \cdot y}{t \cdot {\left(\sqrt[3]{-1}\right)}^{3}}\right)}\]
    7. Simplified1.3

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

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

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

    if -2.69870072511887347e-160 < t < 2.6649632399056567e158

    1. Initial program 3.7

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

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

      \[\leadsto x + \color{blue}{\frac{\frac{y \cdot \left(z - x\right)}{\sqrt[3]{t} \cdot \sqrt[3]{t}}}{\sqrt[3]{t}}}\]
    5. Simplified2.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -2.6987007251188735 \cdot 10^{-160}:\\ \;\;\;\;x + \frac{y}{t} \cdot \left(z - x\right)\\ \mathbf{elif}\;t \leq 2.6649632399056567 \cdot 10^{+158}:\\ \;\;\;\;x + \frac{\left(z - x\right) \cdot \frac{y}{\sqrt[3]{t} \cdot \sqrt[3]{t}}}{\sqrt[3]{t}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{t} \cdot \left(z - x\right)\\ \end{array}\]

Reproduce

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