
(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 13 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 (+ 1.0 (* (/ h l) (* (pow (/ D_m (* d (/ 2.0 M_m))) 2.0) -0.5)))))
(if (<= d -5e-310)
(* (sqrt (/ d l)) (* (/ (sqrt (- d)) (sqrt (- h))) t_0))
(if (<= d 1.32e-176)
(* (/ (sqrt d) (sqrt l)) (* t_0 (/ (sqrt d) (sqrt h))))
(*
(fma h (* (pow (* M_m (* D_m (/ 0.5 d))) 2.0) (/ -0.5 l)) 1.0)
(/ d (* (sqrt l) (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 t_0 = 1.0 + ((h / l) * (pow((D_m / (d * (2.0 / M_m))), 2.0) * -0.5));
double tmp;
if (d <= -5e-310) {
tmp = sqrt((d / l)) * ((sqrt(-d) / sqrt(-h)) * t_0);
} else if (d <= 1.32e-176) {
tmp = (sqrt(d) / sqrt(l)) * (t_0 * (sqrt(d) / sqrt(h)));
} else {
tmp = fma(h, (pow((M_m * (D_m * (0.5 / d))), 2.0) * (-0.5 / l)), 1.0) * (d / (sqrt(l) * 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) t_0 = Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(D_m / Float64(d * Float64(2.0 / M_m))) ^ 2.0) * -0.5))) tmp = 0.0 if (d <= -5e-310) tmp = Float64(sqrt(Float64(d / l)) * Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * t_0)); elseif (d <= 1.32e-176) tmp = Float64(Float64(sqrt(d) / sqrt(l)) * Float64(t_0 * Float64(sqrt(d) / sqrt(h)))); else tmp = Float64(fma(h, Float64((Float64(M_m * Float64(D_m * Float64(0.5 / d))) ^ 2.0) * Float64(-0.5 / l)), 1.0) * Float64(d / Float64(sqrt(l) * 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_] := Block[{t$95$0 = N[(1.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]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5e-310], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.32e-176], N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(h * N[(N[Power[N[(M$95$m * N[(D$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[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 := 1 + \frac{h}{\ell} \cdot \left({\left(\frac{D\_m}{d \cdot \frac{2}{M\_m}}\right)}^{2} \cdot -0.5\right)\\
\mathbf{if}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot t\_0\right)\\
\mathbf{elif}\;d \leq 1.32 \cdot 10^{-176}:\\
\;\;\;\;\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \left(t\_0 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(h, {\left(M\_m \cdot \left(D\_m \cdot \frac{0.5}{d}\right)\right)}^{2} \cdot \frac{-0.5}{\ell}, 1\right) \cdot \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if d < -4.999999999999985e-310Initial program 71.2%
Simplified71.1%
clear-num71.1%
frac-times70.3%
*-un-lft-identity70.3%
Applied egg-rr70.3%
frac-2neg70.3%
sqrt-div82.0%
Applied egg-rr82.0%
if -4.999999999999985e-310 < d < 1.32e-176Initial program 37.9%
Simplified35.7%
clear-num35.7%
frac-times37.8%
*-un-lft-identity37.8%
Applied egg-rr37.8%
sqrt-div47.8%
div-inv47.8%
Applied egg-rr47.8%
associate-*r/47.8%
*-rgt-identity47.8%
Simplified47.8%
sqrt-div61.5%
div-inv61.5%
Applied egg-rr61.5%
associate-*r/61.5%
*-rgt-identity61.5%
Simplified61.5%
if 1.32e-176 < d Initial program 75.9%
Simplified76.9%
sub-neg76.9%
distribute-rgt-in62.0%
*-un-lft-identity62.0%
*-commutative62.0%
sqrt-div65.9%
sqrt-div65.9%
frac-times65.9%
add-sqr-sqrt65.9%
Applied egg-rr74.4%
distribute-rgt1-in86.7%
associate-*l/91.1%
associate-/l*91.1%
fma-define91.1%
associate-/l*91.1%
associate-*r/90.1%
associate-*l/91.1%
associate-/r/91.1%
associate-/l*91.1%
associate-/r/91.1%
Simplified91.1%
Final simplification82.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 -1e-310)
(*
(sqrt (/ d l))
(*
(/ (sqrt (- d)) (sqrt (- h)))
(+ 1.0 (* (/ h l) (* -0.5 (pow (* (/ M_m 2.0) (/ D_m d)) 2.0))))))
(*
(fma h (* (pow (* M_m (* D_m (/ 0.5 d))) 2.0) (/ -0.5 l)) 1.0)
(/ d (* (sqrt l) (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 <= -1e-310) {
tmp = sqrt((d / l)) * ((sqrt(-d) / sqrt(-h)) * (1.0 + ((h / l) * (-0.5 * pow(((M_m / 2.0) * (D_m / d)), 2.0)))));
} else {
tmp = fma(h, (pow((M_m * (D_m * (0.5 / d))), 2.0) * (-0.5 / l)), 1.0) * (d / (sqrt(l) * 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 <= -1e-310) tmp = Float64(sqrt(Float64(d / l)) * Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(1.0 + Float64(Float64(h / l) * Float64(-0.5 * (Float64(Float64(M_m / 2.0) * Float64(D_m / d)) ^ 2.0)))))); else tmp = Float64(fma(h, Float64((Float64(M_m * Float64(D_m * Float64(0.5 / d))) ^ 2.0) * Float64(-0.5 / l)), 1.0) * Float64(d / Float64(sqrt(l) * 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, -1e-310], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(h * N[(N[Power[N[(M$95$m * N[(D$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[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}\;h \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(\frac{M\_m}{2} \cdot \frac{D\_m}{d}\right)}^{2}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(h, {\left(M\_m \cdot \left(D\_m \cdot \frac{0.5}{d}\right)\right)}^{2} \cdot \frac{-0.5}{\ell}, 1\right) \cdot \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if h < -9.999999999999969e-311Initial program 71.2%
Simplified71.1%
frac-2neg70.3%
sqrt-div82.0%
Applied egg-rr83.1%
if -9.999999999999969e-311 < h Initial program 64.6%
Simplified64.7%
sub-neg64.7%
distribute-rgt-in54.2%
*-un-lft-identity54.2%
*-commutative54.2%
sqrt-div59.5%
sqrt-div59.5%
frac-times59.5%
add-sqr-sqrt59.6%
Applied egg-rr68.4%
distribute-rgt1-in77.1%
associate-*l/80.2%
associate-/l*80.3%
fma-define80.3%
associate-/l*80.3%
associate-*r/79.5%
associate-*l/79.6%
associate-/r/80.3%
associate-/l*80.3%
associate-/r/80.3%
Simplified80.3%
Final simplification81.6%
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 l))
(*
(/ (sqrt (- d)) (sqrt (- h)))
(+ 1.0 (* (/ h l) (* (pow (/ D_m (* d (/ 2.0 M_m))) 2.0) -0.5)))))
(*
(fma h (* (pow (* M_m (* D_m (/ 0.5 d))) 2.0) (/ -0.5 l)) 1.0)
(/ d (* (sqrt l) (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 <= -1e-310) {
tmp = sqrt((d / l)) * ((sqrt(-d) / sqrt(-h)) * (1.0 + ((h / l) * (pow((D_m / (d * (2.0 / M_m))), 2.0) * -0.5))));
} else {
tmp = fma(h, (pow((M_m * (D_m * (0.5 / d))), 2.0) * (-0.5 / l)), 1.0) * (d / (sqrt(l) * 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 <= -1e-310) tmp = Float64(sqrt(Float64(d / l)) * Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(1.0 + Float64(Float64(h / l) * Float64((Float64(D_m / Float64(d * Float64(2.0 / M_m))) ^ 2.0) * -0.5))))); else tmp = Float64(fma(h, Float64((Float64(M_m * Float64(D_m * Float64(0.5 / d))) ^ 2.0) * Float64(-0.5 / l)), 1.0) * Float64(d / Float64(sqrt(l) * 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, -1e-310], N[(N[Sqrt[N[(d / 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[(D$95$m / N[(d * N[(2.0 / M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(h * N[(N[Power[N[(M$95$m * N[(D$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[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}\;h \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{D\_m}{d \cdot \frac{2}{M\_m}}\right)}^{2} \cdot -0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(h, {\left(M\_m \cdot \left(D\_m \cdot \frac{0.5}{d}\right)\right)}^{2} \cdot \frac{-0.5}{\ell}, 1\right) \cdot \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if h < -9.999999999999969e-311Initial program 71.2%
Simplified71.1%
clear-num71.1%
frac-times70.3%
*-un-lft-identity70.3%
Applied egg-rr70.3%
frac-2neg70.3%
sqrt-div82.0%
Applied egg-rr82.0%
if -9.999999999999969e-311 < h Initial program 64.6%
Simplified64.7%
sub-neg64.7%
distribute-rgt-in54.2%
*-un-lft-identity54.2%
*-commutative54.2%
sqrt-div59.5%
sqrt-div59.5%
frac-times59.5%
add-sqr-sqrt59.6%
Applied egg-rr68.4%
distribute-rgt1-in77.1%
associate-*l/80.2%
associate-/l*80.3%
fma-define80.3%
associate-/l*80.3%
associate-*r/79.5%
associate-*l/79.6%
associate-/r/80.3%
associate-/l*80.3%
associate-/r/80.3%
Simplified80.3%
Final simplification81.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 2.35e-303)
(*
(sqrt (/ d l))
(*
(sqrt (/ d h))
(+ 1.0 (* h (* -0.125 (/ (pow (* D_m (/ M_m d)) 2.0) l))))))
(*
(fma h (* (pow (* M_m (* D_m (/ 0.5 d))) 2.0) (/ -0.5 l)) 1.0)
(/ d (* (sqrt l) (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 (l <= 2.35e-303) {
tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0 + (h * (-0.125 * (pow((D_m * (M_m / d)), 2.0) / l)))));
} else {
tmp = fma(h, (pow((M_m * (D_m * (0.5 / d))), 2.0) * (-0.5 / l)), 1.0) * (d / (sqrt(l) * 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 (l <= 2.35e-303) tmp = Float64(sqrt(Float64(d / l)) * Float64(sqrt(Float64(d / h)) * Float64(1.0 + Float64(h * Float64(-0.125 * Float64((Float64(D_m * Float64(M_m / d)) ^ 2.0) / l)))))); else tmp = Float64(fma(h, Float64((Float64(M_m * Float64(D_m * Float64(0.5 / d))) ^ 2.0) * Float64(-0.5 / l)), 1.0) * Float64(d / Float64(sqrt(l) * 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[l, 2.35e-303], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(h * N[(-0.125 * N[(N[Power[N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(h * N[(N[Power[N[(M$95$m * N[(D$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[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 2.35 \cdot 10^{-303}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + h \cdot \left(-0.125 \cdot \frac{{\left(D\_m \cdot \frac{M\_m}{d}\right)}^{2}}{\ell}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(h, {\left(M\_m \cdot \left(D\_m \cdot \frac{0.5}{d}\right)\right)}^{2} \cdot \frac{-0.5}{\ell}, 1\right) \cdot \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < 2.3499999999999999e-303Initial program 71.7%
Simplified71.6%
*-commutative71.6%
clear-num71.6%
un-div-inv71.6%
div-inv71.6%
metadata-eval71.6%
Applied egg-rr71.6%
associate-/r/74.1%
*-commutative74.1%
associate-/l*74.1%
associate-*r/74.2%
associate-*l/73.3%
associate-/r/74.1%
associate-/l*74.1%
associate-/r/74.1%
Simplified74.1%
Taylor expanded in M around 0 54.7%
times-frac56.3%
associate-*r/57.2%
unpow257.2%
unpow257.2%
times-frac61.5%
unpow261.5%
swap-sqr74.1%
unpow274.1%
associate-*l/74.2%
associate-/l*73.3%
Simplified73.3%
if 2.3499999999999999e-303 < l Initial program 64.1%
Simplified64.2%
sub-neg64.2%
distribute-rgt-in53.5%
*-un-lft-identity53.5%
*-commutative53.5%
sqrt-div58.9%
sqrt-div58.9%
frac-times58.9%
add-sqr-sqrt59.0%
Applied egg-rr68.0%
distribute-rgt1-in76.8%
associate-*l/79.9%
associate-/l*80.0%
fma-define80.0%
associate-/l*80.0%
associate-*r/79.2%
associate-*l/79.3%
associate-/r/80.0%
associate-/l*80.0%
associate-/r/80.0%
Simplified80.0%
Final simplification76.8%
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 -5.6e+88)
(* (- d) (* (pow (- h) -0.5) (pow (/ -1.0 l) 0.5)))
(if (<= d 2.55e-269)
(*
(sqrt (* (/ d l) (/ d h)))
(+ 1.0 (* -0.125 (/ (* h (pow (/ (* D_m M_m) d) 2.0)) l))))
(*
(+ 1.0 (* h (* (pow (* D_m (/ M_m d)) 2.0) (/ -0.125 l))))
(/ (/ d (sqrt l)) (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 (d <= -5.6e+88) {
tmp = -d * (pow(-h, -0.5) * pow((-1.0 / l), 0.5));
} else if (d <= 2.55e-269) {
tmp = sqrt(((d / l) * (d / h))) * (1.0 + (-0.125 * ((h * pow(((D_m * M_m) / d), 2.0)) / l)));
} else {
tmp = (1.0 + (h * (pow((D_m * (M_m / d)), 2.0) * (-0.125 / l)))) * ((d / sqrt(l)) / 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 (d <= (-5.6d+88)) then
tmp = -d * ((-h ** (-0.5d0)) * (((-1.0d0) / l) ** 0.5d0))
else if (d <= 2.55d-269) then
tmp = sqrt(((d / l) * (d / h))) * (1.0d0 + ((-0.125d0) * ((h * (((d_m * m_m) / d) ** 2.0d0)) / l)))
else
tmp = (1.0d0 + (h * (((d_m * (m_m / d)) ** 2.0d0) * ((-0.125d0) / l)))) * ((d / sqrt(l)) / 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 (d <= -5.6e+88) {
tmp = -d * (Math.pow(-h, -0.5) * Math.pow((-1.0 / l), 0.5));
} else if (d <= 2.55e-269) {
tmp = Math.sqrt(((d / l) * (d / h))) * (1.0 + (-0.125 * ((h * Math.pow(((D_m * M_m) / d), 2.0)) / l)));
} else {
tmp = (1.0 + (h * (Math.pow((D_m * (M_m / d)), 2.0) * (-0.125 / l)))) * ((d / Math.sqrt(l)) / 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 d <= -5.6e+88: tmp = -d * (math.pow(-h, -0.5) * math.pow((-1.0 / l), 0.5)) elif d <= 2.55e-269: tmp = math.sqrt(((d / l) * (d / h))) * (1.0 + (-0.125 * ((h * math.pow(((D_m * M_m) / d), 2.0)) / l))) else: tmp = (1.0 + (h * (math.pow((D_m * (M_m / d)), 2.0) * (-0.125 / l)))) * ((d / math.sqrt(l)) / 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 (d <= -5.6e+88) tmp = Float64(Float64(-d) * Float64((Float64(-h) ^ -0.5) * (Float64(-1.0 / l) ^ 0.5))); elseif (d <= 2.55e-269) tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * Float64(1.0 + Float64(-0.125 * Float64(Float64(h * (Float64(Float64(D_m * M_m) / d) ^ 2.0)) / l)))); else tmp = Float64(Float64(1.0 + Float64(h * Float64((Float64(D_m * Float64(M_m / d)) ^ 2.0) * Float64(-0.125 / l)))) * Float64(Float64(d / sqrt(l)) / 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 (d <= -5.6e+88)
tmp = -d * ((-h ^ -0.5) * ((-1.0 / l) ^ 0.5));
elseif (d <= 2.55e-269)
tmp = sqrt(((d / l) * (d / h))) * (1.0 + (-0.125 * ((h * (((D_m * M_m) / d) ^ 2.0)) / l)));
else
tmp = (1.0 + (h * (((D_m * (M_m / d)) ^ 2.0) * (-0.125 / l)))) * ((d / sqrt(l)) / 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[d, -5.6e+88], N[((-d) * N[(N[Power[(-h), -0.5], $MachinePrecision] * N[Power[N[(-1.0 / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.55e-269], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.125 * N[(N[(h * N[Power[N[(N[(D$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(h * N[(N[Power[N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.125 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(d / N[Sqrt[l], $MachinePrecision]), $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}\;d \leq -5.6 \cdot 10^{+88}:\\
\;\;\;\;\left(-d\right) \cdot \left({\left(-h\right)}^{-0.5} \cdot {\left(\frac{-1}{\ell}\right)}^{0.5}\right)\\
\mathbf{elif}\;d \leq 2.55 \cdot 10^{-269}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + -0.125 \cdot \frac{h \cdot {\left(\frac{D\_m \cdot M\_m}{d}\right)}^{2}}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 + h \cdot \left({\left(D\_m \cdot \frac{M\_m}{d}\right)}^{2} \cdot \frac{-0.125}{\ell}\right)\right) \cdot \frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\
\end{array}
\end{array}
if d < -5.59999999999999977e88Initial program 80.7%
Simplified80.5%
add-sqr-sqrt80.5%
pow280.5%
sqrt-prod80.4%
sqrt-pow180.4%
metadata-eval80.4%
pow180.4%
div-inv80.4%
metadata-eval80.4%
Applied egg-rr80.4%
clear-num80.4%
sqrt-div80.3%
metadata-eval80.3%
Applied egg-rr80.3%
Taylor expanded in d around -inf 66.9%
mul-1-neg66.9%
distribute-rgt-neg-in66.9%
unpow-166.9%
metadata-eval66.9%
pow-sqr66.9%
rem-sqrt-square68.7%
rem-square-sqrt68.6%
fabs-sqr68.6%
rem-square-sqrt68.7%
Simplified68.7%
Taylor expanded in l around -inf 81.4%
distribute-lft-in81.4%
exp-sum82.1%
*-commutative82.1%
exp-to-pow82.4%
mul-1-neg82.4%
*-commutative82.4%
*-commutative82.4%
associate-*l*82.4%
metadata-eval82.4%
exp-to-pow86.0%
Simplified86.0%
if -5.59999999999999977e88 < d < 2.5500000000000001e-269Initial program 63.8%
Simplified62.7%
add-sqr-sqrt62.7%
pow262.7%
sqrt-prod62.7%
sqrt-pow166.3%
metadata-eval66.3%
pow166.3%
div-inv66.3%
metadata-eval66.3%
Applied egg-rr66.3%
pow166.3%
Applied egg-rr57.9%
unpow157.9%
+-commutative57.9%
+-commutative57.9%
associate-*r*57.9%
*-commutative57.9%
Simplified57.9%
Taylor expanded in h around 0 47.4%
associate-*r*47.4%
times-frac45.0%
unpow245.0%
unpow245.0%
unpow245.0%
unswap-sqr53.8%
times-frac59.0%
associate-*l/57.9%
associate-*l/57.9%
unpow257.9%
*-commutative57.9%
associate-*l/59.0%
associate-/l*56.5%
Simplified56.5%
associate-*l/59.0%
associate-*r/61.4%
Applied egg-rr61.4%
if 2.5500000000000001e-269 < d Initial program 65.7%
Simplified66.4%
sub-neg66.4%
distribute-rgt-in55.4%
*-un-lft-identity55.4%
*-commutative55.4%
sqrt-div60.3%
sqrt-div60.3%
frac-times60.3%
add-sqr-sqrt60.4%
Applied egg-rr69.7%
distribute-rgt1-in78.9%
+-commutative78.9%
associate-*l/82.1%
associate-/l*82.2%
associate-*l*82.2%
associate-/r*79.4%
Simplified79.4%
Taylor expanded in M around 0 45.2%
*-commutative45.2%
associate-*l/45.2%
times-frac47.5%
unpow247.5%
unpow247.5%
unswap-sqr63.8%
unpow263.8%
times-frac78.6%
unpow278.6%
associate-/l*78.6%
Simplified78.6%
Final simplification74.4%
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 (pow (* D_m (/ M_m d)) 2.0)))
(if (<= l 2.35e-303)
(* (sqrt (/ d l)) (* (sqrt (/ d h)) (+ 1.0 (* h (* -0.125 (/ t_0 l))))))
(* (+ 1.0 (* h (* t_0 (/ -0.125 l)))) (/ (/ d (sqrt l)) (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 t_0 = pow((D_m * (M_m / d)), 2.0);
double tmp;
if (l <= 2.35e-303) {
tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0 + (h * (-0.125 * (t_0 / l)))));
} else {
tmp = (1.0 + (h * (t_0 * (-0.125 / l)))) * ((d / sqrt(l)) / 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) :: t_0
real(8) :: tmp
t_0 = (d_m * (m_m / d)) ** 2.0d0
if (l <= 2.35d-303) then
tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0d0 + (h * ((-0.125d0) * (t_0 / l)))))
else
tmp = (1.0d0 + (h * (t_0 * ((-0.125d0) / l)))) * ((d / sqrt(l)) / 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 t_0 = Math.pow((D_m * (M_m / d)), 2.0);
double tmp;
if (l <= 2.35e-303) {
tmp = Math.sqrt((d / l)) * (Math.sqrt((d / h)) * (1.0 + (h * (-0.125 * (t_0 / l)))));
} else {
tmp = (1.0 + (h * (t_0 * (-0.125 / l)))) * ((d / Math.sqrt(l)) / 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): t_0 = math.pow((D_m * (M_m / d)), 2.0) tmp = 0 if l <= 2.35e-303: tmp = math.sqrt((d / l)) * (math.sqrt((d / h)) * (1.0 + (h * (-0.125 * (t_0 / l))))) else: tmp = (1.0 + (h * (t_0 * (-0.125 / l)))) * ((d / math.sqrt(l)) / 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) t_0 = Float64(D_m * Float64(M_m / d)) ^ 2.0 tmp = 0.0 if (l <= 2.35e-303) tmp = Float64(sqrt(Float64(d / l)) * Float64(sqrt(Float64(d / h)) * Float64(1.0 + Float64(h * Float64(-0.125 * Float64(t_0 / l)))))); else tmp = Float64(Float64(1.0 + Float64(h * Float64(t_0 * Float64(-0.125 / l)))) * Float64(Float64(d / sqrt(l)) / 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)
t_0 = (D_m * (M_m / d)) ^ 2.0;
tmp = 0.0;
if (l <= 2.35e-303)
tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0 + (h * (-0.125 * (t_0 / l)))));
else
tmp = (1.0 + (h * (t_0 * (-0.125 / l)))) * ((d / sqrt(l)) / 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_] := Block[{t$95$0 = N[Power[N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[l, 2.35e-303], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(h * N[(-0.125 * N[(t$95$0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(h * N[(t$95$0 * N[(-0.125 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(d / N[Sqrt[l], $MachinePrecision]), $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}
t_0 := {\left(D\_m \cdot \frac{M\_m}{d}\right)}^{2}\\
\mathbf{if}\;\ell \leq 2.35 \cdot 10^{-303}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + h \cdot \left(-0.125 \cdot \frac{t\_0}{\ell}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 + h \cdot \left(t\_0 \cdot \frac{-0.125}{\ell}\right)\right) \cdot \frac{\frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\
\end{array}
\end{array}
if l < 2.3499999999999999e-303Initial program 71.7%
Simplified71.6%
*-commutative71.6%
clear-num71.6%
un-div-inv71.6%
div-inv71.6%
metadata-eval71.6%
Applied egg-rr71.6%
associate-/r/74.1%
*-commutative74.1%
associate-/l*74.1%
associate-*r/74.2%
associate-*l/73.3%
associate-/r/74.1%
associate-/l*74.1%
associate-/r/74.1%
Simplified74.1%
Taylor expanded in M around 0 54.7%
times-frac56.3%
associate-*r/57.2%
unpow257.2%
unpow257.2%
times-frac61.5%
unpow261.5%
swap-sqr74.1%
unpow274.1%
associate-*l/74.2%
associate-/l*73.3%
Simplified73.3%
if 2.3499999999999999e-303 < l Initial program 64.1%
Simplified64.2%
sub-neg64.2%
distribute-rgt-in53.5%
*-un-lft-identity53.5%
*-commutative53.5%
sqrt-div58.9%
sqrt-div58.9%
frac-times58.9%
add-sqr-sqrt59.0%
Applied egg-rr68.0%
distribute-rgt1-in76.8%
+-commutative76.8%
associate-*l/79.9%
associate-/l*80.0%
associate-*l*80.0%
associate-/r*76.6%
Simplified76.6%
Taylor expanded in M around 0 43.5%
*-commutative43.5%
associate-*l/43.5%
times-frac45.1%
unpow245.1%
unpow245.1%
unswap-sqr60.8%
unpow260.8%
times-frac75.9%
unpow275.9%
associate-/l*75.9%
Simplified75.9%
Final simplification74.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 -4.2e+130)
(* (- d) (* (pow (- h) -0.5) (pow (/ -1.0 l) 0.5)))
(if (<= l 1.45e+16)
(*
(sqrt (* (/ d l) (/ d h)))
(+ 1.0 (* -0.125 (* (/ h l) (pow (* D_m (/ M_m d)) 2.0)))))
(* d (* (pow l -0.5) (pow 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 tmp;
if (l <= -4.2e+130) {
tmp = -d * (pow(-h, -0.5) * pow((-1.0 / l), 0.5));
} else if (l <= 1.45e+16) {
tmp = sqrt(((d / l) * (d / h))) * (1.0 + (-0.125 * ((h / l) * pow((D_m * (M_m / d)), 2.0))));
} else {
tmp = d * (pow(l, -0.5) * pow(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) :: tmp
if (l <= (-4.2d+130)) then
tmp = -d * ((-h ** (-0.5d0)) * (((-1.0d0) / l) ** 0.5d0))
else if (l <= 1.45d+16) then
tmp = sqrt(((d / l) * (d / h))) * (1.0d0 + ((-0.125d0) * ((h / l) * ((d_m * (m_m / d)) ** 2.0d0))))
else
tmp = d * ((l ** (-0.5d0)) * (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 tmp;
if (l <= -4.2e+130) {
tmp = -d * (Math.pow(-h, -0.5) * Math.pow((-1.0 / l), 0.5));
} else if (l <= 1.45e+16) {
tmp = Math.sqrt(((d / l) * (d / h))) * (1.0 + (-0.125 * ((h / l) * Math.pow((D_m * (M_m / d)), 2.0))));
} else {
tmp = d * (Math.pow(l, -0.5) * Math.pow(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): tmp = 0 if l <= -4.2e+130: tmp = -d * (math.pow(-h, -0.5) * math.pow((-1.0 / l), 0.5)) elif l <= 1.45e+16: tmp = math.sqrt(((d / l) * (d / h))) * (1.0 + (-0.125 * ((h / l) * math.pow((D_m * (M_m / d)), 2.0)))) else: tmp = d * (math.pow(l, -0.5) * math.pow(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) tmp = 0.0 if (l <= -4.2e+130) tmp = Float64(Float64(-d) * Float64((Float64(-h) ^ -0.5) * (Float64(-1.0 / l) ^ 0.5))); elseif (l <= 1.45e+16) tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * Float64(1.0 + Float64(-0.125 * Float64(Float64(h / l) * (Float64(D_m * Float64(M_m / d)) ^ 2.0))))); else tmp = Float64(d * Float64((l ^ -0.5) * (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)
tmp = 0.0;
if (l <= -4.2e+130)
tmp = -d * ((-h ^ -0.5) * ((-1.0 / l) ^ 0.5));
elseif (l <= 1.45e+16)
tmp = sqrt(((d / l) * (d / h))) * (1.0 + (-0.125 * ((h / l) * ((D_m * (M_m / d)) ^ 2.0))));
else
tmp = d * ((l ^ -0.5) * (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_] := If[LessEqual[l, -4.2e+130], N[((-d) * N[(N[Power[(-h), -0.5], $MachinePrecision] * N[Power[N[(-1.0 / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.45e+16], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.125 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $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 -4.2 \cdot 10^{+130}:\\
\;\;\;\;\left(-d\right) \cdot \left({\left(-h\right)}^{-0.5} \cdot {\left(\frac{-1}{\ell}\right)}^{0.5}\right)\\
\mathbf{elif}\;\ell \leq 1.45 \cdot 10^{+16}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(D\_m \cdot \frac{M\_m}{d}\right)}^{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\
\end{array}
\end{array}
if l < -4.19999999999999981e130Initial program 61.9%
Simplified64.1%
add-sqr-sqrt64.1%
pow264.1%
sqrt-prod64.0%
sqrt-pow166.5%
metadata-eval66.5%
pow166.5%
div-inv66.5%
metadata-eval66.5%
Applied egg-rr66.5%
clear-num64.4%
sqrt-div64.4%
metadata-eval64.4%
Applied egg-rr64.4%
Taylor expanded in d around -inf 50.4%
mul-1-neg50.4%
distribute-rgt-neg-in50.4%
unpow-150.4%
metadata-eval50.4%
pow-sqr50.4%
rem-sqrt-square50.4%
rem-square-sqrt50.2%
fabs-sqr50.2%
rem-square-sqrt50.4%
Simplified50.4%
Taylor expanded in l around -inf 63.4%
distribute-lft-in63.4%
exp-sum64.0%
*-commutative64.0%
exp-to-pow63.6%
mul-1-neg63.6%
*-commutative63.6%
*-commutative63.6%
associate-*l*63.6%
metadata-eval63.6%
exp-to-pow68.7%
Simplified68.7%
if -4.19999999999999981e130 < l < 1.45e16Initial program 77.0%
Simplified75.6%
add-sqr-sqrt75.6%
pow275.6%
sqrt-prod75.6%
sqrt-pow177.6%
metadata-eval77.6%
pow177.6%
div-inv77.6%
metadata-eval77.6%
Applied egg-rr77.6%
pow177.6%
Applied egg-rr70.3%
unpow170.3%
+-commutative70.3%
+-commutative70.3%
associate-*r*70.3%
*-commutative70.3%
Simplified70.3%
Taylor expanded in h around 0 51.2%
associate-*r*51.9%
times-frac51.9%
unpow251.9%
unpow251.9%
unpow251.9%
unswap-sqr64.1%
times-frac71.7%
associate-*l/70.3%
associate-*l/70.3%
unpow270.3%
*-commutative70.3%
associate-*l/71.7%
associate-/l*71.7%
Simplified71.7%
if 1.45e16 < l Initial program 52.1%
Simplified53.6%
add-sqr-sqrt53.5%
pow253.5%
sqrt-prod53.6%
sqrt-pow157.9%
metadata-eval57.9%
pow157.9%
div-inv57.9%
metadata-eval57.9%
Applied egg-rr57.9%
Taylor expanded in d around inf 45.3%
unpow-145.3%
metadata-eval45.3%
pow-sqr45.2%
rem-sqrt-square45.2%
sqr-pow45.1%
fabs-sqr45.1%
sqr-pow45.2%
Simplified45.2%
*-commutative45.2%
unpow-prod-down55.8%
Applied egg-rr55.8%
Final simplification66.8%
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+143)
(* (- d) (* (pow (- h) -0.5) (pow (/ -1.0 l) 0.5)))
(if (<= l 2.55e+16)
(*
(sqrt (* (/ d l) (/ d h)))
(+ 1.0 (* -0.125 (/ (* h (pow (/ (* D_m M_m) d) 2.0)) l))))
(* d (* (pow l -0.5) (pow 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 tmp;
if (l <= -1.4e+143) {
tmp = -d * (pow(-h, -0.5) * pow((-1.0 / l), 0.5));
} else if (l <= 2.55e+16) {
tmp = sqrt(((d / l) * (d / h))) * (1.0 + (-0.125 * ((h * pow(((D_m * M_m) / d), 2.0)) / l)));
} else {
tmp = d * (pow(l, -0.5) * pow(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) :: tmp
if (l <= (-1.4d+143)) then
tmp = -d * ((-h ** (-0.5d0)) * (((-1.0d0) / l) ** 0.5d0))
else if (l <= 2.55d+16) then
tmp = sqrt(((d / l) * (d / h))) * (1.0d0 + ((-0.125d0) * ((h * (((d_m * m_m) / d) ** 2.0d0)) / l)))
else
tmp = d * ((l ** (-0.5d0)) * (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 tmp;
if (l <= -1.4e+143) {
tmp = -d * (Math.pow(-h, -0.5) * Math.pow((-1.0 / l), 0.5));
} else if (l <= 2.55e+16) {
tmp = Math.sqrt(((d / l) * (d / h))) * (1.0 + (-0.125 * ((h * Math.pow(((D_m * M_m) / d), 2.0)) / l)));
} else {
tmp = d * (Math.pow(l, -0.5) * Math.pow(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): tmp = 0 if l <= -1.4e+143: tmp = -d * (math.pow(-h, -0.5) * math.pow((-1.0 / l), 0.5)) elif l <= 2.55e+16: tmp = math.sqrt(((d / l) * (d / h))) * (1.0 + (-0.125 * ((h * math.pow(((D_m * M_m) / d), 2.0)) / l))) else: tmp = d * (math.pow(l, -0.5) * math.pow(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) tmp = 0.0 if (l <= -1.4e+143) tmp = Float64(Float64(-d) * Float64((Float64(-h) ^ -0.5) * (Float64(-1.0 / l) ^ 0.5))); elseif (l <= 2.55e+16) tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * Float64(1.0 + Float64(-0.125 * Float64(Float64(h * (Float64(Float64(D_m * M_m) / d) ^ 2.0)) / l)))); else tmp = Float64(d * Float64((l ^ -0.5) * (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)
tmp = 0.0;
if (l <= -1.4e+143)
tmp = -d * ((-h ^ -0.5) * ((-1.0 / l) ^ 0.5));
elseif (l <= 2.55e+16)
tmp = sqrt(((d / l) * (d / h))) * (1.0 + (-0.125 * ((h * (((D_m * M_m) / d) ^ 2.0)) / l)));
else
tmp = d * ((l ^ -0.5) * (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_] := If[LessEqual[l, -1.4e+143], N[((-d) * N[(N[Power[(-h), -0.5], $MachinePrecision] * N[Power[N[(-1.0 / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.55e+16], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.125 * N[(N[(h * N[Power[N[(N[(D$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $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^{+143}:\\
\;\;\;\;\left(-d\right) \cdot \left({\left(-h\right)}^{-0.5} \cdot {\left(\frac{-1}{\ell}\right)}^{0.5}\right)\\
\mathbf{elif}\;\ell \leq 2.55 \cdot 10^{+16}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + -0.125 \cdot \frac{h \cdot {\left(\frac{D\_m \cdot M\_m}{d}\right)}^{2}}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\
\end{array}
\end{array}
if l < -1.39999999999999999e143Initial program 66.5%
Simplified68.8%
add-sqr-sqrt68.8%
pow268.8%
sqrt-prod68.7%
sqrt-pow171.4%
metadata-eval71.4%
pow171.4%
div-inv71.4%
metadata-eval71.4%
Applied egg-rr71.4%
clear-num69.1%
sqrt-div69.1%
metadata-eval69.1%
Applied egg-rr69.1%
Taylor expanded in d around -inf 51.7%
mul-1-neg51.7%
distribute-rgt-neg-in51.7%
unpow-151.7%
metadata-eval51.7%
pow-sqr51.7%
rem-sqrt-square51.7%
rem-square-sqrt51.4%
fabs-sqr51.4%
rem-square-sqrt51.7%
Simplified51.7%
Taylor expanded in l around -inf 66.0%
distribute-lft-in66.0%
exp-sum66.6%
*-commutative66.6%
exp-to-pow66.1%
mul-1-neg66.1%
*-commutative66.1%
*-commutative66.1%
associate-*l*66.1%
metadata-eval66.1%
exp-to-pow71.4%
Simplified71.4%
if -1.39999999999999999e143 < l < 2.55e16Initial program 75.5%
Simplified74.2%
add-sqr-sqrt74.1%
pow274.1%
sqrt-prod74.1%
sqrt-pow176.1%
metadata-eval76.1%
pow176.1%
div-inv76.1%
metadata-eval76.1%
Applied egg-rr76.1%
pow176.1%
Applied egg-rr69.0%
unpow169.0%
+-commutative69.0%
+-commutative69.0%
associate-*r*69.0%
*-commutative69.0%
Simplified69.0%
Taylor expanded in h around 0 50.9%
associate-*r*51.6%
times-frac50.8%
unpow250.8%
unpow250.8%
unpow250.8%
unswap-sqr62.8%
times-frac70.3%
associate-*l/69.0%
associate-*l/69.0%
unpow269.0%
*-commutative69.0%
associate-*l/70.3%
associate-/l*70.3%
Simplified70.3%
associate-*l/72.5%
associate-*r/72.5%
Applied egg-rr72.5%
if 2.55e16 < l Initial program 52.1%
Simplified53.6%
add-sqr-sqrt53.5%
pow253.5%
sqrt-prod53.6%
sqrt-pow157.9%
metadata-eval57.9%
pow157.9%
div-inv57.9%
metadata-eval57.9%
Applied egg-rr57.9%
Taylor expanded in d around inf 45.3%
unpow-145.3%
metadata-eval45.3%
pow-sqr45.2%
rem-sqrt-square45.2%
sqr-pow45.1%
fabs-sqr45.1%
sqr-pow45.2%
Simplified45.2%
*-commutative45.2%
unpow-prod-down55.8%
Applied egg-rr55.8%
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 (<= l -2.4e-300)
(* (- d) (* (pow (- h) -0.5) (pow (/ -1.0 l) 0.5)))
(if (<= l 1.75e-169)
(* (- d) (sqrt (/ (/ 1.0 l) h)))
(* d (* (pow l -0.5) (pow 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 tmp;
if (l <= -2.4e-300) {
tmp = -d * (pow(-h, -0.5) * pow((-1.0 / l), 0.5));
} else if (l <= 1.75e-169) {
tmp = -d * sqrt(((1.0 / l) / h));
} else {
tmp = d * (pow(l, -0.5) * pow(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) :: tmp
if (l <= (-2.4d-300)) then
tmp = -d * ((-h ** (-0.5d0)) * (((-1.0d0) / l) ** 0.5d0))
else if (l <= 1.75d-169) then
tmp = -d * sqrt(((1.0d0 / l) / h))
else
tmp = d * ((l ** (-0.5d0)) * (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 tmp;
if (l <= -2.4e-300) {
tmp = -d * (Math.pow(-h, -0.5) * Math.pow((-1.0 / l), 0.5));
} else if (l <= 1.75e-169) {
tmp = -d * Math.sqrt(((1.0 / l) / h));
} else {
tmp = d * (Math.pow(l, -0.5) * Math.pow(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): tmp = 0 if l <= -2.4e-300: tmp = -d * (math.pow(-h, -0.5) * math.pow((-1.0 / l), 0.5)) elif l <= 1.75e-169: tmp = -d * math.sqrt(((1.0 / l) / h)) else: tmp = d * (math.pow(l, -0.5) * math.pow(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) tmp = 0.0 if (l <= -2.4e-300) tmp = Float64(Float64(-d) * Float64((Float64(-h) ^ -0.5) * (Float64(-1.0 / l) ^ 0.5))); elseif (l <= 1.75e-169) tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / l) / h))); else tmp = Float64(d * Float64((l ^ -0.5) * (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)
tmp = 0.0;
if (l <= -2.4e-300)
tmp = -d * ((-h ^ -0.5) * ((-1.0 / l) ^ 0.5));
elseif (l <= 1.75e-169)
tmp = -d * sqrt(((1.0 / l) / h));
else
tmp = d * ((l ^ -0.5) * (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_] := If[LessEqual[l, -2.4e-300], N[((-d) * N[(N[Power[(-h), -0.5], $MachinePrecision] * N[Power[N[(-1.0 / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.75e-169], N[((-d) * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $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 -2.4 \cdot 10^{-300}:\\
\;\;\;\;\left(-d\right) \cdot \left({\left(-h\right)}^{-0.5} \cdot {\left(\frac{-1}{\ell}\right)}^{0.5}\right)\\
\mathbf{elif}\;\ell \leq 1.75 \cdot 10^{-169}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\
\end{array}
\end{array}
if l < -2.39999999999999999e-300Initial program 71.0%
Simplified71.7%
add-sqr-sqrt71.7%
pow271.7%
sqrt-prod71.7%
sqrt-pow174.2%
metadata-eval74.2%
pow174.2%
div-inv74.2%
metadata-eval74.2%
Applied egg-rr74.2%
clear-num73.4%
sqrt-div73.4%
metadata-eval73.4%
Applied egg-rr73.4%
Taylor expanded in d around -inf 48.7%
mul-1-neg48.7%
distribute-rgt-neg-in48.7%
unpow-148.7%
metadata-eval48.7%
pow-sqr48.7%
rem-sqrt-square49.9%
rem-square-sqrt49.8%
fabs-sqr49.8%
rem-square-sqrt49.9%
Simplified49.9%
Taylor expanded in l around -inf 55.6%
distribute-lft-in55.6%
exp-sum56.0%
*-commutative56.0%
exp-to-pow56.3%
mul-1-neg56.3%
*-commutative56.3%
*-commutative56.3%
associate-*l*56.3%
metadata-eval56.3%
exp-to-pow59.1%
Simplified59.1%
if -2.39999999999999999e-300 < l < 1.7500000000000001e-169Initial program 77.7%
Simplified74.5%
add-sqr-sqrt74.5%
pow274.5%
sqrt-prod74.5%
sqrt-pow177.7%
metadata-eval77.7%
pow177.7%
div-inv77.7%
metadata-eval77.7%
Applied egg-rr77.7%
clear-num77.7%
sqrt-div77.6%
metadata-eval77.6%
Applied egg-rr77.6%
Taylor expanded in d around -inf 37.1%
mul-1-neg37.1%
distribute-rgt-neg-in37.1%
*-commutative37.1%
associate-/r*37.1%
Simplified37.1%
if 1.7500000000000001e-169 < l Initial program 61.2%
Simplified61.3%
add-sqr-sqrt61.2%
pow261.2%
sqrt-prod61.2%
sqrt-pow164.1%
metadata-eval64.1%
pow164.1%
div-inv64.1%
metadata-eval64.1%
Applied egg-rr64.1%
Taylor expanded in d around inf 47.7%
unpow-147.7%
metadata-eval47.7%
pow-sqr47.7%
rem-sqrt-square47.7%
sqr-pow47.6%
fabs-sqr47.6%
sqr-pow47.7%
Simplified47.7%
*-commutative47.7%
unpow-prod-down55.5%
Applied egg-rr55.5%
Final simplification54.9%
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 2.25e-169) (* (- d) (pow (* l h) -0.5)) (* d (* (pow l -0.5) (pow 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 tmp;
if (l <= 2.25e-169) {
tmp = -d * pow((l * h), -0.5);
} else {
tmp = d * (pow(l, -0.5) * pow(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) :: tmp
if (l <= 2.25d-169) then
tmp = -d * ((l * h) ** (-0.5d0))
else
tmp = d * ((l ** (-0.5d0)) * (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 tmp;
if (l <= 2.25e-169) {
tmp = -d * Math.pow((l * h), -0.5);
} else {
tmp = d * (Math.pow(l, -0.5) * Math.pow(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): tmp = 0 if l <= 2.25e-169: tmp = -d * math.pow((l * h), -0.5) else: tmp = d * (math.pow(l, -0.5) * math.pow(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) tmp = 0.0 if (l <= 2.25e-169) tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5)); else tmp = Float64(d * Float64((l ^ -0.5) * (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)
tmp = 0.0;
if (l <= 2.25e-169)
tmp = -d * ((l * h) ^ -0.5);
else
tmp = d * ((l ^ -0.5) * (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_] := If[LessEqual[l, 2.25e-169], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $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 2.25 \cdot 10^{-169}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\
\end{array}
\end{array}
if l < 2.2499999999999999e-169Initial program 72.4%
Simplified72.3%
add-sqr-sqrt72.3%
pow272.3%
sqrt-prod72.3%
sqrt-pow174.9%
metadata-eval74.9%
pow174.9%
div-inv74.9%
metadata-eval74.9%
Applied egg-rr74.9%
clear-num74.3%
sqrt-div74.3%
metadata-eval74.3%
Applied egg-rr74.3%
Taylor expanded in d around -inf 46.3%
mul-1-neg46.3%
distribute-rgt-neg-in46.3%
unpow-146.3%
metadata-eval46.3%
pow-sqr46.3%
rem-sqrt-square47.2%
rem-square-sqrt47.1%
fabs-sqr47.1%
rem-square-sqrt47.2%
Simplified47.2%
if 2.2499999999999999e-169 < l Initial program 61.2%
Simplified61.3%
add-sqr-sqrt61.2%
pow261.2%
sqrt-prod61.2%
sqrt-pow164.1%
metadata-eval64.1%
pow164.1%
div-inv64.1%
metadata-eval64.1%
Applied egg-rr64.1%
Taylor expanded in d around inf 47.7%
unpow-147.7%
metadata-eval47.7%
pow-sqr47.7%
rem-sqrt-square47.7%
sqr-pow47.6%
fabs-sqr47.6%
sqr-pow47.7%
Simplified47.7%
*-commutative47.7%
unpow-prod-down55.5%
Applied egg-rr55.5%
Final simplification50.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 (let* ((t_0 (pow (* l h) -0.5))) (if (<= l 2.5e-169) (* (- d) t_0) (* d t_0))))
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 = pow((l * h), -0.5);
double tmp;
if (l <= 2.5e-169) {
tmp = -d * t_0;
} else {
tmp = d * t_0;
}
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 = (l * h) ** (-0.5d0)
if (l <= 2.5d-169) then
tmp = -d * t_0
else
tmp = d * t_0
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 = Math.pow((l * h), -0.5);
double tmp;
if (l <= 2.5e-169) {
tmp = -d * t_0;
} else {
tmp = d * t_0;
}
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 = math.pow((l * h), -0.5) tmp = 0 if l <= 2.5e-169: tmp = -d * t_0 else: tmp = d * t_0 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(l * h) ^ -0.5 tmp = 0.0 if (l <= 2.5e-169) tmp = Float64(Float64(-d) * t_0); else tmp = Float64(d * t_0); 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 = (l * h) ^ -0.5;
tmp = 0.0;
if (l <= 2.5e-169)
tmp = -d * t_0;
else
tmp = d * t_0;
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[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]}, If[LessEqual[l, 2.5e-169], N[((-d) * t$95$0), $MachinePrecision], N[(d * t$95$0), $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 := {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{if}\;\ell \leq 2.5 \cdot 10^{-169}:\\
\;\;\;\;\left(-d\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;d \cdot t\_0\\
\end{array}
\end{array}
if l < 2.5000000000000001e-169Initial program 72.4%
Simplified72.3%
add-sqr-sqrt72.3%
pow272.3%
sqrt-prod72.3%
sqrt-pow174.9%
metadata-eval74.9%
pow174.9%
div-inv74.9%
metadata-eval74.9%
Applied egg-rr74.9%
clear-num74.3%
sqrt-div74.3%
metadata-eval74.3%
Applied egg-rr74.3%
Taylor expanded in d around -inf 46.3%
mul-1-neg46.3%
distribute-rgt-neg-in46.3%
unpow-146.3%
metadata-eval46.3%
pow-sqr46.3%
rem-sqrt-square47.2%
rem-square-sqrt47.1%
fabs-sqr47.1%
rem-square-sqrt47.2%
Simplified47.2%
if 2.5000000000000001e-169 < l Initial program 61.2%
Simplified61.3%
add-sqr-sqrt61.2%
pow261.2%
sqrt-prod61.2%
sqrt-pow164.1%
metadata-eval64.1%
pow164.1%
div-inv64.1%
metadata-eval64.1%
Applied egg-rr64.1%
Taylor expanded in d around inf 47.7%
unpow-147.7%
metadata-eval47.7%
pow-sqr47.7%
rem-sqrt-square47.7%
sqr-pow47.6%
fabs-sqr47.6%
sqr-pow47.7%
Simplified47.7%
Final simplification47.4%
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 2.05e-169) (* (- d) (pow (* l h) -0.5)) (* 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) {
double tmp;
if (l <= 2.05e-169) {
tmp = -d * pow((l * h), -0.5);
} else {
tmp = d * sqrt(((1.0 / l) / 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 (l <= 2.05d-169) then
tmp = -d * ((l * h) ** (-0.5d0))
else
tmp = d * sqrt(((1.0d0 / l) / 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 (l <= 2.05e-169) {
tmp = -d * Math.pow((l * h), -0.5);
} else {
tmp = d * Math.sqrt(((1.0 / l) / 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 l <= 2.05e-169: tmp = -d * math.pow((l * h), -0.5) else: tmp = d * math.sqrt(((1.0 / l) / 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 <= 2.05e-169) tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5)); else tmp = Float64(d * sqrt(Float64(Float64(1.0 / l) / 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 (l <= 2.05e-169)
tmp = -d * ((l * h) ^ -0.5);
else
tmp = d * sqrt(((1.0 / l) / 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[l, 2.05e-169], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], 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])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 2.05 \cdot 10^{-169}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\
\end{array}
\end{array}
if l < 2.0499999999999999e-169Initial program 72.4%
Simplified72.3%
add-sqr-sqrt72.3%
pow272.3%
sqrt-prod72.3%
sqrt-pow174.9%
metadata-eval74.9%
pow174.9%
div-inv74.9%
metadata-eval74.9%
Applied egg-rr74.9%
clear-num74.3%
sqrt-div74.3%
metadata-eval74.3%
Applied egg-rr74.3%
Taylor expanded in d around -inf 46.3%
mul-1-neg46.3%
distribute-rgt-neg-in46.3%
unpow-146.3%
metadata-eval46.3%
pow-sqr46.3%
rem-sqrt-square47.2%
rem-square-sqrt47.1%
fabs-sqr47.1%
rem-square-sqrt47.2%
Simplified47.2%
if 2.0499999999999999e-169 < l Initial program 61.2%
Simplified61.3%
Taylor expanded in d around inf 47.7%
*-commutative47.7%
associate-/r*48.2%
Simplified48.2%
Final simplification47.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 (* d (pow (* 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) {
return d * pow((l * h), -0.5);
}
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 * ((l * h) ** (-0.5d0))
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.pow((l * h), -0.5);
}
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.pow((l * h), -0.5)
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 * (Float64(l * h) ^ -0.5)) 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 * ((l * h) ^ -0.5);
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[Power[N[(l * h), $MachinePrecision], -0.5], $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 {\left(\ell \cdot h\right)}^{-0.5}
\end{array}
Initial program 67.7%
Simplified67.7%
add-sqr-sqrt67.6%
pow267.6%
sqrt-prod67.6%
sqrt-pow170.4%
metadata-eval70.4%
pow170.4%
div-inv70.4%
metadata-eval70.4%
Applied egg-rr70.4%
Taylor expanded in d around inf 26.6%
unpow-126.6%
metadata-eval26.6%
pow-sqr26.6%
rem-sqrt-square26.6%
sqr-pow26.5%
fabs-sqr26.5%
sqr-pow26.6%
Simplified26.6%
Final simplification26.6%
herbie shell --seed 2024039
(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)))))