Average Error: 4.8 → 0.6
Time: 38.7s
Precision: binary64
\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
\[\begin{array}{l} t_1 := \frac{y}{z} - \frac{t}{1 - z}\\ \mathbf{if}\;t_1 \leq -3.3553661816758805 \cdot 10^{+253}:\\ \;\;\;\;\frac{x \cdot \left(y \cdot \left(1 - z\right) - z \cdot t\right)}{z \cdot \left(1 - z\right)}\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_2 := x \cdot \left(\frac{y}{z} + \frac{t}{z - 1}\right)\\ \mathbf{if}\;t_1 \leq -4.265609901108797 \cdot 10^{-218}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;\frac{y \cdot x + t \cdot x}{z}\\ \mathbf{elif}\;t_1 \leq 1.1121656242996984 \cdot 10^{+184}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z} - \frac{t \cdot x}{1 - z}\\ \end{array}\\ \end{array} \]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
t_1 := \frac{y}{z} - \frac{t}{1 - z}\\
\mathbf{if}\;t_1 \leq -3.3553661816758805 \cdot 10^{+253}:\\
\;\;\;\;\frac{x \cdot \left(y \cdot \left(1 - z\right) - z \cdot t\right)}{z \cdot \left(1 - z\right)}\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_2 := x \cdot \left(\frac{y}{z} + \frac{t}{z - 1}\right)\\
\mathbf{if}\;t_1 \leq -4.265609901108797 \cdot 10^{-218}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;\frac{y \cdot x + t \cdot x}{z}\\

\mathbf{elif}\;t_1 \leq 1.1121656242996984 \cdot 10^{+184}:\\
\;\;\;\;t_2\\

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


\end{array}\\


\end{array}
(FPCore (x y z t) :precision binary64 (* x (- (/ y z) (/ t (- 1.0 z)))))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (/ y z) (/ t (- 1.0 z)))))
   (if (<= t_1 -3.3553661816758805e+253)
     (/ (* x (- (* y (- 1.0 z)) (* z t))) (* z (- 1.0 z)))
     (let* ((t_2 (* x (+ (/ y z) (/ t (- z 1.0))))))
       (if (<= t_1 -4.265609901108797e-218)
         t_2
         (if (<= t_1 0.0)
           (/ (+ (* y x) (* t x)) z)
           (if (<= t_1 1.1121656242996984e+184)
             t_2
             (- (/ (* y x) z) (/ (* t x) (- 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 t_1 = (y / z) - (t / (1.0 - z));
	double tmp;
	if (t_1 <= -3.3553661816758805e+253) {
		tmp = (x * ((y * (1.0 - z)) - (z * t))) / (z * (1.0 - z));
	} else {
		double t_2 = x * ((y / z) + (t / (z - 1.0)));
		double tmp_1;
		if (t_1 <= -4.265609901108797e-218) {
			tmp_1 = t_2;
		} else if (t_1 <= 0.0) {
			tmp_1 = ((y * x) + (t * x)) / z;
		} else if (t_1 <= 1.1121656242996984e+184) {
			tmp_1 = t_2;
		} else {
			tmp_1 = ((y * x) / z) - ((t * x) / (1.0 - z));
		}
		tmp = tmp_1;
	}
	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.4
Herbie0.6
\[\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 4 regimes
  2. if (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < -3.3553661816758805e253

    1. Initial program 32.4

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
    2. Applied frac-sub_binary6434.5

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

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

    if -3.3553661816758805e253 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < -4.2656099011087971e-218 or 0.0 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < 1.11216562429969839e184

    1. Initial program 0.3

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
    2. Applied div-inv_binary640.3

      \[\leadsto x \cdot \left(\frac{y}{z} - \color{blue}{t \cdot \frac{1}{1 - z}}\right) \]
    3. Applied div-inv_binary640.4

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

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

      \[\leadsto x \cdot \mathsf{fma}\left(y, \frac{1}{z}, \color{blue}{\frac{t}{z + -1}}\right) \]
    6. Taylor expanded in x around inf 0.3

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

    if -4.2656099011087971e-218 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < 0.0

    1. Initial program 13.6

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

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

    if 1.11216562429969839e184 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z)))

    1. Initial program 16.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \leq -3.3553661816758805 \cdot 10^{+253}:\\ \;\;\;\;\frac{x \cdot \left(y \cdot \left(1 - z\right) - z \cdot t\right)}{z \cdot \left(1 - z\right)}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq -4.265609901108797 \cdot 10^{-218}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} + \frac{t}{z - 1}\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq 0:\\ \;\;\;\;\frac{y \cdot x + t \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq 1.1121656242996984 \cdot 10^{+184}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} + \frac{t}{z - 1}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z} - \frac{t \cdot x}{1 - z}\\ \end{array} \]

Reproduce

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