Average Error: 4.7 → 0.3
Time: 4.7s
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 -4.1287833379471316 \cdot 10^{+291}:\\ \;\;\;\;\frac{y \cdot x}{z} - \frac{t}{1 - z} \cdot x\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq -1.157283630842069 \cdot 10^{-240}:\\ \;\;\;\;\frac{x}{\frac{z}{y}} - \frac{t}{1 - z} \cdot x\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq 4.9481558492305 \cdot 10^{-314}:\\ \;\;\;\;\frac{x}{z} \cdot \left(t + \left(y + \frac{t}{z}\right)\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq 4.410473996090381 \cdot 10^{+198}:\\ \;\;\;\;\frac{y}{z} \cdot x - \frac{t}{1 - z} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z} - \frac{t}{1 - z} \cdot x\\ \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 -4.1287833379471316 \cdot 10^{+291}:\\
\;\;\;\;\frac{y \cdot x}{z} - \frac{t}{1 - z} \cdot x\\

\mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq -1.157283630842069 \cdot 10^{-240}:\\
\;\;\;\;\frac{x}{\frac{z}{y}} - \frac{t}{1 - z} \cdot x\\

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

\mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq 4.410473996090381 \cdot 10^{+198}:\\
\;\;\;\;\frac{y}{z} \cdot x - \frac{t}{1 - z} \cdot x\\

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

\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))) -4.1287833379471316e+291)
   (- (/ (* y x) z) (* (/ t (- 1.0 z)) x))
   (if (<= (- (/ y z) (/ t (- 1.0 z))) -1.157283630842069e-240)
     (- (/ x (/ z y)) (* (/ t (- 1.0 z)) x))
     (if (<= (- (/ y z) (/ t (- 1.0 z))) 4.9481558492305e-314)
       (* (/ x z) (+ t (+ y (/ t z))))
       (if (<= (- (/ y z) (/ t (- 1.0 z))) 4.410473996090381e+198)
         (- (* (/ y z) x) (* (/ t (- 1.0 z)) x))
         (- (/ (* y x) z) (* (/ t (- 1.0 z)) x)))))))
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))) <= -4.1287833379471316e+291) {
		tmp = ((y * x) / z) - ((t / (1.0 - z)) * x);
	} else if (((y / z) - (t / (1.0 - z))) <= -1.157283630842069e-240) {
		tmp = (x / (z / y)) - ((t / (1.0 - z)) * x);
	} else if (((y / z) - (t / (1.0 - z))) <= 4.9481558492305e-314) {
		tmp = (x / z) * (t + (y + (t / z)));
	} else if (((y / z) - (t / (1.0 - z))) <= 4.410473996090381e+198) {
		tmp = ((y / z) * x) - ((t / (1.0 - z)) * x);
	} else {
		tmp = ((y * x) / z) - ((t / (1.0 - z)) * x);
	}
	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.2
Herbie0.3
\[\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))) < -4.1287833379471316e291 or 4.4104739960903812e198 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z)))

    1. Initial program 27.0

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

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

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

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

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

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

    if -4.1287833379471316e291 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < -1.15728363084206897e-240

    1. Initial program 0.2

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z}} + x \cdot \left(-\frac{t}{1 - z}\right)\]
    9. Using strategy rm
    10. Applied associate-/l*_binary64_121560.2

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

    if -1.15728363084206897e-240 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < 4.9481558492e-314

    1. Initial program 15.1

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

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

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

    if 4.9481558492e-314 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < 4.4104739960903812e198

    1. Initial program 0.2

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \leq -4.1287833379471316 \cdot 10^{+291}:\\ \;\;\;\;\frac{y \cdot x}{z} - \frac{t}{1 - z} \cdot x\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq -1.157283630842069 \cdot 10^{-240}:\\ \;\;\;\;\frac{x}{\frac{z}{y}} - \frac{t}{1 - z} \cdot x\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq 4.9481558492305 \cdot 10^{-314}:\\ \;\;\;\;\frac{x}{z} \cdot \left(t + \left(y + \frac{t}{z}\right)\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq 4.410473996090381 \cdot 10^{+198}:\\ \;\;\;\;\frac{y}{z} \cdot x - \frac{t}{1 - z} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z} - \frac{t}{1 - z} \cdot x\\ \end{array}\]

Reproduce

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