Average Error: 4.8 → 5.3
Time: 9.2s
Precision: 64
\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
\[\begin{array}{l} \mathbf{if}\;t \le -1.81558813368982386 \cdot 10^{-99} \lor \neg \left(t \le -5.192055214536196 \cdot 10^{-135}\right):\\ \;\;\;\;\left(\frac{y}{z} - \frac{1}{\frac{1 - z}{t}}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z} + \left(1 \cdot \frac{t \cdot x}{{z}^{2}} + \frac{t \cdot x}{z}\right)\\ \end{array}\]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
\mathbf{if}\;t \le -1.81558813368982386 \cdot 10^{-99} \lor \neg \left(t \le -5.192055214536196 \cdot 10^{-135}\right):\\
\;\;\;\;\left(\frac{y}{z} - \frac{1}{\frac{1 - z}{t}}\right) \cdot x\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{z} + \left(1 \cdot \frac{t \cdot x}{{z}^{2}} + \frac{t \cdot x}{z}\right)\\

\end{array}
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 temp;
	if (((t <= -1.8155881336898239e-99) || !(t <= -5.192055214536196e-135))) {
		temp = (((y / z) - (1.0 / ((1.0 - z) / t))) * x);
	} else {
		temp = (((x * y) / z) + ((1.0 * ((t * x) / pow(z, 2.0))) + ((t * x) / z)));
	}
	return temp;
}

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
Herbie5.3
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \lt -7.62322630331204244 \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) \lt 1.41339449277023022 \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 2 regimes
  2. if t < -1.8155881336898239e-99 or -5.192055214536196e-135 < t

    1. Initial program 4.7

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

      \[\leadsto \color{blue}{\left(\frac{y}{z} - \frac{t}{1 - z}\right) \cdot x}\]
    4. Using strategy rm
    5. Applied clear-num4.8

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

    if -1.8155881336898239e-99 < t < -5.192055214536196e-135

    1. Initial program 7.2

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

      \[\leadsto \color{blue}{\left(\frac{y}{z} - \frac{t}{1 - z}\right) \cdot x}\]
    4. Using strategy rm
    5. Applied clear-num7.3

      \[\leadsto \left(\frac{y}{z} - \color{blue}{\frac{1}{\frac{1 - z}{t}}}\right) \cdot x\]
    6. Using strategy rm
    7. Applied div-inv7.3

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

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

      \[\leadsto \color{blue}{\frac{y \cdot \frac{1}{t} - z \cdot \frac{1}{1 - z}}{z \cdot \frac{1}{t}}} \cdot x\]
    10. Applied associate-*l/20.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -1.81558813368982386 \cdot 10^{-99} \lor \neg \left(t \le -5.192055214536196 \cdot 10^{-135}\right):\\ \;\;\;\;\left(\frac{y}{z} - \frac{1}{\frac{1 - z}{t}}\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z} + \left(1 \cdot \frac{t \cdot x}{{z}^{2}} + \frac{t \cdot x}{z}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020066 +o rules:numerics
(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 z)))) -7.623226303312042e-196) (* x (- (/ y z) (* t (/ 1 (- 1 z))))) (if (< (* x (- (/ y z) (/ t (- 1 z)))) 1.4133944927702302e-211) (+ (/ (* y x) z) (- (/ (* t x) (- 1 z)))) (* x (- (/ y z) (* t (/ 1 (- 1 z)))))))

  (* x (- (/ y z) (/ t (- 1 z)))))