
(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 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (/ (cbrt h) l)))
(if (<= d -2e-310)
(*
(sqrt (/ d l))
(*
(/ (sqrt (- d)) (sqrt (- h)))
(+
1.0
(+
1.0
(+ (* h (/ (* (pow (* M (* 0.5 (/ D d))) 2.0) -0.5) l)) -1.0)))))
(if (<= d 8.5e-180)
(* (* (fabs t_0) (sqrt t_0)) (* -0.125 (/ (pow (* M D) 2.0) d)))
(*
(+ 1.0 (* h (/ (* -0.5 (pow (/ (* D (* M 0.5)) d) 2.0)) l)))
(/ d (* (sqrt h) (sqrt l))))))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = cbrt(h) / l;
double tmp;
if (d <= -2e-310) {
tmp = sqrt((d / l)) * ((sqrt(-d) / sqrt(-h)) * (1.0 + (1.0 + ((h * ((pow((M * (0.5 * (D / d))), 2.0) * -0.5) / l)) + -1.0))));
} else if (d <= 8.5e-180) {
tmp = (fabs(t_0) * sqrt(t_0)) * (-0.125 * (pow((M * D), 2.0) / d));
} else {
tmp = (1.0 + (h * ((-0.5 * pow(((D * (M * 0.5)) / d), 2.0)) / l))) * (d / (sqrt(h) * sqrt(l)));
}
return tmp;
}
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
double t_0 = Math.cbrt(h) / l;
double tmp;
if (d <= -2e-310) {
tmp = Math.sqrt((d / l)) * ((Math.sqrt(-d) / Math.sqrt(-h)) * (1.0 + (1.0 + ((h * ((Math.pow((M * (0.5 * (D / d))), 2.0) * -0.5) / l)) + -1.0))));
} else if (d <= 8.5e-180) {
tmp = (Math.abs(t_0) * Math.sqrt(t_0)) * (-0.125 * (Math.pow((M * D), 2.0) / d));
} else {
tmp = (1.0 + (h * ((-0.5 * Math.pow(((D * (M * 0.5)) / d), 2.0)) / l))) * (d / (Math.sqrt(h) * Math.sqrt(l)));
}
return tmp;
}
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) t_0 = Float64(cbrt(h) / l) tmp = 0.0 if (d <= -2e-310) tmp = Float64(sqrt(Float64(d / l)) * Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(1.0 + Float64(1.0 + Float64(Float64(h * Float64(Float64((Float64(M * Float64(0.5 * Float64(D / d))) ^ 2.0) * -0.5) / l)) + -1.0))))); elseif (d <= 8.5e-180) tmp = Float64(Float64(abs(t_0) * sqrt(t_0)) * Float64(-0.125 * Float64((Float64(M * D) ^ 2.0) / d))); else tmp = Float64(Float64(1.0 + Float64(h * Float64(Float64(-0.5 * (Float64(Float64(D * Float64(M * 0.5)) / d) ^ 2.0)) / l))) * Float64(d / Float64(sqrt(h) * sqrt(l)))); end return tmp end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[Power[h, 1/3], $MachinePrecision] / l), $MachinePrecision]}, If[LessEqual[d, -2e-310], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(1.0 + N[(N[(h * N[(N[(N[Power[N[(M * N[(0.5 * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 8.5e-180], N[(N[(N[Abs[t$95$0], $MachinePrecision] * N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision] * N[(-0.125 * N[(N[Power[N[(M * D), $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(h * N[(N[(-0.5 * N[Power[N[(N[(D * N[(M * 0.5), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
t_0 := \frac{\sqrt[3]{h}}{\ell}\\
\mathbf{if}\;d \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(1 + \left(1 + \left(h \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot -0.5}{\ell} + -1\right)\right)\right)\right)\\
\mathbf{elif}\;d \leq 8.5 \cdot 10^{-180}:\\
\;\;\;\;\left(\left|t\_0\right| \cdot \sqrt{t\_0}\right) \cdot \left(-0.125 \cdot \frac{{\left(M \cdot D\right)}^{2}}{d}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 + h \cdot \frac{-0.5 \cdot {\left(\frac{D \cdot \left(M \cdot 0.5\right)}{d}\right)}^{2}}{\ell}\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if d < -1.999999999999994e-310Initial program 64.1%
Simplified63.3%
Applied egg-rr63.3%
associate--l+63.3%
associate-*l/64.1%
associate-/l*65.1%
Simplified65.1%
frac-2neg65.1%
sqrt-div76.0%
Applied egg-rr76.0%
if -1.999999999999994e-310 < d < 8.4999999999999993e-180Initial program 41.8%
Applied egg-rr58.8%
distribute-rgt1-in58.8%
+-commutative58.8%
associate-*l/62.0%
associate-/l*62.1%
Simplified62.1%
Taylor expanded in M around inf 49.3%
*-commutative49.3%
*-commutative49.3%
associate-*l*49.3%
unpow249.3%
unpow249.3%
swap-sqr62.3%
unpow262.3%
*-commutative62.3%
Simplified62.3%
pow1/262.3%
add-cube-cbrt62.2%
unpow-prod-down62.3%
pow262.3%
cbrt-div62.2%
unpow362.2%
add-cbrt-cube62.1%
cbrt-div62.3%
unpow362.3%
add-cbrt-cube75.0%
Applied egg-rr75.0%
unpow1/275.0%
unpow275.0%
rem-sqrt-square78.1%
unpow1/278.1%
Simplified78.1%
if 8.4999999999999993e-180 < d Initial program 77.5%
Applied egg-rr76.6%
distribute-rgt1-in87.6%
+-commutative87.6%
associate-*l/92.7%
associate-/l*93.5%
Simplified93.5%
associate-*r*93.5%
metadata-eval93.5%
div-inv93.5%
associate-*r/94.7%
div-inv94.7%
metadata-eval94.7%
Applied egg-rr94.7%
Final simplification83.6%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(if (<= l -5e-311)
(*
(sqrt (/ d l))
(*
(/ (sqrt (- d)) (sqrt (- h)))
(+
1.0
(+ 1.0 (+ (* h (/ (* (pow (* M (* 0.5 (/ D d))) 2.0) -0.5) l)) -1.0)))))
(/
(* d (fma h (* (pow (/ D (/ (* d 2.0) M)) 2.0) (/ -0.5 l)) 1.0))
(* (sqrt h) (sqrt l)))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= -5e-311) {
tmp = sqrt((d / l)) * ((sqrt(-d) / sqrt(-h)) * (1.0 + (1.0 + ((h * ((pow((M * (0.5 * (D / d))), 2.0) * -0.5) / l)) + -1.0))));
} else {
tmp = (d * fma(h, (pow((D / ((d * 2.0) / M)), 2.0) * (-0.5 / l)), 1.0)) / (sqrt(h) * sqrt(l));
}
return tmp;
}
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) tmp = 0.0 if (l <= -5e-311) tmp = Float64(sqrt(Float64(d / l)) * Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(1.0 + Float64(1.0 + Float64(Float64(h * Float64(Float64((Float64(M * Float64(0.5 * Float64(D / d))) ^ 2.0) * -0.5) / l)) + -1.0))))); else tmp = Float64(Float64(d * fma(h, Float64((Float64(D / Float64(Float64(d * 2.0) / M)) ^ 2.0) * Float64(-0.5 / l)), 1.0)) / Float64(sqrt(h) * sqrt(l))); end return tmp end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[l, -5e-311], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(1.0 + N[(N[(h * N[(N[(N[Power[N[(M * N[(0.5 * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d * N[(h * N[(N[Power[N[(D / N[(N[(d * 2.0), $MachinePrecision] / M), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5 \cdot 10^{-311}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(1 + \left(1 + \left(h \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2} \cdot -0.5}{\ell} + -1\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d \cdot \mathsf{fma}\left(h, {\left(\frac{D}{\frac{d \cdot 2}{M}}\right)}^{2} \cdot \frac{-0.5}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if l < -5.00000000000023e-311Initial program 64.1%
Simplified63.3%
Applied egg-rr63.3%
associate--l+63.3%
associate-*l/64.1%
associate-/l*65.1%
Simplified65.1%
frac-2neg65.1%
sqrt-div76.0%
Applied egg-rr76.0%
if -5.00000000000023e-311 < l Initial program 69.1%
Applied egg-rr72.4%
distribute-rgt1-in80.8%
+-commutative80.8%
associate-*r/81.1%
*-commutative81.1%
Simplified86.5%
Final simplification81.4%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(if (<= h -5e-310)
(*
(* (sqrt (/ d h)) (/ (sqrt (- d)) (sqrt (- l))))
(- 1.0 (* 0.5 (* h (/ (pow (* M (* 0.5 (/ D d))) 2.0) l)))))
(/
(* d (fma h (* (pow (/ D (/ (* d 2.0) M)) 2.0) (/ -0.5 l)) 1.0))
(* (sqrt h) (sqrt l)))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (h <= -5e-310) {
tmp = (sqrt((d / h)) * (sqrt(-d) / sqrt(-l))) * (1.0 - (0.5 * (h * (pow((M * (0.5 * (D / d))), 2.0) / l))));
} else {
tmp = (d * fma(h, (pow((D / ((d * 2.0) / M)), 2.0) * (-0.5 / l)), 1.0)) / (sqrt(h) * sqrt(l));
}
return tmp;
}
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) tmp = 0.0 if (h <= -5e-310) tmp = Float64(Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(-d)) / sqrt(Float64(-l)))) * Float64(1.0 - Float64(0.5 * Float64(h * Float64((Float64(M * Float64(0.5 * Float64(D / d))) ^ 2.0) / l))))); else tmp = Float64(Float64(d * fma(h, Float64((Float64(D / Float64(Float64(d * 2.0) / M)) ^ 2.0) * Float64(-0.5 / l)), 1.0)) / Float64(sqrt(h) * sqrt(l))); end return tmp end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[h, -5e-310], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(h * N[(N[Power[N[(M * N[(0.5 * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d * N[(h * N[(N[Power[N[(D / N[(N[(d * 2.0), $MachinePrecision] / M), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\right) \cdot \left(1 - 0.5 \cdot \left(h \cdot \frac{{\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}}{\ell}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d \cdot \mathsf{fma}\left(h, {\left(\frac{D}{\frac{d \cdot 2}{M}}\right)}^{2} \cdot \frac{-0.5}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if h < -4.999999999999985e-310Initial program 64.1%
Simplified63.3%
clear-num63.3%
un-div-inv64.1%
frac-times64.9%
associate-/l*64.1%
*-un-lft-identity64.1%
times-frac64.1%
metadata-eval64.1%
Applied egg-rr64.1%
associate-/r/65.0%
Simplified65.0%
frac-2neg65.0%
sqrt-div70.2%
Applied egg-rr70.2%
if -4.999999999999985e-310 < h Initial program 69.1%
Applied egg-rr72.4%
distribute-rgt1-in80.8%
+-commutative80.8%
associate-*r/81.1%
*-commutative81.1%
Simplified86.5%
Final simplification78.5%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(if (<= h -5e-310)
(*
(* (sqrt (/ d l)) (/ (sqrt (- d)) (sqrt (- h))))
(- 1.0 (* 0.5 (* (/ h l) (pow (* (/ D d) (/ M 2.0)) 2.0)))))
(/
(* d (fma h (* (pow (/ D (/ (* d 2.0) M)) 2.0) (/ -0.5 l)) 1.0))
(* (sqrt h) (sqrt l)))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (h <= -5e-310) {
tmp = (sqrt((d / l)) * (sqrt(-d) / sqrt(-h))) * (1.0 - (0.5 * ((h / l) * pow(((D / d) * (M / 2.0)), 2.0))));
} else {
tmp = (d * fma(h, (pow((D / ((d * 2.0) / M)), 2.0) * (-0.5 / l)), 1.0)) / (sqrt(h) * sqrt(l));
}
return tmp;
}
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) tmp = 0.0 if (h <= -5e-310) tmp = Float64(Float64(sqrt(Float64(d / l)) * Float64(sqrt(Float64(-d)) / sqrt(Float64(-h)))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M / 2.0)) ^ 2.0))))); else tmp = Float64(Float64(d * fma(h, Float64((Float64(D / Float64(Float64(d * 2.0) / M)) ^ 2.0) * Float64(-0.5 / l)), 1.0)) / Float64(sqrt(h) * sqrt(l))); end return tmp end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[h, -5e-310], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d * N[(h * N[(N[Power[N[(D / N[(N[(d * 2.0), $MachinePrecision] / M), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \frac{\sqrt{-d}}{\sqrt{-h}}\right) \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d \cdot \mathsf{fma}\left(h, {\left(\frac{D}{\frac{d \cdot 2}{M}}\right)}^{2} \cdot \frac{-0.5}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if h < -4.999999999999985e-310Initial program 64.1%
Simplified63.3%
frac-2neg65.1%
sqrt-div76.0%
Applied egg-rr73.5%
if -4.999999999999985e-310 < h Initial program 69.1%
Applied egg-rr72.4%
distribute-rgt1-in80.8%
+-commutative80.8%
associate-*r/81.1%
*-commutative81.1%
Simplified86.5%
Final simplification80.1%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(if (<= l -5e-311)
(*
(* (sqrt (/ d l)) (/ (sqrt (- d)) (sqrt (- h))))
(- 1.0 (* 0.5 (* (pow (/ (* M (* 0.5 D)) d) 2.0) (/ h l)))))
(/
(* d (fma h (* (pow (/ D (/ (* d 2.0) M)) 2.0) (/ -0.5 l)) 1.0))
(* (sqrt h) (sqrt l)))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= -5e-311) {
tmp = (sqrt((d / l)) * (sqrt(-d) / sqrt(-h))) * (1.0 - (0.5 * (pow(((M * (0.5 * D)) / d), 2.0) * (h / l))));
} else {
tmp = (d * fma(h, (pow((D / ((d * 2.0) / M)), 2.0) * (-0.5 / l)), 1.0)) / (sqrt(h) * sqrt(l));
}
return tmp;
}
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) tmp = 0.0 if (l <= -5e-311) tmp = Float64(Float64(sqrt(Float64(d / l)) * Float64(sqrt(Float64(-d)) / sqrt(Float64(-h)))) * Float64(1.0 - Float64(0.5 * Float64((Float64(Float64(M * Float64(0.5 * D)) / d) ^ 2.0) * Float64(h / l))))); else tmp = Float64(Float64(d * fma(h, Float64((Float64(D / Float64(Float64(d * 2.0) / M)) ^ 2.0) * Float64(-0.5 / l)), 1.0)) / Float64(sqrt(h) * sqrt(l))); end return tmp end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[l, -5e-311], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[Power[N[(N[(M * N[(0.5 * D), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d * N[(h * N[(N[Power[N[(D / N[(N[(d * 2.0), $MachinePrecision] / M), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5 \cdot 10^{-311}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \frac{\sqrt{-d}}{\sqrt{-h}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M \cdot \left(0.5 \cdot D\right)}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d \cdot \mathsf{fma}\left(h, {\left(\frac{D}{\frac{d \cdot 2}{M}}\right)}^{2} \cdot \frac{-0.5}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if l < -5.00000000000023e-311Initial program 64.1%
Simplified63.3%
associate-*r/64.1%
div-inv64.1%
associate-*l*64.1%
metadata-eval64.1%
Applied egg-rr64.1%
frac-2neg65.1%
sqrt-div76.0%
Applied egg-rr74.3%
if -5.00000000000023e-311 < l Initial program 69.1%
Applied egg-rr72.4%
distribute-rgt1-in80.8%
+-commutative80.8%
associate-*r/81.1%
*-commutative81.1%
Simplified86.5%
Final simplification80.5%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(if (<= l -5.8e-292)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (* 0.5 (pow (* (* M (* 0.5 (/ D d))) (sqrt (/ h l))) 2.0))))
(/
(* d (fma h (* (pow (/ D (/ (* d 2.0) M)) 2.0) (/ -0.5 l)) 1.0))
(* (sqrt h) (sqrt l)))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= -5.8e-292) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (0.5 * pow(((M * (0.5 * (D / d))) * sqrt((h / l))), 2.0)));
} else {
tmp = (d * fma(h, (pow((D / ((d * 2.0) / M)), 2.0) * (-0.5 / l)), 1.0)) / (sqrt(h) * sqrt(l));
}
return tmp;
}
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) tmp = 0.0 if (l <= -5.8e-292) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(0.5 * (Float64(Float64(M * Float64(0.5 * Float64(D / d))) * sqrt(Float64(h / l))) ^ 2.0)))); else tmp = Float64(Float64(d * fma(h, Float64((Float64(D / Float64(Float64(d * 2.0) / M)) ^ 2.0) * Float64(-0.5 / l)), 1.0)) / Float64(sqrt(h) * sqrt(l))); end return tmp end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[l, -5.8e-292], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[Power[N[(N[(M * N[(0.5 * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d * N[(h * N[(N[Power[N[(D / N[(N[(d * 2.0), $MachinePrecision] / M), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5.8 \cdot 10^{-292}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d \cdot \mathsf{fma}\left(h, {\left(\frac{D}{\frac{d \cdot 2}{M}}\right)}^{2} \cdot \frac{-0.5}{\ell}, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if l < -5.79999999999999985e-292Initial program 64.7%
Simplified63.8%
add-sqr-sqrt63.8%
pow263.8%
sqrt-prod63.9%
sqrt-pow168.4%
metadata-eval68.4%
pow168.4%
div-inv68.4%
associate-*l*68.4%
metadata-eval68.4%
Applied egg-rr68.4%
if -5.79999999999999985e-292 < l Initial program 68.6%
Applied egg-rr71.8%
distribute-rgt1-in80.2%
+-commutative80.2%
associate-*r/80.5%
*-commutative80.5%
Simplified85.8%
Final simplification77.4%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (* (pow (/ D (/ (* d 2.0) M)) 2.0) (/ -0.5 l))))
(if (<= d -2e-310)
(* (sqrt (/ d l)) (* (sqrt (/ d h)) (+ 1.0 (* h t_0))))
(/ (* d (fma h t_0 1.0)) (* (sqrt h) (sqrt l))))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = pow((D / ((d * 2.0) / M)), 2.0) * (-0.5 / l);
double tmp;
if (d <= -2e-310) {
tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0 + (h * t_0)));
} else {
tmp = (d * fma(h, t_0, 1.0)) / (sqrt(h) * sqrt(l));
}
return tmp;
}
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) t_0 = Float64((Float64(D / Float64(Float64(d * 2.0) / M)) ^ 2.0) * Float64(-0.5 / l)) tmp = 0.0 if (d <= -2e-310) tmp = Float64(sqrt(Float64(d / l)) * Float64(sqrt(Float64(d / h)) * Float64(1.0 + Float64(h * t_0)))); else tmp = Float64(Float64(d * fma(h, t_0, 1.0)) / Float64(sqrt(h) * sqrt(l))); end return tmp end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[Power[N[(D / N[(N[(d * 2.0), $MachinePrecision] / M), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2e-310], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(h * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d * N[(h * t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{D}{\frac{d \cdot 2}{M}}\right)}^{2} \cdot \frac{-0.5}{\ell}\\
\mathbf{if}\;d \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + h \cdot t\_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d \cdot \mathsf{fma}\left(h, t\_0, 1\right)}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if d < -1.999999999999994e-310Initial program 64.1%
Simplified63.3%
clear-num63.3%
associate-*l/64.1%
*-un-lft-identity64.1%
frac-times64.9%
associate-/l*64.1%
*-un-lft-identity64.1%
times-frac64.1%
metadata-eval64.1%
Applied egg-rr64.1%
associate-/r/65.1%
*-commutative65.1%
associate-/l*65.1%
associate-*r*65.1%
*-commutative65.1%
metadata-eval65.1%
associate-/r/65.0%
times-frac65.1%
*-commutative65.1%
*-rgt-identity65.1%
associate-*l/65.1%
Simplified65.1%
if -1.999999999999994e-310 < d Initial program 69.1%
Applied egg-rr72.4%
distribute-rgt1-in80.8%
+-commutative80.8%
associate-*r/81.1%
*-commutative81.1%
Simplified86.5%
Final simplification76.1%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(if (<= l -5e-311)
(* d (sqrt (/ 1.0 (* l h))))
(if (<= l 3.8e+199)
(*
(fma h (* (/ -0.5 l) (pow (* (/ D d) (* M 0.5)) 2.0)) 1.0)
(/ d (sqrt (* l h))))
(* (sqrt (/ d h)) (/ 1.0 (/ (sqrt l) (sqrt d)))))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= -5e-311) {
tmp = d * sqrt((1.0 / (l * h)));
} else if (l <= 3.8e+199) {
tmp = fma(h, ((-0.5 / l) * pow(((D / d) * (M * 0.5)), 2.0)), 1.0) * (d / sqrt((l * h)));
} else {
tmp = sqrt((d / h)) * (1.0 / (sqrt(l) / sqrt(d)));
}
return tmp;
}
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) tmp = 0.0 if (l <= -5e-311) tmp = Float64(d * sqrt(Float64(1.0 / Float64(l * h)))); elseif (l <= 3.8e+199) tmp = Float64(fma(h, Float64(Float64(-0.5 / l) * (Float64(Float64(D / d) * Float64(M * 0.5)) ^ 2.0)), 1.0) * Float64(d / sqrt(Float64(l * h)))); else tmp = Float64(sqrt(Float64(d / h)) * Float64(1.0 / Float64(sqrt(l) / sqrt(d)))); end return tmp end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[l, -5e-311], N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 3.8e+199], N[(N[(h * N[(N[(-0.5 / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[(N[Sqrt[l], $MachinePrecision] / N[Sqrt[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5 \cdot 10^{-311}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{elif}\;\ell \leq 3.8 \cdot 10^{+199}:\\
\;\;\;\;\mathsf{fma}\left(h, \frac{-0.5}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}, 1\right) \cdot \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \frac{1}{\frac{\sqrt{\ell}}{\sqrt{d}}}\\
\end{array}
\end{array}
if l < -5.00000000000023e-311Initial program 64.1%
Taylor expanded in d around inf 8.6%
if -5.00000000000023e-311 < l < 3.8e199Initial program 69.7%
Applied egg-rr70.3%
distribute-rgt1-in80.2%
+-commutative80.2%
associate-*l/86.4%
associate-/l*86.4%
Simplified86.4%
associate-*r/87.6%
Applied egg-rr78.4%
associate-*r/78.1%
associate-/l*78.1%
associate-*r*78.1%
Simplified78.1%
if 3.8e199 < l Initial program 65.4%
Simplified69.4%
sqrt-div74.7%
clear-num74.5%
Applied egg-rr74.5%
Taylor expanded in l around inf 68.0%
Final simplification43.4%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(if (<= l -5e-311)
(* d (sqrt (/ 1.0 (* l h))))
(if (<= l 3.8e+199)
(/
(* d (fma h (* (/ -0.5 l) (pow (* M (/ (* 0.5 D) d)) 2.0)) 1.0))
(sqrt (* l h)))
(* (sqrt (/ d h)) (/ 1.0 (/ (sqrt l) (sqrt d)))))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= -5e-311) {
tmp = d * sqrt((1.0 / (l * h)));
} else if (l <= 3.8e+199) {
tmp = (d * fma(h, ((-0.5 / l) * pow((M * ((0.5 * D) / d)), 2.0)), 1.0)) / sqrt((l * h));
} else {
tmp = sqrt((d / h)) * (1.0 / (sqrt(l) / sqrt(d)));
}
return tmp;
}
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) tmp = 0.0 if (l <= -5e-311) tmp = Float64(d * sqrt(Float64(1.0 / Float64(l * h)))); elseif (l <= 3.8e+199) tmp = Float64(Float64(d * fma(h, Float64(Float64(-0.5 / l) * (Float64(M * Float64(Float64(0.5 * D) / d)) ^ 2.0)), 1.0)) / sqrt(Float64(l * h))); else tmp = Float64(sqrt(Float64(d / h)) * Float64(1.0 / Float64(sqrt(l) / sqrt(d)))); end return tmp end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[l, -5e-311], N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 3.8e+199], N[(N[(d * N[(h * N[(N[(-0.5 / l), $MachinePrecision] * N[Power[N[(M * N[(N[(0.5 * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[(N[Sqrt[l], $MachinePrecision] / N[Sqrt[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5 \cdot 10^{-311}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{elif}\;\ell \leq 3.8 \cdot 10^{+199}:\\
\;\;\;\;\frac{d \cdot \mathsf{fma}\left(h, \frac{-0.5}{\ell} \cdot {\left(M \cdot \frac{0.5 \cdot D}{d}\right)}^{2}, 1\right)}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \frac{1}{\frac{\sqrt{\ell}}{\sqrt{d}}}\\
\end{array}
\end{array}
if l < -5.00000000000023e-311Initial program 64.1%
Taylor expanded in d around inf 8.6%
if -5.00000000000023e-311 < l < 3.8e199Initial program 69.7%
Applied egg-rr70.3%
distribute-rgt1-in80.2%
+-commutative80.2%
associate-*l/86.4%
associate-/l*86.4%
Simplified86.4%
associate-*r/87.6%
Applied egg-rr78.4%
if 3.8e199 < l Initial program 65.4%
Simplified69.4%
sqrt-div74.7%
clear-num74.5%
Applied egg-rr74.5%
Taylor expanded in l around inf 68.0%
Final simplification43.5%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(if (<= l 9.5e-306)
(*
(sqrt (* (/ d l) (/ d h)))
(fma (* (/ h l) (pow (* (/ D d) (* M 0.5)) 2.0)) -0.5 1.0))
(if (<= l 1.15e+199)
(/
(* d (fma h (* (/ -0.5 l) (pow (* M (/ (* 0.5 D) d)) 2.0)) 1.0))
(sqrt (* l h)))
(* (sqrt (/ d h)) (/ 1.0 (/ (sqrt l) (sqrt d)))))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= 9.5e-306) {
tmp = sqrt(((d / l) * (d / h))) * fma(((h / l) * pow(((D / d) * (M * 0.5)), 2.0)), -0.5, 1.0);
} else if (l <= 1.15e+199) {
tmp = (d * fma(h, ((-0.5 / l) * pow((M * ((0.5 * D) / d)), 2.0)), 1.0)) / sqrt((l * h));
} else {
tmp = sqrt((d / h)) * (1.0 / (sqrt(l) / sqrt(d)));
}
return tmp;
}
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) tmp = 0.0 if (l <= 9.5e-306) tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * fma(Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M * 0.5)) ^ 2.0)), -0.5, 1.0)); elseif (l <= 1.15e+199) tmp = Float64(Float64(d * fma(h, Float64(Float64(-0.5 / l) * (Float64(M * Float64(Float64(0.5 * D) / d)) ^ 2.0)), 1.0)) / sqrt(Float64(l * h))); else tmp = Float64(sqrt(Float64(d / h)) * Float64(1.0 / Float64(sqrt(l) / sqrt(d)))); end return tmp end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[l, 9.5e-306], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.15e+199], N[(N[(d * N[(h * N[(N[(-0.5 / l), $MachinePrecision] * N[Power[N[(M * N[(N[(0.5 * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[(N[Sqrt[l], $MachinePrecision] / N[Sqrt[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 9.5 \cdot 10^{-306}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \mathsf{fma}\left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}, -0.5, 1\right)\\
\mathbf{elif}\;\ell \leq 1.15 \cdot 10^{+199}:\\
\;\;\;\;\frac{d \cdot \mathsf{fma}\left(h, \frac{-0.5}{\ell} \cdot {\left(M \cdot \frac{0.5 \cdot D}{d}\right)}^{2}, 1\right)}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \frac{1}{\frac{\sqrt{\ell}}{\sqrt{d}}}\\
\end{array}
\end{array}
if l < 9.5e-306Initial program 64.4%
Simplified63.6%
clear-num63.6%
un-div-inv64.4%
frac-times65.2%
associate-/l*64.4%
*-un-lft-identity64.4%
times-frac64.4%
metadata-eval64.4%
Applied egg-rr64.4%
associate-/r/65.3%
Simplified65.3%
Applied egg-rr52.8%
unpow152.8%
+-commutative52.8%
*-commutative52.8%
fma-undefine52.8%
Simplified52.8%
if 9.5e-306 < l < 1.14999999999999997e199Initial program 69.5%
Applied egg-rr70.0%
distribute-rgt1-in80.0%
+-commutative80.0%
associate-*l/86.3%
associate-/l*86.3%
Simplified86.3%
associate-*r/87.5%
Applied egg-rr79.1%
if 1.14999999999999997e199 < l Initial program 65.4%
Simplified69.4%
sqrt-div74.7%
clear-num74.5%
Applied egg-rr74.5%
Taylor expanded in l around inf 68.0%
Final simplification65.3%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(if (<= h -5e-310)
(*
(sqrt (/ d l))
(*
(sqrt (/ d h))
(+ 1.0 (* h (* (pow (/ D (/ (* d 2.0) M)) 2.0) (/ -0.5 l))))))
(*
(/ d (* (sqrt h) (sqrt l)))
(+ 1.0 (* h (/ (* -0.5 (pow (* 0.5 (* D (/ M d))) 2.0)) l))))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (h <= -5e-310) {
tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0 + (h * (pow((D / ((d * 2.0) / M)), 2.0) * (-0.5 / l)))));
} else {
tmp = (d / (sqrt(h) * sqrt(l))) * (1.0 + (h * ((-0.5 * pow((0.5 * (D * (M / d))), 2.0)) / l)));
}
return tmp;
}
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: tmp
if (h <= (-5d-310)) then
tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0d0 + (h * (((d_1 / ((d * 2.0d0) / m)) ** 2.0d0) * ((-0.5d0) / l)))))
else
tmp = (d / (sqrt(h) * sqrt(l))) * (1.0d0 + (h * (((-0.5d0) * ((0.5d0 * (d_1 * (m / d))) ** 2.0d0)) / l)))
end if
code = tmp
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (h <= -5e-310) {
tmp = Math.sqrt((d / l)) * (Math.sqrt((d / h)) * (1.0 + (h * (Math.pow((D / ((d * 2.0) / M)), 2.0) * (-0.5 / l)))));
} else {
tmp = (d / (Math.sqrt(h) * Math.sqrt(l))) * (1.0 + (h * ((-0.5 * Math.pow((0.5 * (D * (M / d))), 2.0)) / l)));
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): tmp = 0 if h <= -5e-310: tmp = math.sqrt((d / l)) * (math.sqrt((d / h)) * (1.0 + (h * (math.pow((D / ((d * 2.0) / M)), 2.0) * (-0.5 / l))))) else: tmp = (d / (math.sqrt(h) * math.sqrt(l))) * (1.0 + (h * ((-0.5 * math.pow((0.5 * (D * (M / d))), 2.0)) / l))) return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) tmp = 0.0 if (h <= -5e-310) tmp = Float64(sqrt(Float64(d / l)) * Float64(sqrt(Float64(d / h)) * Float64(1.0 + Float64(h * Float64((Float64(D / Float64(Float64(d * 2.0) / M)) ^ 2.0) * Float64(-0.5 / l)))))); else tmp = Float64(Float64(d / Float64(sqrt(h) * sqrt(l))) * Float64(1.0 + Float64(h * Float64(Float64(-0.5 * (Float64(0.5 * Float64(D * Float64(M / d))) ^ 2.0)) / l)))); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
tmp = 0.0;
if (h <= -5e-310)
tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0 + (h * (((D / ((d * 2.0) / M)) ^ 2.0) * (-0.5 / l)))));
else
tmp = (d / (sqrt(h) * sqrt(l))) * (1.0 + (h * ((-0.5 * ((0.5 * (D * (M / d))) ^ 2.0)) / l)));
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[h, -5e-310], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(h * N[(N[Power[N[(D / N[(N[(d * 2.0), $MachinePrecision] / M), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(h * N[(N[(-0.5 * N[Power[N[(0.5 * N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + h \cdot \left({\left(\frac{D}{\frac{d \cdot 2}{M}}\right)}^{2} \cdot \frac{-0.5}{\ell}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \left(1 + h \cdot \frac{-0.5 \cdot {\left(0.5 \cdot \left(D \cdot \frac{M}{d}\right)\right)}^{2}}{\ell}\right)\\
\end{array}
\end{array}
if h < -4.999999999999985e-310Initial program 64.1%
Simplified63.3%
clear-num63.3%
associate-*l/64.1%
*-un-lft-identity64.1%
frac-times64.9%
associate-/l*64.1%
*-un-lft-identity64.1%
times-frac64.1%
metadata-eval64.1%
Applied egg-rr64.1%
associate-/r/65.1%
*-commutative65.1%
associate-/l*65.1%
associate-*r*65.1%
*-commutative65.1%
metadata-eval65.1%
associate-/r/65.0%
times-frac65.1%
*-commutative65.1%
*-rgt-identity65.1%
associate-*l/65.1%
Simplified65.1%
if -4.999999999999985e-310 < h Initial program 69.1%
Applied egg-rr72.4%
distribute-rgt1-in80.8%
+-commutative80.8%
associate-*l/85.4%
associate-/l*86.1%
Simplified86.1%
Taylor expanded in M around 0 86.2%
associate-/l*85.4%
Simplified85.4%
Final simplification75.5%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(if (<= l -5.8e-292)
(*
(sqrt (* (/ d l) (/ d h)))
(fma (* (/ h l) (pow (* (/ D d) (* M 0.5)) 2.0)) -0.5 1.0))
(*
(/ d (* (sqrt h) (sqrt l)))
(+ 1.0 (* h (/ (* -0.5 (pow (* 0.5 (* D (/ M d))) 2.0)) l))))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= -5.8e-292) {
tmp = sqrt(((d / l) * (d / h))) * fma(((h / l) * pow(((D / d) * (M * 0.5)), 2.0)), -0.5, 1.0);
} else {
tmp = (d / (sqrt(h) * sqrt(l))) * (1.0 + (h * ((-0.5 * pow((0.5 * (D * (M / d))), 2.0)) / l)));
}
return tmp;
}
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) tmp = 0.0 if (l <= -5.8e-292) tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * fma(Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M * 0.5)) ^ 2.0)), -0.5, 1.0)); else tmp = Float64(Float64(d / Float64(sqrt(h) * sqrt(l))) * Float64(1.0 + Float64(h * Float64(Float64(-0.5 * (Float64(0.5 * Float64(D * Float64(M / d))) ^ 2.0)) / l)))); end return tmp end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[l, -5.8e-292], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M * 0.5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(h * N[(N[(-0.5 * N[Power[N[(0.5 * N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5.8 \cdot 10^{-292}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \mathsf{fma}\left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}, -0.5, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \left(1 + h \cdot \frac{-0.5 \cdot {\left(0.5 \cdot \left(D \cdot \frac{M}{d}\right)\right)}^{2}}{\ell}\right)\\
\end{array}
\end{array}
if l < -5.79999999999999985e-292Initial program 64.7%
Simplified63.8%
clear-num63.8%
un-div-inv64.6%
frac-times65.4%
associate-/l*64.6%
*-un-lft-identity64.6%
times-frac64.6%
metadata-eval64.6%
Applied egg-rr64.6%
associate-/r/65.6%
Simplified65.6%
Applied egg-rr52.8%
unpow152.8%
+-commutative52.8%
*-commutative52.8%
fma-undefine52.8%
Simplified52.8%
if -5.79999999999999985e-292 < l Initial program 68.6%
Applied egg-rr71.8%
distribute-rgt1-in80.2%
+-commutative80.2%
associate-*l/84.8%
associate-/l*85.4%
Simplified85.4%
Taylor expanded in M around 0 85.6%
associate-/l*84.7%
Simplified84.7%
Final simplification69.3%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. (FPCore (d h l M D) :precision binary64 (if (<= M 4.5e-124) (* d (sqrt (/ 1.0 (* l h)))) (* (sqrt (* h (pow l -3.0))) (/ (* -0.125 (pow (* M D) 2.0)) d))))
assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (M <= 4.5e-124) {
tmp = d * sqrt((1.0 / (l * h)));
} else {
tmp = sqrt((h * pow(l, -3.0))) * ((-0.125 * pow((M * D), 2.0)) / d);
}
return tmp;
}
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: tmp
if (m <= 4.5d-124) then
tmp = d * sqrt((1.0d0 / (l * h)))
else
tmp = sqrt((h * (l ** (-3.0d0)))) * (((-0.125d0) * ((m * d_1) ** 2.0d0)) / d)
end if
code = tmp
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (M <= 4.5e-124) {
tmp = d * Math.sqrt((1.0 / (l * h)));
} else {
tmp = Math.sqrt((h * Math.pow(l, -3.0))) * ((-0.125 * Math.pow((M * D), 2.0)) / d);
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): tmp = 0 if M <= 4.5e-124: tmp = d * math.sqrt((1.0 / (l * h))) else: tmp = math.sqrt((h * math.pow(l, -3.0))) * ((-0.125 * math.pow((M * D), 2.0)) / d) return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) tmp = 0.0 if (M <= 4.5e-124) tmp = Float64(d * sqrt(Float64(1.0 / Float64(l * h)))); else tmp = Float64(sqrt(Float64(h * (l ^ -3.0))) * Float64(Float64(-0.125 * (Float64(M * D) ^ 2.0)) / d)); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
tmp = 0.0;
if (M <= 4.5e-124)
tmp = d * sqrt((1.0 / (l * h)));
else
tmp = sqrt((h * (l ^ -3.0))) * ((-0.125 * ((M * D) ^ 2.0)) / d);
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[M, 4.5e-124], N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(h * N[Power[l, -3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[(-0.125 * N[Power[N[(M * D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 4.5 \cdot 10^{-124}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{h \cdot {\ell}^{-3}} \cdot \frac{-0.125 \cdot {\left(M \cdot D\right)}^{2}}{d}\\
\end{array}
\end{array}
if M < 4.4999999999999996e-124Initial program 65.8%
Taylor expanded in d around inf 28.1%
if 4.4999999999999996e-124 < M Initial program 68.2%
Applied egg-rr35.9%
distribute-rgt1-in40.4%
+-commutative40.4%
associate-*l/41.7%
associate-/l*42.7%
Simplified42.7%
Taylor expanded in M around inf 19.8%
*-commutative19.8%
*-commutative19.8%
associate-*l*19.8%
unpow219.8%
unpow219.8%
swap-sqr21.2%
unpow221.2%
*-commutative21.2%
Simplified21.2%
pow121.2%
associate-*r*21.2%
div-inv20.3%
pow-flip20.3%
metadata-eval20.3%
*-commutative20.3%
Applied egg-rr20.3%
unpow120.3%
associate-*l*20.3%
associate-*r/20.3%
*-commutative20.3%
Simplified20.3%
Final simplification25.4%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. (FPCore (d h l M D) :precision binary64 (if (<= M 4.3e-124) (* d (sqrt (/ 1.0 (* l h)))) (* (* -0.125 (/ (pow (* M D) 2.0) d)) (sqrt (/ h (pow l 3.0))))))
assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (M <= 4.3e-124) {
tmp = d * sqrt((1.0 / (l * h)));
} else {
tmp = (-0.125 * (pow((M * D), 2.0) / d)) * sqrt((h / pow(l, 3.0)));
}
return tmp;
}
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: tmp
if (m <= 4.3d-124) then
tmp = d * sqrt((1.0d0 / (l * h)))
else
tmp = ((-0.125d0) * (((m * d_1) ** 2.0d0) / d)) * sqrt((h / (l ** 3.0d0)))
end if
code = tmp
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (M <= 4.3e-124) {
tmp = d * Math.sqrt((1.0 / (l * h)));
} else {
tmp = (-0.125 * (Math.pow((M * D), 2.0) / d)) * Math.sqrt((h / Math.pow(l, 3.0)));
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): tmp = 0 if M <= 4.3e-124: tmp = d * math.sqrt((1.0 / (l * h))) else: tmp = (-0.125 * (math.pow((M * D), 2.0) / d)) * math.sqrt((h / math.pow(l, 3.0))) return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) tmp = 0.0 if (M <= 4.3e-124) tmp = Float64(d * sqrt(Float64(1.0 / Float64(l * h)))); else tmp = Float64(Float64(-0.125 * Float64((Float64(M * D) ^ 2.0) / d)) * sqrt(Float64(h / (l ^ 3.0)))); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
tmp = 0.0;
if (M <= 4.3e-124)
tmp = d * sqrt((1.0 / (l * h)));
else
tmp = (-0.125 * (((M * D) ^ 2.0) / d)) * sqrt((h / (l ^ 3.0)));
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[M, 4.3e-124], N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(-0.125 * N[(N[Power[N[(M * D), $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 4.3 \cdot 10^{-124}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\left(-0.125 \cdot \frac{{\left(M \cdot D\right)}^{2}}{d}\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\\
\end{array}
\end{array}
if M < 4.3e-124Initial program 65.8%
Taylor expanded in d around inf 28.1%
if 4.3e-124 < M Initial program 68.2%
Applied egg-rr35.9%
distribute-rgt1-in40.4%
+-commutative40.4%
associate-*l/41.7%
associate-/l*42.7%
Simplified42.7%
Taylor expanded in M around inf 19.8%
*-commutative19.8%
*-commutative19.8%
associate-*l*19.8%
unpow219.8%
unpow219.8%
swap-sqr21.2%
unpow221.2%
*-commutative21.2%
Simplified21.2%
Final simplification25.7%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. (FPCore (d h l M D) :precision binary64 (if (<= h 3.15e-117) (* d (sqrt (/ 1.0 (* l h)))) (* (sqrt (/ d h)) (/ 1.0 (/ (sqrt l) (sqrt d))))))
assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (h <= 3.15e-117) {
tmp = d * sqrt((1.0 / (l * h)));
} else {
tmp = sqrt((d / h)) * (1.0 / (sqrt(l) / sqrt(d)));
}
return tmp;
}
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: tmp
if (h <= 3.15d-117) then
tmp = d * sqrt((1.0d0 / (l * h)))
else
tmp = sqrt((d / h)) * (1.0d0 / (sqrt(l) / sqrt(d)))
end if
code = tmp
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (h <= 3.15e-117) {
tmp = d * Math.sqrt((1.0 / (l * h)));
} else {
tmp = Math.sqrt((d / h)) * (1.0 / (Math.sqrt(l) / Math.sqrt(d)));
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): tmp = 0 if h <= 3.15e-117: tmp = d * math.sqrt((1.0 / (l * h))) else: tmp = math.sqrt((d / h)) * (1.0 / (math.sqrt(l) / math.sqrt(d))) return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) tmp = 0.0 if (h <= 3.15e-117) tmp = Float64(d * sqrt(Float64(1.0 / Float64(l * h)))); else tmp = Float64(sqrt(Float64(d / h)) * Float64(1.0 / Float64(sqrt(l) / sqrt(d)))); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
tmp = 0.0;
if (h <= 3.15e-117)
tmp = d * sqrt((1.0 / (l * h)));
else
tmp = sqrt((d / h)) * (1.0 / (sqrt(l) / sqrt(d)));
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[h, 3.15e-117], N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[(N[Sqrt[l], $MachinePrecision] / N[Sqrt[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq 3.15 \cdot 10^{-117}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \frac{1}{\frac{\sqrt{\ell}}{\sqrt{d}}}\\
\end{array}
\end{array}
if h < 3.1499999999999999e-117Initial program 64.8%
Taylor expanded in d around inf 19.3%
if 3.1499999999999999e-117 < h Initial program 70.4%
Simplified71.3%
sqrt-div71.6%
clear-num71.6%
Applied egg-rr71.6%
Taylor expanded in l around inf 46.8%
Final simplification28.5%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. (FPCore (d h l M D) :precision binary64 (* d (sqrt (/ 1.0 (* l h)))))
assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
return d * sqrt((1.0 / (l * h)));
}
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = d * sqrt((1.0d0 / (l * h)))
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
return d * Math.sqrt((1.0 / (l * h)));
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): return d * math.sqrt((1.0 / (l * h)))
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) return Float64(d * sqrt(Float64(1.0 / Float64(l * h)))) end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp = code(d, h, l, M, D)
tmp = d * sqrt((1.0 / (l * h)));
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
d \cdot \sqrt{\frac{1}{\ell \cdot h}}
\end{array}
Initial program 66.7%
Taylor expanded in d around inf 25.0%
Final simplification25.0%
herbie shell --seed 2024044
(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)))))