Average Error: 6.3 → 1.4
Time: 7.0s
Precision: binary64
\[x + \frac{y \cdot \left(z - x\right)}{t} \]
\[\begin{array}{l} \mathbf{if}\;y \leq -7.933019809099192 \cdot 10^{-29}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z - x}{t}, x\right)\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_1 := \sqrt[3]{y} \cdot \sqrt[3]{y}\\ \mathbf{if}\;y \leq 1.3006984664826421 \cdot 10^{-183}:\\ \;\;\;\;x + \frac{t_1}{t} \cdot \left(\left(z - x\right) \cdot \sqrt[3]{y}\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{t_1}{\sqrt[3]{t} \cdot \sqrt[3]{t}} \cdot \frac{\sqrt[3]{y}}{\frac{\sqrt[3]{t}}{z - x}}\\ \end{array}\\ \end{array} \]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
\mathbf{if}\;y \leq -7.933019809099192 \cdot 10^{-29}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - x}{t}, x\right)\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_1 := \sqrt[3]{y} \cdot \sqrt[3]{y}\\
\mathbf{if}\;y \leq 1.3006984664826421 \cdot 10^{-183}:\\
\;\;\;\;x + \frac{t_1}{t} \cdot \left(\left(z - x\right) \cdot \sqrt[3]{y}\right)\\

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


\end{array}\\


\end{array}
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
(FPCore (x y z t)
 :precision binary64
 (if (<= y -7.933019809099192e-29)
   (fma y (/ (- z x) t) x)
   (let* ((t_1 (* (cbrt y) (cbrt y))))
     (if (<= y 1.3006984664826421e-183)
       (+ x (* (/ t_1 t) (* (- z x) (cbrt y))))
       (+
        x
        (*
         (/ t_1 (* (cbrt t) (cbrt t)))
         (/ (cbrt y) (/ (cbrt 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 (y <= -7.933019809099192e-29) {
		tmp = fma(y, ((z - x) / t), x);
	} else {
		double t_1 = cbrt(y) * cbrt(y);
		double tmp_1;
		if (y <= 1.3006984664826421e-183) {
			tmp_1 = x + ((t_1 / t) * ((z - x) * cbrt(y)));
		} else {
			tmp_1 = x + ((t_1 / (cbrt(t) * cbrt(t))) * (cbrt(y) / (cbrt(t) / (z - x))));
		}
		tmp = tmp_1;
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.3
Target2.0
Herbie1.4
\[x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right) \]

Derivation

  1. Split input into 3 regimes
  2. if y < -7.93301980909919193e-29

    1. Initial program 13.3

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

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

    if -7.93301980909919193e-29 < y < 1.300698466482642e-183

    1. Initial program 1.1

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

      \[\leadsto x + \color{blue}{\frac{y}{\frac{t}{z - x}}} \]
    3. Applied div-inv_binary6410.3

      \[\leadsto x + \frac{y}{\color{blue}{t \cdot \frac{1}{z - x}}} \]
    4. Applied add-cube-cbrt_binary6410.5

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

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

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

    if 1.300698466482642e-183 < y

    1. Initial program 8.2

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Applied associate-/l*_binary644.0

      \[\leadsto x + \color{blue}{\frac{y}{\frac{t}{z - x}}} \]
    3. Applied *-un-lft-identity_binary644.0

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

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

      \[\leadsto x + \frac{y}{\color{blue}{\frac{\sqrt[3]{t} \cdot \sqrt[3]{t}}{1} \cdot \frac{\sqrt[3]{t}}{z - x}}} \]
    6. Applied add-cube-cbrt_binary644.7

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

      \[\leadsto x + \color{blue}{\frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{\frac{\sqrt[3]{t} \cdot \sqrt[3]{t}}{1}} \cdot \frac{\sqrt[3]{y}}{\frac{\sqrt[3]{t}}{z - x}}} \]
    8. Simplified1.6

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

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

Reproduce

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