
(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 14 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}
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (+ 1.0 (* (/ h l) (* (pow (* D (/ (/ M_m 2.0) d)) 2.0) -0.5)))))
(if (<= d -5e-310)
(* (/ 1.0 (sqrt (/ l d))) (* (/ (sqrt (- d)) (sqrt (- h))) t_0))
(if (<= d 5.2e-224)
(* (sqrt (/ d l)) (* t_0 (/ (sqrt d) (sqrt h))))
(if (<= d 9.4e-185)
(/
(* d (fma -0.5 (* (/ h l) (pow (/ (* D M_m) (* d 2.0)) 2.0)) 1.0))
(sqrt (* l h)))
(if (<= d 5.6e+116)
(*
(fma h (* -0.5 (/ (pow (* 0.5 (* D (/ M_m d))) 2.0) l)) 1.0)
(/ (/ d (sqrt h)) (sqrt l)))
(*
(+ 1.0 (* (* (/ h l) -0.5) (pow (* D (/ M_m (* d 2.0))) 2.0)))
(/ d (* (sqrt h) (sqrt l))))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = 1.0 + ((h / l) * (pow((D * ((M_m / 2.0) / d)), 2.0) * -0.5));
double tmp;
if (d <= -5e-310) {
tmp = (1.0 / sqrt((l / d))) * ((sqrt(-d) / sqrt(-h)) * t_0);
} else if (d <= 5.2e-224) {
tmp = sqrt((d / l)) * (t_0 * (sqrt(d) / sqrt(h)));
} else if (d <= 9.4e-185) {
tmp = (d * fma(-0.5, ((h / l) * pow(((D * M_m) / (d * 2.0)), 2.0)), 1.0)) / sqrt((l * h));
} else if (d <= 5.6e+116) {
tmp = fma(h, (-0.5 * (pow((0.5 * (D * (M_m / d))), 2.0) / l)), 1.0) * ((d / sqrt(h)) / sqrt(l));
} else {
tmp = (1.0 + (((h / l) * -0.5) * pow((D * (M_m / (d * 2.0))), 2.0))) * (d / (sqrt(h) * sqrt(l)));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(D * Float64(Float64(M_m / 2.0) / d)) ^ 2.0) * -0.5))) tmp = 0.0 if (d <= -5e-310) tmp = Float64(Float64(1.0 / sqrt(Float64(l / d))) * Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * t_0)); elseif (d <= 5.2e-224) tmp = Float64(sqrt(Float64(d / l)) * Float64(t_0 * Float64(sqrt(d) / sqrt(h)))); elseif (d <= 9.4e-185) tmp = Float64(Float64(d * fma(-0.5, Float64(Float64(h / l) * (Float64(Float64(D * M_m) / Float64(d * 2.0)) ^ 2.0)), 1.0)) / sqrt(Float64(l * h))); elseif (d <= 5.6e+116) tmp = Float64(fma(h, Float64(-0.5 * Float64((Float64(0.5 * Float64(D * Float64(M_m / d))) ^ 2.0) / l)), 1.0) * Float64(Float64(d / sqrt(h)) / sqrt(l))); else tmp = Float64(Float64(1.0 + Float64(Float64(Float64(h / l) * -0.5) * (Float64(D * Float64(M_m / Float64(d * 2.0))) ^ 2.0))) * Float64(d / Float64(sqrt(h) * sqrt(l)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(D * N[(N[(M$95$m / 2.0), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5e-310], N[(N[(1.0 / N[Sqrt[N[(l / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.2e-224], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(t$95$0 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 9.4e-185], N[(N[(d * N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D * M$95$m), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.6e+116], N[(N[(h * N[(-0.5 * N[(N[Power[N[(0.5 * N[(D * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(d / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(D * N[(M$95$m / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := 1 + \frac{h}{\ell} \cdot \left({\left(D \cdot \frac{\frac{M\_m}{2}}{d}\right)}^{2} \cdot -0.5\right)\\
\mathbf{if}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{1}{\sqrt{\frac{\ell}{d}}} \cdot \left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot t\_0\right)\\
\mathbf{elif}\;d \leq 5.2 \cdot 10^{-224}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(t\_0 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right)\\
\mathbf{elif}\;d \leq 9.4 \cdot 10^{-185}:\\
\;\;\;\;\frac{d \cdot \mathsf{fma}\left(-0.5, \frac{h}{\ell} \cdot {\left(\frac{D \cdot M\_m}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{\ell \cdot h}}\\
\mathbf{elif}\;d \leq 5.6 \cdot 10^{+116}:\\
\;\;\;\;\mathsf{fma}\left(h, -0.5 \cdot \frac{{\left(0.5 \cdot \left(D \cdot \frac{M\_m}{d}\right)\right)}^{2}}{\ell}, 1\right) \cdot \frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M\_m}{d \cdot 2}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if d < -4.999999999999985e-310Initial program 67.2%
Simplified67.2%
clear-num67.1%
sqrt-div67.9%
metadata-eval67.9%
Applied egg-rr67.9%
frac-2neg67.9%
sqrt-div77.7%
Applied egg-rr77.7%
if -4.999999999999985e-310 < d < 5.2000000000000004e-224Initial program 54.6%
Simplified54.5%
sqrt-div76.0%
div-inv76.1%
Applied egg-rr76.1%
associate-*r/76.0%
*-rgt-identity76.0%
Simplified76.0%
if 5.2000000000000004e-224 < d < 9.4000000000000004e-185Initial program 45.4%
Simplified44.4%
sub-neg44.4%
distribute-rgt-in44.4%
*-un-lft-identity44.4%
sqrt-div44.4%
sqrt-div44.4%
frac-times44.3%
add-sqr-sqrt44.3%
Applied egg-rr68.0%
distribute-rgt1-in68.0%
+-commutative68.0%
associate-*r*68.0%
times-frac68.0%
*-commutative68.0%
associate-/l*68.0%
Simplified68.0%
associate-*r/78.2%
+-commutative78.2%
associate-*l*78.2%
fma-define78.2%
associate-*r/78.2%
sqrt-unprod78.2%
*-commutative78.2%
Applied egg-rr78.2%
if 9.4000000000000004e-185 < d < 5.60000000000000009e116Initial program 70.4%
Simplified70.4%
sub-neg70.4%
distribute-rgt-in67.2%
*-un-lft-identity67.2%
sqrt-div68.2%
sqrt-div73.0%
frac-times73.0%
add-sqr-sqrt73.2%
Applied egg-rr83.6%
distribute-rgt1-in86.6%
Simplified92.6%
if 5.60000000000000009e116 < d Initial program 69.4%
Simplified71.3%
sub-neg71.3%
distribute-rgt-in40.6%
*-un-lft-identity40.6%
sqrt-div40.5%
sqrt-div42.5%
frac-times42.5%
add-sqr-sqrt42.6%
Applied egg-rr69.8%
distribute-rgt1-in96.3%
+-commutative96.3%
associate-*r*96.3%
times-frac95.5%
*-commutative95.5%
associate-/l*96.3%
Simplified96.3%
Final simplification85.1%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (pow (/ (* D M_m) (* d 2.0)) 2.0))
(t_1 (/ (pow (* 0.5 (* D (/ M_m d))) 2.0) l)))
(if (<= d -5e-160)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) (- 1.0 (* 0.5 (* h t_1))))
(if (<= d -1.8e-208)
(* d (- (sqrt (/ 1.0 (* l h)))))
(if (<= d 1.45e-296)
(*
(* (pow (/ d h) 0.5) (pow (/ d l) 0.5))
(- 1.0 (* (/ h l) (* t_0 0.5))))
(if (<= d 7.5e-185)
(/ (* d (fma -0.5 (* (/ h l) t_0) 1.0)) (sqrt (* l h)))
(* (fma h (* -0.5 t_1) 1.0) (/ (/ d (sqrt h)) (sqrt l)))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = pow(((D * M_m) / (d * 2.0)), 2.0);
double t_1 = pow((0.5 * (D * (M_m / d))), 2.0) / l;
double tmp;
if (d <= -5e-160) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (0.5 * (h * t_1)));
} else if (d <= -1.8e-208) {
tmp = d * -sqrt((1.0 / (l * h)));
} else if (d <= 1.45e-296) {
tmp = (pow((d / h), 0.5) * pow((d / l), 0.5)) * (1.0 - ((h / l) * (t_0 * 0.5)));
} else if (d <= 7.5e-185) {
tmp = (d * fma(-0.5, ((h / l) * t_0), 1.0)) / sqrt((l * h));
} else {
tmp = fma(h, (-0.5 * t_1), 1.0) * ((d / sqrt(h)) / sqrt(l));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64(D * M_m) / Float64(d * 2.0)) ^ 2.0 t_1 = Float64((Float64(0.5 * Float64(D * Float64(M_m / d))) ^ 2.0) / l) tmp = 0.0 if (d <= -5e-160) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(0.5 * Float64(h * t_1)))); elseif (d <= -1.8e-208) tmp = Float64(d * Float64(-sqrt(Float64(1.0 / Float64(l * h))))); elseif (d <= 1.45e-296) tmp = Float64(Float64((Float64(d / h) ^ 0.5) * (Float64(d / l) ^ 0.5)) * Float64(1.0 - Float64(Float64(h / l) * Float64(t_0 * 0.5)))); elseif (d <= 7.5e-185) tmp = Float64(Float64(d * fma(-0.5, Float64(Float64(h / l) * t_0), 1.0)) / sqrt(Float64(l * h))); else tmp = Float64(fma(h, Float64(-0.5 * t_1), 1.0) * Float64(Float64(d / sqrt(h)) / sqrt(l))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[Power[N[(N[(D * M$95$m), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(0.5 * N[(D * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]}, If[LessEqual[d, -5e-160], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(h * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.8e-208], N[(d * (-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[d, 1.45e-296], N[(N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(t$95$0 * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7.5e-185], N[(N[(d * N[(-0.5 * N[(N[(h / l), $MachinePrecision] * t$95$0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(h * N[(-0.5 * t$95$1), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(d / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{D \cdot M\_m}{d \cdot 2}\right)}^{2}\\
t_1 := \frac{{\left(0.5 \cdot \left(D \cdot \frac{M\_m}{d}\right)\right)}^{2}}{\ell}\\
\mathbf{if}\;d \leq -5 \cdot 10^{-160}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot t\_1\right)\right)\\
\mathbf{elif}\;d \leq -1.8 \cdot 10^{-208}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{1}{\ell \cdot h}}\right)\\
\mathbf{elif}\;d \leq 1.45 \cdot 10^{-296}:\\
\;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(t\_0 \cdot 0.5\right)\right)\\
\mathbf{elif}\;d \leq 7.5 \cdot 10^{-185}:\\
\;\;\;\;\frac{d \cdot \mathsf{fma}\left(-0.5, \frac{h}{\ell} \cdot t\_0, 1\right)}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(h, -0.5 \cdot t\_1, 1\right) \cdot \frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}\\
\end{array}
\end{array}
if d < -4.99999999999999994e-160Initial program 72.8%
Simplified72.8%
clear-num72.8%
un-div-inv73.4%
frac-times73.3%
*-commutative73.3%
times-frac73.4%
Applied egg-rr73.4%
associate-/r/76.2%
*-commutative76.2%
*-rgt-identity76.2%
associate-/l*76.2%
metadata-eval76.2%
*-commutative76.2%
associate-*r*76.2%
Simplified76.2%
if -4.99999999999999994e-160 < d < -1.7999999999999999e-208Initial program 35.1%
Simplified35.1%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt79.9%
neg-mul-179.9%
Simplified79.9%
if -1.7999999999999999e-208 < d < 1.44999999999999991e-296Initial program 54.1%
if 1.44999999999999991e-296 < d < 7.49999999999999978e-185Initial program 49.4%
Simplified49.1%
sub-neg49.1%
distribute-rgt-in49.1%
*-un-lft-identity49.1%
sqrt-div49.0%
sqrt-div49.0%
frac-times49.1%
add-sqr-sqrt49.1%
Applied egg-rr61.7%
distribute-rgt1-in61.7%
+-commutative61.7%
associate-*r*61.7%
times-frac61.7%
*-commutative61.7%
associate-/l*61.7%
Simplified61.7%
associate-*r/78.8%
+-commutative78.8%
associate-*l*78.8%
fma-define78.8%
associate-*r/78.8%
sqrt-unprod70.1%
*-commutative70.1%
Applied egg-rr70.1%
if 7.49999999999999978e-185 < d Initial program 70.0%
Simplified70.8%
sub-neg70.8%
distribute-rgt-in56.0%
*-un-lft-identity56.0%
sqrt-div56.5%
sqrt-div60.1%
frac-times60.2%
add-sqr-sqrt60.3%
Applied egg-rr77.8%
distribute-rgt1-in90.7%
Simplified91.9%
Final simplification81.6%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (/ (pow (* 0.5 (* D (/ M_m d))) 2.0) l)) (t_1 (sqrt (/ d l))))
(if (<= h 7.5e-307)
(* (* t_1 (sqrt (/ d h))) (- 1.0 (* 0.5 (* h t_0))))
(if (<= h 3.7e-71)
(*
(/ d (* (sqrt h) (sqrt l)))
(+ 1.0 (* (pow (/ (* D M_m) (* d 2.0)) 2.0) (* (/ h l) -0.5))))
(if (<= h 1.4e+109)
(* (fma h (* -0.5 t_0) 1.0) (/ (/ d (sqrt h)) (sqrt l)))
(*
t_1
(*
(+ 1.0 (* (/ h l) (* (pow (* D (/ (/ M_m 2.0) d)) 2.0) -0.5)))
(/ (sqrt d) (sqrt h)))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = pow((0.5 * (D * (M_m / d))), 2.0) / l;
double t_1 = sqrt((d / l));
double tmp;
if (h <= 7.5e-307) {
tmp = (t_1 * sqrt((d / h))) * (1.0 - (0.5 * (h * t_0)));
} else if (h <= 3.7e-71) {
tmp = (d / (sqrt(h) * sqrt(l))) * (1.0 + (pow(((D * M_m) / (d * 2.0)), 2.0) * ((h / l) * -0.5)));
} else if (h <= 1.4e+109) {
tmp = fma(h, (-0.5 * t_0), 1.0) * ((d / sqrt(h)) / sqrt(l));
} else {
tmp = t_1 * ((1.0 + ((h / l) * (pow((D * ((M_m / 2.0) / d)), 2.0) * -0.5))) * (sqrt(d) / sqrt(h)));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64((Float64(0.5 * Float64(D * Float64(M_m / d))) ^ 2.0) / l) t_1 = sqrt(Float64(d / l)) tmp = 0.0 if (h <= 7.5e-307) tmp = Float64(Float64(t_1 * sqrt(Float64(d / h))) * Float64(1.0 - Float64(0.5 * Float64(h * t_0)))); elseif (h <= 3.7e-71) tmp = Float64(Float64(d / Float64(sqrt(h) * sqrt(l))) * Float64(1.0 + Float64((Float64(Float64(D * M_m) / Float64(d * 2.0)) ^ 2.0) * Float64(Float64(h / l) * -0.5)))); elseif (h <= 1.4e+109) tmp = Float64(fma(h, Float64(-0.5 * t_0), 1.0) * Float64(Float64(d / sqrt(h)) / sqrt(l))); else tmp = Float64(t_1 * Float64(Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(D * Float64(Float64(M_m / 2.0) / d)) ^ 2.0) * -0.5))) * Float64(sqrt(d) / sqrt(h)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[Power[N[(0.5 * N[(D * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[h, 7.5e-307], N[(N[(t$95$1 * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(h * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, 3.7e-71], N[(N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[Power[N[(N[(D * M$95$m), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, 1.4e+109], N[(N[(h * N[(-0.5 * t$95$0), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(d / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(D * N[(N[(M$95$m / 2.0), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \frac{{\left(0.5 \cdot \left(D \cdot \frac{M\_m}{d}\right)\right)}^{2}}{\ell}\\
t_1 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;h \leq 7.5 \cdot 10^{-307}:\\
\;\;\;\;\left(t\_1 \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot t\_0\right)\right)\\
\mathbf{elif}\;h \leq 3.7 \cdot 10^{-71}:\\
\;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \left(1 + {\left(\frac{D \cdot M\_m}{d \cdot 2}\right)}^{2} \cdot \left(\frac{h}{\ell} \cdot -0.5\right)\right)\\
\mathbf{elif}\;h \leq 1.4 \cdot 10^{+109}:\\
\;\;\;\;\mathsf{fma}\left(h, -0.5 \cdot t\_0, 1\right) \cdot \frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(\left(1 + \frac{h}{\ell} \cdot \left({\left(D \cdot \frac{\frac{M\_m}{2}}{d}\right)}^{2} \cdot -0.5\right)\right) \cdot \frac{\sqrt{d}}{\sqrt{h}}\right)\\
\end{array}
\end{array}
if h < 7.5000000000000006e-307Initial program 66.9%
Simplified66.9%
clear-num66.9%
un-div-inv67.4%
frac-times67.3%
*-commutative67.3%
times-frac67.3%
Applied egg-rr67.3%
associate-/r/70.4%
*-commutative70.4%
*-rgt-identity70.4%
associate-/l*70.4%
metadata-eval70.4%
*-commutative70.4%
associate-*r*70.4%
Simplified70.4%
if 7.5000000000000006e-307 < h < 3.6999999999999996e-71Initial program 70.8%
Simplified70.7%
sub-neg70.7%
distribute-rgt-in47.1%
*-un-lft-identity47.1%
sqrt-div47.1%
sqrt-div51.5%
frac-times51.5%
add-sqr-sqrt51.7%
Applied egg-rr70.1%
distribute-rgt1-in92.3%
+-commutative92.3%
associate-*r*92.3%
times-frac92.4%
*-commutative92.4%
associate-/l*92.3%
Simplified92.3%
associate-*r/92.4%
Applied egg-rr92.4%
if 3.6999999999999996e-71 < h < 1.4000000000000001e109Initial program 70.6%
Simplified70.4%
sub-neg70.4%
distribute-rgt-in62.4%
*-un-lft-identity62.4%
sqrt-div62.3%
sqrt-div64.6%
frac-times64.6%
add-sqr-sqrt64.7%
Applied egg-rr77.6%
distribute-rgt1-in82.4%
Simplified87.3%
if 1.4000000000000001e109 < h Initial program 58.3%
Simplified60.0%
sqrt-div86.3%
div-inv86.2%
Applied egg-rr86.2%
associate-*r/86.3%
*-rgt-identity86.3%
Simplified86.3%
Final simplification80.6%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (+ 1.0 (* (/ h l) (* (pow (* D (/ (/ M_m 2.0) d)) 2.0) -0.5))))
(t_1 (sqrt (/ d l))))
(if (<= d -5e-310)
(* (* (/ (sqrt (- d)) (sqrt (- h))) t_0) t_1)
(if (<= d 1.05e-223)
(* t_1 (* t_0 (/ (sqrt d) (sqrt h))))
(if (<= d 1e+184)
(*
(fma h (* -0.5 (/ (pow (* 0.5 (* D (/ M_m d))) 2.0) l)) 1.0)
(/ (/ d (sqrt h)) (sqrt l)))
(*
(+ 1.0 (* (* (/ h l) -0.5) (pow (* D (/ M_m (* d 2.0))) 2.0)))
(/ d (* (sqrt h) (sqrt l)))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = 1.0 + ((h / l) * (pow((D * ((M_m / 2.0) / d)), 2.0) * -0.5));
double t_1 = sqrt((d / l));
double tmp;
if (d <= -5e-310) {
tmp = ((sqrt(-d) / sqrt(-h)) * t_0) * t_1;
} else if (d <= 1.05e-223) {
tmp = t_1 * (t_0 * (sqrt(d) / sqrt(h)));
} else if (d <= 1e+184) {
tmp = fma(h, (-0.5 * (pow((0.5 * (D * (M_m / d))), 2.0) / l)), 1.0) * ((d / sqrt(h)) / sqrt(l));
} else {
tmp = (1.0 + (((h / l) * -0.5) * pow((D * (M_m / (d * 2.0))), 2.0))) * (d / (sqrt(h) * sqrt(l)));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(D * Float64(Float64(M_m / 2.0) / d)) ^ 2.0) * -0.5))) t_1 = sqrt(Float64(d / l)) tmp = 0.0 if (d <= -5e-310) tmp = Float64(Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * t_0) * t_1); elseif (d <= 1.05e-223) tmp = Float64(t_1 * Float64(t_0 * Float64(sqrt(d) / sqrt(h)))); elseif (d <= 1e+184) tmp = Float64(fma(h, Float64(-0.5 * Float64((Float64(0.5 * Float64(D * Float64(M_m / d))) ^ 2.0) / l)), 1.0) * Float64(Float64(d / sqrt(h)) / sqrt(l))); else tmp = Float64(Float64(1.0 + Float64(Float64(Float64(h / l) * -0.5) * (Float64(D * Float64(M_m / Float64(d * 2.0))) ^ 2.0))) * Float64(d / Float64(sqrt(h) * sqrt(l)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(D * N[(N[(M$95$m / 2.0), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -5e-310], N[(N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[d, 1.05e-223], N[(t$95$1 * N[(t$95$0 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1e+184], N[(N[(h * N[(-0.5 * N[(N[Power[N[(0.5 * N[(D * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(d / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(D * N[(M$95$m / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := 1 + \frac{h}{\ell} \cdot \left({\left(D \cdot \frac{\frac{M\_m}{2}}{d}\right)}^{2} \cdot -0.5\right)\\
t_1 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot t\_0\right) \cdot t\_1\\
\mathbf{elif}\;d \leq 1.05 \cdot 10^{-223}:\\
\;\;\;\;t\_1 \cdot \left(t\_0 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right)\\
\mathbf{elif}\;d \leq 10^{+184}:\\
\;\;\;\;\mathsf{fma}\left(h, -0.5 \cdot \frac{{\left(0.5 \cdot \left(D \cdot \frac{M\_m}{d}\right)\right)}^{2}}{\ell}, 1\right) \cdot \frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M\_m}{d \cdot 2}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if d < -4.999999999999985e-310Initial program 67.2%
Simplified67.2%
frac-2neg67.9%
sqrt-div77.7%
Applied egg-rr76.9%
if -4.999999999999985e-310 < d < 1.04999999999999991e-223Initial program 54.6%
Simplified54.5%
sqrt-div76.0%
div-inv76.1%
Applied egg-rr76.1%
associate-*r/76.0%
*-rgt-identity76.0%
Simplified76.0%
if 1.04999999999999991e-223 < d < 1.00000000000000002e184Initial program 66.3%
Simplified66.2%
sub-neg66.2%
distribute-rgt-in61.3%
*-un-lft-identity61.3%
sqrt-div62.0%
sqrt-div66.5%
frac-times66.5%
add-sqr-sqrt66.6%
Applied egg-rr82.4%
distribute-rgt1-in85.7%
Simplified90.0%
if 1.00000000000000002e184 < d Initial program 73.7%
Simplified76.6%
sub-neg76.6%
distribute-rgt-in37.3%
*-un-lft-identity37.3%
sqrt-div37.2%
sqrt-div37.3%
frac-times37.3%
add-sqr-sqrt37.4%
Applied egg-rr61.4%
distribute-rgt1-in98.9%
+-commutative98.9%
associate-*r*98.9%
times-frac96.6%
*-commutative96.6%
associate-/l*98.9%
Simplified98.9%
Final simplification84.4%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (pow (/ (* D M_m) (* d 2.0)) 2.0)))
(if (<= d -4.4e-160)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (* 0.5 (* h (/ (pow (* 0.5 (* D (/ M_m d))) 2.0) l)))))
(if (<= d -2.9e-208)
(* d (- (sqrt (/ 1.0 (* l h)))))
(if (<= d 1.45e-296)
(*
(* (pow (/ d h) 0.5) (pow (/ d l) 0.5))
(- 1.0 (* (/ h l) (* t_0 0.5))))
(if (<= d 2.2e-184)
(/ (* d (fma -0.5 (* (/ h l) t_0) 1.0)) (sqrt (* l h)))
(*
(+ 1.0 (* (* (/ h l) -0.5) (pow (* D (/ M_m (* d 2.0))) 2.0)))
(/ d (* (sqrt h) (sqrt l))))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = pow(((D * M_m) / (d * 2.0)), 2.0);
double tmp;
if (d <= -4.4e-160) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (0.5 * (h * (pow((0.5 * (D * (M_m / d))), 2.0) / l))));
} else if (d <= -2.9e-208) {
tmp = d * -sqrt((1.0 / (l * h)));
} else if (d <= 1.45e-296) {
tmp = (pow((d / h), 0.5) * pow((d / l), 0.5)) * (1.0 - ((h / l) * (t_0 * 0.5)));
} else if (d <= 2.2e-184) {
tmp = (d * fma(-0.5, ((h / l) * t_0), 1.0)) / sqrt((l * h));
} else {
tmp = (1.0 + (((h / l) * -0.5) * pow((D * (M_m / (d * 2.0))), 2.0))) * (d / (sqrt(h) * sqrt(l)));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64(D * M_m) / Float64(d * 2.0)) ^ 2.0 tmp = 0.0 if (d <= -4.4e-160) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(0.5 * Float64(h * Float64((Float64(0.5 * Float64(D * Float64(M_m / d))) ^ 2.0) / l))))); elseif (d <= -2.9e-208) tmp = Float64(d * Float64(-sqrt(Float64(1.0 / Float64(l * h))))); elseif (d <= 1.45e-296) tmp = Float64(Float64((Float64(d / h) ^ 0.5) * (Float64(d / l) ^ 0.5)) * Float64(1.0 - Float64(Float64(h / l) * Float64(t_0 * 0.5)))); elseif (d <= 2.2e-184) tmp = Float64(Float64(d * fma(-0.5, Float64(Float64(h / l) * t_0), 1.0)) / sqrt(Float64(l * h))); else tmp = Float64(Float64(1.0 + Float64(Float64(Float64(h / l) * -0.5) * (Float64(D * Float64(M_m / Float64(d * 2.0))) ^ 2.0))) * Float64(d / Float64(sqrt(h) * sqrt(l)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[Power[N[(N[(D * M$95$m), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[d, -4.4e-160], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(h * N[(N[Power[N[(0.5 * N[(D * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.9e-208], N[(d * (-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[d, 1.45e-296], N[(N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(t$95$0 * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.2e-184], N[(N[(d * N[(-0.5 * N[(N[(h / l), $MachinePrecision] * t$95$0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(D * N[(M$95$m / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{D \cdot M\_m}{d \cdot 2}\right)}^{2}\\
\mathbf{if}\;d \leq -4.4 \cdot 10^{-160}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(0.5 \cdot \left(D \cdot \frac{M\_m}{d}\right)\right)}^{2}}{\ell}\right)\right)\\
\mathbf{elif}\;d \leq -2.9 \cdot 10^{-208}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{1}{\ell \cdot h}}\right)\\
\mathbf{elif}\;d \leq 1.45 \cdot 10^{-296}:\\
\;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(t\_0 \cdot 0.5\right)\right)\\
\mathbf{elif}\;d \leq 2.2 \cdot 10^{-184}:\\
\;\;\;\;\frac{d \cdot \mathsf{fma}\left(-0.5, \frac{h}{\ell} \cdot t\_0, 1\right)}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M\_m}{d \cdot 2}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if d < -4.4e-160Initial program 72.8%
Simplified72.8%
clear-num72.8%
un-div-inv73.4%
frac-times73.3%
*-commutative73.3%
times-frac73.4%
Applied egg-rr73.4%
associate-/r/76.2%
*-commutative76.2%
*-rgt-identity76.2%
associate-/l*76.2%
metadata-eval76.2%
*-commutative76.2%
associate-*r*76.2%
Simplified76.2%
if -4.4e-160 < d < -2.8999999999999999e-208Initial program 35.1%
Simplified35.1%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt79.9%
neg-mul-179.9%
Simplified79.9%
if -2.8999999999999999e-208 < d < 1.44999999999999991e-296Initial program 54.1%
if 1.44999999999999991e-296 < d < 2.19999999999999992e-184Initial program 49.4%
Simplified49.1%
sub-neg49.1%
distribute-rgt-in49.1%
*-un-lft-identity49.1%
sqrt-div49.0%
sqrt-div49.0%
frac-times49.1%
add-sqr-sqrt49.1%
Applied egg-rr61.7%
distribute-rgt1-in61.7%
+-commutative61.7%
associate-*r*61.7%
times-frac61.7%
*-commutative61.7%
associate-/l*61.7%
Simplified61.7%
associate-*r/78.8%
+-commutative78.8%
associate-*l*78.8%
fma-define78.8%
associate-*r/78.8%
sqrt-unprod70.1%
*-commutative70.1%
Applied egg-rr70.1%
if 2.19999999999999992e-184 < d Initial program 70.0%
Simplified70.8%
sub-neg70.8%
distribute-rgt-in56.0%
*-un-lft-identity56.0%
sqrt-div56.5%
sqrt-div60.1%
frac-times60.2%
add-sqr-sqrt60.3%
Applied egg-rr77.8%
distribute-rgt1-in90.7%
+-commutative90.7%
associate-*r*90.7%
times-frac90.4%
*-commutative90.4%
associate-/l*90.7%
Simplified90.7%
Final simplification81.1%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (sqrt (/ h (pow l 3.0))))
(t_1 (* d (- (sqrt (/ 1.0 (* l h))))))
(t_2 (pow (* D M_m) 2.0)))
(if (<= d -1.05e+113)
t_1
(if (<= d -5e+60)
(* t_0 (* -0.125 (* t_2 (/ -1.0 d))))
(if (<= d -2.1e-213)
t_1
(if (<= d -1.65e-274)
(* -0.125 (* t_2 (/ t_0 (- d))))
(*
(+ 1.0 (* (* (/ h l) -0.5) (pow (* D (/ M_m (* d 2.0))) 2.0)))
(/ d (* (sqrt h) (sqrt l))))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = sqrt((h / pow(l, 3.0)));
double t_1 = d * -sqrt((1.0 / (l * h)));
double t_2 = pow((D * M_m), 2.0);
double tmp;
if (d <= -1.05e+113) {
tmp = t_1;
} else if (d <= -5e+60) {
tmp = t_0 * (-0.125 * (t_2 * (-1.0 / d)));
} else if (d <= -2.1e-213) {
tmp = t_1;
} else if (d <= -1.65e-274) {
tmp = -0.125 * (t_2 * (t_0 / -d));
} else {
tmp = (1.0 + (((h / l) * -0.5) * pow((D * (M_m / (d * 2.0))), 2.0))) * (d / (sqrt(h) * sqrt(l)));
}
return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sqrt((h / (l ** 3.0d0)))
t_1 = d * -sqrt((1.0d0 / (l * h)))
t_2 = (d_1 * m_m) ** 2.0d0
if (d <= (-1.05d+113)) then
tmp = t_1
else if (d <= (-5d+60)) then
tmp = t_0 * ((-0.125d0) * (t_2 * ((-1.0d0) / d)))
else if (d <= (-2.1d-213)) then
tmp = t_1
else if (d <= (-1.65d-274)) then
tmp = (-0.125d0) * (t_2 * (t_0 / -d))
else
tmp = (1.0d0 + (((h / l) * (-0.5d0)) * ((d_1 * (m_m / (d * 2.0d0))) ** 2.0d0))) * (d / (sqrt(h) * sqrt(l)))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = Math.sqrt((h / Math.pow(l, 3.0)));
double t_1 = d * -Math.sqrt((1.0 / (l * h)));
double t_2 = Math.pow((D * M_m), 2.0);
double tmp;
if (d <= -1.05e+113) {
tmp = t_1;
} else if (d <= -5e+60) {
tmp = t_0 * (-0.125 * (t_2 * (-1.0 / d)));
} else if (d <= -2.1e-213) {
tmp = t_1;
} else if (d <= -1.65e-274) {
tmp = -0.125 * (t_2 * (t_0 / -d));
} else {
tmp = (1.0 + (((h / l) * -0.5) * Math.pow((D * (M_m / (d * 2.0))), 2.0))) * (d / (Math.sqrt(h) * Math.sqrt(l)));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = math.sqrt((h / math.pow(l, 3.0))) t_1 = d * -math.sqrt((1.0 / (l * h))) t_2 = math.pow((D * M_m), 2.0) tmp = 0 if d <= -1.05e+113: tmp = t_1 elif d <= -5e+60: tmp = t_0 * (-0.125 * (t_2 * (-1.0 / d))) elif d <= -2.1e-213: tmp = t_1 elif d <= -1.65e-274: tmp = -0.125 * (t_2 * (t_0 / -d)) else: tmp = (1.0 + (((h / l) * -0.5) * math.pow((D * (M_m / (d * 2.0))), 2.0))) * (d / (math.sqrt(h) * math.sqrt(l))) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = sqrt(Float64(h / (l ^ 3.0))) t_1 = Float64(d * Float64(-sqrt(Float64(1.0 / Float64(l * h))))) t_2 = Float64(D * M_m) ^ 2.0 tmp = 0.0 if (d <= -1.05e+113) tmp = t_1; elseif (d <= -5e+60) tmp = Float64(t_0 * Float64(-0.125 * Float64(t_2 * Float64(-1.0 / d)))); elseif (d <= -2.1e-213) tmp = t_1; elseif (d <= -1.65e-274) tmp = Float64(-0.125 * Float64(t_2 * Float64(t_0 / Float64(-d)))); else tmp = Float64(Float64(1.0 + Float64(Float64(Float64(h / l) * -0.5) * (Float64(D * Float64(M_m / Float64(d * 2.0))) ^ 2.0))) * Float64(d / Float64(sqrt(h) * sqrt(l)))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = sqrt((h / (l ^ 3.0)));
t_1 = d * -sqrt((1.0 / (l * h)));
t_2 = (D * M_m) ^ 2.0;
tmp = 0.0;
if (d <= -1.05e+113)
tmp = t_1;
elseif (d <= -5e+60)
tmp = t_0 * (-0.125 * (t_2 * (-1.0 / d)));
elseif (d <= -2.1e-213)
tmp = t_1;
elseif (d <= -1.65e-274)
tmp = -0.125 * (t_2 * (t_0 / -d));
else
tmp = (1.0 + (((h / l) * -0.5) * ((D * (M_m / (d * 2.0))) ^ 2.0))) * (d / (sqrt(h) * sqrt(l)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(d * (-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(D * M$95$m), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[d, -1.05e+113], t$95$1, If[LessEqual[d, -5e+60], N[(t$95$0 * N[(-0.125 * N[(t$95$2 * N[(-1.0 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.1e-213], t$95$1, If[LessEqual[d, -1.65e-274], N[(-0.125 * N[(t$95$2 * N[(t$95$0 / (-d)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(D * N[(M$95$m / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{h}{{\ell}^{3}}}\\
t_1 := d \cdot \left(-\sqrt{\frac{1}{\ell \cdot h}}\right)\\
t_2 := {\left(D \cdot M\_m\right)}^{2}\\
\mathbf{if}\;d \leq -1.05 \cdot 10^{+113}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -5 \cdot 10^{+60}:\\
\;\;\;\;t\_0 \cdot \left(-0.125 \cdot \left(t\_2 \cdot \frac{-1}{d}\right)\right)\\
\mathbf{elif}\;d \leq -2.1 \cdot 10^{-213}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -1.65 \cdot 10^{-274}:\\
\;\;\;\;-0.125 \cdot \left(t\_2 \cdot \frac{t\_0}{-d}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M\_m}{d \cdot 2}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if d < -1.0499999999999999e113 or -4.99999999999999975e60 < d < -2.0999999999999998e-213Initial program 70.4%
Simplified70.4%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt57.7%
neg-mul-157.7%
Simplified57.7%
if -1.0499999999999999e113 < d < -4.99999999999999975e60Initial program 63.0%
Simplified63.0%
add-sqr-sqrt3.0%
sqrt-unprod3.0%
*-commutative3.0%
*-commutative3.0%
swap-sqr3.0%
Applied egg-rr3.0%
associate-*r*3.0%
times-frac3.0%
*-commutative3.0%
associate-/l*3.0%
Simplified3.0%
Taylor expanded in h around -inf 0.0%
associate-*r*0.0%
*-commutative0.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt60.2%
associate-/l*60.2%
unpow260.2%
unpow260.2%
swap-sqr60.3%
unpow260.3%
Simplified60.3%
if -2.0999999999999998e-213 < d < -1.6499999999999999e-274Initial program 34.7%
Simplified34.7%
add-sqr-sqrt0.8%
sqrt-unprod1.0%
*-commutative1.0%
*-commutative1.0%
swap-sqr0.2%
Applied egg-rr0.0%
associate-*r*0.0%
times-frac0.0%
*-commutative0.0%
associate-/l*0.0%
Simplified0.0%
Taylor expanded in h around -inf 0.0%
associate-*l/0.0%
associate-/l*0.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt44.7%
*-commutative44.7%
mul-1-neg44.7%
unpow244.7%
unpow244.7%
swap-sqr55.9%
unpow255.9%
Simplified55.9%
if -1.6499999999999999e-274 < d Initial program 66.8%
Simplified67.4%
sub-neg67.4%
distribute-rgt-in55.4%
*-un-lft-identity55.4%
sqrt-div55.1%
sqrt-div58.1%
frac-times58.1%
add-sqr-sqrt58.2%
Applied egg-rr74.4%
distribute-rgt1-in84.9%
+-commutative84.9%
associate-*r*84.9%
times-frac84.6%
*-commutative84.6%
associate-/l*84.9%
Simplified84.9%
Final simplification72.9%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (sqrt (/ h (pow l 3.0))))
(t_1 (* d (- (sqrt (/ 1.0 (* l h))))))
(t_2 (pow (* D M_m) 2.0)))
(if (<= d -1.05e+113)
t_1
(if (<= d -4.5e+60)
(* t_0 (* -0.125 (* t_2 (/ -1.0 d))))
(if (<= d -1.05e-212)
t_1
(if (<= d -1.65e-274)
(* -0.125 (* t_2 (/ t_0 (- d))))
(/
(* d (fma -0.5 (* (/ h l) (pow (/ (* D M_m) (* d 2.0)) 2.0)) 1.0))
(sqrt (* l h)))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = sqrt((h / pow(l, 3.0)));
double t_1 = d * -sqrt((1.0 / (l * h)));
double t_2 = pow((D * M_m), 2.0);
double tmp;
if (d <= -1.05e+113) {
tmp = t_1;
} else if (d <= -4.5e+60) {
tmp = t_0 * (-0.125 * (t_2 * (-1.0 / d)));
} else if (d <= -1.05e-212) {
tmp = t_1;
} else if (d <= -1.65e-274) {
tmp = -0.125 * (t_2 * (t_0 / -d));
} else {
tmp = (d * fma(-0.5, ((h / l) * pow(((D * M_m) / (d * 2.0)), 2.0)), 1.0)) / sqrt((l * h));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = sqrt(Float64(h / (l ^ 3.0))) t_1 = Float64(d * Float64(-sqrt(Float64(1.0 / Float64(l * h))))) t_2 = Float64(D * M_m) ^ 2.0 tmp = 0.0 if (d <= -1.05e+113) tmp = t_1; elseif (d <= -4.5e+60) tmp = Float64(t_0 * Float64(-0.125 * Float64(t_2 * Float64(-1.0 / d)))); elseif (d <= -1.05e-212) tmp = t_1; elseif (d <= -1.65e-274) tmp = Float64(-0.125 * Float64(t_2 * Float64(t_0 / Float64(-d)))); else tmp = Float64(Float64(d * fma(-0.5, Float64(Float64(h / l) * (Float64(Float64(D * M_m) / Float64(d * 2.0)) ^ 2.0)), 1.0)) / sqrt(Float64(l * h))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(d * (-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(D * M$95$m), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[d, -1.05e+113], t$95$1, If[LessEqual[d, -4.5e+60], N[(t$95$0 * N[(-0.125 * N[(t$95$2 * N[(-1.0 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.05e-212], t$95$1, If[LessEqual[d, -1.65e-274], N[(-0.125 * N[(t$95$2 * N[(t$95$0 / (-d)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d * N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D * M$95$m), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{h}{{\ell}^{3}}}\\
t_1 := d \cdot \left(-\sqrt{\frac{1}{\ell \cdot h}}\right)\\
t_2 := {\left(D \cdot M\_m\right)}^{2}\\
\mathbf{if}\;d \leq -1.05 \cdot 10^{+113}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -4.5 \cdot 10^{+60}:\\
\;\;\;\;t\_0 \cdot \left(-0.125 \cdot \left(t\_2 \cdot \frac{-1}{d}\right)\right)\\
\mathbf{elif}\;d \leq -1.05 \cdot 10^{-212}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -1.65 \cdot 10^{-274}:\\
\;\;\;\;-0.125 \cdot \left(t\_2 \cdot \frac{t\_0}{-d}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d \cdot \mathsf{fma}\left(-0.5, \frac{h}{\ell} \cdot {\left(\frac{D \cdot M\_m}{d \cdot 2}\right)}^{2}, 1\right)}{\sqrt{\ell \cdot h}}\\
\end{array}
\end{array}
if d < -1.0499999999999999e113 or -4.50000000000000013e60 < d < -1.05e-212Initial program 70.4%
Simplified70.4%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt57.7%
neg-mul-157.7%
Simplified57.7%
if -1.0499999999999999e113 < d < -4.50000000000000013e60Initial program 63.0%
Simplified63.0%
add-sqr-sqrt3.0%
sqrt-unprod3.0%
*-commutative3.0%
*-commutative3.0%
swap-sqr3.0%
Applied egg-rr3.0%
associate-*r*3.0%
times-frac3.0%
*-commutative3.0%
associate-/l*3.0%
Simplified3.0%
Taylor expanded in h around -inf 0.0%
associate-*r*0.0%
*-commutative0.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt60.2%
associate-/l*60.2%
unpow260.2%
unpow260.2%
swap-sqr60.3%
unpow260.3%
Simplified60.3%
if -1.05e-212 < d < -1.6499999999999999e-274Initial program 34.7%
Simplified34.7%
add-sqr-sqrt0.8%
sqrt-unprod1.0%
*-commutative1.0%
*-commutative1.0%
swap-sqr0.2%
Applied egg-rr0.0%
associate-*r*0.0%
times-frac0.0%
*-commutative0.0%
associate-/l*0.0%
Simplified0.0%
Taylor expanded in h around -inf 0.0%
associate-*l/0.0%
associate-/l*0.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt44.7%
*-commutative44.7%
mul-1-neg44.7%
unpow244.7%
unpow244.7%
swap-sqr55.9%
unpow255.9%
Simplified55.9%
if -1.6499999999999999e-274 < d Initial program 66.8%
Simplified67.4%
sub-neg67.4%
distribute-rgt-in55.4%
*-un-lft-identity55.4%
sqrt-div55.1%
sqrt-div58.1%
frac-times58.1%
add-sqr-sqrt58.2%
Applied egg-rr74.4%
distribute-rgt1-in84.9%
+-commutative84.9%
associate-*r*84.9%
times-frac84.6%
*-commutative84.6%
associate-/l*84.9%
Simplified84.9%
associate-*r/88.4%
+-commutative88.4%
associate-*l*88.4%
fma-define88.4%
associate-*r/88.1%
sqrt-unprod76.1%
*-commutative76.1%
Applied egg-rr76.1%
Final simplification68.0%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (* 0.5 (* h (/ (pow (* 0.5 (* D (/ M_m d))) 2.0) l)))))))
(if (<= d -5e-160)
t_0
(if (<= d -2.9e-208)
(* d (- (sqrt (/ 1.0 (* l h)))))
(if (<= d -1.85e-260)
t_0
(*
(+ 1.0 (* (* (/ h l) -0.5) (pow (* D (/ M_m (* d 2.0))) 2.0)))
(/ d (* (sqrt h) (sqrt l)))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (0.5 * (h * (pow((0.5 * (D * (M_m / d))), 2.0) / l))));
double tmp;
if (d <= -5e-160) {
tmp = t_0;
} else if (d <= -2.9e-208) {
tmp = d * -sqrt((1.0 / (l * h)));
} else if (d <= -1.85e-260) {
tmp = t_0;
} else {
tmp = (1.0 + (((h / l) * -0.5) * pow((D * (M_m / (d * 2.0))), 2.0))) * (d / (sqrt(h) * sqrt(l)));
}
return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = (sqrt((d / l)) * sqrt((d / h))) * (1.0d0 - (0.5d0 * (h * (((0.5d0 * (d_1 * (m_m / d))) ** 2.0d0) / l))))
if (d <= (-5d-160)) then
tmp = t_0
else if (d <= (-2.9d-208)) then
tmp = d * -sqrt((1.0d0 / (l * h)))
else if (d <= (-1.85d-260)) then
tmp = t_0
else
tmp = (1.0d0 + (((h / l) * (-0.5d0)) * ((d_1 * (m_m / (d * 2.0d0))) ** 2.0d0))) * (d / (sqrt(h) * sqrt(l)))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * (1.0 - (0.5 * (h * (Math.pow((0.5 * (D * (M_m / d))), 2.0) / l))));
double tmp;
if (d <= -5e-160) {
tmp = t_0;
} else if (d <= -2.9e-208) {
tmp = d * -Math.sqrt((1.0 / (l * h)));
} else if (d <= -1.85e-260) {
tmp = t_0;
} else {
tmp = (1.0 + (((h / l) * -0.5) * Math.pow((D * (M_m / (d * 2.0))), 2.0))) * (d / (Math.sqrt(h) * Math.sqrt(l)));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = (math.sqrt((d / l)) * math.sqrt((d / h))) * (1.0 - (0.5 * (h * (math.pow((0.5 * (D * (M_m / d))), 2.0) / l)))) tmp = 0 if d <= -5e-160: tmp = t_0 elif d <= -2.9e-208: tmp = d * -math.sqrt((1.0 / (l * h))) elif d <= -1.85e-260: tmp = t_0 else: tmp = (1.0 + (((h / l) * -0.5) * math.pow((D * (M_m / (d * 2.0))), 2.0))) * (d / (math.sqrt(h) * math.sqrt(l))) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(0.5 * Float64(h * Float64((Float64(0.5 * Float64(D * Float64(M_m / d))) ^ 2.0) / l))))) tmp = 0.0 if (d <= -5e-160) tmp = t_0; elseif (d <= -2.9e-208) tmp = Float64(d * Float64(-sqrt(Float64(1.0 / Float64(l * h))))); elseif (d <= -1.85e-260) tmp = t_0; else tmp = Float64(Float64(1.0 + Float64(Float64(Float64(h / l) * -0.5) * (Float64(D * Float64(M_m / Float64(d * 2.0))) ^ 2.0))) * Float64(d / Float64(sqrt(h) * sqrt(l)))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (0.5 * (h * (((0.5 * (D * (M_m / d))) ^ 2.0) / l))));
tmp = 0.0;
if (d <= -5e-160)
tmp = t_0;
elseif (d <= -2.9e-208)
tmp = d * -sqrt((1.0 / (l * h)));
elseif (d <= -1.85e-260)
tmp = t_0;
else
tmp = (1.0 + (((h / l) * -0.5) * ((D * (M_m / (d * 2.0))) ^ 2.0))) * (d / (sqrt(h) * sqrt(l)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(h * N[(N[Power[N[(0.5 * N[(D * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5e-160], t$95$0, If[LessEqual[d, -2.9e-208], N[(d * (-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[d, -1.85e-260], t$95$0, N[(N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(D * N[(M$95$m / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(0.5 \cdot \left(D \cdot \frac{M\_m}{d}\right)\right)}^{2}}{\ell}\right)\right)\\
\mathbf{if}\;d \leq -5 \cdot 10^{-160}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -2.9 \cdot 10^{-208}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{1}{\ell \cdot h}}\right)\\
\mathbf{elif}\;d \leq -1.85 \cdot 10^{-260}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M\_m}{d \cdot 2}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if d < -4.99999999999999994e-160 or -2.8999999999999999e-208 < d < -1.8500000000000001e-260Initial program 71.7%
Simplified71.8%
clear-num71.8%
un-div-inv72.3%
frac-times72.2%
*-commutative72.2%
times-frac72.2%
Applied egg-rr72.2%
associate-/r/74.9%
*-commutative74.9%
*-rgt-identity74.9%
associate-/l*74.9%
metadata-eval74.9%
*-commutative74.9%
associate-*r*74.9%
Simplified74.9%
if -4.99999999999999994e-160 < d < -2.8999999999999999e-208Initial program 35.1%
Simplified35.1%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt79.9%
neg-mul-179.9%
Simplified79.9%
if -1.8500000000000001e-260 < d Initial program 65.7%
Simplified66.3%
sub-neg66.3%
distribute-rgt-in54.6%
*-un-lft-identity54.6%
sqrt-div53.6%
sqrt-div56.5%
frac-times56.5%
add-sqr-sqrt56.6%
Applied egg-rr72.4%
distribute-rgt1-in82.6%
+-commutative82.6%
associate-*r*82.6%
times-frac82.3%
*-commutative82.3%
associate-/l*82.6%
Simplified82.6%
Final simplification79.5%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (sqrt (/ h (pow l 3.0))))
(t_1 (* d (- (sqrt (/ 1.0 (* l h))))))
(t_2 (pow (* D M_m) 2.0)))
(if (<= d -1.05e+113)
t_1
(if (<= d -5e+60)
(* t_0 (* -0.125 (* t_2 (/ -1.0 d))))
(if (<= d -8e-213)
t_1
(if (<= d -1.65e-274)
(* -0.125 (* t_2 (/ t_0 (- d))))
(*
(+ 1.0 (* (* (/ h l) -0.5) (pow (* D (/ M_m (* d 2.0))) 2.0)))
(/ d (sqrt (* l h))))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = sqrt((h / pow(l, 3.0)));
double t_1 = d * -sqrt((1.0 / (l * h)));
double t_2 = pow((D * M_m), 2.0);
double tmp;
if (d <= -1.05e+113) {
tmp = t_1;
} else if (d <= -5e+60) {
tmp = t_0 * (-0.125 * (t_2 * (-1.0 / d)));
} else if (d <= -8e-213) {
tmp = t_1;
} else if (d <= -1.65e-274) {
tmp = -0.125 * (t_2 * (t_0 / -d));
} else {
tmp = (1.0 + (((h / l) * -0.5) * pow((D * (M_m / (d * 2.0))), 2.0))) * (d / sqrt((l * h)));
}
return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sqrt((h / (l ** 3.0d0)))
t_1 = d * -sqrt((1.0d0 / (l * h)))
t_2 = (d_1 * m_m) ** 2.0d0
if (d <= (-1.05d+113)) then
tmp = t_1
else if (d <= (-5d+60)) then
tmp = t_0 * ((-0.125d0) * (t_2 * ((-1.0d0) / d)))
else if (d <= (-8d-213)) then
tmp = t_1
else if (d <= (-1.65d-274)) then
tmp = (-0.125d0) * (t_2 * (t_0 / -d))
else
tmp = (1.0d0 + (((h / l) * (-0.5d0)) * ((d_1 * (m_m / (d * 2.0d0))) ** 2.0d0))) * (d / sqrt((l * h)))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = Math.sqrt((h / Math.pow(l, 3.0)));
double t_1 = d * -Math.sqrt((1.0 / (l * h)));
double t_2 = Math.pow((D * M_m), 2.0);
double tmp;
if (d <= -1.05e+113) {
tmp = t_1;
} else if (d <= -5e+60) {
tmp = t_0 * (-0.125 * (t_2 * (-1.0 / d)));
} else if (d <= -8e-213) {
tmp = t_1;
} else if (d <= -1.65e-274) {
tmp = -0.125 * (t_2 * (t_0 / -d));
} else {
tmp = (1.0 + (((h / l) * -0.5) * Math.pow((D * (M_m / (d * 2.0))), 2.0))) * (d / Math.sqrt((l * h)));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = math.sqrt((h / math.pow(l, 3.0))) t_1 = d * -math.sqrt((1.0 / (l * h))) t_2 = math.pow((D * M_m), 2.0) tmp = 0 if d <= -1.05e+113: tmp = t_1 elif d <= -5e+60: tmp = t_0 * (-0.125 * (t_2 * (-1.0 / d))) elif d <= -8e-213: tmp = t_1 elif d <= -1.65e-274: tmp = -0.125 * (t_2 * (t_0 / -d)) else: tmp = (1.0 + (((h / l) * -0.5) * math.pow((D * (M_m / (d * 2.0))), 2.0))) * (d / math.sqrt((l * h))) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = sqrt(Float64(h / (l ^ 3.0))) t_1 = Float64(d * Float64(-sqrt(Float64(1.0 / Float64(l * h))))) t_2 = Float64(D * M_m) ^ 2.0 tmp = 0.0 if (d <= -1.05e+113) tmp = t_1; elseif (d <= -5e+60) tmp = Float64(t_0 * Float64(-0.125 * Float64(t_2 * Float64(-1.0 / d)))); elseif (d <= -8e-213) tmp = t_1; elseif (d <= -1.65e-274) tmp = Float64(-0.125 * Float64(t_2 * Float64(t_0 / Float64(-d)))); else tmp = Float64(Float64(1.0 + Float64(Float64(Float64(h / l) * -0.5) * (Float64(D * Float64(M_m / Float64(d * 2.0))) ^ 2.0))) * Float64(d / sqrt(Float64(l * h)))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = sqrt((h / (l ^ 3.0)));
t_1 = d * -sqrt((1.0 / (l * h)));
t_2 = (D * M_m) ^ 2.0;
tmp = 0.0;
if (d <= -1.05e+113)
tmp = t_1;
elseif (d <= -5e+60)
tmp = t_0 * (-0.125 * (t_2 * (-1.0 / d)));
elseif (d <= -8e-213)
tmp = t_1;
elseif (d <= -1.65e-274)
tmp = -0.125 * (t_2 * (t_0 / -d));
else
tmp = (1.0 + (((h / l) * -0.5) * ((D * (M_m / (d * 2.0))) ^ 2.0))) * (d / sqrt((l * h)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(d * (-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(D * M$95$m), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[d, -1.05e+113], t$95$1, If[LessEqual[d, -5e+60], N[(t$95$0 * N[(-0.125 * N[(t$95$2 * N[(-1.0 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -8e-213], t$95$1, If[LessEqual[d, -1.65e-274], N[(-0.125 * N[(t$95$2 * N[(t$95$0 / (-d)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(D * N[(M$95$m / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{h}{{\ell}^{3}}}\\
t_1 := d \cdot \left(-\sqrt{\frac{1}{\ell \cdot h}}\right)\\
t_2 := {\left(D \cdot M\_m\right)}^{2}\\
\mathbf{if}\;d \leq -1.05 \cdot 10^{+113}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -5 \cdot 10^{+60}:\\
\;\;\;\;t\_0 \cdot \left(-0.125 \cdot \left(t\_2 \cdot \frac{-1}{d}\right)\right)\\
\mathbf{elif}\;d \leq -8 \cdot 10^{-213}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -1.65 \cdot 10^{-274}:\\
\;\;\;\;-0.125 \cdot \left(t\_2 \cdot \frac{t\_0}{-d}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M\_m}{d \cdot 2}\right)}^{2}\right) \cdot \frac{d}{\sqrt{\ell \cdot h}}\\
\end{array}
\end{array}
if d < -1.0499999999999999e113 or -4.99999999999999975e60 < d < -7.9999999999999996e-213Initial program 70.4%
Simplified70.4%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt57.7%
neg-mul-157.7%
Simplified57.7%
if -1.0499999999999999e113 < d < -4.99999999999999975e60Initial program 63.0%
Simplified63.0%
add-sqr-sqrt3.0%
sqrt-unprod3.0%
*-commutative3.0%
*-commutative3.0%
swap-sqr3.0%
Applied egg-rr3.0%
associate-*r*3.0%
times-frac3.0%
*-commutative3.0%
associate-/l*3.0%
Simplified3.0%
Taylor expanded in h around -inf 0.0%
associate-*r*0.0%
*-commutative0.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt60.2%
associate-/l*60.2%
unpow260.2%
unpow260.2%
swap-sqr60.3%
unpow260.3%
Simplified60.3%
if -7.9999999999999996e-213 < d < -1.6499999999999999e-274Initial program 34.7%
Simplified34.7%
add-sqr-sqrt0.8%
sqrt-unprod1.0%
*-commutative1.0%
*-commutative1.0%
swap-sqr0.2%
Applied egg-rr0.0%
associate-*r*0.0%
times-frac0.0%
*-commutative0.0%
associate-/l*0.0%
Simplified0.0%
Taylor expanded in h around -inf 0.0%
associate-*l/0.0%
associate-/l*0.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt44.7%
*-commutative44.7%
mul-1-neg44.7%
unpow244.7%
unpow244.7%
swap-sqr55.9%
unpow255.9%
Simplified55.9%
if -1.6499999999999999e-274 < d Initial program 66.8%
Simplified67.4%
sub-neg67.4%
distribute-rgt-in55.4%
*-un-lft-identity55.4%
sqrt-div55.1%
sqrt-div58.1%
frac-times58.1%
add-sqr-sqrt58.2%
Applied egg-rr74.4%
distribute-rgt1-in84.9%
+-commutative84.9%
associate-*r*84.9%
times-frac84.6%
*-commutative84.6%
associate-/l*84.9%
Simplified84.9%
Taylor expanded in h around 0 73.0%
*-commutative73.0%
Simplified73.0%
Final simplification66.3%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0
(* -0.125 (* (pow (* D M_m) 2.0) (/ (sqrt (/ h (pow l 3.0))) (- d)))))
(t_1 (* d (- (sqrt (/ 1.0 (* l h)))))))
(if (<= d -1.05e+113)
t_1
(if (<= d -5e+60)
t_0
(if (<= d -1.18e-212)
t_1
(if (<= d -1.65e-274)
t_0
(*
(+ 1.0 (* (* (/ h l) -0.5) (pow (* D (/ M_m (* d 2.0))) 2.0)))
(/ d (sqrt (* l h))))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = -0.125 * (pow((D * M_m), 2.0) * (sqrt((h / pow(l, 3.0))) / -d));
double t_1 = d * -sqrt((1.0 / (l * h)));
double tmp;
if (d <= -1.05e+113) {
tmp = t_1;
} else if (d <= -5e+60) {
tmp = t_0;
} else if (d <= -1.18e-212) {
tmp = t_1;
} else if (d <= -1.65e-274) {
tmp = t_0;
} else {
tmp = (1.0 + (((h / l) * -0.5) * pow((D * (M_m / (d * 2.0))), 2.0))) * (d / sqrt((l * h)));
}
return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (-0.125d0) * (((d_1 * m_m) ** 2.0d0) * (sqrt((h / (l ** 3.0d0))) / -d))
t_1 = d * -sqrt((1.0d0 / (l * h)))
if (d <= (-1.05d+113)) then
tmp = t_1
else if (d <= (-5d+60)) then
tmp = t_0
else if (d <= (-1.18d-212)) then
tmp = t_1
else if (d <= (-1.65d-274)) then
tmp = t_0
else
tmp = (1.0d0 + (((h / l) * (-0.5d0)) * ((d_1 * (m_m / (d * 2.0d0))) ** 2.0d0))) * (d / sqrt((l * h)))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = -0.125 * (Math.pow((D * M_m), 2.0) * (Math.sqrt((h / Math.pow(l, 3.0))) / -d));
double t_1 = d * -Math.sqrt((1.0 / (l * h)));
double tmp;
if (d <= -1.05e+113) {
tmp = t_1;
} else if (d <= -5e+60) {
tmp = t_0;
} else if (d <= -1.18e-212) {
tmp = t_1;
} else if (d <= -1.65e-274) {
tmp = t_0;
} else {
tmp = (1.0 + (((h / l) * -0.5) * Math.pow((D * (M_m / (d * 2.0))), 2.0))) * (d / Math.sqrt((l * h)));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = -0.125 * (math.pow((D * M_m), 2.0) * (math.sqrt((h / math.pow(l, 3.0))) / -d)) t_1 = d * -math.sqrt((1.0 / (l * h))) tmp = 0 if d <= -1.05e+113: tmp = t_1 elif d <= -5e+60: tmp = t_0 elif d <= -1.18e-212: tmp = t_1 elif d <= -1.65e-274: tmp = t_0 else: tmp = (1.0 + (((h / l) * -0.5) * math.pow((D * (M_m / (d * 2.0))), 2.0))) * (d / math.sqrt((l * h))) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(-0.125 * Float64((Float64(D * M_m) ^ 2.0) * Float64(sqrt(Float64(h / (l ^ 3.0))) / Float64(-d)))) t_1 = Float64(d * Float64(-sqrt(Float64(1.0 / Float64(l * h))))) tmp = 0.0 if (d <= -1.05e+113) tmp = t_1; elseif (d <= -5e+60) tmp = t_0; elseif (d <= -1.18e-212) tmp = t_1; elseif (d <= -1.65e-274) tmp = t_0; else tmp = Float64(Float64(1.0 + Float64(Float64(Float64(h / l) * -0.5) * (Float64(D * Float64(M_m / Float64(d * 2.0))) ^ 2.0))) * Float64(d / sqrt(Float64(l * h)))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = -0.125 * (((D * M_m) ^ 2.0) * (sqrt((h / (l ^ 3.0))) / -d));
t_1 = d * -sqrt((1.0 / (l * h)));
tmp = 0.0;
if (d <= -1.05e+113)
tmp = t_1;
elseif (d <= -5e+60)
tmp = t_0;
elseif (d <= -1.18e-212)
tmp = t_1;
elseif (d <= -1.65e-274)
tmp = t_0;
else
tmp = (1.0 + (((h / l) * -0.5) * ((D * (M_m / (d * 2.0))) ^ 2.0))) * (d / sqrt((l * h)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(-0.125 * N[(N[Power[N[(D * M$95$m), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-d)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d * (-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]}, If[LessEqual[d, -1.05e+113], t$95$1, If[LessEqual[d, -5e+60], t$95$0, If[LessEqual[d, -1.18e-212], t$95$1, If[LessEqual[d, -1.65e-274], t$95$0, N[(N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(D * N[(M$95$m / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := -0.125 \cdot \left({\left(D \cdot M\_m\right)}^{2} \cdot \frac{\sqrt{\frac{h}{{\ell}^{3}}}}{-d}\right)\\
t_1 := d \cdot \left(-\sqrt{\frac{1}{\ell \cdot h}}\right)\\
\mathbf{if}\;d \leq -1.05 \cdot 10^{+113}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -5 \cdot 10^{+60}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -1.18 \cdot 10^{-212}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -1.65 \cdot 10^{-274}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M\_m}{d \cdot 2}\right)}^{2}\right) \cdot \frac{d}{\sqrt{\ell \cdot h}}\\
\end{array}
\end{array}
if d < -1.0499999999999999e113 or -4.99999999999999975e60 < d < -1.17999999999999996e-212Initial program 70.4%
Simplified70.4%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt57.7%
neg-mul-157.7%
Simplified57.7%
if -1.0499999999999999e113 < d < -4.99999999999999975e60 or -1.17999999999999996e-212 < d < -1.6499999999999999e-274Initial program 49.6%
Simplified49.6%
add-sqr-sqrt2.0%
sqrt-unprod2.1%
*-commutative2.1%
*-commutative2.1%
swap-sqr1.7%
Applied egg-rr1.6%
associate-*r*1.6%
times-frac1.6%
*-commutative1.6%
associate-/l*1.6%
Simplified1.6%
Taylor expanded in h around -inf 0.0%
associate-*l/0.0%
associate-/l*0.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt52.8%
*-commutative52.8%
mul-1-neg52.8%
unpow252.8%
unpow252.8%
swap-sqr58.2%
unpow258.2%
Simplified58.2%
if -1.6499999999999999e-274 < d Initial program 66.8%
Simplified67.4%
sub-neg67.4%
distribute-rgt-in55.4%
*-un-lft-identity55.4%
sqrt-div55.1%
sqrt-div58.1%
frac-times58.1%
add-sqr-sqrt58.2%
Applied egg-rr74.4%
distribute-rgt1-in84.9%
+-commutative84.9%
associate-*r*84.9%
times-frac84.6%
*-commutative84.6%
associate-/l*84.9%
Simplified84.9%
Taylor expanded in h around 0 73.0%
*-commutative73.0%
Simplified73.0%
Final simplification66.3%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<= h -3.6e-305)
(*
(sqrt (/ d l))
(*
(+ 1.0 (* (/ h l) (* (pow (* D (/ (/ M_m 2.0) d)) 2.0) -0.5)))
(sqrt (/ d h))))
(*
(+ 1.0 (* (* (/ h l) -0.5) (pow (* D (/ M_m (* d 2.0))) 2.0)))
(/ d (* (sqrt h) (sqrt l))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (h <= -3.6e-305) {
tmp = sqrt((d / l)) * ((1.0 + ((h / l) * (pow((D * ((M_m / 2.0) / d)), 2.0) * -0.5))) * sqrt((d / h)));
} else {
tmp = (1.0 + (((h / l) * -0.5) * pow((D * (M_m / (d * 2.0))), 2.0))) * (d / (sqrt(h) * sqrt(l)));
}
return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: tmp
if (h <= (-3.6d-305)) then
tmp = sqrt((d / l)) * ((1.0d0 + ((h / l) * (((d_1 * ((m_m / 2.0d0) / d)) ** 2.0d0) * (-0.5d0)))) * sqrt((d / h)))
else
tmp = (1.0d0 + (((h / l) * (-0.5d0)) * ((d_1 * (m_m / (d * 2.0d0))) ** 2.0d0))) * (d / (sqrt(h) * sqrt(l)))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (h <= -3.6e-305) {
tmp = Math.sqrt((d / l)) * ((1.0 + ((h / l) * (Math.pow((D * ((M_m / 2.0) / d)), 2.0) * -0.5))) * Math.sqrt((d / h)));
} else {
tmp = (1.0 + (((h / l) * -0.5) * Math.pow((D * (M_m / (d * 2.0))), 2.0))) * (d / (Math.sqrt(h) * Math.sqrt(l)));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if h <= -3.6e-305: tmp = math.sqrt((d / l)) * ((1.0 + ((h / l) * (math.pow((D * ((M_m / 2.0) / d)), 2.0) * -0.5))) * math.sqrt((d / h))) else: tmp = (1.0 + (((h / l) * -0.5) * math.pow((D * (M_m / (d * 2.0))), 2.0))) * (d / (math.sqrt(h) * math.sqrt(l))) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (h <= -3.6e-305) tmp = Float64(sqrt(Float64(d / l)) * Float64(Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(D * Float64(Float64(M_m / 2.0) / d)) ^ 2.0) * -0.5))) * sqrt(Float64(d / h)))); else tmp = Float64(Float64(1.0 + Float64(Float64(Float64(h / l) * -0.5) * (Float64(D * Float64(M_m / Float64(d * 2.0))) ^ 2.0))) * Float64(d / Float64(sqrt(h) * sqrt(l)))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (h <= -3.6e-305)
tmp = sqrt((d / l)) * ((1.0 + ((h / l) * (((D * ((M_m / 2.0) / d)) ^ 2.0) * -0.5))) * sqrt((d / h)));
else
tmp = (1.0 + (((h / l) * -0.5) * ((D * (M_m / (d * 2.0))) ^ 2.0))) * (d / (sqrt(h) * sqrt(l)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[h, -3.6e-305], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(D * N[(N[(M$95$m / 2.0), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(D * N[(M$95$m / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -3.6 \cdot 10^{-305}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\left(1 + \frac{h}{\ell} \cdot \left({\left(D \cdot \frac{\frac{M\_m}{2}}{d}\right)}^{2} \cdot -0.5\right)\right) \cdot \sqrt{\frac{d}{h}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M\_m}{d \cdot 2}\right)}^{2}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if h < -3.60000000000000004e-305Initial program 67.8%
Simplified67.8%
if -3.60000000000000004e-305 < h Initial program 66.1%
Simplified66.7%
sub-neg66.7%
distribute-rgt-in54.7%
*-un-lft-identity54.7%
sqrt-div55.1%
sqrt-div58.1%
frac-times58.1%
add-sqr-sqrt58.2%
Applied egg-rr74.4%
distribute-rgt1-in84.9%
+-commutative84.9%
associate-*r*84.9%
times-frac84.6%
*-commutative84.6%
associate-/l*84.9%
Simplified84.9%
Final simplification77.3%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<= l -4.3e-274)
(* d (- (sqrt (/ 1.0 (* l h)))))
(*
(+ 1.0 (* (* (/ h l) -0.5) (pow (* D (/ M_m (* d 2.0))) 2.0)))
(/ d (sqrt (* l h))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= -4.3e-274) {
tmp = d * -sqrt((1.0 / (l * h)));
} else {
tmp = (1.0 + (((h / l) * -0.5) * pow((D * (M_m / (d * 2.0))), 2.0))) * (d / sqrt((l * h)));
}
return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: tmp
if (l <= (-4.3d-274)) then
tmp = d * -sqrt((1.0d0 / (l * h)))
else
tmp = (1.0d0 + (((h / l) * (-0.5d0)) * ((d_1 * (m_m / (d * 2.0d0))) ** 2.0d0))) * (d / sqrt((l * h)))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= -4.3e-274) {
tmp = d * -Math.sqrt((1.0 / (l * h)));
} else {
tmp = (1.0 + (((h / l) * -0.5) * Math.pow((D * (M_m / (d * 2.0))), 2.0))) * (d / Math.sqrt((l * h)));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if l <= -4.3e-274: tmp = d * -math.sqrt((1.0 / (l * h))) else: tmp = (1.0 + (((h / l) * -0.5) * math.pow((D * (M_m / (d * 2.0))), 2.0))) * (d / math.sqrt((l * h))) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (l <= -4.3e-274) tmp = Float64(d * Float64(-sqrt(Float64(1.0 / Float64(l * h))))); else tmp = Float64(Float64(1.0 + Float64(Float64(Float64(h / l) * -0.5) * (Float64(D * Float64(M_m / Float64(d * 2.0))) ^ 2.0))) * Float64(d / sqrt(Float64(l * h)))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (l <= -4.3e-274)
tmp = d * -sqrt((1.0 / (l * h)));
else
tmp = (1.0 + (((h / l) * -0.5) * ((D * (M_m / (d * 2.0))) ^ 2.0))) * (d / sqrt((l * h)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[l, -4.3e-274], N[(d * (-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(D * N[(M$95$m / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4.3 \cdot 10^{-274}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{1}{\ell \cdot h}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(D \cdot \frac{M\_m}{d \cdot 2}\right)}^{2}\right) \cdot \frac{d}{\sqrt{\ell \cdot h}}\\
\end{array}
\end{array}
if l < -4.29999999999999989e-274Initial program 66.0%
Simplified66.0%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt49.7%
neg-mul-149.7%
Simplified49.7%
if -4.29999999999999989e-274 < l Initial program 67.5%
Simplified68.1%
sub-neg68.1%
distribute-rgt-in54.3%
*-un-lft-identity54.3%
sqrt-div54.0%
sqrt-div56.9%
frac-times56.9%
add-sqr-sqrt57.0%
Applied egg-rr72.9%
distribute-rgt1-in83.1%
+-commutative83.1%
associate-*r*83.1%
times-frac82.9%
*-commutative82.9%
associate-/l*83.1%
Simplified83.1%
Taylor expanded in h around 0 71.5%
*-commutative71.5%
Simplified71.5%
Final simplification62.1%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (let* ((t_0 (sqrt (/ 1.0 (* l h))))) (if (<= d 5.5e-285) (* d (- t_0)) (* d t_0))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = sqrt((1.0 / (l * h)));
double tmp;
if (d <= 5.5e-285) {
tmp = d * -t_0;
} else {
tmp = d * t_0;
}
return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((1.0d0 / (l * h)))
if (d <= 5.5d-285) then
tmp = d * -t_0
else
tmp = d * t_0
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = Math.sqrt((1.0 / (l * h)));
double tmp;
if (d <= 5.5e-285) {
tmp = d * -t_0;
} else {
tmp = d * t_0;
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = math.sqrt((1.0 / (l * h))) tmp = 0 if d <= 5.5e-285: tmp = d * -t_0 else: tmp = d * t_0 return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = sqrt(Float64(1.0 / Float64(l * h))) tmp = 0.0 if (d <= 5.5e-285) tmp = Float64(d * Float64(-t_0)); else tmp = Float64(d * t_0); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = sqrt((1.0 / (l * h)));
tmp = 0.0;
if (d <= 5.5e-285)
tmp = d * -t_0;
else
tmp = d * t_0;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, 5.5e-285], N[(d * (-t$95$0)), $MachinePrecision], N[(d * t$95$0), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{if}\;d \leq 5.5 \cdot 10^{-285}:\\
\;\;\;\;d \cdot \left(-t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot t\_0\\
\end{array}
\end{array}
if d < 5.5000000000000001e-285Initial program 66.9%
Simplified66.9%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt49.4%
neg-mul-149.4%
Simplified49.4%
if 5.5000000000000001e-285 < d Initial program 66.8%
Simplified67.4%
Taylor expanded in d around inf 52.8%
Final simplification51.2%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (* d (sqrt (/ 1.0 (* l h)))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
return d * sqrt((1.0 / (l * h)));
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
code = d * sqrt((1.0d0 / (l * h)))
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
return d * Math.sqrt((1.0 / (l * h)));
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): return d * math.sqrt((1.0 / (l * h)))
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) return Float64(d * sqrt(Float64(1.0 / Float64(l * h)))) end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp = code(d, h, l, M_m, D)
tmp = d * sqrt((1.0 / (l * h)));
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
d \cdot \sqrt{\frac{1}{\ell \cdot h}}
\end{array}
Initial program 66.8%
Simplified67.2%
Taylor expanded in d around inf 32.6%
Final simplification32.6%
herbie shell --seed 2024103
(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)))))