Average Error: 4.5 → 5.3
Time: 5.0s
Precision: binary64
\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\]
\[\begin{array}{l} \mathbf{if}\;z \leq -7.990743750263743 \cdot 10^{-268}:\\ \;\;\;\;x \cdot \frac{y}{z} - \left(x \cdot \left(\sqrt[3]{t} \cdot \sqrt[3]{t}\right)\right) \cdot \frac{\sqrt[3]{t}}{1 - z}\\ \mathbf{elif}\;z \leq 1.4490584958334922 \cdot 10^{+107} \lor \neg \left(z \leq 3.4122879858986516 \cdot 10^{+246}\right):\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{z} - x \cdot \frac{t}{1 - z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{z} - \frac{x}{1 + \sqrt{z}} \cdot \frac{t}{1 - \sqrt{z}}\\ \end{array}\]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
\mathbf{if}\;z \leq -7.990743750263743 \cdot 10^{-268}:\\
\;\;\;\;x \cdot \frac{y}{z} - \left(x \cdot \left(\sqrt[3]{t} \cdot \sqrt[3]{t}\right)\right) \cdot \frac{\sqrt[3]{t}}{1 - z}\\

\mathbf{elif}\;z \leq 1.4490584958334922 \cdot 10^{+107} \lor \neg \left(z \leq 3.4122879858986516 \cdot 10^{+246}\right):\\
\;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{z} - x \cdot \frac{t}{1 - z}\\

\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{z} - \frac{x}{1 + \sqrt{z}} \cdot \frac{t}{1 - \sqrt{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 (<= z -7.990743750263743e-268)
   (- (* x (/ y z)) (* (* x (* (cbrt t) (cbrt t))) (/ (cbrt t) (- 1.0 z))))
   (if (or (<= z 1.4490584958334922e+107) (not (<= z 3.4122879858986516e+246)))
     (- (* (* x y) (/ 1.0 z)) (* x (/ t (- 1.0 z))))
     (- (* x (/ y z)) (* (/ x (+ 1.0 (sqrt z))) (/ t (- 1.0 (sqrt 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 (z <= -7.990743750263743e-268) {
		tmp = (x * (y / z)) - ((x * (cbrt(t) * cbrt(t))) * (cbrt(t) / (1.0 - z)));
	} else if ((z <= 1.4490584958334922e+107) || !(z <= 3.4122879858986516e+246)) {
		tmp = ((x * y) * (1.0 / z)) - (x * (t / (1.0 - z)));
	} else {
		tmp = (x * (y / z)) - ((x / (1.0 + sqrt(z))) * (t / (1.0 - sqrt(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.5
Target4.3
Herbie5.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 3 regimes
  2. if z < -7.9907437502637426e-268

    1. Initial program 4.6

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

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

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

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

      \[\leadsto x \cdot \frac{y}{z} + \color{blue}{x \cdot \left(-\frac{t}{1 - z}\right)}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity_binary64_149054.6

      \[\leadsto x \cdot \frac{y}{z} + x \cdot \left(-\frac{t}{\color{blue}{1 \cdot \left(1 - z\right)}}\right)\]
    9. Applied add-cube-cbrt_binary64_149375.1

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

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

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

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

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

    if -7.9907437502637426e-268 < z < 1.44905849583349222e107 or 3.4122879858986516e246 < z

    1. Initial program 5.3

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

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

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

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

      \[\leadsto x \cdot \frac{y}{z} + \color{blue}{x \cdot \left(-\frac{t}{1 - z}\right)}\]
    7. Using strategy rm
    8. Applied div-inv_binary64_149025.4

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

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

    if 1.44905849583349222e107 < z < 3.4122879858986516e246

    1. Initial program 1.8

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

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

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

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

      \[\leadsto x \cdot \frac{y}{z} + \color{blue}{x \cdot \left(-\frac{t}{1 - z}\right)}\]
    7. Using strategy rm
    8. Applied add-sqr-sqrt_binary64_149262.0

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

      \[\leadsto x \cdot \frac{y}{z} + x \cdot \left(-\frac{t}{\color{blue}{1 \cdot 1} - \sqrt{z} \cdot \sqrt{z}}\right)\]
    10. Applied difference-of-squares_binary64_148742.0

      \[\leadsto x \cdot \frac{y}{z} + x \cdot \left(-\frac{t}{\color{blue}{\left(1 + \sqrt{z}\right) \cdot \left(1 - \sqrt{z}\right)}}\right)\]
    11. Applied *-un-lft-identity_binary64_149052.0

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7.990743750263743 \cdot 10^{-268}:\\ \;\;\;\;x \cdot \frac{y}{z} - \left(x \cdot \left(\sqrt[3]{t} \cdot \sqrt[3]{t}\right)\right) \cdot \frac{\sqrt[3]{t}}{1 - z}\\ \mathbf{elif}\;z \leq 1.4490584958334922 \cdot 10^{+107} \lor \neg \left(z \leq 3.4122879858986516 \cdot 10^{+246}\right):\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{z} - x \cdot \frac{t}{1 - z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{z} - \frac{x}{1 + \sqrt{z}} \cdot \frac{t}{1 - \sqrt{z}}\\ \end{array}\]

Reproduce

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