
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (sqrt (pow h -1.0))))
(if (<= d -2e-310)
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (/ (sqrt (- d)) (sqrt (- l))))
(fma (/ (* -0.5 (pow (* (/ 2.0 M) (/ d D_m)) -2.0)) l) h 1.0))
(if (<= d 2.7e-151)
(*
(fma (* (* M M) (* (/ (/ (* D_m D_m) l) d) -0.125)) (sqrt h) (* t_0 d))
(pow l -0.5))
(if (<= d 1.82e-22)
(*
(/
(fma
(* -0.125 (sqrt h))
(* (* (* M M) D_m) (/ D_m l))
(* t_0 (* d d)))
d)
(pow l -0.5))
(*
(*
(*
(fma (* -0.5 h) (/ (* 0.25 (pow (/ (/ d D_m) M) -2.0)) l) 1.0)
(sqrt (/ d h)))
(sqrt d))
(pow l -0.5)))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = sqrt(pow(h, -1.0));
double tmp;
if (d <= -2e-310) {
tmp = (pow((d / h), pow(2.0, -1.0)) * (sqrt(-d) / sqrt(-l))) * fma(((-0.5 * pow(((2.0 / M) * (d / D_m)), -2.0)) / l), h, 1.0);
} else if (d <= 2.7e-151) {
tmp = fma(((M * M) * ((((D_m * D_m) / l) / d) * -0.125)), sqrt(h), (t_0 * d)) * pow(l, -0.5);
} else if (d <= 1.82e-22) {
tmp = (fma((-0.125 * sqrt(h)), (((M * M) * D_m) * (D_m / l)), (t_0 * (d * d))) / d) * pow(l, -0.5);
} else {
tmp = ((fma((-0.5 * h), ((0.25 * pow(((d / D_m) / M), -2.0)) / l), 1.0) * sqrt((d / h))) * sqrt(d)) * pow(l, -0.5);
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = sqrt((h ^ -1.0)) tmp = 0.0 if (d <= -2e-310) tmp = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * Float64(sqrt(Float64(-d)) / sqrt(Float64(-l)))) * fma(Float64(Float64(-0.5 * (Float64(Float64(2.0 / M) * Float64(d / D_m)) ^ -2.0)) / l), h, 1.0)); elseif (d <= 2.7e-151) tmp = Float64(fma(Float64(Float64(M * M) * Float64(Float64(Float64(Float64(D_m * D_m) / l) / d) * -0.125)), sqrt(h), Float64(t_0 * d)) * (l ^ -0.5)); elseif (d <= 1.82e-22) tmp = Float64(Float64(fma(Float64(-0.125 * sqrt(h)), Float64(Float64(Float64(M * M) * D_m) * Float64(D_m / l)), Float64(t_0 * Float64(d * d))) / d) * (l ^ -0.5)); else tmp = Float64(Float64(Float64(fma(Float64(-0.5 * h), Float64(Float64(0.25 * (Float64(Float64(d / D_m) / M) ^ -2.0)) / l), 1.0) * sqrt(Float64(d / h))) * sqrt(d)) * (l ^ -0.5)); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[Power[h, -1.0], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -2e-310], N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(-0.5 * N[Power[N[(N[(2.0 / M), $MachinePrecision] * N[(d / D$95$m), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * h + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.7e-151], N[(N[(N[(N[(M * M), $MachinePrecision] * N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] / l), $MachinePrecision] / d), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision] * N[Sqrt[h], $MachinePrecision] + N[(t$95$0 * d), $MachinePrecision]), $MachinePrecision] * N[Power[l, -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.82e-22], N[(N[(N[(N[(-0.125 * N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M * M), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(D$95$m / l), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * N[Power[l, -0.5], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(-0.5 * h), $MachinePrecision] * N[(N[(0.25 * N[Power[N[(N[(d / D$95$m), $MachinePrecision] / M), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[d], $MachinePrecision]), $MachinePrecision] * N[Power[l, -0.5], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{{h}^{-1}}\\
\mathbf{if}\;d \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\right) \cdot \mathsf{fma}\left(\frac{-0.5 \cdot {\left(\frac{2}{M} \cdot \frac{d}{D\_m}\right)}^{-2}}{\ell}, h, 1\right)\\
\mathbf{elif}\;d \leq 2.7 \cdot 10^{-151}:\\
\;\;\;\;\mathsf{fma}\left(\left(M \cdot M\right) \cdot \left(\frac{\frac{D\_m \cdot D\_m}{\ell}}{d} \cdot -0.125\right), \sqrt{h}, t\_0 \cdot d\right) \cdot {\ell}^{-0.5}\\
\mathbf{elif}\;d \leq 1.82 \cdot 10^{-22}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.125 \cdot \sqrt{h}, \left(\left(M \cdot M\right) \cdot D\_m\right) \cdot \frac{D\_m}{\ell}, t\_0 \cdot \left(d \cdot d\right)\right)}{d} \cdot {\ell}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(-0.5 \cdot h, \frac{0.25 \cdot {\left(\frac{\frac{d}{D\_m}}{M}\right)}^{-2}}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{d}\right) \cdot {\ell}^{-0.5}\\
\end{array}
\end{array}
if d < -1.999999999999994e-310Initial program 65.4%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-/.f64N/A
clear-numN/A
associate-*r/N/A
div-invN/A
times-fracN/A
clear-numN/A
/-rgt-identityN/A
lower-fma.f64N/A
Applied rewrites69.4%
lift-/.f64N/A
lift-pow.f64N/A
metadata-evalN/A
pow1/2N/A
lift-/.f64N/A
frac-2negN/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-neg.f6476.4
Applied rewrites76.4%
if -1.999999999999994e-310 < d < 2.70000000000000007e-151Initial program 42.3%
Applied rewrites56.1%
Taylor expanded in l around inf
Applied rewrites78.1%
if 2.70000000000000007e-151 < d < 1.82e-22Initial program 63.0%
Applied rewrites66.1%
Taylor expanded in d around 0
lower-/.f64N/A
Applied rewrites86.7%
if 1.82e-22 < d Initial program 78.0%
Applied rewrites83.3%
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
*-commutativeN/A
associate-*r/N/A
lift-/.f64N/A
Applied rewrites93.1%
Final simplification82.4%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1 (sqrt (/ d l))))
(if (<= t_0 -5e-116)
(*
(*
(fma (* (* (* (* (/ h l) -0.5) M) (* D_m 0.25)) (/ (/ D_m d) d)) M 1.0)
(sqrt (/ d h)))
t_1)
(if (<= t_0 0.0) (/ d (sqrt (* l h))) (/ t_1 (sqrt (/ h d)))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = sqrt((d / l));
double tmp;
if (t_0 <= -5e-116) {
tmp = (fma((((((h / l) * -0.5) * M) * (D_m * 0.25)) * ((D_m / d) / d)), M, 1.0) * sqrt((d / h))) * t_1;
} else if (t_0 <= 0.0) {
tmp = d / sqrt((l * h));
} else {
tmp = t_1 / sqrt((h / d));
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = sqrt(Float64(d / l)) tmp = 0.0 if (t_0 <= -5e-116) tmp = Float64(Float64(fma(Float64(Float64(Float64(Float64(Float64(h / l) * -0.5) * M) * Float64(D_m * 0.25)) * Float64(Float64(D_m / d) / d)), M, 1.0) * sqrt(Float64(d / h))) * t_1); elseif (t_0 <= 0.0) tmp = Float64(d / sqrt(Float64(l * h))); else tmp = Float64(t_1 / sqrt(Float64(h / d))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -5e-116], N[(N[(N[(N[(N[(N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * M), $MachinePrecision] * N[(D$95$m * 0.25), $MachinePrecision]), $MachinePrecision] * N[(N[(D$95$m / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * M + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$1 / N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-116}:\\
\;\;\;\;\left(\mathsf{fma}\left(\left(\left(\left(\frac{h}{\ell} \cdot -0.5\right) \cdot M\right) \cdot \left(D\_m \cdot 0.25\right)\right) \cdot \frac{\frac{D\_m}{d}}{d}, M, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot t\_1\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{\sqrt{\frac{h}{d}}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -5.0000000000000003e-116Initial program 82.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-/.f64N/A
clear-numN/A
frac-timesN/A
*-rgt-identityN/A
associate-*r/N/A
associate-*r/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites71.0%
lift-/.f64N/A
lift-pow.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6471.0
Applied rewrites71.0%
Applied rewrites65.2%
metadata-evalN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites75.1%
if -5.0000000000000003e-116 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0Initial program 37.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6472.3
Applied rewrites72.3%
Applied rewrites72.3%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 60.2%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6436.2
Applied rewrites36.2%
Applied rewrites63.1%
Final simplification67.6%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1 (sqrt (/ d l))))
(if (<= t_0 -1000000000000.0)
(*
(*
(* (* (* (/ (/ (* D_m D_m) d) d) h) -0.125) (/ (* M M) l))
(sqrt (/ d h)))
t_1)
(if (<= t_0 0.0) (/ d (sqrt (* l h))) (/ t_1 (sqrt (/ h d)))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = sqrt((d / l));
double tmp;
if (t_0 <= -1000000000000.0) {
tmp = (((((((D_m * D_m) / d) / d) * h) * -0.125) * ((M * M) / l)) * sqrt((d / h))) * t_1;
} else if (t_0 <= 0.0) {
tmp = d / sqrt((l * h));
} else {
tmp = t_1 / sqrt((h / d));
}
return tmp;
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (((d / h) ** (2.0d0 ** (-1.0d0))) * ((d / l) ** (2.0d0 ** (-1.0d0)))) * (1.0d0 - (((2.0d0 ** (-1.0d0)) * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
t_1 = sqrt((d / l))
if (t_0 <= (-1000000000000.0d0)) then
tmp = (((((((d_m * d_m) / d) / d) * h) * (-0.125d0)) * ((m * m) / l)) * sqrt((d / h))) * t_1
else if (t_0 <= 0.0d0) then
tmp = d / sqrt((l * h))
else
tmp = t_1 / sqrt((h / d))
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = (Math.pow((d / h), Math.pow(2.0, -1.0)) * Math.pow((d / l), Math.pow(2.0, -1.0))) * (1.0 - ((Math.pow(2.0, -1.0) * Math.pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = Math.sqrt((d / l));
double tmp;
if (t_0 <= -1000000000000.0) {
tmp = (((((((D_m * D_m) / d) / d) * h) * -0.125) * ((M * M) / l)) * Math.sqrt((d / h))) * t_1;
} else if (t_0 <= 0.0) {
tmp = d / Math.sqrt((l * h));
} else {
tmp = t_1 / Math.sqrt((h / d));
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = (math.pow((d / h), math.pow(2.0, -1.0)) * math.pow((d / l), math.pow(2.0, -1.0))) * (1.0 - ((math.pow(2.0, -1.0) * math.pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l))) t_1 = math.sqrt((d / l)) tmp = 0 if t_0 <= -1000000000000.0: tmp = (((((((D_m * D_m) / d) / d) * h) * -0.125) * ((M * M) / l)) * math.sqrt((d / h))) * t_1 elif t_0 <= 0.0: tmp = d / math.sqrt((l * h)) else: tmp = t_1 / math.sqrt((h / d)) return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = sqrt(Float64(d / l)) tmp = 0.0 if (t_0 <= -1000000000000.0) tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(D_m * D_m) / d) / d) * h) * -0.125) * Float64(Float64(M * M) / l)) * sqrt(Float64(d / h))) * t_1); elseif (t_0 <= 0.0) tmp = Float64(d / sqrt(Float64(l * h))); else tmp = Float64(t_1 / sqrt(Float64(h / d))); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = (((d / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
t_1 = sqrt((d / l));
tmp = 0.0;
if (t_0 <= -1000000000000.0)
tmp = (((((((D_m * D_m) / d) / d) * h) * -0.125) * ((M * M) / l)) * sqrt((d / h))) * t_1;
elseif (t_0 <= 0.0)
tmp = d / sqrt((l * h));
else
tmp = t_1 / sqrt((h / d));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -1000000000000.0], N[(N[(N[(N[(N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision] * h), $MachinePrecision] * -0.125), $MachinePrecision] * N[(N[(M * M), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$1 / N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;t\_0 \leq -1000000000000:\\
\;\;\;\;\left(\left(\left(\left(\frac{\frac{D\_m \cdot D\_m}{d}}{d} \cdot h\right) \cdot -0.125\right) \cdot \frac{M \cdot M}{\ell}\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot t\_1\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{\sqrt{\frac{h}{d}}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -1e12Initial program 83.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites83.2%
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
*-commutativeN/A
associate-*r/N/A
lift-/.f64N/A
Applied rewrites84.4%
Taylor expanded in d around 0
*-commutativeN/A
associate-*r*N/A
associate-*l/N/A
associate-*l*N/A
associate-*r/N/A
associate-*l/N/A
times-fracN/A
lower-*.f64N/A
Applied rewrites69.2%
if -1e12 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0Initial program 47.4%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6456.0
Applied rewrites56.0%
Applied rewrites56.0%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 60.2%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6436.2
Applied rewrites36.2%
Applied rewrites63.1%
Final simplification64.4%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* (/ M (* 2.0 d)) D_m)))
(if (<=
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l))))
INFINITY)
(*
(* (fma t_0 (* t_0 (* (/ h l) -0.5)) 1.0) (sqrt (/ d h)))
(sqrt (/ d l)))
(*
(/
(fma
(* -0.125 (sqrt h))
(* (* (* M M) D_m) (/ D_m l))
(* (sqrt (pow h -1.0)) (* d d)))
d)
(pow l -0.5)))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = (M / (2.0 * d)) * D_m;
double tmp;
if (((pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= ((double) INFINITY)) {
tmp = (fma(t_0, (t_0 * ((h / l) * -0.5)), 1.0) * sqrt((d / h))) * sqrt((d / l));
} else {
tmp = (fma((-0.125 * sqrt(h)), (((M * M) * D_m) * (D_m / l)), (sqrt(pow(h, -1.0)) * (d * d))) / d) * pow(l, -0.5);
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64(M / Float64(2.0 * d)) * D_m) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= Inf) tmp = Float64(Float64(fma(t_0, Float64(t_0 * Float64(Float64(h / l) * -0.5)), 1.0) * sqrt(Float64(d / h))) * sqrt(Float64(d / l))); else tmp = Float64(Float64(fma(Float64(-0.125 * sqrt(h)), Float64(Float64(Float64(M * M) * D_m) * Float64(D_m / l)), Float64(sqrt((h ^ -1.0)) * Float64(d * d))) / d) * (l ^ -0.5)); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(M / N[(2.0 * d), $MachinePrecision]), $MachinePrecision] * D$95$m), $MachinePrecision]}, If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(t$95$0 * N[(t$95$0 * N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(-0.125 * N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M * M), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(D$95$m / l), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[Power[h, -1.0], $MachinePrecision]], $MachinePrecision] * N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * N[Power[l, -0.5], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{M}{2 \cdot d} \cdot D\_m\\
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq \infty:\\
\;\;\;\;\left(\mathsf{fma}\left(t\_0, t\_0 \cdot \left(\frac{h}{\ell} \cdot -0.5\right), 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.125 \cdot \sqrt{h}, \left(\left(M \cdot M\right) \cdot D\_m\right) \cdot \frac{D\_m}{\ell}, \sqrt{{h}^{-1}} \cdot \left(d \cdot d\right)\right)}{d} \cdot {\ell}^{-0.5}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 80.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites80.3%
lift-fma.f64N/A
*-commutativeN/A
lift-pow.f64N/A
metadata-evalN/A
pow-powN/A
inv-powN/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
clear-numN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites81.7%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
Applied rewrites2.2%
Taylor expanded in d around 0
lower-/.f64N/A
Applied rewrites26.7%
Final simplification71.8%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* (/ M (* 2.0 d)) D_m)))
(if (<=
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l))))
INFINITY)
(*
(* (fma t_0 (* t_0 (* (/ h l) -0.5)) 1.0) (sqrt (/ d h)))
(sqrt (/ d l)))
(*
(fma
(* (* M M) (* (/ (/ (* D_m D_m) l) d) -0.125))
(sqrt h)
(* (sqrt (pow h -1.0)) d))
(pow l -0.5)))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = (M / (2.0 * d)) * D_m;
double tmp;
if (((pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= ((double) INFINITY)) {
tmp = (fma(t_0, (t_0 * ((h / l) * -0.5)), 1.0) * sqrt((d / h))) * sqrt((d / l));
} else {
tmp = fma(((M * M) * ((((D_m * D_m) / l) / d) * -0.125)), sqrt(h), (sqrt(pow(h, -1.0)) * d)) * pow(l, -0.5);
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64(M / Float64(2.0 * d)) * D_m) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= Inf) tmp = Float64(Float64(fma(t_0, Float64(t_0 * Float64(Float64(h / l) * -0.5)), 1.0) * sqrt(Float64(d / h))) * sqrt(Float64(d / l))); else tmp = Float64(fma(Float64(Float64(M * M) * Float64(Float64(Float64(Float64(D_m * D_m) / l) / d) * -0.125)), sqrt(h), Float64(sqrt((h ^ -1.0)) * d)) * (l ^ -0.5)); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(M / N[(2.0 * d), $MachinePrecision]), $MachinePrecision] * D$95$m), $MachinePrecision]}, If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(t$95$0 * N[(t$95$0 * N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(M * M), $MachinePrecision] * N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] / l), $MachinePrecision] / d), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision] * N[Sqrt[h], $MachinePrecision] + N[(N[Sqrt[N[Power[h, -1.0], $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] * N[Power[l, -0.5], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{M}{2 \cdot d} \cdot D\_m\\
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq \infty:\\
\;\;\;\;\left(\mathsf{fma}\left(t\_0, t\_0 \cdot \left(\frac{h}{\ell} \cdot -0.5\right), 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(M \cdot M\right) \cdot \left(\frac{\frac{D\_m \cdot D\_m}{\ell}}{d} \cdot -0.125\right), \sqrt{h}, \sqrt{{h}^{-1}} \cdot d\right) \cdot {\ell}^{-0.5}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 80.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites80.3%
lift-fma.f64N/A
*-commutativeN/A
lift-pow.f64N/A
metadata-evalN/A
pow-powN/A
inv-powN/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
clear-numN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites81.7%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
Applied rewrites2.2%
Taylor expanded in l around inf
Applied rewrites28.5%
Final simplification72.1%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* (/ M (* 2.0 d)) D_m)))
(if (<=
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l))))
INFINITY)
(*
(* (fma t_0 (* t_0 (* (/ h l) -0.5)) 1.0) (sqrt (/ d h)))
(sqrt (/ d l)))
(*
(* (* (* D_m D_m) -0.125) (* (/ (sqrt h) d) (/ (* M M) l)))
(pow l -0.5)))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = (M / (2.0 * d)) * D_m;
double tmp;
if (((pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= ((double) INFINITY)) {
tmp = (fma(t_0, (t_0 * ((h / l) * -0.5)), 1.0) * sqrt((d / h))) * sqrt((d / l));
} else {
tmp = (((D_m * D_m) * -0.125) * ((sqrt(h) / d) * ((M * M) / l))) * pow(l, -0.5);
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64(M / Float64(2.0 * d)) * D_m) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= Inf) tmp = Float64(Float64(fma(t_0, Float64(t_0 * Float64(Float64(h / l) * -0.5)), 1.0) * sqrt(Float64(d / h))) * sqrt(Float64(d / l))); else tmp = Float64(Float64(Float64(Float64(D_m * D_m) * -0.125) * Float64(Float64(sqrt(h) / d) * Float64(Float64(M * M) / l))) * (l ^ -0.5)); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(M / N[(2.0 * d), $MachinePrecision]), $MachinePrecision] * D$95$m), $MachinePrecision]}, If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(t$95$0 * N[(t$95$0 * N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * -0.125), $MachinePrecision] * N[(N[(N[Sqrt[h], $MachinePrecision] / d), $MachinePrecision] * N[(N[(M * M), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[l, -0.5], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{M}{2 \cdot d} \cdot D\_m\\
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq \infty:\\
\;\;\;\;\left(\mathsf{fma}\left(t\_0, t\_0 \cdot \left(\frac{h}{\ell} \cdot -0.5\right), 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(D\_m \cdot D\_m\right) \cdot -0.125\right) \cdot \left(\frac{\sqrt{h}}{d} \cdot \frac{M \cdot M}{\ell}\right)\right) \cdot {\ell}^{-0.5}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 80.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites80.3%
lift-fma.f64N/A
*-commutativeN/A
lift-pow.f64N/A
metadata-evalN/A
pow-powN/A
inv-powN/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
clear-numN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites81.7%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
Applied rewrites2.2%
Taylor expanded in d around 0
*-commutativeN/A
associate-/l*N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
associate-*r/N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6424.3
Applied rewrites24.3%
Final simplification71.4%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* (/ M (* 2.0 d)) D_m))
(t_1 (sqrt (/ d h)))
(t_2 (sqrt (/ d l))))
(if (<=
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l))))
INFINITY)
(* (* (fma t_0 (* t_0 (* (/ h l) -0.5)) 1.0) t_1) t_2)
(*
(* (fma (* (* (/ (/ (* D_m D_m) d) d) h) -0.125) (/ (* M M) l) 1.0) t_1)
t_2))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = (M / (2.0 * d)) * D_m;
double t_1 = sqrt((d / h));
double t_2 = sqrt((d / l));
double tmp;
if (((pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= ((double) INFINITY)) {
tmp = (fma(t_0, (t_0 * ((h / l) * -0.5)), 1.0) * t_1) * t_2;
} else {
tmp = (fma((((((D_m * D_m) / d) / d) * h) * -0.125), ((M * M) / l), 1.0) * t_1) * t_2;
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64(M / Float64(2.0 * d)) * D_m) t_1 = sqrt(Float64(d / h)) t_2 = sqrt(Float64(d / l)) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= Inf) tmp = Float64(Float64(fma(t_0, Float64(t_0 * Float64(Float64(h / l) * -0.5)), 1.0) * t_1) * t_2); else tmp = Float64(Float64(fma(Float64(Float64(Float64(Float64(Float64(D_m * D_m) / d) / d) * h) * -0.125), Float64(Float64(M * M) / l), 1.0) * t_1) * t_2); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(M / N[(2.0 * d), $MachinePrecision]), $MachinePrecision] * D$95$m), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(t$95$0 * N[(t$95$0 * N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$2), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision] * h), $MachinePrecision] * -0.125), $MachinePrecision] * N[(N[(M * M), $MachinePrecision] / l), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$2), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{M}{2 \cdot d} \cdot D\_m\\
t_1 := \sqrt{\frac{d}{h}}\\
t_2 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq \infty:\\
\;\;\;\;\left(\mathsf{fma}\left(t\_0, t\_0 \cdot \left(\frac{h}{\ell} \cdot -0.5\right), 1\right) \cdot t\_1\right) \cdot t\_2\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\left(\frac{\frac{D\_m \cdot D\_m}{d}}{d} \cdot h\right) \cdot -0.125, \frac{M \cdot M}{\ell}, 1\right) \cdot t\_1\right) \cdot t\_2\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 80.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites80.3%
lift-fma.f64N/A
*-commutativeN/A
lift-pow.f64N/A
metadata-evalN/A
pow-powN/A
inv-powN/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
clear-numN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites81.7%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites2.2%
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
*-commutativeN/A
associate-*r/N/A
lift-/.f64N/A
Applied rewrites22.6%
Taylor expanded in d around inf
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l/N/A
associate-*l*N/A
associate-*r/N/A
associate-*l/N/A
times-fracN/A
lower-fma.f64N/A
Applied rewrites20.4%
Final simplification70.7%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (sqrt (pow h -1.0))))
(if (<= d -2e-310)
(/
(*
(*
(fma (* -0.5 (/ h l)) (pow (* (/ 2.0 M) (/ d D_m)) -2.0) 1.0)
(sqrt (/ d l)))
(sqrt (- d)))
(sqrt (- h)))
(if (<= d 2.7e-151)
(*
(fma (* (* M M) (* (/ (/ (* D_m D_m) l) d) -0.125)) (sqrt h) (* t_0 d))
(pow l -0.5))
(if (<= d 1.82e-22)
(*
(/
(fma
(* -0.125 (sqrt h))
(* (* (* M M) D_m) (/ D_m l))
(* t_0 (* d d)))
d)
(pow l -0.5))
(*
(*
(*
(fma (* -0.5 h) (/ (* 0.25 (pow (/ (/ d D_m) M) -2.0)) l) 1.0)
(sqrt (/ d h)))
(sqrt d))
(pow l -0.5)))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = sqrt(pow(h, -1.0));
double tmp;
if (d <= -2e-310) {
tmp = ((fma((-0.5 * (h / l)), pow(((2.0 / M) * (d / D_m)), -2.0), 1.0) * sqrt((d / l))) * sqrt(-d)) / sqrt(-h);
} else if (d <= 2.7e-151) {
tmp = fma(((M * M) * ((((D_m * D_m) / l) / d) * -0.125)), sqrt(h), (t_0 * d)) * pow(l, -0.5);
} else if (d <= 1.82e-22) {
tmp = (fma((-0.125 * sqrt(h)), (((M * M) * D_m) * (D_m / l)), (t_0 * (d * d))) / d) * pow(l, -0.5);
} else {
tmp = ((fma((-0.5 * h), ((0.25 * pow(((d / D_m) / M), -2.0)) / l), 1.0) * sqrt((d / h))) * sqrt(d)) * pow(l, -0.5);
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = sqrt((h ^ -1.0)) tmp = 0.0 if (d <= -2e-310) tmp = Float64(Float64(Float64(fma(Float64(-0.5 * Float64(h / l)), (Float64(Float64(2.0 / M) * Float64(d / D_m)) ^ -2.0), 1.0) * sqrt(Float64(d / l))) * sqrt(Float64(-d))) / sqrt(Float64(-h))); elseif (d <= 2.7e-151) tmp = Float64(fma(Float64(Float64(M * M) * Float64(Float64(Float64(Float64(D_m * D_m) / l) / d) * -0.125)), sqrt(h), Float64(t_0 * d)) * (l ^ -0.5)); elseif (d <= 1.82e-22) tmp = Float64(Float64(fma(Float64(-0.125 * sqrt(h)), Float64(Float64(Float64(M * M) * D_m) * Float64(D_m / l)), Float64(t_0 * Float64(d * d))) / d) * (l ^ -0.5)); else tmp = Float64(Float64(Float64(fma(Float64(-0.5 * h), Float64(Float64(0.25 * (Float64(Float64(d / D_m) / M) ^ -2.0)) / l), 1.0) * sqrt(Float64(d / h))) * sqrt(d)) * (l ^ -0.5)); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[Power[h, -1.0], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -2e-310], N[(N[(N[(N[(N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] * N[Power[N[(N[(2.0 / M), $MachinePrecision] * N[(d / D$95$m), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[(-d)], $MachinePrecision]), $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.7e-151], N[(N[(N[(N[(M * M), $MachinePrecision] * N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] / l), $MachinePrecision] / d), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision] * N[Sqrt[h], $MachinePrecision] + N[(t$95$0 * d), $MachinePrecision]), $MachinePrecision] * N[Power[l, -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.82e-22], N[(N[(N[(N[(-0.125 * N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M * M), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(D$95$m / l), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * N[Power[l, -0.5], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(-0.5 * h), $MachinePrecision] * N[(N[(0.25 * N[Power[N[(N[(d / D$95$m), $MachinePrecision] / M), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[d], $MachinePrecision]), $MachinePrecision] * N[Power[l, -0.5], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{{h}^{-1}}\\
\mathbf{if}\;d \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{\left(\mathsf{fma}\left(-0.5 \cdot \frac{h}{\ell}, {\left(\frac{2}{M} \cdot \frac{d}{D\_m}\right)}^{-2}, 1\right) \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \sqrt{-d}}{\sqrt{-h}}\\
\mathbf{elif}\;d \leq 2.7 \cdot 10^{-151}:\\
\;\;\;\;\mathsf{fma}\left(\left(M \cdot M\right) \cdot \left(\frac{\frac{D\_m \cdot D\_m}{\ell}}{d} \cdot -0.125\right), \sqrt{h}, t\_0 \cdot d\right) \cdot {\ell}^{-0.5}\\
\mathbf{elif}\;d \leq 1.82 \cdot 10^{-22}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.125 \cdot \sqrt{h}, \left(\left(M \cdot M\right) \cdot D\_m\right) \cdot \frac{D\_m}{\ell}, t\_0 \cdot \left(d \cdot d\right)\right)}{d} \cdot {\ell}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(-0.5 \cdot h, \frac{0.25 \cdot {\left(\frac{\frac{d}{D\_m}}{M}\right)}^{-2}}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{d}\right) \cdot {\ell}^{-0.5}\\
\end{array}
\end{array}
if d < -1.999999999999994e-310Initial program 65.4%
Applied rewrites71.2%
if -1.999999999999994e-310 < d < 2.70000000000000007e-151Initial program 42.3%
Applied rewrites56.1%
Taylor expanded in l around inf
Applied rewrites78.1%
if 2.70000000000000007e-151 < d < 1.82e-22Initial program 63.0%
Applied rewrites66.1%
Taylor expanded in d around 0
lower-/.f64N/A
Applied rewrites86.7%
if 1.82e-22 < d Initial program 78.0%
Applied rewrites83.3%
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
*-commutativeN/A
associate-*r/N/A
lift-/.f64N/A
Applied rewrites93.1%
Final simplification79.8%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (sqrt (/ d l))) (t_1 (sqrt (pow h -1.0))))
(if (<= d -2e-310)
(/
(*
(* (fma (* -0.5 (/ h l)) (pow (* (/ 2.0 M) (/ d D_m)) -2.0) 1.0) t_0)
(sqrt (- d)))
(sqrt (- h)))
(if (<= d 2.7e-151)
(*
(fma (* (* M M) (* (/ (/ (* D_m D_m) l) d) -0.125)) (sqrt h) (* t_1 d))
(pow l -0.5))
(if (<= d 4.4e-36)
(*
(/
(fma
(* -0.125 (sqrt h))
(* (* (* M M) D_m) (/ D_m l))
(* t_1 (* d d)))
d)
(pow l -0.5))
(*
(*
(fma (* -0.5 h) (/ (* 0.25 (pow (/ (/ d D_m) M) -2.0)) l) 1.0)
(sqrt (/ d h)))
t_0))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = sqrt((d / l));
double t_1 = sqrt(pow(h, -1.0));
double tmp;
if (d <= -2e-310) {
tmp = ((fma((-0.5 * (h / l)), pow(((2.0 / M) * (d / D_m)), -2.0), 1.0) * t_0) * sqrt(-d)) / sqrt(-h);
} else if (d <= 2.7e-151) {
tmp = fma(((M * M) * ((((D_m * D_m) / l) / d) * -0.125)), sqrt(h), (t_1 * d)) * pow(l, -0.5);
} else if (d <= 4.4e-36) {
tmp = (fma((-0.125 * sqrt(h)), (((M * M) * D_m) * (D_m / l)), (t_1 * (d * d))) / d) * pow(l, -0.5);
} else {
tmp = (fma((-0.5 * h), ((0.25 * pow(((d / D_m) / M), -2.0)) / l), 1.0) * sqrt((d / h))) * t_0;
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = sqrt(Float64(d / l)) t_1 = sqrt((h ^ -1.0)) tmp = 0.0 if (d <= -2e-310) tmp = Float64(Float64(Float64(fma(Float64(-0.5 * Float64(h / l)), (Float64(Float64(2.0 / M) * Float64(d / D_m)) ^ -2.0), 1.0) * t_0) * sqrt(Float64(-d))) / sqrt(Float64(-h))); elseif (d <= 2.7e-151) tmp = Float64(fma(Float64(Float64(M * M) * Float64(Float64(Float64(Float64(D_m * D_m) / l) / d) * -0.125)), sqrt(h), Float64(t_1 * d)) * (l ^ -0.5)); elseif (d <= 4.4e-36) tmp = Float64(Float64(fma(Float64(-0.125 * sqrt(h)), Float64(Float64(Float64(M * M) * D_m) * Float64(D_m / l)), Float64(t_1 * Float64(d * d))) / d) * (l ^ -0.5)); else tmp = Float64(Float64(fma(Float64(-0.5 * h), Float64(Float64(0.25 * (Float64(Float64(d / D_m) / M) ^ -2.0)) / l), 1.0) * sqrt(Float64(d / h))) * t_0); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[Power[h, -1.0], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -2e-310], N[(N[(N[(N[(N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] * N[Power[N[(N[(2.0 / M), $MachinePrecision] * N[(d / D$95$m), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision] + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[(-d)], $MachinePrecision]), $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.7e-151], N[(N[(N[(N[(M * M), $MachinePrecision] * N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] / l), $MachinePrecision] / d), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision] * N[Sqrt[h], $MachinePrecision] + N[(t$95$1 * d), $MachinePrecision]), $MachinePrecision] * N[Power[l, -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.4e-36], N[(N[(N[(N[(-0.125 * N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M * M), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(D$95$m / l), $MachinePrecision]), $MachinePrecision] + N[(t$95$1 * N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * N[Power[l, -0.5], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(-0.5 * h), $MachinePrecision] * N[(N[(0.25 * N[Power[N[(N[(d / D$95$m), $MachinePrecision] / M), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
t_1 := \sqrt{{h}^{-1}}\\
\mathbf{if}\;d \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{\left(\mathsf{fma}\left(-0.5 \cdot \frac{h}{\ell}, {\left(\frac{2}{M} \cdot \frac{d}{D\_m}\right)}^{-2}, 1\right) \cdot t\_0\right) \cdot \sqrt{-d}}{\sqrt{-h}}\\
\mathbf{elif}\;d \leq 2.7 \cdot 10^{-151}:\\
\;\;\;\;\mathsf{fma}\left(\left(M \cdot M\right) \cdot \left(\frac{\frac{D\_m \cdot D\_m}{\ell}}{d} \cdot -0.125\right), \sqrt{h}, t\_1 \cdot d\right) \cdot {\ell}^{-0.5}\\
\mathbf{elif}\;d \leq 4.4 \cdot 10^{-36}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.125 \cdot \sqrt{h}, \left(\left(M \cdot M\right) \cdot D\_m\right) \cdot \frac{D\_m}{\ell}, t\_1 \cdot \left(d \cdot d\right)\right)}{d} \cdot {\ell}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(-0.5 \cdot h, \frac{0.25 \cdot {\left(\frac{\frac{d}{D\_m}}{M}\right)}^{-2}}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot t\_0\\
\end{array}
\end{array}
if d < -1.999999999999994e-310Initial program 65.4%
Applied rewrites71.2%
if -1.999999999999994e-310 < d < 2.70000000000000007e-151Initial program 42.3%
Applied rewrites56.1%
Taylor expanded in l around inf
Applied rewrites78.1%
if 2.70000000000000007e-151 < d < 4.3999999999999999e-36Initial program 58.8%
Applied rewrites62.4%
Taylor expanded in d around 0
lower-/.f64N/A
Applied rewrites85.2%
if 4.3999999999999999e-36 < d Initial program 78.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites80.3%
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
*-commutativeN/A
associate-*r/N/A
lift-/.f64N/A
Applied rewrites88.4%
Final simplification78.4%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (sqrt (/ d h))) (t_1 (sqrt (pow h -1.0))))
(if (<= d -2e-310)
(/
(*
(* (fma (* -0.5 (/ h l)) (pow (* (/ 2.0 M) (/ d D_m)) -2.0) 1.0) t_0)
(sqrt (- d)))
(sqrt (- l)))
(if (<= d 2.7e-151)
(*
(fma (* (* M M) (* (/ (/ (* D_m D_m) l) d) -0.125)) (sqrt h) (* t_1 d))
(pow l -0.5))
(if (<= d 4.4e-36)
(*
(/
(fma
(* -0.125 (sqrt h))
(* (* (* M M) D_m) (/ D_m l))
(* t_1 (* d d)))
d)
(pow l -0.5))
(*
(*
(fma (* -0.5 h) (/ (* 0.25 (pow (/ (/ d D_m) M) -2.0)) l) 1.0)
t_0)
(sqrt (/ d l))))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = sqrt((d / h));
double t_1 = sqrt(pow(h, -1.0));
double tmp;
if (d <= -2e-310) {
tmp = ((fma((-0.5 * (h / l)), pow(((2.0 / M) * (d / D_m)), -2.0), 1.0) * t_0) * sqrt(-d)) / sqrt(-l);
} else if (d <= 2.7e-151) {
tmp = fma(((M * M) * ((((D_m * D_m) / l) / d) * -0.125)), sqrt(h), (t_1 * d)) * pow(l, -0.5);
} else if (d <= 4.4e-36) {
tmp = (fma((-0.125 * sqrt(h)), (((M * M) * D_m) * (D_m / l)), (t_1 * (d * d))) / d) * pow(l, -0.5);
} else {
tmp = (fma((-0.5 * h), ((0.25 * pow(((d / D_m) / M), -2.0)) / l), 1.0) * t_0) * sqrt((d / l));
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = sqrt(Float64(d / h)) t_1 = sqrt((h ^ -1.0)) tmp = 0.0 if (d <= -2e-310) tmp = Float64(Float64(Float64(fma(Float64(-0.5 * Float64(h / l)), (Float64(Float64(2.0 / M) * Float64(d / D_m)) ^ -2.0), 1.0) * t_0) * sqrt(Float64(-d))) / sqrt(Float64(-l))); elseif (d <= 2.7e-151) tmp = Float64(fma(Float64(Float64(M * M) * Float64(Float64(Float64(Float64(D_m * D_m) / l) / d) * -0.125)), sqrt(h), Float64(t_1 * d)) * (l ^ -0.5)); elseif (d <= 4.4e-36) tmp = Float64(Float64(fma(Float64(-0.125 * sqrt(h)), Float64(Float64(Float64(M * M) * D_m) * Float64(D_m / l)), Float64(t_1 * Float64(d * d))) / d) * (l ^ -0.5)); else tmp = Float64(Float64(fma(Float64(-0.5 * h), Float64(Float64(0.25 * (Float64(Float64(d / D_m) / M) ^ -2.0)) / l), 1.0) * t_0) * sqrt(Float64(d / l))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[Power[h, -1.0], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -2e-310], N[(N[(N[(N[(N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] * N[Power[N[(N[(2.0 / M), $MachinePrecision] * N[(d / D$95$m), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision] + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[(-d)], $MachinePrecision]), $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.7e-151], N[(N[(N[(N[(M * M), $MachinePrecision] * N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] / l), $MachinePrecision] / d), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision] * N[Sqrt[h], $MachinePrecision] + N[(t$95$1 * d), $MachinePrecision]), $MachinePrecision] * N[Power[l, -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.4e-36], N[(N[(N[(N[(-0.125 * N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M * M), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(D$95$m / l), $MachinePrecision]), $MachinePrecision] + N[(t$95$1 * N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * N[Power[l, -0.5], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(-0.5 * h), $MachinePrecision] * N[(N[(0.25 * N[Power[N[(N[(d / D$95$m), $MachinePrecision] / M), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h}}\\
t_1 := \sqrt{{h}^{-1}}\\
\mathbf{if}\;d \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{\left(\mathsf{fma}\left(-0.5 \cdot \frac{h}{\ell}, {\left(\frac{2}{M} \cdot \frac{d}{D\_m}\right)}^{-2}, 1\right) \cdot t\_0\right) \cdot \sqrt{-d}}{\sqrt{-\ell}}\\
\mathbf{elif}\;d \leq 2.7 \cdot 10^{-151}:\\
\;\;\;\;\mathsf{fma}\left(\left(M \cdot M\right) \cdot \left(\frac{\frac{D\_m \cdot D\_m}{\ell}}{d} \cdot -0.125\right), \sqrt{h}, t\_1 \cdot d\right) \cdot {\ell}^{-0.5}\\
\mathbf{elif}\;d \leq 4.4 \cdot 10^{-36}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.125 \cdot \sqrt{h}, \left(\left(M \cdot M\right) \cdot D\_m\right) \cdot \frac{D\_m}{\ell}, t\_1 \cdot \left(d \cdot d\right)\right)}{d} \cdot {\ell}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(-0.5 \cdot h, \frac{0.25 \cdot {\left(\frac{\frac{d}{D\_m}}{M}\right)}^{-2}}{\ell}, 1\right) \cdot t\_0\right) \cdot \sqrt{\frac{d}{\ell}}\\
\end{array}
\end{array}
if d < -1.999999999999994e-310Initial program 65.4%
Applied rewrites70.9%
if -1.999999999999994e-310 < d < 2.70000000000000007e-151Initial program 42.3%
Applied rewrites56.1%
Taylor expanded in l around inf
Applied rewrites78.1%
if 2.70000000000000007e-151 < d < 4.3999999999999999e-36Initial program 58.8%
Applied rewrites62.4%
Taylor expanded in d around 0
lower-/.f64N/A
Applied rewrites85.2%
if 4.3999999999999999e-36 < d Initial program 78.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites80.3%
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
*-commutativeN/A
associate-*r/N/A
lift-/.f64N/A
Applied rewrites88.4%
Final simplification78.2%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (sqrt (/ d h))) (t_1 (sqrt (/ d l))) (t_2 (sqrt (pow h -1.0))))
(if (<= d -2e-310)
(*
(* (fma (* -0.5 h) (/ (* 0.25 (pow (/ d (* M D_m)) -2.0)) l) 1.0) t_0)
t_1)
(if (<= d 2.7e-151)
(*
(fma (* (* M M) (* (/ (/ (* D_m D_m) l) d) -0.125)) (sqrt h) (* t_2 d))
(pow l -0.5))
(if (<= d 4.4e-36)
(*
(/
(fma
(* -0.125 (sqrt h))
(* (* (* M M) D_m) (/ D_m l))
(* t_2 (* d d)))
d)
(pow l -0.5))
(*
(*
(fma (* -0.5 h) (/ (* 0.25 (pow (/ (/ d D_m) M) -2.0)) l) 1.0)
t_0)
t_1))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = sqrt((d / h));
double t_1 = sqrt((d / l));
double t_2 = sqrt(pow(h, -1.0));
double tmp;
if (d <= -2e-310) {
tmp = (fma((-0.5 * h), ((0.25 * pow((d / (M * D_m)), -2.0)) / l), 1.0) * t_0) * t_1;
} else if (d <= 2.7e-151) {
tmp = fma(((M * M) * ((((D_m * D_m) / l) / d) * -0.125)), sqrt(h), (t_2 * d)) * pow(l, -0.5);
} else if (d <= 4.4e-36) {
tmp = (fma((-0.125 * sqrt(h)), (((M * M) * D_m) * (D_m / l)), (t_2 * (d * d))) / d) * pow(l, -0.5);
} else {
tmp = (fma((-0.5 * h), ((0.25 * pow(((d / D_m) / M), -2.0)) / l), 1.0) * t_0) * t_1;
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = sqrt(Float64(d / h)) t_1 = sqrt(Float64(d / l)) t_2 = sqrt((h ^ -1.0)) tmp = 0.0 if (d <= -2e-310) tmp = Float64(Float64(fma(Float64(-0.5 * h), Float64(Float64(0.25 * (Float64(d / Float64(M * D_m)) ^ -2.0)) / l), 1.0) * t_0) * t_1); elseif (d <= 2.7e-151) tmp = Float64(fma(Float64(Float64(M * M) * Float64(Float64(Float64(Float64(D_m * D_m) / l) / d) * -0.125)), sqrt(h), Float64(t_2 * d)) * (l ^ -0.5)); elseif (d <= 4.4e-36) tmp = Float64(Float64(fma(Float64(-0.125 * sqrt(h)), Float64(Float64(Float64(M * M) * D_m) * Float64(D_m / l)), Float64(t_2 * Float64(d * d))) / d) * (l ^ -0.5)); else tmp = Float64(Float64(fma(Float64(-0.5 * h), Float64(Float64(0.25 * (Float64(Float64(d / D_m) / M) ^ -2.0)) / l), 1.0) * t_0) * t_1); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[Power[h, -1.0], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -2e-310], N[(N[(N[(N[(-0.5 * h), $MachinePrecision] * N[(N[(0.25 * N[Power[N[(d / N[(M * D$95$m), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[d, 2.7e-151], N[(N[(N[(N[(M * M), $MachinePrecision] * N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] / l), $MachinePrecision] / d), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision] * N[Sqrt[h], $MachinePrecision] + N[(t$95$2 * d), $MachinePrecision]), $MachinePrecision] * N[Power[l, -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.4e-36], N[(N[(N[(N[(-0.125 * N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M * M), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(D$95$m / l), $MachinePrecision]), $MachinePrecision] + N[(t$95$2 * N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * N[Power[l, -0.5], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(-0.5 * h), $MachinePrecision] * N[(N[(0.25 * N[Power[N[(N[(d / D$95$m), $MachinePrecision] / M), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h}}\\
t_1 := \sqrt{\frac{d}{\ell}}\\
t_2 := \sqrt{{h}^{-1}}\\
\mathbf{if}\;d \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\left(\mathsf{fma}\left(-0.5 \cdot h, \frac{0.25 \cdot {\left(\frac{d}{M \cdot D\_m}\right)}^{-2}}{\ell}, 1\right) \cdot t\_0\right) \cdot t\_1\\
\mathbf{elif}\;d \leq 2.7 \cdot 10^{-151}:\\
\;\;\;\;\mathsf{fma}\left(\left(M \cdot M\right) \cdot \left(\frac{\frac{D\_m \cdot D\_m}{\ell}}{d} \cdot -0.125\right), \sqrt{h}, t\_2 \cdot d\right) \cdot {\ell}^{-0.5}\\
\mathbf{elif}\;d \leq 4.4 \cdot 10^{-36}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.125 \cdot \sqrt{h}, \left(\left(M \cdot M\right) \cdot D\_m\right) \cdot \frac{D\_m}{\ell}, t\_2 \cdot \left(d \cdot d\right)\right)}{d} \cdot {\ell}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(-0.5 \cdot h, \frac{0.25 \cdot {\left(\frac{\frac{d}{D\_m}}{M}\right)}^{-2}}{\ell}, 1\right) \cdot t\_0\right) \cdot t\_1\\
\end{array}
\end{array}
if d < -1.999999999999994e-310Initial program 65.4%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites65.4%
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
*-commutativeN/A
associate-*r/N/A
lift-/.f64N/A
Applied rewrites69.4%
lift-/.f64N/A
lift-/.f64N/A
associate-/r*N/A
lift-*.f64N/A
lower-/.f6469.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.4
Applied rewrites69.4%
if -1.999999999999994e-310 < d < 2.70000000000000007e-151Initial program 42.3%
Applied rewrites56.1%
Taylor expanded in l around inf
Applied rewrites78.1%
if 2.70000000000000007e-151 < d < 4.3999999999999999e-36Initial program 58.8%
Applied rewrites62.4%
Taylor expanded in d around 0
lower-/.f64N/A
Applied rewrites85.2%
if 4.3999999999999999e-36 < d Initial program 78.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites80.3%
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
*-commutativeN/A
associate-*r/N/A
lift-/.f64N/A
Applied rewrites88.4%
Final simplification77.5%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0
(*
(*
(fma (* -0.5 h) (/ (* 0.25 (pow (/ d (* M D_m)) -2.0)) l) 1.0)
(sqrt (/ d h)))
(sqrt (/ d l))))
(t_1 (sqrt (pow h -1.0))))
(if (<= d -2e-310)
t_0
(if (<= d 2.7e-151)
(*
(fma (* (* M M) (* (/ (/ (* D_m D_m) l) d) -0.125)) (sqrt h) (* t_1 d))
(pow l -0.5))
(if (<= d 4.4e-36)
(*
(/
(fma
(* -0.125 (sqrt h))
(* (* (* M M) D_m) (/ D_m l))
(* t_1 (* d d)))
d)
(pow l -0.5))
t_0)))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = (fma((-0.5 * h), ((0.25 * pow((d / (M * D_m)), -2.0)) / l), 1.0) * sqrt((d / h))) * sqrt((d / l));
double t_1 = sqrt(pow(h, -1.0));
double tmp;
if (d <= -2e-310) {
tmp = t_0;
} else if (d <= 2.7e-151) {
tmp = fma(((M * M) * ((((D_m * D_m) / l) / d) * -0.125)), sqrt(h), (t_1 * d)) * pow(l, -0.5);
} else if (d <= 4.4e-36) {
tmp = (fma((-0.125 * sqrt(h)), (((M * M) * D_m) * (D_m / l)), (t_1 * (d * d))) / d) * pow(l, -0.5);
} else {
tmp = t_0;
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64(fma(Float64(-0.5 * h), Float64(Float64(0.25 * (Float64(d / Float64(M * D_m)) ^ -2.0)) / l), 1.0) * sqrt(Float64(d / h))) * sqrt(Float64(d / l))) t_1 = sqrt((h ^ -1.0)) tmp = 0.0 if (d <= -2e-310) tmp = t_0; elseif (d <= 2.7e-151) tmp = Float64(fma(Float64(Float64(M * M) * Float64(Float64(Float64(Float64(D_m * D_m) / l) / d) * -0.125)), sqrt(h), Float64(t_1 * d)) * (l ^ -0.5)); elseif (d <= 4.4e-36) tmp = Float64(Float64(fma(Float64(-0.125 * sqrt(h)), Float64(Float64(Float64(M * M) * D_m) * Float64(D_m / l)), Float64(t_1 * Float64(d * d))) / d) * (l ^ -0.5)); else tmp = t_0; end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(N[(N[(-0.5 * h), $MachinePrecision] * N[(N[(0.25 * N[Power[N[(d / N[(M * D$95$m), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[Power[h, -1.0], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -2e-310], t$95$0, If[LessEqual[d, 2.7e-151], N[(N[(N[(N[(M * M), $MachinePrecision] * N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] / l), $MachinePrecision] / d), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision] * N[Sqrt[h], $MachinePrecision] + N[(t$95$1 * d), $MachinePrecision]), $MachinePrecision] * N[Power[l, -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.4e-36], N[(N[(N[(N[(-0.125 * N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M * M), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(D$95$m / l), $MachinePrecision]), $MachinePrecision] + N[(t$95$1 * N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * N[Power[l, -0.5], $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \left(\mathsf{fma}\left(-0.5 \cdot h, \frac{0.25 \cdot {\left(\frac{d}{M \cdot D\_m}\right)}^{-2}}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}}\\
t_1 := \sqrt{{h}^{-1}}\\
\mathbf{if}\;d \leq -2 \cdot 10^{-310}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 2.7 \cdot 10^{-151}:\\
\;\;\;\;\mathsf{fma}\left(\left(M \cdot M\right) \cdot \left(\frac{\frac{D\_m \cdot D\_m}{\ell}}{d} \cdot -0.125\right), \sqrt{h}, t\_1 \cdot d\right) \cdot {\ell}^{-0.5}\\
\mathbf{elif}\;d \leq 4.4 \cdot 10^{-36}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.125 \cdot \sqrt{h}, \left(\left(M \cdot M\right) \cdot D\_m\right) \cdot \frac{D\_m}{\ell}, t\_1 \cdot \left(d \cdot d\right)\right)}{d} \cdot {\ell}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -1.999999999999994e-310 or 4.3999999999999999e-36 < d Initial program 70.4%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites70.9%
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
*-commutativeN/A
associate-*r/N/A
lift-/.f64N/A
Applied rewrites76.4%
lift-/.f64N/A
lift-/.f64N/A
associate-/r*N/A
lift-*.f64N/A
lower-/.f6476.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6476.4
Applied rewrites76.4%
if -1.999999999999994e-310 < d < 2.70000000000000007e-151Initial program 42.3%
Applied rewrites56.1%
Taylor expanded in l around inf
Applied rewrites78.1%
if 2.70000000000000007e-151 < d < 4.3999999999999999e-36Initial program 58.8%
Applied rewrites62.4%
Taylor expanded in d around 0
lower-/.f64N/A
Applied rewrites85.2%
Final simplification77.5%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (sqrt (/ d h))) (t_1 (sqrt (/ d l))))
(if (<= (* M D_m) 5e-94)
(/ t_1 (sqrt (/ h d)))
(if (<= (* M D_m) 6e+205)
(*
(* t_0 t_1)
(-
1.0
(/ (* (* (/ h l) 0.5) (* D_m M)) (/ (* 4.0 (* d d)) (* D_m M)))))
(*
(* (* (* (* (/ (/ (* D_m D_m) d) d) h) -0.125) (/ (* M M) l)) t_0)
t_1)))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = sqrt((d / h));
double t_1 = sqrt((d / l));
double tmp;
if ((M * D_m) <= 5e-94) {
tmp = t_1 / sqrt((h / d));
} else if ((M * D_m) <= 6e+205) {
tmp = (t_0 * t_1) * (1.0 - ((((h / l) * 0.5) * (D_m * M)) / ((4.0 * (d * d)) / (D_m * M))));
} else {
tmp = (((((((D_m * D_m) / d) / d) * h) * -0.125) * ((M * M) / l)) * t_0) * t_1;
}
return tmp;
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sqrt((d / h))
t_1 = sqrt((d / l))
if ((m * d_m) <= 5d-94) then
tmp = t_1 / sqrt((h / d))
else if ((m * d_m) <= 6d+205) then
tmp = (t_0 * t_1) * (1.0d0 - ((((h / l) * 0.5d0) * (d_m * m)) / ((4.0d0 * (d * d)) / (d_m * m))))
else
tmp = (((((((d_m * d_m) / d) / d) * h) * (-0.125d0)) * ((m * m) / l)) * t_0) * t_1
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = Math.sqrt((d / h));
double t_1 = Math.sqrt((d / l));
double tmp;
if ((M * D_m) <= 5e-94) {
tmp = t_1 / Math.sqrt((h / d));
} else if ((M * D_m) <= 6e+205) {
tmp = (t_0 * t_1) * (1.0 - ((((h / l) * 0.5) * (D_m * M)) / ((4.0 * (d * d)) / (D_m * M))));
} else {
tmp = (((((((D_m * D_m) / d) / d) * h) * -0.125) * ((M * M) / l)) * t_0) * t_1;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = math.sqrt((d / h)) t_1 = math.sqrt((d / l)) tmp = 0 if (M * D_m) <= 5e-94: tmp = t_1 / math.sqrt((h / d)) elif (M * D_m) <= 6e+205: tmp = (t_0 * t_1) * (1.0 - ((((h / l) * 0.5) * (D_m * M)) / ((4.0 * (d * d)) / (D_m * M)))) else: tmp = (((((((D_m * D_m) / d) / d) * h) * -0.125) * ((M * M) / l)) * t_0) * t_1 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = sqrt(Float64(d / h)) t_1 = sqrt(Float64(d / l)) tmp = 0.0 if (Float64(M * D_m) <= 5e-94) tmp = Float64(t_1 / sqrt(Float64(h / d))); elseif (Float64(M * D_m) <= 6e+205) tmp = Float64(Float64(t_0 * t_1) * Float64(1.0 - Float64(Float64(Float64(Float64(h / l) * 0.5) * Float64(D_m * M)) / Float64(Float64(4.0 * Float64(d * d)) / Float64(D_m * M))))); else tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(D_m * D_m) / d) / d) * h) * -0.125) * Float64(Float64(M * M) / l)) * t_0) * t_1); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = sqrt((d / h));
t_1 = sqrt((d / l));
tmp = 0.0;
if ((M * D_m) <= 5e-94)
tmp = t_1 / sqrt((h / d));
elseif ((M * D_m) <= 6e+205)
tmp = (t_0 * t_1) * (1.0 - ((((h / l) * 0.5) * (D_m * M)) / ((4.0 * (d * d)) / (D_m * M))));
else
tmp = (((((((D_m * D_m) / d) / d) * h) * -0.125) * ((M * M) / l)) * t_0) * t_1;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(M * D$95$m), $MachinePrecision], 5e-94], N[(t$95$1 / N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(M * D$95$m), $MachinePrecision], 6e+205], N[(N[(t$95$0 * t$95$1), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(h / l), $MachinePrecision] * 0.5), $MachinePrecision] * N[(D$95$m * M), $MachinePrecision]), $MachinePrecision] / N[(N[(4.0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(D$95$m * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision] * h), $MachinePrecision] * -0.125), $MachinePrecision] * N[(N[(M * M), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h}}\\
t_1 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;M \cdot D\_m \leq 5 \cdot 10^{-94}:\\
\;\;\;\;\frac{t\_1}{\sqrt{\frac{h}{d}}}\\
\mathbf{elif}\;M \cdot D\_m \leq 6 \cdot 10^{+205}:\\
\;\;\;\;\left(t\_0 \cdot t\_1\right) \cdot \left(1 - \frac{\left(\frac{h}{\ell} \cdot 0.5\right) \cdot \left(D\_m \cdot M\right)}{\frac{4 \cdot \left(d \cdot d\right)}{D\_m \cdot M}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(\left(\frac{\frac{D\_m \cdot D\_m}{d}}{d} \cdot h\right) \cdot -0.125\right) \cdot \frac{M \cdot M}{\ell}\right) \cdot t\_0\right) \cdot t\_1\\
\end{array}
\end{array}
if (*.f64 M D) < 4.9999999999999995e-94Initial program 65.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6436.3
Applied rewrites36.3%
Applied rewrites46.5%
if 4.9999999999999995e-94 < (*.f64 M D) < 5.9999999999999999e205Initial program 72.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-/.f64N/A
clear-numN/A
frac-timesN/A
*-rgt-identityN/A
associate-*r/N/A
associate-*r/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites71.0%
lift-/.f64N/A
lift-pow.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6471.0
Applied rewrites71.0%
lift-/.f64N/A
lift-pow.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6471.0
Applied rewrites71.0%
if 5.9999999999999999e205 < (*.f64 M D) Initial program 59.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites64.6%
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
*-commutativeN/A
associate-*r/N/A
lift-/.f64N/A
Applied rewrites78.3%
Taylor expanded in d around 0
*-commutativeN/A
associate-*r*N/A
associate-*l/N/A
associate-*l*N/A
associate-*r/N/A
associate-*l/N/A
times-fracN/A
lower-*.f64N/A
Applied rewrites77.9%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(if (<= l -5e-310)
(/ (/ (- d) (sqrt (- l))) (sqrt (- h)))
(if (<= l 1.2e+129)
(*
(fma (* (/ (* (/ D_m (/ (* d d) M)) M) 4.0) D_m) (* (/ h l) -0.5) 1.0)
(/ d (sqrt (* l h))))
(/ d (* (sqrt l) (sqrt h))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (l <= -5e-310) {
tmp = (-d / sqrt(-l)) / sqrt(-h);
} else if (l <= 1.2e+129) {
tmp = fma(((((D_m / ((d * d) / M)) * M) / 4.0) * D_m), ((h / l) * -0.5), 1.0) * (d / sqrt((l * h)));
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) tmp = 0.0 if (l <= -5e-310) tmp = Float64(Float64(Float64(-d) / sqrt(Float64(-l))) / sqrt(Float64(-h))); elseif (l <= 1.2e+129) tmp = Float64(fma(Float64(Float64(Float64(Float64(D_m / Float64(Float64(d * d) / M)) * M) / 4.0) * D_m), Float64(Float64(h / l) * -0.5), 1.0) * Float64(d / sqrt(Float64(l * h)))); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); end return tmp end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[l, -5e-310], N[(N[((-d) / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.2e+129], N[(N[(N[(N[(N[(N[(D$95$m / N[(N[(d * d), $MachinePrecision] / M), $MachinePrecision]), $MachinePrecision] * M), $MachinePrecision] / 4.0), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] + 1.0), $MachinePrecision] * N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{\frac{-d}{\sqrt{-\ell}}}{\sqrt{-h}}\\
\mathbf{elif}\;\ell \leq 1.2 \cdot 10^{+129}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{D\_m}{\frac{d \cdot d}{M}} \cdot M}{4} \cdot D\_m, \frac{h}{\ell} \cdot -0.5, 1\right) \cdot \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < -4.999999999999985e-310Initial program 65.4%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f649.8
Applied rewrites9.8%
Applied rewrites33.1%
Applied rewrites45.5%
if -4.999999999999985e-310 < l < 1.1999999999999999e129Initial program 72.3%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-/.f64N/A
clear-numN/A
frac-timesN/A
*-rgt-identityN/A
associate-*r/N/A
associate-*r/N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites63.3%
lift-/.f64N/A
lift-pow.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6463.3
Applied rewrites63.3%
Applied rewrites59.0%
Applied rewrites64.7%
if 1.1999999999999999e129 < l Initial program 55.2%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6458.3
Applied rewrites58.3%
Applied rewrites58.2%
Applied rewrites67.9%
Final simplification55.6%
D_m = (fabs.f64 D) NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M D_m) :precision binary64 (if (<= l -5e-310) (/ (/ (- d) (sqrt (- l))) (sqrt (- h))) (/ d (* (sqrt l) (sqrt h)))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (l <= -5e-310) {
tmp = (-d / sqrt(-l)) / sqrt(-h);
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: tmp
if (l <= (-5d-310)) then
tmp = (-d / sqrt(-l)) / sqrt(-h)
else
tmp = d / (sqrt(l) * sqrt(h))
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (l <= -5e-310) {
tmp = (-d / Math.sqrt(-l)) / Math.sqrt(-h);
} else {
tmp = d / (Math.sqrt(l) * Math.sqrt(h));
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): tmp = 0 if l <= -5e-310: tmp = (-d / math.sqrt(-l)) / math.sqrt(-h) else: tmp = d / (math.sqrt(l) * math.sqrt(h)) return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) tmp = 0.0 if (l <= -5e-310) tmp = Float64(Float64(Float64(-d) / sqrt(Float64(-l))) / sqrt(Float64(-h))); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
tmp = 0.0;
if (l <= -5e-310)
tmp = (-d / sqrt(-l)) / sqrt(-h);
else
tmp = d / (sqrt(l) * sqrt(h));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[l, -5e-310], N[(N[((-d) / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{\frac{-d}{\sqrt{-\ell}}}{\sqrt{-h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < -4.999999999999985e-310Initial program 65.4%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f649.8
Applied rewrites9.8%
Applied rewrites33.1%
Applied rewrites45.5%
if -4.999999999999985e-310 < l Initial program 67.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6451.9
Applied rewrites51.9%
Applied rewrites51.9%
Applied rewrites57.1%
Final simplification51.3%
D_m = (fabs.f64 D) NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M D_m) :precision binary64 (if (<= l 7.8e-259) (/ (- d) (sqrt (* l h))) (/ d (* (sqrt l) (sqrt h)))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (l <= 7.8e-259) {
tmp = -d / sqrt((l * h));
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: tmp
if (l <= 7.8d-259) then
tmp = -d / sqrt((l * h))
else
tmp = d / (sqrt(l) * sqrt(h))
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (l <= 7.8e-259) {
tmp = -d / Math.sqrt((l * h));
} else {
tmp = d / (Math.sqrt(l) * Math.sqrt(h));
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): tmp = 0 if l <= 7.8e-259: tmp = -d / math.sqrt((l * h)) else: tmp = d / (math.sqrt(l) * math.sqrt(h)) return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) tmp = 0.0 if (l <= 7.8e-259) tmp = Float64(Float64(-d) / sqrt(Float64(l * h))); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
tmp = 0.0;
if (l <= 7.8e-259)
tmp = -d / sqrt((l * h));
else
tmp = d / (sqrt(l) * sqrt(h));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[l, 7.8e-259], N[((-d) / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 7.8 \cdot 10^{-259}:\\
\;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < 7.80000000000000031e-259Initial program 66.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6411.3
Applied rewrites11.3%
Applied rewrites11.3%
Applied rewrites39.9%
if 7.80000000000000031e-259 < l Initial program 66.0%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6453.7
Applied rewrites53.7%
Applied rewrites53.7%
Applied rewrites59.3%
Final simplification48.8%
D_m = (fabs.f64 D) NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M D_m) :precision binary64 (let* ((t_0 (sqrt (* l h)))) (if (<= d -3.4e-171) (/ (- d) t_0) (/ d t_0))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = sqrt((l * h));
double tmp;
if (d <= -3.4e-171) {
tmp = -d / t_0;
} else {
tmp = d / t_0;
}
return tmp;
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((l * h))
if (d <= (-3.4d-171)) then
tmp = -d / t_0
else
tmp = d / t_0
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = Math.sqrt((l * h));
double tmp;
if (d <= -3.4e-171) {
tmp = -d / t_0;
} else {
tmp = d / t_0;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = math.sqrt((l * h)) tmp = 0 if d <= -3.4e-171: tmp = -d / t_0 else: tmp = d / t_0 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = sqrt(Float64(l * h)) tmp = 0.0 if (d <= -3.4e-171) tmp = Float64(Float64(-d) / t_0); else tmp = Float64(d / t_0); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = sqrt((l * h));
tmp = 0.0;
if (d <= -3.4e-171)
tmp = -d / t_0;
else
tmp = d / t_0;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -3.4e-171], N[((-d) / t$95$0), $MachinePrecision], N[(d / t$95$0), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;d \leq -3.4 \cdot 10^{-171}:\\
\;\;\;\;\frac{-d}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{t\_0}\\
\end{array}
\end{array}
if d < -3.39999999999999985e-171Initial program 73.3%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f647.4
Applied rewrites7.4%
Applied rewrites7.4%
Applied rewrites46.9%
if -3.39999999999999985e-171 < d Initial program 61.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6446.1
Applied rewrites46.1%
Applied rewrites46.1%
Final simplification46.4%
D_m = (fabs.f64 D) NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M D_m) :precision binary64 (/ d (sqrt (* l h))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
return d / sqrt((l * h));
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
code = d / sqrt((l * h))
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
return d / Math.sqrt((l * h));
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): return d / math.sqrt((l * h))
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) return Float64(d / sqrt(Float64(l * h))) end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp = code(d, h, l, M, D_m)
tmp = d / sqrt((l * h));
end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\frac{d}{\sqrt{\ell \cdot h}}
\end{array}
Initial program 66.3%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6430.8
Applied rewrites30.8%
Applied rewrites30.9%
herbie shell --seed 2024298
(FPCore (d h l M D)
:name "Henrywood and Agarwal, Equation (12)"
:precision binary64
(* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))