Average Error: 4.8 → 1.4
Time: 23.7s
Precision: binary64
\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
\[\begin{array}{l} t_1 := \frac{y \cdot x}{z} - t \cdot \left(x + z \cdot x\right)\\ t_2 := \frac{t}{1 - z}\\ t_3 := \frac{y}{z} - t_2\\ \mathbf{if}\;t_3 \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_3 \leq 9.023942997923525 \cdot 10^{+270}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(1, \frac{y}{z}, -t_2\right) + x \cdot \left(t_2 - t_2\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (* x (- (/ y z) (/ t (- 1.0 z)))))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (/ (* y x) z) (* t (+ x (* z x)))))
        (t_2 (/ t (- 1.0 z)))
        (t_3 (- (/ y z) t_2)))
   (if (<= t_3 (- INFINITY))
     t_1
     (if (<= t_3 9.023942997923525e+270)
       (+ (* x (fma 1.0 (/ y z) (- t_2))) (* x (- t_2 t_2)))
       t_1))))
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 t_1 = ((y * x) / z) - (t * (x + (z * x)));
	double t_2 = t / (1.0 - z);
	double t_3 = (y / z) - t_2;
	double tmp;
	if (t_3 <= -((double) INFINITY)) {
		tmp = t_1;
	} else if (t_3 <= 9.023942997923525e+270) {
		tmp = (x * fma(1.0, (y / z), -t_2)) + (x * (t_2 - t_2));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t)
	return Float64(x * Float64(Float64(y / z) - Float64(t / Float64(1.0 - z))))
end
function code(x, y, z, t)
	t_1 = Float64(Float64(Float64(y * x) / z) - Float64(t * Float64(x + Float64(z * x))))
	t_2 = Float64(t / Float64(1.0 - z))
	t_3 = Float64(Float64(y / z) - t_2)
	tmp = 0.0
	if (t_3 <= Float64(-Inf))
		tmp = t_1;
	elseif (t_3 <= 9.023942997923525e+270)
		tmp = Float64(Float64(x * fma(1.0, Float64(y / z), Float64(-t_2))) + Float64(x * Float64(t_2 - t_2)));
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_] := N[(x * N[(N[(y / z), $MachinePrecision] - N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision] - N[(t * N[(x + N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(y / z), $MachinePrecision] - t$95$2), $MachinePrecision]}, If[LessEqual[t$95$3, (-Infinity)], t$95$1, If[LessEqual[t$95$3, 9.023942997923525e+270], N[(N[(x * N[(1.0 * N[(y / z), $MachinePrecision] + (-t$95$2)), $MachinePrecision]), $MachinePrecision] + N[(x * N[(t$95$2 - t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
t_1 := \frac{y \cdot x}{z} - t \cdot \left(x + z \cdot x\right)\\
t_2 := \frac{t}{1 - z}\\
t_3 := \frac{y}{z} - t_2\\
\mathbf{if}\;t_3 \leq -\infty:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_3 \leq 9.023942997923525 \cdot 10^{+270}:\\
\;\;\;\;x \cdot \mathsf{fma}\left(1, \frac{y}{z}, -t_2\right) + x \cdot \left(t_2 - t_2\right)\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.8
Target4.4
Herbie1.4
\[\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 2 regimes
  2. if (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < -inf.0 or 9.02394299792352489e270 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z)))

    1. Initial program 48.2

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
    2. Applied add-cube-cbrt_binary6448.5

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

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

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

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

    if -inf.0 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < 9.02394299792352489e270

    1. Initial program 1.4

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
    2. Applied add-cube-cbrt_binary642.4

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

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

      \[\leadsto \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(\sqrt[3]{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)\right) \]
    5. Applied *-un-lft-identity_binary642.5

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

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

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

      \[\leadsto \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(\sqrt[3]{x} \cdot \color{blue}{\left(\mathsf{fma}\left(\frac{1}{1}, \frac{y}{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)}\right) \]
    9. Applied distribute-lft-in_binary642.5

      \[\leadsto \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \color{blue}{\left(\sqrt[3]{x} \cdot \mathsf{fma}\left(\frac{1}{1}, \frac{y}{z}, -\sqrt[3]{\frac{t}{1 - z}} \cdot \left(\sqrt[3]{\frac{t}{1 - z}} \cdot \sqrt[3]{\frac{t}{1 - z}}\right)\right) + \sqrt[3]{x} \cdot \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)} \]
    10. Applied distribute-lft-in_binary642.5

      \[\leadsto \color{blue}{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(\sqrt[3]{x} \cdot \mathsf{fma}\left(\frac{1}{1}, \frac{y}{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) + \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(\sqrt[3]{x} \cdot \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)} \]
    11. Simplified1.4

      \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(1, \frac{y}{z}, -\frac{t}{1 - z}\right)} + \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(\sqrt[3]{x} \cdot \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) \]
    12. Simplified1.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} - \frac{t}{1 - z} \leq -\infty:\\ \;\;\;\;\frac{y \cdot x}{z} - t \cdot \left(x + z \cdot x\right)\\ \mathbf{elif}\;\frac{y}{z} - \frac{t}{1 - z} \leq 9.023942997923525 \cdot 10^{+270}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(1, \frac{y}{z}, -\frac{t}{1 - z}\right) + x \cdot \left(\frac{t}{1 - z} - \frac{t}{1 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z} - t \cdot \left(x + z \cdot x\right)\\ \end{array} \]

Reproduce

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