Average Error: 4.6 → 1.6
Time: 6.3s
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 -1.7719375982154692 \cdot 10^{186} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le -2.16390322287129159 \cdot 10^{-24} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 2.379884009843327 \cdot 10^{-235} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 4.61028574925404029 \cdot 10^{228}\right)\right)\right):\\ \;\;\;\;\left(-x\right) \cdot \frac{t}{1 - z} + \frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(y, \frac{1}{z}, \frac{-t}{1 - z}\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 -1.7719375982154692 \cdot 10^{186} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le -2.16390322287129159 \cdot 10^{-24} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 2.379884009843327 \cdot 10^{-235} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 4.61028574925404029 \cdot 10^{228}\right)\right)\right):\\
\;\;\;\;\left(-x\right) \cdot \frac{t}{1 - z} + \frac{x \cdot y}{z}\\

\mathbf{else}:\\
\;\;\;\;x \cdot \mathsf{fma}\left(y, \frac{1}{z}, \frac{-t}{1 - 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 (((((y / z) - (t / (1.0 - z))) <= -1.7719375982154692e+186) || !((((y / z) - (t / (1.0 - z))) <= -2.1639032228712916e-24) || !((((y / z) - (t / (1.0 - z))) <= 2.379884009843327e-235) || !(((y / z) - (t / (1.0 - z))) <= 4.61028574925404e+228))))) {
		temp = ((-x * (t / (1.0 - z))) + ((x * y) / z));
	} else {
		temp = (x * fma(y, (1.0 / z), (-t / (1.0 - 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.6
Target4.2
Herbie1.6
\[\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))) < -1.7719375982154692e+186 or -2.1639032228712916e-24 < (- (/ y z) (/ t (- 1.0 z))) < 2.379884009843327e-235 or 4.61028574925404e+228 < (- (/ y z) (/ t (- 1.0 z)))

    1. Initial program 11.0

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot x\right)} \cdot \frac{\sqrt[3]{y}}{z} + \left(-x\right) \cdot \frac{t}{1 - z}\]
    14. Using strategy rm
    15. Applied pow15.1

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

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

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

      \[\leadsto \left(\left(\color{blue}{{\left(\sqrt[3]{y}\right)}^{1}} \cdot {\left(\sqrt[3]{y}\right)}^{1}\right) \cdot {x}^{1}\right) \cdot {\left(\frac{\sqrt[3]{y}}{z}\right)}^{1} + \left(-x\right) \cdot \frac{t}{1 - z}\]
    19. Applied pow-prod-down5.1

      \[\leadsto \left(\color{blue}{{\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right)}^{1}} \cdot {x}^{1}\right) \cdot {\left(\frac{\sqrt[3]{y}}{z}\right)}^{1} + \left(-x\right) \cdot \frac{t}{1 - z}\]
    20. Applied pow-prod-down5.1

      \[\leadsto \color{blue}{{\left(\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot x\right)}^{1}} \cdot {\left(\frac{\sqrt[3]{y}}{z}\right)}^{1} + \left(-x\right) \cdot \frac{t}{1 - z}\]
    21. Applied pow-prod-down5.1

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

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

    if -1.7719375982154692e+186 < (- (/ y z) (/ t (- 1.0 z))) < -2.1639032228712916e-24 or 2.379884009843327e-235 < (- (/ y z) (/ t (- 1.0 z))) < 4.61028574925404e+228

    1. Initial program 0.2

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \le -1.7719375982154692 \cdot 10^{186} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le -2.16390322287129159 \cdot 10^{-24} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 2.379884009843327 \cdot 10^{-235} \lor \neg \left(\frac{y}{z} - \frac{t}{1 - z} \le 4.61028574925404029 \cdot 10^{228}\right)\right)\right):\\ \;\;\;\;\left(-x\right) \cdot \frac{t}{1 - z} + \frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(y, \frac{1}{z}, \frac{-t}{1 - z}\right)\\ \end{array}\]

Reproduce

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