
(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 12 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}
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (sqrt (/ d h))) (t_1 (sqrt (/ d l))))
(if (<= d -5.2e-303)
(*
(pow (* (pow (- d) 0.25) (pow (/ -1.0 l) 0.25)) 2.0)
(* t_0 (fma (/ h l) (* (pow (* D (/ M d)) 2.0) -0.125) 1.0)))
(if (<= d 8e-148)
(*
d
(*
(fma -0.125 (* (* h M) (* (/ D d) (* M (/ (/ D d) l)))) 1.0)
(sqrt (/ 1.0 (* l h)))))
(if (<= d 1.65e+88)
(*
(* t_0 t_1)
(- 1.0 (* 0.5 (* 0.25 (* (/ D (/ d (/ M l))) (* h (/ D (/ d M))))))))
(*
(* t_1 (/ (sqrt d) (sqrt h)))
(- 1.0 (* 0.5 (* (/ h l) (pow (* (/ D d) (/ M 2.0)) 2.0))))))))))M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = sqrt((d / h));
double t_1 = sqrt((d / l));
double tmp;
if (d <= -5.2e-303) {
tmp = pow((pow(-d, 0.25) * pow((-1.0 / l), 0.25)), 2.0) * (t_0 * fma((h / l), (pow((D * (M / d)), 2.0) * -0.125), 1.0));
} else if (d <= 8e-148) {
tmp = d * (fma(-0.125, ((h * M) * ((D / d) * (M * ((D / d) / l)))), 1.0) * sqrt((1.0 / (l * h))));
} else if (d <= 1.65e+88) {
tmp = (t_0 * t_1) * (1.0 - (0.5 * (0.25 * ((D / (d / (M / l))) * (h * (D / (d / M)))))));
} else {
tmp = (t_1 * (sqrt(d) / sqrt(h))) * (1.0 - (0.5 * ((h / l) * pow(((D / d) * (M / 2.0)), 2.0))));
}
return tmp;
}
M = abs(M) M, D = sort([M, D]) function code(d, h, l, M, D) t_0 = sqrt(Float64(d / h)) t_1 = sqrt(Float64(d / l)) tmp = 0.0 if (d <= -5.2e-303) tmp = Float64((Float64((Float64(-d) ^ 0.25) * (Float64(-1.0 / l) ^ 0.25)) ^ 2.0) * Float64(t_0 * fma(Float64(h / l), Float64((Float64(D * Float64(M / d)) ^ 2.0) * -0.125), 1.0))); elseif (d <= 8e-148) tmp = Float64(d * Float64(fma(-0.125, Float64(Float64(h * M) * Float64(Float64(D / d) * Float64(M * Float64(Float64(D / d) / l)))), 1.0) * sqrt(Float64(1.0 / Float64(l * h))))); elseif (d <= 1.65e+88) tmp = Float64(Float64(t_0 * t_1) * Float64(1.0 - Float64(0.5 * Float64(0.25 * Float64(Float64(D / Float64(d / Float64(M / l))) * Float64(h * Float64(D / Float64(d / M)))))))); else tmp = Float64(Float64(t_1 * Float64(sqrt(d) / sqrt(h))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M / 2.0)) ^ 2.0))))); end return tmp end
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -5.2e-303], N[(N[Power[N[(N[Power[(-d), 0.25], $MachinePrecision] * N[Power[N[(-1.0 / l), $MachinePrecision], 0.25], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(t$95$0 * N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.125), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 8e-148], N[(d * N[(N[(-0.125 * N[(N[(h * M), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(M * N[(N[(D / d), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.65e+88], N[(N[(t$95$0 * t$95$1), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(0.25 * N[(N[(D / N[(d / N[(M / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h * N[(D / N[(d / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h}}\\
t_1 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;d \leq -5.2 \cdot 10^{-303}:\\
\;\;\;\;{\left({\left(-d\right)}^{0.25} \cdot {\left(\frac{-1}{\ell}\right)}^{0.25}\right)}^{2} \cdot \left(t_0 \cdot \mathsf{fma}\left(\frac{h}{\ell}, {\left(D \cdot \frac{M}{d}\right)}^{2} \cdot -0.125, 1\right)\right)\\
\mathbf{elif}\;d \leq 8 \cdot 10^{-148}:\\
\;\;\;\;d \cdot \left(\mathsf{fma}\left(-0.125, \left(h \cdot M\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot \frac{\frac{D}{d}}{\ell}\right)\right), 1\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)\\
\mathbf{elif}\;d \leq 1.65 \cdot 10^{+88}:\\
\;\;\;\;\left(t_0 \cdot t_1\right) \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot \left(\frac{D}{\frac{d}{\frac{M}{\ell}}} \cdot \left(h \cdot \frac{D}{\frac{d}{M}}\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t_1 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right) \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\right)\right)\\
\end{array}
\end{array}
if d < -5.20000000000000009e-303Initial program 69.9%
Simplified69.4%
fma-udef69.4%
unpow-prod-down69.4%
metadata-eval69.4%
div-inv69.4%
clear-num69.4%
Applied egg-rr69.4%
associate-*r*69.4%
*-commutative69.4%
*-commutative69.4%
unpow269.4%
metadata-eval69.4%
swap-sqr69.4%
*-commutative69.4%
associate-*r*69.4%
*-commutative69.4%
*-commutative69.4%
associate-*r*69.4%
*-commutative69.4%
unpow269.4%
Simplified69.8%
pow1/269.8%
sqr-pow69.7%
pow269.7%
metadata-eval69.7%
Applied egg-rr69.7%
Taylor expanded in l around -inf 75.1%
+-commutative75.1%
distribute-lft-in75.1%
*-commutative75.1%
exp-sum75.3%
*-commutative75.3%
exp-to-pow75.8%
mul-1-neg75.8%
metadata-eval75.8%
distribute-neg-frac75.8%
exp-to-pow78.3%
distribute-neg-frac78.3%
metadata-eval78.3%
Simplified78.3%
if -5.20000000000000009e-303 < d < 7.99999999999999949e-148Initial program 47.4%
Simplified44.8%
add-log-exp31.8%
*-commutative31.8%
exp-prod32.4%
Applied egg-rr23.8%
Taylor expanded in M around inf 39.6%
Simplified64.6%
if 7.99999999999999949e-148 < d < 1.6500000000000002e88Initial program 85.4%
Simplified85.4%
Taylor expanded in M around 0 64.6%
*-commutative64.6%
*-commutative64.6%
associate-/l*62.9%
unpow262.9%
unpow262.9%
associate-*r*62.9%
*-commutative62.9%
unpow262.9%
associate-*l*64.7%
Simplified64.7%
times-frac69.9%
*-commutative69.9%
Applied egg-rr69.9%
times-frac87.3%
associate-/l*87.3%
*-commutative87.3%
Applied egg-rr87.3%
Taylor expanded in D around 0 89.0%
associate-*l/87.3%
*-commutative87.3%
associate-*l*90.8%
*-commutative90.8%
associate-/r/90.8%
Simplified90.8%
if 1.6500000000000002e88 < d Initial program 73.1%
Simplified73.2%
sqrt-div92.1%
Applied egg-rr92.1%
Final simplification81.3%
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (* (* h M) (* (/ D d) (* M (/ (/ D d) l)))))
(t_1 (sqrt (/ d l)))
(t_2 (* (sqrt (/ d h)) t_1)))
(if (<= d -1.44e-55)
(* t_2 (- 1.0 (* 0.5 (* 0.25 t_0))))
(if (<= d -5.2e-303)
(*
(/ d (sqrt (* l h)))
(- -1.0 (* -0.5 (* (/ h l) (pow (* M (* (/ D d) 0.5)) 2.0)))))
(if (<= d 1.35e-146)
(* d (* (fma -0.125 t_0 1.0) (sqrt (/ 1.0 (* l h)))))
(if (<= d 3.1e+91)
(*
t_2
(-
1.0
(* 0.5 (* 0.25 (* (/ D (/ d (/ M l))) (* h (/ D (/ d M))))))))
(*
(* t_1 (/ (sqrt d) (sqrt h)))
(- 1.0 (* 0.5 (* (/ h l) (pow (* (/ D d) (/ M 2.0)) 2.0)))))))))))M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = (h * M) * ((D / d) * (M * ((D / d) / l)));
double t_1 = sqrt((d / l));
double t_2 = sqrt((d / h)) * t_1;
double tmp;
if (d <= -1.44e-55) {
tmp = t_2 * (1.0 - (0.5 * (0.25 * t_0)));
} else if (d <= -5.2e-303) {
tmp = (d / sqrt((l * h))) * (-1.0 - (-0.5 * ((h / l) * pow((M * ((D / d) * 0.5)), 2.0))));
} else if (d <= 1.35e-146) {
tmp = d * (fma(-0.125, t_0, 1.0) * sqrt((1.0 / (l * h))));
} else if (d <= 3.1e+91) {
tmp = t_2 * (1.0 - (0.5 * (0.25 * ((D / (d / (M / l))) * (h * (D / (d / M)))))));
} else {
tmp = (t_1 * (sqrt(d) / sqrt(h))) * (1.0 - (0.5 * ((h / l) * pow(((D / d) * (M / 2.0)), 2.0))));
}
return tmp;
}
M = abs(M) M, D = sort([M, D]) function code(d, h, l, M, D) t_0 = Float64(Float64(h * M) * Float64(Float64(D / d) * Float64(M * Float64(Float64(D / d) / l)))) t_1 = sqrt(Float64(d / l)) t_2 = Float64(sqrt(Float64(d / h)) * t_1) tmp = 0.0 if (d <= -1.44e-55) tmp = Float64(t_2 * Float64(1.0 - Float64(0.5 * Float64(0.25 * t_0)))); elseif (d <= -5.2e-303) tmp = Float64(Float64(d / sqrt(Float64(l * h))) * Float64(-1.0 - Float64(-0.5 * Float64(Float64(h / l) * (Float64(M * Float64(Float64(D / d) * 0.5)) ^ 2.0))))); elseif (d <= 1.35e-146) tmp = Float64(d * Float64(fma(-0.125, t_0, 1.0) * sqrt(Float64(1.0 / Float64(l * h))))); elseif (d <= 3.1e+91) tmp = Float64(t_2 * Float64(1.0 - Float64(0.5 * Float64(0.25 * Float64(Float64(D / Float64(d / Float64(M / l))) * Float64(h * Float64(D / Float64(d / M)))))))); else tmp = Float64(Float64(t_1 * Float64(sqrt(d) / sqrt(h))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M / 2.0)) ^ 2.0))))); end return tmp end
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(h * M), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(M * N[(N[(D / d), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision]}, If[LessEqual[d, -1.44e-55], N[(t$95$2 * N[(1.0 - N[(0.5 * N[(0.25 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5.2e-303], N[(N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-1.0 - N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(N[(D / d), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.35e-146], N[(d * N[(N[(-0.125 * t$95$0 + 1.0), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.1e+91], N[(t$95$2 * N[(1.0 - N[(0.5 * N[(0.25 * N[(N[(D / N[(d / N[(M / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h * N[(D / N[(d / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \left(h \cdot M\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot \frac{\frac{D}{d}}{\ell}\right)\right)\\
t_1 := \sqrt{\frac{d}{\ell}}\\
t_2 := \sqrt{\frac{d}{h}} \cdot t_1\\
\mathbf{if}\;d \leq -1.44 \cdot 10^{-55}:\\
\;\;\;\;t_2 \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot t_0\right)\right)\\
\mathbf{elif}\;d \leq -5.2 \cdot 10^{-303}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(\frac{D}{d} \cdot 0.5\right)\right)}^{2}\right)\right)\\
\mathbf{elif}\;d \leq 1.35 \cdot 10^{-146}:\\
\;\;\;\;d \cdot \left(\mathsf{fma}\left(-0.125, t_0, 1\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)\\
\mathbf{elif}\;d \leq 3.1 \cdot 10^{+91}:\\
\;\;\;\;t_2 \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot \left(\frac{D}{\frac{d}{\frac{M}{\ell}}} \cdot \left(h \cdot \frac{D}{\frac{d}{M}}\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t_1 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right) \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\right)\right)\\
\end{array}
\end{array}
if d < -1.43999999999999991e-55Initial program 81.6%
Simplified81.6%
Taylor expanded in M around 0 45.5%
*-commutative45.5%
*-commutative45.5%
associate-/l*43.9%
unpow243.9%
unpow243.9%
associate-*r*48.7%
*-commutative48.7%
unpow248.7%
associate-*l*50.3%
Simplified50.3%
Taylor expanded in D around 0 45.5%
unpow245.5%
associate-*r*47.0%
*-commutative47.0%
associate-*l/44.0%
unpow244.0%
unpow244.0%
associate-*r*48.7%
associate-*r*56.6%
*-commutative56.6%
times-frac69.3%
associate-*l*73.9%
associate-/r*81.8%
Simplified81.8%
if -1.43999999999999991e-55 < d < -5.20000000000000009e-303Initial program 57.8%
Simplified56.9%
add-log-exp33.6%
*-commutative33.6%
exp-prod33.9%
Applied egg-rr30.8%
pow-exp30.1%
add-log-exp41.9%
associate-*l*41.9%
*-commutative41.9%
Applied egg-rr41.9%
Taylor expanded in d around -inf 75.5%
mul-1-neg75.5%
*-commutative75.5%
unpow1/275.5%
rem-exp-log73.7%
log-pow73.7%
log-rec73.7%
distribute-rgt-neg-in73.7%
log-pow73.7%
unpow1/273.7%
rec-exp73.7%
rem-exp-log75.5%
associate-*r/75.5%
*-rgt-identity75.5%
Simplified75.5%
if -5.20000000000000009e-303 < d < 1.34999999999999997e-146Initial program 47.4%
Simplified44.8%
add-log-exp31.8%
*-commutative31.8%
exp-prod32.4%
Applied egg-rr23.8%
Taylor expanded in M around inf 39.6%
Simplified64.6%
if 1.34999999999999997e-146 < d < 3.09999999999999998e91Initial program 85.4%
Simplified85.4%
Taylor expanded in M around 0 64.6%
*-commutative64.6%
*-commutative64.6%
associate-/l*62.9%
unpow262.9%
unpow262.9%
associate-*r*62.9%
*-commutative62.9%
unpow262.9%
associate-*l*64.7%
Simplified64.7%
times-frac69.9%
*-commutative69.9%
Applied egg-rr69.9%
times-frac87.3%
associate-/l*87.3%
*-commutative87.3%
Applied egg-rr87.3%
Taylor expanded in D around 0 89.0%
associate-*l/87.3%
*-commutative87.3%
associate-*l*90.8%
*-commutative90.8%
associate-/r/90.8%
Simplified90.8%
if 3.09999999999999998e91 < d Initial program 73.1%
Simplified73.2%
sqrt-div92.1%
Applied egg-rr92.1%
Final simplification81.5%
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (* (* h M) (* (/ D d) (* M (/ (/ D d) l)))))
(t_1
(* (* (sqrt (/ d h)) (sqrt (/ d l))) (- 1.0 (* 0.5 (* 0.25 t_0))))))
(if (<= d -6.5e-57)
t_1
(if (<= d -5.2e-303)
(*
(/ d (sqrt (* l h)))
(- -1.0 (* -0.5 (* (/ h l) (pow (* M (* (/ D d) 0.5)) 2.0)))))
(if (or (<= d 3.7e-137) (not (<= d 1.15e+113)))
(* d (* (fma -0.125 t_0 1.0) (sqrt (/ 1.0 (* l h)))))
t_1)))))M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = (h * M) * ((D / d) * (M * ((D / d) / l)));
double t_1 = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (0.5 * (0.25 * t_0)));
double tmp;
if (d <= -6.5e-57) {
tmp = t_1;
} else if (d <= -5.2e-303) {
tmp = (d / sqrt((l * h))) * (-1.0 - (-0.5 * ((h / l) * pow((M * ((D / d) * 0.5)), 2.0))));
} else if ((d <= 3.7e-137) || !(d <= 1.15e+113)) {
tmp = d * (fma(-0.125, t_0, 1.0) * sqrt((1.0 / (l * h))));
} else {
tmp = t_1;
}
return tmp;
}
M = abs(M) M, D = sort([M, D]) function code(d, h, l, M, D) t_0 = Float64(Float64(h * M) * Float64(Float64(D / d) * Float64(M * Float64(Float64(D / d) / l)))) t_1 = Float64(Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))) * Float64(1.0 - Float64(0.5 * Float64(0.25 * t_0)))) tmp = 0.0 if (d <= -6.5e-57) tmp = t_1; elseif (d <= -5.2e-303) tmp = Float64(Float64(d / sqrt(Float64(l * h))) * Float64(-1.0 - Float64(-0.5 * Float64(Float64(h / l) * (Float64(M * Float64(Float64(D / d) * 0.5)) ^ 2.0))))); elseif ((d <= 3.7e-137) || !(d <= 1.15e+113)) tmp = Float64(d * Float64(fma(-0.125, t_0, 1.0) * sqrt(Float64(1.0 / Float64(l * h))))); else tmp = t_1; end return tmp end
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(h * M), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(M * N[(N[(D / d), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(0.25 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -6.5e-57], t$95$1, If[LessEqual[d, -5.2e-303], N[(N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-1.0 - N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(N[(D / d), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[d, 3.7e-137], N[Not[LessEqual[d, 1.15e+113]], $MachinePrecision]], N[(d * N[(N[(-0.125 * t$95$0 + 1.0), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \left(h \cdot M\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot \frac{\frac{D}{d}}{\ell}\right)\right)\\
t_1 := \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot t_0\right)\right)\\
\mathbf{if}\;d \leq -6.5 \cdot 10^{-57}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq -5.2 \cdot 10^{-303}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(\frac{D}{d} \cdot 0.5\right)\right)}^{2}\right)\right)\\
\mathbf{elif}\;d \leq 3.7 \cdot 10^{-137} \lor \neg \left(d \leq 1.15 \cdot 10^{+113}\right):\\
\;\;\;\;d \cdot \left(\mathsf{fma}\left(-0.125, t_0, 1\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if d < -6.49999999999999992e-57 or 3.7e-137 < d < 1.14999999999999998e113Initial program 84.1%
Simplified84.1%
Taylor expanded in M around 0 55.0%
*-commutative55.0%
*-commutative55.0%
associate-/l*53.3%
unpow253.3%
unpow253.3%
associate-*r*55.9%
*-commutative55.9%
unpow255.9%
associate-*l*57.6%
Simplified57.6%
Taylor expanded in D around 0 55.0%
unpow255.0%
associate-*r*56.7%
*-commutative56.7%
associate-*l/53.4%
unpow253.4%
unpow253.4%
associate-*r*55.9%
associate-*r*62.5%
*-commutative62.5%
times-frac75.6%
associate-*l*80.5%
associate-/r*85.8%
Simplified85.8%
if -6.49999999999999992e-57 < d < -5.20000000000000009e-303Initial program 57.8%
Simplified56.9%
add-log-exp33.6%
*-commutative33.6%
exp-prod33.9%
Applied egg-rr30.8%
pow-exp30.1%
add-log-exp41.9%
associate-*l*41.9%
*-commutative41.9%
Applied egg-rr41.9%
Taylor expanded in d around -inf 75.5%
mul-1-neg75.5%
*-commutative75.5%
unpow1/275.5%
rem-exp-log73.7%
log-pow73.7%
log-rec73.7%
distribute-rgt-neg-in73.7%
log-pow73.7%
unpow1/273.7%
rec-exp73.7%
rem-exp-log75.5%
associate-*r/75.5%
*-rgt-identity75.5%
Simplified75.5%
if -5.20000000000000009e-303 < d < 3.7e-137 or 1.14999999999999998e113 < d Initial program 60.0%
Simplified58.8%
add-log-exp32.7%
*-commutative32.7%
exp-prod33.0%
Applied egg-rr28.9%
Taylor expanded in M around inf 50.5%
Simplified74.1%
Final simplification79.9%
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (* (* h M) (* (/ D d) (* M (/ (/ D d) l)))))
(t_1 (* (sqrt (/ d h)) (sqrt (/ d l)))))
(if (<= d -1.55e-56)
(* t_1 (- 1.0 (* 0.5 (* 0.25 t_0))))
(if (<= d -5.2e-303)
(*
(/ d (sqrt (* l h)))
(- -1.0 (* -0.5 (* (/ h l) (pow (* M (* (/ D d) 0.5)) 2.0)))))
(if (or (<= d 4.2e-146) (not (<= d 9.2e+111)))
(* d (* (fma -0.125 t_0 1.0) (sqrt (/ 1.0 (* l h)))))
(*
t_1
(-
1.0
(* 0.5 (* 0.25 (* (/ D (/ d (/ M l))) (* h (/ D (/ d M)))))))))))))M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = (h * M) * ((D / d) * (M * ((D / d) / l)));
double t_1 = sqrt((d / h)) * sqrt((d / l));
double tmp;
if (d <= -1.55e-56) {
tmp = t_1 * (1.0 - (0.5 * (0.25 * t_0)));
} else if (d <= -5.2e-303) {
tmp = (d / sqrt((l * h))) * (-1.0 - (-0.5 * ((h / l) * pow((M * ((D / d) * 0.5)), 2.0))));
} else if ((d <= 4.2e-146) || !(d <= 9.2e+111)) {
tmp = d * (fma(-0.125, t_0, 1.0) * sqrt((1.0 / (l * h))));
} else {
tmp = t_1 * (1.0 - (0.5 * (0.25 * ((D / (d / (M / l))) * (h * (D / (d / M)))))));
}
return tmp;
}
M = abs(M) M, D = sort([M, D]) function code(d, h, l, M, D) t_0 = Float64(Float64(h * M) * Float64(Float64(D / d) * Float64(M * Float64(Float64(D / d) / l)))) t_1 = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))) tmp = 0.0 if (d <= -1.55e-56) tmp = Float64(t_1 * Float64(1.0 - Float64(0.5 * Float64(0.25 * t_0)))); elseif (d <= -5.2e-303) tmp = Float64(Float64(d / sqrt(Float64(l * h))) * Float64(-1.0 - Float64(-0.5 * Float64(Float64(h / l) * (Float64(M * Float64(Float64(D / d) * 0.5)) ^ 2.0))))); elseif ((d <= 4.2e-146) || !(d <= 9.2e+111)) tmp = Float64(d * Float64(fma(-0.125, t_0, 1.0) * sqrt(Float64(1.0 / Float64(l * h))))); else tmp = Float64(t_1 * Float64(1.0 - Float64(0.5 * Float64(0.25 * Float64(Float64(D / Float64(d / Float64(M / l))) * Float64(h * Float64(D / Float64(d / M)))))))); end return tmp end
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(h * M), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(M * N[(N[(D / d), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.55e-56], N[(t$95$1 * N[(1.0 - N[(0.5 * N[(0.25 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5.2e-303], N[(N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-1.0 - N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(N[(D / d), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[d, 4.2e-146], N[Not[LessEqual[d, 9.2e+111]], $MachinePrecision]], N[(d * N[(N[(-0.125 * t$95$0 + 1.0), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(1.0 - N[(0.5 * N[(0.25 * N[(N[(D / N[(d / N[(M / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h * N[(D / N[(d / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \left(h \cdot M\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot \frac{\frac{D}{d}}{\ell}\right)\right)\\
t_1 := \sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;d \leq -1.55 \cdot 10^{-56}:\\
\;\;\;\;t_1 \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot t_0\right)\right)\\
\mathbf{elif}\;d \leq -5.2 \cdot 10^{-303}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(\frac{D}{d} \cdot 0.5\right)\right)}^{2}\right)\right)\\
\mathbf{elif}\;d \leq 4.2 \cdot 10^{-146} \lor \neg \left(d \leq 9.2 \cdot 10^{+111}\right):\\
\;\;\;\;d \cdot \left(\mathsf{fma}\left(-0.125, t_0, 1\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(1 - 0.5 \cdot \left(0.25 \cdot \left(\frac{D}{\frac{d}{\frac{M}{\ell}}} \cdot \left(h \cdot \frac{D}{\frac{d}{M}}\right)\right)\right)\right)\\
\end{array}
\end{array}
if d < -1.54999999999999994e-56Initial program 81.6%
Simplified81.6%
Taylor expanded in M around 0 45.5%
*-commutative45.5%
*-commutative45.5%
associate-/l*43.9%
unpow243.9%
unpow243.9%
associate-*r*48.7%
*-commutative48.7%
unpow248.7%
associate-*l*50.3%
Simplified50.3%
Taylor expanded in D around 0 45.5%
unpow245.5%
associate-*r*47.0%
*-commutative47.0%
associate-*l/44.0%
unpow244.0%
unpow244.0%
associate-*r*48.7%
associate-*r*56.6%
*-commutative56.6%
times-frac69.3%
associate-*l*73.9%
associate-/r*81.8%
Simplified81.8%
if -1.54999999999999994e-56 < d < -5.20000000000000009e-303Initial program 57.8%
Simplified56.9%
add-log-exp33.6%
*-commutative33.6%
exp-prod33.9%
Applied egg-rr30.8%
pow-exp30.1%
add-log-exp41.9%
associate-*l*41.9%
*-commutative41.9%
Applied egg-rr41.9%
Taylor expanded in d around -inf 75.5%
mul-1-neg75.5%
*-commutative75.5%
unpow1/275.5%
rem-exp-log73.7%
log-pow73.7%
log-rec73.7%
distribute-rgt-neg-in73.7%
log-pow73.7%
unpow1/273.7%
rec-exp73.7%
rem-exp-log75.5%
associate-*r/75.5%
*-rgt-identity75.5%
Simplified75.5%
if -5.20000000000000009e-303 < d < 4.1999999999999998e-146 or 9.20000000000000008e111 < d Initial program 60.3%
Simplified59.1%
add-log-exp33.5%
*-commutative33.5%
exp-prod33.8%
Applied egg-rr29.6%
Taylor expanded in M around inf 51.8%
Simplified74.6%
if 4.1999999999999998e-146 < d < 9.20000000000000008e111Initial program 85.6%
Simplified85.6%
Taylor expanded in M around 0 63.5%
*-commutative63.5%
*-commutative63.5%
associate-/l*61.8%
unpow261.8%
unpow261.8%
associate-*r*61.8%
*-commutative61.8%
unpow261.8%
associate-*l*63.5%
Simplified63.5%
times-frac68.7%
*-commutative68.7%
Applied egg-rr68.7%
times-frac85.8%
associate-/l*85.8%
*-commutative85.8%
Applied egg-rr85.8%
Taylor expanded in D around 0 87.5%
associate-*l/85.8%
*-commutative85.8%
associate-*l*90.9%
*-commutative90.9%
associate-/r/90.9%
Simplified90.9%
Final simplification80.3%
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (fma -0.125 (* (* h M) (* (/ D d) (* M (/ (/ D d) l)))) 1.0))
(t_1 (sqrt (/ 1.0 (* l h)))))
(if (<= l -1e-310) (* t_1 (* d (- t_0))) (* d (* t_0 t_1)))))M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = fma(-0.125, ((h * M) * ((D / d) * (M * ((D / d) / l)))), 1.0);
double t_1 = sqrt((1.0 / (l * h)));
double tmp;
if (l <= -1e-310) {
tmp = t_1 * (d * -t_0);
} else {
tmp = d * (t_0 * t_1);
}
return tmp;
}
M = abs(M) M, D = sort([M, D]) function code(d, h, l, M, D) t_0 = fma(-0.125, Float64(Float64(h * M) * Float64(Float64(D / d) * Float64(M * Float64(Float64(D / d) / l)))), 1.0) t_1 = sqrt(Float64(1.0 / Float64(l * h))) tmp = 0.0 if (l <= -1e-310) tmp = Float64(t_1 * Float64(d * Float64(-t_0))); else tmp = Float64(d * Float64(t_0 * t_1)); end return tmp end
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(-0.125 * N[(N[(h * M), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(M * N[(N[(D / d), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -1e-310], N[(t$95$1 * N[(d * (-t$95$0)), $MachinePrecision]), $MachinePrecision], N[(d * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-0.125, \left(h \cdot M\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot \frac{\frac{D}{d}}{\ell}\right)\right), 1\right)\\
t_1 := \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{if}\;\ell \leq -1 \cdot 10^{-310}:\\
\;\;\;\;t_1 \cdot \left(d \cdot \left(-t_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \left(t_0 \cdot t_1\right)\\
\end{array}
\end{array}
if l < -9.999999999999969e-311Initial program 68.8%
Simplified68.3%
add-log-exp40.3%
*-commutative40.3%
exp-prod39.7%
Applied egg-rr38.2%
Taylor expanded in d around -inf 50.4%
Simplified77.5%
if -9.999999999999969e-311 < l Initial program 72.5%
Simplified71.8%
add-log-exp32.1%
*-commutative32.1%
exp-prod31.8%
Applied egg-rr28.6%
Taylor expanded in M around inf 55.0%
Simplified76.6%
Final simplification77.0%
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(if (<= l 8e-306)
(*
(/ d (sqrt (* l h)))
(- -1.0 (* -0.5 (* (/ h l) (pow (* M (* (/ D d) 0.5)) 2.0)))))
(*
d
(*
(fma -0.125 (* (* h M) (* (/ D d) (* M (/ (/ D d) l)))) 1.0)
(sqrt (/ 1.0 (* l h)))))))M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= 8e-306) {
tmp = (d / sqrt((l * h))) * (-1.0 - (-0.5 * ((h / l) * pow((M * ((D / d) * 0.5)), 2.0))));
} else {
tmp = d * (fma(-0.125, ((h * M) * ((D / d) * (M * ((D / d) / l)))), 1.0) * sqrt((1.0 / (l * h))));
}
return tmp;
}
M = abs(M) M, D = sort([M, D]) function code(d, h, l, M, D) tmp = 0.0 if (l <= 8e-306) tmp = Float64(Float64(d / sqrt(Float64(l * h))) * Float64(-1.0 - Float64(-0.5 * Float64(Float64(h / l) * (Float64(M * Float64(Float64(D / d) * 0.5)) ^ 2.0))))); else tmp = Float64(d * Float64(fma(-0.125, Float64(Float64(h * M) * Float64(Float64(D / d) * Float64(M * Float64(Float64(D / d) / l)))), 1.0) * sqrt(Float64(1.0 / Float64(l * h))))); end return tmp end
NOTE: M should be positive before calling this function NOTE: M and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[l, 8e-306], N[(N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-1.0 - N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(N[(D / d), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[(-0.125 * N[(N[(h * M), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(M * N[(N[(D / d), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 8 \cdot 10^{-306}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(\frac{D}{d} \cdot 0.5\right)\right)}^{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \left(\mathsf{fma}\left(-0.125, \left(h \cdot M\right) \cdot \left(\frac{D}{d} \cdot \left(M \cdot \frac{\frac{D}{d}}{\ell}\right)\right), 1\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)\\
\end{array}
\end{array}
if l < 8.00000000000000022e-306Initial program 69.0%
Simplified68.5%
add-log-exp40.0%
*-commutative40.0%
exp-prod39.5%
Applied egg-rr37.9%
pow-exp38.3%
add-log-exp55.4%
associate-*l*55.4%
*-commutative55.4%
Applied egg-rr55.4%
Taylor expanded in d around -inf 72.0%
mul-1-neg72.0%
*-commutative72.0%
unpow1/272.0%
rem-exp-log69.8%
log-pow69.8%
log-rec69.8%
distribute-rgt-neg-in69.8%
log-pow69.8%
unpow1/269.8%
rec-exp69.8%
rem-exp-log72.0%
associate-*r/71.9%
*-rgt-identity71.9%
Simplified71.9%
if 8.00000000000000022e-306 < l Initial program 72.3%
Simplified71.6%
add-log-exp32.3%
*-commutative32.3%
exp-prod32.0%
Applied egg-rr28.8%
Taylor expanded in M around inf 55.4%
Simplified77.2%
Final simplification74.6%
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (* -0.125 (* (* M (* h M)) (* (/ D d) (/ D (* d l))))))
(t_1 (sqrt (/ 1.0 (* l h)))))
(if (<= h -4.5e+155)
(* d (* t_1 (- -1.0 t_0)))
(if (<= h -5e-310)
(*
(/ d (sqrt (* l h)))
(- -1.0 (* -0.5 (* (/ h l) (pow (* M (* (/ D d) 0.5)) 2.0)))))
(* d (* t_1 (+ 1.0 t_0)))))))M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = -0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l))));
double t_1 = sqrt((1.0 / (l * h)));
double tmp;
if (h <= -4.5e+155) {
tmp = d * (t_1 * (-1.0 - t_0));
} else if (h <= -5e-310) {
tmp = (d / sqrt((l * h))) * (-1.0 - (-0.5 * ((h / l) * pow((M * ((D / d) * 0.5)), 2.0))));
} else {
tmp = d * (t_1 * (1.0 + t_0));
}
return tmp;
}
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
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
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (-0.125d0) * ((m * (h * m)) * ((d_1 / d) * (d_1 / (d * l))))
t_1 = sqrt((1.0d0 / (l * h)))
if (h <= (-4.5d+155)) then
tmp = d * (t_1 * ((-1.0d0) - t_0))
else if (h <= (-5d-310)) then
tmp = (d / sqrt((l * h))) * ((-1.0d0) - ((-0.5d0) * ((h / l) * ((m * ((d_1 / d) * 0.5d0)) ** 2.0d0))))
else
tmp = d * (t_1 * (1.0d0 + t_0))
end if
code = tmp
end function
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
double t_0 = -0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l))));
double t_1 = Math.sqrt((1.0 / (l * h)));
double tmp;
if (h <= -4.5e+155) {
tmp = d * (t_1 * (-1.0 - t_0));
} else if (h <= -5e-310) {
tmp = (d / Math.sqrt((l * h))) * (-1.0 - (-0.5 * ((h / l) * Math.pow((M * ((D / d) * 0.5)), 2.0))));
} else {
tmp = d * (t_1 * (1.0 + t_0));
}
return tmp;
}
M = abs(M) [M, D] = sort([M, D]) def code(d, h, l, M, D): t_0 = -0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l)))) t_1 = math.sqrt((1.0 / (l * h))) tmp = 0 if h <= -4.5e+155: tmp = d * (t_1 * (-1.0 - t_0)) elif h <= -5e-310: tmp = (d / math.sqrt((l * h))) * (-1.0 - (-0.5 * ((h / l) * math.pow((M * ((D / d) * 0.5)), 2.0)))) else: tmp = d * (t_1 * (1.0 + t_0)) return tmp
M = abs(M) M, D = sort([M, D]) function code(d, h, l, M, D) t_0 = Float64(-0.125 * Float64(Float64(M * Float64(h * M)) * Float64(Float64(D / d) * Float64(D / Float64(d * l))))) t_1 = sqrt(Float64(1.0 / Float64(l * h))) tmp = 0.0 if (h <= -4.5e+155) tmp = Float64(d * Float64(t_1 * Float64(-1.0 - t_0))); elseif (h <= -5e-310) tmp = Float64(Float64(d / sqrt(Float64(l * h))) * Float64(-1.0 - Float64(-0.5 * Float64(Float64(h / l) * (Float64(M * Float64(Float64(D / d) * 0.5)) ^ 2.0))))); else tmp = Float64(d * Float64(t_1 * Float64(1.0 + t_0))); end return tmp end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
t_0 = -0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l))));
t_1 = sqrt((1.0 / (l * h)));
tmp = 0.0;
if (h <= -4.5e+155)
tmp = d * (t_1 * (-1.0 - t_0));
elseif (h <= -5e-310)
tmp = (d / sqrt((l * h))) * (-1.0 - (-0.5 * ((h / l) * ((M * ((D / d) * 0.5)) ^ 2.0))));
else
tmp = d * (t_1 * (1.0 + t_0));
end
tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(-0.125 * N[(N[(M * N[(h * M), $MachinePrecision]), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(D / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[h, -4.5e+155], N[(d * N[(t$95$1 * N[(-1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -5e-310], N[(N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-1.0 - N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(N[(D / d), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(t$95$1 * N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := -0.125 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d \cdot \ell}\right)\right)\\
t_1 := \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{if}\;h \leq -4.5 \cdot 10^{+155}:\\
\;\;\;\;d \cdot \left(t_1 \cdot \left(-1 - t_0\right)\right)\\
\mathbf{elif}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(-1 - -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(\frac{D}{d} \cdot 0.5\right)\right)}^{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \left(t_1 \cdot \left(1 + t_0\right)\right)\\
\end{array}
\end{array}
if h < -4.49999999999999973e155Initial program 41.3%
Simplified41.3%
add-log-exp22.1%
*-commutative22.1%
exp-prod22.6%
Applied egg-rr22.4%
Taylor expanded in d around -inf 48.6%
Simplified64.8%
if -4.49999999999999973e155 < h < -4.999999999999985e-310Initial program 75.6%
Simplified75.0%
add-log-exp44.8%
*-commutative44.8%
exp-prod44.0%
Applied egg-rr42.1%
pow-exp42.7%
add-log-exp59.5%
associate-*l*59.5%
*-commutative59.5%
Applied egg-rr59.5%
Taylor expanded in d around -inf 79.3%
mul-1-neg79.3%
*-commutative79.3%
unpow1/279.3%
rem-exp-log76.7%
log-pow76.7%
log-rec76.7%
distribute-rgt-neg-in76.7%
log-pow76.7%
unpow1/276.7%
rec-exp76.7%
rem-exp-log79.3%
associate-*r/79.3%
*-rgt-identity79.3%
Simplified79.3%
if -4.999999999999985e-310 < h Initial program 72.5%
Simplified71.8%
add-log-exp32.1%
*-commutative32.1%
exp-prod31.8%
Applied egg-rr28.6%
Taylor expanded in M around inf 55.0%
Simplified70.1%
Final simplification73.2%
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (* -0.125 (* (* M (* h M)) (* (/ D d) (/ D (* d l))))))
(t_1 (sqrt (/ 1.0 (* l h)))))
(if (<= l -1e-310)
(* d (* t_1 (- -1.0 t_0)))
(if (<= l 5.2e+133)
(* d (* t_1 (+ 1.0 t_0)))
(/ d (* (sqrt h) (sqrt l)))))))M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = -0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l))));
double t_1 = sqrt((1.0 / (l * h)));
double tmp;
if (l <= -1e-310) {
tmp = d * (t_1 * (-1.0 - t_0));
} else if (l <= 5.2e+133) {
tmp = d * (t_1 * (1.0 + t_0));
} else {
tmp = d / (sqrt(h) * sqrt(l));
}
return tmp;
}
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
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
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (-0.125d0) * ((m * (h * m)) * ((d_1 / d) * (d_1 / (d * l))))
t_1 = sqrt((1.0d0 / (l * h)))
if (l <= (-1d-310)) then
tmp = d * (t_1 * ((-1.0d0) - t_0))
else if (l <= 5.2d+133) then
tmp = d * (t_1 * (1.0d0 + t_0))
else
tmp = d / (sqrt(h) * sqrt(l))
end if
code = tmp
end function
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
double t_0 = -0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l))));
double t_1 = Math.sqrt((1.0 / (l * h)));
double tmp;
if (l <= -1e-310) {
tmp = d * (t_1 * (-1.0 - t_0));
} else if (l <= 5.2e+133) {
tmp = d * (t_1 * (1.0 + t_0));
} else {
tmp = d / (Math.sqrt(h) * Math.sqrt(l));
}
return tmp;
}
M = abs(M) [M, D] = sort([M, D]) def code(d, h, l, M, D): t_0 = -0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l)))) t_1 = math.sqrt((1.0 / (l * h))) tmp = 0 if l <= -1e-310: tmp = d * (t_1 * (-1.0 - t_0)) elif l <= 5.2e+133: tmp = d * (t_1 * (1.0 + t_0)) else: tmp = d / (math.sqrt(h) * math.sqrt(l)) return tmp
M = abs(M) M, D = sort([M, D]) function code(d, h, l, M, D) t_0 = Float64(-0.125 * Float64(Float64(M * Float64(h * M)) * Float64(Float64(D / d) * Float64(D / Float64(d * l))))) t_1 = sqrt(Float64(1.0 / Float64(l * h))) tmp = 0.0 if (l <= -1e-310) tmp = Float64(d * Float64(t_1 * Float64(-1.0 - t_0))); elseif (l <= 5.2e+133) tmp = Float64(d * Float64(t_1 * Float64(1.0 + t_0))); else tmp = Float64(d / Float64(sqrt(h) * sqrt(l))); end return tmp end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
t_0 = -0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l))));
t_1 = sqrt((1.0 / (l * h)));
tmp = 0.0;
if (l <= -1e-310)
tmp = d * (t_1 * (-1.0 - t_0));
elseif (l <= 5.2e+133)
tmp = d * (t_1 * (1.0 + t_0));
else
tmp = d / (sqrt(h) * sqrt(l));
end
tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(-0.125 * N[(N[(M * N[(h * M), $MachinePrecision]), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(D / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -1e-310], N[(d * N[(t$95$1 * N[(-1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5.2e+133], N[(d * N[(t$95$1 * N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := -0.125 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d \cdot \ell}\right)\right)\\
t_1 := \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{if}\;\ell \leq -1 \cdot 10^{-310}:\\
\;\;\;\;d \cdot \left(t_1 \cdot \left(-1 - t_0\right)\right)\\
\mathbf{elif}\;\ell \leq 5.2 \cdot 10^{+133}:\\
\;\;\;\;d \cdot \left(t_1 \cdot \left(1 + t_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if l < -9.999999999999969e-311Initial program 68.8%
Simplified68.3%
add-log-exp40.3%
*-commutative40.3%
exp-prod39.7%
Applied egg-rr38.2%
Taylor expanded in d around -inf 50.4%
Simplified66.5%
if -9.999999999999969e-311 < l < 5.1999999999999995e133Initial program 76.6%
Simplified75.7%
add-log-exp38.0%
*-commutative38.0%
exp-prod37.3%
Applied egg-rr33.1%
Taylor expanded in M around inf 63.9%
Simplified75.0%
if 5.1999999999999995e133 < l Initial program 60.9%
Simplified60.9%
Taylor expanded in d around inf 48.3%
sqrt-div48.2%
metadata-eval48.2%
*-commutative48.2%
Applied egg-rr48.2%
Taylor expanded in d around 0 48.3%
*-commutative48.3%
associate-/r*48.3%
unpow1/248.3%
sqr-pow48.2%
rem-exp-log45.2%
sqr-pow45.2%
unpow1/245.2%
associate-/r*45.2%
unpow-145.2%
metadata-eval45.2%
pow-sqr45.2%
rem-sqrt-square45.2%
sqr-pow45.2%
fabs-sqr45.2%
sqr-pow45.2%
rem-exp-log45.4%
exp-sum45.2%
log-pow45.4%
metadata-eval45.4%
distribute-lft-neg-in45.4%
log-pow45.4%
unpow1/245.4%
Simplified48.4%
sqrt-prod67.8%
Applied egg-rr67.8%
Final simplification69.8%
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(if (<= h 6.5e-296)
(/ d (sqrt (* l h)))
(*
d
(*
(sqrt (/ 1.0 (* l h)))
(+ 1.0 (* -0.125 (* (* M (* h M)) (* (/ D d) (/ D (* d l))))))))))M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (h <= 6.5e-296) {
tmp = d / sqrt((l * h));
} else {
tmp = d * (sqrt((1.0 / (l * h))) * (1.0 + (-0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l)))))));
}
return tmp;
}
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
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
real(8) :: tmp
if (h <= 6.5d-296) then
tmp = d / sqrt((l * h))
else
tmp = d * (sqrt((1.0d0 / (l * h))) * (1.0d0 + ((-0.125d0) * ((m * (h * m)) * ((d_1 / d) * (d_1 / (d * l)))))))
end if
code = tmp
end function
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (h <= 6.5e-296) {
tmp = d / Math.sqrt((l * h));
} else {
tmp = d * (Math.sqrt((1.0 / (l * h))) * (1.0 + (-0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l)))))));
}
return tmp;
}
M = abs(M) [M, D] = sort([M, D]) def code(d, h, l, M, D): tmp = 0 if h <= 6.5e-296: tmp = d / math.sqrt((l * h)) else: tmp = d * (math.sqrt((1.0 / (l * h))) * (1.0 + (-0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l))))))) return tmp
M = abs(M) M, D = sort([M, D]) function code(d, h, l, M, D) tmp = 0.0 if (h <= 6.5e-296) tmp = Float64(d / sqrt(Float64(l * h))); else tmp = Float64(d * Float64(sqrt(Float64(1.0 / Float64(l * h))) * Float64(1.0 + Float64(-0.125 * Float64(Float64(M * Float64(h * M)) * Float64(Float64(D / d) * Float64(D / Float64(d * l)))))))); end return tmp end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
tmp = 0.0;
if (h <= 6.5e-296)
tmp = d / sqrt((l * h));
else
tmp = d * (sqrt((1.0 / (l * h))) * (1.0 + (-0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l)))))));
end
tmp_2 = tmp;
end
NOTE: M should be positive before calling this function NOTE: M and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[h, 6.5e-296], N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.125 * N[(N[(M * N[(h * M), $MachinePrecision]), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(D / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq 6.5 \cdot 10^{-296}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \left(\sqrt{\frac{1}{\ell \cdot h}} \cdot \left(1 + -0.125 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d \cdot \ell}\right)\right)\right)\right)\\
\end{array}
\end{array}
if h < 6.49999999999999963e-296Initial program 68.8%
Simplified68.4%
Taylor expanded in d around inf 10.5%
sqrt-div10.5%
metadata-eval10.5%
*-commutative10.5%
Applied egg-rr10.5%
Taylor expanded in d around 0 10.5%
*-commutative10.5%
associate-/r*10.5%
unpow1/210.5%
sqr-pow10.5%
rem-exp-log0.8%
sqr-pow0.8%
unpow1/20.8%
associate-/r*0.8%
unpow-10.8%
metadata-eval0.8%
pow-sqr0.8%
rem-sqrt-square0.8%
sqr-pow0.8%
fabs-sqr0.8%
sqr-pow0.8%
rem-exp-log0.8%
exp-sum0.8%
log-pow0.8%
metadata-eval0.8%
distribute-lft-neg-in0.8%
log-pow0.8%
unpow1/20.8%
Simplified10.5%
if 6.49999999999999963e-296 < h Initial program 72.6%
Simplified71.9%
add-log-exp32.6%
*-commutative32.6%
exp-prod32.2%
Applied egg-rr29.0%
Taylor expanded in M around inf 55.9%
Simplified71.4%
Final simplification40.5%
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (* -0.125 (* (* M (* h M)) (* (/ D d) (/ D (* d l))))))
(t_1 (sqrt (/ 1.0 (* l h)))))
(if (<= d -6.8e-306) (* d (* t_1 (- -1.0 t_0))) (* d (* t_1 (+ 1.0 t_0))))))M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = -0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l))));
double t_1 = sqrt((1.0 / (l * h)));
double tmp;
if (d <= -6.8e-306) {
tmp = d * (t_1 * (-1.0 - t_0));
} else {
tmp = d * (t_1 * (1.0 + t_0));
}
return tmp;
}
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
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
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (-0.125d0) * ((m * (h * m)) * ((d_1 / d) * (d_1 / (d * l))))
t_1 = sqrt((1.0d0 / (l * h)))
if (d <= (-6.8d-306)) then
tmp = d * (t_1 * ((-1.0d0) - t_0))
else
tmp = d * (t_1 * (1.0d0 + t_0))
end if
code = tmp
end function
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
double t_0 = -0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l))));
double t_1 = Math.sqrt((1.0 / (l * h)));
double tmp;
if (d <= -6.8e-306) {
tmp = d * (t_1 * (-1.0 - t_0));
} else {
tmp = d * (t_1 * (1.0 + t_0));
}
return tmp;
}
M = abs(M) [M, D] = sort([M, D]) def code(d, h, l, M, D): t_0 = -0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l)))) t_1 = math.sqrt((1.0 / (l * h))) tmp = 0 if d <= -6.8e-306: tmp = d * (t_1 * (-1.0 - t_0)) else: tmp = d * (t_1 * (1.0 + t_0)) return tmp
M = abs(M) M, D = sort([M, D]) function code(d, h, l, M, D) t_0 = Float64(-0.125 * Float64(Float64(M * Float64(h * M)) * Float64(Float64(D / d) * Float64(D / Float64(d * l))))) t_1 = sqrt(Float64(1.0 / Float64(l * h))) tmp = 0.0 if (d <= -6.8e-306) tmp = Float64(d * Float64(t_1 * Float64(-1.0 - t_0))); else tmp = Float64(d * Float64(t_1 * Float64(1.0 + t_0))); end return tmp end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
t_0 = -0.125 * ((M * (h * M)) * ((D / d) * (D / (d * l))));
t_1 = sqrt((1.0 / (l * h)));
tmp = 0.0;
if (d <= -6.8e-306)
tmp = d * (t_1 * (-1.0 - t_0));
else
tmp = d * (t_1 * (1.0 + t_0));
end
tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(-0.125 * N[(N[(M * N[(h * M), $MachinePrecision]), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(D / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -6.8e-306], N[(d * N[(t$95$1 * N[(-1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(t$95$1 * N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := -0.125 \cdot \left(\left(M \cdot \left(h \cdot M\right)\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d \cdot \ell}\right)\right)\\
t_1 := \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{if}\;d \leq -6.8 \cdot 10^{-306}:\\
\;\;\;\;d \cdot \left(t_1 \cdot \left(-1 - t_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \left(t_1 \cdot \left(1 + t_0\right)\right)\\
\end{array}
\end{array}
if d < -6.7999999999999996e-306Initial program 69.3%
Simplified68.9%
add-log-exp40.6%
*-commutative40.6%
exp-prod40.0%
Applied egg-rr38.5%
Taylor expanded in d around -inf 50.8%
Simplified67.0%
if -6.7999999999999996e-306 < d Initial program 72.0%
Simplified71.3%
add-log-exp31.9%
*-commutative31.9%
exp-prod31.5%
Applied egg-rr28.4%
Taylor expanded in M around inf 54.6%
Simplified69.5%
Final simplification68.3%
NOTE: M should be positive before calling this function NOTE: M and D should be sorted in increasing order before calling this function. (FPCore (d h l M D) :precision binary64 (* d (pow (* l h) -0.5)))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
return d * pow((l * h), -0.5);
}
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
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 * ((l * h) ** (-0.5d0))
end function
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
return d * Math.pow((l * h), -0.5);
}
M = abs(M) [M, D] = sort([M, D]) def code(d, h, l, M, D): return d * math.pow((l * h), -0.5)
M = abs(M) M, D = sort([M, D]) function code(d, h, l, M, D) return Float64(d * (Float64(l * h) ^ -0.5)) end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
tmp = d * ((l * h) ^ -0.5);
end
NOTE: M should be positive before calling this function NOTE: M and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
d \cdot {\left(\ell \cdot h\right)}^{-0.5}
\end{array}
Initial program 70.7%
Simplified70.1%
Taylor expanded in d around inf 28.7%
sqrt-div28.9%
metadata-eval28.9%
*-commutative28.9%
Applied egg-rr28.9%
expm1-log1p-u28.2%
expm1-udef20.5%
pow1/220.5%
metadata-eval20.5%
pow-flip20.5%
*-commutative20.5%
metadata-eval20.5%
metadata-eval20.5%
Applied egg-rr20.5%
expm1-def28.2%
expm1-log1p28.9%
Simplified28.9%
Final simplification28.9%
NOTE: M should be positive before calling this function NOTE: M and D should be sorted in increasing order before calling this function. (FPCore (d h l M D) :precision binary64 (/ d (sqrt (* l h))))
M = abs(M);
assert(M < D);
double code(double d, double h, double l, double M, double D) {
return d / sqrt((l * h));
}
NOTE: M should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
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 / sqrt((l * h))
end function
M = Math.abs(M);
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
return d / Math.sqrt((l * h));
}
M = abs(M) [M, D] = sort([M, D]) def code(d, h, l, M, D): return d / math.sqrt((l * h))
M = abs(M) M, D = sort([M, D]) function code(d, h, l, M, D) return Float64(d / sqrt(Float64(l * h))) end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
tmp = d / sqrt((l * h));
end
NOTE: M should be positive before calling this function NOTE: M and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\frac{d}{\sqrt{\ell \cdot h}}
\end{array}
Initial program 70.7%
Simplified70.1%
Taylor expanded in d around inf 28.7%
sqrt-div28.9%
metadata-eval28.9%
*-commutative28.9%
Applied egg-rr28.9%
Taylor expanded in d around 0 28.7%
*-commutative28.7%
associate-/r*28.7%
unpow1/228.7%
sqr-pow28.6%
rem-exp-log22.3%
sqr-pow22.3%
unpow1/222.3%
associate-/r*22.3%
unpow-122.3%
metadata-eval22.3%
pow-sqr22.3%
rem-sqrt-square22.5%
sqr-pow22.5%
fabs-sqr22.5%
sqr-pow22.5%
rem-exp-log22.4%
exp-sum22.4%
log-pow22.4%
metadata-eval22.4%
distribute-lft-neg-in22.4%
log-pow22.4%
unpow1/222.4%
Simplified28.9%
Final simplification28.9%
herbie shell --seed 2023274
(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)))))