
(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_s
(if (<= t_m 1.9e-162)
(/ (* t_m (sqrt (* 2.0 (fma 0.5 x -0.5)))) l_m)
(if (<= t_m 4.2e+24)
(*
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)))))
(sqrt (/ (+ x -1.0) (+ 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 tmp;
if (t_m <= 1.9e-162) {
tmp = (t_m * sqrt((2.0 * fma(0.5, x, -0.5)))) / l_m;
} else if (t_m <= 4.2e+24) {
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))));
} else {
tmp = sqrt(((x + -1.0) / (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)) tmp = 0.0 if (t_m <= 1.9e-162) tmp = Float64(Float64(t_m * sqrt(Float64(2.0 * fma(0.5, x, -0.5)))) / l_m); elseif (t_m <= 4.2e+24) 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))))); else tmp = sqrt(Float64(Float64(x + -1.0) / 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]}, N[(t$95$s * If[LessEqual[t$95$m, 1.9e-162], N[(N[(t$95$m * N[Sqrt[N[(2.0 * N[(0.5 * x + -0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / l$95$m), $MachinePrecision], If[LessEqual[t$95$m, 4.2e+24], 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], N[Sqrt[N[(N[(x + -1.0), $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_s \cdot \begin{array}{l}
\mathbf{if}\;t_m \leq 1.9 \cdot 10^{-162}:\\
\;\;\;\;\frac{t_m \cdot \sqrt{2 \cdot \mathsf{fma}\left(0.5, x, -0.5\right)}}{l_m}\\
\mathbf{elif}\;t_m \leq 4.2 \cdot 10^{+24}:\\
\;\;\;\;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}}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{x + -1}{x + 1}}\\
\end{array}
\end{array}
\end{array}
if t < 1.90000000000000002e-162Initial program 30.8%
Simplified30.8%
Taylor expanded in l around inf 3.0%
*-commutative3.0%
associate--l+11.4%
sub-neg11.4%
metadata-eval11.4%
+-commutative11.4%
sub-neg11.4%
metadata-eval11.4%
+-commutative11.4%
Simplified11.4%
Taylor expanded in x around 0 19.9%
add-exp-log10.1%
associate-*r*10.1%
sqrt-unprod10.1%
fma-neg10.1%
metadata-eval10.1%
Applied egg-rr10.1%
rem-exp-log20.0%
associate-*r/21.3%
Applied egg-rr21.3%
if 1.90000000000000002e-162 < t < 4.2000000000000003e24Initial program 37.1%
Simplified37.2%
Taylor expanded in x around inf 84.4%
if 4.2000000000000003e24 < t Initial program 37.7%
Simplified37.7%
Taylor expanded in t around inf 93.5%
Taylor expanded in t around 0 93.7%
Final simplification51.7%
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 (/ (+ x -1.0) (+ x 1.0))))
(*
t_s
(if (<= t_m 1.8e-162)
(/ (* t_m (sqrt (* 2.0 (fma 0.5 x -0.5)))) l_m)
(if (<= t_m 2.05e+24)
(*
(sqrt 2.0)
(/
t_m
(sqrt (fma 2.0 (/ (pow t_m 2.0) t_2) (* 2.0 (/ (pow l_m 2.0) x))))))
(sqrt 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 = (x + -1.0) / (x + 1.0);
double tmp;
if (t_m <= 1.8e-162) {
tmp = (t_m * sqrt((2.0 * fma(0.5, x, -0.5)))) / l_m;
} else if (t_m <= 2.05e+24) {
tmp = sqrt(2.0) * (t_m / sqrt(fma(2.0, (pow(t_m, 2.0) / t_2), (2.0 * (pow(l_m, 2.0) / x)))));
} else {
tmp = sqrt(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(Float64(x + -1.0) / Float64(x + 1.0)) tmp = 0.0 if (t_m <= 1.8e-162) tmp = Float64(Float64(t_m * sqrt(Float64(2.0 * fma(0.5, x, -0.5)))) / l_m); elseif (t_m <= 2.05e+24) tmp = Float64(sqrt(2.0) * Float64(t_m / sqrt(fma(2.0, Float64((t_m ^ 2.0) / t_2), Float64(2.0 * Float64((l_m ^ 2.0) / x)))))); else tmp = sqrt(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[(N[(x + -1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, N[(t$95$s * If[LessEqual[t$95$m, 1.8e-162], N[(N[(t$95$m * N[Sqrt[N[(2.0 * N[(0.5 * x + -0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / l$95$m), $MachinePrecision], If[LessEqual[t$95$m, 2.05e+24], N[(N[Sqrt[2.0], $MachinePrecision] * N[(t$95$m / N[Sqrt[N[(2.0 * N[(N[Power[t$95$m, 2.0], $MachinePrecision] / t$95$2), $MachinePrecision] + N[(2.0 * N[(N[Power[l$95$m, 2.0], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sqrt[t$95$2], $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 := \frac{x + -1}{x + 1}\\
t_s \cdot \begin{array}{l}
\mathbf{if}\;t_m \leq 1.8 \cdot 10^{-162}:\\
\;\;\;\;\frac{t_m \cdot \sqrt{2 \cdot \mathsf{fma}\left(0.5, x, -0.5\right)}}{l_m}\\
\mathbf{elif}\;t_m \leq 2.05 \cdot 10^{+24}:\\
\;\;\;\;\sqrt{2} \cdot \frac{t_m}{\sqrt{\mathsf{fma}\left(2, \frac{{t_m}^{2}}{t_2}, 2 \cdot \frac{{l_m}^{2}}{x}\right)}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{t_2}\\
\end{array}
\end{array}
\end{array}
if t < 1.7999999999999999e-162Initial program 30.8%
Simplified30.8%
Taylor expanded in l around inf 3.0%
*-commutative3.0%
associate--l+11.4%
sub-neg11.4%
metadata-eval11.4%
+-commutative11.4%
sub-neg11.4%
metadata-eval11.4%
+-commutative11.4%
Simplified11.4%
Taylor expanded in x around 0 19.9%
add-exp-log10.1%
associate-*r*10.1%
sqrt-unprod10.1%
fma-neg10.1%
metadata-eval10.1%
Applied egg-rr10.1%
rem-exp-log20.0%
associate-*r/21.3%
Applied egg-rr21.3%
if 1.7999999999999999e-162 < t < 2.05e24Initial program 37.1%
Simplified37.1%
Taylor expanded in l around 0 64.1%
fma-def64.1%
associate-/l*67.5%
+-commutative67.5%
sub-neg67.5%
metadata-eval67.5%
+-commutative67.5%
associate--l+70.1%
sub-neg70.1%
metadata-eval70.1%
+-commutative70.1%
sub-neg70.1%
metadata-eval70.1%
+-commutative70.1%
Simplified70.1%
Taylor expanded in x around inf 84.2%
if 2.05e24 < t Initial program 37.7%
Simplified37.7%
Taylor expanded in t around inf 93.5%
Taylor expanded in t around 0 93.7%
Final simplification51.7%
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 (<=
(/
(* t_m (sqrt 2.0))
(sqrt
(-
(* (/ (+ x 1.0) (+ x -1.0)) (+ (* l_m l_m) (* 2.0 (* t_m t_m))))
(* l_m l_m))))
INFINITY)
(sqrt (/ (+ x -1.0) (+ x 1.0)))
(/ (* t_m (sqrt (* 2.0 (fma 0.5 x -0.5)))) l_m))))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 * sqrt(2.0)) / sqrt(((((x + 1.0) / (x + -1.0)) * ((l_m * l_m) + (2.0 * (t_m * t_m)))) - (l_m * l_m)))) <= ((double) INFINITY)) {
tmp = sqrt(((x + -1.0) / (x + 1.0)));
} else {
tmp = (t_m * sqrt((2.0 * fma(0.5, x, -0.5)))) / l_m;
}
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 (Float64(Float64(t_m * sqrt(2.0)) / sqrt(Float64(Float64(Float64(Float64(x + 1.0) / Float64(x + -1.0)) * Float64(Float64(l_m * l_m) + Float64(2.0 * Float64(t_m * t_m)))) - Float64(l_m * l_m)))) <= Inf) tmp = sqrt(Float64(Float64(x + -1.0) / Float64(x + 1.0))); else tmp = Float64(Float64(t_m * sqrt(Float64(2.0 * fma(0.5, x, -0.5)))) / l_m); 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[LessEqual[N[(N[(t$95$m * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(N[(N[(x + 1.0), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision] * N[(N[(l$95$m * l$95$m), $MachinePrecision] + N[(2.0 * N[(t$95$m * t$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(l$95$m * l$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], Infinity], N[Sqrt[N[(N[(x + -1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[(t$95$m * N[Sqrt[N[(2.0 * N[(0.5 * x + -0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / l$95$m), $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}\;\frac{t_m \cdot \sqrt{2}}{\sqrt{\frac{x + 1}{x + -1} \cdot \left(l_m \cdot l_m + 2 \cdot \left(t_m \cdot t_m\right)\right) - l_m \cdot l_m}} \leq \infty:\\
\;\;\;\;\sqrt{\frac{x + -1}{x + 1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_m \cdot \sqrt{2 \cdot \mathsf{fma}\left(0.5, x, -0.5\right)}}{l_m}\\
\end{array}
\end{array}
if (/.f64 (*.f64 (sqrt.f64 2) t) (sqrt.f64 (-.f64 (*.f64 (/.f64 (+.f64 x 1) (-.f64 x 1)) (+.f64 (*.f64 l l) (*.f64 2 (*.f64 t t)))) (*.f64 l l)))) < +inf.0Initial program 41.7%
Simplified41.7%
Taylor expanded in t around inf 45.5%
Taylor expanded in t around 0 45.6%
if +inf.0 < (/.f64 (*.f64 (sqrt.f64 2) t) (sqrt.f64 (-.f64 (*.f64 (/.f64 (+.f64 x 1) (-.f64 x 1)) (+.f64 (*.f64 l l) (*.f64 2 (*.f64 t t)))) (*.f64 l l)))) Initial program 0.0%
Simplified0.0%
Taylor expanded in l around inf 4.7%
*-commutative4.7%
associate--l+27.3%
sub-neg27.3%
metadata-eval27.3%
+-commutative27.3%
sub-neg27.3%
metadata-eval27.3%
+-commutative27.3%
Simplified27.3%
Taylor expanded in x around 0 43.8%
add-exp-log32.5%
associate-*r*32.5%
sqrt-unprod32.5%
fma-neg32.5%
metadata-eval32.5%
Applied egg-rr32.5%
rem-exp-log44.0%
associate-*r/43.8%
Applied egg-rr43.8%
Final simplification45.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
(if (<= l_m 1.1e+150)
(sqrt (/ (+ x -1.0) (+ x 1.0)))
(* (sqrt 2.0) (* (/ t_m l_m) (sqrt (* 0.5 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 tmp;
if (l_m <= 1.1e+150) {
tmp = sqrt(((x + -1.0) / (x + 1.0)));
} else {
tmp = sqrt(2.0) * ((t_m / l_m) * sqrt((0.5 * x)));
}
return t_s * tmp;
}
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
real(8) :: tmp
if (l_m <= 1.1d+150) then
tmp = sqrt(((x + (-1.0d0)) / (x + 1.0d0)))
else
tmp = sqrt(2.0d0) * ((t_m / l_m) * sqrt((0.5d0 * x)))
end if
code = t_s * tmp
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) {
double tmp;
if (l_m <= 1.1e+150) {
tmp = Math.sqrt(((x + -1.0) / (x + 1.0)));
} else {
tmp = Math.sqrt(2.0) * ((t_m / l_m) * Math.sqrt((0.5 * x)));
}
return t_s * tmp;
}
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): tmp = 0 if l_m <= 1.1e+150: tmp = math.sqrt(((x + -1.0) / (x + 1.0))) else: tmp = math.sqrt(2.0) * ((t_m / l_m) * math.sqrt((0.5 * 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) tmp = 0.0 if (l_m <= 1.1e+150) tmp = sqrt(Float64(Float64(x + -1.0) / Float64(x + 1.0))); else tmp = Float64(sqrt(2.0) * Float64(Float64(t_m / l_m) * sqrt(Float64(0.5 * x)))); end return Float64(t_s * tmp) end
l_m = abs(l); t_m = abs(t); t_s = sign(t) * abs(1.0); function tmp_2 = code(t_s, x, l_m, t_m) tmp = 0.0; if (l_m <= 1.1e+150) tmp = sqrt(((x + -1.0) / (x + 1.0))); else tmp = sqrt(2.0) * ((t_m / l_m) * sqrt((0.5 * x))); end tmp_2 = 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[LessEqual[l$95$m, 1.1e+150], N[Sqrt[N[(N[(x + -1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[(t$95$m / l$95$m), $MachinePrecision] * N[Sqrt[N[(0.5 * x), $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)
\\
t_s \cdot \begin{array}{l}
\mathbf{if}\;l_m \leq 1.1 \cdot 10^{+150}:\\
\;\;\;\;\sqrt{\frac{x + -1}{x + 1}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot \left(\frac{t_m}{l_m} \cdot \sqrt{0.5 \cdot x}\right)\\
\end{array}
\end{array}
if l < 1.1e150Initial program 38.0%
Simplified38.0%
Taylor expanded in t around inf 43.5%
Taylor expanded in t around 0 43.6%
if 1.1e150 < l Initial program 0.2%
Simplified0.2%
Taylor expanded in l around inf 7.7%
*-commutative7.7%
associate--l+35.0%
sub-neg35.0%
metadata-eval35.0%
+-commutative35.0%
sub-neg35.0%
metadata-eval35.0%
+-commutative35.0%
Simplified35.0%
Taylor expanded in x around inf 64.3%
*-commutative64.3%
Simplified64.3%
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
(*
t_s
(if (<= l_m 9e+149)
(sqrt (/ (+ x -1.0) (+ x 1.0)))
(* (/ t_m l_m) (sqrt (* 2.0 (fma x 0.5 -0.5)))))))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 (l_m <= 9e+149) {
tmp = sqrt(((x + -1.0) / (x + 1.0)));
} else {
tmp = (t_m / l_m) * sqrt((2.0 * fma(x, 0.5, -0.5)));
}
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 (l_m <= 9e+149) tmp = sqrt(Float64(Float64(x + -1.0) / Float64(x + 1.0))); else tmp = Float64(Float64(t_m / l_m) * sqrt(Float64(2.0 * fma(x, 0.5, -0.5)))); 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[LessEqual[l$95$m, 9e+149], N[Sqrt[N[(N[(x + -1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[(t$95$m / l$95$m), $MachinePrecision] * N[Sqrt[N[(2.0 * N[(x * 0.5 + -0.5), $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)
\\
t_s \cdot \begin{array}{l}
\mathbf{if}\;l_m \leq 9 \cdot 10^{+149}:\\
\;\;\;\;\sqrt{\frac{x + -1}{x + 1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_m}{l_m} \cdot \sqrt{2 \cdot \mathsf{fma}\left(x, 0.5, -0.5\right)}\\
\end{array}
\end{array}
if l < 8.99999999999999965e149Initial program 38.0%
Simplified38.0%
Taylor expanded in t around inf 43.5%
Taylor expanded in t around 0 43.6%
if 8.99999999999999965e149 < l Initial program 0.2%
Simplified0.2%
Taylor expanded in l around inf 7.7%
*-commutative7.7%
associate--l+35.0%
sub-neg35.0%
metadata-eval35.0%
+-commutative35.0%
sub-neg35.0%
metadata-eval35.0%
+-commutative35.0%
Simplified35.0%
Taylor expanded in x around 0 65.7%
expm1-log1p-u65.3%
expm1-udef28.9%
associate-*r*28.9%
sqrt-unprod28.9%
fma-neg28.9%
metadata-eval28.9%
Applied egg-rr28.9%
expm1-def65.6%
expm1-log1p65.9%
*-commutative65.9%
fma-udef65.9%
*-commutative65.9%
fma-def65.9%
Simplified65.9%
Final simplification46.1%
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 (/ (+ x -1.0) (+ 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(((x + -1.0) / (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(((x + (-1.0d0)) / (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(((x + -1.0) / (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(((x + -1.0) / (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(x + -1.0) / 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(((x + -1.0) / (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[(x + -1.0), $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{x + -1}{x + 1}}
\end{array}
Initial program 33.8%
Simplified33.7%
Taylor expanded in t around inf 41.0%
Taylor expanded in t around 0 41.1%
Final simplification41.1%
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.8%
Simplified33.7%
Taylor expanded in t around inf 41.0%
Taylor expanded in x around inf 41.0%
Final simplification41.0%
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.8%
Simplified33.7%
Taylor expanded in t around inf 41.0%
Taylor expanded in x around inf 40.7%
Final simplification40.7%
herbie shell --seed 2024019
(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)))))