Average Error: 4.6 → 1.1
Time: 6.9s
Precision: binary64
\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \leq -\infty:\\ \;\;\;\;\frac{x \cdot y}{z} - x \cdot \frac{t}{1 - z}\\ \mathbf{elif}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \leq 4.204934269713327 \cdot 10^{+306}:\\ \;\;\;\;x \cdot \frac{y}{z} - x \cdot \frac{t}{1 - z}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{z} - x \cdot \frac{t}{1 - z}\\ \end{array}\]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
\mathbf{if}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \leq -\infty:\\
\;\;\;\;\frac{x \cdot y}{z} - x \cdot \frac{t}{1 - z}\\

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

\mathbf{else}:\\
\;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{z} - x \cdot \frac{t}{1 - 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 (<= (* x (- (/ y z) (/ t (- 1.0 z)))) (- INFINITY))
   (- (/ (* x y) z) (* x (/ t (- 1.0 z))))
   (if (<= (* x (- (/ y z) (/ t (- 1.0 z)))) 4.204934269713327e+306)
     (- (* x (/ y z)) (* x (/ t (- 1.0 z))))
     (- (* (* x y) (/ 1.0 z)) (* x (/ t (- 1.0 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 ((x * ((y / z) - (t / (1.0 - z)))) <= -((double) INFINITY)) {
		tmp = ((x * y) / z) - (x * (t / (1.0 - z)));
	} else if ((x * ((y / z) - (t / (1.0 - z)))) <= 4.204934269713327e+306) {
		tmp = (x * (y / z)) - (x * (t / (1.0 - z)));
	} else {
		tmp = ((x * y) * (1.0 / z)) - (x * (t / (1.0 - 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.6
Target4.4
Herbie1.1
\[\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 x (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z)))) < -inf.0

    1. Initial program 64.0

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

      \[\leadsto \color{blue}{\left(\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}\right)} \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
    4. Applied associate-*l*_binary6464.0

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

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z} - \frac{t \cdot x}{1 - z}}\]
    7. Simplified0.3

      \[\leadsto \color{blue}{\frac{x \cdot y}{z} - \frac{t}{1 - z} \cdot x}\]
    8. Using strategy rm
    9. Applied *-un-lft-identity_binary640.3

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

    if -inf.0 < (*.f64 x (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z)))) < 4.20493426971332703e306

    1. Initial program 1.2

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

      \[\leadsto \color{blue}{\left(\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}\right)} \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
    4. Applied associate-*l*_binary642.2

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

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z} - \frac{t \cdot x}{1 - z}}\]
    7. Simplified5.3

      \[\leadsto \color{blue}{\frac{x \cdot y}{z} - \frac{t}{1 - z} \cdot x}\]
    8. Using strategy rm
    9. Applied *-un-lft-identity_binary645.3

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

      \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{y}{z}} - \frac{t}{1 - z} \cdot x\]
    11. Simplified1.2

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

    if 4.20493426971332703e306 < (*.f64 x (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))))

    1. Initial program 62.6

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

      \[\leadsto \color{blue}{\left(\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}\right)} \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
    4. Applied associate-*l*_binary6462.6

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

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z} - \frac{t \cdot x}{1 - z}}\]
    7. Simplified0.9

      \[\leadsto \color{blue}{\frac{x \cdot y}{z} - \frac{t}{1 - z} \cdot x}\]
    8. Using strategy rm
    9. Applied div-inv_binary640.9

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

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

Reproduce

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