Average Error: 4.5 → 0.6
Time: 13.0s
Precision: binary64
\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
\[\begin{array}{l} t_1 := \frac{t \cdot x}{1 - z}\\ t_2 := \frac{t}{1 - z}\\ t_3 := \frac{y}{z} - t_2\\ \mathbf{if}\;t_3 \leq -8.275559905218104 \cdot 10^{+307}:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{1}{z} - t_1\\ \mathbf{elif}\;t_3 \leq -2.0154290514920976 \cdot 10^{-135}:\\ \;\;\;\;\frac{y}{z} \cdot x - t_2 \cdot x\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_4 := \frac{y \cdot x}{z}\\ \mathbf{if}\;t_3 \leq 5.691460963819012 \cdot 10^{-166}:\\ \;\;\;\;t_4 - t_1\\ \mathbf{elif}\;t_3 \leq 3.473759016862935 \cdot 10^{+259}:\\ \;\;\;\;t_3 \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_4 - \left(t \cdot x\right) \cdot \frac{1}{1 - z}\\ \end{array}\\ \end{array} \]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
t_1 := \frac{t \cdot x}{1 - z}\\
t_2 := \frac{t}{1 - z}\\
t_3 := \frac{y}{z} - t_2\\
\mathbf{if}\;t_3 \leq -8.275559905218104 \cdot 10^{+307}:\\
\;\;\;\;\left(y \cdot x\right) \cdot \frac{1}{z} - t_1\\

\mathbf{elif}\;t_3 \leq -2.0154290514920976 \cdot 10^{-135}:\\
\;\;\;\;\frac{y}{z} \cdot x - t_2 \cdot x\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_4 := \frac{y \cdot x}{z}\\
\mathbf{if}\;t_3 \leq 5.691460963819012 \cdot 10^{-166}:\\
\;\;\;\;t_4 - t_1\\

\mathbf{elif}\;t_3 \leq 3.473759016862935 \cdot 10^{+259}:\\
\;\;\;\;t_3 \cdot x\\

\mathbf{else}:\\
\;\;\;\;t_4 - \left(t \cdot x\right) \cdot \frac{1}{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 (/ (* t x) (- 1.0 z)))
        (t_2 (/ t (- 1.0 z)))
        (t_3 (- (/ y z) t_2)))
   (if (<= t_3 -8.275559905218104e+307)
     (- (* (* y x) (/ 1.0 z)) t_1)
     (if (<= t_3 -2.0154290514920976e-135)
       (- (* (/ y z) x) (* t_2 x))
       (let* ((t_4 (/ (* y x) z)))
         (if (<= t_3 5.691460963819012e-166)
           (- t_4 t_1)
           (if (<= t_3 3.473759016862935e+259)
             (* t_3 x)
             (- t_4 (* (* t x) (/ 1.0 (- 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 = (t * x) / (1.0 - z);
	double t_2 = t / (1.0 - z);
	double t_3 = (y / z) - t_2;
	double tmp;
	if (t_3 <= -8.275559905218104e+307) {
		tmp = ((y * x) * (1.0 / z)) - t_1;
	} else if (t_3 <= -2.0154290514920976e-135) {
		tmp = ((y / z) * x) - (t_2 * x);
	} else {
		double t_4 = (y * x) / z;
		double tmp_1;
		if (t_3 <= 5.691460963819012e-166) {
			tmp_1 = t_4 - t_1;
		} else if (t_3 <= 3.473759016862935e+259) {
			tmp_1 = t_3 * x;
		} else {
			tmp_1 = t_4 - ((t * x) * (1.0 / (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.5
Target4.0
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 5 regimes
  2. if (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < -8.27555990521810415e307

    1. Initial program 63.3

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

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

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

    if -8.27555990521810415e307 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < -2.0154290514920976e-135

    1. Initial program 0.2

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

      \[\leadsto x \cdot \left(\frac{y}{z} - \frac{t}{\color{blue}{1 \cdot \left(1 - z\right)}}\right) \]
    3. Applied *-un-lft-identity_binary640.2

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

      \[\leadsto x \cdot \left(\frac{y}{z} - \color{blue}{\frac{1}{1} \cdot \frac{t}{1 - z}}\right) \]
    5. Applied cancel-sign-sub-inv_binary640.2

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

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

    if -2.0154290514920976e-135 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < 5.6914609638190115e-166

    1. Initial program 6.1

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

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

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

    if 5.6914609638190115e-166 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < 3.47375901686293489e259

    1. Initial program 0.2

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

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

    if 3.47375901686293489e259 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z)))

    1. Initial program 33.5

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \leq -8.275559905218104 \cdot 10^{+307}:\\ \;\;\;\;\left(y \cdot x\right) \cdot \frac{1}{z} - \frac{t \cdot x}{1 - z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq -2.0154290514920976 \cdot 10^{-135}:\\ \;\;\;\;\frac{y}{z} \cdot x - \frac{t}{1 - z} \cdot x\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq 5.691460963819012 \cdot 10^{-166}:\\ \;\;\;\;\frac{y \cdot x}{z} - \frac{t \cdot x}{1 - z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq 3.473759016862935 \cdot 10^{+259}:\\ \;\;\;\;\left(\frac{y}{z} - \frac{t}{1 - z}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z} - \left(t \cdot x\right) \cdot \frac{1}{1 - z}\\ \end{array} \]

Reproduce

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