Average Error: 6.6 → 2.3
Time: 4.8s
Precision: binary64
\[x + \frac{y \cdot \left(z - x\right)}{t} \]
\[\begin{array}{l} \mathbf{if}\;t \leq -2.2786730843016057 \cdot 10^{-249}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)\\ \mathbf{elif}\;t \leq 2.050710958518032 \cdot 10^{+142}:\\ \;\;\;\;\mathsf{fma}\left(1, x, \frac{y \cdot \left(z - x\right)}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{1}{\frac{1}{\sqrt[3]{y} \cdot \sqrt[3]{y}}} \cdot \frac{1}{\frac{\frac{t}{\sqrt[3]{y}}}{z - x}}\\ \end{array} \]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
\mathbf{if}\;t \leq -2.2786730843016057 \cdot 10^{-249}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)\\

\mathbf{elif}\;t \leq 2.050710958518032 \cdot 10^{+142}:\\
\;\;\;\;\mathsf{fma}\left(1, x, \frac{y \cdot \left(z - x\right)}{t}\right)\\

\mathbf{else}:\\
\;\;\;\;x + \frac{1}{\frac{1}{\sqrt[3]{y} \cdot \sqrt[3]{y}}} \cdot \frac{1}{\frac{\frac{t}{\sqrt[3]{y}}}{z - x}}\\


\end{array}
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
(FPCore (x y z t)
 :precision binary64
 (if (<= t -2.2786730843016057e-249)
   (fma (/ y t) (- z x) x)
   (if (<= t 2.050710958518032e+142)
     (fma 1.0 x (/ (* y (- z x)) t))
     (+
      x
      (*
       (/ 1.0 (/ 1.0 (* (cbrt y) (cbrt y))))
       (/ 1.0 (/ (/ t (cbrt y)) (- 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.2786730843016057e-249) {
		tmp = fma((y / t), (z - x), x);
	} else if (t <= 2.050710958518032e+142) {
		tmp = fma(1.0, x, ((y * (z - x)) / t));
	} else {
		tmp = x + ((1.0 / (1.0 / (cbrt(y) * cbrt(y)))) * (1.0 / ((t / cbrt(y)) / (z - x))));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.6
Target2.1
Herbie2.3
\[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 < -2.2786730843016057e-249

    1. Initial program 6.4

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Taylor expanded in x around 0 6.4

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

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

    if -2.2786730843016057e-249 < t < 2.050710958518032e142

    1. Initial program 3.7

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Applied *-un-lft-identity_binary643.7

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

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

    if 2.050710958518032e142 < t

    1. Initial program 12.9

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

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

      \[\leadsto x + \frac{1}{\color{blue}{\frac{\frac{t}{y}}{z - x}}} \]
    4. Applied *-un-lft-identity_binary641.5

      \[\leadsto x + \frac{1}{\frac{\frac{t}{y}}{\color{blue}{1 \cdot \left(z - x\right)}}} \]
    5. Applied add-cube-cbrt_binary641.8

      \[\leadsto x + \frac{1}{\frac{\frac{t}{\color{blue}{\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \sqrt[3]{y}}}}{1 \cdot \left(z - x\right)}} \]
    6. Applied *-un-lft-identity_binary641.8

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

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

      \[\leadsto x + \frac{1}{\color{blue}{\frac{\frac{1}{\sqrt[3]{y} \cdot \sqrt[3]{y}}}{1} \cdot \frac{\frac{t}{\sqrt[3]{y}}}{z - x}}} \]
    9. Applied *-un-lft-identity_binary641.0

      \[\leadsto x + \frac{\color{blue}{1 \cdot 1}}{\frac{\frac{1}{\sqrt[3]{y} \cdot \sqrt[3]{y}}}{1} \cdot \frac{\frac{t}{\sqrt[3]{y}}}{z - x}} \]
    10. Applied times-frac_binary641.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -2.2786730843016057 \cdot 10^{-249}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{t}, z - x, x\right)\\ \mathbf{elif}\;t \leq 2.050710958518032 \cdot 10^{+142}:\\ \;\;\;\;\mathsf{fma}\left(1, x, \frac{y \cdot \left(z - x\right)}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{1}{\frac{1}{\sqrt[3]{y} \cdot \sqrt[3]{y}}} \cdot \frac{1}{\frac{\frac{t}{\sqrt[3]{y}}}{z - x}}\\ \end{array} \]

Reproduce

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