
(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 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
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
(fma
(/ (* M_m (* D_m (/ 0.5 d))) l)
(* (* (- 0.25) D_m) (* (/ M_m d) h))
1.0)))
(if (<= d -2.3e-144)
(* t_0 (* (sqrt (/ d l)) (/ (sqrt (- d)) (sqrt (- h)))))
(if (<= d -3.9e-301)
(*
(- 1.0 (* (/ h l) (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ 1.0 2.0))))
(* (sqrt (/ 1.0 (* l h))) (- d)))
(if (<= d 5.4e-164)
(/
(*
(/
(*
(sqrt d)
(fma (* (pow (* (/ M_m d) D_m) 2.0) 0.25) (* -0.5 (/ h l)) 1.0))
(sqrt l))
(sqrt d))
(sqrt h))
(* (* (/ -1.0 (sqrt h)) (/ (- d) (sqrt l))) t_0))))))D_m = fabs(D);
M_m = fabs(M);
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 = fma(((M_m * (D_m * (0.5 / d))) / l), ((-0.25 * D_m) * ((M_m / d) * h)), 1.0);
double tmp;
if (d <= -2.3e-144) {
tmp = t_0 * (sqrt((d / l)) * (sqrt(-d) / sqrt(-h)));
} else if (d <= -3.9e-301) {
tmp = (1.0 - ((h / l) * (pow(((M_m * D_m) / (2.0 * d)), 2.0) * (1.0 / 2.0)))) * (sqrt((1.0 / (l * h))) * -d);
} else if (d <= 5.4e-164) {
tmp = (((sqrt(d) * fma((pow(((M_m / d) * D_m), 2.0) * 0.25), (-0.5 * (h / l)), 1.0)) / sqrt(l)) * sqrt(d)) / sqrt(h);
} else {
tmp = ((-1.0 / sqrt(h)) * (-d / sqrt(l))) * t_0;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) 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 = fma(Float64(Float64(M_m * Float64(D_m * Float64(0.5 / d))) / l), Float64(Float64(Float64(-0.25) * D_m) * Float64(Float64(M_m / d) * h)), 1.0) tmp = 0.0 if (d <= -2.3e-144) tmp = Float64(t_0 * Float64(sqrt(Float64(d / l)) * Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))))); elseif (d <= -3.9e-301) tmp = Float64(Float64(1.0 - Float64(Float64(h / l) * Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(1.0 / 2.0)))) * Float64(sqrt(Float64(1.0 / Float64(l * h))) * Float64(-d))); elseif (d <= 5.4e-164) tmp = Float64(Float64(Float64(Float64(sqrt(d) * fma(Float64((Float64(Float64(M_m / d) * D_m) ^ 2.0) * 0.25), Float64(-0.5 * Float64(h / l)), 1.0)) / sqrt(l)) * sqrt(d)) / sqrt(h)); else tmp = Float64(Float64(Float64(-1.0 / sqrt(h)) * Float64(Float64(-d) / sqrt(l))) * t_0); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $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[(N[(N[(M$95$m * N[(D$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(N[((-0.25) * D$95$m), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[d, -2.3e-144], N[(t$95$0 * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -3.9e-301], N[(N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(1.0 / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-d)), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.4e-164], N[(N[(N[(N[(N[Sqrt[d], $MachinePrecision] * N[(N[(N[Power[N[(N[(M$95$m / d), $MachinePrecision] * D$95$m), $MachinePrecision], 2.0], $MachinePrecision] * 0.25), $MachinePrecision] * N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * N[Sqrt[d], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision], N[(N[(N[(-1.0 / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[((-d) / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{M\_m \cdot \left(D\_m \cdot \frac{0.5}{d}\right)}{\ell}, \left(\left(-0.25\right) \cdot D\_m\right) \cdot \left(\frac{M\_m}{d} \cdot h\right), 1\right)\\
\mathbf{if}\;d \leq -2.3 \cdot 10^{-144}:\\
\;\;\;\;t\_0 \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \frac{\sqrt{-d}}{\sqrt{-h}}\right)\\
\mathbf{elif}\;d \leq -3.9 \cdot 10^{-301}:\\
\;\;\;\;\left(1 - \frac{h}{\ell} \cdot \left({\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{1}{2}\right)\right) \cdot \left(\sqrt{\frac{1}{\ell \cdot h}} \cdot \left(-d\right)\right)\\
\mathbf{elif}\;d \leq 5.4 \cdot 10^{-164}:\\
\;\;\;\;\frac{\frac{\sqrt{d} \cdot \mathsf{fma}\left({\left(\frac{M\_m}{d} \cdot D\_m\right)}^{2} \cdot 0.25, -0.5 \cdot \frac{h}{\ell}, 1\right)}{\sqrt{\ell}} \cdot \sqrt{d}}{\sqrt{h}}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{-1}{\sqrt{h}} \cdot \frac{-d}{\sqrt{\ell}}\right) \cdot t\_0\\
\end{array}
\end{array}
if d < -2.3e-144Initial program 76.5%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6476.5
Applied rewrites76.5%
Applied rewrites78.4%
lift-/.f64N/A
metadata-eval78.4
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
frac-2negN/A
sqrt-divN/A
pow1/2N/A
lower-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-neg.f6487.8
Applied rewrites87.8%
if -2.3e-144 < d < -3.9000000000000001e-301Initial program 38.1%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6438.1
Applied rewrites38.1%
lift-/.f64N/A
metadata-eval38.1
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6438.1
Applied rewrites38.1%
Taylor expanded in h around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6467.9
Applied rewrites67.9%
if -3.9000000000000001e-301 < d < 5.4000000000000003e-164Initial program 39.7%
Applied rewrites52.4%
Applied rewrites62.1%
if 5.4000000000000003e-164 < d Initial program 78.7%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6478.7
Applied rewrites78.7%
Applied rewrites79.9%
lift-/.f64N/A
metadata-eval79.9
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6479.9
Applied rewrites79.9%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-unprodN/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
sqrt-divN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lift-*.f64N/A
sqrt-prodN/A
*-rgt-identityN/A
times-fracN/A
frac-2negN/A
times-fracN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
times-fracN/A
lower-*.f64N/A
Applied rewrites92.7%
Final simplification84.4%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
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 l) (/ 1.0 2.0)) (pow (/ d h) (/ 1.0 2.0)))
(-
1.0
(* (/ h l) (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ 1.0 2.0)))))))
(if (<= t_0 -5e-132)
(/
(* (* (/ (* D_m D_m) d) (sqrt (* l h))) (* -0.125 (* M_m M_m)))
(* l l))
(if (<= t_0 0.0)
(* (sqrt (/ 1.0 (* l h))) (- d))
(/ (sqrt (/ d l)) (sqrt (/ h d)))))))D_m = fabs(D);
M_m = fabs(M);
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 / l), (1.0 / 2.0)) * pow((d / h), (1.0 / 2.0))) * (1.0 - ((h / l) * (pow(((M_m * D_m) / (2.0 * d)), 2.0) * (1.0 / 2.0))));
double tmp;
if (t_0 <= -5e-132) {
tmp = ((((D_m * D_m) / d) * sqrt((l * h))) * (-0.125 * (M_m * M_m))) / (l * l);
} else if (t_0 <= 0.0) {
tmp = sqrt((1.0 / (l * h))) * -d;
} else {
tmp = sqrt((d / l)) / sqrt((h / d));
}
return tmp;
}
D_m = abs(d)
M_m = abs(m)
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 / l) ** (1.0d0 / 2.0d0)) * ((d / h) ** (1.0d0 / 2.0d0))) * (1.0d0 - ((h / l) * ((((m_m * d_m) / (2.0d0 * d)) ** 2.0d0) * (1.0d0 / 2.0d0))))
if (t_0 <= (-5d-132)) then
tmp = ((((d_m * d_m) / d) * sqrt((l * h))) * ((-0.125d0) * (m_m * m_m))) / (l * l)
else if (t_0 <= 0.0d0) then
tmp = sqrt((1.0d0 / (l * h))) * -d
else
tmp = sqrt((d / l)) / sqrt((h / d))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
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 / l), (1.0 / 2.0)) * Math.pow((d / h), (1.0 / 2.0))) * (1.0 - ((h / l) * (Math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (1.0 / 2.0))));
double tmp;
if (t_0 <= -5e-132) {
tmp = ((((D_m * D_m) / d) * Math.sqrt((l * h))) * (-0.125 * (M_m * M_m))) / (l * l);
} else if (t_0 <= 0.0) {
tmp = Math.sqrt((1.0 / (l * h))) * -d;
} else {
tmp = Math.sqrt((d / l)) / Math.sqrt((h / d));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [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 / l), (1.0 / 2.0)) * math.pow((d / h), (1.0 / 2.0))) * (1.0 - ((h / l) * (math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (1.0 / 2.0)))) tmp = 0 if t_0 <= -5e-132: tmp = ((((D_m * D_m) / d) * math.sqrt((l * h))) * (-0.125 * (M_m * M_m))) / (l * l) elif t_0 <= 0.0: tmp = math.sqrt((1.0 / (l * h))) * -d else: tmp = math.sqrt((d / l)) / math.sqrt((h / d)) return tmp
D_m = abs(D) M_m = abs(M) 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(Float64((Float64(d / l) ^ Float64(1.0 / 2.0)) * (Float64(d / h) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(h / l) * Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(1.0 / 2.0))))) tmp = 0.0 if (t_0 <= -5e-132) tmp = Float64(Float64(Float64(Float64(Float64(D_m * D_m) / d) * sqrt(Float64(l * h))) * Float64(-0.125 * Float64(M_m * M_m))) / Float64(l * l)); elseif (t_0 <= 0.0) tmp = Float64(sqrt(Float64(1.0 / Float64(l * h))) * Float64(-d)); else tmp = Float64(sqrt(Float64(d / l)) / sqrt(Float64(h / d))); end return tmp end
D_m = abs(D);
M_m = abs(M);
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 / l) ^ (1.0 / 2.0)) * ((d / h) ^ (1.0 / 2.0))) * (1.0 - ((h / l) * ((((M_m * D_m) / (2.0 * d)) ^ 2.0) * (1.0 / 2.0))));
tmp = 0.0;
if (t_0 <= -5e-132)
tmp = ((((D_m * D_m) / d) * sqrt((l * h))) * (-0.125 * (M_m * M_m))) / (l * l);
elseif (t_0 <= 0.0)
tmp = sqrt((1.0 / (l * h))) * -d;
else
tmp = sqrt((d / l)) / sqrt((h / d));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $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[(N[(N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(1.0 / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-132], N[(N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision] * N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.125 * N[(M$95$m * M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-d)), $MachinePrecision], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left({\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{1}{2}\right)\right)\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-132}:\\
\;\;\;\;\frac{\left(\frac{D\_m \cdot D\_m}{d} \cdot \sqrt{\ell \cdot h}\right) \cdot \left(-0.125 \cdot \left(M\_m \cdot M\_m\right)\right)}{\ell \cdot \ell}\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\sqrt{\frac{1}{\ell \cdot h}} \cdot \left(-d\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\frac{d}{\ell}}}{\sqrt{\frac{h}{d}}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -4.9999999999999999e-132Initial program 86.4%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites29.2%
Taylor expanded in h around inf
Applied rewrites34.8%
if -4.9999999999999999e-132 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0Initial program 30.4%
Taylor expanded in l around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6458.7
Applied rewrites58.7%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 61.4%
Taylor expanded in h around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6437.6
Applied rewrites37.6%
Applied rewrites64.6%
Final simplification53.7%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
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 l) (/ 1.0 2.0)) (pow (/ d h) (/ 1.0 2.0)))
(-
1.0
(* (/ h l) (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ 1.0 2.0)))))))
(if (<= t_0 -5e-132)
(/
(* (* (/ (* M_m M_m) d) (sqrt (* l h))) (* -0.125 (* D_m D_m)))
(* l l))
(if (<= t_0 0.0)
(* (sqrt (/ 1.0 (* l h))) (- d))
(/ (sqrt (/ d l)) (sqrt (/ h d)))))))D_m = fabs(D);
M_m = fabs(M);
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 / l), (1.0 / 2.0)) * pow((d / h), (1.0 / 2.0))) * (1.0 - ((h / l) * (pow(((M_m * D_m) / (2.0 * d)), 2.0) * (1.0 / 2.0))));
double tmp;
if (t_0 <= -5e-132) {
tmp = ((((M_m * M_m) / d) * sqrt((l * h))) * (-0.125 * (D_m * D_m))) / (l * l);
} else if (t_0 <= 0.0) {
tmp = sqrt((1.0 / (l * h))) * -d;
} else {
tmp = sqrt((d / l)) / sqrt((h / d));
}
return tmp;
}
D_m = abs(d)
M_m = abs(m)
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 / l) ** (1.0d0 / 2.0d0)) * ((d / h) ** (1.0d0 / 2.0d0))) * (1.0d0 - ((h / l) * ((((m_m * d_m) / (2.0d0 * d)) ** 2.0d0) * (1.0d0 / 2.0d0))))
if (t_0 <= (-5d-132)) then
tmp = ((((m_m * m_m) / d) * sqrt((l * h))) * ((-0.125d0) * (d_m * d_m))) / (l * l)
else if (t_0 <= 0.0d0) then
tmp = sqrt((1.0d0 / (l * h))) * -d
else
tmp = sqrt((d / l)) / sqrt((h / d))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
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 / l), (1.0 / 2.0)) * Math.pow((d / h), (1.0 / 2.0))) * (1.0 - ((h / l) * (Math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (1.0 / 2.0))));
double tmp;
if (t_0 <= -5e-132) {
tmp = ((((M_m * M_m) / d) * Math.sqrt((l * h))) * (-0.125 * (D_m * D_m))) / (l * l);
} else if (t_0 <= 0.0) {
tmp = Math.sqrt((1.0 / (l * h))) * -d;
} else {
tmp = Math.sqrt((d / l)) / Math.sqrt((h / d));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [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 / l), (1.0 / 2.0)) * math.pow((d / h), (1.0 / 2.0))) * (1.0 - ((h / l) * (math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (1.0 / 2.0)))) tmp = 0 if t_0 <= -5e-132: tmp = ((((M_m * M_m) / d) * math.sqrt((l * h))) * (-0.125 * (D_m * D_m))) / (l * l) elif t_0 <= 0.0: tmp = math.sqrt((1.0 / (l * h))) * -d else: tmp = math.sqrt((d / l)) / math.sqrt((h / d)) return tmp
D_m = abs(D) M_m = abs(M) 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(Float64((Float64(d / l) ^ Float64(1.0 / 2.0)) * (Float64(d / h) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(h / l) * Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(1.0 / 2.0))))) tmp = 0.0 if (t_0 <= -5e-132) tmp = Float64(Float64(Float64(Float64(Float64(M_m * M_m) / d) * sqrt(Float64(l * h))) * Float64(-0.125 * Float64(D_m * D_m))) / Float64(l * l)); elseif (t_0 <= 0.0) tmp = Float64(sqrt(Float64(1.0 / Float64(l * h))) * Float64(-d)); else tmp = Float64(sqrt(Float64(d / l)) / sqrt(Float64(h / d))); end return tmp end
D_m = abs(D);
M_m = abs(M);
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 / l) ^ (1.0 / 2.0)) * ((d / h) ^ (1.0 / 2.0))) * (1.0 - ((h / l) * ((((M_m * D_m) / (2.0 * d)) ^ 2.0) * (1.0 / 2.0))));
tmp = 0.0;
if (t_0 <= -5e-132)
tmp = ((((M_m * M_m) / d) * sqrt((l * h))) * (-0.125 * (D_m * D_m))) / (l * l);
elseif (t_0 <= 0.0)
tmp = sqrt((1.0 / (l * h))) * -d;
else
tmp = sqrt((d / l)) / sqrt((h / d));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $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[(N[(N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(1.0 / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-132], N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision] * N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.125 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-d)), $MachinePrecision], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left({\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{1}{2}\right)\right)\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-132}:\\
\;\;\;\;\frac{\left(\frac{M\_m \cdot M\_m}{d} \cdot \sqrt{\ell \cdot h}\right) \cdot \left(-0.125 \cdot \left(D\_m \cdot D\_m\right)\right)}{\ell \cdot \ell}\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\sqrt{\frac{1}{\ell \cdot h}} \cdot \left(-d\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\frac{d}{\ell}}}{\sqrt{\frac{h}{d}}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -4.9999999999999999e-132Initial program 86.4%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites29.2%
Taylor expanded in h around 0
Applied rewrites2.1%
Taylor expanded in h around inf
Applied rewrites32.6%
if -4.9999999999999999e-132 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0Initial program 30.4%
Taylor expanded in l around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6458.7
Applied rewrites58.7%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 61.4%
Taylor expanded in h around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6437.6
Applied rewrites37.6%
Applied rewrites64.6%
Final simplification53.0%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
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
(fma
(/ (* M_m (* D_m (/ 0.5 d))) l)
(* (* (- 0.25) D_m) (* (/ M_m d) h))
1.0)))
(if (<= d -2.3e-144)
(* t_0 (* (sqrt (/ d l)) (/ (sqrt (- d)) (sqrt (- h)))))
(if (<= d -3.9e-301)
(*
(- 1.0 (* (/ h l) (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ 1.0 2.0))))
(* (sqrt (/ 1.0 (* l h))) (- d)))
(* (* (/ -1.0 (sqrt h)) (/ (- d) (sqrt l))) t_0)))))D_m = fabs(D);
M_m = fabs(M);
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 = fma(((M_m * (D_m * (0.5 / d))) / l), ((-0.25 * D_m) * ((M_m / d) * h)), 1.0);
double tmp;
if (d <= -2.3e-144) {
tmp = t_0 * (sqrt((d / l)) * (sqrt(-d) / sqrt(-h)));
} else if (d <= -3.9e-301) {
tmp = (1.0 - ((h / l) * (pow(((M_m * D_m) / (2.0 * d)), 2.0) * (1.0 / 2.0)))) * (sqrt((1.0 / (l * h))) * -d);
} else {
tmp = ((-1.0 / sqrt(h)) * (-d / sqrt(l))) * t_0;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) 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 = fma(Float64(Float64(M_m * Float64(D_m * Float64(0.5 / d))) / l), Float64(Float64(Float64(-0.25) * D_m) * Float64(Float64(M_m / d) * h)), 1.0) tmp = 0.0 if (d <= -2.3e-144) tmp = Float64(t_0 * Float64(sqrt(Float64(d / l)) * Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))))); elseif (d <= -3.9e-301) tmp = Float64(Float64(1.0 - Float64(Float64(h / l) * Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(1.0 / 2.0)))) * Float64(sqrt(Float64(1.0 / Float64(l * h))) * Float64(-d))); else tmp = Float64(Float64(Float64(-1.0 / sqrt(h)) * Float64(Float64(-d) / sqrt(l))) * t_0); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $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[(N[(N[(M$95$m * N[(D$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(N[((-0.25) * D$95$m), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[d, -2.3e-144], N[(t$95$0 * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -3.9e-301], N[(N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(1.0 / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-d)), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-1.0 / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[((-d) / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{M\_m \cdot \left(D\_m \cdot \frac{0.5}{d}\right)}{\ell}, \left(\left(-0.25\right) \cdot D\_m\right) \cdot \left(\frac{M\_m}{d} \cdot h\right), 1\right)\\
\mathbf{if}\;d \leq -2.3 \cdot 10^{-144}:\\
\;\;\;\;t\_0 \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \frac{\sqrt{-d}}{\sqrt{-h}}\right)\\
\mathbf{elif}\;d \leq -3.9 \cdot 10^{-301}:\\
\;\;\;\;\left(1 - \frac{h}{\ell} \cdot \left({\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{1}{2}\right)\right) \cdot \left(\sqrt{\frac{1}{\ell \cdot h}} \cdot \left(-d\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{-1}{\sqrt{h}} \cdot \frac{-d}{\sqrt{\ell}}\right) \cdot t\_0\\
\end{array}
\end{array}
if d < -2.3e-144Initial program 76.5%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6476.5
Applied rewrites76.5%
Applied rewrites78.4%
lift-/.f64N/A
metadata-eval78.4
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
frac-2negN/A
sqrt-divN/A
pow1/2N/A
lower-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-neg.f6487.8
Applied rewrites87.8%
if -2.3e-144 < d < -3.9000000000000001e-301Initial program 38.1%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6438.1
Applied rewrites38.1%
lift-/.f64N/A
metadata-eval38.1
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6438.1
Applied rewrites38.1%
Taylor expanded in h around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6467.9
Applied rewrites67.9%
if -3.9000000000000001e-301 < d Initial program 70.3%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6470.3
Applied rewrites70.3%
Applied rewrites71.1%
lift-/.f64N/A
metadata-eval71.1
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6471.1
Applied rewrites71.1%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-unprodN/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
sqrt-divN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lift-*.f64N/A
sqrt-prodN/A
*-rgt-identityN/A
times-fracN/A
frac-2negN/A
times-fracN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
times-fracN/A
lower-*.f64N/A
Applied rewrites83.9%
Final simplification83.1%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
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
(fma
(/ (* M_m (* D_m (/ 0.5 d))) l)
(* (* (- 0.25) D_m) (* (/ M_m d) h))
1.0)))
(if (<= d -7.2e-55)
(* t_0 (* (sqrt (/ d l)) (/ (sqrt (- d)) (sqrt (- h)))))
(if (<= d -6.7e-307)
(* (* (sqrt (/ 1.0 (* l h))) (- d)) t_0)
(* (* (/ -1.0 (sqrt h)) (/ (- d) (sqrt l))) t_0)))))D_m = fabs(D);
M_m = fabs(M);
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 = fma(((M_m * (D_m * (0.5 / d))) / l), ((-0.25 * D_m) * ((M_m / d) * h)), 1.0);
double tmp;
if (d <= -7.2e-55) {
tmp = t_0 * (sqrt((d / l)) * (sqrt(-d) / sqrt(-h)));
} else if (d <= -6.7e-307) {
tmp = (sqrt((1.0 / (l * h))) * -d) * t_0;
} else {
tmp = ((-1.0 / sqrt(h)) * (-d / sqrt(l))) * t_0;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) 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 = fma(Float64(Float64(M_m * Float64(D_m * Float64(0.5 / d))) / l), Float64(Float64(Float64(-0.25) * D_m) * Float64(Float64(M_m / d) * h)), 1.0) tmp = 0.0 if (d <= -7.2e-55) tmp = Float64(t_0 * Float64(sqrt(Float64(d / l)) * Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))))); elseif (d <= -6.7e-307) tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * Float64(-d)) * t_0); else tmp = Float64(Float64(Float64(-1.0 / sqrt(h)) * Float64(Float64(-d) / sqrt(l))) * t_0); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $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[(N[(N[(M$95$m * N[(D$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(N[((-0.25) * D$95$m), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[d, -7.2e-55], N[(t$95$0 * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -6.7e-307], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-d)), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(N[(-1.0 / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[((-d) / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{M\_m \cdot \left(D\_m \cdot \frac{0.5}{d}\right)}{\ell}, \left(\left(-0.25\right) \cdot D\_m\right) \cdot \left(\frac{M\_m}{d} \cdot h\right), 1\right)\\
\mathbf{if}\;d \leq -7.2 \cdot 10^{-55}:\\
\;\;\;\;t\_0 \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \frac{\sqrt{-d}}{\sqrt{-h}}\right)\\
\mathbf{elif}\;d \leq -6.7 \cdot 10^{-307}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot \left(-d\right)\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{-1}{\sqrt{h}} \cdot \frac{-d}{\sqrt{\ell}}\right) \cdot t\_0\\
\end{array}
\end{array}
if d < -7.2000000000000001e-55Initial program 78.0%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6478.0
Applied rewrites78.0%
Applied rewrites79.4%
lift-/.f64N/A
metadata-eval79.4
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
frac-2negN/A
sqrt-divN/A
pow1/2N/A
lower-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-neg.f6491.0
Applied rewrites91.0%
if -7.2000000000000001e-55 < d < -6.6999999999999999e-307Initial program 47.3%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6447.3
Applied rewrites47.3%
Applied rewrites47.0%
lift-/.f64N/A
metadata-eval47.0
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6447.0
Applied rewrites47.0%
Taylor expanded in h around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6467.1
Applied rewrites67.1%
if -6.6999999999999999e-307 < d Initial program 70.8%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6470.8
Applied rewrites70.8%
Applied rewrites71.6%
lift-/.f64N/A
metadata-eval71.6
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6471.6
Applied rewrites71.6%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-unprodN/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
sqrt-divN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lift-*.f64N/A
sqrt-prodN/A
*-rgt-identityN/A
times-fracN/A
frac-2negN/A
times-fracN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
times-fracN/A
lower-*.f64N/A
Applied rewrites84.5%
Final simplification82.9%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
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))) l))
(t_1 (fma t_0 (* (* (- 0.25) D_m) (* (/ M_m d) h)) 1.0))
(t_2
(*
(fma t_0 (/ (* (* -0.25 D_m) (* M_m h)) d) 1.0)
(* (sqrt (/ d h)) (sqrt (/ d l))))))
(if (<= h -7.6e+151)
t_2
(if (<= h -4e-310)
(* (* (sqrt (/ 1.0 (* l h))) (- d)) t_1)
(if (<= h 1.5e+190) (* (/ d (sqrt (* l h))) t_1) t_2)))))D_m = fabs(D);
M_m = fabs(M);
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))) / l;
double t_1 = fma(t_0, ((-0.25 * D_m) * ((M_m / d) * h)), 1.0);
double t_2 = fma(t_0, (((-0.25 * D_m) * (M_m * h)) / d), 1.0) * (sqrt((d / h)) * sqrt((d / l)));
double tmp;
if (h <= -7.6e+151) {
tmp = t_2;
} else if (h <= -4e-310) {
tmp = (sqrt((1.0 / (l * h))) * -d) * t_1;
} else if (h <= 1.5e+190) {
tmp = (d / sqrt((l * h))) * t_1;
} else {
tmp = t_2;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) 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(Float64(M_m * Float64(D_m * Float64(0.5 / d))) / l) t_1 = fma(t_0, Float64(Float64(Float64(-0.25) * D_m) * Float64(Float64(M_m / d) * h)), 1.0) t_2 = Float64(fma(t_0, Float64(Float64(Float64(-0.25 * D_m) * Float64(M_m * h)) / d), 1.0) * Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l)))) tmp = 0.0 if (h <= -7.6e+151) tmp = t_2; elseif (h <= -4e-310) tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * Float64(-d)) * t_1); elseif (h <= 1.5e+190) tmp = Float64(Float64(d / sqrt(Float64(l * h))) * t_1); else tmp = t_2; end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $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[(N[(M$95$m * N[(D$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[((-0.25) * D$95$m), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$0 * N[(N[(N[(-0.25 * D$95$m), $MachinePrecision] * N[(M$95$m * h), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -7.6e+151], t$95$2, If[LessEqual[h, -4e-310], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-d)), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[h, 1.5e+190], N[(N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], t$95$2]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{M\_m \cdot \left(D\_m \cdot \frac{0.5}{d}\right)}{\ell}\\
t_1 := \mathsf{fma}\left(t\_0, \left(\left(-0.25\right) \cdot D\_m\right) \cdot \left(\frac{M\_m}{d} \cdot h\right), 1\right)\\
t_2 := \mathsf{fma}\left(t\_0, \frac{\left(-0.25 \cdot D\_m\right) \cdot \left(M\_m \cdot h\right)}{d}, 1\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\\
\mathbf{if}\;h \leq -7.6 \cdot 10^{+151}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;h \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot \left(-d\right)\right) \cdot t\_1\\
\mathbf{elif}\;h \leq 1.5 \cdot 10^{+190}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if h < -7.6000000000000001e151 or 1.49999999999999991e190 < h Initial program 56.8%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6456.8
Applied rewrites56.8%
Applied rewrites52.2%
lift-/.f64N/A
metadata-eval52.2
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6452.2
Applied rewrites52.2%
lift-neg.f64N/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval49.4
Applied rewrites49.4%
if -7.6000000000000001e151 < h < -3.999999999999988e-310Initial program 68.5%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6468.5
Applied rewrites68.5%
Applied rewrites70.9%
lift-/.f64N/A
metadata-eval70.9
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6470.9
Applied rewrites70.9%
Taylor expanded in h around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6484.0
Applied rewrites84.0%
if -3.999999999999988e-310 < h < 1.49999999999999991e190Initial program 73.4%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6473.4
Applied rewrites73.4%
Applied rewrites75.3%
lift-/.f64N/A
metadata-eval75.3
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6475.3
Applied rewrites75.3%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-unprodN/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
sqrt-divN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lower-/.f6485.4
Applied rewrites85.4%
Final simplification77.4%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
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))) l))
(t_1 (fma t_0 (* (* (- 0.25) D_m) (* (/ M_m d) h)) 1.0)))
(if (<= h -7.6e+151)
(*
(fma t_0 (/ (* (* -0.25 D_m) (* M_m h)) d) 1.0)
(* (sqrt (/ d h)) (sqrt (/ d l))))
(if (<= h -4e-310)
(* (* (sqrt (/ 1.0 (* l h))) (- d)) t_1)
(* (* (/ -1.0 (sqrt h)) (/ (- d) (sqrt l))) t_1)))))D_m = fabs(D);
M_m = fabs(M);
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))) / l;
double t_1 = fma(t_0, ((-0.25 * D_m) * ((M_m / d) * h)), 1.0);
double tmp;
if (h <= -7.6e+151) {
tmp = fma(t_0, (((-0.25 * D_m) * (M_m * h)) / d), 1.0) * (sqrt((d / h)) * sqrt((d / l)));
} else if (h <= -4e-310) {
tmp = (sqrt((1.0 / (l * h))) * -d) * t_1;
} else {
tmp = ((-1.0 / sqrt(h)) * (-d / sqrt(l))) * t_1;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) 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(Float64(M_m * Float64(D_m * Float64(0.5 / d))) / l) t_1 = fma(t_0, Float64(Float64(Float64(-0.25) * D_m) * Float64(Float64(M_m / d) * h)), 1.0) tmp = 0.0 if (h <= -7.6e+151) tmp = Float64(fma(t_0, Float64(Float64(Float64(-0.25 * D_m) * Float64(M_m * h)) / d), 1.0) * Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l)))); elseif (h <= -4e-310) tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * Float64(-d)) * t_1); else tmp = Float64(Float64(Float64(-1.0 / sqrt(h)) * Float64(Float64(-d) / sqrt(l))) * t_1); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $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[(N[(M$95$m * N[(D$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[((-0.25) * D$95$m), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[h, -7.6e+151], N[(N[(t$95$0 * N[(N[(N[(-0.25 * D$95$m), $MachinePrecision] * N[(M$95$m * h), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -4e-310], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-d)), $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(N[(-1.0 / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[((-d) / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{M\_m \cdot \left(D\_m \cdot \frac{0.5}{d}\right)}{\ell}\\
t_1 := \mathsf{fma}\left(t\_0, \left(\left(-0.25\right) \cdot D\_m\right) \cdot \left(\frac{M\_m}{d} \cdot h\right), 1\right)\\
\mathbf{if}\;h \leq -7.6 \cdot 10^{+151}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, \frac{\left(-0.25 \cdot D\_m\right) \cdot \left(M\_m \cdot h\right)}{d}, 1\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\\
\mathbf{elif}\;h \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot \left(-d\right)\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{-1}{\sqrt{h}} \cdot \frac{-d}{\sqrt{\ell}}\right) \cdot t\_1\\
\end{array}
\end{array}
if h < -7.6000000000000001e151Initial program 51.9%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6451.9
Applied rewrites51.9%
Applied rewrites47.0%
lift-/.f64N/A
metadata-eval47.0
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6447.0
Applied rewrites47.0%
lift-neg.f64N/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval41.3
Applied rewrites41.3%
if -7.6000000000000001e151 < h < -3.999999999999988e-310Initial program 68.5%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6468.5
Applied rewrites68.5%
Applied rewrites70.9%
lift-/.f64N/A
metadata-eval70.9
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6470.9
Applied rewrites70.9%
Taylor expanded in h around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6484.0
Applied rewrites84.0%
if -3.999999999999988e-310 < h Initial program 71.3%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6471.3
Applied rewrites71.3%
Applied rewrites72.1%
lift-/.f64N/A
metadata-eval72.1
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6472.1
Applied rewrites72.1%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-unprodN/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
sqrt-divN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lift-*.f64N/A
sqrt-prodN/A
*-rgt-identityN/A
times-fracN/A
frac-2negN/A
times-fracN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
times-fracN/A
lower-*.f64N/A
Applied rewrites85.1%
Final simplification79.9%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
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)))
(t_1
(*
(/ (sqrt (/ h l)) (fabs l))
(* (/ (* M_m M_m) d) (* (* D_m D_m) 0.125)))))
(if (<= d -1.45e+65)
(* (sqrt (/ (/ (- d) l) h)) t_0)
(if (<= d -2.8e+23)
t_1
(if (<= d -3.8e-75)
(/ (/ t_0 (sqrt (- l))) (sqrt (/ h d)))
(if (<= d -5e-311)
t_1
(*
(/ d (sqrt (* l h)))
(fma
(/ (* M_m (* D_m (/ 0.5 d))) l)
(* (* (- 0.25) D_m) (* (/ M_m d) h))
1.0))))))))D_m = fabs(D);
M_m = fabs(M);
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);
double t_1 = (sqrt((h / l)) / fabs(l)) * (((M_m * M_m) / d) * ((D_m * D_m) * 0.125));
double tmp;
if (d <= -1.45e+65) {
tmp = sqrt(((-d / l) / h)) * t_0;
} else if (d <= -2.8e+23) {
tmp = t_1;
} else if (d <= -3.8e-75) {
tmp = (t_0 / sqrt(-l)) / sqrt((h / d));
} else if (d <= -5e-311) {
tmp = t_1;
} else {
tmp = (d / sqrt((l * h))) * fma(((M_m * (D_m * (0.5 / d))) / l), ((-0.25 * D_m) * ((M_m / d) * h)), 1.0);
}
return tmp;
}
D_m = abs(D) M_m = abs(M) 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)) t_1 = Float64(Float64(sqrt(Float64(h / l)) / abs(l)) * Float64(Float64(Float64(M_m * M_m) / d) * Float64(Float64(D_m * D_m) * 0.125))) tmp = 0.0 if (d <= -1.45e+65) tmp = Float64(sqrt(Float64(Float64(Float64(-d) / l) / h)) * t_0); elseif (d <= -2.8e+23) tmp = t_1; elseif (d <= -3.8e-75) tmp = Float64(Float64(t_0 / sqrt(Float64(-l))) / sqrt(Float64(h / d))); elseif (d <= -5e-311) tmp = t_1; else tmp = Float64(Float64(d / sqrt(Float64(l * h))) * fma(Float64(Float64(M_m * Float64(D_m * Float64(0.5 / d))) / l), Float64(Float64(Float64(-0.25) * D_m) * Float64(Float64(M_m / d) * h)), 1.0)); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $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[(-d)], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] / N[Abs[l], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision] * N[(N[(D$95$m * D$95$m), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.45e+65], N[(N[Sqrt[N[(N[((-d) / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[d, -2.8e+23], t$95$1, If[LessEqual[d, -3.8e-75], N[(N[(t$95$0 / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5e-311], t$95$1, N[(N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M$95$m * N[(D$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(N[((-0.25) * D$95$m), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{-d}\\
t_1 := \frac{\sqrt{\frac{h}{\ell}}}{\left|\ell\right|} \cdot \left(\frac{M\_m \cdot M\_m}{d} \cdot \left(\left(D\_m \cdot D\_m\right) \cdot 0.125\right)\right)\\
\mathbf{if}\;d \leq -1.45 \cdot 10^{+65}:\\
\;\;\;\;\sqrt{\frac{\frac{-d}{\ell}}{h}} \cdot t\_0\\
\mathbf{elif}\;d \leq -2.8 \cdot 10^{+23}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -3.8 \cdot 10^{-75}:\\
\;\;\;\;\frac{\frac{t\_0}{\sqrt{-\ell}}}{\sqrt{\frac{h}{d}}}\\
\mathbf{elif}\;d \leq -5 \cdot 10^{-311}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \mathsf{fma}\left(\frac{M\_m \cdot \left(D\_m \cdot \frac{0.5}{d}\right)}{\ell}, \left(\left(-0.25\right) \cdot D\_m\right) \cdot \left(\frac{M\_m}{d} \cdot h\right), 1\right)\\
\end{array}
\end{array}
if d < -1.45e65Initial program 72.0%
Taylor expanded in h around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f641.9
Applied rewrites1.9%
Applied rewrites60.4%
Applied rewrites76.3%
if -1.45e65 < d < -2.8e23 or -3.79999999999999994e-75 < d < -5.00000000000023e-311Initial program 51.4%
Taylor expanded in h around -inf
associate-*r*N/A
lower-*.f64N/A
Applied rewrites37.4%
Applied rewrites50.3%
if -2.8e23 < d < -3.79999999999999994e-75Initial program 86.5%
Taylor expanded in h around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f642.7
Applied rewrites2.7%
Applied rewrites61.1%
Applied rewrites64.3%
if -5.00000000000023e-311 < d Initial program 71.3%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6471.3
Applied rewrites71.3%
Applied rewrites72.1%
lift-/.f64N/A
metadata-eval72.1
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6472.1
Applied rewrites72.1%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-unprodN/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
sqrt-divN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lower-/.f6477.0
Applied rewrites77.0%
Final simplification70.0%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
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
(fma
(/ (* M_m (* D_m (/ 0.5 d))) l)
(* (* (- 0.25) D_m) (* (/ M_m d) h))
1.0)))
(if (<= l -4e-310)
(* (* (sqrt (/ 1.0 (* l h))) (- d)) t_0)
(* (/ d (sqrt (* l h))) t_0))))D_m = fabs(D);
M_m = fabs(M);
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 = fma(((M_m * (D_m * (0.5 / d))) / l), ((-0.25 * D_m) * ((M_m / d) * h)), 1.0);
double tmp;
if (l <= -4e-310) {
tmp = (sqrt((1.0 / (l * h))) * -d) * t_0;
} else {
tmp = (d / sqrt((l * h))) * t_0;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) 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 = fma(Float64(Float64(M_m * Float64(D_m * Float64(0.5 / d))) / l), Float64(Float64(Float64(-0.25) * D_m) * Float64(Float64(M_m / d) * h)), 1.0) tmp = 0.0 if (l <= -4e-310) tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * Float64(-d)) * t_0); else tmp = Float64(Float64(d / sqrt(Float64(l * h))) * t_0); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $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[(N[(N[(M$95$m * N[(D$95$m * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(N[((-0.25) * D$95$m), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[l, -4e-310], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-d)), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{M\_m \cdot \left(D\_m \cdot \frac{0.5}{d}\right)}{\ell}, \left(\left(-0.25\right) \cdot D\_m\right) \cdot \left(\frac{M\_m}{d} \cdot h\right), 1\right)\\
\mathbf{if}\;\ell \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot \left(-d\right)\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot t\_0\\
\end{array}
\end{array}
if l < -3.999999999999988e-310Initial program 64.4%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6464.4
Applied rewrites64.4%
Applied rewrites65.0%
lift-/.f64N/A
metadata-eval65.0
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6465.0
Applied rewrites65.0%
Taylor expanded in h around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6472.4
Applied rewrites72.4%
if -3.999999999999988e-310 < l Initial program 71.3%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6471.3
Applied rewrites71.3%
Applied rewrites72.1%
lift-/.f64N/A
metadata-eval72.1
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6472.1
Applied rewrites72.1%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-unprodN/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
sqrt-divN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lower-/.f6477.0
Applied rewrites77.0%
Final simplification75.0%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) 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 7e-295) (* (sqrt (/ 1.0 (* l h))) (- d)) (/ d (* (sqrt h) (sqrt l)))))
D_m = fabs(D);
M_m = fabs(M);
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 <= 7e-295) {
tmp = sqrt((1.0 / (l * h))) * -d;
} else {
tmp = d / (sqrt(h) * sqrt(l));
}
return tmp;
}
D_m = abs(d)
M_m = abs(m)
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 <= 7d-295) then
tmp = sqrt((1.0d0 / (l * h))) * -d
else
tmp = d / (sqrt(h) * sqrt(l))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
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 <= 7e-295) {
tmp = Math.sqrt((1.0 / (l * h))) * -d;
} else {
tmp = d / (Math.sqrt(h) * Math.sqrt(l));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [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 <= 7e-295: tmp = math.sqrt((1.0 / (l * h))) * -d else: tmp = d / (math.sqrt(h) * math.sqrt(l)) return tmp
D_m = abs(D) M_m = abs(M) 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 <= 7e-295) tmp = Float64(sqrt(Float64(1.0 / Float64(l * h))) * Float64(-d)); else tmp = Float64(d / Float64(sqrt(h) * sqrt(l))); end return tmp end
D_m = abs(D);
M_m = abs(M);
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 <= 7e-295)
tmp = sqrt((1.0 / (l * h))) * -d;
else
tmp = d / (sqrt(h) * sqrt(l));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $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, 7e-295], N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-d)), $MachinePrecision], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 7 \cdot 10^{-295}:\\
\;\;\;\;\sqrt{\frac{1}{\ell \cdot h}} \cdot \left(-d\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if l < 6.99999999999999977e-295Initial program 65.3%
Taylor expanded in l around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6444.2
Applied rewrites44.2%
if 6.99999999999999977e-295 < l Initial program 70.7%
Taylor expanded in h around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6444.1
Applied rewrites44.1%
Applied rewrites44.1%
Applied rewrites50.0%
Final simplification47.4%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) 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-188) (* (sqrt (/ 1.0 (* l h))) (- d)) (/ d (sqrt (* l h)))))
D_m = fabs(D);
M_m = fabs(M);
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-188) {
tmp = sqrt((1.0 / (l * h))) * -d;
} else {
tmp = d / sqrt((l * h));
}
return tmp;
}
D_m = abs(d)
M_m = abs(m)
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 <= 1d-188) then
tmp = sqrt((1.0d0 / (l * h))) * -d
else
tmp = d / sqrt((l * h))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
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 <= 1e-188) {
tmp = Math.sqrt((1.0 / (l * h))) * -d;
} else {
tmp = d / Math.sqrt((l * h));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [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 <= 1e-188: tmp = math.sqrt((1.0 / (l * h))) * -d else: tmp = d / math.sqrt((l * h)) return tmp
D_m = abs(D) M_m = abs(M) 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-188) tmp = Float64(sqrt(Float64(1.0 / Float64(l * h))) * Float64(-d)); else tmp = Float64(d / sqrt(Float64(l * h))); end return tmp end
D_m = abs(D);
M_m = abs(M);
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 <= 1e-188)
tmp = sqrt((1.0 / (l * h))) * -d;
else
tmp = d / sqrt((l * h));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $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-188], N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-d)), $MachinePrecision], N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 10^{-188}:\\
\;\;\;\;\sqrt{\frac{1}{\ell \cdot h}} \cdot \left(-d\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\
\end{array}
\end{array}
if l < 9.9999999999999995e-189Initial program 67.5%
Taylor expanded in l around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6441.6
Applied rewrites41.6%
if 9.9999999999999995e-189 < l Initial program 69.2%
Taylor expanded in h around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6448.3
Applied rewrites48.3%
Applied rewrites48.3%
Final simplification44.7%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) 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 (* l h))))
D_m = fabs(D);
M_m = fabs(M);
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((l * h));
}
D_m = abs(d)
M_m = abs(m)
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((l * h))
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
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((l * h));
}
D_m = math.fabs(D) M_m = math.fabs(M) [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((l * h))
D_m = abs(D) M_m = abs(M) 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(l * h))) end
D_m = abs(D);
M_m = abs(M);
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((l * h));
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $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[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\frac{d}{\sqrt{\ell \cdot h}}
\end{array}
Initial program 68.2%
Taylor expanded in h around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6427.5
Applied rewrites27.5%
Applied rewrites27.5%
herbie shell --seed 2024256
(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)))))