(FPCore (x y z t) :precision binary64 (* x (- (/ y z) (/ t (- 1.0 z)))))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (* x y) z)) (t_2 (* x (- (/ y z) (/ t (- 1.0 z))))))
(if (<= t_2 (- INFINITY))
(- t_1 (+ (* x t) (+ (* t (* x (pow z 2.0))) (* t (* x z)))))
(if (<= t_2 -3.6850752570351976e-273)
t_2
(if (<= t_2 3.254386259682045e-249)
(- t_1 (/ 1.0 (/ (- 1.0 z) (* x t))))
(if (<= t_2 5.424889879778089e+275)
t_2
(- (/ y (/ z x)) (/ (* x t) (- 1.0 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 t_1 = (x * y) / z;
double t_2 = x * ((y / z) - (t / (1.0 - z)));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1 - ((x * t) + ((t * (x * pow(z, 2.0))) + (t * (x * z))));
} else if (t_2 <= -3.6850752570351976e-273) {
tmp = t_2;
} else if (t_2 <= 3.254386259682045e-249) {
tmp = t_1 - (1.0 / ((1.0 - z) / (x * t)));
} else if (t_2 <= 5.424889879778089e+275) {
tmp = t_2;
} else {
tmp = (y / (z / x)) - ((x * t) / (1.0 - z));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
return x * ((y / z) - (t / (1.0 - z)));
}
public static double code(double x, double y, double z, double t) {
double t_1 = (x * y) / z;
double t_2 = x * ((y / z) - (t / (1.0 - z)));
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = t_1 - ((x * t) + ((t * (x * Math.pow(z, 2.0))) + (t * (x * z))));
} else if (t_2 <= -3.6850752570351976e-273) {
tmp = t_2;
} else if (t_2 <= 3.254386259682045e-249) {
tmp = t_1 - (1.0 / ((1.0 - z) / (x * t)));
} else if (t_2 <= 5.424889879778089e+275) {
tmp = t_2;
} else {
tmp = (y / (z / x)) - ((x * t) / (1.0 - z));
}
return tmp;
}
def code(x, y, z, t): return x * ((y / z) - (t / (1.0 - z)))
def code(x, y, z, t): t_1 = (x * y) / z t_2 = x * ((y / z) - (t / (1.0 - z))) tmp = 0 if t_2 <= -math.inf: tmp = t_1 - ((x * t) + ((t * (x * math.pow(z, 2.0))) + (t * (x * z)))) elif t_2 <= -3.6850752570351976e-273: tmp = t_2 elif t_2 <= 3.254386259682045e-249: tmp = t_1 - (1.0 / ((1.0 - z) / (x * t))) elif t_2 <= 5.424889879778089e+275: tmp = t_2 else: tmp = (y / (z / x)) - ((x * t) / (1.0 - z)) 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(x * y) / z) t_2 = Float64(x * Float64(Float64(y / z) - Float64(t / Float64(1.0 - z)))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(t_1 - Float64(Float64(x * t) + Float64(Float64(t * Float64(x * (z ^ 2.0))) + Float64(t * Float64(x * z))))); elseif (t_2 <= -3.6850752570351976e-273) tmp = t_2; elseif (t_2 <= 3.254386259682045e-249) tmp = Float64(t_1 - Float64(1.0 / Float64(Float64(1.0 - z) / Float64(x * t)))); elseif (t_2 <= 5.424889879778089e+275) tmp = t_2; else tmp = Float64(Float64(y / Float64(z / x)) - Float64(Float64(x * t) / Float64(1.0 - z))); end return tmp end
function tmp = code(x, y, z, t) tmp = x * ((y / z) - (t / (1.0 - z))); end
function tmp_2 = code(x, y, z, t) t_1 = (x * y) / z; t_2 = x * ((y / z) - (t / (1.0 - z))); tmp = 0.0; if (t_2 <= -Inf) tmp = t_1 - ((x * t) + ((t * (x * (z ^ 2.0))) + (t * (x * z)))); elseif (t_2 <= -3.6850752570351976e-273) tmp = t_2; elseif (t_2 <= 3.254386259682045e-249) tmp = t_1 - (1.0 / ((1.0 - z) / (x * t))); elseif (t_2 <= 5.424889879778089e+275) tmp = t_2; else tmp = (y / (z / x)) - ((x * t) / (1.0 - z)); end tmp_2 = 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[(x * y), $MachinePrecision] / z), $MachinePrecision]}, Block[{t$95$2 = N[(x * N[(N[(y / z), $MachinePrecision] - N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(t$95$1 - N[(N[(x * t), $MachinePrecision] + N[(N[(t * N[(x * N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -3.6850752570351976e-273], t$95$2, If[LessEqual[t$95$2, 3.254386259682045e-249], N[(t$95$1 - N[(1.0 / N[(N[(1.0 - z), $MachinePrecision] / N[(x * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5.424889879778089e+275], t$95$2, N[(N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision] - N[(N[(x * t), $MachinePrecision] / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
t_1 := \frac{x \cdot y}{z}\\
t_2 := x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_1 - \left(x \cdot t + \left(t \cdot \left(x \cdot {z}^{2}\right) + t \cdot \left(x \cdot z\right)\right)\right)\\
\mathbf{elif}\;t_2 \leq -3.6850752570351976 \cdot 10^{-273}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_2 \leq 3.254386259682045 \cdot 10^{-249}:\\
\;\;\;\;t_1 - \frac{1}{\frac{1 - z}{x \cdot t}}\\
\mathbf{elif}\;t_2 \leq 5.424889879778089 \cdot 10^{+275}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{x}} - \frac{x \cdot t}{1 - z}\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 4.6 |
|---|---|
| Target | 4.3 |
| Herbie | 1.3 |
if (*.f64 x (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z)))) < -inf.0Initial program 64.0
Applied egg-rr64.0
Taylor expanded in z around 0 0.3
if -inf.0 < (*.f64 x (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z)))) < -3.68507525703519758e-273 or 3.2543862596820452e-249 < (*.f64 x (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z)))) < 5.424889879778089e275Initial program 0.3
Taylor expanded in y around 0 8.0
Taylor expanded in x around -inf 0.3
if -3.68507525703519758e-273 < (*.f64 x (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z)))) < 3.2543862596820452e-249Initial program 6.3
Taylor expanded in y around 0 1.9
Applied egg-rr1.9
Applied egg-rr2.9
if 5.424889879778089e275 < (*.f64 x (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z)))) Initial program 37.5
Taylor expanded in y around 0 10.0
Applied egg-rr12.8
Final simplification1.3
herbie shell --seed 2022150
(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)))))