Average Error: 4.5 → 3.7
Time: 5.9s
Precision: 64
\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \le -3.6719810849065342 \cdot 10^{-160} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 0.0\right):\\ \;\;\;\;x \cdot \left(\mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z}\right) + \mathsf{fma}\left(-\frac{t}{1 - z}, 1, t \cdot \frac{1}{1 - z}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{x}{z}, \mathsf{fma}\left(1, \frac{t \cdot x}{{z}^{2}}, \frac{t \cdot x}{z}\right)\right)\\ \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} \le -3.6719810849065342 \cdot 10^{-160} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 0.0\right):\\
\;\;\;\;x \cdot \left(\mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z}\right) + \mathsf{fma}\left(-\frac{t}{1 - z}, 1, t \cdot \frac{1}{1 - z}\right)\right)\\

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

\end{array}
double code(double x, double y, double z, double t) {
	return ((double) (x * ((double) (((double) (y / z)) - ((double) (t / ((double) (1.0 - z))))))));
}
double code(double x, double y, double z, double t) {
	double VAR;
	if (((((double) (((double) (y / z)) - ((double) (t / ((double) (1.0 - z)))))) <= -3.671981084906534e-160) || !(((double) (((double) (y / z)) - ((double) (t / ((double) (1.0 - z)))))) <= 0.0))) {
		VAR = ((double) (x * ((double) (((double) fma(y, ((double) (1.0 / z)), ((double) -(((double) (t / ((double) (1.0 - z)))))))) + ((double) fma(((double) -(((double) (t / ((double) (1.0 - z)))))), 1.0, ((double) (t * ((double) (1.0 / ((double) (1.0 - z))))))))))));
	} else {
		VAR = ((double) fma(y, ((double) (x / z)), ((double) fma(1.0, ((double) (((double) (t * x)) / ((double) pow(z, 2.0)))), ((double) (((double) (t * x)) / z))))));
	}
	return VAR;
}

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.1
Herbie3.7
\[\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 (- (/ y z) (/ t (- 1.0 z))) < -3.671981084906534e-160 or 0.0 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 3.8

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

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

      \[\leadsto x \cdot \left(\color{blue}{y \cdot \frac{1}{z}} - \left(\sqrt[3]{\frac{t}{1 - z}} \cdot \sqrt[3]{\frac{t}{1 - z}}\right) \cdot \sqrt[3]{\frac{t}{1 - z}}\right)\]
    5. Applied prod-diff4.3

      \[\leadsto x \cdot \color{blue}{\left(\mathsf{fma}\left(y, \frac{1}{z}, -\sqrt[3]{\frac{t}{1 - z}} \cdot \left(\sqrt[3]{\frac{t}{1 - z}} \cdot \sqrt[3]{\frac{t}{1 - z}}\right)\right) + \mathsf{fma}\left(-\sqrt[3]{\frac{t}{1 - z}}, \sqrt[3]{\frac{t}{1 - z}} \cdot \sqrt[3]{\frac{t}{1 - z}}, \sqrt[3]{\frac{t}{1 - z}} \cdot \left(\sqrt[3]{\frac{t}{1 - z}} \cdot \sqrt[3]{\frac{t}{1 - z}}\right)\right)\right)}\]
    6. Simplified3.9

      \[\leadsto x \cdot \left(\color{blue}{\mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z}\right)} + \mathsf{fma}\left(-\sqrt[3]{\frac{t}{1 - z}}, \sqrt[3]{\frac{t}{1 - z}} \cdot \sqrt[3]{\frac{t}{1 - z}}, \sqrt[3]{\frac{t}{1 - z}} \cdot \left(\sqrt[3]{\frac{t}{1 - z}} \cdot \sqrt[3]{\frac{t}{1 - z}}\right)\right)\right)\]
    7. Simplified3.9

      \[\leadsto x \cdot \left(\mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z}\right) + \color{blue}{\mathsf{fma}\left(-\frac{t}{1 - z}, 1, \frac{t}{1 - z}\right)}\right)\]
    8. Using strategy rm
    9. Applied div-inv3.9

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

    if -3.671981084906534e-160 < (- (/ y z) (/ t (- 1.0 z))) < 0.0

    1. Initial program 9.9

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

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

      \[\leadsto x \cdot \left(\color{blue}{y \cdot \frac{1}{z}} - \left(\sqrt[3]{\frac{t}{1 - z}} \cdot \sqrt[3]{\frac{t}{1 - z}}\right) \cdot \sqrt[3]{\frac{t}{1 - z}}\right)\]
    5. Applied prod-diff10.1

      \[\leadsto x \cdot \color{blue}{\left(\mathsf{fma}\left(y, \frac{1}{z}, -\sqrt[3]{\frac{t}{1 - z}} \cdot \left(\sqrt[3]{\frac{t}{1 - z}} \cdot \sqrt[3]{\frac{t}{1 - z}}\right)\right) + \mathsf{fma}\left(-\sqrt[3]{\frac{t}{1 - z}}, \sqrt[3]{\frac{t}{1 - z}} \cdot \sqrt[3]{\frac{t}{1 - z}}, \sqrt[3]{\frac{t}{1 - z}} \cdot \left(\sqrt[3]{\frac{t}{1 - z}} \cdot \sqrt[3]{\frac{t}{1 - z}}\right)\right)\right)}\]
    6. Simplified10.0

      \[\leadsto x \cdot \left(\color{blue}{\mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z}\right)} + \mathsf{fma}\left(-\sqrt[3]{\frac{t}{1 - z}}, \sqrt[3]{\frac{t}{1 - z}} \cdot \sqrt[3]{\frac{t}{1 - z}}, \sqrt[3]{\frac{t}{1 - z}} \cdot \left(\sqrt[3]{\frac{t}{1 - z}} \cdot \sqrt[3]{\frac{t}{1 - z}}\right)\right)\right)\]
    7. Simplified10.0

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z} + \left(1 \cdot \frac{t \cdot x}{{z}^{2}} + \frac{t \cdot x}{z}\right)}\]
    9. Simplified2.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \le -3.6719810849065342 \cdot 10^{-160} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 0.0\right):\\ \;\;\;\;x \cdot \left(\mathsf{fma}\left(y, \frac{1}{z}, -\frac{t}{1 - z}\right) + \mathsf{fma}\left(-\frac{t}{1 - z}, 1, t \cdot \frac{1}{1 - z}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{x}{z}, \mathsf{fma}\left(1, \frac{t \cdot x}{{z}^{2}}, \frac{t \cdot x}{z}\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020114 +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)))))