(FPCore (x y z t a) :precision binary64 (/ (* (* x y) z) (sqrt (- (* z z) (* t a)))))
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (/ a z) t))
(t_2 (sqrt (* a (- t))))
(t_3 (/ z (sqrt (- (* z z) (* a t))))))
(if (<= z -1e+154)
(/ (* y x) (/ (- (* 0.5 t_1) z) z))
(if (<= z -1.9e-160)
(* y (* x t_3))
(if (<= z 9e-143)
(* x (/ (* z y) (fma 0.5 (/ z (/ t_2 z)) t_2)))
(if (<= z 1.5e+116)
(* (* y x) t_3)
(/ (* y x) (/ (+ z (* t_1 -0.5)) z))))))))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 t_1 = (a / z) * t;
double t_2 = sqrt((a * -t));
double t_3 = z / sqrt(((z * z) - (a * t)));
double tmp;
if (z <= -1e+154) {
tmp = (y * x) / (((0.5 * t_1) - z) / z);
} else if (z <= -1.9e-160) {
tmp = y * (x * t_3);
} else if (z <= 9e-143) {
tmp = x * ((z * y) / fma(0.5, (z / (t_2 / z)), t_2));
} else if (z <= 1.5e+116) {
tmp = (y * x) * t_3;
} else {
tmp = (y * x) / ((z + (t_1 * -0.5)) / z);
}
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) t_1 = Float64(Float64(a / z) * t) t_2 = sqrt(Float64(a * Float64(-t))) t_3 = Float64(z / sqrt(Float64(Float64(z * z) - Float64(a * t)))) tmp = 0.0 if (z <= -1e+154) tmp = Float64(Float64(y * x) / Float64(Float64(Float64(0.5 * t_1) - z) / z)); elseif (z <= -1.9e-160) tmp = Float64(y * Float64(x * t_3)); elseif (z <= 9e-143) tmp = Float64(x * Float64(Float64(z * y) / fma(0.5, Float64(z / Float64(t_2 / z)), t_2))); elseif (z <= 1.5e+116) tmp = Float64(Float64(y * x) * t_3); else tmp = Float64(Float64(y * x) / Float64(Float64(z + Float64(t_1 * -0.5)) / z)); 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_] := Block[{t$95$1 = N[(N[(a / z), $MachinePrecision] * t), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(a * (-t)), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(z / N[Sqrt[N[(N[(z * z), $MachinePrecision] - N[(a * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1e+154], N[(N[(y * x), $MachinePrecision] / N[(N[(N[(0.5 * t$95$1), $MachinePrecision] - z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -1.9e-160], N[(y * N[(x * t$95$3), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 9e-143], N[(x * N[(N[(z * y), $MachinePrecision] / N[(0.5 * N[(z / N[(t$95$2 / z), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.5e+116], N[(N[(y * x), $MachinePrecision] * t$95$3), $MachinePrecision], N[(N[(y * x), $MachinePrecision] / N[(N[(z + N[(t$95$1 * -0.5), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]]]]]]
\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}
\begin{array}{l}
t_1 := \frac{a}{z} \cdot t\\
t_2 := \sqrt{a \cdot \left(-t\right)}\\
t_3 := \frac{z}{\sqrt{z \cdot z - a \cdot t}}\\
\mathbf{if}\;z \leq -1 \cdot 10^{+154}:\\
\;\;\;\;\frac{y \cdot x}{\frac{0.5 \cdot t_1 - z}{z}}\\
\mathbf{elif}\;z \leq -1.9 \cdot 10^{-160}:\\
\;\;\;\;y \cdot \left(x \cdot t_3\right)\\
\mathbf{elif}\;z \leq 9 \cdot 10^{-143}:\\
\;\;\;\;x \cdot \frac{z \cdot y}{\mathsf{fma}\left(0.5, \frac{z}{\frac{t_2}{z}}, t_2\right)}\\
\mathbf{elif}\;z \leq 1.5 \cdot 10^{+116}:\\
\;\;\;\;\left(y \cdot x\right) \cdot t_3\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{\frac{z + t_1 \cdot -0.5}{z}}\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t




Bits error versus a
| Original | 25.1 |
|---|---|
| Target | 8.0 |
| Herbie | 5.8 |
if z < -1.00000000000000004e154Initial program 54.1
Simplified54.2
Applied egg-rr53.7
Taylor expanded in z around -inf 5.8
Simplified1.2
if -1.00000000000000004e154 < z < -1.8999999999999999e-160Initial program 9.6
Simplified9.5
Applied egg-rr5.7
Applied egg-rr5.2
if -1.8999999999999999e-160 < z < 9.00000000000000001e-143Initial program 18.7
Simplified17.0
Taylor expanded in z around 0 17.5
Simplified15.7
if 9.00000000000000001e-143 < z < 1.4999999999999999e116Initial program 7.9
Simplified8.3
Applied egg-rr4.5
Applied egg-rr4.5
if 1.4999999999999999e116 < z Initial program 46.4
Simplified46.7
Applied egg-rr43.9
Taylor expanded in z around inf 4.9
Simplified1.7
Final simplification5.8
herbie shell --seed 2022166
(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)))))