Average Error: 4.7 → 0.7
Time: 5.1s
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 -6.47911217694995 \cdot 10^{+111}:\\ \;\;\;\;y \cdot \frac{x}{z} - \frac{t}{1 - z} \cdot x\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq -2.102509075217015 \cdot 10^{-242}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - z}\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq 5.7450177110158 \cdot 10^{-315}:\\ \;\;\;\;\frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \frac{y}{\sqrt[3]{z}} - \frac{t \cdot x}{1 - z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq 1.0778704636607535 \cdot 10^{+188}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{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 -6.47911217694995 \cdot 10^{+111}:\\
\;\;\;\;y \cdot \frac{x}{z} - \frac{t}{1 - z} \cdot x\\

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

\mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq 5.7450177110158 \cdot 10^{-315}:\\
\;\;\;\;\frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \frac{y}{\sqrt[3]{z}} - \frac{t \cdot x}{1 - z}\\

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

\mathbf{else}:\\
\;\;\;\;y \cdot \frac{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))) -6.47911217694995e+111)
   (- (* y (/ x z)) (* (/ t (- 1.0 z)) x))
   (if (<= (- (/ y z) (/ t (- 1.0 z))) -2.102509075217015e-242)
     (* x (- (/ y z) (* t (/ 1.0 (- 1.0 z)))))
     (if (<= (- (/ y z) (/ t (- 1.0 z))) 5.7450177110158e-315)
       (- (* (/ x (* (cbrt z) (cbrt z))) (/ y (cbrt z))) (/ (* t x) (- 1.0 z)))
       (if (<= (- (/ y z) (/ t (- 1.0 z))) 1.0778704636607535e+188)
         (* x (- (/ y z) (* t (/ 1.0 (- 1.0 z)))))
         (- (* y (/ x z)) (* (/ t (- 1.0 z)) x)))))))
double code(double x, double y, double z, double t) {
	return ((double) (x * ((double) ((y / z) - (t / ((double) (1.0 - z)))))));
}
double code(double x, double y, double z, double t) {
	double tmp;
	if ((((double) ((y / z) - (t / ((double) (1.0 - z))))) <= -6.47911217694995e+111)) {
		tmp = ((double) (((double) (y * (x / z))) - ((double) ((t / ((double) (1.0 - z))) * x))));
	} else {
		double tmp_1;
		if ((((double) ((y / z) - (t / ((double) (1.0 - z))))) <= -2.102509075217015e-242)) {
			tmp_1 = ((double) (x * ((double) ((y / z) - ((double) (t * (1.0 / ((double) (1.0 - z)))))))));
		} else {
			double tmp_2;
			if ((((double) ((y / z) - (t / ((double) (1.0 - z))))) <= 5.7450177110158e-315)) {
				tmp_2 = ((double) (((double) ((x / ((double) (((double) cbrt(z)) * ((double) cbrt(z))))) * (y / ((double) cbrt(z))))) - (((double) (t * x)) / ((double) (1.0 - z)))));
			} else {
				double tmp_3;
				if ((((double) ((y / z) - (t / ((double) (1.0 - z))))) <= 1.0778704636607535e+188)) {
					tmp_3 = ((double) (x * ((double) ((y / z) - ((double) (t * (1.0 / ((double) (1.0 - z)))))))));
				} else {
					tmp_3 = ((double) (((double) (y * (x / z))) - ((double) ((t / ((double) (1.0 - z))) * x))));
				}
				tmp_2 = tmp_3;
			}
			tmp_1 = tmp_2;
		}
		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.7
Target4.5
Herbie0.7
\[\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 3 regimes
  2. if (-.f64 (/.f64 y z) (/.f64 t (-.f64 1.0 z))) < -6.47911217694994992e111 or 1.07787046366075349e188 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1.0 z)))

    1. Initial program 14.1

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

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

      \[\leadsto \color{blue}{x \cdot \frac{y}{z} + x \cdot \left(-\frac{t}{1 - z}\right)}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt_binary6414.6

      \[\leadsto x \cdot \frac{y}{\color{blue}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}}} + x \cdot \left(-\frac{t}{1 - z}\right)\]
    7. Applied *-un-lft-identity_binary6414.6

      \[\leadsto x \cdot \frac{\color{blue}{1 \cdot y}}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}} + x \cdot \left(-\frac{t}{1 - z}\right)\]
    8. Applied times-frac_binary6414.6

      \[\leadsto x \cdot \color{blue}{\left(\frac{1}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \frac{y}{\sqrt[3]{z}}\right)} + x \cdot \left(-\frac{t}{1 - z}\right)\]
    9. Applied associate-*r*_binary644.6

      \[\leadsto \color{blue}{\left(x \cdot \frac{1}{\sqrt[3]{z} \cdot \sqrt[3]{z}}\right) \cdot \frac{y}{\sqrt[3]{z}}} + x \cdot \left(-\frac{t}{1 - z}\right)\]
    10. Simplified4.6

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

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

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

    if -6.47911217694994992e111 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1.0 z))) < -2.10250907521701493e-242 or 5.745017711e-315 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1.0 z))) < 1.07787046366075349e188

    1. Initial program 0.2

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

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

    if -2.10250907521701493e-242 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1.0 z))) < 5.745017711e-315

    1. Initial program 13.8

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

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

      \[\leadsto \color{blue}{x \cdot \frac{y}{z} + x \cdot \left(-\frac{t}{1 - z}\right)}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt_binary6413.9

      \[\leadsto x \cdot \frac{y}{\color{blue}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}}} + x \cdot \left(-\frac{t}{1 - z}\right)\]
    7. Applied *-un-lft-identity_binary6413.9

      \[\leadsto x \cdot \frac{\color{blue}{1 \cdot y}}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}} + x \cdot \left(-\frac{t}{1 - z}\right)\]
    8. Applied times-frac_binary6413.9

      \[\leadsto x \cdot \color{blue}{\left(\frac{1}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \frac{y}{\sqrt[3]{z}}\right)} + x \cdot \left(-\frac{t}{1 - z}\right)\]
    9. Applied associate-*r*_binary647.4

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

      \[\leadsto \color{blue}{\frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}}} \cdot \frac{y}{\sqrt[3]{z}} + x \cdot \left(-\frac{t}{1 - z}\right)\]
    11. Using strategy rm
    12. Applied distribute-neg-frac_binary647.4

      \[\leadsto \frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \frac{y}{\sqrt[3]{z}} + x \cdot \color{blue}{\frac{-t}{1 - z}}\]
    13. Applied associate-*r/_binary640.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \leq -6.47911217694995 \cdot 10^{+111}:\\ \;\;\;\;y \cdot \frac{x}{z} - \frac{t}{1 - z} \cdot x\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq -2.102509075217015 \cdot 10^{-242}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - z}\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq 5.7450177110158 \cdot 10^{-315}:\\ \;\;\;\;\frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \frac{y}{\sqrt[3]{z}} - \frac{t \cdot x}{1 - z}\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq 1.0778704636607535 \cdot 10^{+188}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z} - \frac{t}{1 - z} \cdot x\\ \end{array}\]

Reproduce

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