(FPCore (x y z t a) :precision binary64 (/ (* (* x y) z) (sqrt (- (* z z) (* t a)))))
(FPCore (x y z t a)
:precision binary64
(if (<= z -1.75e+99)
(* x (- y))
(if (<= z -3e-167)
(* (sqrt (/ 1.0 (fma t (- a) (* z z)))) (* x (* z y)))
(if (<= z 1.28e-68)
(/ x (/ (hypot (sqrt (* t (- a))) z) (* z y)))
(if (<= z 1.05e+98)
(/ (* z (* x y)) (sqrt (- (* z z) (* t a))))
(* x y))))))double code(double x, double y, double z, double t, double a) {
return ((x * y) * z) / sqrt(((z * z) - (t * a)));
}
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.75e+99) {
tmp = x * -y;
} else if (z <= -3e-167) {
tmp = sqrt((1.0 / fma(t, -a, (z * z)))) * (x * (z * y));
} else if (z <= 1.28e-68) {
tmp = x / (hypot(sqrt((t * -a)), z) / (z * y));
} else if (z <= 1.05e+98) {
tmp = (z * (x * y)) / sqrt(((z * z) - (t * a)));
} else {
tmp = x * y;
}
return tmp;
}
function code(x, y, z, t, a) return Float64(Float64(Float64(x * y) * z) / sqrt(Float64(Float64(z * z) - Float64(t * a)))) end
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.75e+99) tmp = Float64(x * Float64(-y)); elseif (z <= -3e-167) tmp = Float64(sqrt(Float64(1.0 / fma(t, Float64(-a), Float64(z * z)))) * Float64(x * Float64(z * y))); elseif (z <= 1.28e-68) tmp = Float64(x / Float64(hypot(sqrt(Float64(t * Float64(-a))), z) / Float64(z * y))); elseif (z <= 1.05e+98) tmp = Float64(Float64(z * Float64(x * y)) / sqrt(Float64(Float64(z * z) - Float64(t * a)))); else tmp = Float64(x * y); end return tmp end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] * z), $MachinePrecision] / N[Sqrt[N[(N[(z * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.75e+99], N[(x * (-y)), $MachinePrecision], If[LessEqual[z, -3e-167], N[(N[Sqrt[N[(1.0 / N[(t * (-a) + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.28e-68], N[(x / N[(N[Sqrt[N[Sqrt[N[(t * (-a)), $MachinePrecision]], $MachinePrecision] ^ 2 + z ^ 2], $MachinePrecision] / N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.05e+98], N[(N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(z * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(x * y), $MachinePrecision]]]]]
\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\begin{array}{l}
\mathbf{if}\;z \leq -1.75 \cdot 10^{+99}:\\
\;\;\;\;x \cdot \left(-y\right)\\
\mathbf{elif}\;z \leq -3 \cdot 10^{-167}:\\
\;\;\;\;\sqrt{\frac{1}{\mathsf{fma}\left(t, -a, z \cdot z\right)}} \cdot \left(x \cdot \left(z \cdot y\right)\right)\\
\mathbf{elif}\;z \leq 1.28 \cdot 10^{-68}:\\
\;\;\;\;\frac{x}{\frac{\mathsf{hypot}\left(\sqrt{t \cdot \left(-a\right)}, z\right)}{z \cdot y}}\\
\mathbf{elif}\;z \leq 1.05 \cdot 10^{+98}:\\
\;\;\;\;\frac{z \cdot \left(x \cdot y\right)}{\sqrt{z \cdot z - t \cdot a}}\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t




Bits error versus a
| Original | 24.8 |
|---|---|
| Target | 7.3 |
| Herbie | 6.6 |
if z < -1.7499999999999999e99Initial program 44.2
Simplified44.0
Taylor expanded in z around -inf 1.7
Simplified1.7
if -1.7499999999999999e99 < z < -2.9999999999999998e-167Initial program 7.5
Taylor expanded in x around 0 9.7
Simplified9.6
if -2.9999999999999998e-167 < z < 1.27999999999999999e-68Initial program 15.5
Simplified14.6
Applied egg-rr14.7
Taylor expanded in y around 0 15.0
Simplified12.9
if 1.27999999999999999e-68 < z < 1.05000000000000002e98Initial program 6.4
if 1.05000000000000002e98 < z Initial program 43.3
Simplified43.9
Taylor expanded in z around inf 2.1
Final simplification6.6
herbie shell --seed 2022170
(FPCore (x y z t a)
:name "Statistics.Math.RootFinding:ridders from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(if (< z -3.1921305903852764e+46) (- (* y x)) (if (< z 5.976268120920894e+90) (/ (* x z) (/ (sqrt (- (* z z) (* a t))) y)) (* y x)))
(/ (* (* x y) z) (sqrt (- (* z z) (* t a)))))