Average Error: 4.7 → 0.6
Time: 18.4s
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 -1.0690732745595959 \cdot 10^{+186}:\\ \;\;\;\;y \cdot \frac{x}{z} - t \cdot \frac{x}{1 - z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq -3.501687232319656 \cdot 10^{-195}:\\ \;\;\;\;\left(\frac{y}{z} - \frac{t}{1 - z}\right) \cdot x\\ \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.0504291516730519 \cdot 10^{+198}:\\ \;\;\;\;\frac{y}{z} \cdot x - \frac{t}{1 - z} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z} - \frac{t \cdot x}{1 - 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 -1.0690732745595959 \cdot 10^{+186}:\\
\;\;\;\;y \cdot \frac{x}{z} - t \cdot \frac{x}{1 - z}\\

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

\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.0504291516730519 \cdot 10^{+198}:\\
\;\;\;\;\frac{y}{z} \cdot x - \frac{t}{1 - z} \cdot x\\

\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{z} - \frac{t \cdot x}{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 (<= (- (/ y z) (/ t (- 1.0 z))) -1.0690732745595959e+186)
   (- (* y (/ x z)) (* t (/ x (- 1.0 z))))
   (if (<= (- (/ y z) (/ t (- 1.0 z))) -3.501687232319656e-195)
     (* (- (/ y z) (/ t (- 1.0 z))) x)
     (if (<= (- (/ y z) (/ t (- 1.0 z))) 0.0)
       (/ (+ (* y x) (* t x)) z)
       (if (<= (- (/ y z) (/ t (- 1.0 z))) 1.0504291516730519e+198)
         (- (* (/ y z) x) (* (/ t (- 1.0 z)) x))
         (- (/ (* 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 tmp;
	if (((y / z) - (t / (1.0 - z))) <= -1.0690732745595959e+186) {
		tmp = (y * (x / z)) - (t * (x / (1.0 - z)));
	} else if (((y / z) - (t / (1.0 - z))) <= -3.501687232319656e-195) {
		tmp = ((y / z) - (t / (1.0 - z))) * x;
	} else if (((y / z) - (t / (1.0 - z))) <= 0.0) {
		tmp = ((y * x) + (t * x)) / z;
	} else if (((y / z) - (t / (1.0 - z))) <= 1.0504291516730519e+198) {
		tmp = ((y / z) * x) - ((t / (1.0 - z)) * x);
	} else {
		tmp = ((y * x) / z) - ((t * x) / (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.7
Target4.3
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))) < -1.06907327455959592e186

    1. Initial program 17.7

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

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

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

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} + \left(\left(-t\right) \cdot \frac{1}{1 - z}\right) \cdot x\]
    7. Taylor expanded around 0 1.9

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

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

    if -1.06907327455959592e186 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < -3.5016872323196563e-195

    1. Initial program 0.2

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

    if -3.5016872323196563e-195 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < 0.0

    1. Initial program 11.8

      \[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 + t \cdot x}{z}}\]

    if 0.0 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < 1.0504291516730519e198

    1. Initial program 0.3

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

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

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

    if 1.0504291516730519e198 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z)))

    1. Initial program 20.0

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z} - \frac{t \cdot x}{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 -1.0690732745595959 \cdot 10^{+186}:\\ \;\;\;\;y \cdot \frac{x}{z} - t \cdot \frac{x}{1 - z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq -3.501687232319656 \cdot 10^{-195}:\\ \;\;\;\;\left(\frac{y}{z} - \frac{t}{1 - z}\right) \cdot x\\ \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.0504291516730519 \cdot 10^{+198}:\\ \;\;\;\;\frac{y}{z} \cdot x - \frac{t}{1 - z} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z} - \frac{t \cdot x}{1 - z}\\ \end{array}\]

Reproduce

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