
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (/ d l))) (t_1 (/ (sqrt (- d)) (sqrt (- h)))))
(if (<= l -2e+40)
(*
t_1
(* t_0 (fma (/ h l) (* (pow (/ D_m (* d (/ 2.0 M_m))) 2.0) -0.5) 1.0)))
(if (<= l -1e-309)
(*
t_1
(*
t_0
(+ 1.0 (/ (* h (* -0.5 (pow (* (* M_m 0.5) (/ D_m d)) 2.0))) l))))
(*
(fma h (/ (pow (* M_m (* 0.5 (/ D_m d))) 2.0) (/ l -0.5)) 1.0)
(/ d (* (sqrt h) (sqrt l))))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((d / l));
double t_1 = sqrt(-d) / sqrt(-h);
double tmp;
if (l <= -2e+40) {
tmp = t_1 * (t_0 * fma((h / l), (pow((D_m / (d * (2.0 / M_m))), 2.0) * -0.5), 1.0));
} else if (l <= -1e-309) {
tmp = t_1 * (t_0 * (1.0 + ((h * (-0.5 * pow(((M_m * 0.5) * (D_m / d)), 2.0))) / l)));
} else {
tmp = fma(h, (pow((M_m * (0.5 * (D_m / d))), 2.0) / (l / -0.5)), 1.0) * (d / (sqrt(h) * sqrt(l)));
}
return tmp;
}
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = sqrt(Float64(d / l)) t_1 = Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) tmp = 0.0 if (l <= -2e+40) tmp = Float64(t_1 * Float64(t_0 * fma(Float64(h / l), Float64((Float64(D_m / Float64(d * Float64(2.0 / M_m))) ^ 2.0) * -0.5), 1.0))); elseif (l <= -1e-309) tmp = Float64(t_1 * Float64(t_0 * Float64(1.0 + Float64(Float64(h * Float64(-0.5 * (Float64(Float64(M_m * 0.5) * Float64(D_m / d)) ^ 2.0))) / l)))); else tmp = Float64(fma(h, Float64((Float64(M_m * Float64(0.5 * Float64(D_m / d))) ^ 2.0) / Float64(l / -0.5)), 1.0) * Float64(d / Float64(sqrt(h) * sqrt(l)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2e+40], N[(t$95$1 * N[(t$95$0 * N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(D$95$m / N[(d * N[(2.0 / M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -1e-309], N[(t$95$1 * N[(t$95$0 * N[(1.0 + N[(N[(h * N[(-0.5 * N[Power[N[(N[(M$95$m * 0.5), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(h * N[(N[Power[N[(M$95$m * N[(0.5 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / N[(l / -0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
t_1 := \frac{\sqrt{-d}}{\sqrt{-h}}\\
\mathbf{if}\;\ell \leq -2 \cdot 10^{+40}:\\
\;\;\;\;t\_1 \cdot \left(t\_0 \cdot \mathsf{fma}\left(\frac{h}{\ell}, {\left(\frac{D\_m}{d \cdot \frac{2}{M\_m}}\right)}^{2} \cdot -0.5, 1\right)\right)\\
\mathbf{elif}\;\ell \leq -1 \cdot 10^{-309}:\\
\;\;\;\;t\_1 \cdot \left(t\_0 \cdot \left(1 + \frac{h \cdot \left(-0.5 \cdot {\left(\left(M\_m \cdot 0.5\right) \cdot \frac{D\_m}{d}\right)}^{2}\right)}{\ell}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(h, \frac{{\left(M\_m \cdot \left(0.5 \cdot \frac{D\_m}{d}\right)\right)}^{2}}{\frac{\ell}{-0.5}}, 1\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if l < -2.00000000000000006e40Initial program 56.2%
Simplified54.5%
frac-2neg54.5%
sqrt-div66.5%
Applied egg-rr66.5%
if -2.00000000000000006e40 < l < -1.000000000000002e-309Initial program 72.2%
Simplified72.2%
associate-*l/76.9%
Applied egg-rr76.9%
frac-2neg70.7%
sqrt-div84.9%
Applied egg-rr91.1%
if -1.000000000000002e-309 < l Initial program 57.1%
Applied egg-rr31.0%
expm1-def40.3%
expm1-log1p73.2%
*-commutative73.2%
Simplified80.2%
Final simplification79.7%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= d -5e-310)
(*
(sqrt (/ d h))
(*
(+ 1.0 (* (/ h l) (* -0.5 (pow (* (/ D_m d) (/ M_m 2.0)) 2.0))))
(/ (sqrt (- d)) (sqrt (- l)))))
(*
(fma h (/ (pow (* M_m (* 0.5 (/ D_m d))) 2.0) (/ l -0.5)) 1.0)
(/ d (* (sqrt h) (sqrt l))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (d <= -5e-310) {
tmp = sqrt((d / h)) * ((1.0 + ((h / l) * (-0.5 * pow(((D_m / d) * (M_m / 2.0)), 2.0)))) * (sqrt(-d) / sqrt(-l)));
} else {
tmp = fma(h, (pow((M_m * (0.5 * (D_m / d))), 2.0) / (l / -0.5)), 1.0) * (d / (sqrt(h) * sqrt(l)));
}
return tmp;
}
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (d <= -5e-310) tmp = Float64(sqrt(Float64(d / h)) * Float64(Float64(1.0 + Float64(Float64(h / l) * Float64(-0.5 * (Float64(Float64(D_m / d) * Float64(M_m / 2.0)) ^ 2.0)))) * Float64(sqrt(Float64(-d)) / sqrt(Float64(-l))))); else tmp = Float64(fma(h, Float64((Float64(M_m * Float64(0.5 * Float64(D_m / d))) ^ 2.0) / Float64(l / -0.5)), 1.0) * Float64(d / Float64(sqrt(h) * sqrt(l)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[d, -5e-310], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(h * N[(N[Power[N[(M$95$m * N[(0.5 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / N[(l / -0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{D\_m}{d} \cdot \frac{M\_m}{2}\right)}^{2}\right)\right) \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(h, \frac{{\left(M\_m \cdot \left(0.5 \cdot \frac{D\_m}{d}\right)\right)}^{2}}{\frac{\ell}{-0.5}}, 1\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if d < -4.999999999999985e-310Initial program 64.4%
Simplified62.9%
frac-2neg62.9%
sqrt-div68.0%
Applied egg-rr68.0%
if -4.999999999999985e-310 < d Initial program 57.1%
Applied egg-rr31.0%
expm1-def40.3%
expm1-log1p73.2%
*-commutative73.2%
Simplified80.2%
Final simplification74.1%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= h -1e-310)
(*
(sqrt (/ d h))
(*
(+ 1.0 (/ (* h (* -0.5 (pow (* (* M_m 0.5) (/ D_m d)) 2.0))) l))
(/ (sqrt (- d)) (sqrt (- l)))))
(*
(fma h (/ (pow (* M_m (* 0.5 (/ D_m d))) 2.0) (/ l -0.5)) 1.0)
(/ d (* (sqrt h) (sqrt l))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (h <= -1e-310) {
tmp = sqrt((d / h)) * ((1.0 + ((h * (-0.5 * pow(((M_m * 0.5) * (D_m / d)), 2.0))) / l)) * (sqrt(-d) / sqrt(-l)));
} else {
tmp = fma(h, (pow((M_m * (0.5 * (D_m / d))), 2.0) / (l / -0.5)), 1.0) * (d / (sqrt(h) * sqrt(l)));
}
return tmp;
}
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (h <= -1e-310) tmp = Float64(sqrt(Float64(d / h)) * Float64(Float64(1.0 + Float64(Float64(h * Float64(-0.5 * (Float64(Float64(M_m * 0.5) * Float64(D_m / d)) ^ 2.0))) / l)) * Float64(sqrt(Float64(-d)) / sqrt(Float64(-l))))); else tmp = Float64(fma(h, Float64((Float64(M_m * Float64(0.5 * Float64(D_m / d))) ^ 2.0) / Float64(l / -0.5)), 1.0) * Float64(d / Float64(sqrt(h) * sqrt(l)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[h, -1e-310], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 + N[(N[(h * N[(-0.5 * N[Power[N[(N[(M$95$m * 0.5), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(h * N[(N[Power[N[(M$95$m * N[(0.5 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / N[(l / -0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\left(1 + \frac{h \cdot \left(-0.5 \cdot {\left(\left(M\_m \cdot 0.5\right) \cdot \frac{D\_m}{d}\right)}^{2}\right)}{\ell}\right) \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(h, \frac{{\left(M\_m \cdot \left(0.5 \cdot \frac{D\_m}{d}\right)\right)}^{2}}{\frac{\ell}{-0.5}}, 1\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if h < -9.999999999999969e-311Initial program 64.4%
Simplified62.9%
associate-*l/64.0%
Applied egg-rr64.0%
frac-2neg62.9%
sqrt-div68.0%
Applied egg-rr72.1%
if -9.999999999999969e-311 < h Initial program 57.1%
Applied egg-rr31.0%
expm1-def40.3%
expm1-log1p73.2%
*-commutative73.2%
Simplified80.2%
Final simplification76.1%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= l -1e-309)
(*
(/ (sqrt (- d)) (sqrt (- h)))
(*
(sqrt (/ d l))
(+ 1.0 (* (/ h l) (* -0.5 (pow (* (/ D_m d) (/ M_m 2.0)) 2.0))))))
(*
(fma h (/ (pow (* M_m (* 0.5 (/ D_m d))) 2.0) (/ l -0.5)) 1.0)
(/ d (* (sqrt h) (sqrt l))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= -1e-309) {
tmp = (sqrt(-d) / sqrt(-h)) * (sqrt((d / l)) * (1.0 + ((h / l) * (-0.5 * pow(((D_m / d) * (M_m / 2.0)), 2.0)))));
} else {
tmp = fma(h, (pow((M_m * (0.5 * (D_m / d))), 2.0) / (l / -0.5)), 1.0) * (d / (sqrt(h) * sqrt(l)));
}
return tmp;
}
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (l <= -1e-309) tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(sqrt(Float64(d / l)) * Float64(1.0 + Float64(Float64(h / l) * Float64(-0.5 * (Float64(Float64(D_m / d) * Float64(M_m / 2.0)) ^ 2.0)))))); else tmp = Float64(fma(h, Float64((Float64(M_m * Float64(0.5 * Float64(D_m / d))) ^ 2.0) / Float64(l / -0.5)), 1.0) * Float64(d / Float64(sqrt(h) * sqrt(l)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -1e-309], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(h * N[(N[Power[N[(M$95$m * N[(0.5 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / N[(l / -0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1 \cdot 10^{-309}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{D\_m}{d} \cdot \frac{M\_m}{2}\right)}^{2}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(h, \frac{{\left(M\_m \cdot \left(0.5 \cdot \frac{D\_m}{d}\right)\right)}^{2}}{\frac{\ell}{-0.5}}, 1\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if l < -1.000000000000002e-309Initial program 64.4%
Simplified62.9%
frac-2neg62.8%
sqrt-div76.0%
Applied egg-rr75.3%
if -1.000000000000002e-309 < l Initial program 57.1%
Applied egg-rr31.0%
expm1-def40.3%
expm1-log1p73.2%
*-commutative73.2%
Simplified80.2%
Final simplification77.7%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= l -1e-309)
(*
(/ (sqrt (- d)) (sqrt (- h)))
(*
(sqrt (/ d l))
(+ 1.0 (/ (* h (* -0.5 (pow (* (* M_m 0.5) (/ D_m d)) 2.0))) l))))
(*
(fma h (/ (pow (* M_m (* 0.5 (/ D_m d))) 2.0) (/ l -0.5)) 1.0)
(/ d (* (sqrt h) (sqrt l))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= -1e-309) {
tmp = (sqrt(-d) / sqrt(-h)) * (sqrt((d / l)) * (1.0 + ((h * (-0.5 * pow(((M_m * 0.5) * (D_m / d)), 2.0))) / l)));
} else {
tmp = fma(h, (pow((M_m * (0.5 * (D_m / d))), 2.0) / (l / -0.5)), 1.0) * (d / (sqrt(h) * sqrt(l)));
}
return tmp;
}
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (l <= -1e-309) tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(sqrt(Float64(d / l)) * Float64(1.0 + Float64(Float64(h * Float64(-0.5 * (Float64(Float64(M_m * 0.5) * Float64(D_m / d)) ^ 2.0))) / l)))); else tmp = Float64(fma(h, Float64((Float64(M_m * Float64(0.5 * Float64(D_m / d))) ^ 2.0) / Float64(l / -0.5)), 1.0) * Float64(d / Float64(sqrt(h) * sqrt(l)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -1e-309], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(N[(h * N[(-0.5 * N[Power[N[(N[(M$95$m * 0.5), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(h * N[(N[Power[N[(M$95$m * N[(0.5 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / N[(l / -0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1 \cdot 10^{-309}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + \frac{h \cdot \left(-0.5 \cdot {\left(\left(M\_m \cdot 0.5\right) \cdot \frac{D\_m}{d}\right)}^{2}\right)}{\ell}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(h, \frac{{\left(M\_m \cdot \left(0.5 \cdot \frac{D\_m}{d}\right)\right)}^{2}}{\frac{\ell}{-0.5}}, 1\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if l < -1.000000000000002e-309Initial program 64.4%
Simplified62.9%
associate-*l/64.0%
Applied egg-rr64.0%
frac-2neg62.8%
sqrt-div76.0%
Applied egg-rr76.3%
if -1.000000000000002e-309 < l Initial program 57.1%
Applied egg-rr31.0%
expm1-def40.3%
expm1-log1p73.2%
*-commutative73.2%
Simplified80.2%
Final simplification78.3%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (* M_m (/ (* D_m 0.5) d))))
(if (<= d -5e-310)
(*
(sqrt (/ d h))
(* (sqrt (/ d l)) (+ 1.0 (* h (* (/ t_0 l) (/ t_0 -2.0))))))
(*
(fma h (/ (pow (* M_m (* 0.5 (/ D_m d))) 2.0) (/ l -0.5)) 1.0)
(/ d (* (sqrt h) (sqrt l)))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = M_m * ((D_m * 0.5) / d);
double tmp;
if (d <= -5e-310) {
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 + (h * ((t_0 / l) * (t_0 / -2.0)))));
} else {
tmp = fma(h, (pow((M_m * (0.5 * (D_m / d))), 2.0) / (l / -0.5)), 1.0) * (d / (sqrt(h) * sqrt(l)));
}
return tmp;
}
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(M_m * Float64(Float64(D_m * 0.5) / d)) tmp = 0.0 if (d <= -5e-310) tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(d / l)) * Float64(1.0 + Float64(h * Float64(Float64(t_0 / l) * Float64(t_0 / -2.0)))))); else tmp = Float64(fma(h, Float64((Float64(M_m * Float64(0.5 * Float64(D_m / d))) ^ 2.0) / Float64(l / -0.5)), 1.0) * Float64(d / Float64(sqrt(h) * sqrt(l)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(M$95$m * N[(N[(D$95$m * 0.5), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5e-310], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(h * N[(N[(t$95$0 / l), $MachinePrecision] * N[(t$95$0 / -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(h * N[(N[Power[N[(M$95$m * N[(0.5 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / N[(l / -0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := M\_m \cdot \frac{D\_m \cdot 0.5}{d}\\
\mathbf{if}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + h \cdot \left(\frac{t\_0}{\ell} \cdot \frac{t\_0}{-2}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(h, \frac{{\left(M\_m \cdot \left(0.5 \cdot \frac{D\_m}{d}\right)\right)}^{2}}{\frac{\ell}{-0.5}}, 1\right) \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if d < -4.999999999999985e-310Initial program 64.4%
Simplified62.9%
Applied egg-rr33.5%
expm1-def33.5%
expm1-log1p62.9%
associate-*l/64.0%
*-commutative64.0%
associate-*l/66.2%
*-commutative66.2%
associate-/l*66.2%
associate-*l*66.2%
Simplified66.2%
unpow266.2%
div-inv66.2%
metadata-eval66.2%
metadata-eval66.2%
times-frac66.9%
associate-*r/66.9%
associate-*r/66.9%
metadata-eval66.9%
Applied egg-rr66.9%
if -4.999999999999985e-310 < d Initial program 57.1%
Applied egg-rr31.0%
expm1-def40.3%
expm1-log1p73.2%
*-commutative73.2%
Simplified80.2%
Final simplification73.5%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (* M_m (/ (* D_m 0.5) d))))
(if (<= l 3.85e-305)
(*
(sqrt (/ d h))
(* (sqrt (/ d l)) (+ 1.0 (* h (* (/ t_0 l) (/ t_0 -2.0))))))
(*
(/ d (* (sqrt h) (sqrt l)))
(- 1.0 (/ (pow (* D_m (/ M_m (* d 2.0))) 2.0) (/ (/ l h) 0.5)))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = M_m * ((D_m * 0.5) / d);
double tmp;
if (l <= 3.85e-305) {
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 + (h * ((t_0 / l) * (t_0 / -2.0)))));
} else {
tmp = (d / (sqrt(h) * sqrt(l))) * (1.0 - (pow((D_m * (M_m / (d * 2.0))), 2.0) / ((l / h) / 0.5)));
}
return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = m_m * ((d_m * 0.5d0) / d)
if (l <= 3.85d-305) then
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0d0 + (h * ((t_0 / l) * (t_0 / (-2.0d0))))))
else
tmp = (d / (sqrt(h) * sqrt(l))) * (1.0d0 - (((d_m * (m_m / (d * 2.0d0))) ** 2.0d0) / ((l / h) / 0.5d0)))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = M_m * ((D_m * 0.5) / d);
double tmp;
if (l <= 3.85e-305) {
tmp = Math.sqrt((d / h)) * (Math.sqrt((d / l)) * (1.0 + (h * ((t_0 / l) * (t_0 / -2.0)))));
} else {
tmp = (d / (Math.sqrt(h) * Math.sqrt(l))) * (1.0 - (Math.pow((D_m * (M_m / (d * 2.0))), 2.0) / ((l / h) / 0.5)));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = M_m * ((D_m * 0.5) / d) tmp = 0 if l <= 3.85e-305: tmp = math.sqrt((d / h)) * (math.sqrt((d / l)) * (1.0 + (h * ((t_0 / l) * (t_0 / -2.0))))) else: tmp = (d / (math.sqrt(h) * math.sqrt(l))) * (1.0 - (math.pow((D_m * (M_m / (d * 2.0))), 2.0) / ((l / h) / 0.5))) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(M_m * Float64(Float64(D_m * 0.5) / d)) tmp = 0.0 if (l <= 3.85e-305) tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(d / l)) * Float64(1.0 + Float64(h * Float64(Float64(t_0 / l) * Float64(t_0 / -2.0)))))); else tmp = Float64(Float64(d / Float64(sqrt(h) * sqrt(l))) * Float64(1.0 - Float64((Float64(D_m * Float64(M_m / Float64(d * 2.0))) ^ 2.0) / Float64(Float64(l / h) / 0.5)))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = M_m * ((D_m * 0.5) / d);
tmp = 0.0;
if (l <= 3.85e-305)
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 + (h * ((t_0 / l) * (t_0 / -2.0)))));
else
tmp = (d / (sqrt(h) * sqrt(l))) * (1.0 - (((D_m * (M_m / (d * 2.0))) ^ 2.0) / ((l / h) / 0.5)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(M$95$m * N[(N[(D$95$m * 0.5), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, 3.85e-305], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(h * N[(N[(t$95$0 / l), $MachinePrecision] * N[(t$95$0 / -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[Power[N[(D$95$m * N[(M$95$m / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / N[(N[(l / h), $MachinePrecision] / 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := M\_m \cdot \frac{D\_m \cdot 0.5}{d}\\
\mathbf{if}\;\ell \leq 3.85 \cdot 10^{-305}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + h \cdot \left(\frac{t\_0}{\ell} \cdot \frac{t\_0}{-2}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \left(1 - \frac{{\left(D\_m \cdot \frac{M\_m}{d \cdot 2}\right)}^{2}}{\frac{\frac{\ell}{h}}{0.5}}\right)\\
\end{array}
\end{array}
if l < 3.8499999999999999e-305Initial program 64.5%
Simplified63.0%
Applied egg-rr32.7%
expm1-def32.7%
expm1-log1p63.0%
associate-*l/64.0%
*-commutative64.0%
associate-*l/66.2%
*-commutative66.2%
associate-/l*66.2%
associate-*l*66.2%
Simplified66.2%
unpow266.2%
div-inv66.2%
metadata-eval66.2%
metadata-eval66.2%
times-frac66.9%
associate-*r/66.9%
associate-*r/66.9%
metadata-eval66.9%
Applied egg-rr66.9%
if 3.8499999999999999e-305 < l Initial program 56.8%
Applied egg-rr31.7%
expm1-def41.3%
expm1-log1p73.4%
associate-*l/79.7%
*-commutative79.7%
associate-/l*75.2%
associate-/l*75.2%
*-commutative75.2%
/-rgt-identity75.2%
associate-/l*75.2%
metadata-eval75.2%
times-frac74.3%
associate-*r/75.9%
*-commutative75.9%
Simplified75.9%
Final simplification71.3%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (* M_m (/ (* D_m 0.5) d))))
(if (<= l 3.55e+207)
(*
(sqrt (/ d h))
(* (sqrt (/ d l)) (+ 1.0 (* h (* (/ t_0 l) (/ t_0 -2.0))))))
(* d (* (pow l -0.5) (sqrt (/ 1.0 h)))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = M_m * ((D_m * 0.5) / d);
double tmp;
if (l <= 3.55e+207) {
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 + (h * ((t_0 / l) * (t_0 / -2.0)))));
} else {
tmp = d * (pow(l, -0.5) * sqrt((1.0 / h)));
}
return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = m_m * ((d_m * 0.5d0) / d)
if (l <= 3.55d+207) then
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0d0 + (h * ((t_0 / l) * (t_0 / (-2.0d0))))))
else
tmp = d * ((l ** (-0.5d0)) * sqrt((1.0d0 / h)))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = M_m * ((D_m * 0.5) / d);
double tmp;
if (l <= 3.55e+207) {
tmp = Math.sqrt((d / h)) * (Math.sqrt((d / l)) * (1.0 + (h * ((t_0 / l) * (t_0 / -2.0)))));
} else {
tmp = d * (Math.pow(l, -0.5) * Math.sqrt((1.0 / h)));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = M_m * ((D_m * 0.5) / d) tmp = 0 if l <= 3.55e+207: tmp = math.sqrt((d / h)) * (math.sqrt((d / l)) * (1.0 + (h * ((t_0 / l) * (t_0 / -2.0))))) else: tmp = d * (math.pow(l, -0.5) * math.sqrt((1.0 / h))) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(M_m * Float64(Float64(D_m * 0.5) / d)) tmp = 0.0 if (l <= 3.55e+207) tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(d / l)) * Float64(1.0 + Float64(h * Float64(Float64(t_0 / l) * Float64(t_0 / -2.0)))))); else tmp = Float64(d * Float64((l ^ -0.5) * sqrt(Float64(1.0 / h)))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = M_m * ((D_m * 0.5) / d);
tmp = 0.0;
if (l <= 3.55e+207)
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 + (h * ((t_0 / l) * (t_0 / -2.0)))));
else
tmp = d * ((l ^ -0.5) * sqrt((1.0 / h)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(M$95$m * N[(N[(D$95$m * 0.5), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, 3.55e+207], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(h * N[(N[(t$95$0 / l), $MachinePrecision] * N[(t$95$0 / -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := M\_m \cdot \frac{D\_m \cdot 0.5}{d}\\
\mathbf{if}\;\ell \leq 3.55 \cdot 10^{+207}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + h \cdot \left(\frac{t\_0}{\ell} \cdot \frac{t\_0}{-2}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)\\
\end{array}
\end{array}
if l < 3.55000000000000021e207Initial program 63.9%
Simplified63.5%
Applied egg-rr32.0%
expm1-def32.0%
expm1-log1p63.5%
associate-*l/66.6%
*-commutative66.6%
associate-*l/67.5%
*-commutative67.5%
associate-/l*67.5%
associate-*l*67.5%
Simplified67.5%
unpow267.5%
div-inv67.5%
metadata-eval67.5%
metadata-eval67.5%
times-frac68.7%
associate-*r/68.7%
associate-*r/68.7%
metadata-eval68.7%
Applied egg-rr68.7%
if 3.55000000000000021e207 < l Initial program 28.3%
Taylor expanded in d around inf 45.2%
*-commutative45.2%
associate-/r*49.2%
Simplified49.2%
pow1/249.2%
div-inv49.2%
unpow-prod-down57.3%
pow1/257.3%
inv-pow57.3%
sqrt-pow157.5%
metadata-eval57.5%
Applied egg-rr57.5%
unpow1/257.5%
Simplified57.5%
Final simplification67.7%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= d -9.5e-108)
(* (sqrt (/ d l)) (sqrt (/ d h)))
(if (<= d 8e-261)
(* d (cbrt (pow (/ 1.0 (* l h)) 1.5)))
(* d (* (pow l -0.5) (sqrt (/ 1.0 h)))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (d <= -9.5e-108) {
tmp = sqrt((d / l)) * sqrt((d / h));
} else if (d <= 8e-261) {
tmp = d * cbrt(pow((1.0 / (l * h)), 1.5));
} else {
tmp = d * (pow(l, -0.5) * sqrt((1.0 / h)));
}
return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (d <= -9.5e-108) {
tmp = Math.sqrt((d / l)) * Math.sqrt((d / h));
} else if (d <= 8e-261) {
tmp = d * Math.cbrt(Math.pow((1.0 / (l * h)), 1.5));
} else {
tmp = d * (Math.pow(l, -0.5) * Math.sqrt((1.0 / h)));
}
return tmp;
}
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (d <= -9.5e-108) tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))); elseif (d <= 8e-261) tmp = Float64(d * cbrt((Float64(1.0 / Float64(l * h)) ^ 1.5))); else tmp = Float64(d * Float64((l ^ -0.5) * sqrt(Float64(1.0 / h)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[d, -9.5e-108], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 8e-261], N[(d * N[Power[N[Power[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -9.5 \cdot 10^{-108}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{elif}\;d \leq 8 \cdot 10^{-261}:\\
\;\;\;\;d \cdot \sqrt[3]{{\left(\frac{1}{\ell \cdot h}\right)}^{1.5}}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)\\
\end{array}
\end{array}
if d < -9.5000000000000005e-108Initial program 71.0%
Simplified69.8%
Taylor expanded in h around 0 47.6%
if -9.5000000000000005e-108 < d < 7.99999999999999987e-261Initial program 41.1%
Taylor expanded in d around inf 15.8%
*-commutative15.8%
associate-/r*15.8%
Simplified15.8%
add-cbrt-cube26.8%
pow1/326.8%
add-sqr-sqrt26.8%
pow126.8%
pow1/226.8%
pow-prod-up26.8%
associate-/l/26.8%
metadata-eval26.8%
Applied egg-rr26.8%
unpow1/326.8%
*-commutative26.8%
Simplified26.8%
if 7.99999999999999987e-261 < d Initial program 62.1%
Taylor expanded in d around inf 40.9%
*-commutative40.9%
associate-/r*41.7%
Simplified41.7%
pow1/241.7%
div-inv41.7%
unpow-prod-down51.9%
pow1/251.9%
inv-pow51.9%
sqrt-pow151.9%
metadata-eval51.9%
Applied egg-rr51.9%
unpow1/251.9%
Simplified51.9%
Final simplification45.2%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (if (<= h 2.8e-298) (* d (cbrt (pow (/ 1.0 (* l h)) 1.5))) (* d (/ (pow l -0.5) (sqrt h)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (h <= 2.8e-298) {
tmp = d * cbrt(pow((1.0 / (l * h)), 1.5));
} else {
tmp = d * (pow(l, -0.5) / sqrt(h));
}
return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (h <= 2.8e-298) {
tmp = d * Math.cbrt(Math.pow((1.0 / (l * h)), 1.5));
} else {
tmp = d * (Math.pow(l, -0.5) / Math.sqrt(h));
}
return tmp;
}
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (h <= 2.8e-298) tmp = Float64(d * cbrt((Float64(1.0 / Float64(l * h)) ^ 1.5))); else tmp = Float64(d * Float64((l ^ -0.5) / sqrt(h))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[h, 2.8e-298], N[(d * N[Power[N[Power[N[(1.0 / N[(l * h), $MachinePrecision]), $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_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq 2.8 \cdot 10^{-298}:\\
\;\;\;\;d \cdot \sqrt[3]{{\left(\frac{1}{\ell \cdot h}\right)}^{1.5}}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\sqrt{h}}\\
\end{array}
\end{array}
if h < 2.79999999999999992e-298Initial program 64.0%
Taylor expanded in d around inf 14.0%
*-commutative14.0%
associate-/r*14.0%
Simplified14.0%
add-cbrt-cube19.3%
pow1/319.2%
add-sqr-sqrt19.2%
pow119.2%
pow1/219.2%
pow-prod-up19.2%
associate-/l/19.2%
metadata-eval19.2%
Applied egg-rr19.2%
unpow1/319.3%
*-commutative19.3%
Simplified19.3%
if 2.79999999999999992e-298 < h Initial program 57.5%
Taylor expanded in d around inf 36.9%
*-commutative36.9%
associate-/r*37.6%
Simplified37.6%
expm1-log1p-u36.5%
expm1-udef22.4%
sqrt-div28.8%
inv-pow28.8%
sqrt-pow128.8%
metadata-eval28.8%
Applied egg-rr28.8%
expm1-def45.1%
expm1-log1p46.9%
Simplified46.9%
Final simplification33.0%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (if (<= l 1.4e-307) (* d (cbrt (pow (/ 1.0 (* l h)) 1.5))) (* d (* (pow l -0.5) (sqrt (/ 1.0 h))))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= 1.4e-307) {
tmp = d * cbrt(pow((1.0 / (l * h)), 1.5));
} else {
tmp = d * (pow(l, -0.5) * sqrt((1.0 / h)));
}
return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= 1.4e-307) {
tmp = d * Math.cbrt(Math.pow((1.0 / (l * h)), 1.5));
} else {
tmp = d * (Math.pow(l, -0.5) * Math.sqrt((1.0 / h)));
}
return tmp;
}
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (l <= 1.4e-307) tmp = Float64(d * cbrt((Float64(1.0 / Float64(l * h)) ^ 1.5))); else tmp = Float64(d * Float64((l ^ -0.5) * sqrt(Float64(1.0 / h)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, 1.4e-307], N[(d * N[Power[N[Power[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.4 \cdot 10^{-307}:\\
\;\;\;\;d \cdot \sqrt[3]{{\left(\frac{1}{\ell \cdot h}\right)}^{1.5}}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot \sqrt{\frac{1}{h}}\right)\\
\end{array}
\end{array}
if l < 1.4e-307Initial program 64.7%
Taylor expanded in d around inf 13.2%
*-commutative13.2%
associate-/r*13.2%
Simplified13.2%
add-cbrt-cube18.5%
pow1/318.5%
add-sqr-sqrt18.5%
pow118.5%
pow1/218.5%
pow-prod-up18.5%
associate-/l/18.5%
metadata-eval18.5%
Applied egg-rr18.5%
unpow1/318.5%
*-commutative18.5%
Simplified18.5%
if 1.4e-307 < l Initial program 56.7%
Taylor expanded in d around inf 37.7%
*-commutative37.7%
associate-/r*38.4%
Simplified38.4%
pow1/238.4%
div-inv38.4%
unpow-prod-down47.7%
pow1/247.7%
inv-pow47.7%
sqrt-pow147.7%
metadata-eval47.7%
Applied egg-rr47.7%
unpow1/247.7%
Simplified47.7%
Final simplification33.0%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (if (<= h 4.5e-296) (* d (sqrt (/ 1.0 (* l h)))) (* d (/ (pow l -0.5) (sqrt h)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (h <= 4.5e-296) {
tmp = d * sqrt((1.0 / (l * h)));
} else {
tmp = d * (pow(l, -0.5) / sqrt(h));
}
return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: tmp
if (h <= 4.5d-296) then
tmp = d * sqrt((1.0d0 / (l * h)))
else
tmp = d * ((l ** (-0.5d0)) / sqrt(h))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (h <= 4.5e-296) {
tmp = d * Math.sqrt((1.0 / (l * h)));
} else {
tmp = d * (Math.pow(l, -0.5) / Math.sqrt(h));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if h <= 4.5e-296: tmp = d * math.sqrt((1.0 / (l * h))) else: tmp = d * (math.pow(l, -0.5) / math.sqrt(h)) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (h <= 4.5e-296) tmp = Float64(d * sqrt(Float64(1.0 / Float64(l * h)))); else tmp = Float64(d * Float64((l ^ -0.5) / sqrt(h))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (h <= 4.5e-296)
tmp = d * sqrt((1.0 / (l * h)));
else
tmp = d * ((l ^ -0.5) / sqrt(h));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[h, 4.5e-296], N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq 4.5 \cdot 10^{-296}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \frac{{\ell}^{-0.5}}{\sqrt{h}}\\
\end{array}
\end{array}
if h < 4.5000000000000002e-296Initial program 64.0%
Taylor expanded in d around inf 14.0%
if 4.5000000000000002e-296 < h Initial program 57.5%
Taylor expanded in d around inf 36.9%
*-commutative36.9%
associate-/r*37.6%
Simplified37.6%
expm1-log1p-u36.5%
expm1-udef22.4%
sqrt-div28.8%
inv-pow28.8%
sqrt-pow128.8%
metadata-eval28.8%
Applied egg-rr28.8%
expm1-def45.1%
expm1-log1p46.9%
Simplified46.9%
Final simplification30.3%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (* d (sqrt (/ 1.0 (* l h)))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
return d * sqrt((1.0 / (l * h)));
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
code = d * sqrt((1.0d0 / (l * h)))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
return d * Math.sqrt((1.0 / (l * h)));
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): return d * math.sqrt((1.0 / (l * h)))
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) return Float64(d * sqrt(Float64(1.0 / Float64(l * h)))) end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
tmp = d * sqrt((1.0 / (l * h)));
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
d \cdot \sqrt{\frac{1}{\ell \cdot h}}
\end{array}
Initial program 60.7%
Taylor expanded in d around inf 25.3%
Final simplification25.3%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (* d (sqrt (/ (/ 1.0 l) h))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
return d * sqrt(((1.0 / l) / h));
}
M_m = abs(M)
D_m = abs(D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
code = d * sqrt(((1.0d0 / l) / h))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
return d * Math.sqrt(((1.0 / l) / h));
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): return d * math.sqrt(((1.0 / l) / h))
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) return Float64(d * sqrt(Float64(Float64(1.0 / l) / h))) end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
tmp = d * sqrt(((1.0 / l) / h));
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := N[(d * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}
\end{array}
Initial program 60.7%
Taylor expanded in d around inf 25.3%
*-commutative25.3%
associate-/r*25.7%
Simplified25.7%
Final simplification25.7%
herbie shell --seed 2024040
(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)))))