Average Error: 4.8 → 2.8
Time: 3.5s
Precision: binary64
\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \leq -3.628654004135568 \cdot 10^{-240}:\\ \;\;\;\;\sqrt[3]{\frac{y}{z}} \cdot \left(x \cdot \left(\sqrt[3]{\frac{y}{z}} \cdot \sqrt[3]{\frac{y}{z}}\right)\right) + x \cdot \frac{t}{z - 1}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq 2.797145385757385 \cdot 10^{-201}:\\ \;\;\;\;\frac{x}{z} \cdot \left(t + \left(y + \frac{t}{z}\right)\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq 1.347321449727839 \cdot 10^{+117}:\\ \;\;\;\;\sqrt[3]{\frac{y}{z}} \cdot \left(x \cdot \left(\sqrt[3]{\frac{y}{z}} \cdot \sqrt[3]{\frac{y}{z}}\right)\right) + x \cdot \frac{t}{z - 1}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{t}{z - 1} + \frac{y \cdot x}{z}\\ \end{array}\]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \leq -3.628654004135568 \cdot 10^{-240}:\\
\;\;\;\;\sqrt[3]{\frac{y}{z}} \cdot \left(x \cdot \left(\sqrt[3]{\frac{y}{z}} \cdot \sqrt[3]{\frac{y}{z}}\right)\right) + x \cdot \frac{t}{z - 1}\\

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

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

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

\end{array}
(FPCore (x y z t) :precision binary64 (* x (- (/ y z) (/ t (- 1.0 z)))))
(FPCore (x y z t)
 :precision binary64
 (if (<= (- (/ y z) (/ t (- 1.0 z))) -3.628654004135568e-240)
   (+
    (* (cbrt (/ y z)) (* x (* (cbrt (/ y z)) (cbrt (/ y z)))))
    (* x (/ t (- z 1.0))))
   (if (<= (- (/ y z) (/ t (- 1.0 z))) 2.797145385757385e-201)
     (* (/ x z) (+ t (+ y (/ t z))))
     (if (<= (- (/ y z) (/ t (- 1.0 z))) 1.347321449727839e+117)
       (+
        (* (cbrt (/ y z)) (* x (* (cbrt (/ y z)) (cbrt (/ y z)))))
        (* x (/ t (- z 1.0))))
       (+ (* x (/ t (- z 1.0))) (/ (* y x) z))))))
double code(double x, double y, double z, double t) {
	return x * ((y / z) - (t / (1.0 - z)));
}
double code(double x, double y, double z, double t) {
	double tmp;
	if (((y / z) - (t / (1.0 - z))) <= -3.628654004135568e-240) {
		tmp = (cbrt(y / z) * (x * (cbrt(y / z) * cbrt(y / z)))) + (x * (t / (z - 1.0)));
	} else if (((y / z) - (t / (1.0 - z))) <= 2.797145385757385e-201) {
		tmp = (x / z) * (t + (y + (t / z)));
	} else if (((y / z) - (t / (1.0 - z))) <= 1.347321449727839e+117) {
		tmp = (cbrt(y / z) * (x * (cbrt(y / z) * cbrt(y / z)))) + (x * (t / (z - 1.0)));
	} else {
		tmp = (x * (t / (z - 1.0))) + ((y * x) / z);
	}
	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

Original4.8
Target4.2
Herbie2.8
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) < -7.623226303312042 \cdot 10^{-196}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - z}\right)\\ \mathbf{elif}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) < 1.4133944927702302 \cdot 10^{-211}:\\ \;\;\;\;\frac{y \cdot x}{z} + \left(-\frac{t \cdot x}{1 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - z}\right)\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < -3.6286540041355679e-240 or 2.79714538575738503e-201 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < 1.34732144972783902e117

    1. Initial program 2.6

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
    2. Using strategy rm
    3. Applied sub-neg_binary642.6

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

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

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

      \[\leadsto x \cdot \frac{y}{z} + \color{blue}{x \cdot \frac{t}{z - 1}}\]
    7. Using strategy rm
    8. Applied add-cube-cbrt_binary643.2

      \[\leadsto x \cdot \color{blue}{\left(\left(\sqrt[3]{\frac{y}{z}} \cdot \sqrt[3]{\frac{y}{z}}\right) \cdot \sqrt[3]{\frac{y}{z}}\right)} + x \cdot \frac{t}{z - 1}\]
    9. Applied associate-*r*_binary643.2

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

    if -3.6286540041355679e-240 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < 2.79714538575738503e-201

    1. Initial program 10.7

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
    2. Taylor expanded around inf 1.4

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

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

    if 1.34732144972783902e117 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z)))

    1. Initial program 11.0

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
    2. Using strategy rm
    3. Applied sub-neg_binary6411.0

      \[\leadsto x \cdot \color{blue}{\left(\frac{y}{z} + \left(-\frac{t}{1 - z}\right)\right)}\]
    4. Applied distribute-rgt-in_binary6411.0

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

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

      \[\leadsto x \cdot \frac{y}{z} + \color{blue}{x \cdot \frac{t}{z - 1}}\]
    7. Using strategy rm
    8. Applied associate-*r/_binary642.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \leq -3.628654004135568 \cdot 10^{-240}:\\ \;\;\;\;\sqrt[3]{\frac{y}{z}} \cdot \left(x \cdot \left(\sqrt[3]{\frac{y}{z}} \cdot \sqrt[3]{\frac{y}{z}}\right)\right) + x \cdot \frac{t}{z - 1}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq 2.797145385757385 \cdot 10^{-201}:\\ \;\;\;\;\frac{x}{z} \cdot \left(t + \left(y + \frac{t}{z}\right)\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq 1.347321449727839 \cdot 10^{+117}:\\ \;\;\;\;\sqrt[3]{\frac{y}{z}} \cdot \left(x \cdot \left(\sqrt[3]{\frac{y}{z}} \cdot \sqrt[3]{\frac{y}{z}}\right)\right) + x \cdot \frac{t}{z - 1}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{t}{z - 1} + \frac{y \cdot x}{z}\\ \end{array}\]

Reproduce

herbie shell --seed 2020232 
(FPCore (x y z t)
  :name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, C"
  :precision binary64

  :herbie-target
  (if (< (* x (- (/ y z) (/ t (- 1.0 z)))) -7.623226303312042e-196) (* x (- (/ y z) (* t (/ 1.0 (- 1.0 z))))) (if (< (* x (- (/ y z) (/ t (- 1.0 z)))) 1.4133944927702302e-211) (+ (/ (* y x) z) (- (/ (* t x) (- 1.0 z)))) (* x (- (/ y z) (* t (/ 1.0 (- 1.0 z)))))))

  (* x (- (/ y z) (/ t (- 1.0 z)))))