
(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 23 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(if (<= l -5e-310)
(*
(pow (pow (/ d h) 0.25) 2.0)
(*
(/ (sqrt (- d)) (sqrt (- l)))
(- 1.0 (* 0.5 (/ (* h (pow (* (* 0.5 M) (/ D d)) 2.0)) l)))))
(*
(/ (sqrt d) (sqrt l))
(*
(/ (sqrt d) (sqrt h))
(+ 1.0 (* (/ h l) (* (pow (* (/ D d) (/ M 2.0)) 2.0) -0.5)))))))assert(M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= -5e-310) {
tmp = pow(pow((d / h), 0.25), 2.0) * ((sqrt(-d) / sqrt(-l)) * (1.0 - (0.5 * ((h * pow(((0.5 * M) * (D / d)), 2.0)) / l))));
} else {
tmp = (sqrt(d) / sqrt(l)) * ((sqrt(d) / sqrt(h)) * (1.0 + ((h / l) * (pow(((D / d) * (M / 2.0)), 2.0) * -0.5))));
}
return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: tmp
if (l <= (-5d-310)) then
tmp = (((d / h) ** 0.25d0) ** 2.0d0) * ((sqrt(-d) / sqrt(-l)) * (1.0d0 - (0.5d0 * ((h * (((0.5d0 * m) * (d_1 / d)) ** 2.0d0)) / l))))
else
tmp = (sqrt(d) / sqrt(l)) * ((sqrt(d) / sqrt(h)) * (1.0d0 + ((h / l) * ((((d_1 / d) * (m / 2.0d0)) ** 2.0d0) * (-0.5d0)))))
end if
code = tmp
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= -5e-310) {
tmp = Math.pow(Math.pow((d / h), 0.25), 2.0) * ((Math.sqrt(-d) / Math.sqrt(-l)) * (1.0 - (0.5 * ((h * Math.pow(((0.5 * M) * (D / d)), 2.0)) / l))));
} else {
tmp = (Math.sqrt(d) / Math.sqrt(l)) * ((Math.sqrt(d) / Math.sqrt(h)) * (1.0 + ((h / l) * (Math.pow(((D / d) * (M / 2.0)), 2.0) * -0.5))));
}
return tmp;
}
[M, D] = sort([M, D]) def code(d, h, l, M, D): tmp = 0 if l <= -5e-310: tmp = math.pow(math.pow((d / h), 0.25), 2.0) * ((math.sqrt(-d) / math.sqrt(-l)) * (1.0 - (0.5 * ((h * math.pow(((0.5 * M) * (D / d)), 2.0)) / l)))) else: tmp = (math.sqrt(d) / math.sqrt(l)) * ((math.sqrt(d) / math.sqrt(h)) * (1.0 + ((h / l) * (math.pow(((D / d) * (M / 2.0)), 2.0) * -0.5)))) return tmp
M, D = sort([M, D]) function code(d, h, l, M, D) tmp = 0.0 if (l <= -5e-310) tmp = Float64(((Float64(d / h) ^ 0.25) ^ 2.0) * Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-l))) * Float64(1.0 - Float64(0.5 * Float64(Float64(h * (Float64(Float64(0.5 * M) * Float64(D / d)) ^ 2.0)) / l))))); else tmp = Float64(Float64(sqrt(d) / sqrt(l)) * Float64(Float64(sqrt(d) / sqrt(h)) * Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(Float64(D / d) * Float64(M / 2.0)) ^ 2.0) * -0.5))))); end return tmp end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
tmp = 0.0;
if (l <= -5e-310)
tmp = (((d / h) ^ 0.25) ^ 2.0) * ((sqrt(-d) / sqrt(-l)) * (1.0 - (0.5 * ((h * (((0.5 * M) * (D / d)) ^ 2.0)) / l))));
else
tmp = (sqrt(d) / sqrt(l)) * ((sqrt(d) / sqrt(h)) * (1.0 + ((h / l) * ((((D / d) * (M / 2.0)) ^ 2.0) * -0.5))));
end
tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[l, -5e-310], N[(N[Power[N[Power[N[(d / h), $MachinePrecision], 0.25], $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h * N[Power[N[(N[(0.5 * M), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;{\left({\left(\frac{d}{h}\right)}^{0.25}\right)}^{2} \cdot \left(\frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \left(1 - 0.5 \cdot \frac{h \cdot {\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \left(\frac{\sqrt{d}}{\sqrt{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2} \cdot -0.5\right)\right)\right)\\
\end{array}
\end{array}
if l < -4.999999999999985e-310Initial program 70.1%
Simplified69.2%
pow1/269.2%
metadata-eval69.2%
sqr-pow69.2%
pow269.2%
metadata-eval69.2%
metadata-eval69.2%
Applied egg-rr69.2%
associate-*r/71.1%
add-sqr-sqrt44.1%
add-sqr-sqrt71.1%
div-inv71.1%
metadata-eval71.1%
Applied egg-rr71.1%
frac-2neg71.1%
sqrt-div77.1%
Applied egg-rr77.1%
if -4.999999999999985e-310 < l Initial program 66.2%
Simplified65.5%
sqrt-div67.4%
Applied egg-rr67.4%
sqrt-div81.5%
Applied egg-rr81.5%
Final simplification79.4%
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) 0.5) (pow (/ d l) 0.5))
(- 1.0 (* (/ h l) (* 0.5 (pow (/ (* M D) (* d 2.0)) 2.0))))))
(t_1 (sqrt (* l h))))
(if (<= t_0 2e+287)
(*
(sqrt (/ d l))
(*
(sqrt (/ d h))
(+ 1.0 (* (/ h l) (* -0.5 (pow (/ (/ (* M D) 2.0) d) 2.0))))))
(if (<= t_0 INFINITY)
(fabs
(*
(/ d t_1)
(fma 0.5 (* (/ h l) (- (pow (* M (/ (* 0.5 D) d)) 2.0))) 1.0)))
(sqrt (pow (* d (/ 1.0 t_1)) 2.0))))))assert(M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = (pow((d / h), 0.5) * pow((d / l), 0.5)) * (1.0 - ((h / l) * (0.5 * pow(((M * D) / (d * 2.0)), 2.0))));
double t_1 = sqrt((l * h));
double tmp;
if (t_0 <= 2e+287) {
tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0 + ((h / l) * (-0.5 * pow((((M * D) / 2.0) / d), 2.0)))));
} else if (t_0 <= ((double) INFINITY)) {
tmp = fabs(((d / t_1) * fma(0.5, ((h / l) * -pow((M * ((0.5 * D) / d)), 2.0)), 1.0)));
} else {
tmp = sqrt(pow((d * (1.0 / t_1)), 2.0));
}
return tmp;
}
M, D = sort([M, D]) function code(d, h, l, M, D) t_0 = Float64(Float64((Float64(d / h) ^ 0.5) * (Float64(d / l) ^ 0.5)) * Float64(1.0 - Float64(Float64(h / l) * Float64(0.5 * (Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0))))) t_1 = sqrt(Float64(l * h)) tmp = 0.0 if (t_0 <= 2e+287) tmp = Float64(sqrt(Float64(d / l)) * Float64(sqrt(Float64(d / h)) * Float64(1.0 + Float64(Float64(h / l) * Float64(-0.5 * (Float64(Float64(Float64(M * D) / 2.0) / d) ^ 2.0)))))); elseif (t_0 <= Inf) tmp = abs(Float64(Float64(d / t_1) * fma(0.5, Float64(Float64(h / l) * Float64(-(Float64(M * Float64(Float64(0.5 * D) / d)) ^ 2.0))), 1.0))); else tmp = sqrt((Float64(d * Float64(1.0 / t_1)) ^ 2.0)); end return tmp end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(0.5 * N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 2e+287], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(N[(N[(M * D), $MachinePrecision] / 2.0), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[Abs[N[(N[(d / t$95$1), $MachinePrecision] * N[(0.5 * N[(N[(h / l), $MachinePrecision] * (-N[Power[N[(M * N[(N[(0.5 * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision])), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[Power[N[(d * N[(1.0 / t$95$1), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right)\right)\\
t_1 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;t_0 \leq 2 \cdot 10^{+287}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{\frac{M \cdot D}{2}}{d}\right)}^{2}\right)\right)\right)\\
\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;\left|\frac{d}{t_1} \cdot \mathsf{fma}\left(0.5, \frac{h}{\ell} \cdot \left(-{\left(M \cdot \frac{0.5 \cdot D}{d}\right)}^{2}\right), 1\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\sqrt{{\left(d \cdot \frac{1}{t_1}\right)}^{2}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < 2.0000000000000002e287Initial program 87.4%
Simplified86.3%
frac-times87.4%
associate-/r*87.4%
Applied egg-rr87.4%
if 2.0000000000000002e287 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < +inf.0Initial program 56.4%
add-sqr-sqrt56.4%
pow256.4%
sqrt-prod56.4%
*-commutative56.4%
frac-times56.4%
sqrt-prod56.4%
sqrt-pow156.4%
metadata-eval56.4%
pow156.4%
div-inv56.4%
metadata-eval56.4%
metadata-eval56.4%
Applied egg-rr56.4%
expm1-log1p-u56.4%
expm1-udef56.1%
metadata-eval56.1%
unpow1/256.1%
Applied egg-rr56.1%
expm1-def56.4%
expm1-log1p56.4%
Simplified56.4%
Applied egg-rr59.4%
unpow259.4%
rem-sqrt-square99.8%
*-commutative99.8%
cancel-sign-sub-inv99.8%
*-commutative99.8%
+-commutative99.8%
associate-*l*99.8%
fma-def99.8%
Simplified99.8%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) Initial program 0.0%
Simplified0.0%
Taylor expanded in d around inf 17.1%
*-commutative17.1%
associate-/r*17.2%
Simplified17.2%
add-sqr-sqrt16.3%
sqrt-unprod21.4%
pow221.4%
associate-/l/21.4%
sqrt-div21.3%
metadata-eval21.3%
Applied egg-rr21.3%
Final simplification77.3%
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (sqrt (* l h)))
(t_1
(*
(* (pow (/ d h) 0.5) (pow (/ d l) 0.5))
(- 1.0 (* (/ h l) (* 0.5 (pow (/ (* M D) (* d 2.0)) 2.0)))))))
(if (<= t_1 2e+287)
(*
(sqrt (/ d h))
(*
(sqrt (/ d l))
(- 1.0 (* 0.5 (pow (* (* (* 0.5 M) (/ D d)) (sqrt (/ h l))) 2.0)))))
(if (<= t_1 INFINITY)
(fabs
(*
(/ d t_0)
(fma 0.5 (* (/ h l) (- (pow (* M (/ (* 0.5 D) d)) 2.0))) 1.0)))
(sqrt (pow (* d (/ 1.0 t_0)) 2.0))))))assert(M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = sqrt((l * h));
double t_1 = (pow((d / h), 0.5) * pow((d / l), 0.5)) * (1.0 - ((h / l) * (0.5 * pow(((M * D) / (d * 2.0)), 2.0))));
double tmp;
if (t_1 <= 2e+287) {
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 - (0.5 * pow((((0.5 * M) * (D / d)) * sqrt((h / l))), 2.0))));
} else if (t_1 <= ((double) INFINITY)) {
tmp = fabs(((d / t_0) * fma(0.5, ((h / l) * -pow((M * ((0.5 * D) / d)), 2.0)), 1.0)));
} else {
tmp = sqrt(pow((d * (1.0 / t_0)), 2.0));
}
return tmp;
}
M, D = sort([M, D]) function code(d, h, l, M, D) t_0 = sqrt(Float64(l * h)) t_1 = Float64(Float64((Float64(d / h) ^ 0.5) * (Float64(d / l) ^ 0.5)) * Float64(1.0 - Float64(Float64(h / l) * Float64(0.5 * (Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0))))) tmp = 0.0 if (t_1 <= 2e+287) tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(d / l)) * Float64(1.0 - Float64(0.5 * (Float64(Float64(Float64(0.5 * M) * Float64(D / d)) * sqrt(Float64(h / l))) ^ 2.0))))); elseif (t_1 <= Inf) tmp = abs(Float64(Float64(d / t_0) * fma(0.5, Float64(Float64(h / l) * Float64(-(Float64(M * Float64(Float64(0.5 * D) / d)) ^ 2.0))), 1.0))); else tmp = sqrt((Float64(d * Float64(1.0 / t_0)) ^ 2.0)); end return tmp end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(0.5 * N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 2e+287], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(0.5 * N[Power[N[(N[(N[(0.5 * M), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[Abs[N[(N[(d / t$95$0), $MachinePrecision] * N[(0.5 * N[(N[(h / l), $MachinePrecision] * (-N[Power[N[(M * N[(N[(0.5 * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision])), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[Power[N[(d * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
t_1 := \left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right)\right)\\
\mathbf{if}\;t_1 \leq 2 \cdot 10^{+287}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot {\left(\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right)\right)\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;\left|\frac{d}{t_0} \cdot \mathsf{fma}\left(0.5, \frac{h}{\ell} \cdot \left(-{\left(M \cdot \frac{0.5 \cdot D}{d}\right)}^{2}\right), 1\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\sqrt{{\left(d \cdot \frac{1}{t_0}\right)}^{2}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < 2.0000000000000002e287Initial program 87.4%
Simplified86.3%
add-sqr-sqrt86.3%
pow286.3%
sqrt-prod86.3%
sqrt-pow188.4%
metadata-eval88.4%
pow188.4%
div-inv88.4%
metadata-eval88.4%
Applied egg-rr88.4%
if 2.0000000000000002e287 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < +inf.0Initial program 56.4%
add-sqr-sqrt56.4%
pow256.4%
sqrt-prod56.4%
*-commutative56.4%
frac-times56.4%
sqrt-prod56.4%
sqrt-pow156.4%
metadata-eval56.4%
pow156.4%
div-inv56.4%
metadata-eval56.4%
metadata-eval56.4%
Applied egg-rr56.4%
expm1-log1p-u56.4%
expm1-udef56.1%
metadata-eval56.1%
unpow1/256.1%
Applied egg-rr56.1%
expm1-def56.4%
expm1-log1p56.4%
Simplified56.4%
Applied egg-rr59.4%
unpow259.4%
rem-sqrt-square99.8%
*-commutative99.8%
cancel-sign-sub-inv99.8%
*-commutative99.8%
+-commutative99.8%
associate-*l*99.8%
fma-def99.8%
Simplified99.8%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) Initial program 0.0%
Simplified0.0%
Taylor expanded in d around inf 17.1%
*-commutative17.1%
associate-/r*17.2%
Simplified17.2%
add-sqr-sqrt16.3%
sqrt-unprod21.4%
pow221.4%
associate-/l/21.4%
sqrt-div21.3%
metadata-eval21.3%
Applied egg-rr21.3%
Final simplification78.0%
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (pow (* (/ D d) (/ M 2.0)) 2.0)))
(if (<= d -9.5e-300)
(*
(/ (sqrt (- d)) (sqrt (- h)))
(* (sqrt (/ d l)) (- 1.0 (* 0.5 (* (/ h l) t_0)))))
(*
(/ (sqrt d) (sqrt l))
(* (/ (sqrt d) (sqrt h)) (+ 1.0 (* (/ h l) (* t_0 -0.5))))))))assert(M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = pow(((D / d) * (M / 2.0)), 2.0);
double tmp;
if (d <= -9.5e-300) {
tmp = (sqrt(-d) / sqrt(-h)) * (sqrt((d / l)) * (1.0 - (0.5 * ((h / l) * t_0))));
} else {
tmp = (sqrt(d) / sqrt(l)) * ((sqrt(d) / sqrt(h)) * (1.0 + ((h / l) * (t_0 * -0.5))));
}
return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = ((d_1 / d) * (m / 2.0d0)) ** 2.0d0
if (d <= (-9.5d-300)) then
tmp = (sqrt(-d) / sqrt(-h)) * (sqrt((d / l)) * (1.0d0 - (0.5d0 * ((h / l) * t_0))))
else
tmp = (sqrt(d) / sqrt(l)) * ((sqrt(d) / sqrt(h)) * (1.0d0 + ((h / l) * (t_0 * (-0.5d0)))))
end if
code = tmp
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
double t_0 = Math.pow(((D / d) * (M / 2.0)), 2.0);
double tmp;
if (d <= -9.5e-300) {
tmp = (Math.sqrt(-d) / Math.sqrt(-h)) * (Math.sqrt((d / l)) * (1.0 - (0.5 * ((h / l) * t_0))));
} else {
tmp = (Math.sqrt(d) / Math.sqrt(l)) * ((Math.sqrt(d) / Math.sqrt(h)) * (1.0 + ((h / l) * (t_0 * -0.5))));
}
return tmp;
}
[M, D] = sort([M, D]) def code(d, h, l, M, D): t_0 = math.pow(((D / d) * (M / 2.0)), 2.0) tmp = 0 if d <= -9.5e-300: tmp = (math.sqrt(-d) / math.sqrt(-h)) * (math.sqrt((d / l)) * (1.0 - (0.5 * ((h / l) * t_0)))) else: tmp = (math.sqrt(d) / math.sqrt(l)) * ((math.sqrt(d) / math.sqrt(h)) * (1.0 + ((h / l) * (t_0 * -0.5)))) return tmp
M, D = sort([M, D]) function code(d, h, l, M, D) t_0 = Float64(Float64(D / d) * Float64(M / 2.0)) ^ 2.0 tmp = 0.0 if (d <= -9.5e-300) tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(sqrt(Float64(d / l)) * Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * t_0))))); else tmp = Float64(Float64(sqrt(d) / sqrt(l)) * Float64(Float64(sqrt(d) / sqrt(h)) * Float64(1.0 + Float64(Float64(h / l) * Float64(t_0 * -0.5))))); end return tmp end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
t_0 = ((D / d) * (M / 2.0)) ^ 2.0;
tmp = 0.0;
if (d <= -9.5e-300)
tmp = (sqrt(-d) / sqrt(-h)) * (sqrt((d / l)) * (1.0 - (0.5 * ((h / l) * t_0))));
else
tmp = (sqrt(d) / sqrt(l)) * ((sqrt(d) / sqrt(h)) * (1.0 + ((h / l) * (t_0 * -0.5))));
end
tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Power[N[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[d, -9.5e-300], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[(h / l), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(t$95$0 * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\\
\mathbf{if}\;d \leq -9.5 \cdot 10^{-300}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot t_0\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \left(\frac{\sqrt{d}}{\sqrt{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(t_0 \cdot -0.5\right)\right)\right)\\
\end{array}
\end{array}
if d < -9.5000000000000007e-300Initial program 71.2%
Simplified70.3%
frac-2neg70.3%
sqrt-div76.5%
Applied egg-rr76.5%
if -9.5000000000000007e-300 < d Initial program 65.2%
Simplified64.5%
sqrt-div66.4%
Applied egg-rr66.4%
sqrt-div80.3%
Applied egg-rr80.3%
Final simplification78.5%
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0
(*
(sqrt (/ d l))
(- 1.0 (* 0.5 (* (/ h l) (pow (* (/ D d) (/ M 2.0)) 2.0)))))))
(if (<= d -9.5e-300)
(* (/ (sqrt (- d)) (sqrt (- h))) t_0)
(* (/ (sqrt d) (sqrt h)) t_0))))assert(M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = sqrt((d / l)) * (1.0 - (0.5 * ((h / l) * pow(((D / d) * (M / 2.0)), 2.0))));
double tmp;
if (d <= -9.5e-300) {
tmp = (sqrt(-d) / sqrt(-h)) * t_0;
} else {
tmp = (sqrt(d) / sqrt(h)) * t_0;
}
return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((d / l)) * (1.0d0 - (0.5d0 * ((h / l) * (((d_1 / d) * (m / 2.0d0)) ** 2.0d0))))
if (d <= (-9.5d-300)) then
tmp = (sqrt(-d) / sqrt(-h)) * t_0
else
tmp = (sqrt(d) / sqrt(h)) * t_0
end if
code = tmp
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
double t_0 = Math.sqrt((d / l)) * (1.0 - (0.5 * ((h / l) * Math.pow(((D / d) * (M / 2.0)), 2.0))));
double tmp;
if (d <= -9.5e-300) {
tmp = (Math.sqrt(-d) / Math.sqrt(-h)) * t_0;
} else {
tmp = (Math.sqrt(d) / Math.sqrt(h)) * t_0;
}
return tmp;
}
[M, D] = sort([M, D]) def code(d, h, l, M, D): t_0 = math.sqrt((d / l)) * (1.0 - (0.5 * ((h / l) * math.pow(((D / d) * (M / 2.0)), 2.0)))) tmp = 0 if d <= -9.5e-300: tmp = (math.sqrt(-d) / math.sqrt(-h)) * t_0 else: tmp = (math.sqrt(d) / math.sqrt(h)) * t_0 return tmp
M, D = sort([M, D]) function code(d, h, l, M, D) t_0 = Float64(sqrt(Float64(d / l)) * Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M / 2.0)) ^ 2.0))))) tmp = 0.0 if (d <= -9.5e-300) tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * t_0); else tmp = Float64(Float64(sqrt(d) / sqrt(h)) * t_0); end return tmp end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
t_0 = sqrt((d / l)) * (1.0 - (0.5 * ((h / l) * (((D / d) * (M / 2.0)) ^ 2.0))));
tmp = 0.0;
if (d <= -9.5e-300)
tmp = (sqrt(-d) / sqrt(-h)) * t_0;
else
tmp = (sqrt(d) / sqrt(h)) * t_0;
end
tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[Sqrt[N[(d / l), $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]}, If[LessEqual[d, -9.5e-300], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\right)\right)\\
\mathbf{if}\;d \leq -9.5 \cdot 10^{-300}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{d}}{\sqrt{h}} \cdot t_0\\
\end{array}
\end{array}
if d < -9.5000000000000007e-300Initial program 71.2%
Simplified70.3%
frac-2neg70.3%
sqrt-div76.5%
Applied egg-rr76.5%
if -9.5000000000000007e-300 < d Initial program 65.2%
Simplified64.6%
sqrt-div80.3%
Applied egg-rr76.2%
Final simplification76.4%
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (sqrt (* l h))) (t_1 (pow (/ d h) 0.25)) (t_2 (sqrt (/ d l))))
(if (<= d -1.9e+125)
(* t_1 (* t_1 t_2))
(if (<= d -1.85e+73)
(log1p (expm1 (/ d t_0)))
(if (<= d -9.2e-17)
(* t_2 (sqrt (/ d h)))
(if (<= d 4.05e-299)
(/ d (+ (exp (log1p t_0)) -1.0))
(*
(/ d (* (sqrt l) (sqrt h)))
(+ 1.0 (* -0.5 (* (/ h l) (pow (* M (* 0.5 (/ D d))) 2.0)))))))))))assert(M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = sqrt((l * h));
double t_1 = pow((d / h), 0.25);
double t_2 = sqrt((d / l));
double tmp;
if (d <= -1.9e+125) {
tmp = t_1 * (t_1 * t_2);
} else if (d <= -1.85e+73) {
tmp = log1p(expm1((d / t_0)));
} else if (d <= -9.2e-17) {
tmp = t_2 * sqrt((d / h));
} else if (d <= 4.05e-299) {
tmp = d / (exp(log1p(t_0)) + -1.0);
} else {
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (-0.5 * ((h / l) * pow((M * (0.5 * (D / d))), 2.0))));
}
return tmp;
}
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
double t_0 = Math.sqrt((l * h));
double t_1 = Math.pow((d / h), 0.25);
double t_2 = Math.sqrt((d / l));
double tmp;
if (d <= -1.9e+125) {
tmp = t_1 * (t_1 * t_2);
} else if (d <= -1.85e+73) {
tmp = Math.log1p(Math.expm1((d / t_0)));
} else if (d <= -9.2e-17) {
tmp = t_2 * Math.sqrt((d / h));
} else if (d <= 4.05e-299) {
tmp = d / (Math.exp(Math.log1p(t_0)) + -1.0);
} else {
tmp = (d / (Math.sqrt(l) * Math.sqrt(h))) * (1.0 + (-0.5 * ((h / l) * Math.pow((M * (0.5 * (D / d))), 2.0))));
}
return tmp;
}
[M, D] = sort([M, D]) def code(d, h, l, M, D): t_0 = math.sqrt((l * h)) t_1 = math.pow((d / h), 0.25) t_2 = math.sqrt((d / l)) tmp = 0 if d <= -1.9e+125: tmp = t_1 * (t_1 * t_2) elif d <= -1.85e+73: tmp = math.log1p(math.expm1((d / t_0))) elif d <= -9.2e-17: tmp = t_2 * math.sqrt((d / h)) elif d <= 4.05e-299: tmp = d / (math.exp(math.log1p(t_0)) + -1.0) else: tmp = (d / (math.sqrt(l) * math.sqrt(h))) * (1.0 + (-0.5 * ((h / l) * math.pow((M * (0.5 * (D / d))), 2.0)))) return tmp
M, D = sort([M, D]) function code(d, h, l, M, D) t_0 = sqrt(Float64(l * h)) t_1 = Float64(d / h) ^ 0.25 t_2 = sqrt(Float64(d / l)) tmp = 0.0 if (d <= -1.9e+125) tmp = Float64(t_1 * Float64(t_1 * t_2)); elseif (d <= -1.85e+73) tmp = log1p(expm1(Float64(d / t_0))); elseif (d <= -9.2e-17) tmp = Float64(t_2 * sqrt(Float64(d / h))); elseif (d <= 4.05e-299) tmp = Float64(d / Float64(exp(log1p(t_0)) + -1.0)); else tmp = Float64(Float64(d / Float64(sqrt(l) * sqrt(h))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(M * Float64(0.5 * Float64(D / d))) ^ 2.0))))); end return tmp end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(d / h), $MachinePrecision], 0.25], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -1.9e+125], N[(t$95$1 * N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.85e+73], N[Log[1 + N[(Exp[N[(d / t$95$0), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, -9.2e-17], N[(t$95$2 * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.05e-299], N[(d / N[(N[Exp[N[Log[1 + t$95$0], $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(0.5 * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
t_1 := {\left(\frac{d}{h}\right)}^{0.25}\\
t_2 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;d \leq -1.9 \cdot 10^{+125}:\\
\;\;\;\;t_1 \cdot \left(t_1 \cdot t_2\right)\\
\mathbf{elif}\;d \leq -1.85 \cdot 10^{+73}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{d}{t_0}\right)\right)\\
\mathbf{elif}\;d \leq -9.2 \cdot 10^{-17}:\\
\;\;\;\;t_2 \cdot \sqrt{\frac{d}{h}}\\
\mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\
\;\;\;\;\frac{d}{e^{\mathsf{log1p}\left(t_0\right)} + -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right)\\
\end{array}
\end{array}
if d < -1.90000000000000001e125Initial program 75.6%
Simplified75.6%
Taylor expanded in d around inf 4.0%
*-commutative4.0%
associate-/r*4.0%
Simplified4.0%
expm1-log1p-u0.5%
expm1-udef0.5%
associate-/l/0.5%
sqrt-div0.5%
metadata-eval0.5%
Applied egg-rr0.5%
expm1-def0.5%
expm1-log1p4.0%
associate-*r/4.0%
*-rgt-identity4.0%
Simplified4.0%
add-sqr-sqrt0.0%
sqrt-prod0.0%
times-frac0.0%
sqrt-div0.0%
unpow1/20.0%
metadata-eval0.0%
sqrt-div62.9%
*-commutative62.9%
add-sqr-sqrt62.9%
associate-*r*62.9%
sqrt-pow163.0%
metadata-eval63.0%
metadata-eval63.0%
sqrt-pow162.9%
metadata-eval62.9%
metadata-eval62.9%
Applied egg-rr62.9%
if -1.90000000000000001e125 < d < -1.84999999999999987e73Initial program 80.4%
Simplified80.4%
Taylor expanded in d around inf 9.6%
*-commutative9.6%
associate-/r*9.6%
Simplified9.6%
expm1-log1p-u0.4%
expm1-udef0.3%
associate-/l/0.3%
sqrt-div0.3%
metadata-eval0.3%
Applied egg-rr0.3%
expm1-def0.4%
expm1-log1p9.6%
associate-*r/9.6%
*-rgt-identity9.6%
Simplified9.6%
log1p-expm1-u54.1%
Applied egg-rr54.1%
if -1.84999999999999987e73 < d < -9.20000000000000035e-17Initial program 81.5%
Simplified81.5%
Taylor expanded in d around inf 3.2%
*-commutative3.2%
associate-/r*3.2%
Simplified3.2%
expm1-log1p-u2.6%
expm1-udef3.0%
associate-/l/3.0%
sqrt-div3.0%
metadata-eval3.0%
Applied egg-rr3.0%
expm1-def2.6%
expm1-log1p3.2%
associate-*r/3.2%
*-rgt-identity3.2%
Simplified3.2%
add-sqr-sqrt0.0%
sqrt-prod0.0%
times-frac0.0%
sqrt-div0.0%
unpow1/20.0%
metadata-eval0.0%
sqrt-div64.5%
*-commutative64.5%
metadata-eval64.5%
unpow1/264.5%
Applied egg-rr64.5%
if -9.20000000000000035e-17 < d < 4.0499999999999998e-299Initial program 58.3%
Simplified58.3%
Taylor expanded in d around inf 19.2%
*-commutative19.2%
associate-/r*19.2%
Simplified19.2%
expm1-log1p-u7.0%
expm1-udef6.7%
associate-/l/6.7%
sqrt-div6.7%
metadata-eval6.7%
Applied egg-rr6.7%
expm1-def7.0%
expm1-log1p19.2%
associate-*r/19.2%
*-rgt-identity19.2%
Simplified19.2%
expm1-log1p-u19.2%
expm1-udef40.7%
Applied egg-rr40.7%
if 4.0499999999999998e-299 < d Initial program 67.3%
expm1-log1p-u29.0%
expm1-udef20.9%
Applied egg-rr26.3%
expm1-def36.8%
expm1-log1p78.2%
cancel-sign-sub-inv78.2%
metadata-eval78.2%
associate-*l*78.2%
Simplified78.2%
Final simplification65.0%
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (pow (/ d l) 0.25)))
(if (<= d -7.5e+170)
(* t_0 (* (sqrt (/ d h)) t_0))
(if (<= d -2.25e-104)
(*
(- 1.0 (* (pow (* (/ D d) (/ M 2.0)) 2.0) (* 0.5 (/ h l))))
(sqrt (/ (pow d 2.0) (* l h))))
(if (<= d 4.05e-299)
(/ d (+ (exp (log1p (sqrt (* l h)))) -1.0))
(*
(/ d (* (sqrt l) (sqrt h)))
(+ 1.0 (* -0.5 (* (/ h l) (pow (* M (* 0.5 (/ D d))) 2.0))))))))))assert(M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = pow((d / l), 0.25);
double tmp;
if (d <= -7.5e+170) {
tmp = t_0 * (sqrt((d / h)) * t_0);
} else if (d <= -2.25e-104) {
tmp = (1.0 - (pow(((D / d) * (M / 2.0)), 2.0) * (0.5 * (h / l)))) * sqrt((pow(d, 2.0) / (l * h)));
} else if (d <= 4.05e-299) {
tmp = d / (exp(log1p(sqrt((l * h)))) + -1.0);
} else {
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (-0.5 * ((h / l) * pow((M * (0.5 * (D / d))), 2.0))));
}
return tmp;
}
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
double t_0 = Math.pow((d / l), 0.25);
double tmp;
if (d <= -7.5e+170) {
tmp = t_0 * (Math.sqrt((d / h)) * t_0);
} else if (d <= -2.25e-104) {
tmp = (1.0 - (Math.pow(((D / d) * (M / 2.0)), 2.0) * (0.5 * (h / l)))) * Math.sqrt((Math.pow(d, 2.0) / (l * h)));
} else if (d <= 4.05e-299) {
tmp = d / (Math.exp(Math.log1p(Math.sqrt((l * h)))) + -1.0);
} else {
tmp = (d / (Math.sqrt(l) * Math.sqrt(h))) * (1.0 + (-0.5 * ((h / l) * Math.pow((M * (0.5 * (D / d))), 2.0))));
}
return tmp;
}
[M, D] = sort([M, D]) def code(d, h, l, M, D): t_0 = math.pow((d / l), 0.25) tmp = 0 if d <= -7.5e+170: tmp = t_0 * (math.sqrt((d / h)) * t_0) elif d <= -2.25e-104: tmp = (1.0 - (math.pow(((D / d) * (M / 2.0)), 2.0) * (0.5 * (h / l)))) * math.sqrt((math.pow(d, 2.0) / (l * h))) elif d <= 4.05e-299: tmp = d / (math.exp(math.log1p(math.sqrt((l * h)))) + -1.0) else: tmp = (d / (math.sqrt(l) * math.sqrt(h))) * (1.0 + (-0.5 * ((h / l) * math.pow((M * (0.5 * (D / d))), 2.0)))) return tmp
M, D = sort([M, D]) function code(d, h, l, M, D) t_0 = Float64(d / l) ^ 0.25 tmp = 0.0 if (d <= -7.5e+170) tmp = Float64(t_0 * Float64(sqrt(Float64(d / h)) * t_0)); elseif (d <= -2.25e-104) tmp = Float64(Float64(1.0 - Float64((Float64(Float64(D / d) * Float64(M / 2.0)) ^ 2.0) * Float64(0.5 * Float64(h / l)))) * sqrt(Float64((d ^ 2.0) / Float64(l * h)))); elseif (d <= 4.05e-299) tmp = Float64(d / Float64(exp(log1p(sqrt(Float64(l * h)))) + -1.0)); else tmp = Float64(Float64(d / Float64(sqrt(l) * sqrt(h))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(M * Float64(0.5 * Float64(D / d))) ^ 2.0))))); end return tmp end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Power[N[(d / l), $MachinePrecision], 0.25], $MachinePrecision]}, If[LessEqual[d, -7.5e+170], N[(t$95$0 * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.25e-104], N[(N[(1.0 - N[(N[Power[N[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[Power[d, 2.0], $MachinePrecision] / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.05e-299], N[(d / N[(N[Exp[N[Log[1 + N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(0.5 * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{d}{\ell}\right)}^{0.25}\\
\mathbf{if}\;d \leq -7.5 \cdot 10^{+170}:\\
\;\;\;\;t_0 \cdot \left(\sqrt{\frac{d}{h}} \cdot t_0\right)\\
\mathbf{elif}\;d \leq -2.25 \cdot 10^{-104}:\\
\;\;\;\;\left(1 - {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2} \cdot \left(0.5 \cdot \frac{h}{\ell}\right)\right) \cdot \sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\
\mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\
\;\;\;\;\frac{d}{e^{\mathsf{log1p}\left(\sqrt{\ell \cdot h}\right)} + -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right)\\
\end{array}
\end{array}
if d < -7.5000000000000002e170Initial program 79.7%
Simplified79.7%
Taylor expanded in d around inf 1.2%
*-commutative1.2%
associate-/r*1.2%
Simplified1.2%
expm1-log1p-u0.7%
expm1-udef0.7%
associate-/l/0.7%
sqrt-div0.7%
metadata-eval0.7%
Applied egg-rr0.7%
expm1-def0.7%
expm1-log1p1.2%
associate-*r/1.2%
*-rgt-identity1.2%
Simplified1.2%
add-sqr-sqrt0.0%
sqrt-prod0.0%
times-frac0.0%
sqrt-div0.0%
unpow1/20.0%
metadata-eval0.0%
sqrt-div72.8%
add-sqr-sqrt72.7%
associate-*r*72.9%
metadata-eval72.9%
unpow1/272.9%
pow1/272.9%
metadata-eval72.9%
sqrt-pow172.9%
metadata-eval72.9%
metadata-eval72.9%
pow1/272.9%
metadata-eval72.9%
sqrt-pow172.9%
Applied egg-rr72.9%
if -7.5000000000000002e170 < d < -2.2499999999999999e-104Initial program 77.9%
add-sqr-sqrt77.9%
pow277.9%
sqrt-prod77.9%
*-commutative77.9%
frac-times77.8%
sqrt-prod77.7%
sqrt-pow180.9%
metadata-eval80.9%
pow180.9%
div-inv80.9%
metadata-eval80.9%
metadata-eval80.9%
Applied egg-rr80.9%
Applied egg-rr12.7%
expm1-def23.9%
expm1-log1p66.8%
*-commutative66.8%
*-commutative66.8%
associate-*l*66.8%
times-frac66.7%
Simplified66.7%
if -2.2499999999999999e-104 < d < 4.0499999999999998e-299Initial program 47.1%
Simplified47.1%
Taylor expanded in d around inf 20.1%
*-commutative20.1%
associate-/r*20.1%
Simplified20.1%
expm1-log1p-u9.7%
expm1-udef9.4%
associate-/l/9.4%
sqrt-div9.4%
metadata-eval9.4%
Applied egg-rr9.4%
expm1-def9.7%
expm1-log1p20.1%
associate-*r/20.1%
*-rgt-identity20.1%
Simplified20.1%
expm1-log1p-u20.1%
expm1-udef42.8%
Applied egg-rr42.8%
if 4.0499999999999998e-299 < d Initial program 67.3%
expm1-log1p-u29.0%
expm1-udef20.9%
Applied egg-rr26.3%
expm1-def36.8%
expm1-log1p78.2%
cancel-sign-sub-inv78.2%
metadata-eval78.2%
associate-*l*78.2%
Simplified78.2%
Final simplification69.4%
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(if (<= d -9.5e-300)
(*
(*
(sqrt (/ d l))
(- 1.0 (* 0.5 (* (/ h l) (pow (* (/ D d) (/ M 2.0)) 2.0)))))
(sqrt (/ d h)))
(*
(/ d (* (sqrt l) (sqrt h)))
(+ 1.0 (* -0.5 (* (/ h l) (pow (* M (* 0.5 (/ D d))) 2.0)))))))assert(M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (d <= -9.5e-300) {
tmp = (sqrt((d / l)) * (1.0 - (0.5 * ((h / l) * pow(((D / d) * (M / 2.0)), 2.0))))) * sqrt((d / h));
} else {
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (-0.5 * ((h / l) * pow((M * (0.5 * (D / d))), 2.0))));
}
return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: tmp
if (d <= (-9.5d-300)) then
tmp = (sqrt((d / l)) * (1.0d0 - (0.5d0 * ((h / l) * (((d_1 / d) * (m / 2.0d0)) ** 2.0d0))))) * sqrt((d / h))
else
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0d0 + ((-0.5d0) * ((h / l) * ((m * (0.5d0 * (d_1 / d))) ** 2.0d0))))
end if
code = tmp
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (d <= -9.5e-300) {
tmp = (Math.sqrt((d / l)) * (1.0 - (0.5 * ((h / l) * Math.pow(((D / d) * (M / 2.0)), 2.0))))) * Math.sqrt((d / h));
} else {
tmp = (d / (Math.sqrt(l) * Math.sqrt(h))) * (1.0 + (-0.5 * ((h / l) * Math.pow((M * (0.5 * (D / d))), 2.0))));
}
return tmp;
}
[M, D] = sort([M, D]) def code(d, h, l, M, D): tmp = 0 if d <= -9.5e-300: tmp = (math.sqrt((d / l)) * (1.0 - (0.5 * ((h / l) * math.pow(((D / d) * (M / 2.0)), 2.0))))) * math.sqrt((d / h)) else: tmp = (d / (math.sqrt(l) * math.sqrt(h))) * (1.0 + (-0.5 * ((h / l) * math.pow((M * (0.5 * (D / d))), 2.0)))) return tmp
M, D = sort([M, D]) function code(d, h, l, M, D) tmp = 0.0 if (d <= -9.5e-300) tmp = Float64(Float64(sqrt(Float64(d / l)) * Float64(1.0 - Float64(0.5 * Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M / 2.0)) ^ 2.0))))) * sqrt(Float64(d / h))); else tmp = Float64(Float64(d / Float64(sqrt(l) * sqrt(h))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(M * Float64(0.5 * Float64(D / d))) ^ 2.0))))); end return tmp end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
tmp = 0.0;
if (d <= -9.5e-300)
tmp = (sqrt((d / l)) * (1.0 - (0.5 * ((h / l) * (((D / d) * (M / 2.0)) ^ 2.0))))) * sqrt((d / h));
else
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (-0.5 * ((h / l) * ((M * (0.5 * (D / d))) ^ 2.0))));
end
tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[d, -9.5e-300], N[(N[(N[Sqrt[N[(d / l), $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[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(0.5 * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -9.5 \cdot 10^{-300}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\right)\right)\right) \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right)\\
\end{array}
\end{array}
if d < -9.5000000000000007e-300Initial program 71.2%
Simplified70.3%
if -9.5000000000000007e-300 < d Initial program 65.2%
expm1-log1p-u28.1%
expm1-udef20.2%
Applied egg-rr25.5%
expm1-def35.7%
expm1-log1p75.8%
cancel-sign-sub-inv75.8%
metadata-eval75.8%
associate-*l*75.8%
Simplified75.8%
Final simplification73.1%
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(if (<= d -9.5e-300)
(*
(sqrt (/ d l))
(*
(+ 1.0 (* (/ h l) (* (pow (* (/ D d) (/ M 2.0)) 2.0) -0.5)))
(sqrt (/ d h))))
(*
(/ d (* (sqrt l) (sqrt h)))
(+ 1.0 (* -0.5 (* (/ h l) (pow (* M (* 0.5 (/ D d))) 2.0)))))))assert(M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (d <= -9.5e-300) {
tmp = sqrt((d / l)) * ((1.0 + ((h / l) * (pow(((D / d) * (M / 2.0)), 2.0) * -0.5))) * sqrt((d / h)));
} else {
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (-0.5 * ((h / l) * pow((M * (0.5 * (D / d))), 2.0))));
}
return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: tmp
if (d <= (-9.5d-300)) then
tmp = sqrt((d / l)) * ((1.0d0 + ((h / l) * ((((d_1 / d) * (m / 2.0d0)) ** 2.0d0) * (-0.5d0)))) * sqrt((d / h)))
else
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0d0 + ((-0.5d0) * ((h / l) * ((m * (0.5d0 * (d_1 / d))) ** 2.0d0))))
end if
code = tmp
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (d <= -9.5e-300) {
tmp = Math.sqrt((d / l)) * ((1.0 + ((h / l) * (Math.pow(((D / d) * (M / 2.0)), 2.0) * -0.5))) * Math.sqrt((d / h)));
} else {
tmp = (d / (Math.sqrt(l) * Math.sqrt(h))) * (1.0 + (-0.5 * ((h / l) * Math.pow((M * (0.5 * (D / d))), 2.0))));
}
return tmp;
}
[M, D] = sort([M, D]) def code(d, h, l, M, D): tmp = 0 if d <= -9.5e-300: tmp = math.sqrt((d / l)) * ((1.0 + ((h / l) * (math.pow(((D / d) * (M / 2.0)), 2.0) * -0.5))) * math.sqrt((d / h))) else: tmp = (d / (math.sqrt(l) * math.sqrt(h))) * (1.0 + (-0.5 * ((h / l) * math.pow((M * (0.5 * (D / d))), 2.0)))) return tmp
M, D = sort([M, D]) function code(d, h, l, M, D) tmp = 0.0 if (d <= -9.5e-300) tmp = Float64(sqrt(Float64(d / l)) * Float64(Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(Float64(D / d) * Float64(M / 2.0)) ^ 2.0) * -0.5))) * sqrt(Float64(d / h)))); else tmp = Float64(Float64(d / Float64(sqrt(l) * sqrt(h))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(M * Float64(0.5 * Float64(D / d))) ^ 2.0))))); end return tmp end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
tmp = 0.0;
if (d <= -9.5e-300)
tmp = sqrt((d / l)) * ((1.0 + ((h / l) * ((((D / d) * (M / 2.0)) ^ 2.0) * -0.5))) * sqrt((d / h)));
else
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (-0.5 * ((h / l) * ((M * (0.5 * (D / d))) ^ 2.0))));
end
tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[d, -9.5e-300], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(0.5 * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -9.5 \cdot 10^{-300}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2} \cdot -0.5\right)\right) \cdot \sqrt{\frac{d}{h}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right)\\
\end{array}
\end{array}
if d < -9.5000000000000007e-300Initial program 71.2%
Simplified70.3%
if -9.5000000000000007e-300 < d Initial program 65.2%
expm1-log1p-u28.1%
expm1-udef20.2%
Applied egg-rr25.5%
expm1-def35.7%
expm1-log1p75.8%
cancel-sign-sub-inv75.8%
metadata-eval75.8%
associate-*l*75.8%
Simplified75.8%
Final simplification73.2%
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(if (<= d 1.02e-231)
(*
(sqrt (/ d l))
(*
(sqrt (/ d h))
(+ 1.0 (* (/ h l) (* -0.5 (pow (/ (/ (* M D) 2.0) d) 2.0))))))
(*
(/ d (* (sqrt l) (sqrt h)))
(+ 1.0 (* -0.5 (* (/ h l) (pow (* M (* 0.5 (/ D d))) 2.0)))))))assert(M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (d <= 1.02e-231) {
tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0 + ((h / l) * (-0.5 * pow((((M * D) / 2.0) / d), 2.0)))));
} else {
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (-0.5 * ((h / l) * pow((M * (0.5 * (D / d))), 2.0))));
}
return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: tmp
if (d <= 1.02d-231) then
tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0d0 + ((h / l) * ((-0.5d0) * ((((m * d_1) / 2.0d0) / d) ** 2.0d0)))))
else
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0d0 + ((-0.5d0) * ((h / l) * ((m * (0.5d0 * (d_1 / d))) ** 2.0d0))))
end if
code = tmp
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (d <= 1.02e-231) {
tmp = Math.sqrt((d / l)) * (Math.sqrt((d / h)) * (1.0 + ((h / l) * (-0.5 * Math.pow((((M * D) / 2.0) / d), 2.0)))));
} else {
tmp = (d / (Math.sqrt(l) * Math.sqrt(h))) * (1.0 + (-0.5 * ((h / l) * Math.pow((M * (0.5 * (D / d))), 2.0))));
}
return tmp;
}
[M, D] = sort([M, D]) def code(d, h, l, M, D): tmp = 0 if d <= 1.02e-231: tmp = math.sqrt((d / l)) * (math.sqrt((d / h)) * (1.0 + ((h / l) * (-0.5 * math.pow((((M * D) / 2.0) / d), 2.0))))) else: tmp = (d / (math.sqrt(l) * math.sqrt(h))) * (1.0 + (-0.5 * ((h / l) * math.pow((M * (0.5 * (D / d))), 2.0)))) return tmp
M, D = sort([M, D]) function code(d, h, l, M, D) tmp = 0.0 if (d <= 1.02e-231) tmp = Float64(sqrt(Float64(d / l)) * Float64(sqrt(Float64(d / h)) * Float64(1.0 + Float64(Float64(h / l) * Float64(-0.5 * (Float64(Float64(Float64(M * D) / 2.0) / d) ^ 2.0)))))); else tmp = Float64(Float64(d / Float64(sqrt(l) * sqrt(h))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(M * Float64(0.5 * Float64(D / d))) ^ 2.0))))); end return tmp end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
tmp = 0.0;
if (d <= 1.02e-231)
tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0 + ((h / l) * (-0.5 * ((((M * D) / 2.0) / d) ^ 2.0)))));
else
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (-0.5 * ((h / l) * ((M * (0.5 * (D / d))) ^ 2.0))));
end
tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[d, 1.02e-231], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(N[(N[(M * D), $MachinePrecision] / 2.0), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(0.5 * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 1.02 \cdot 10^{-231}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{\frac{M \cdot D}{2}}{d}\right)}^{2}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right)\\
\end{array}
\end{array}
if d < 1.02000000000000006e-231Initial program 68.8%
Simplified68.0%
frac-times68.8%
associate-/r*68.8%
Applied egg-rr68.8%
if 1.02000000000000006e-231 < d Initial program 67.3%
expm1-log1p-u30.3%
expm1-udef23.0%
Applied egg-rr29.0%
expm1-def39.0%
expm1-log1p79.3%
cancel-sign-sub-inv79.3%
metadata-eval79.3%
associate-*l*79.3%
Simplified79.3%
Final simplification73.5%
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(if (<= l 2e-31)
(*
(sqrt (/ d l))
(*
(sqrt (/ d h))
(+ 1.0 (/ (* h (* (pow (* (* 0.5 M) (/ D d)) 2.0) -0.5)) l))))
(*
(/ d (* (sqrt l) (sqrt h)))
(+ 1.0 (* -0.5 (* (/ h l) (pow (* M (* 0.5 (/ D d))) 2.0)))))))assert(M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= 2e-31) {
tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0 + ((h * (pow(((0.5 * M) * (D / d)), 2.0) * -0.5)) / l)));
} else {
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (-0.5 * ((h / l) * pow((M * (0.5 * (D / d))), 2.0))));
}
return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: tmp
if (l <= 2d-31) then
tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0d0 + ((h * ((((0.5d0 * m) * (d_1 / d)) ** 2.0d0) * (-0.5d0))) / l)))
else
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0d0 + ((-0.5d0) * ((h / l) * ((m * (0.5d0 * (d_1 / d))) ** 2.0d0))))
end if
code = tmp
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= 2e-31) {
tmp = Math.sqrt((d / l)) * (Math.sqrt((d / h)) * (1.0 + ((h * (Math.pow(((0.5 * M) * (D / d)), 2.0) * -0.5)) / l)));
} else {
tmp = (d / (Math.sqrt(l) * Math.sqrt(h))) * (1.0 + (-0.5 * ((h / l) * Math.pow((M * (0.5 * (D / d))), 2.0))));
}
return tmp;
}
[M, D] = sort([M, D]) def code(d, h, l, M, D): tmp = 0 if l <= 2e-31: tmp = math.sqrt((d / l)) * (math.sqrt((d / h)) * (1.0 + ((h * (math.pow(((0.5 * M) * (D / d)), 2.0) * -0.5)) / l))) else: tmp = (d / (math.sqrt(l) * math.sqrt(h))) * (1.0 + (-0.5 * ((h / l) * math.pow((M * (0.5 * (D / d))), 2.0)))) return tmp
M, D = sort([M, D]) function code(d, h, l, M, D) tmp = 0.0 if (l <= 2e-31) tmp = Float64(sqrt(Float64(d / l)) * Float64(sqrt(Float64(d / h)) * Float64(1.0 + Float64(Float64(h * Float64((Float64(Float64(0.5 * M) * Float64(D / d)) ^ 2.0) * -0.5)) / l)))); else tmp = Float64(Float64(d / Float64(sqrt(l) * sqrt(h))) * Float64(1.0 + Float64(-0.5 * Float64(Float64(h / l) * (Float64(M * Float64(0.5 * Float64(D / d))) ^ 2.0))))); end return tmp end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
tmp = 0.0;
if (l <= 2e-31)
tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0 + ((h * ((((0.5 * M) * (D / d)) ^ 2.0) * -0.5)) / l)));
else
tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 + (-0.5 * ((h / l) * ((M * (0.5 * (D / d))) ^ 2.0))));
end
tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[l, 2e-31], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(N[(h * N[(N[Power[N[(N[(0.5 * M), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(0.5 * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 2 \cdot 10^{-31}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h \cdot \left({\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2} \cdot -0.5\right)}{\ell}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(M \cdot \left(0.5 \cdot \frac{D}{d}\right)\right)}^{2}\right)\right)\\
\end{array}
\end{array}
if l < 2e-31Initial program 73.8%
Simplified72.2%
associate-*l/75.4%
add-sqr-sqrt46.6%
add-sqr-sqrt75.4%
div-inv75.4%
metadata-eval75.4%
Applied egg-rr75.4%
if 2e-31 < l Initial program 52.9%
expm1-log1p-u32.7%
expm1-udef17.7%
Applied egg-rr26.5%
expm1-def45.8%
expm1-log1p71.4%
cancel-sign-sub-inv71.4%
metadata-eval71.4%
associate-*l*71.4%
Simplified71.4%
Final simplification74.3%
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (sqrt (* l h)))
(t_1 (/ d t_0))
(t_2 (* (sqrt (/ d l)) (sqrt (/ d h)))))
(if (<= d -3.9e+128)
t_2
(if (<= d -1.75e+73)
(log1p (expm1 t_1))
(if (<= d -3.5e-17)
t_2
(if (<= d 4.05e-299)
(/ d (+ (exp (log1p t_0)) -1.0))
(*
t_1
(- 1.0 (* (* 0.5 (/ h l)) (pow (* M (/ (* 0.5 D) d)) 2.0))))))))))assert(M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = sqrt((l * h));
double t_1 = d / t_0;
double t_2 = sqrt((d / l)) * sqrt((d / h));
double tmp;
if (d <= -3.9e+128) {
tmp = t_2;
} else if (d <= -1.75e+73) {
tmp = log1p(expm1(t_1));
} else if (d <= -3.5e-17) {
tmp = t_2;
} else if (d <= 4.05e-299) {
tmp = d / (exp(log1p(t_0)) + -1.0);
} else {
tmp = t_1 * (1.0 - ((0.5 * (h / l)) * pow((M * ((0.5 * D) / d)), 2.0)));
}
return tmp;
}
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
double t_0 = Math.sqrt((l * h));
double t_1 = d / t_0;
double t_2 = Math.sqrt((d / l)) * Math.sqrt((d / h));
double tmp;
if (d <= -3.9e+128) {
tmp = t_2;
} else if (d <= -1.75e+73) {
tmp = Math.log1p(Math.expm1(t_1));
} else if (d <= -3.5e-17) {
tmp = t_2;
} else if (d <= 4.05e-299) {
tmp = d / (Math.exp(Math.log1p(t_0)) + -1.0);
} else {
tmp = t_1 * (1.0 - ((0.5 * (h / l)) * Math.pow((M * ((0.5 * D) / d)), 2.0)));
}
return tmp;
}
[M, D] = sort([M, D]) def code(d, h, l, M, D): t_0 = math.sqrt((l * h)) t_1 = d / t_0 t_2 = math.sqrt((d / l)) * math.sqrt((d / h)) tmp = 0 if d <= -3.9e+128: tmp = t_2 elif d <= -1.75e+73: tmp = math.log1p(math.expm1(t_1)) elif d <= -3.5e-17: tmp = t_2 elif d <= 4.05e-299: tmp = d / (math.exp(math.log1p(t_0)) + -1.0) else: tmp = t_1 * (1.0 - ((0.5 * (h / l)) * math.pow((M * ((0.5 * D) / d)), 2.0))) return tmp
M, D = sort([M, D]) function code(d, h, l, M, D) t_0 = sqrt(Float64(l * h)) t_1 = Float64(d / t_0) t_2 = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) tmp = 0.0 if (d <= -3.9e+128) tmp = t_2; elseif (d <= -1.75e+73) tmp = log1p(expm1(t_1)); elseif (d <= -3.5e-17) tmp = t_2; elseif (d <= 4.05e-299) tmp = Float64(d / Float64(exp(log1p(t_0)) + -1.0)); else tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(0.5 * Float64(h / l)) * (Float64(M * Float64(Float64(0.5 * D) / d)) ^ 2.0)))); end return tmp end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(d / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.9e+128], t$95$2, If[LessEqual[d, -1.75e+73], N[Log[1 + N[(Exp[t$95$1] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, -3.5e-17], t$95$2, If[LessEqual[d, 4.05e-299], N[(d / N[(N[Exp[N[Log[1 + t$95$0], $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(1.0 - N[(N[(0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] * N[Power[N[(M * N[(N[(0.5 * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
t_1 := \frac{d}{t_0}\\
t_2 := \sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{if}\;d \leq -3.9 \cdot 10^{+128}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d \leq -1.75 \cdot 10^{+73}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(t_1\right)\right)\\
\mathbf{elif}\;d \leq -3.5 \cdot 10^{-17}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\
\;\;\;\;\frac{d}{e^{\mathsf{log1p}\left(t_0\right)} + -1}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(1 - \left(0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{0.5 \cdot D}{d}\right)}^{2}\right)\\
\end{array}
\end{array}
if d < -3.8999999999999997e128 or -1.75000000000000001e73 < d < -3.5000000000000002e-17Initial program 77.3%
Simplified77.3%
Taylor expanded in d around inf 3.8%
*-commutative3.8%
associate-/r*3.8%
Simplified3.8%
expm1-log1p-u1.1%
expm1-udef1.2%
associate-/l/1.2%
sqrt-div1.2%
metadata-eval1.2%
Applied egg-rr1.2%
expm1-def1.1%
expm1-log1p3.8%
associate-*r/3.8%
*-rgt-identity3.8%
Simplified3.8%
add-sqr-sqrt0.0%
sqrt-prod0.0%
times-frac0.0%
sqrt-div0.0%
unpow1/20.0%
metadata-eval0.0%
sqrt-div63.4%
*-commutative63.4%
metadata-eval63.4%
unpow1/263.4%
Applied egg-rr63.4%
if -3.8999999999999997e128 < d < -1.75000000000000001e73Initial program 80.4%
Simplified80.4%
Taylor expanded in d around inf 9.6%
*-commutative9.6%
associate-/r*9.6%
Simplified9.6%
expm1-log1p-u0.4%
expm1-udef0.3%
associate-/l/0.3%
sqrt-div0.3%
metadata-eval0.3%
Applied egg-rr0.3%
expm1-def0.4%
expm1-log1p9.6%
associate-*r/9.6%
*-rgt-identity9.6%
Simplified9.6%
log1p-expm1-u54.1%
Applied egg-rr54.1%
if -3.5000000000000002e-17 < d < 4.0499999999999998e-299Initial program 58.3%
Simplified58.3%
Taylor expanded in d around inf 19.2%
*-commutative19.2%
associate-/r*19.2%
Simplified19.2%
expm1-log1p-u7.0%
expm1-udef6.7%
associate-/l/6.7%
sqrt-div6.7%
metadata-eval6.7%
Applied egg-rr6.7%
expm1-def7.0%
expm1-log1p19.2%
associate-*r/19.2%
*-rgt-identity19.2%
Simplified19.2%
expm1-log1p-u19.2%
expm1-udef40.7%
Applied egg-rr40.7%
if 4.0499999999999998e-299 < d Initial program 67.3%
add-sqr-sqrt67.3%
pow267.3%
sqrt-prod67.3%
*-commutative67.3%
frac-times66.5%
sqrt-prod66.5%
sqrt-pow169.8%
metadata-eval69.8%
pow169.8%
div-inv69.8%
metadata-eval69.8%
metadata-eval69.8%
Applied egg-rr69.8%
expm1-log1p-u68.9%
expm1-udef45.4%
metadata-eval45.4%
unpow1/245.4%
Applied egg-rr45.4%
expm1-def68.9%
expm1-log1p69.8%
Simplified69.8%
Applied egg-rr62.8%
*-lft-identity62.8%
distribute-rgt-in71.6%
*-commutative71.6%
cancel-sign-sub-inv71.6%
associate-*r*71.6%
associate-*r/71.6%
Simplified71.6%
Final simplification61.7%
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (sqrt (* l h)))
(t_1 (/ d t_0))
(t_2 (pow (/ d h) 0.25))
(t_3 (sqrt (/ d l))))
(if (<= d -6e+126)
(* t_2 (* t_2 t_3))
(if (<= d -1.85e+73)
(log1p (expm1 t_1))
(if (<= d -1.26e-17)
(* t_3 (sqrt (/ d h)))
(if (<= d 4.05e-299)
(/ d (+ (exp (log1p t_0)) -1.0))
(*
t_1
(- 1.0 (* (* 0.5 (/ h l)) (pow (* M (/ (* 0.5 D) d)) 2.0))))))))))assert(M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = sqrt((l * h));
double t_1 = d / t_0;
double t_2 = pow((d / h), 0.25);
double t_3 = sqrt((d / l));
double tmp;
if (d <= -6e+126) {
tmp = t_2 * (t_2 * t_3);
} else if (d <= -1.85e+73) {
tmp = log1p(expm1(t_1));
} else if (d <= -1.26e-17) {
tmp = t_3 * sqrt((d / h));
} else if (d <= 4.05e-299) {
tmp = d / (exp(log1p(t_0)) + -1.0);
} else {
tmp = t_1 * (1.0 - ((0.5 * (h / l)) * pow((M * ((0.5 * D) / d)), 2.0)));
}
return tmp;
}
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
double t_0 = Math.sqrt((l * h));
double t_1 = d / t_0;
double t_2 = Math.pow((d / h), 0.25);
double t_3 = Math.sqrt((d / l));
double tmp;
if (d <= -6e+126) {
tmp = t_2 * (t_2 * t_3);
} else if (d <= -1.85e+73) {
tmp = Math.log1p(Math.expm1(t_1));
} else if (d <= -1.26e-17) {
tmp = t_3 * Math.sqrt((d / h));
} else if (d <= 4.05e-299) {
tmp = d / (Math.exp(Math.log1p(t_0)) + -1.0);
} else {
tmp = t_1 * (1.0 - ((0.5 * (h / l)) * Math.pow((M * ((0.5 * D) / d)), 2.0)));
}
return tmp;
}
[M, D] = sort([M, D]) def code(d, h, l, M, D): t_0 = math.sqrt((l * h)) t_1 = d / t_0 t_2 = math.pow((d / h), 0.25) t_3 = math.sqrt((d / l)) tmp = 0 if d <= -6e+126: tmp = t_2 * (t_2 * t_3) elif d <= -1.85e+73: tmp = math.log1p(math.expm1(t_1)) elif d <= -1.26e-17: tmp = t_3 * math.sqrt((d / h)) elif d <= 4.05e-299: tmp = d / (math.exp(math.log1p(t_0)) + -1.0) else: tmp = t_1 * (1.0 - ((0.5 * (h / l)) * math.pow((M * ((0.5 * D) / d)), 2.0))) return tmp
M, D = sort([M, D]) function code(d, h, l, M, D) t_0 = sqrt(Float64(l * h)) t_1 = Float64(d / t_0) t_2 = Float64(d / h) ^ 0.25 t_3 = sqrt(Float64(d / l)) tmp = 0.0 if (d <= -6e+126) tmp = Float64(t_2 * Float64(t_2 * t_3)); elseif (d <= -1.85e+73) tmp = log1p(expm1(t_1)); elseif (d <= -1.26e-17) tmp = Float64(t_3 * sqrt(Float64(d / h))); elseif (d <= 4.05e-299) tmp = Float64(d / Float64(exp(log1p(t_0)) + -1.0)); else tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(0.5 * Float64(h / l)) * (Float64(M * Float64(Float64(0.5 * D) / d)) ^ 2.0)))); end return tmp end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(d / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(d / h), $MachinePrecision], 0.25], $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -6e+126], N[(t$95$2 * N[(t$95$2 * t$95$3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.85e+73], N[Log[1 + N[(Exp[t$95$1] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, -1.26e-17], N[(t$95$3 * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.05e-299], N[(d / N[(N[Exp[N[Log[1 + t$95$0], $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(1.0 - N[(N[(0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] * N[Power[N[(M * N[(N[(0.5 * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
t_1 := \frac{d}{t_0}\\
t_2 := {\left(\frac{d}{h}\right)}^{0.25}\\
t_3 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;d \leq -6 \cdot 10^{+126}:\\
\;\;\;\;t_2 \cdot \left(t_2 \cdot t_3\right)\\
\mathbf{elif}\;d \leq -1.85 \cdot 10^{+73}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(t_1\right)\right)\\
\mathbf{elif}\;d \leq -1.26 \cdot 10^{-17}:\\
\;\;\;\;t_3 \cdot \sqrt{\frac{d}{h}}\\
\mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\
\;\;\;\;\frac{d}{e^{\mathsf{log1p}\left(t_0\right)} + -1}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(1 - \left(0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{0.5 \cdot D}{d}\right)}^{2}\right)\\
\end{array}
\end{array}
if d < -6.0000000000000005e126Initial program 75.6%
Simplified75.6%
Taylor expanded in d around inf 4.0%
*-commutative4.0%
associate-/r*4.0%
Simplified4.0%
expm1-log1p-u0.5%
expm1-udef0.5%
associate-/l/0.5%
sqrt-div0.5%
metadata-eval0.5%
Applied egg-rr0.5%
expm1-def0.5%
expm1-log1p4.0%
associate-*r/4.0%
*-rgt-identity4.0%
Simplified4.0%
add-sqr-sqrt0.0%
sqrt-prod0.0%
times-frac0.0%
sqrt-div0.0%
unpow1/20.0%
metadata-eval0.0%
sqrt-div62.9%
*-commutative62.9%
add-sqr-sqrt62.9%
associate-*r*62.9%
sqrt-pow163.0%
metadata-eval63.0%
metadata-eval63.0%
sqrt-pow162.9%
metadata-eval62.9%
metadata-eval62.9%
Applied egg-rr62.9%
if -6.0000000000000005e126 < d < -1.84999999999999987e73Initial program 80.4%
Simplified80.4%
Taylor expanded in d around inf 9.6%
*-commutative9.6%
associate-/r*9.6%
Simplified9.6%
expm1-log1p-u0.4%
expm1-udef0.3%
associate-/l/0.3%
sqrt-div0.3%
metadata-eval0.3%
Applied egg-rr0.3%
expm1-def0.4%
expm1-log1p9.6%
associate-*r/9.6%
*-rgt-identity9.6%
Simplified9.6%
log1p-expm1-u54.1%
Applied egg-rr54.1%
if -1.84999999999999987e73 < d < -1.2600000000000001e-17Initial program 81.5%
Simplified81.5%
Taylor expanded in d around inf 3.2%
*-commutative3.2%
associate-/r*3.2%
Simplified3.2%
expm1-log1p-u2.6%
expm1-udef3.0%
associate-/l/3.0%
sqrt-div3.0%
metadata-eval3.0%
Applied egg-rr3.0%
expm1-def2.6%
expm1-log1p3.2%
associate-*r/3.2%
*-rgt-identity3.2%
Simplified3.2%
add-sqr-sqrt0.0%
sqrt-prod0.0%
times-frac0.0%
sqrt-div0.0%
unpow1/20.0%
metadata-eval0.0%
sqrt-div64.5%
*-commutative64.5%
metadata-eval64.5%
unpow1/264.5%
Applied egg-rr64.5%
if -1.2600000000000001e-17 < d < 4.0499999999999998e-299Initial program 58.3%
Simplified58.3%
Taylor expanded in d around inf 19.2%
*-commutative19.2%
associate-/r*19.2%
Simplified19.2%
expm1-log1p-u7.0%
expm1-udef6.7%
associate-/l/6.7%
sqrt-div6.7%
metadata-eval6.7%
Applied egg-rr6.7%
expm1-def7.0%
expm1-log1p19.2%
associate-*r/19.2%
*-rgt-identity19.2%
Simplified19.2%
expm1-log1p-u19.2%
expm1-udef40.7%
Applied egg-rr40.7%
if 4.0499999999999998e-299 < d Initial program 67.3%
add-sqr-sqrt67.3%
pow267.3%
sqrt-prod67.3%
*-commutative67.3%
frac-times66.5%
sqrt-prod66.5%
sqrt-pow169.8%
metadata-eval69.8%
pow169.8%
div-inv69.8%
metadata-eval69.8%
metadata-eval69.8%
Applied egg-rr69.8%
expm1-log1p-u68.9%
expm1-udef45.4%
metadata-eval45.4%
unpow1/245.4%
Applied egg-rr45.4%
expm1-def68.9%
expm1-log1p69.8%
Simplified69.8%
Applied egg-rr62.8%
*-lft-identity62.8%
distribute-rgt-in71.6%
*-commutative71.6%
cancel-sign-sub-inv71.6%
associate-*r*71.6%
associate-*r/71.6%
Simplified71.6%
Final simplification61.7%
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (sqrt (* l h)))
(t_1 (/ d t_0))
(t_2 (* (sqrt (/ d l)) (sqrt (/ d h)))))
(if (<= d -1.66e+125)
t_2
(if (<= d -3.15e+72)
(log1p (expm1 t_1))
(if (<= d -1.3e-17)
t_2
(if (<= d 4.05e-299)
(/ d (log (exp t_0)))
(*
t_1
(- 1.0 (* (* 0.5 (/ h l)) (pow (* M (/ (* 0.5 D) d)) 2.0))))))))))assert(M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = sqrt((l * h));
double t_1 = d / t_0;
double t_2 = sqrt((d / l)) * sqrt((d / h));
double tmp;
if (d <= -1.66e+125) {
tmp = t_2;
} else if (d <= -3.15e+72) {
tmp = log1p(expm1(t_1));
} else if (d <= -1.3e-17) {
tmp = t_2;
} else if (d <= 4.05e-299) {
tmp = d / log(exp(t_0));
} else {
tmp = t_1 * (1.0 - ((0.5 * (h / l)) * pow((M * ((0.5 * D) / d)), 2.0)));
}
return tmp;
}
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
double t_0 = Math.sqrt((l * h));
double t_1 = d / t_0;
double t_2 = Math.sqrt((d / l)) * Math.sqrt((d / h));
double tmp;
if (d <= -1.66e+125) {
tmp = t_2;
} else if (d <= -3.15e+72) {
tmp = Math.log1p(Math.expm1(t_1));
} else if (d <= -1.3e-17) {
tmp = t_2;
} else if (d <= 4.05e-299) {
tmp = d / Math.log(Math.exp(t_0));
} else {
tmp = t_1 * (1.0 - ((0.5 * (h / l)) * Math.pow((M * ((0.5 * D) / d)), 2.0)));
}
return tmp;
}
[M, D] = sort([M, D]) def code(d, h, l, M, D): t_0 = math.sqrt((l * h)) t_1 = d / t_0 t_2 = math.sqrt((d / l)) * math.sqrt((d / h)) tmp = 0 if d <= -1.66e+125: tmp = t_2 elif d <= -3.15e+72: tmp = math.log1p(math.expm1(t_1)) elif d <= -1.3e-17: tmp = t_2 elif d <= 4.05e-299: tmp = d / math.log(math.exp(t_0)) else: tmp = t_1 * (1.0 - ((0.5 * (h / l)) * math.pow((M * ((0.5 * D) / d)), 2.0))) return tmp
M, D = sort([M, D]) function code(d, h, l, M, D) t_0 = sqrt(Float64(l * h)) t_1 = Float64(d / t_0) t_2 = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) tmp = 0.0 if (d <= -1.66e+125) tmp = t_2; elseif (d <= -3.15e+72) tmp = log1p(expm1(t_1)); elseif (d <= -1.3e-17) tmp = t_2; elseif (d <= 4.05e-299) tmp = Float64(d / log(exp(t_0))); else tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(0.5 * Float64(h / l)) * (Float64(M * Float64(Float64(0.5 * D) / d)) ^ 2.0)))); end return tmp end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(d / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.66e+125], t$95$2, If[LessEqual[d, -3.15e+72], N[Log[1 + N[(Exp[t$95$1] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, -1.3e-17], t$95$2, If[LessEqual[d, 4.05e-299], N[(d / N[Log[N[Exp[t$95$0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(1.0 - N[(N[(0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] * N[Power[N[(M * N[(N[(0.5 * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
t_1 := \frac{d}{t_0}\\
t_2 := \sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{if}\;d \leq -1.66 \cdot 10^{+125}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d \leq -3.15 \cdot 10^{+72}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(t_1\right)\right)\\
\mathbf{elif}\;d \leq -1.3 \cdot 10^{-17}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\
\;\;\;\;\frac{d}{\log \left(e^{t_0}\right)}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(1 - \left(0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{0.5 \cdot D}{d}\right)}^{2}\right)\\
\end{array}
\end{array}
if d < -1.66000000000000005e125 or -3.14999999999999981e72 < d < -1.30000000000000002e-17Initial program 77.3%
Simplified77.3%
Taylor expanded in d around inf 3.8%
*-commutative3.8%
associate-/r*3.8%
Simplified3.8%
expm1-log1p-u1.1%
expm1-udef1.2%
associate-/l/1.2%
sqrt-div1.2%
metadata-eval1.2%
Applied egg-rr1.2%
expm1-def1.1%
expm1-log1p3.8%
associate-*r/3.8%
*-rgt-identity3.8%
Simplified3.8%
add-sqr-sqrt0.0%
sqrt-prod0.0%
times-frac0.0%
sqrt-div0.0%
unpow1/20.0%
metadata-eval0.0%
sqrt-div63.4%
*-commutative63.4%
metadata-eval63.4%
unpow1/263.4%
Applied egg-rr63.4%
if -1.66000000000000005e125 < d < -3.14999999999999981e72Initial program 80.4%
Simplified80.4%
Taylor expanded in d around inf 9.6%
*-commutative9.6%
associate-/r*9.6%
Simplified9.6%
expm1-log1p-u0.4%
expm1-udef0.3%
associate-/l/0.3%
sqrt-div0.3%
metadata-eval0.3%
Applied egg-rr0.3%
expm1-def0.4%
expm1-log1p9.6%
associate-*r/9.6%
*-rgt-identity9.6%
Simplified9.6%
log1p-expm1-u54.1%
Applied egg-rr54.1%
if -1.30000000000000002e-17 < d < 4.0499999999999998e-299Initial program 58.3%
Simplified58.3%
Taylor expanded in d around inf 19.2%
*-commutative19.2%
associate-/r*19.2%
Simplified19.2%
expm1-log1p-u7.0%
expm1-udef6.7%
associate-/l/6.7%
sqrt-div6.7%
metadata-eval6.7%
Applied egg-rr6.7%
expm1-def7.0%
expm1-log1p19.2%
associate-*r/19.2%
*-rgt-identity19.2%
Simplified19.2%
add-log-exp40.7%
Applied egg-rr40.7%
if 4.0499999999999998e-299 < d Initial program 67.3%
add-sqr-sqrt67.3%
pow267.3%
sqrt-prod67.3%
*-commutative67.3%
frac-times66.5%
sqrt-prod66.5%
sqrt-pow169.8%
metadata-eval69.8%
pow169.8%
div-inv69.8%
metadata-eval69.8%
metadata-eval69.8%
Applied egg-rr69.8%
expm1-log1p-u68.9%
expm1-udef45.4%
metadata-eval45.4%
unpow1/245.4%
Applied egg-rr45.4%
expm1-def68.9%
expm1-log1p69.8%
Simplified69.8%
Applied egg-rr62.8%
*-lft-identity62.8%
distribute-rgt-in71.6%
*-commutative71.6%
cancel-sign-sub-inv71.6%
associate-*r*71.6%
associate-*r/71.6%
Simplified71.6%
Final simplification61.7%
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (/ d (sqrt (* l h)))) (t_1 (* (sqrt (/ d l)) (sqrt (/ d h)))))
(if (<= d -1e+125)
t_1
(if (<= d -4.6e+67)
(log1p (expm1 t_0))
(if (<= d -6e-140)
t_1
(if (<= d 4.05e-299)
(/ d (cbrt (pow (* l h) 1.5)))
(*
t_0
(- 1.0 (* (* 0.5 (/ h l)) (pow (* M (/ (* 0.5 D) d)) 2.0))))))))))assert(M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = d / sqrt((l * h));
double t_1 = sqrt((d / l)) * sqrt((d / h));
double tmp;
if (d <= -1e+125) {
tmp = t_1;
} else if (d <= -4.6e+67) {
tmp = log1p(expm1(t_0));
} else if (d <= -6e-140) {
tmp = t_1;
} else if (d <= 4.05e-299) {
tmp = d / cbrt(pow((l * h), 1.5));
} else {
tmp = t_0 * (1.0 - ((0.5 * (h / l)) * pow((M * ((0.5 * D) / d)), 2.0)));
}
return tmp;
}
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
double t_0 = d / Math.sqrt((l * h));
double t_1 = Math.sqrt((d / l)) * Math.sqrt((d / h));
double tmp;
if (d <= -1e+125) {
tmp = t_1;
} else if (d <= -4.6e+67) {
tmp = Math.log1p(Math.expm1(t_0));
} else if (d <= -6e-140) {
tmp = t_1;
} else if (d <= 4.05e-299) {
tmp = d / Math.cbrt(Math.pow((l * h), 1.5));
} else {
tmp = t_0 * (1.0 - ((0.5 * (h / l)) * Math.pow((M * ((0.5 * D) / d)), 2.0)));
}
return tmp;
}
M, D = sort([M, D]) function code(d, h, l, M, D) t_0 = Float64(d / sqrt(Float64(l * h))) t_1 = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) tmp = 0.0 if (d <= -1e+125) tmp = t_1; elseif (d <= -4.6e+67) tmp = log1p(expm1(t_0)); elseif (d <= -6e-140) tmp = t_1; elseif (d <= 4.05e-299) tmp = Float64(d / cbrt((Float64(l * h) ^ 1.5))); else tmp = Float64(t_0 * Float64(1.0 - Float64(Float64(0.5 * Float64(h / l)) * (Float64(M * Float64(Float64(0.5 * D) / d)) ^ 2.0)))); end return tmp end
NOTE: M and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1e+125], t$95$1, If[LessEqual[d, -4.6e+67], N[Log[1 + N[(Exp[t$95$0] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, -6e-140], t$95$1, If[LessEqual[d, 4.05e-299], N[(d / N[Power[N[Power[N[(l * h), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(1.0 - N[(N[(0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] * N[Power[N[(M * N[(N[(0.5 * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := \frac{d}{\sqrt{\ell \cdot h}}\\
t_1 := \sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{if}\;d \leq -1 \cdot 10^{+125}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq -4.6 \cdot 10^{+67}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(t_0\right)\right)\\
\mathbf{elif}\;d \leq -6 \cdot 10^{-140}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\
\;\;\;\;\frac{d}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(1 - \left(0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{0.5 \cdot D}{d}\right)}^{2}\right)\\
\end{array}
\end{array}
if d < -9.9999999999999992e124 or -4.5999999999999997e67 < d < -6.00000000000000037e-140Initial program 77.3%
Simplified77.3%
Taylor expanded in d around inf 7.0%
*-commutative7.0%
associate-/r*7.0%
Simplified7.0%
expm1-log1p-u1.3%
expm1-udef1.3%
associate-/l/1.3%
sqrt-div1.3%
metadata-eval1.3%
Applied egg-rr1.3%
expm1-def1.3%
expm1-log1p7.0%
associate-*r/7.0%
*-rgt-identity7.0%
Simplified7.0%
add-sqr-sqrt0.0%
sqrt-prod0.0%
times-frac0.0%
sqrt-div0.0%
unpow1/20.0%
metadata-eval0.0%
sqrt-div51.1%
*-commutative51.1%
metadata-eval51.1%
unpow1/251.1%
Applied egg-rr51.1%
if -9.9999999999999992e124 < d < -4.5999999999999997e67Initial program 80.4%
Simplified80.4%
Taylor expanded in d around inf 9.6%
*-commutative9.6%
associate-/r*9.6%
Simplified9.6%
expm1-log1p-u0.4%
expm1-udef0.3%
associate-/l/0.3%
sqrt-div0.3%
metadata-eval0.3%
Applied egg-rr0.3%
expm1-def0.4%
expm1-log1p9.6%
associate-*r/9.6%
*-rgt-identity9.6%
Simplified9.6%
log1p-expm1-u54.1%
Applied egg-rr54.1%
if -6.00000000000000037e-140 < d < 4.0499999999999998e-299Initial program 43.5%
Simplified43.5%
Taylor expanded in d around inf 23.4%
*-commutative23.4%
associate-/r*23.4%
Simplified23.4%
expm1-log1p-u11.0%
expm1-udef10.7%
associate-/l/10.7%
sqrt-div10.7%
metadata-eval10.7%
Applied egg-rr10.7%
expm1-def11.0%
expm1-log1p23.4%
associate-*r/23.4%
*-rgt-identity23.4%
Simplified23.4%
add-cbrt-cube38.2%
pow1/338.2%
add-sqr-sqrt38.2%
pow138.2%
pow1/238.2%
metadata-eval38.2%
pow-prod-up38.2%
metadata-eval38.2%
metadata-eval38.2%
Applied egg-rr38.2%
unpow1/338.2%
Simplified38.2%
if 4.0499999999999998e-299 < d Initial program 67.3%
add-sqr-sqrt67.3%
pow267.3%
sqrt-prod67.3%
*-commutative67.3%
frac-times66.5%
sqrt-prod66.5%
sqrt-pow169.8%
metadata-eval69.8%
pow169.8%
div-inv69.8%
metadata-eval69.8%
metadata-eval69.8%
Applied egg-rr69.8%
expm1-log1p-u68.9%
expm1-udef45.4%
metadata-eval45.4%
unpow1/245.4%
Applied egg-rr45.4%
expm1-def68.9%
expm1-log1p69.8%
Simplified69.8%
Applied egg-rr62.8%
*-lft-identity62.8%
distribute-rgt-in71.6%
*-commutative71.6%
cancel-sign-sub-inv71.6%
associate-*r*71.6%
associate-*r/71.6%
Simplified71.6%
Final simplification59.8%
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(if (<= d -2.8e-139)
(* (sqrt (/ d l)) (sqrt (/ d h)))
(if (<= d 4.05e-299)
(/ d (cbrt (pow (* l h) 1.5)))
(*
(/ d (sqrt (* l h)))
(- 1.0 (* (* 0.5 (/ h l)) (pow (* M (/ (* 0.5 D) d)) 2.0)))))))assert(M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (d <= -2.8e-139) {
tmp = sqrt((d / l)) * sqrt((d / h));
} else if (d <= 4.05e-299) {
tmp = d / cbrt(pow((l * h), 1.5));
} else {
tmp = (d / sqrt((l * h))) * (1.0 - ((0.5 * (h / l)) * pow((M * ((0.5 * D) / d)), 2.0)));
}
return tmp;
}
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (d <= -2.8e-139) {
tmp = Math.sqrt((d / l)) * Math.sqrt((d / h));
} else if (d <= 4.05e-299) {
tmp = d / Math.cbrt(Math.pow((l * h), 1.5));
} else {
tmp = (d / Math.sqrt((l * h))) * (1.0 - ((0.5 * (h / l)) * Math.pow((M * ((0.5 * D) / d)), 2.0)));
}
return tmp;
}
M, D = sort([M, D]) function code(d, h, l, M, D) tmp = 0.0 if (d <= -2.8e-139) tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))); elseif (d <= 4.05e-299) tmp = Float64(d / cbrt((Float64(l * h) ^ 1.5))); else tmp = Float64(Float64(d / sqrt(Float64(l * h))) * Float64(1.0 - Float64(Float64(0.5 * Float64(h / l)) * (Float64(M * Float64(Float64(0.5 * D) / d)) ^ 2.0)))); end return tmp end
NOTE: M and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[d, -2.8e-139], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.05e-299], N[(d / N[Power[N[Power[N[(l * h), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] * N[Power[N[(M * N[(N[(0.5 * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.8 \cdot 10^{-139}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{elif}\;d \leq 4.05 \cdot 10^{-299}:\\
\;\;\;\;\frac{d}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(0.5 \cdot \frac{h}{\ell}\right) \cdot {\left(M \cdot \frac{0.5 \cdot D}{d}\right)}^{2}\right)\\
\end{array}
\end{array}
if d < -2.7999999999999999e-139Initial program 77.8%
Simplified77.8%
Taylor expanded in d around inf 7.4%
*-commutative7.4%
associate-/r*7.4%
Simplified7.4%
expm1-log1p-u1.2%
expm1-udef1.1%
associate-/l/1.1%
sqrt-div1.1%
metadata-eval1.1%
Applied egg-rr1.1%
expm1-def1.2%
expm1-log1p7.4%
associate-*r/7.4%
*-rgt-identity7.4%
Simplified7.4%
add-sqr-sqrt0.0%
sqrt-prod0.0%
times-frac0.0%
sqrt-div0.0%
unpow1/20.0%
metadata-eval0.0%
sqrt-div46.3%
*-commutative46.3%
metadata-eval46.3%
unpow1/246.3%
Applied egg-rr46.3%
if -2.7999999999999999e-139 < d < 4.0499999999999998e-299Initial program 43.5%
Simplified43.5%
Taylor expanded in d around inf 23.4%
*-commutative23.4%
associate-/r*23.4%
Simplified23.4%
expm1-log1p-u11.0%
expm1-udef10.7%
associate-/l/10.7%
sqrt-div10.7%
metadata-eval10.7%
Applied egg-rr10.7%
expm1-def11.0%
expm1-log1p23.4%
associate-*r/23.4%
*-rgt-identity23.4%
Simplified23.4%
add-cbrt-cube38.2%
pow1/338.2%
add-sqr-sqrt38.2%
pow138.2%
pow1/238.2%
metadata-eval38.2%
pow-prod-up38.2%
metadata-eval38.2%
metadata-eval38.2%
Applied egg-rr38.2%
unpow1/338.2%
Simplified38.2%
if 4.0499999999999998e-299 < d Initial program 67.3%
add-sqr-sqrt67.3%
pow267.3%
sqrt-prod67.3%
*-commutative67.3%
frac-times66.5%
sqrt-prod66.5%
sqrt-pow169.8%
metadata-eval69.8%
pow169.8%
div-inv69.8%
metadata-eval69.8%
metadata-eval69.8%
Applied egg-rr69.8%
expm1-log1p-u68.9%
expm1-udef45.4%
metadata-eval45.4%
unpow1/245.4%
Applied egg-rr45.4%
expm1-def68.9%
expm1-log1p69.8%
Simplified69.8%
Applied egg-rr62.8%
*-lft-identity62.8%
distribute-rgt-in71.6%
*-commutative71.6%
cancel-sign-sub-inv71.6%
associate-*r*71.6%
associate-*r/71.6%
Simplified71.6%
Final simplification57.8%
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(if (<= d -1.42e-142)
(sqrt (/ (pow d 2.0) (* l h)))
(if (<= d 3.8e-66)
(* d (sqrt (/ (/ 1.0 l) h)))
(* d (/ (pow l -0.5) (sqrt h))))))assert(M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (d <= -1.42e-142) {
tmp = sqrt((pow(d, 2.0) / (l * h)));
} else if (d <= 3.8e-66) {
tmp = d * sqrt(((1.0 / l) / h));
} else {
tmp = d * (pow(l, -0.5) / sqrt(h));
}
return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: tmp
if (d <= (-1.42d-142)) then
tmp = sqrt(((d ** 2.0d0) / (l * h)))
else if (d <= 3.8d-66) then
tmp = d * sqrt(((1.0d0 / l) / h))
else
tmp = d * ((l ** (-0.5d0)) / sqrt(h))
end if
code = tmp
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (d <= -1.42e-142) {
tmp = Math.sqrt((Math.pow(d, 2.0) / (l * h)));
} else if (d <= 3.8e-66) {
tmp = d * Math.sqrt(((1.0 / l) / h));
} else {
tmp = d * (Math.pow(l, -0.5) / Math.sqrt(h));
}
return tmp;
}
[M, D] = sort([M, D]) def code(d, h, l, M, D): tmp = 0 if d <= -1.42e-142: tmp = math.sqrt((math.pow(d, 2.0) / (l * h))) elif d <= 3.8e-66: tmp = d * math.sqrt(((1.0 / l) / h)) else: tmp = d * (math.pow(l, -0.5) / math.sqrt(h)) return tmp
M, D = sort([M, D]) function code(d, h, l, M, D) tmp = 0.0 if (d <= -1.42e-142) tmp = sqrt(Float64((d ^ 2.0) / Float64(l * h))); elseif (d <= 3.8e-66) tmp = Float64(d * sqrt(Float64(Float64(1.0 / l) / h))); else tmp = Float64(d * Float64((l ^ -0.5) / sqrt(h))); end return tmp end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
tmp = 0.0;
if (d <= -1.42e-142)
tmp = sqrt(((d ^ 2.0) / (l * h)));
elseif (d <= 3.8e-66)
tmp = d * sqrt(((1.0 / l) / h));
else
tmp = d * ((l ^ -0.5) / sqrt(h));
end
tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[d, -1.42e-142], N[Sqrt[N[(N[Power[d, 2.0], $MachinePrecision] / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, 3.8e-66], N[(d * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.42 \cdot 10^{-142}:\\
\;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\
\mathbf{elif}\;d \leq 3.8 \cdot 10^{-66}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\sqrt{h}}\\
\end{array}
\end{array}
if d < -1.42000000000000007e-142Initial program 77.8%
Simplified77.8%
Taylor expanded in d around inf 7.4%
*-commutative7.4%
associate-/r*7.4%
Simplified7.4%
expm1-log1p-u1.2%
expm1-udef1.1%
associate-/l/1.1%
sqrt-div1.1%
metadata-eval1.1%
Applied egg-rr1.1%
expm1-def1.2%
expm1-log1p7.4%
associate-*r/7.4%
*-rgt-identity7.4%
Simplified7.4%
add-sqr-sqrt0.0%
sqrt-prod0.0%
times-frac0.0%
sqrt-div0.0%
unpow1/20.0%
metadata-eval0.0%
sqrt-div46.3%
pow1/246.3%
metadata-eval46.3%
pow-prod-down35.4%
Applied egg-rr29.1%
unpow1/229.1%
Simplified29.1%
if -1.42000000000000007e-142 < d < 3.7999999999999998e-66Initial program 48.8%
Simplified47.6%
Taylor expanded in d around inf 22.4%
*-commutative22.4%
associate-/r*23.4%
Simplified23.4%
if 3.7999999999999998e-66 < d Initial program 78.6%
Simplified78.6%
Taylor expanded in d around inf 52.5%
*-commutative52.5%
associate-/r*53.4%
Simplified53.4%
sqrt-div58.9%
inv-pow58.9%
sqrt-pow158.9%
metadata-eval58.9%
Applied egg-rr58.9%
Final simplification35.7%
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(if (<= d -9e-140)
(sqrt (/ (pow d 2.0) (* l h)))
(if (<= d 7.8e-266)
(/ d (cbrt (pow (* l h) 1.5)))
(* d (/ (pow l -0.5) (sqrt h))))))assert(M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (d <= -9e-140) {
tmp = sqrt((pow(d, 2.0) / (l * h)));
} else if (d <= 7.8e-266) {
tmp = d / cbrt(pow((l * h), 1.5));
} else {
tmp = d * (pow(l, -0.5) / sqrt(h));
}
return tmp;
}
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (d <= -9e-140) {
tmp = Math.sqrt((Math.pow(d, 2.0) / (l * h)));
} else if (d <= 7.8e-266) {
tmp = d / Math.cbrt(Math.pow((l * h), 1.5));
} else {
tmp = d * (Math.pow(l, -0.5) / Math.sqrt(h));
}
return tmp;
}
M, D = sort([M, D]) function code(d, h, l, M, D) tmp = 0.0 if (d <= -9e-140) tmp = sqrt(Float64((d ^ 2.0) / Float64(l * h))); elseif (d <= 7.8e-266) tmp = Float64(d / cbrt((Float64(l * h) ^ 1.5))); else tmp = Float64(d * Float64((l ^ -0.5) / sqrt(h))); end return tmp end
NOTE: M and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[d, -9e-140], N[Sqrt[N[(N[Power[d, 2.0], $MachinePrecision] / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, 7.8e-266], N[(d / N[Power[N[Power[N[(l * h), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -9 \cdot 10^{-140}:\\
\;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\
\mathbf{elif}\;d \leq 7.8 \cdot 10^{-266}:\\
\;\;\;\;\frac{d}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\sqrt{h}}\\
\end{array}
\end{array}
if d < -9.00000000000000008e-140Initial program 77.8%
Simplified77.8%
Taylor expanded in d around inf 7.4%
*-commutative7.4%
associate-/r*7.4%
Simplified7.4%
expm1-log1p-u1.2%
expm1-udef1.1%
associate-/l/1.1%
sqrt-div1.1%
metadata-eval1.1%
Applied egg-rr1.1%
expm1-def1.2%
expm1-log1p7.4%
associate-*r/7.4%
*-rgt-identity7.4%
Simplified7.4%
add-sqr-sqrt0.0%
sqrt-prod0.0%
times-frac0.0%
sqrt-div0.0%
unpow1/20.0%
metadata-eval0.0%
sqrt-div46.3%
pow1/246.3%
metadata-eval46.3%
pow-prod-down35.4%
Applied egg-rr29.1%
unpow1/229.1%
Simplified29.1%
if -9.00000000000000008e-140 < d < 7.80000000000000057e-266Initial program 44.2%
Simplified44.2%
Taylor expanded in d around inf 23.6%
*-commutative23.6%
associate-/r*23.6%
Simplified23.6%
expm1-log1p-u12.6%
expm1-udef10.0%
associate-/l/10.0%
sqrt-div10.0%
metadata-eval10.0%
Applied egg-rr10.0%
expm1-def12.6%
expm1-log1p23.6%
associate-*r/23.6%
*-rgt-identity23.6%
Simplified23.6%
add-cbrt-cube36.9%
pow1/336.7%
add-sqr-sqrt36.7%
pow136.7%
pow1/236.7%
metadata-eval36.7%
pow-prod-up36.7%
metadata-eval36.7%
metadata-eval36.7%
Applied egg-rr36.7%
unpow1/336.9%
Simplified36.9%
if 7.80000000000000057e-266 < d Initial program 67.8%
Simplified67.0%
Taylor expanded in d around inf 39.9%
*-commutative39.9%
associate-/r*41.1%
Simplified41.1%
sqrt-div44.4%
inv-pow44.4%
sqrt-pow144.4%
metadata-eval44.4%
Applied egg-rr44.4%
Final simplification37.6%
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(if (<= d -2.45e-139)
(* (sqrt (/ d l)) (sqrt (/ d h)))
(if (<= d 7.8e-266)
(/ d (cbrt (pow (* l h) 1.5)))
(* d (/ (pow l -0.5) (sqrt h))))))assert(M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (d <= -2.45e-139) {
tmp = sqrt((d / l)) * sqrt((d / h));
} else if (d <= 7.8e-266) {
tmp = d / cbrt(pow((l * h), 1.5));
} else {
tmp = d * (pow(l, -0.5) / sqrt(h));
}
return tmp;
}
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (d <= -2.45e-139) {
tmp = Math.sqrt((d / l)) * Math.sqrt((d / h));
} else if (d <= 7.8e-266) {
tmp = d / Math.cbrt(Math.pow((l * h), 1.5));
} else {
tmp = d * (Math.pow(l, -0.5) / Math.sqrt(h));
}
return tmp;
}
M, D = sort([M, D]) function code(d, h, l, M, D) tmp = 0.0 if (d <= -2.45e-139) tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))); elseif (d <= 7.8e-266) tmp = Float64(d / cbrt((Float64(l * h) ^ 1.5))); else tmp = Float64(d * Float64((l ^ -0.5) / sqrt(h))); end return tmp end
NOTE: M and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[d, -2.45e-139], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7.8e-266], N[(d / N[Power[N[Power[N[(l * h), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.45 \cdot 10^{-139}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{elif}\;d \leq 7.8 \cdot 10^{-266}:\\
\;\;\;\;\frac{d}{\sqrt[3]{{\left(\ell \cdot h\right)}^{1.5}}}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\sqrt{h}}\\
\end{array}
\end{array}
if d < -2.45000000000000016e-139Initial program 77.8%
Simplified77.8%
Taylor expanded in d around inf 7.4%
*-commutative7.4%
associate-/r*7.4%
Simplified7.4%
expm1-log1p-u1.2%
expm1-udef1.1%
associate-/l/1.1%
sqrt-div1.1%
metadata-eval1.1%
Applied egg-rr1.1%
expm1-def1.2%
expm1-log1p7.4%
associate-*r/7.4%
*-rgt-identity7.4%
Simplified7.4%
add-sqr-sqrt0.0%
sqrt-prod0.0%
times-frac0.0%
sqrt-div0.0%
unpow1/20.0%
metadata-eval0.0%
sqrt-div46.3%
*-commutative46.3%
metadata-eval46.3%
unpow1/246.3%
Applied egg-rr46.3%
if -2.45000000000000016e-139 < d < 7.80000000000000057e-266Initial program 44.2%
Simplified44.2%
Taylor expanded in d around inf 23.6%
*-commutative23.6%
associate-/r*23.6%
Simplified23.6%
expm1-log1p-u12.6%
expm1-udef10.0%
associate-/l/10.0%
sqrt-div10.0%
metadata-eval10.0%
Applied egg-rr10.0%
expm1-def12.6%
expm1-log1p23.6%
associate-*r/23.6%
*-rgt-identity23.6%
Simplified23.6%
add-cbrt-cube36.9%
pow1/336.7%
add-sqr-sqrt36.7%
pow136.7%
pow1/236.7%
metadata-eval36.7%
pow-prod-up36.7%
metadata-eval36.7%
metadata-eval36.7%
Applied egg-rr36.7%
unpow1/336.9%
Simplified36.9%
if 7.80000000000000057e-266 < d Initial program 67.8%
Simplified67.0%
Taylor expanded in d around inf 39.9%
*-commutative39.9%
associate-/r*41.1%
Simplified41.1%
sqrt-div44.4%
inv-pow44.4%
sqrt-pow144.4%
metadata-eval44.4%
Applied egg-rr44.4%
Final simplification44.0%
NOTE: M and D should be sorted in increasing order before calling this function. (FPCore (d h l M D) :precision binary64 (if (<= d -2.85e-140) (sqrt (/ (pow d 2.0) (* l h))) (* d (sqrt (/ (/ 1.0 l) h)))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (d <= -2.85e-140) {
tmp = sqrt((pow(d, 2.0) / (l * h)));
} else {
tmp = d * sqrt(((1.0 / l) / h));
}
return tmp;
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: tmp
if (d <= (-2.85d-140)) then
tmp = sqrt(((d ** 2.0d0) / (l * h)))
else
tmp = d * sqrt(((1.0d0 / l) / h))
end if
code = tmp
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (d <= -2.85e-140) {
tmp = Math.sqrt((Math.pow(d, 2.0) / (l * h)));
} else {
tmp = d * Math.sqrt(((1.0 / l) / h));
}
return tmp;
}
[M, D] = sort([M, D]) def code(d, h, l, M, D): tmp = 0 if d <= -2.85e-140: tmp = math.sqrt((math.pow(d, 2.0) / (l * h))) else: tmp = d * math.sqrt(((1.0 / l) / h)) return tmp
M, D = sort([M, D]) function code(d, h, l, M, D) tmp = 0.0 if (d <= -2.85e-140) tmp = sqrt(Float64((d ^ 2.0) / Float64(l * h))); else tmp = Float64(d * sqrt(Float64(Float64(1.0 / l) / h))); end return tmp end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(d, h, l, M, D)
tmp = 0.0;
if (d <= -2.85e-140)
tmp = sqrt(((d ^ 2.0) / (l * h)));
else
tmp = d * sqrt(((1.0 / l) / h));
end
tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[d, -2.85e-140], N[Sqrt[N[(N[Power[d, 2.0], $MachinePrecision] / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(d * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.85 \cdot 10^{-140}:\\
\;\;\;\;\sqrt{\frac{{d}^{2}}{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\
\end{array}
\end{array}
if d < -2.85e-140Initial program 77.8%
Simplified77.8%
Taylor expanded in d around inf 7.4%
*-commutative7.4%
associate-/r*7.4%
Simplified7.4%
expm1-log1p-u1.2%
expm1-udef1.1%
associate-/l/1.1%
sqrt-div1.1%
metadata-eval1.1%
Applied egg-rr1.1%
expm1-def1.2%
expm1-log1p7.4%
associate-*r/7.4%
*-rgt-identity7.4%
Simplified7.4%
add-sqr-sqrt0.0%
sqrt-prod0.0%
times-frac0.0%
sqrt-div0.0%
unpow1/20.0%
metadata-eval0.0%
sqrt-div46.3%
pow1/246.3%
metadata-eval46.3%
pow-prod-down35.4%
Applied egg-rr29.1%
unpow1/229.1%
Simplified29.1%
if -2.85e-140 < d Initial program 62.4%
Simplified61.7%
Taylor expanded in d around inf 36.1%
*-commutative36.1%
associate-/r*37.1%
Simplified37.1%
Final simplification34.1%
NOTE: 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(M < D);
double code(double d, double h, double l, double M, double D) {
return d * sqrt(((1.0 / l) / h));
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = d * sqrt(((1.0d0 / l) / h))
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
return d * Math.sqrt(((1.0 / l) / h));
}
[M, D] = sort([M, D]) def code(d, h, l, M, D): return d * math.sqrt(((1.0 / l) / h))
M, D = sort([M, D]) function code(d, h, l, M, D) return Float64(d * sqrt(Float64(Float64(1.0 / l) / h))) end
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
tmp = d * sqrt(((1.0 / l) / h));
end
NOTE: M and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := N[(d * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}
\end{array}
Initial program 68.1%
Simplified67.8%
Taylor expanded in d around inf 25.4%
*-commutative25.4%
associate-/r*26.0%
Simplified26.0%
Final simplification26.0%
NOTE: M and D should be sorted in increasing order before calling this function. (FPCore (d h l M D) :precision binary64 (/ d (sqrt (* l h))))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
return d / sqrt((l * h));
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = d / sqrt((l * h))
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
return d / Math.sqrt((l * h));
}
[M, D] = sort([M, D]) def code(d, h, l, M, D): return d / math.sqrt((l * h))
M, D = sort([M, D]) function code(d, h, l, M, D) return Float64(d / sqrt(Float64(l * h))) end
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
tmp = d / sqrt((l * h));
end
NOTE: M and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\frac{d}{\sqrt{\ell \cdot h}}
\end{array}
Initial program 68.1%
Simplified67.8%
Taylor expanded in d around inf 25.4%
*-commutative25.4%
associate-/r*26.0%
Simplified26.0%
expm1-log1p-u21.3%
expm1-udef15.1%
associate-/l/14.8%
sqrt-div14.8%
metadata-eval14.8%
Applied egg-rr14.8%
expm1-def20.7%
expm1-log1p25.3%
associate-*r/25.4%
*-rgt-identity25.4%
Simplified25.4%
Final simplification25.4%
NOTE: M and D should be sorted in increasing order before calling this function. (FPCore (d h l M D) :precision binary64 (* d 0.0))
assert(M < D);
double code(double d, double h, double l, double M, double D) {
return d * 0.0;
}
NOTE: M and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = d * 0.0d0
end function
assert M < D;
public static double code(double d, double h, double l, double M, double D) {
return d * 0.0;
}
[M, D] = sort([M, D]) def code(d, h, l, M, D): return d * 0.0
M, D = sort([M, D]) function code(d, h, l, M, D) return Float64(d * 0.0) end
M, D = num2cell(sort([M, D])){:}
function tmp = code(d, h, l, M, D)
tmp = d * 0.0;
end
NOTE: M and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := N[(d * 0.0), $MachinePrecision]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
d \cdot 0
\end{array}
Initial program 68.1%
Simplified67.8%
Taylor expanded in d around inf 25.4%
*-commutative25.4%
associate-/r*26.0%
Simplified26.0%
expm1-log1p-u25.6%
expm1-udef18.1%
associate-/l/18.1%
sqrt-div18.1%
metadata-eval18.1%
Applied egg-rr18.1%
Taylor expanded in h around inf 3.5%
Final simplification3.5%
herbie shell --seed 2023312
(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)))))