
(FPCore (x l t) :precision binary64 (/ (* (sqrt 2.0) t) (sqrt (- (* (/ (+ x 1.0) (- x 1.0)) (+ (* l l) (* 2.0 (* t t)))) (* l l)))))
double code(double x, double l, double t) {
return (sqrt(2.0) * t) / sqrt(((((x + 1.0) / (x - 1.0)) * ((l * l) + (2.0 * (t * t)))) - (l * l)));
}
real(8) function code(x, l, t)
real(8), intent (in) :: x
real(8), intent (in) :: l
real(8), intent (in) :: t
code = (sqrt(2.0d0) * t) / sqrt(((((x + 1.0d0) / (x - 1.0d0)) * ((l * l) + (2.0d0 * (t * t)))) - (l * l)))
end function
public static double code(double x, double l, double t) {
return (Math.sqrt(2.0) * t) / Math.sqrt(((((x + 1.0) / (x - 1.0)) * ((l * l) + (2.0 * (t * t)))) - (l * l)));
}
def code(x, l, t): return (math.sqrt(2.0) * t) / math.sqrt(((((x + 1.0) / (x - 1.0)) * ((l * l) + (2.0 * (t * t)))) - (l * l)))
function code(x, l, t) return Float64(Float64(sqrt(2.0) * t) / sqrt(Float64(Float64(Float64(Float64(x + 1.0) / Float64(x - 1.0)) * Float64(Float64(l * l) + Float64(2.0 * Float64(t * t)))) - Float64(l * l)))) end
function tmp = code(x, l, t) tmp = (sqrt(2.0) * t) / sqrt(((((x + 1.0) / (x - 1.0)) * ((l * l) + (2.0 * (t * t)))) - (l * l))); end
code[x_, l_, t_] := N[(N[(N[Sqrt[2.0], $MachinePrecision] * t), $MachinePrecision] / N[Sqrt[N[(N[(N[(N[(x + 1.0), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] + N[(2.0 * N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(l * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt{2} \cdot t}{\sqrt{\frac{x + 1}{x - 1} \cdot \left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right) - \ell \cdot \ell}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x l t) :precision binary64 (/ (* (sqrt 2.0) t) (sqrt (- (* (/ (+ x 1.0) (- x 1.0)) (+ (* l l) (* 2.0 (* t t)))) (* l l)))))
double code(double x, double l, double t) {
return (sqrt(2.0) * t) / sqrt(((((x + 1.0) / (x - 1.0)) * ((l * l) + (2.0 * (t * t)))) - (l * l)));
}
real(8) function code(x, l, t)
real(8), intent (in) :: x
real(8), intent (in) :: l
real(8), intent (in) :: t
code = (sqrt(2.0d0) * t) / sqrt(((((x + 1.0d0) / (x - 1.0d0)) * ((l * l) + (2.0d0 * (t * t)))) - (l * l)))
end function
public static double code(double x, double l, double t) {
return (Math.sqrt(2.0) * t) / Math.sqrt(((((x + 1.0) / (x - 1.0)) * ((l * l) + (2.0 * (t * t)))) - (l * l)));
}
def code(x, l, t): return (math.sqrt(2.0) * t) / math.sqrt(((((x + 1.0) / (x - 1.0)) * ((l * l) + (2.0 * (t * t)))) - (l * l)))
function code(x, l, t) return Float64(Float64(sqrt(2.0) * t) / sqrt(Float64(Float64(Float64(Float64(x + 1.0) / Float64(x - 1.0)) * Float64(Float64(l * l) + Float64(2.0 * Float64(t * t)))) - Float64(l * l)))) end
function tmp = code(x, l, t) tmp = (sqrt(2.0) * t) / sqrt(((((x + 1.0) / (x - 1.0)) * ((l * l) + (2.0 * (t * t)))) - (l * l))); end
code[x_, l_, t_] := N[(N[(N[Sqrt[2.0], $MachinePrecision] * t), $MachinePrecision] / N[Sqrt[N[(N[(N[(N[(x + 1.0), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision] * N[(N[(l * l), $MachinePrecision] + N[(2.0 * N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(l * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt{2} \cdot t}{\sqrt{\frac{x + 1}{x - 1} \cdot \left(\ell \cdot \ell + 2 \cdot \left(t \cdot t\right)\right) - \ell \cdot \ell}}
\end{array}
l_m = (fabs.f64 l)
t_m = (fabs.f64 t)
t_s = (copysign.f64 1 t)
(FPCore (t_s x l_m t_m)
:precision binary64
(let* ((t_2 (* 2.0 (pow t_m 2.0)))
(t_3 (+ t_2 (pow l_m 2.0)))
(t_4
(*
t_m
(/
(sqrt 2.0)
(+
(* 0.5 (/ (+ t_3 t_3) (* t_m (* (sqrt 2.0) x))))
(* t_m (sqrt 2.0)))))))
(*
t_s
(if (<= t_m 1.9e-254)
t_4
(if (<= t_m 3.2e-199)
(/ (* t_m (sqrt (* 2.0 (fma x 0.5 -0.5)))) l_m)
(if (<= t_m 4.4e-159)
t_4
(if (<= t_m 3.5e-53)
(*
t_m
(/
(sqrt 2.0)
(sqrt
(+
(+ (* 2.0 (/ (pow t_m 2.0) x)) (+ t_2 (/ (pow l_m 2.0) x)))
(/ t_3 x)))))
(sqrt (/ (+ -1.0 x) (+ x 1.0))))))))))l_m = fabs(l);
t_m = fabs(t);
t_s = copysign(1.0, t);
double code(double t_s, double x, double l_m, double t_m) {
double t_2 = 2.0 * pow(t_m, 2.0);
double t_3 = t_2 + pow(l_m, 2.0);
double t_4 = t_m * (sqrt(2.0) / ((0.5 * ((t_3 + t_3) / (t_m * (sqrt(2.0) * x)))) + (t_m * sqrt(2.0))));
double tmp;
if (t_m <= 1.9e-254) {
tmp = t_4;
} else if (t_m <= 3.2e-199) {
tmp = (t_m * sqrt((2.0 * fma(x, 0.5, -0.5)))) / l_m;
} else if (t_m <= 4.4e-159) {
tmp = t_4;
} else if (t_m <= 3.5e-53) {
tmp = t_m * (sqrt(2.0) / sqrt((((2.0 * (pow(t_m, 2.0) / x)) + (t_2 + (pow(l_m, 2.0) / x))) + (t_3 / x))));
} else {
tmp = sqrt(((-1.0 + x) / (x + 1.0)));
}
return t_s * tmp;
}
l_m = abs(l) t_m = abs(t) t_s = copysign(1.0, t) function code(t_s, x, l_m, t_m) t_2 = Float64(2.0 * (t_m ^ 2.0)) t_3 = Float64(t_2 + (l_m ^ 2.0)) t_4 = Float64(t_m * Float64(sqrt(2.0) / Float64(Float64(0.5 * Float64(Float64(t_3 + t_3) / Float64(t_m * Float64(sqrt(2.0) * x)))) + Float64(t_m * sqrt(2.0))))) tmp = 0.0 if (t_m <= 1.9e-254) tmp = t_4; elseif (t_m <= 3.2e-199) tmp = Float64(Float64(t_m * sqrt(Float64(2.0 * fma(x, 0.5, -0.5)))) / l_m); elseif (t_m <= 4.4e-159) tmp = t_4; elseif (t_m <= 3.5e-53) tmp = Float64(t_m * Float64(sqrt(2.0) / sqrt(Float64(Float64(Float64(2.0 * Float64((t_m ^ 2.0) / x)) + Float64(t_2 + Float64((l_m ^ 2.0) / x))) + Float64(t_3 / x))))); else tmp = sqrt(Float64(Float64(-1.0 + x) / Float64(x + 1.0))); end return Float64(t_s * tmp) end
l_m = N[Abs[l], $MachinePrecision]
t_m = N[Abs[t], $MachinePrecision]
t_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, x_, l$95$m_, t$95$m_] := Block[{t$95$2 = N[(2.0 * N[Power[t$95$m, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 + N[Power[l$95$m, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$m * N[(N[Sqrt[2.0], $MachinePrecision] / N[(N[(0.5 * N[(N[(t$95$3 + t$95$3), $MachinePrecision] / N[(t$95$m * N[(N[Sqrt[2.0], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$m * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(t$95$s * If[LessEqual[t$95$m, 1.9e-254], t$95$4, If[LessEqual[t$95$m, 3.2e-199], N[(N[(t$95$m * N[Sqrt[N[(2.0 * N[(x * 0.5 + -0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / l$95$m), $MachinePrecision], If[LessEqual[t$95$m, 4.4e-159], t$95$4, If[LessEqual[t$95$m, 3.5e-53], N[(t$95$m * N[(N[Sqrt[2.0], $MachinePrecision] / N[Sqrt[N[(N[(N[(2.0 * N[(N[Power[t$95$m, 2.0], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] + N[(t$95$2 + N[(N[Power[l$95$m, 2.0], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$3 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[(-1.0 + x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]), $MachinePrecision]]]]
\begin{array}{l}
l_m = \left|\ell\right|
\\
t_m = \left|t\right|
\\
t_s = \mathsf{copysign}\left(1, t\right)
\\
\begin{array}{l}
t_2 := 2 \cdot {t_m}^{2}\\
t_3 := t_2 + {l_m}^{2}\\
t_4 := t_m \cdot \frac{\sqrt{2}}{0.5 \cdot \frac{t_3 + t_3}{t_m \cdot \left(\sqrt{2} \cdot x\right)} + t_m \cdot \sqrt{2}}\\
t_s \cdot \begin{array}{l}
\mathbf{if}\;t_m \leq 1.9 \cdot 10^{-254}:\\
\;\;\;\;t_4\\
\mathbf{elif}\;t_m \leq 3.2 \cdot 10^{-199}:\\
\;\;\;\;\frac{t_m \cdot \sqrt{2 \cdot \mathsf{fma}\left(x, 0.5, -0.5\right)}}{l_m}\\
\mathbf{elif}\;t_m \leq 4.4 \cdot 10^{-159}:\\
\;\;\;\;t_4\\
\mathbf{elif}\;t_m \leq 3.5 \cdot 10^{-53}:\\
\;\;\;\;t_m \cdot \frac{\sqrt{2}}{\sqrt{\left(2 \cdot \frac{{t_m}^{2}}{x} + \left(t_2 + \frac{{l_m}^{2}}{x}\right)\right) + \frac{t_3}{x}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{-1 + x}{x + 1}}\\
\end{array}
\end{array}
\end{array}
if t < 1.9000000000000001e-254 or 3.1999999999999999e-199 < t < 4.4e-159Initial program 27.4%
Simplified27.4%
Taylor expanded in x around inf 11.4%
if 1.9000000000000001e-254 < t < 3.1999999999999999e-199Initial program 2.0%
Simplified2.0%
Taylor expanded in l around inf 1.3%
*-commutative1.3%
associate--l+26.6%
sub-neg26.6%
metadata-eval26.6%
+-commutative26.6%
sub-neg26.6%
metadata-eval26.6%
+-commutative26.6%
Simplified26.6%
Taylor expanded in x around 0 52.6%
Taylor expanded in t around 0 52.8%
associate-*l/59.6%
*-commutative59.6%
fma-neg59.6%
metadata-eval59.6%
associate-*l*59.6%
sqrt-prod59.6%
associate-*l/52.5%
*-commutative52.5%
associate-*r/59.6%
Applied egg-rr59.6%
if 4.4e-159 < t < 3.49999999999999993e-53Initial program 37.6%
Simplified37.8%
Taylor expanded in x around inf 84.4%
if 3.49999999999999993e-53 < t Initial program 46.9%
Simplified46.8%
Taylor expanded in t around inf 92.0%
associate-*l*92.0%
+-commutative92.0%
sub-neg92.0%
metadata-eval92.0%
+-commutative92.0%
Simplified92.0%
Taylor expanded in t around 0 92.2%
Final simplification45.9%
l_m = (fabs.f64 l)
t_m = (fabs.f64 t)
t_s = (copysign.f64 1 t)
(FPCore (t_s x l_m t_m)
:precision binary64
(let* ((t_2 (* 2.0 (pow t_m 2.0))))
(*
t_s
(if (<= t_m 9.5e-196)
(/ (* t_m (sqrt (* 2.0 (fma x 0.5 -0.5)))) l_m)
(if (or (<= t_m 1e-159) (not (<= t_m 1.95e-53)))
(sqrt (/ (+ -1.0 x) (+ x 1.0)))
(*
t_m
(/
(sqrt 2.0)
(sqrt
(+
(+ (* 2.0 (/ (pow t_m 2.0) x)) (+ t_2 (/ (pow l_m 2.0) x)))
(/ (+ t_2 (pow l_m 2.0)) x))))))))))l_m = fabs(l);
t_m = fabs(t);
t_s = copysign(1.0, t);
double code(double t_s, double x, double l_m, double t_m) {
double t_2 = 2.0 * pow(t_m, 2.0);
double tmp;
if (t_m <= 9.5e-196) {
tmp = (t_m * sqrt((2.0 * fma(x, 0.5, -0.5)))) / l_m;
} else if ((t_m <= 1e-159) || !(t_m <= 1.95e-53)) {
tmp = sqrt(((-1.0 + x) / (x + 1.0)));
} else {
tmp = t_m * (sqrt(2.0) / sqrt((((2.0 * (pow(t_m, 2.0) / x)) + (t_2 + (pow(l_m, 2.0) / x))) + ((t_2 + pow(l_m, 2.0)) / x))));
}
return t_s * tmp;
}
l_m = abs(l) t_m = abs(t) t_s = copysign(1.0, t) function code(t_s, x, l_m, t_m) t_2 = Float64(2.0 * (t_m ^ 2.0)) tmp = 0.0 if (t_m <= 9.5e-196) tmp = Float64(Float64(t_m * sqrt(Float64(2.0 * fma(x, 0.5, -0.5)))) / l_m); elseif ((t_m <= 1e-159) || !(t_m <= 1.95e-53)) tmp = sqrt(Float64(Float64(-1.0 + x) / Float64(x + 1.0))); else tmp = Float64(t_m * Float64(sqrt(2.0) / sqrt(Float64(Float64(Float64(2.0 * Float64((t_m ^ 2.0) / x)) + Float64(t_2 + Float64((l_m ^ 2.0) / x))) + Float64(Float64(t_2 + (l_m ^ 2.0)) / x))))); end return Float64(t_s * tmp) end
l_m = N[Abs[l], $MachinePrecision]
t_m = N[Abs[t], $MachinePrecision]
t_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, x_, l$95$m_, t$95$m_] := Block[{t$95$2 = N[(2.0 * N[Power[t$95$m, 2.0], $MachinePrecision]), $MachinePrecision]}, N[(t$95$s * If[LessEqual[t$95$m, 9.5e-196], N[(N[(t$95$m * N[Sqrt[N[(2.0 * N[(x * 0.5 + -0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / l$95$m), $MachinePrecision], If[Or[LessEqual[t$95$m, 1e-159], N[Not[LessEqual[t$95$m, 1.95e-53]], $MachinePrecision]], N[Sqrt[N[(N[(-1.0 + x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(t$95$m * N[(N[Sqrt[2.0], $MachinePrecision] / N[Sqrt[N[(N[(N[(2.0 * N[(N[Power[t$95$m, 2.0], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] + N[(t$95$2 + N[(N[Power[l$95$m, 2.0], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$2 + N[Power[l$95$m, 2.0], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
l_m = \left|\ell\right|
\\
t_m = \left|t\right|
\\
t_s = \mathsf{copysign}\left(1, t\right)
\\
\begin{array}{l}
t_2 := 2 \cdot {t_m}^{2}\\
t_s \cdot \begin{array}{l}
\mathbf{if}\;t_m \leq 9.5 \cdot 10^{-196}:\\
\;\;\;\;\frac{t_m \cdot \sqrt{2 \cdot \mathsf{fma}\left(x, 0.5, -0.5\right)}}{l_m}\\
\mathbf{elif}\;t_m \leq 10^{-159} \lor \neg \left(t_m \leq 1.95 \cdot 10^{-53}\right):\\
\;\;\;\;\sqrt{\frac{-1 + x}{x + 1}}\\
\mathbf{else}:\\
\;\;\;\;t_m \cdot \frac{\sqrt{2}}{\sqrt{\left(2 \cdot \frac{{t_m}^{2}}{x} + \left(t_2 + \frac{{l_m}^{2}}{x}\right)\right) + \frac{t_2 + {l_m}^{2}}{x}}}\\
\end{array}
\end{array}
\end{array}
if t < 9.50000000000000032e-196Initial program 26.0%
Simplified26.0%
Taylor expanded in l around inf 3.0%
*-commutative3.0%
associate--l+8.4%
sub-neg8.4%
metadata-eval8.4%
+-commutative8.4%
sub-neg8.4%
metadata-eval8.4%
+-commutative8.4%
Simplified8.4%
Taylor expanded in x around 0 14.3%
Taylor expanded in t around 0 14.4%
associate-*l/17.2%
*-commutative17.2%
fma-neg17.2%
metadata-eval17.2%
associate-*l*17.2%
sqrt-prod17.2%
associate-*l/14.4%
*-commutative14.4%
associate-*r/17.2%
Applied egg-rr17.2%
if 9.50000000000000032e-196 < t < 9.99999999999999989e-160 or 1.9500000000000001e-53 < t Initial program 44.5%
Simplified44.4%
Taylor expanded in t around inf 90.4%
associate-*l*90.5%
+-commutative90.5%
sub-neg90.5%
metadata-eval90.5%
+-commutative90.5%
Simplified90.5%
Taylor expanded in t around 0 90.7%
if 9.99999999999999989e-160 < t < 1.9500000000000001e-53Initial program 37.6%
Simplified37.8%
Taylor expanded in x around inf 84.4%
Final simplification48.3%
l_m = (fabs.f64 l)
t_m = (fabs.f64 t)
t_s = (copysign.f64 1 t)
(FPCore (t_s x l_m t_m)
:precision binary64
(let* ((t_2 (* t_m (sqrt (* 2.0 (fma x 0.5 -0.5))))))
(*
t_s
(if (<= t_m 4.2e-199)
(/ t_2 l_m)
(if (or (<= t_m 3.6e-144) (not (<= t_m 8.8e-125)))
(sqrt (/ (+ -1.0 x) (+ x 1.0)))
(/ 1.0 (/ l_m t_2)))))))l_m = fabs(l);
t_m = fabs(t);
t_s = copysign(1.0, t);
double code(double t_s, double x, double l_m, double t_m) {
double t_2 = t_m * sqrt((2.0 * fma(x, 0.5, -0.5)));
double tmp;
if (t_m <= 4.2e-199) {
tmp = t_2 / l_m;
} else if ((t_m <= 3.6e-144) || !(t_m <= 8.8e-125)) {
tmp = sqrt(((-1.0 + x) / (x + 1.0)));
} else {
tmp = 1.0 / (l_m / t_2);
}
return t_s * tmp;
}
l_m = abs(l) t_m = abs(t) t_s = copysign(1.0, t) function code(t_s, x, l_m, t_m) t_2 = Float64(t_m * sqrt(Float64(2.0 * fma(x, 0.5, -0.5)))) tmp = 0.0 if (t_m <= 4.2e-199) tmp = Float64(t_2 / l_m); elseif ((t_m <= 3.6e-144) || !(t_m <= 8.8e-125)) tmp = sqrt(Float64(Float64(-1.0 + x) / Float64(x + 1.0))); else tmp = Float64(1.0 / Float64(l_m / t_2)); end return Float64(t_s * tmp) end
l_m = N[Abs[l], $MachinePrecision]
t_m = N[Abs[t], $MachinePrecision]
t_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, x_, l$95$m_, t$95$m_] := Block[{t$95$2 = N[(t$95$m * N[Sqrt[N[(2.0 * N[(x * 0.5 + -0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(t$95$s * If[LessEqual[t$95$m, 4.2e-199], N[(t$95$2 / l$95$m), $MachinePrecision], If[Or[LessEqual[t$95$m, 3.6e-144], N[Not[LessEqual[t$95$m, 8.8e-125]], $MachinePrecision]], N[Sqrt[N[(N[(-1.0 + x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(1.0 / N[(l$95$m / t$95$2), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
l_m = \left|\ell\right|
\\
t_m = \left|t\right|
\\
t_s = \mathsf{copysign}\left(1, t\right)
\\
\begin{array}{l}
t_2 := t_m \cdot \sqrt{2 \cdot \mathsf{fma}\left(x, 0.5, -0.5\right)}\\
t_s \cdot \begin{array}{l}
\mathbf{if}\;t_m \leq 4.2 \cdot 10^{-199}:\\
\;\;\;\;\frac{t_2}{l_m}\\
\mathbf{elif}\;t_m \leq 3.6 \cdot 10^{-144} \lor \neg \left(t_m \leq 8.8 \cdot 10^{-125}\right):\\
\;\;\;\;\sqrt{\frac{-1 + x}{x + 1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{l_m}{t_2}}\\
\end{array}
\end{array}
\end{array}
if t < 4.20000000000000004e-199Initial program 26.0%
Simplified26.0%
Taylor expanded in l around inf 3.0%
*-commutative3.0%
associate--l+8.4%
sub-neg8.4%
metadata-eval8.4%
+-commutative8.4%
sub-neg8.4%
metadata-eval8.4%
+-commutative8.4%
Simplified8.4%
Taylor expanded in x around 0 14.3%
Taylor expanded in t around 0 14.4%
associate-*l/17.2%
*-commutative17.2%
fma-neg17.2%
metadata-eval17.2%
associate-*l*17.2%
sqrt-prod17.2%
associate-*l/14.4%
*-commutative14.4%
associate-*r/17.2%
Applied egg-rr17.2%
if 4.20000000000000004e-199 < t < 3.6e-144 or 8.79999999999999979e-125 < t Initial program 44.4%
Simplified44.4%
Taylor expanded in t around inf 86.6%
associate-*l*86.6%
+-commutative86.6%
sub-neg86.6%
metadata-eval86.6%
+-commutative86.6%
Simplified86.6%
Taylor expanded in t around 0 86.7%
if 3.6e-144 < t < 8.79999999999999979e-125Initial program 2.1%
Simplified2.1%
Taylor expanded in l around inf 1.5%
*-commutative1.5%
associate--l+9.3%
sub-neg9.3%
metadata-eval9.3%
+-commutative9.3%
sub-neg9.3%
metadata-eval9.3%
+-commutative9.3%
Simplified9.3%
Taylor expanded in x around 0 35.9%
Taylor expanded in t around 0 35.4%
associate-*l/35.4%
*-commutative35.4%
fma-neg35.4%
metadata-eval35.4%
associate-*l*35.9%
sqrt-prod35.9%
associate-*l/35.9%
*-commutative35.9%
associate-*r/35.9%
clear-num35.9%
Applied egg-rr35.9%
Final simplification46.5%
l_m = (fabs.f64 l)
t_m = (fabs.f64 t)
t_s = (copysign.f64 1 t)
(FPCore (t_s x l_m t_m)
:precision binary64
(*
t_s
(if (or (<= t_m 1.2e-196) (and (not (<= t_m 3.7e-144)) (<= t_m 8.8e-125)))
(* t_m (/ (sqrt (* 2.0 (fma x 0.5 -0.5))) l_m))
(sqrt (/ (+ -1.0 x) (+ x 1.0))))))l_m = fabs(l);
t_m = fabs(t);
t_s = copysign(1.0, t);
double code(double t_s, double x, double l_m, double t_m) {
double tmp;
if ((t_m <= 1.2e-196) || (!(t_m <= 3.7e-144) && (t_m <= 8.8e-125))) {
tmp = t_m * (sqrt((2.0 * fma(x, 0.5, -0.5))) / l_m);
} else {
tmp = sqrt(((-1.0 + x) / (x + 1.0)));
}
return t_s * tmp;
}
l_m = abs(l) t_m = abs(t) t_s = copysign(1.0, t) function code(t_s, x, l_m, t_m) tmp = 0.0 if ((t_m <= 1.2e-196) || (!(t_m <= 3.7e-144) && (t_m <= 8.8e-125))) tmp = Float64(t_m * Float64(sqrt(Float64(2.0 * fma(x, 0.5, -0.5))) / l_m)); else tmp = sqrt(Float64(Float64(-1.0 + x) / Float64(x + 1.0))); end return Float64(t_s * tmp) end
l_m = N[Abs[l], $MachinePrecision]
t_m = N[Abs[t], $MachinePrecision]
t_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, x_, l$95$m_, t$95$m_] := N[(t$95$s * If[Or[LessEqual[t$95$m, 1.2e-196], And[N[Not[LessEqual[t$95$m, 3.7e-144]], $MachinePrecision], LessEqual[t$95$m, 8.8e-125]]], N[(t$95$m * N[(N[Sqrt[N[(2.0 * N[(x * 0.5 + -0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / l$95$m), $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[(-1.0 + x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
l_m = \left|\ell\right|
\\
t_m = \left|t\right|
\\
t_s = \mathsf{copysign}\left(1, t\right)
\\
t_s \cdot \begin{array}{l}
\mathbf{if}\;t_m \leq 1.2 \cdot 10^{-196} \lor \neg \left(t_m \leq 3.7 \cdot 10^{-144}\right) \land t_m \leq 8.8 \cdot 10^{-125}:\\
\;\;\;\;t_m \cdot \frac{\sqrt{2 \cdot \mathsf{fma}\left(x, 0.5, -0.5\right)}}{l_m}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{-1 + x}{x + 1}}\\
\end{array}
\end{array}
if t < 1.2000000000000001e-196 or 3.7000000000000003e-144 < t < 8.79999999999999979e-125Initial program 25.5%
Simplified25.5%
Taylor expanded in l around inf 3.0%
*-commutative3.0%
associate--l+8.5%
sub-neg8.5%
metadata-eval8.5%
+-commutative8.5%
sub-neg8.5%
metadata-eval8.5%
+-commutative8.5%
Simplified8.5%
Taylor expanded in x around 0 14.8%
Taylor expanded in t around 0 14.8%
associate-*l/17.5%
*-commutative17.5%
fma-neg17.5%
metadata-eval17.5%
associate-*l*17.6%
sqrt-prod17.6%
associate-*l/14.8%
*-commutative14.8%
expm1-log1p-u14.0%
expm1-udef6.5%
Applied egg-rr6.5%
expm1-def14.0%
expm1-log1p14.8%
associate-*r/17.6%
*-rgt-identity17.6%
*-commutative17.6%
associate-*r/17.5%
associate-*l*17.6%
*-commutative17.6%
associate-*l/17.6%
*-lft-identity17.6%
Simplified17.6%
if 1.2000000000000001e-196 < t < 3.7000000000000003e-144 or 8.79999999999999979e-125 < t Initial program 44.4%
Simplified44.4%
Taylor expanded in t around inf 86.6%
associate-*l*86.6%
+-commutative86.6%
sub-neg86.6%
metadata-eval86.6%
+-commutative86.6%
Simplified86.6%
Taylor expanded in t around 0 86.7%
Final simplification46.5%
l_m = (fabs.f64 l)
t_m = (fabs.f64 t)
t_s = (copysign.f64 1 t)
(FPCore (t_s x l_m t_m)
:precision binary64
(*
t_s
(if (or (<= t_m 2.5e-198) (and (not (<= t_m 3.6e-144)) (<= t_m 1.26e-121)))
(/ (* t_m (sqrt (* 2.0 (fma x 0.5 -0.5)))) l_m)
(sqrt (/ (+ -1.0 x) (+ x 1.0))))))l_m = fabs(l);
t_m = fabs(t);
t_s = copysign(1.0, t);
double code(double t_s, double x, double l_m, double t_m) {
double tmp;
if ((t_m <= 2.5e-198) || (!(t_m <= 3.6e-144) && (t_m <= 1.26e-121))) {
tmp = (t_m * sqrt((2.0 * fma(x, 0.5, -0.5)))) / l_m;
} else {
tmp = sqrt(((-1.0 + x) / (x + 1.0)));
}
return t_s * tmp;
}
l_m = abs(l) t_m = abs(t) t_s = copysign(1.0, t) function code(t_s, x, l_m, t_m) tmp = 0.0 if ((t_m <= 2.5e-198) || (!(t_m <= 3.6e-144) && (t_m <= 1.26e-121))) tmp = Float64(Float64(t_m * sqrt(Float64(2.0 * fma(x, 0.5, -0.5)))) / l_m); else tmp = sqrt(Float64(Float64(-1.0 + x) / Float64(x + 1.0))); end return Float64(t_s * tmp) end
l_m = N[Abs[l], $MachinePrecision]
t_m = N[Abs[t], $MachinePrecision]
t_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, x_, l$95$m_, t$95$m_] := N[(t$95$s * If[Or[LessEqual[t$95$m, 2.5e-198], And[N[Not[LessEqual[t$95$m, 3.6e-144]], $MachinePrecision], LessEqual[t$95$m, 1.26e-121]]], N[(N[(t$95$m * N[Sqrt[N[(2.0 * N[(x * 0.5 + -0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / l$95$m), $MachinePrecision], N[Sqrt[N[(N[(-1.0 + x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
l_m = \left|\ell\right|
\\
t_m = \left|t\right|
\\
t_s = \mathsf{copysign}\left(1, t\right)
\\
t_s \cdot \begin{array}{l}
\mathbf{if}\;t_m \leq 2.5 \cdot 10^{-198} \lor \neg \left(t_m \leq 3.6 \cdot 10^{-144}\right) \land t_m \leq 1.26 \cdot 10^{-121}:\\
\;\;\;\;\frac{t_m \cdot \sqrt{2 \cdot \mathsf{fma}\left(x, 0.5, -0.5\right)}}{l_m}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{-1 + x}{x + 1}}\\
\end{array}
\end{array}
if t < 2.5e-198 or 3.6e-144 < t < 1.26e-121Initial program 25.5%
Simplified25.5%
Taylor expanded in l around inf 3.0%
*-commutative3.0%
associate--l+8.5%
sub-neg8.5%
metadata-eval8.5%
+-commutative8.5%
sub-neg8.5%
metadata-eval8.5%
+-commutative8.5%
Simplified8.5%
Taylor expanded in x around 0 14.8%
Taylor expanded in t around 0 14.8%
associate-*l/17.5%
*-commutative17.5%
fma-neg17.5%
metadata-eval17.5%
associate-*l*17.6%
sqrt-prod17.6%
associate-*l/14.8%
*-commutative14.8%
associate-*r/17.6%
Applied egg-rr17.6%
if 2.5e-198 < t < 3.6e-144 or 1.26e-121 < t Initial program 44.4%
Simplified44.4%
Taylor expanded in t around inf 86.6%
associate-*l*86.6%
+-commutative86.6%
sub-neg86.6%
metadata-eval86.6%
+-commutative86.6%
Simplified86.6%
Taylor expanded in t around 0 86.7%
Final simplification46.5%
l_m = (fabs.f64 l) t_m = (fabs.f64 t) t_s = (copysign.f64 1 t) (FPCore (t_s x l_m t_m) :precision binary64 (* t_s (sqrt (/ (+ -1.0 x) (+ x 1.0)))))
l_m = fabs(l);
t_m = fabs(t);
t_s = copysign(1.0, t);
double code(double t_s, double x, double l_m, double t_m) {
return t_s * sqrt(((-1.0 + x) / (x + 1.0)));
}
l_m = abs(l)
t_m = abs(t)
t_s = copysign(1.0d0, t)
real(8) function code(t_s, x, l_m, t_m)
real(8), intent (in) :: t_s
real(8), intent (in) :: x
real(8), intent (in) :: l_m
real(8), intent (in) :: t_m
code = t_s * sqrt((((-1.0d0) + x) / (x + 1.0d0)))
end function
l_m = Math.abs(l);
t_m = Math.abs(t);
t_s = Math.copySign(1.0, t);
public static double code(double t_s, double x, double l_m, double t_m) {
return t_s * Math.sqrt(((-1.0 + x) / (x + 1.0)));
}
l_m = math.fabs(l) t_m = math.fabs(t) t_s = math.copysign(1.0, t) def code(t_s, x, l_m, t_m): return t_s * math.sqrt(((-1.0 + x) / (x + 1.0)))
l_m = abs(l) t_m = abs(t) t_s = copysign(1.0, t) function code(t_s, x, l_m, t_m) return Float64(t_s * sqrt(Float64(Float64(-1.0 + x) / Float64(x + 1.0)))) end
l_m = abs(l); t_m = abs(t); t_s = sign(t) * abs(1.0); function tmp = code(t_s, x, l_m, t_m) tmp = t_s * sqrt(((-1.0 + x) / (x + 1.0))); end
l_m = N[Abs[l], $MachinePrecision]
t_m = N[Abs[t], $MachinePrecision]
t_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, x_, l$95$m_, t$95$m_] := N[(t$95$s * N[Sqrt[N[(N[(-1.0 + x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
l_m = \left|\ell\right|
\\
t_m = \left|t\right|
\\
t_s = \mathsf{copysign}\left(1, t\right)
\\
t_s \cdot \sqrt{\frac{-1 + x}{x + 1}}
\end{array}
Initial program 33.4%
Simplified33.4%
Taylor expanded in t around inf 39.5%
associate-*l*39.5%
+-commutative39.5%
sub-neg39.5%
metadata-eval39.5%
+-commutative39.5%
Simplified39.5%
Taylor expanded in t around 0 39.6%
Final simplification39.6%
l_m = (fabs.f64 l) t_m = (fabs.f64 t) t_s = (copysign.f64 1 t) (FPCore (t_s x l_m t_m) :precision binary64 (* t_s (+ 1.0 (/ -1.0 x))))
l_m = fabs(l);
t_m = fabs(t);
t_s = copysign(1.0, t);
double code(double t_s, double x, double l_m, double t_m) {
return t_s * (1.0 + (-1.0 / x));
}
l_m = abs(l)
t_m = abs(t)
t_s = copysign(1.0d0, t)
real(8) function code(t_s, x, l_m, t_m)
real(8), intent (in) :: t_s
real(8), intent (in) :: x
real(8), intent (in) :: l_m
real(8), intent (in) :: t_m
code = t_s * (1.0d0 + ((-1.0d0) / x))
end function
l_m = Math.abs(l);
t_m = Math.abs(t);
t_s = Math.copySign(1.0, t);
public static double code(double t_s, double x, double l_m, double t_m) {
return t_s * (1.0 + (-1.0 / x));
}
l_m = math.fabs(l) t_m = math.fabs(t) t_s = math.copysign(1.0, t) def code(t_s, x, l_m, t_m): return t_s * (1.0 + (-1.0 / x))
l_m = abs(l) t_m = abs(t) t_s = copysign(1.0, t) function code(t_s, x, l_m, t_m) return Float64(t_s * Float64(1.0 + Float64(-1.0 / x))) end
l_m = abs(l); t_m = abs(t); t_s = sign(t) * abs(1.0); function tmp = code(t_s, x, l_m, t_m) tmp = t_s * (1.0 + (-1.0 / x)); end
l_m = N[Abs[l], $MachinePrecision]
t_m = N[Abs[t], $MachinePrecision]
t_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, x_, l$95$m_, t$95$m_] := N[(t$95$s * N[(1.0 + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
l_m = \left|\ell\right|
\\
t_m = \left|t\right|
\\
t_s = \mathsf{copysign}\left(1, t\right)
\\
t_s \cdot \left(1 + \frac{-1}{x}\right)
\end{array}
Initial program 33.4%
Simplified33.4%
Taylor expanded in t around inf 39.5%
associate-*l*39.5%
+-commutative39.5%
sub-neg39.5%
metadata-eval39.5%
+-commutative39.5%
Simplified39.5%
Taylor expanded in x around inf 39.3%
Final simplification39.3%
l_m = (fabs.f64 l) t_m = (fabs.f64 t) t_s = (copysign.f64 1 t) (FPCore (t_s x l_m t_m) :precision binary64 (* t_s 1.0))
l_m = fabs(l);
t_m = fabs(t);
t_s = copysign(1.0, t);
double code(double t_s, double x, double l_m, double t_m) {
return t_s * 1.0;
}
l_m = abs(l)
t_m = abs(t)
t_s = copysign(1.0d0, t)
real(8) function code(t_s, x, l_m, t_m)
real(8), intent (in) :: t_s
real(8), intent (in) :: x
real(8), intent (in) :: l_m
real(8), intent (in) :: t_m
code = t_s * 1.0d0
end function
l_m = Math.abs(l);
t_m = Math.abs(t);
t_s = Math.copySign(1.0, t);
public static double code(double t_s, double x, double l_m, double t_m) {
return t_s * 1.0;
}
l_m = math.fabs(l) t_m = math.fabs(t) t_s = math.copysign(1.0, t) def code(t_s, x, l_m, t_m): return t_s * 1.0
l_m = abs(l) t_m = abs(t) t_s = copysign(1.0, t) function code(t_s, x, l_m, t_m) return Float64(t_s * 1.0) end
l_m = abs(l); t_m = abs(t); t_s = sign(t) * abs(1.0); function tmp = code(t_s, x, l_m, t_m) tmp = t_s * 1.0; end
l_m = N[Abs[l], $MachinePrecision]
t_m = N[Abs[t], $MachinePrecision]
t_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, x_, l$95$m_, t$95$m_] := N[(t$95$s * 1.0), $MachinePrecision]
\begin{array}{l}
l_m = \left|\ell\right|
\\
t_m = \left|t\right|
\\
t_s = \mathsf{copysign}\left(1, t\right)
\\
t_s \cdot 1
\end{array}
Initial program 33.4%
Simplified33.4%
Taylor expanded in t around inf 39.5%
associate-*l*39.5%
+-commutative39.5%
sub-neg39.5%
metadata-eval39.5%
+-commutative39.5%
Simplified39.5%
Taylor expanded in x around inf 39.1%
Final simplification39.1%
herbie shell --seed 2024021
(FPCore (x l t)
:name "Toniolo and Linder, Equation (7)"
:precision binary64
(/ (* (sqrt 2.0) t) (sqrt (- (* (/ (+ x 1.0) (- x 1.0)) (+ (* l l) (* 2.0 (* t t)))) (* l l)))))