
(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 10 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 9e-215)
(* (sqrt (/ d l)) (* t_0 (/ (sqrt d) (sqrt h))))
(*
(fma h (* -0.5 (/ (pow (* 0.5 (* D (/ M_m d))) 2.0) l)) 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 = 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 <= 9e-215) {
tmp = sqrt((d / l)) * (t_0 * (sqrt(d) / sqrt(h)));
} else {
tmp = fma(h, (-0.5 * (pow((0.5 * (D * (M_m / d))), 2.0) / l)), 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(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 <= 9e-215) tmp = Float64(sqrt(Float64(d / l)) * Float64(t_0 * Float64(sqrt(d) / sqrt(h)))); else 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))); 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, 9e-215], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(t$95$0 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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]]]]
\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 9 \cdot 10^{-215}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(t\_0 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right)\\
\mathbf{else}:\\
\;\;\;\;\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}}\\
\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 < 9e-215Initial program 51.6%
Simplified51.5%
sqrt-div77.3%
div-inv77.5%
Applied egg-rr77.5%
associate-*r/77.3%
*-rgt-identity77.3%
Simplified77.3%
if 9e-215 < d Initial program 68.7%
Simplified69.4%
sub-neg69.4%
distribute-rgt-in55.6%
*-un-lft-identity55.6%
sqrt-div56.1%
sqrt-div59.5%
frac-times59.5%
add-sqr-sqrt59.6%
Applied egg-rr76.9%
distribute-rgt1-in89.0%
Simplified90.1%
Final simplification83.7%
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 3.55e-218)
(* t_1 (* t_0 (/ (sqrt d) (sqrt h))))
(*
(fma h (* -0.5 (/ (pow (* 0.5 (* D (/ M_m d))) 2.0) l)) 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 = 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 <= 3.55e-218) {
tmp = t_1 * (t_0 * (sqrt(d) / sqrt(h)));
} else {
tmp = fma(h, (-0.5 * (pow((0.5 * (D * (M_m / d))), 2.0) / l)), 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(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 <= 3.55e-218) tmp = Float64(t_1 * Float64(t_0 * Float64(sqrt(d) / sqrt(h)))); else 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))); 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, 3.55e-218], N[(t$95$1 * N[(t$95$0 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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]]]]]
\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 3.55 \cdot 10^{-218}:\\
\;\;\;\;t\_1 \cdot \left(t\_0 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right)\\
\mathbf{else}:\\
\;\;\;\;\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}}\\
\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 < 3.5499999999999998e-218Initial program 51.6%
Simplified51.5%
sqrt-div77.3%
div-inv77.5%
Applied egg-rr77.5%
associate-*r/77.3%
*-rgt-identity77.3%
Simplified77.3%
if 3.5499999999999998e-218 < d Initial program 68.7%
Simplified69.4%
sub-neg69.4%
distribute-rgt-in55.6%
*-un-lft-identity55.6%
sqrt-div56.1%
sqrt-div59.5%
frac-times59.5%
add-sqr-sqrt59.6%
Applied egg-rr76.9%
distribute-rgt1-in89.0%
Simplified90.1%
Final simplification83.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 -3.6e-128)
(* (- d) (sqrt (/ 1.0 (* l h))))
(if (<= l -4e-311)
(* -0.125 (* (pow (* D M_m) 2.0) (/ (sqrt (/ h (pow l 3.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 tmp;
if (l <= -3.6e-128) {
tmp = -d * sqrt((1.0 / (l * h)));
} else if (l <= -4e-311) {
tmp = -0.125 * (pow((D * M_m), 2.0) * (sqrt((h / pow(l, 3.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) :: tmp
if (l <= (-3.6d-128)) then
tmp = -d * sqrt((1.0d0 / (l * h)))
else if (l <= (-4d-311)) then
tmp = (-0.125d0) * (((d_1 * m_m) ** 2.0d0) * (sqrt((h / (l ** 3.0d0))) / -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 tmp;
if (l <= -3.6e-128) {
tmp = -d * Math.sqrt((1.0 / (l * h)));
} else if (l <= -4e-311) {
tmp = -0.125 * (Math.pow((D * M_m), 2.0) * (Math.sqrt((h / Math.pow(l, 3.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): tmp = 0 if l <= -3.6e-128: tmp = -d * math.sqrt((1.0 / (l * h))) elif l <= -4e-311: tmp = -0.125 * (math.pow((D * M_m), 2.0) * (math.sqrt((h / math.pow(l, 3.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) tmp = 0.0 if (l <= -3.6e-128) tmp = Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(l * h)))); elseif (l <= -4e-311) tmp = Float64(-0.125 * Float64((Float64(D * M_m) ^ 2.0) * Float64(sqrt(Float64(h / (l ^ 3.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)
tmp = 0.0;
if (l <= -3.6e-128)
tmp = -d * sqrt((1.0 / (l * h)));
elseif (l <= -4e-311)
tmp = -0.125 * (((D * M_m) ^ 2.0) * (sqrt((h / (l ^ 3.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_] := If[LessEqual[l, -3.6e-128], N[((-d) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -4e-311], 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], 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}\;\ell \leq -3.6 \cdot 10^{-128}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{elif}\;\ell \leq -4 \cdot 10^{-311}:\\
\;\;\;\;-0.125 \cdot \left({\left(D \cdot M\_m\right)}^{2} \cdot \frac{\sqrt{\frac{h}{{\ell}^{3}}}}{-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 l < -3.60000000000000025e-128Initial program 65.4%
Simplified65.5%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt56.0%
neg-mul-156.0%
Simplified56.0%
if -3.60000000000000025e-128 < l < -3.99999999999979e-311Initial program 71.8%
Simplified71.8%
add-sqr-sqrt20.0%
sqrt-unprod17.1%
*-commutative17.1%
*-commutative17.1%
swap-sqr17.1%
Applied egg-rr17.1%
associate-*r*17.1%
times-frac17.1%
*-commutative17.1%
associate-/l*17.1%
Simplified17.1%
Taylor expanded in h around -inf 0.0%
associate-*l/0.0%
associate-/l*0.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt51.8%
*-commutative51.8%
mul-1-neg51.8%
unpow251.8%
unpow251.8%
swap-sqr55.2%
unpow255.2%
Simplified55.2%
if -3.99999999999979e-311 < l Initial program 66.6%
Simplified67.2%
sub-neg67.2%
distribute-rgt-in55.1%
*-un-lft-identity55.1%
sqrt-div55.5%
sqrt-div58.5%
frac-times58.5%
add-sqr-sqrt58.6%
Applied egg-rr74.9%
distribute-rgt1-in85.5%
+-commutative85.5%
associate-*r*85.5%
times-frac85.2%
*-commutative85.2%
associate-/l*85.5%
Simplified85.5%
Final simplification72.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 -1.12e-126)
(* (- d) (sqrt (/ 1.0 (* l h))))
(if (<= l -4e-311)
(* -0.125 (* (pow (* D M_m) 2.0) (/ (sqrt (/ h (pow l 3.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 tmp;
if (l <= -1.12e-126) {
tmp = -d * sqrt((1.0 / (l * h)));
} else if (l <= -4e-311) {
tmp = -0.125 * (pow((D * M_m), 2.0) * (sqrt((h / pow(l, 3.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) tmp = 0.0 if (l <= -1.12e-126) tmp = Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(l * h)))); elseif (l <= -4e-311) tmp = Float64(-0.125 * Float64((Float64(D * M_m) ^ 2.0) * Float64(sqrt(Float64(h / (l ^ 3.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_] := If[LessEqual[l, -1.12e-126], N[((-d) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -4e-311], 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], 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}
\mathbf{if}\;\ell \leq -1.12 \cdot 10^{-126}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{elif}\;\ell \leq -4 \cdot 10^{-311}:\\
\;\;\;\;-0.125 \cdot \left({\left(D \cdot M\_m\right)}^{2} \cdot \frac{\sqrt{\frac{h}{{\ell}^{3}}}}{-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 l < -1.12e-126Initial program 65.4%
Simplified65.5%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt56.0%
neg-mul-156.0%
Simplified56.0%
if -1.12e-126 < l < -3.99999999999979e-311Initial program 71.8%
Simplified71.8%
add-sqr-sqrt20.0%
sqrt-unprod17.1%
*-commutative17.1%
*-commutative17.1%
swap-sqr17.1%
Applied egg-rr17.1%
associate-*r*17.1%
times-frac17.1%
*-commutative17.1%
associate-/l*17.1%
Simplified17.1%
Taylor expanded in h around -inf 0.0%
associate-*l/0.0%
associate-/l*0.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt51.8%
*-commutative51.8%
mul-1-neg51.8%
unpow251.8%
unpow251.8%
swap-sqr55.2%
unpow255.2%
Simplified55.2%
if -3.99999999999979e-311 < l Initial program 66.6%
Simplified67.2%
sub-neg67.2%
distribute-rgt-in55.1%
*-un-lft-identity55.1%
sqrt-div55.5%
sqrt-div58.5%
frac-times58.5%
add-sqr-sqrt58.6%
Applied egg-rr74.9%
distribute-rgt1-in85.5%
+-commutative85.5%
associate-*r*85.5%
times-frac85.2%
*-commutative85.2%
associate-/l*85.5%
Simplified85.5%
associate-*r/89.0%
+-commutative89.0%
associate-*l*89.0%
fma-define89.0%
associate-*r/88.7%
sqrt-unprod76.6%
*-commutative76.6%
Applied egg-rr76.6%
Final simplification67.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 1.08e-302)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (* 0.5 (* h (/ (pow (* 0.5 (* D (/ M_m d))) 2.0) 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 tmp;
if (h <= 1.08e-302) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (0.5 * (h * (pow((0.5 * (D * (M_m / d))), 2.0) / 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)
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 <= 1.08d-302) then
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0d0 - (0.5d0 * (h * (((0.5d0 * (d_1 * (m_m / d))) ** 2.0d0) / l))))
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 <= 1.08e-302) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * (1.0 - (0.5 * (h * (Math.pow((0.5 * (D * (M_m / d))), 2.0) / l))));
} 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 <= 1.08e-302: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * (1.0 - (0.5 * (h * (math.pow((0.5 * (D * (M_m / d))), 2.0) / l)))) 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 <= 1.08e-302) 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))))); 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 <= 1.08e-302)
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (0.5 * (h * (((0.5 * (D * (M_m / d))) ^ 2.0) / l))));
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, 1.08e-302], 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], 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 1.08 \cdot 10^{-302}:\\
\;\;\;\;\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{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 < 1.07999999999999994e-302Initial program 67.2%
Simplified67.2%
clear-num67.2%
un-div-inv67.6%
frac-times67.6%
*-commutative67.6%
times-frac67.6%
Applied egg-rr67.6%
associate-/r/70.7%
*-commutative70.7%
*-rgt-identity70.7%
associate-/l*70.7%
metadata-eval70.7%
*-commutative70.7%
associate-*r*70.7%
Simplified70.7%
if 1.07999999999999994e-302 < h Initial program 66.6%
Simplified67.2%
sub-neg67.2%
distribute-rgt-in55.5%
*-un-lft-identity55.5%
sqrt-div56.0%
sqrt-div59.0%
frac-times59.0%
add-sqr-sqrt59.2%
Applied egg-rr75.8%
distribute-rgt1-in85.9%
+-commutative85.9%
associate-*r*85.9%
times-frac85.6%
*-commutative85.6%
associate-/l*85.9%
Simplified85.9%
Final simplification78.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
(if (<= h 1.08e-302)
(*
(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 <= 1.08e-302) {
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 <= 1.08d-302) 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 <= 1.08e-302) {
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 <= 1.08e-302: 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 <= 1.08e-302) 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 <= 1.08e-302)
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, 1.08e-302], 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 1.08 \cdot 10^{-302}:\\
\;\;\;\;\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 < 1.07999999999999994e-302Initial program 67.2%
Simplified67.2%
if 1.07999999999999994e-302 < h Initial program 66.6%
Simplified67.2%
sub-neg67.2%
distribute-rgt-in55.5%
*-un-lft-identity55.5%
sqrt-div56.0%
sqrt-div59.0%
frac-times59.0%
add-sqr-sqrt59.2%
Applied egg-rr75.8%
distribute-rgt1-in85.9%
+-commutative85.9%
associate-*r*85.9%
times-frac85.6%
*-commutative85.6%
associate-/l*85.9%
Simplified85.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 -1.12e-128)
(* (- d) (sqrt (/ 1.0 (* l h))))
(if (<= l -4e-311)
(* -0.125 (* (pow (* D M_m) 2.0) (/ (sqrt (/ h (pow l 3.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 tmp;
if (l <= -1.12e-128) {
tmp = -d * sqrt((1.0 / (l * h)));
} else if (l <= -4e-311) {
tmp = -0.125 * (pow((D * M_m), 2.0) * (sqrt((h / pow(l, 3.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) :: tmp
if (l <= (-1.12d-128)) then
tmp = -d * sqrt((1.0d0 / (l * h)))
else if (l <= (-4d-311)) then
tmp = (-0.125d0) * (((d_1 * m_m) ** 2.0d0) * (sqrt((h / (l ** 3.0d0))) / -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 tmp;
if (l <= -1.12e-128) {
tmp = -d * Math.sqrt((1.0 / (l * h)));
} else if (l <= -4e-311) {
tmp = -0.125 * (Math.pow((D * M_m), 2.0) * (Math.sqrt((h / Math.pow(l, 3.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): tmp = 0 if l <= -1.12e-128: tmp = -d * math.sqrt((1.0 / (l * h))) elif l <= -4e-311: tmp = -0.125 * (math.pow((D * M_m), 2.0) * (math.sqrt((h / math.pow(l, 3.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) tmp = 0.0 if (l <= -1.12e-128) tmp = Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(l * h)))); elseif (l <= -4e-311) tmp = Float64(-0.125 * Float64((Float64(D * M_m) ^ 2.0) * Float64(sqrt(Float64(h / (l ^ 3.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)
tmp = 0.0;
if (l <= -1.12e-128)
tmp = -d * sqrt((1.0 / (l * h)));
elseif (l <= -4e-311)
tmp = -0.125 * (((D * M_m) ^ 2.0) * (sqrt((h / (l ^ 3.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_] := If[LessEqual[l, -1.12e-128], N[((-d) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -4e-311], 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], 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 -1.12 \cdot 10^{-128}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{elif}\;\ell \leq -4 \cdot 10^{-311}:\\
\;\;\;\;-0.125 \cdot \left({\left(D \cdot M\_m\right)}^{2} \cdot \frac{\sqrt{\frac{h}{{\ell}^{3}}}}{-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 l < -1.12e-128Initial program 65.4%
Simplified65.5%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt56.0%
neg-mul-156.0%
Simplified56.0%
if -1.12e-128 < l < -3.99999999999979e-311Initial program 71.8%
Simplified71.8%
add-sqr-sqrt20.0%
sqrt-unprod17.1%
*-commutative17.1%
*-commutative17.1%
swap-sqr17.1%
Applied egg-rr17.1%
associate-*r*17.1%
times-frac17.1%
*-commutative17.1%
associate-/l*17.1%
Simplified17.1%
Taylor expanded in h around -inf 0.0%
associate-*l/0.0%
associate-/l*0.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt51.8%
*-commutative51.8%
mul-1-neg51.8%
unpow251.8%
unpow251.8%
swap-sqr55.2%
unpow255.2%
Simplified55.2%
if -3.99999999999979e-311 < l Initial program 66.6%
Simplified67.2%
sub-neg67.2%
distribute-rgt-in55.1%
*-un-lft-identity55.1%
sqrt-div55.5%
sqrt-div58.5%
frac-times58.5%
add-sqr-sqrt58.6%
Applied egg-rr74.9%
distribute-rgt1-in85.5%
+-commutative85.5%
associate-*r*85.5%
times-frac85.2%
*-commutative85.2%
associate-/l*85.5%
Simplified85.5%
Taylor expanded in h around 0 73.5%
*-commutative73.5%
Simplified73.5%
Final simplification65.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
(if (<= d 4e-262)
(* (- 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 (d <= 4e-262) {
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 (d <= 4d-262) 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 (d <= 4e-262) {
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 d <= 4e-262: 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 (d <= 4e-262) tmp = Float64(Float64(-d) * 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 (d <= 4e-262)
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[d, 4e-262], 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}\;d \leq 4 \cdot 10^{-262}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{\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{\ell \cdot h}}\\
\end{array}
\end{array}
if d < 4.00000000000000005e-262Initial program 66.3%
Simplified66.4%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt48.7%
neg-mul-148.7%
Simplified48.7%
if 4.00000000000000005e-262 < d Initial program 67.3%
Simplified68.0%
sub-neg68.0%
distribute-rgt-in54.8%
*-un-lft-identity54.8%
sqrt-div55.2%
sqrt-div58.5%
frac-times58.5%
add-sqr-sqrt58.6%
Applied egg-rr76.4%
distribute-rgt1-in88.0%
+-commutative88.0%
associate-*r*88.0%
times-frac87.7%
*-commutative87.7%
associate-/l*88.0%
Simplified88.0%
Taylor expanded in h around 0 76.4%
*-commutative76.4%
Simplified76.4%
Final simplification62.8%
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 1.45e-174) (* (- 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 <= 1.45e-174) {
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 <= 1.45d-174) 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 <= 1.45e-174) {
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 <= 1.45e-174: 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 <= 1.45e-174) tmp = Float64(Float64(-d) * 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 <= 1.45e-174)
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, 1.45e-174], 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 1.45 \cdot 10^{-174}:\\
\;\;\;\;\left(-d\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;d \cdot t\_0\\
\end{array}
\end{array}
if d < 1.45000000000000005e-174Initial program 63.9%
Simplified63.9%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt45.0%
neg-mul-145.0%
Simplified45.0%
if 1.45000000000000005e-174 < d Initial program 70.6%
Simplified71.5%
Taylor expanded in d around inf 60.1%
Final simplification51.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 (* 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)))))