
(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 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (sqrt (- d))))
(if (<= d -1.65e+143)
(*
(sqrt (/ d l))
(*
(/ t_0 (sqrt (- h)))
(+ 1.0 (* (/ h l) (* (pow (* D_m (/ (/ M 2.0) d)) 2.0) -0.5)))))
(if (<= d -1e-310)
(*
(* (sqrt (/ d h)) (/ t_0 (sqrt (- l))))
(- 1.0 (* 0.5 (/ (* h (pow (* M (* 0.5 (/ D_m d))) 2.0)) l))))
(*
d
(/
(fma (* (/ -0.5 l) (pow (* 0.5 (/ M (/ d D_m))) 2.0)) h 1.0)
(* (sqrt l) (sqrt h))))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = sqrt(-d);
double tmp;
if (d <= -1.65e+143) {
tmp = sqrt((d / l)) * ((t_0 / sqrt(-h)) * (1.0 + ((h / l) * (pow((D_m * ((M / 2.0) / d)), 2.0) * -0.5))));
} else if (d <= -1e-310) {
tmp = (sqrt((d / h)) * (t_0 / sqrt(-l))) * (1.0 - (0.5 * ((h * pow((M * (0.5 * (D_m / d))), 2.0)) / l)));
} else {
tmp = d * (fma(((-0.5 / l) * pow((0.5 * (M / (d / D_m))), 2.0)), h, 1.0) / (sqrt(l) * sqrt(h)));
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = sqrt(Float64(-d)) tmp = 0.0 if (d <= -1.65e+143) tmp = Float64(sqrt(Float64(d / l)) * Float64(Float64(t_0 / sqrt(Float64(-h))) * Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(D_m * Float64(Float64(M / 2.0) / d)) ^ 2.0) * -0.5))))); elseif (d <= -1e-310) tmp = Float64(Float64(sqrt(Float64(d / h)) * Float64(t_0 / sqrt(Float64(-l)))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(M * Float64(0.5 * Float64(D_m / d))) ^ 2.0)) / l)))); else tmp = Float64(d * Float64(fma(Float64(Float64(-0.5 / l) * (Float64(0.5 * Float64(M / Float64(d / D_m))) ^ 2.0)), h, 1.0) / Float64(sqrt(l) * sqrt(h)))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[Sqrt[(-d)], $MachinePrecision]}, If[LessEqual[d, -1.65e+143], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[(t$95$0 / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(D$95$m * N[(N[(M / 2.0), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1e-310], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(t$95$0 / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(M * N[(0.5 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[(N[(N[(-0.5 / l), $MachinePrecision] * N[Power[N[(0.5 * N[(M / N[(d / D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * h + 1.0), $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{-d}\\
\mathbf{if}\;d \leq -1.65 \cdot 10^{+143}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\frac{t\_0}{\sqrt{-h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(D\_m \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5\right)\right)\right)\\
\mathbf{elif}\;d \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \frac{t\_0}{\sqrt{-\ell}}\right) \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(M \cdot \left(0.5 \cdot \frac{D\_m}{d}\right)\right)}^{2}}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(\frac{-0.5}{\ell} \cdot {\left(0.5 \cdot \frac{M}{\frac{d}{D\_m}}\right)}^{2}, h, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if d < -1.65e143Initial program 65.5%
Simplified65.5%
frac-2neg65.5%
sqrt-div88.5%
Applied egg-rr88.5%
if -1.65e143 < d < -9.999999999999969e-311Initial program 62.7%
Simplified62.7%
*-commutative62.7%
unpow262.7%
associate-*r*63.8%
*-commutative63.8%
associate-*l/63.8%
associate-*r/62.7%
*-commutative62.7%
associate-*l/62.7%
associate-*r/62.7%
associate-*r*61.5%
unpow261.5%
associate-*l/64.8%
Applied egg-rr65.2%
frac-2neg65.2%
sqrt-div78.3%
Applied egg-rr78.3%
if -9.999999999999969e-311 < d Initial program 63.3%
Simplified63.2%
*-commutative63.2%
unpow263.2%
associate-*r*64.6%
*-commutative64.6%
associate-*l/64.7%
associate-*r/64.7%
*-commutative64.7%
associate-*l/65.6%
associate-*r/65.6%
associate-*r*63.3%
unpow263.3%
associate-*l/65.1%
Applied egg-rr65.0%
add-sqr-sqrt64.8%
pow264.8%
pow1/264.8%
sqrt-pow164.9%
metadata-eval64.9%
Applied egg-rr64.9%
Applied egg-rr84.2%
unpow184.2%
*-commutative84.2%
associate-*l/85.1%
associate-/l*85.1%
Simplified86.8%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* 0.5 (/ (* h (pow (* M (* 0.5 (/ D_m d))) 2.0)) l)))
(t_1 (sqrt (/ d l))))
(if (<= d -5.5e+139)
(*
t_1
(*
(/ (sqrt (- d)) (sqrt (- h)))
(+ 1.0 (* (/ h l) (* (pow (* D_m (/ (/ M 2.0) d)) 2.0) -0.5)))))
(if (<= d -2.05e-67)
(* (- 1.0 t_0) (* t_1 (sqrt (/ d h))))
(if (<= d -1e-310)
(* (* d (sqrt (/ 1.0 (* l h)))) (+ t_0 -1.0))
(*
d
(/
(fma (* (/ -0.5 l) (pow (* 0.5 (/ M (/ d D_m))) 2.0)) h 1.0)
(* (sqrt l) (sqrt h)))))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = 0.5 * ((h * pow((M * (0.5 * (D_m / d))), 2.0)) / l);
double t_1 = sqrt((d / l));
double tmp;
if (d <= -5.5e+139) {
tmp = t_1 * ((sqrt(-d) / sqrt(-h)) * (1.0 + ((h / l) * (pow((D_m * ((M / 2.0) / d)), 2.0) * -0.5))));
} else if (d <= -2.05e-67) {
tmp = (1.0 - t_0) * (t_1 * sqrt((d / h)));
} else if (d <= -1e-310) {
tmp = (d * sqrt((1.0 / (l * h)))) * (t_0 + -1.0);
} else {
tmp = d * (fma(((-0.5 / l) * pow((0.5 * (M / (d / D_m))), 2.0)), h, 1.0) / (sqrt(l) * sqrt(h)));
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(0.5 * Float64(Float64(h * (Float64(M * Float64(0.5 * Float64(D_m / d))) ^ 2.0)) / l)) t_1 = sqrt(Float64(d / l)) tmp = 0.0 if (d <= -5.5e+139) tmp = Float64(t_1 * Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(D_m * Float64(Float64(M / 2.0) / d)) ^ 2.0) * -0.5))))); elseif (d <= -2.05e-67) tmp = Float64(Float64(1.0 - t_0) * Float64(t_1 * sqrt(Float64(d / h)))); elseif (d <= -1e-310) tmp = Float64(Float64(d * sqrt(Float64(1.0 / Float64(l * h)))) * Float64(t_0 + -1.0)); else tmp = Float64(d * Float64(fma(Float64(Float64(-0.5 / l) * (Float64(0.5 * Float64(M / Float64(d / D_m))) ^ 2.0)), h, 1.0) / Float64(sqrt(l) * sqrt(h)))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(0.5 * N[(N[(h * N[Power[N[(M * N[(0.5 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -5.5e+139], N[(t$95$1 * N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(D$95$m * N[(N[(M / 2.0), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.05e-67], N[(N[(1.0 - t$95$0), $MachinePrecision] * N[(t$95$1 * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1e-310], N[(N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[(N[(N[(-0.5 / l), $MachinePrecision] * N[Power[N[(0.5 * N[(M / N[(d / D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * h + 1.0), $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := 0.5 \cdot \frac{h \cdot {\left(M \cdot \left(0.5 \cdot \frac{D\_m}{d}\right)\right)}^{2}}{\ell}\\
t_1 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;d \leq -5.5 \cdot 10^{+139}:\\
\;\;\;\;t\_1 \cdot \left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(D\_m \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5\right)\right)\right)\\
\mathbf{elif}\;d \leq -2.05 \cdot 10^{-67}:\\
\;\;\;\;\left(1 - t\_0\right) \cdot \left(t\_1 \cdot \sqrt{\frac{d}{h}}\right)\\
\mathbf{elif}\;d \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\left(d \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \left(t\_0 + -1\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(\frac{-0.5}{\ell} \cdot {\left(0.5 \cdot \frac{M}{\frac{d}{D\_m}}\right)}^{2}, h, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if d < -5.4999999999999996e139Initial program 65.5%
Simplified65.5%
frac-2neg65.5%
sqrt-div88.5%
Applied egg-rr88.5%
if -5.4999999999999996e139 < d < -2.0499999999999999e-67Initial program 71.3%
Simplified71.3%
*-commutative71.3%
unpow271.3%
associate-*r*73.8%
*-commutative73.8%
associate-*l/73.8%
associate-*r/71.4%
*-commutative71.4%
associate-*l/71.4%
associate-*r/71.3%
associate-*r*68.8%
unpow268.8%
associate-*l/78.6%
Applied egg-rr79.5%
if -2.0499999999999999e-67 < d < -9.999999999999969e-311Initial program 56.3%
Simplified56.3%
*-commutative56.3%
unpow256.3%
associate-*r*56.4%
*-commutative56.4%
associate-*l/56.4%
associate-*r/56.2%
*-commutative56.2%
associate-*l/56.3%
associate-*r/56.3%
associate-*r*56.2%
unpow256.2%
associate-*l/54.5%
Applied egg-rr54.7%
add-sqr-sqrt54.5%
pow254.5%
pow1/254.5%
sqrt-pow154.6%
metadata-eval54.6%
Applied egg-rr54.6%
Taylor expanded in h around -inf 0.0%
*-commutative0.0%
*-commutative0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt69.5%
neg-mul-169.5%
Simplified69.5%
if -9.999999999999969e-311 < d Initial program 63.3%
Simplified63.2%
*-commutative63.2%
unpow263.2%
associate-*r*64.6%
*-commutative64.6%
associate-*l/64.7%
associate-*r/64.7%
*-commutative64.7%
associate-*l/65.6%
associate-*r/65.6%
associate-*r*63.3%
unpow263.3%
associate-*l/65.1%
Applied egg-rr65.0%
add-sqr-sqrt64.8%
pow264.8%
pow1/264.8%
sqrt-pow164.9%
metadata-eval64.9%
Applied egg-rr64.9%
Applied egg-rr84.2%
unpow184.2%
*-commutative84.2%
associate-*l/85.1%
associate-/l*85.1%
Simplified86.8%
Final simplification82.3%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* 0.5 (/ (* h (pow (* M (* 0.5 (/ D_m d))) 2.0)) l))))
(if (<= l -2.5e+138)
(* (- d) (sqrt (/ (/ 1.0 h) l)))
(if (<= l -4e-229)
(* (- 1.0 t_0) (/ 1.0 (/ (sqrt (/ h d)) (sqrt (/ d l)))))
(if (<= l -4e-310)
(* (* d (pow (* l h) -0.5)) (+ t_0 -1.0))
(*
d
(/
(fma (* (/ -0.5 l) (pow (* 0.5 (/ M (/ d D_m))) 2.0)) h 1.0)
(* (sqrt l) (sqrt h)))))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = 0.5 * ((h * pow((M * (0.5 * (D_m / d))), 2.0)) / l);
double tmp;
if (l <= -2.5e+138) {
tmp = -d * sqrt(((1.0 / h) / l));
} else if (l <= -4e-229) {
tmp = (1.0 - t_0) * (1.0 / (sqrt((h / d)) / sqrt((d / l))));
} else if (l <= -4e-310) {
tmp = (d * pow((l * h), -0.5)) * (t_0 + -1.0);
} else {
tmp = d * (fma(((-0.5 / l) * pow((0.5 * (M / (d / D_m))), 2.0)), h, 1.0) / (sqrt(l) * sqrt(h)));
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(0.5 * Float64(Float64(h * (Float64(M * Float64(0.5 * Float64(D_m / d))) ^ 2.0)) / l)) tmp = 0.0 if (l <= -2.5e+138) tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l))); elseif (l <= -4e-229) tmp = Float64(Float64(1.0 - t_0) * Float64(1.0 / Float64(sqrt(Float64(h / d)) / sqrt(Float64(d / l))))); elseif (l <= -4e-310) tmp = Float64(Float64(d * (Float64(l * h) ^ -0.5)) * Float64(t_0 + -1.0)); else tmp = Float64(d * Float64(fma(Float64(Float64(-0.5 / l) * (Float64(0.5 * Float64(M / Float64(d / D_m))) ^ 2.0)), h, 1.0) / Float64(sqrt(l) * sqrt(h)))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(0.5 * N[(N[(h * N[Power[N[(M * N[(0.5 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2.5e+138], N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -4e-229], N[(N[(1.0 - t$95$0), $MachinePrecision] * N[(1.0 / N[(N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -4e-310], N[(N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[(N[(N[(-0.5 / l), $MachinePrecision] * N[Power[N[(0.5 * N[(M / N[(d / D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * h + 1.0), $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := 0.5 \cdot \frac{h \cdot {\left(M \cdot \left(0.5 \cdot \frac{D\_m}{d}\right)\right)}^{2}}{\ell}\\
\mathbf{if}\;\ell \leq -2.5 \cdot 10^{+138}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\
\mathbf{elif}\;\ell \leq -4 \cdot 10^{-229}:\\
\;\;\;\;\left(1 - t\_0\right) \cdot \frac{1}{\frac{\sqrt{\frac{h}{d}}}{\sqrt{\frac{d}{\ell}}}}\\
\mathbf{elif}\;\ell \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\left(d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right) \cdot \left(t\_0 + -1\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(\frac{-0.5}{\ell} \cdot {\left(0.5 \cdot \frac{M}{\frac{d}{D\_m}}\right)}^{2}, h, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < -2.50000000000000008e138Initial program 45.3%
Simplified45.3%
add-sqr-sqrt45.3%
pow245.3%
sqrt-prod45.3%
sqrt-pow149.2%
metadata-eval49.2%
pow149.2%
div-inv49.2%
metadata-eval49.2%
associate-*l*49.2%
Applied egg-rr49.2%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
associate-/r*0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt63.6%
neg-mul-163.6%
Simplified63.6%
if -2.50000000000000008e138 < l < -4.00000000000000028e-229Initial program 80.2%
Simplified80.2%
*-commutative80.2%
unpow280.2%
associate-*r*80.2%
*-commutative80.2%
associate-*l/80.2%
associate-*r/78.8%
*-commutative78.8%
associate-*l/78.8%
associate-*r/78.7%
associate-*r*78.7%
unpow278.7%
associate-*l/83.1%
Applied egg-rr83.6%
add-sqr-sqrt83.2%
pow283.2%
pow1/283.2%
sqrt-pow183.3%
metadata-eval83.3%
Applied egg-rr83.3%
pow-pow83.6%
metadata-eval83.6%
pow1/283.6%
*-commutative83.6%
clear-num83.6%
sqrt-div85.3%
metadata-eval85.3%
div-inv85.2%
clear-num85.3%
Applied egg-rr85.3%
if -4.00000000000000028e-229 < l < -3.999999999999988e-310Initial program 52.0%
Simplified52.0%
*-commutative52.0%
unpow252.0%
associate-*r*52.0%
*-commutative52.0%
associate-*l/52.0%
associate-*r/52.0%
*-commutative52.0%
associate-*l/57.6%
associate-*r/57.6%
associate-*r*52.0%
unpow252.0%
associate-*l/52.6%
Applied egg-rr52.6%
add-sqr-sqrt52.6%
pow252.6%
pow1/252.6%
sqrt-pow152.6%
metadata-eval52.6%
Applied egg-rr52.6%
pow-pow52.6%
metadata-eval52.6%
pow1/252.6%
*-commutative52.6%
clear-num52.6%
sqrt-div52.5%
metadata-eval52.5%
div-inv52.6%
clear-num52.6%
Applied egg-rr52.6%
Taylor expanded in d around -inf 78.9%
associate-*r*78.9%
rem-exp-log77.5%
exp-neg77.5%
unpow1/277.5%
exp-prod77.5%
distribute-lft-neg-out77.5%
distribute-rgt-neg-in77.5%
metadata-eval77.5%
exp-to-pow79.0%
neg-mul-179.0%
distribute-lft-neg-in79.0%
distribute-rgt-neg-in79.0%
Simplified79.0%
if -3.999999999999988e-310 < l Initial program 63.3%
Simplified63.2%
*-commutative63.2%
unpow263.2%
associate-*r*64.6%
*-commutative64.6%
associate-*l/64.7%
associate-*r/64.7%
*-commutative64.7%
associate-*l/65.6%
associate-*r/65.6%
associate-*r*63.3%
unpow263.3%
associate-*l/65.1%
Applied egg-rr65.0%
add-sqr-sqrt64.8%
pow264.8%
pow1/264.8%
sqrt-pow164.9%
metadata-eval64.9%
Applied egg-rr64.9%
Applied egg-rr84.2%
unpow184.2%
*-commutative84.2%
associate-*l/85.1%
associate-/l*85.1%
Simplified86.8%
Final simplification81.2%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* 0.5 (/ (* h (pow (* M (* 0.5 (/ D_m d))) 2.0)) l)))
(t_1 (- 1.0 t_0)))
(if (<= l -2.55e+138)
(* (- d) (sqrt (/ (/ 1.0 h) l)))
(if (<= l -7.2e-230)
(* t_1 (/ 1.0 (/ (sqrt (/ h d)) (sqrt (/ d l)))))
(if (<= l -4e-310)
(* (* d (pow (* l h) -0.5)) (+ t_0 -1.0))
(* t_1 (/ d (* (sqrt l) (sqrt h)))))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = 0.5 * ((h * pow((M * (0.5 * (D_m / d))), 2.0)) / l);
double t_1 = 1.0 - t_0;
double tmp;
if (l <= -2.55e+138) {
tmp = -d * sqrt(((1.0 / h) / l));
} else if (l <= -7.2e-230) {
tmp = t_1 * (1.0 / (sqrt((h / d)) / sqrt((d / l))));
} else if (l <= -4e-310) {
tmp = (d * pow((l * h), -0.5)) * (t_0 + -1.0);
} else {
tmp = t_1 * (d / (sqrt(l) * sqrt(h)));
}
return tmp;
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 0.5d0 * ((h * ((m * (0.5d0 * (d_m / d))) ** 2.0d0)) / l)
t_1 = 1.0d0 - t_0
if (l <= (-2.55d+138)) then
tmp = -d * sqrt(((1.0d0 / h) / l))
else if (l <= (-7.2d-230)) then
tmp = t_1 * (1.0d0 / (sqrt((h / d)) / sqrt((d / l))))
else if (l <= (-4d-310)) then
tmp = (d * ((l * h) ** (-0.5d0))) * (t_0 + (-1.0d0))
else
tmp = t_1 * (d / (sqrt(l) * sqrt(h)))
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = 0.5 * ((h * Math.pow((M * (0.5 * (D_m / d))), 2.0)) / l);
double t_1 = 1.0 - t_0;
double tmp;
if (l <= -2.55e+138) {
tmp = -d * Math.sqrt(((1.0 / h) / l));
} else if (l <= -7.2e-230) {
tmp = t_1 * (1.0 / (Math.sqrt((h / d)) / Math.sqrt((d / l))));
} else if (l <= -4e-310) {
tmp = (d * Math.pow((l * h), -0.5)) * (t_0 + -1.0);
} else {
tmp = t_1 * (d / (Math.sqrt(l) * Math.sqrt(h)));
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = 0.5 * ((h * math.pow((M * (0.5 * (D_m / d))), 2.0)) / l) t_1 = 1.0 - t_0 tmp = 0 if l <= -2.55e+138: tmp = -d * math.sqrt(((1.0 / h) / l)) elif l <= -7.2e-230: tmp = t_1 * (1.0 / (math.sqrt((h / d)) / math.sqrt((d / l)))) elif l <= -4e-310: tmp = (d * math.pow((l * h), -0.5)) * (t_0 + -1.0) else: tmp = t_1 * (d / (math.sqrt(l) * math.sqrt(h))) return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(0.5 * Float64(Float64(h * (Float64(M * Float64(0.5 * Float64(D_m / d))) ^ 2.0)) / l)) t_1 = Float64(1.0 - t_0) tmp = 0.0 if (l <= -2.55e+138) tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l))); elseif (l <= -7.2e-230) tmp = Float64(t_1 * Float64(1.0 / Float64(sqrt(Float64(h / d)) / sqrt(Float64(d / l))))); elseif (l <= -4e-310) tmp = Float64(Float64(d * (Float64(l * h) ^ -0.5)) * Float64(t_0 + -1.0)); else tmp = Float64(t_1 * Float64(d / Float64(sqrt(l) * sqrt(h)))); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = 0.5 * ((h * ((M * (0.5 * (D_m / d))) ^ 2.0)) / l);
t_1 = 1.0 - t_0;
tmp = 0.0;
if (l <= -2.55e+138)
tmp = -d * sqrt(((1.0 / h) / l));
elseif (l <= -7.2e-230)
tmp = t_1 * (1.0 / (sqrt((h / d)) / sqrt((d / l))));
elseif (l <= -4e-310)
tmp = (d * ((l * h) ^ -0.5)) * (t_0 + -1.0);
else
tmp = t_1 * (d / (sqrt(l) * sqrt(h)));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(0.5 * N[(N[(h * N[Power[N[(M * N[(0.5 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - t$95$0), $MachinePrecision]}, If[LessEqual[l, -2.55e+138], N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -7.2e-230], N[(t$95$1 * N[(1.0 / N[(N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -4e-310], N[(N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := 0.5 \cdot \frac{h \cdot {\left(M \cdot \left(0.5 \cdot \frac{D\_m}{d}\right)\right)}^{2}}{\ell}\\
t_1 := 1 - t\_0\\
\mathbf{if}\;\ell \leq -2.55 \cdot 10^{+138}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\
\mathbf{elif}\;\ell \leq -7.2 \cdot 10^{-230}:\\
\;\;\;\;t\_1 \cdot \frac{1}{\frac{\sqrt{\frac{h}{d}}}{\sqrt{\frac{d}{\ell}}}}\\
\mathbf{elif}\;\ell \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\left(d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right) \cdot \left(t\_0 + -1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < -2.5499999999999999e138Initial program 45.3%
Simplified45.3%
add-sqr-sqrt45.3%
pow245.3%
sqrt-prod45.3%
sqrt-pow149.2%
metadata-eval49.2%
pow149.2%
div-inv49.2%
metadata-eval49.2%
associate-*l*49.2%
Applied egg-rr49.2%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
associate-/r*0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt63.6%
neg-mul-163.6%
Simplified63.6%
if -2.5499999999999999e138 < l < -7.1999999999999997e-230Initial program 80.2%
Simplified80.2%
*-commutative80.2%
unpow280.2%
associate-*r*80.2%
*-commutative80.2%
associate-*l/80.2%
associate-*r/78.8%
*-commutative78.8%
associate-*l/78.8%
associate-*r/78.7%
associate-*r*78.7%
unpow278.7%
associate-*l/83.1%
Applied egg-rr83.6%
add-sqr-sqrt83.2%
pow283.2%
pow1/283.2%
sqrt-pow183.3%
metadata-eval83.3%
Applied egg-rr83.3%
pow-pow83.6%
metadata-eval83.6%
pow1/283.6%
*-commutative83.6%
clear-num83.6%
sqrt-div85.3%
metadata-eval85.3%
div-inv85.2%
clear-num85.3%
Applied egg-rr85.3%
if -7.1999999999999997e-230 < l < -3.999999999999988e-310Initial program 52.0%
Simplified52.0%
*-commutative52.0%
unpow252.0%
associate-*r*52.0%
*-commutative52.0%
associate-*l/52.0%
associate-*r/52.0%
*-commutative52.0%
associate-*l/57.6%
associate-*r/57.6%
associate-*r*52.0%
unpow252.0%
associate-*l/52.6%
Applied egg-rr52.6%
add-sqr-sqrt52.6%
pow252.6%
pow1/252.6%
sqrt-pow152.6%
metadata-eval52.6%
Applied egg-rr52.6%
pow-pow52.6%
metadata-eval52.6%
pow1/252.6%
*-commutative52.6%
clear-num52.6%
sqrt-div52.5%
metadata-eval52.5%
div-inv52.6%
clear-num52.6%
Applied egg-rr52.6%
Taylor expanded in d around -inf 78.9%
associate-*r*78.9%
rem-exp-log77.5%
exp-neg77.5%
unpow1/277.5%
exp-prod77.5%
distribute-lft-neg-out77.5%
distribute-rgt-neg-in77.5%
metadata-eval77.5%
exp-to-pow79.0%
neg-mul-179.0%
distribute-lft-neg-in79.0%
distribute-rgt-neg-in79.0%
Simplified79.0%
if -3.999999999999988e-310 < l Initial program 63.3%
Simplified63.2%
*-commutative63.2%
unpow263.2%
associate-*r*64.6%
*-commutative64.6%
associate-*l/64.7%
associate-*r/64.7%
*-commutative64.7%
associate-*l/65.6%
associate-*r/65.6%
associate-*r*63.3%
unpow263.3%
associate-*l/65.1%
Applied egg-rr65.0%
add-sqr-sqrt64.8%
pow264.8%
pow1/264.8%
sqrt-pow164.9%
metadata-eval64.9%
Applied egg-rr64.9%
sqrt-div75.5%
pow-pow75.6%
metadata-eval75.6%
pow1/275.6%
sqrt-div84.1%
frac-times84.1%
add-sqr-sqrt84.2%
Applied egg-rr84.2%
*-commutative84.2%
Simplified84.2%
Final simplification80.0%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* 0.5 (/ (* h (pow (* M (* 0.5 (/ D_m d))) 2.0)) l))))
(if (<= h -5e-310)
(* (* d (pow (* l h) -0.5)) (+ t_0 -1.0))
(* (- 1.0 t_0) (/ d (* (sqrt l) (sqrt h)))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = 0.5 * ((h * pow((M * (0.5 * (D_m / d))), 2.0)) / l);
double tmp;
if (h <= -5e-310) {
tmp = (d * pow((l * h), -0.5)) * (t_0 + -1.0);
} else {
tmp = (1.0 - t_0) * (d / (sqrt(l) * sqrt(h)));
}
return tmp;
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = 0.5d0 * ((h * ((m * (0.5d0 * (d_m / d))) ** 2.0d0)) / l)
if (h <= (-5d-310)) then
tmp = (d * ((l * h) ** (-0.5d0))) * (t_0 + (-1.0d0))
else
tmp = (1.0d0 - t_0) * (d / (sqrt(l) * sqrt(h)))
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = 0.5 * ((h * Math.pow((M * (0.5 * (D_m / d))), 2.0)) / l);
double tmp;
if (h <= -5e-310) {
tmp = (d * Math.pow((l * h), -0.5)) * (t_0 + -1.0);
} else {
tmp = (1.0 - t_0) * (d / (Math.sqrt(l) * Math.sqrt(h)));
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = 0.5 * ((h * math.pow((M * (0.5 * (D_m / d))), 2.0)) / l) tmp = 0 if h <= -5e-310: tmp = (d * math.pow((l * h), -0.5)) * (t_0 + -1.0) else: tmp = (1.0 - t_0) * (d / (math.sqrt(l) * math.sqrt(h))) return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(0.5 * Float64(Float64(h * (Float64(M * Float64(0.5 * Float64(D_m / d))) ^ 2.0)) / l)) tmp = 0.0 if (h <= -5e-310) tmp = Float64(Float64(d * (Float64(l * h) ^ -0.5)) * Float64(t_0 + -1.0)); else tmp = Float64(Float64(1.0 - t_0) * Float64(d / Float64(sqrt(l) * sqrt(h)))); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = 0.5 * ((h * ((M * (0.5 * (D_m / d))) ^ 2.0)) / l);
tmp = 0.0;
if (h <= -5e-310)
tmp = (d * ((l * h) ^ -0.5)) * (t_0 + -1.0);
else
tmp = (1.0 - t_0) * (d / (sqrt(l) * sqrt(h)));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(0.5 * N[(N[(h * N[Power[N[(M * N[(0.5 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -5e-310], N[(N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - t$95$0), $MachinePrecision] * N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := 0.5 \cdot \frac{h \cdot {\left(M \cdot \left(0.5 \cdot \frac{D\_m}{d}\right)\right)}^{2}}{\ell}\\
\mathbf{if}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right) \cdot \left(t\_0 + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - t\_0\right) \cdot \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if h < -4.999999999999985e-310Initial program 63.6%
Simplified63.6%
*-commutative63.6%
unpow263.6%
associate-*r*65.1%
*-commutative65.1%
associate-*l/64.4%
associate-*r/64.3%
*-commutative64.3%
associate-*l/64.3%
associate-*r/65.0%
associate-*r*62.8%
unpow262.8%
associate-*l/64.4%
Applied egg-rr64.7%
add-sqr-sqrt64.5%
pow264.5%
pow1/264.5%
sqrt-pow164.6%
metadata-eval64.6%
Applied egg-rr64.6%
pow-pow64.7%
metadata-eval64.7%
pow1/264.7%
*-commutative64.7%
clear-num64.7%
sqrt-div65.6%
metadata-eval65.6%
div-inv65.6%
clear-num65.7%
Applied egg-rr65.7%
Taylor expanded in d around -inf 71.3%
associate-*r*71.3%
rem-exp-log68.9%
exp-neg68.9%
unpow1/268.9%
exp-prod68.9%
distribute-lft-neg-out68.9%
distribute-rgt-neg-in68.9%
metadata-eval68.9%
exp-to-pow71.3%
neg-mul-171.3%
distribute-lft-neg-in71.3%
distribute-rgt-neg-in71.3%
Simplified71.3%
if -4.999999999999985e-310 < h Initial program 63.3%
Simplified63.2%
*-commutative63.2%
unpow263.2%
associate-*r*64.6%
*-commutative64.6%
associate-*l/64.7%
associate-*r/64.7%
*-commutative64.7%
associate-*l/65.6%
associate-*r/65.6%
associate-*r*63.3%
unpow263.3%
associate-*l/65.1%
Applied egg-rr65.0%
add-sqr-sqrt64.8%
pow264.8%
pow1/264.8%
sqrt-pow164.9%
metadata-eval64.9%
Applied egg-rr64.9%
sqrt-div75.5%
pow-pow75.6%
metadata-eval75.6%
pow1/275.6%
sqrt-div84.1%
frac-times84.1%
add-sqr-sqrt84.2%
Applied egg-rr84.2%
*-commutative84.2%
Simplified84.2%
Final simplification77.3%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* d (pow (* l h) -0.5)))
(t_1 (- 1.0 (* 0.5 (/ (* h (pow (* M (* 0.5 (/ D_m d))) 2.0)) l)))))
(if (<= h -4e+133)
(* t_1 (sqrt (* (/ d l) (/ d h))))
(if (<= h -5e-310)
(* t_0 (+ (* 0.5 (* (/ h l) (pow (* (/ M 2.0) (/ D_m d)) 2.0))) -1.0))
(* t_1 t_0)))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = d * pow((l * h), -0.5);
double t_1 = 1.0 - (0.5 * ((h * pow((M * (0.5 * (D_m / d))), 2.0)) / l));
double tmp;
if (h <= -4e+133) {
tmp = t_1 * sqrt(((d / l) * (d / h)));
} else if (h <= -5e-310) {
tmp = t_0 * ((0.5 * ((h / l) * pow(((M / 2.0) * (D_m / d)), 2.0))) + -1.0);
} else {
tmp = t_1 * t_0;
}
return tmp;
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = d * ((l * h) ** (-0.5d0))
t_1 = 1.0d0 - (0.5d0 * ((h * ((m * (0.5d0 * (d_m / d))) ** 2.0d0)) / l))
if (h <= (-4d+133)) then
tmp = t_1 * sqrt(((d / l) * (d / h)))
else if (h <= (-5d-310)) then
tmp = t_0 * ((0.5d0 * ((h / l) * (((m / 2.0d0) * (d_m / d)) ** 2.0d0))) + (-1.0d0))
else
tmp = t_1 * t_0
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = d * Math.pow((l * h), -0.5);
double t_1 = 1.0 - (0.5 * ((h * Math.pow((M * (0.5 * (D_m / d))), 2.0)) / l));
double tmp;
if (h <= -4e+133) {
tmp = t_1 * Math.sqrt(((d / l) * (d / h)));
} else if (h <= -5e-310) {
tmp = t_0 * ((0.5 * ((h / l) * Math.pow(((M / 2.0) * (D_m / d)), 2.0))) + -1.0);
} else {
tmp = t_1 * t_0;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = d * math.pow((l * h), -0.5) t_1 = 1.0 - (0.5 * ((h * math.pow((M * (0.5 * (D_m / d))), 2.0)) / l)) tmp = 0 if h <= -4e+133: tmp = t_1 * math.sqrt(((d / l) * (d / h))) elif h <= -5e-310: tmp = t_0 * ((0.5 * ((h / l) * math.pow(((M / 2.0) * (D_m / d)), 2.0))) + -1.0) else: tmp = t_1 * t_0 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(d * (Float64(l * h) ^ -0.5)) t_1 = Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(M * Float64(0.5 * Float64(D_m / d))) ^ 2.0)) / l))) tmp = 0.0 if (h <= -4e+133) tmp = Float64(t_1 * sqrt(Float64(Float64(d / l) * Float64(d / h)))); elseif (h <= -5e-310) tmp = Float64(t_0 * Float64(Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(M / 2.0) * Float64(D_m / d)) ^ 2.0))) + -1.0)); else tmp = Float64(t_1 * t_0); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = d * ((l * h) ^ -0.5);
t_1 = 1.0 - (0.5 * ((h * ((M * (0.5 * (D_m / d))) ^ 2.0)) / l));
tmp = 0.0;
if (h <= -4e+133)
tmp = t_1 * sqrt(((d / l) * (d / h)));
elseif (h <= -5e-310)
tmp = t_0 * ((0.5 * ((h / l) * (((M / 2.0) * (D_m / d)) ^ 2.0))) + -1.0);
else
tmp = t_1 * t_0;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(M * N[(0.5 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -4e+133], N[(t$95$1 * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -5e-310], N[(t$95$0 * N[(N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(M / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
t_1 := 1 - 0.5 \cdot \frac{h \cdot {\left(M \cdot \left(0.5 \cdot \frac{D\_m}{d}\right)\right)}^{2}}{\ell}\\
\mathbf{if}\;h \leq -4 \cdot 10^{+133}:\\
\;\;\;\;t\_1 \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{elif}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;t\_0 \cdot \left(0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M}{2} \cdot \frac{D\_m}{d}\right)}^{2}\right) + -1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot t\_0\\
\end{array}
\end{array}
if h < -4.0000000000000001e133Initial program 56.8%
Simplified56.8%
*-commutative56.8%
unpow256.8%
associate-*r*56.9%
*-commutative56.9%
associate-*l/56.9%
associate-*r/54.3%
*-commutative54.3%
associate-*l/54.3%
associate-*r/54.3%
associate-*r*54.3%
unpow254.3%
associate-*l/59.6%
Applied egg-rr60.4%
add-sqr-sqrt60.3%
pow260.3%
pow1/260.3%
sqrt-pow160.3%
metadata-eval60.3%
Applied egg-rr60.3%
pow1/260.3%
pow-pow60.4%
metadata-eval60.4%
pow-prod-down58.0%
Applied egg-rr58.0%
unpow1/258.0%
*-commutative58.0%
Simplified58.0%
if -4.0000000000000001e133 < h < -4.999999999999985e-310Initial program 66.3%
Simplified66.3%
clear-num66.3%
sqrt-div67.6%
metadata-eval67.6%
Applied egg-rr67.6%
Taylor expanded in d around -inf 75.4%
mul-1-neg75.4%
*-commutative75.4%
inv-pow75.4%
sqrt-pow175.5%
metadata-eval75.5%
Applied egg-rr75.5%
if -4.999999999999985e-310 < h Initial program 63.3%
Simplified63.2%
*-commutative63.2%
unpow263.2%
associate-*r*64.6%
*-commutative64.6%
associate-*l/64.7%
associate-*r/64.7%
*-commutative64.7%
associate-*l/65.6%
associate-*r/65.6%
associate-*r*63.3%
unpow263.3%
associate-*l/65.1%
Applied egg-rr65.0%
add-sqr-sqrt64.8%
pow264.8%
pow1/264.8%
sqrt-pow164.9%
metadata-eval64.9%
Applied egg-rr64.9%
pow-pow65.0%
metadata-eval65.0%
pow1/265.0%
*-commutative65.0%
clear-num64.9%
sqrt-div64.9%
metadata-eval64.9%
div-inv64.9%
clear-num64.9%
Applied egg-rr64.9%
Taylor expanded in h around 0 78.5%
rem-exp-log76.2%
exp-neg76.2%
unpow1/276.2%
exp-prod76.2%
distribute-lft-neg-out76.2%
distribute-rgt-neg-in76.2%
metadata-eval76.2%
exp-to-pow78.5%
Simplified78.5%
Final simplification74.2%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(if (<= l -1.8e-141)
(* (- d) (sqrt (/ (/ 1.0 h) l)))
(if (<= l -2.8e-289)
(* (sqrt (/ d l)) (sqrt (/ d h)))
(*
(- 1.0 (* 0.5 (/ (* h (pow (* M (* 0.5 (/ D_m d))) 2.0)) l)))
(* d (pow (* l h) -0.5))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (l <= -1.8e-141) {
tmp = -d * sqrt(((1.0 / h) / l));
} else if (l <= -2.8e-289) {
tmp = sqrt((d / l)) * sqrt((d / h));
} else {
tmp = (1.0 - (0.5 * ((h * pow((M * (0.5 * (D_m / d))), 2.0)) / l))) * (d * pow((l * h), -0.5));
}
return tmp;
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: tmp
if (l <= (-1.8d-141)) then
tmp = -d * sqrt(((1.0d0 / h) / l))
else if (l <= (-2.8d-289)) then
tmp = sqrt((d / l)) * sqrt((d / h))
else
tmp = (1.0d0 - (0.5d0 * ((h * ((m * (0.5d0 * (d_m / d))) ** 2.0d0)) / l))) * (d * ((l * h) ** (-0.5d0)))
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (l <= -1.8e-141) {
tmp = -d * Math.sqrt(((1.0 / h) / l));
} else if (l <= -2.8e-289) {
tmp = Math.sqrt((d / l)) * Math.sqrt((d / h));
} else {
tmp = (1.0 - (0.5 * ((h * Math.pow((M * (0.5 * (D_m / d))), 2.0)) / l))) * (d * Math.pow((l * h), -0.5));
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): tmp = 0 if l <= -1.8e-141: tmp = -d * math.sqrt(((1.0 / h) / l)) elif l <= -2.8e-289: tmp = math.sqrt((d / l)) * math.sqrt((d / h)) else: tmp = (1.0 - (0.5 * ((h * math.pow((M * (0.5 * (D_m / d))), 2.0)) / l))) * (d * math.pow((l * h), -0.5)) return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) tmp = 0.0 if (l <= -1.8e-141) tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l))); elseif (l <= -2.8e-289) tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))); else tmp = Float64(Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(M * Float64(0.5 * Float64(D_m / d))) ^ 2.0)) / l))) * Float64(d * (Float64(l * h) ^ -0.5))); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
tmp = 0.0;
if (l <= -1.8e-141)
tmp = -d * sqrt(((1.0 / h) / l));
elseif (l <= -2.8e-289)
tmp = sqrt((d / l)) * sqrt((d / h));
else
tmp = (1.0 - (0.5 * ((h * ((M * (0.5 * (D_m / d))) ^ 2.0)) / l))) * (d * ((l * h) ^ -0.5));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[l, -1.8e-141], N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -2.8e-289], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(M * N[(0.5 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.8 \cdot 10^{-141}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\
\mathbf{elif}\;\ell \leq -2.8 \cdot 10^{-289}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 - 0.5 \cdot \frac{h \cdot {\left(M \cdot \left(0.5 \cdot \frac{D\_m}{d}\right)\right)}^{2}}{\ell}\right) \cdot \left(d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right)\\
\end{array}
\end{array}
if l < -1.80000000000000007e-141Initial program 59.2%
Simplified59.2%
add-sqr-sqrt59.2%
pow259.2%
sqrt-prod59.2%
sqrt-pow161.2%
metadata-eval61.2%
pow161.2%
div-inv61.2%
metadata-eval61.2%
associate-*l*61.2%
Applied egg-rr61.2%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
associate-/r*0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt51.3%
neg-mul-151.3%
Simplified51.3%
if -1.80000000000000007e-141 < l < -2.79999999999999985e-289Initial program 82.6%
Simplified82.6%
add-sqr-sqrt82.5%
pow282.5%
sqrt-prod82.5%
sqrt-pow182.5%
metadata-eval82.5%
pow182.5%
div-inv82.5%
metadata-eval82.5%
associate-*l*82.5%
Applied egg-rr82.5%
Taylor expanded in M around 0 52.4%
if -2.79999999999999985e-289 < l Initial program 61.8%
Simplified61.7%
*-commutative61.7%
unpow261.7%
associate-*r*63.1%
*-commutative63.1%
associate-*l/63.1%
associate-*r/63.1%
*-commutative63.1%
associate-*l/64.8%
associate-*r/64.8%
associate-*r*61.8%
unpow261.8%
associate-*l/63.5%
Applied egg-rr63.5%
add-sqr-sqrt63.3%
pow263.3%
pow1/263.3%
sqrt-pow163.4%
metadata-eval63.4%
Applied egg-rr63.4%
pow-pow63.5%
metadata-eval63.5%
pow1/263.5%
*-commutative63.5%
clear-num63.4%
sqrt-div63.4%
metadata-eval63.4%
div-inv63.4%
clear-num63.4%
Applied egg-rr63.4%
Taylor expanded in h around 0 77.3%
rem-exp-log75.1%
exp-neg75.1%
unpow1/275.1%
exp-prod75.1%
distribute-lft-neg-out75.1%
distribute-rgt-neg-in75.1%
metadata-eval75.1%
exp-to-pow77.4%
Simplified77.4%
Final simplification63.8%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* 0.5 (/ (* h (pow (* M (* 0.5 (/ D_m d))) 2.0)) l)))
(t_1 (* d (pow (* l h) -0.5))))
(if (<= h -5e-310) (* t_1 (+ t_0 -1.0)) (* (- 1.0 t_0) t_1))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = 0.5 * ((h * pow((M * (0.5 * (D_m / d))), 2.0)) / l);
double t_1 = d * pow((l * h), -0.5);
double tmp;
if (h <= -5e-310) {
tmp = t_1 * (t_0 + -1.0);
} else {
tmp = (1.0 - t_0) * t_1;
}
return tmp;
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 0.5d0 * ((h * ((m * (0.5d0 * (d_m / d))) ** 2.0d0)) / l)
t_1 = d * ((l * h) ** (-0.5d0))
if (h <= (-5d-310)) then
tmp = t_1 * (t_0 + (-1.0d0))
else
tmp = (1.0d0 - t_0) * t_1
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = 0.5 * ((h * Math.pow((M * (0.5 * (D_m / d))), 2.0)) / l);
double t_1 = d * Math.pow((l * h), -0.5);
double tmp;
if (h <= -5e-310) {
tmp = t_1 * (t_0 + -1.0);
} else {
tmp = (1.0 - t_0) * t_1;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = 0.5 * ((h * math.pow((M * (0.5 * (D_m / d))), 2.0)) / l) t_1 = d * math.pow((l * h), -0.5) tmp = 0 if h <= -5e-310: tmp = t_1 * (t_0 + -1.0) else: tmp = (1.0 - t_0) * t_1 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(0.5 * Float64(Float64(h * (Float64(M * Float64(0.5 * Float64(D_m / d))) ^ 2.0)) / l)) t_1 = Float64(d * (Float64(l * h) ^ -0.5)) tmp = 0.0 if (h <= -5e-310) tmp = Float64(t_1 * Float64(t_0 + -1.0)); else tmp = Float64(Float64(1.0 - t_0) * t_1); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = 0.5 * ((h * ((M * (0.5 * (D_m / d))) ^ 2.0)) / l);
t_1 = d * ((l * h) ^ -0.5);
tmp = 0.0;
if (h <= -5e-310)
tmp = t_1 * (t_0 + -1.0);
else
tmp = (1.0 - t_0) * t_1;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(0.5 * N[(N[(h * N[Power[N[(M * N[(0.5 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -5e-310], N[(t$95$1 * N[(t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := 0.5 \cdot \frac{h \cdot {\left(M \cdot \left(0.5 \cdot \frac{D\_m}{d}\right)\right)}^{2}}{\ell}\\
t_1 := d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{if}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;t\_1 \cdot \left(t\_0 + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - t\_0\right) \cdot t\_1\\
\end{array}
\end{array}
if h < -4.999999999999985e-310Initial program 63.6%
Simplified63.6%
*-commutative63.6%
unpow263.6%
associate-*r*65.1%
*-commutative65.1%
associate-*l/64.4%
associate-*r/64.3%
*-commutative64.3%
associate-*l/64.3%
associate-*r/65.0%
associate-*r*62.8%
unpow262.8%
associate-*l/64.4%
Applied egg-rr64.7%
add-sqr-sqrt64.5%
pow264.5%
pow1/264.5%
sqrt-pow164.6%
metadata-eval64.6%
Applied egg-rr64.6%
pow-pow64.7%
metadata-eval64.7%
pow1/264.7%
*-commutative64.7%
clear-num64.7%
sqrt-div65.6%
metadata-eval65.6%
div-inv65.6%
clear-num65.7%
Applied egg-rr65.7%
Taylor expanded in d around -inf 71.3%
associate-*r*71.3%
rem-exp-log68.9%
exp-neg68.9%
unpow1/268.9%
exp-prod68.9%
distribute-lft-neg-out68.9%
distribute-rgt-neg-in68.9%
metadata-eval68.9%
exp-to-pow71.3%
neg-mul-171.3%
distribute-lft-neg-in71.3%
distribute-rgt-neg-in71.3%
Simplified71.3%
if -4.999999999999985e-310 < h Initial program 63.3%
Simplified63.2%
*-commutative63.2%
unpow263.2%
associate-*r*64.6%
*-commutative64.6%
associate-*l/64.7%
associate-*r/64.7%
*-commutative64.7%
associate-*l/65.6%
associate-*r/65.6%
associate-*r*63.3%
unpow263.3%
associate-*l/65.1%
Applied egg-rr65.0%
add-sqr-sqrt64.8%
pow264.8%
pow1/264.8%
sqrt-pow164.9%
metadata-eval64.9%
Applied egg-rr64.9%
pow-pow65.0%
metadata-eval65.0%
pow1/265.0%
*-commutative65.0%
clear-num64.9%
sqrt-div64.9%
metadata-eval64.9%
div-inv64.9%
clear-num64.9%
Applied egg-rr64.9%
Taylor expanded in h around 0 78.5%
rem-exp-log76.2%
exp-neg76.2%
unpow1/276.2%
exp-prod76.2%
distribute-lft-neg-out76.2%
distribute-rgt-neg-in76.2%
metadata-eval76.2%
exp-to-pow78.5%
Simplified78.5%
Final simplification74.6%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* d (pow (* l h) -0.5))))
(if (<= h -5e-310)
(* t_0 (+ (* 0.5 (* (/ h l) (pow (* (/ M 2.0) (/ D_m d)) 2.0))) -1.0))
(* (- 1.0 (* 0.5 (/ (* h (pow (* M (* 0.5 (/ D_m d))) 2.0)) l))) t_0))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = d * pow((l * h), -0.5);
double tmp;
if (h <= -5e-310) {
tmp = t_0 * ((0.5 * ((h / l) * pow(((M / 2.0) * (D_m / d)), 2.0))) + -1.0);
} else {
tmp = (1.0 - (0.5 * ((h * pow((M * (0.5 * (D_m / d))), 2.0)) / l))) * t_0;
}
return tmp;
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = d * ((l * h) ** (-0.5d0))
if (h <= (-5d-310)) then
tmp = t_0 * ((0.5d0 * ((h / l) * (((m / 2.0d0) * (d_m / d)) ** 2.0d0))) + (-1.0d0))
else
tmp = (1.0d0 - (0.5d0 * ((h * ((m * (0.5d0 * (d_m / d))) ** 2.0d0)) / l))) * t_0
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = d * Math.pow((l * h), -0.5);
double tmp;
if (h <= -5e-310) {
tmp = t_0 * ((0.5 * ((h / l) * Math.pow(((M / 2.0) * (D_m / d)), 2.0))) + -1.0);
} else {
tmp = (1.0 - (0.5 * ((h * Math.pow((M * (0.5 * (D_m / d))), 2.0)) / l))) * t_0;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = d * math.pow((l * h), -0.5) tmp = 0 if h <= -5e-310: tmp = t_0 * ((0.5 * ((h / l) * math.pow(((M / 2.0) * (D_m / d)), 2.0))) + -1.0) else: tmp = (1.0 - (0.5 * ((h * math.pow((M * (0.5 * (D_m / d))), 2.0)) / l))) * t_0 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(d * (Float64(l * h) ^ -0.5)) tmp = 0.0 if (h <= -5e-310) tmp = Float64(t_0 * Float64(Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(M / 2.0) * Float64(D_m / d)) ^ 2.0))) + -1.0)); else tmp = Float64(Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(M * Float64(0.5 * Float64(D_m / d))) ^ 2.0)) / l))) * t_0); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = d * ((l * h) ^ -0.5);
tmp = 0.0;
if (h <= -5e-310)
tmp = t_0 * ((0.5 * ((h / l) * (((M / 2.0) * (D_m / d)) ^ 2.0))) + -1.0);
else
tmp = (1.0 - (0.5 * ((h * ((M * (0.5 * (D_m / d))) ^ 2.0)) / l))) * t_0;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -5e-310], N[(t$95$0 * N[(N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(M / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(M * N[(0.5 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{if}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;t\_0 \cdot \left(0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M}{2} \cdot \frac{D\_m}{d}\right)}^{2}\right) + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - 0.5 \cdot \frac{h \cdot {\left(M \cdot \left(0.5 \cdot \frac{D\_m}{d}\right)\right)}^{2}}{\ell}\right) \cdot t\_0\\
\end{array}
\end{array}
if h < -4.999999999999985e-310Initial program 63.6%
Simplified63.6%
clear-num63.6%
sqrt-div64.5%
metadata-eval64.5%
Applied egg-rr64.5%
Taylor expanded in d around -inf 66.8%
mul-1-neg66.8%
*-commutative66.8%
inv-pow66.8%
sqrt-pow166.8%
metadata-eval66.8%
Applied egg-rr66.8%
if -4.999999999999985e-310 < h Initial program 63.3%
Simplified63.2%
*-commutative63.2%
unpow263.2%
associate-*r*64.6%
*-commutative64.6%
associate-*l/64.7%
associate-*r/64.7%
*-commutative64.7%
associate-*l/65.6%
associate-*r/65.6%
associate-*r*63.3%
unpow263.3%
associate-*l/65.1%
Applied egg-rr65.0%
add-sqr-sqrt64.8%
pow264.8%
pow1/264.8%
sqrt-pow164.9%
metadata-eval64.9%
Applied egg-rr64.9%
pow-pow65.0%
metadata-eval65.0%
pow1/265.0%
*-commutative65.0%
clear-num64.9%
sqrt-div64.9%
metadata-eval64.9%
div-inv64.9%
clear-num64.9%
Applied egg-rr64.9%
Taylor expanded in h around 0 78.5%
rem-exp-log76.2%
exp-neg76.2%
unpow1/276.2%
exp-prod76.2%
distribute-lft-neg-out76.2%
distribute-rgt-neg-in76.2%
metadata-eval76.2%
exp-to-pow78.5%
Simplified78.5%
Final simplification72.2%
D_m = (fabs.f64 D) NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M D_m) :precision binary64 (if (<= d -2.1e-183) (* (- d) (sqrt (/ (/ 1.0 h) l))) (* d (pow (* l h) -0.5))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (d <= -2.1e-183) {
tmp = -d * sqrt(((1.0 / h) / l));
} else {
tmp = d * pow((l * h), -0.5);
}
return tmp;
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: tmp
if (d <= (-2.1d-183)) then
tmp = -d * sqrt(((1.0d0 / h) / l))
else
tmp = d * ((l * h) ** (-0.5d0))
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (d <= -2.1e-183) {
tmp = -d * Math.sqrt(((1.0 / h) / l));
} else {
tmp = d * Math.pow((l * h), -0.5);
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): tmp = 0 if d <= -2.1e-183: tmp = -d * math.sqrt(((1.0 / h) / l)) else: tmp = d * math.pow((l * h), -0.5) return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) tmp = 0.0 if (d <= -2.1e-183) tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l))); else tmp = Float64(d * (Float64(l * h) ^ -0.5)); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
tmp = 0.0;
if (d <= -2.1e-183)
tmp = -d * sqrt(((1.0 / h) / l));
else
tmp = d * ((l * h) ^ -0.5);
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[d, -2.1e-183], N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.1 \cdot 10^{-183}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;d \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\end{array}
\end{array}
if d < -2.1000000000000002e-183Initial program 65.2%
Simplified65.2%
add-sqr-sqrt65.2%
pow265.2%
sqrt-prod65.1%
sqrt-pow166.9%
metadata-eval66.9%
pow166.9%
div-inv66.9%
metadata-eval66.9%
associate-*l*66.9%
Applied egg-rr66.9%
Taylor expanded in l around -inf 0.0%
*-commutative0.0%
associate-/r*0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt53.7%
neg-mul-153.7%
Simplified53.7%
if -2.1000000000000002e-183 < d Initial program 62.0%
Simplified61.9%
add-sqr-sqrt61.9%
pow261.9%
sqrt-prod61.9%
sqrt-pow163.2%
metadata-eval63.2%
pow163.2%
div-inv63.2%
metadata-eval63.2%
associate-*l*63.2%
Applied egg-rr63.2%
Taylor expanded in d around inf 40.2%
associate-/r*40.2%
Simplified40.2%
Taylor expanded in h around 0 40.2%
rem-exp-log38.5%
exp-neg38.5%
unpow1/238.5%
exp-prod38.5%
distribute-lft-neg-out38.5%
distribute-rgt-neg-in38.5%
metadata-eval38.5%
exp-to-pow40.2%
Simplified40.2%
Final simplification46.3%
D_m = (fabs.f64 D) NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M D_m) :precision binary64 (* d (pow (* l h) -0.5)))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
return d * pow((l * h), -0.5);
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
code = d * ((l * h) ** (-0.5d0))
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
return d * Math.pow((l * h), -0.5);
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): return d * math.pow((l * h), -0.5)
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) return Float64(d * (Float64(l * h) ^ -0.5)) end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp = code(d, h, l, M, D_m)
tmp = d * ((l * h) ^ -0.5);
end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
d \cdot {\left(\ell \cdot h\right)}^{-0.5}
\end{array}
Initial program 63.4%
Simplified63.4%
add-sqr-sqrt63.4%
pow263.4%
sqrt-prod63.4%
sqrt-pow164.9%
metadata-eval64.9%
pow164.9%
div-inv64.9%
metadata-eval64.9%
associate-*l*64.9%
Applied egg-rr64.9%
Taylor expanded in d around inf 24.6%
associate-/r*24.6%
Simplified24.6%
Taylor expanded in h around 0 24.6%
rem-exp-log23.6%
exp-neg23.6%
unpow1/223.6%
exp-prod23.6%
distribute-lft-neg-out23.6%
distribute-rgt-neg-in23.6%
metadata-eval23.6%
exp-to-pow24.6%
Simplified24.6%
Final simplification24.6%
herbie shell --seed 2024111
(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)))))