
(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 17 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 (sqrt (- d)))
(t_1
(fma
(/ (* (* D_m (/ M_m d)) -0.5) l)
(* (* (/ M_m d) h) (* 0.25 D_m))
1.0))
(t_2 (sqrt (/ d l))))
(if (<= l -1.15e+120)
(* (* t_1 (sqrt (/ d h))) (* t_0 (sqrt (pow (- l) -1.0))))
(if (<= l -1.15e-307)
(* (* t_1 (/ t_0 (sqrt (- h)))) t_2)
(if (<= l 6.6e+212)
(* (* t_1 (/ (sqrt d) (sqrt h))) t_2)
(/ d (* (sqrt l) (sqrt 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 t_0 = sqrt(-d);
double t_1 = fma((((D_m * (M_m / d)) * -0.5) / l), (((M_m / d) * h) * (0.25 * D_m)), 1.0);
double t_2 = sqrt((d / l));
double tmp;
if (l <= -1.15e+120) {
tmp = (t_1 * sqrt((d / h))) * (t_0 * sqrt(pow(-l, -1.0)));
} else if (l <= -1.15e-307) {
tmp = (t_1 * (t_0 / sqrt(-h))) * t_2;
} else if (l <= 6.6e+212) {
tmp = (t_1 * (sqrt(d) / sqrt(h))) * t_2;
} else {
tmp = d / (sqrt(l) * sqrt(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) t_0 = sqrt(Float64(-d)) t_1 = fma(Float64(Float64(Float64(D_m * Float64(M_m / d)) * -0.5) / l), Float64(Float64(Float64(M_m / d) * h) * Float64(0.25 * D_m)), 1.0) t_2 = sqrt(Float64(d / l)) tmp = 0.0 if (l <= -1.15e+120) tmp = Float64(Float64(t_1 * sqrt(Float64(d / h))) * Float64(t_0 * sqrt((Float64(-l) ^ -1.0)))); elseif (l <= -1.15e-307) tmp = Float64(Float64(t_1 * Float64(t_0 / sqrt(Float64(-h)))) * t_2); elseif (l <= 6.6e+212) tmp = Float64(Float64(t_1 * Float64(sqrt(d) / sqrt(h))) * t_2); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); 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[(N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision] / l), $MachinePrecision] * N[(N[(N[(M$95$m / d), $MachinePrecision] * h), $MachinePrecision] * N[(0.25 * D$95$m), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -1.15e+120], N[(N[(t$95$1 * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * N[Sqrt[N[Power[(-l), -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -1.15e-307], N[(N[(t$95$1 * N[(t$95$0 / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[l, 6.6e+212], N[(N[(t$95$1 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[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}
t_0 := \sqrt{-d}\\
t_1 := \mathsf{fma}\left(\frac{\left(D\_m \cdot \frac{M\_m}{d}\right) \cdot -0.5}{\ell}, \left(\frac{M\_m}{d} \cdot h\right) \cdot \left(0.25 \cdot D\_m\right), 1\right)\\
t_2 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;\ell \leq -1.15 \cdot 10^{+120}:\\
\;\;\;\;\left(t\_1 \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(t\_0 \cdot \sqrt{{\left(-\ell\right)}^{-1}}\right)\\
\mathbf{elif}\;\ell \leq -1.15 \cdot 10^{-307}:\\
\;\;\;\;\left(t\_1 \cdot \frac{t\_0}{\sqrt{-h}}\right) \cdot t\_2\\
\mathbf{elif}\;\ell \leq 6.6 \cdot 10^{+212}:\\
\;\;\;\;\left(t\_1 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right) \cdot t\_2\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < -1.14999999999999996e120Initial program 47.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites51.3%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6447.7
Applied rewrites47.7%
Applied rewrites55.4%
lift-sqrt.f64N/A
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
div-invN/A
sqrt-prodN/A
lift-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-neg.f6468.3
Applied rewrites68.3%
if -1.14999999999999996e120 < l < -1.1499999999999999e-307Initial program 68.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.6%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6468.9
Applied rewrites68.9%
Applied rewrites70.2%
lift-sqrt.f64N/A
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
lift-neg.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lower-/.f6481.7
Applied rewrites81.7%
if -1.1499999999999999e-307 < l < 6.6e212Initial program 72.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.9%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6472.2
Applied rewrites72.2%
Applied rewrites73.3%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
pow1/2N/A
metadata-evalN/A
pow1/2N/A
metadata-evalN/A
lower-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f6480.3
Applied rewrites80.3%
if 6.6e212 < l Initial program 17.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6460.0
Applied rewrites60.0%
Applied rewrites59.8%
Applied rewrites70.8%
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 (/ (* -0.5 (* (/ M_m d) D_m)) l))
(t_1
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(*
(* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0))
(/ h l)))))
(t_2 (sqrt (/ d h)))
(t_3 (sqrt (/ d l))))
(if (<= t_1 -1e-191)
(* (* (fma (* (* t_0 h) (/ M_m d)) (* 0.25 D_m) 1.0) t_2) t_3)
(if (<= t_1 0.0)
(fabs (/ d (sqrt (* l h))))
(if (<= t_1 4e+148)
(* (* (fma (* 0.25 (* h (/ M_m d))) (* D_m t_0) 1.0) t_3) t_2)
(pow (/ (sqrt (* h l)) (fabs d)) -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 = (-0.5 * ((M_m / d) * D_m)) / l;
double t_1 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_2 = sqrt((d / h));
double t_3 = sqrt((d / l));
double tmp;
if (t_1 <= -1e-191) {
tmp = (fma(((t_0 * h) * (M_m / d)), (0.25 * D_m), 1.0) * t_2) * t_3;
} else if (t_1 <= 0.0) {
tmp = fabs((d / sqrt((l * h))));
} else if (t_1 <= 4e+148) {
tmp = (fma((0.25 * (h * (M_m / d))), (D_m * t_0), 1.0) * t_3) * t_2;
} else {
tmp = pow((sqrt((h * l)) / fabs(d)), -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 = Float64(Float64(-0.5 * Float64(Float64(M_m / d) * D_m)) / l) t_1 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_2 = sqrt(Float64(d / h)) t_3 = sqrt(Float64(d / l)) tmp = 0.0 if (t_1 <= -1e-191) tmp = Float64(Float64(fma(Float64(Float64(t_0 * h) * Float64(M_m / d)), Float64(0.25 * D_m), 1.0) * t_2) * t_3); elseif (t_1 <= 0.0) tmp = abs(Float64(d / sqrt(Float64(l * h)))); elseif (t_1 <= 4e+148) tmp = Float64(Float64(fma(Float64(0.25 * Float64(h * Float64(M_m / d))), Float64(D_m * t_0), 1.0) * t_3) * t_2); else tmp = Float64(sqrt(Float64(h * l)) / abs(d)) ^ -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[(N[(-0.5 * N[(N[(M$95$m / d), $MachinePrecision] * D$95$m), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, -1e-191], N[(N[(N[(N[(N[(t$95$0 * h), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] * N[(0.25 * D$95$m), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$2), $MachinePrecision] * t$95$3), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$1, 4e+148], N[(N[(N[(N[(0.25 * N[(h * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(D$95$m * t$95$0), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$3), $MachinePrecision] * t$95$2), $MachinePrecision], N[Power[N[(N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision] / N[Abs[d], $MachinePrecision]), $MachinePrecision], -1.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 := \frac{-0.5 \cdot \left(\frac{M\_m}{d} \cdot D\_m\right)}{\ell}\\
t_1 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_2 := \sqrt{\frac{d}{h}}\\
t_3 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{-191}:\\
\;\;\;\;\left(\mathsf{fma}\left(\left(t\_0 \cdot h\right) \cdot \frac{M\_m}{d}, 0.25 \cdot D\_m, 1\right) \cdot t\_2\right) \cdot t\_3\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+148}:\\
\;\;\;\;\left(\mathsf{fma}\left(0.25 \cdot \left(h \cdot \frac{M\_m}{d}\right), D\_m \cdot t\_0, 1\right) \cdot t\_3\right) \cdot t\_2\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{\sqrt{h \cdot \ell}}{\left|d\right|}\right)}^{-1}\\
\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)))) < -1e-191Initial program 79.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites76.3%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6479.7
Applied rewrites79.7%
Applied rewrites78.4%
lift-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites82.5%
if -1e-191 < (*.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 26.4%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6464.4
Applied rewrites64.4%
Applied rewrites77.6%
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)))) < 4.0000000000000002e148Initial program 97.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites97.7%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6497.7
Applied rewrites97.7%
Applied rewrites96.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites96.0%
if 4.0000000000000002e148 < (*.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 26.3%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6428.7
Applied rewrites28.7%
Applied rewrites58.0%
Applied rewrites58.0%
Final simplification77.5%
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 h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(*
(* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0))
(/ h l)))))
(t_1
(*
(*
(fma
(* 0.25 (* h (/ M_m d)))
(* D_m (/ (* -0.5 (* (/ M_m d) D_m)) l))
1.0)
(sqrt (/ d l)))
(sqrt (/ d h)))))
(if (<= t_0 -1e-191)
t_1
(if (<= t_0 0.0)
(fabs (/ d (sqrt (* l h))))
(if (<= t_0 4e+148) t_1 (pow (/ (sqrt (* h l)) (fabs d)) -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 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = (fma((0.25 * (h * (M_m / d))), (D_m * ((-0.5 * ((M_m / d) * D_m)) / l)), 1.0) * sqrt((d / l))) * sqrt((d / h));
double tmp;
if (t_0 <= -1e-191) {
tmp = t_1;
} else if (t_0 <= 0.0) {
tmp = fabs((d / sqrt((l * h))));
} else if (t_0 <= 4e+148) {
tmp = t_1;
} else {
tmp = pow((sqrt((h * l)) / fabs(d)), -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 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(Float64(fma(Float64(0.25 * Float64(h * Float64(M_m / d))), Float64(D_m * Float64(Float64(-0.5 * Float64(Float64(M_m / d) * D_m)) / l)), 1.0) * sqrt(Float64(d / l))) * sqrt(Float64(d / h))) tmp = 0.0 if (t_0 <= -1e-191) tmp = t_1; elseif (t_0 <= 0.0) tmp = abs(Float64(d / sqrt(Float64(l * h)))); elseif (t_0 <= 4e+148) tmp = t_1; else tmp = Float64(sqrt(Float64(h * l)) / abs(d)) ^ -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[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(0.25 * N[(h * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(D$95$m * N[(N[(-0.5 * N[(N[(M$95$m / d), $MachinePrecision] * D$95$m), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-191], t$95$1, If[LessEqual[t$95$0, 0.0], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$0, 4e+148], t$95$1, N[Power[N[(N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision] / N[Abs[d], $MachinePrecision]), $MachinePrecision], -1.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 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \left(\mathsf{fma}\left(0.25 \cdot \left(h \cdot \frac{M\_m}{d}\right), D\_m \cdot \frac{-0.5 \cdot \left(\frac{M\_m}{d} \cdot D\_m\right)}{\ell}, 1\right) \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \sqrt{\frac{d}{h}}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-191}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+148}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{\sqrt{h \cdot \ell}}{\left|d\right|}\right)}^{-1}\\
\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)))) < -1e-191 or 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)))) < 4.0000000000000002e148Initial program 86.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites84.5%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6486.6
Applied rewrites86.6%
Applied rewrites85.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites84.0%
if -1e-191 < (*.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 26.4%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6464.4
Applied rewrites64.4%
Applied rewrites77.6%
if 4.0000000000000002e148 < (*.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 26.3%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6428.7
Applied rewrites28.7%
Applied rewrites58.0%
Applied rewrites58.0%
Final simplification75.2%
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 h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(*
(* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0))
(/ h l)))))
(t_1 (sqrt (/ d h)))
(t_2 (sqrt (/ d l))))
(if (<= t_0 -5e-134)
(*
(*
(fma
(/ (* (* M_m D_m) -0.5) (* d l))
(* (* (/ M_m d) h) (* 0.25 D_m))
1.0)
t_1)
t_2)
(if (<= t_0 0.0)
(fabs (/ d (sqrt (* l h))))
(if (<= t_0 4e+148)
(* t_2 t_1)
(pow (/ (sqrt (* h l)) (fabs d)) -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 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = sqrt((d / h));
double t_2 = sqrt((d / l));
double tmp;
if (t_0 <= -5e-134) {
tmp = (fma((((M_m * D_m) * -0.5) / (d * l)), (((M_m / d) * h) * (0.25 * D_m)), 1.0) * t_1) * t_2;
} else if (t_0 <= 0.0) {
tmp = fabs((d / sqrt((l * h))));
} else if (t_0 <= 4e+148) {
tmp = t_2 * t_1;
} else {
tmp = pow((sqrt((h * l)) / fabs(d)), -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 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = sqrt(Float64(d / h)) t_2 = sqrt(Float64(d / l)) tmp = 0.0 if (t_0 <= -5e-134) tmp = Float64(Float64(fma(Float64(Float64(Float64(M_m * D_m) * -0.5) / Float64(d * l)), Float64(Float64(Float64(M_m / d) * h) * Float64(0.25 * D_m)), 1.0) * t_1) * t_2); elseif (t_0 <= 0.0) tmp = abs(Float64(d / sqrt(Float64(l * h)))); elseif (t_0 <= 4e+148) tmp = Float64(t_2 * t_1); else tmp = Float64(sqrt(Float64(h * l)) / abs(d)) ^ -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[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -5e-134], N[(N[(N[(N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * -0.5), $MachinePrecision] / N[(d * l), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M$95$m / d), $MachinePrecision] * h), $MachinePrecision] * N[(0.25 * D$95$m), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$0, 4e+148], N[(t$95$2 * t$95$1), $MachinePrecision], N[Power[N[(N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision] / N[Abs[d], $MachinePrecision]), $MachinePrecision], -1.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 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \sqrt{\frac{d}{h}}\\
t_2 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-134}:\\
\;\;\;\;\left(\mathsf{fma}\left(\frac{\left(M\_m \cdot D\_m\right) \cdot -0.5}{d \cdot \ell}, \left(\frac{M\_m}{d} \cdot h\right) \cdot \left(0.25 \cdot D\_m\right), 1\right) \cdot t\_1\right) \cdot t\_2\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+148}:\\
\;\;\;\;t\_2 \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{\sqrt{h \cdot \ell}}{\left|d\right|}\right)}^{-1}\\
\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)))) < -5.0000000000000003e-134Initial program 79.5%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites76.0%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6479.5
Applied rewrites79.5%
Applied rewrites79.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6473.6
Applied rewrites73.6%
if -5.0000000000000003e-134 < (*.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 29.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6461.9
Applied rewrites61.9%
Applied rewrites74.5%
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)))) < 4.0000000000000002e148Initial program 97.7%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6436.9
Applied rewrites36.9%
Applied rewrites97.5%
if 4.0000000000000002e148 < (*.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 26.3%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6428.7
Applied rewrites28.7%
Applied rewrites58.0%
Applied rewrites58.0%
Final simplification74.2%
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 h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(*
(* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0))
(/ h l)))))
(t_1 (sqrt (/ d h)))
(t_2 (sqrt (/ d l))))
(if (<= t_0 -1e-96)
(*
(*
(/ (fma M_m (* (* -0.125 M_m) (* (/ (* D_m D_m) l) h)) (* d d)) (* d d))
t_1)
t_2)
(if (<= t_0 0.0)
(fabs (/ d (sqrt (* l h))))
(if (<= t_0 4e+148)
(* t_2 t_1)
(pow (/ (sqrt (* h l)) (fabs d)) -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 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = sqrt((d / h));
double t_2 = sqrt((d / l));
double tmp;
if (t_0 <= -1e-96) {
tmp = ((fma(M_m, ((-0.125 * M_m) * (((D_m * D_m) / l) * h)), (d * d)) / (d * d)) * t_1) * t_2;
} else if (t_0 <= 0.0) {
tmp = fabs((d / sqrt((l * h))));
} else if (t_0 <= 4e+148) {
tmp = t_2 * t_1;
} else {
tmp = pow((sqrt((h * l)) / fabs(d)), -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 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = sqrt(Float64(d / h)) t_2 = sqrt(Float64(d / l)) tmp = 0.0 if (t_0 <= -1e-96) tmp = Float64(Float64(Float64(fma(M_m, Float64(Float64(-0.125 * M_m) * Float64(Float64(Float64(D_m * D_m) / l) * h)), Float64(d * d)) / Float64(d * d)) * t_1) * t_2); elseif (t_0 <= 0.0) tmp = abs(Float64(d / sqrt(Float64(l * h)))); elseif (t_0 <= 4e+148) tmp = Float64(t_2 * t_1); else tmp = Float64(sqrt(Float64(h * l)) / abs(d)) ^ -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[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -1e-96], N[(N[(N[(N[(M$95$m * N[(N[(-0.125 * M$95$m), $MachinePrecision] * N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] / l), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$0, 4e+148], N[(t$95$2 * t$95$1), $MachinePrecision], N[Power[N[(N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision] / N[Abs[d], $MachinePrecision]), $MachinePrecision], -1.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 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \sqrt{\frac{d}{h}}\\
t_2 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-96}:\\
\;\;\;\;\left(\frac{\mathsf{fma}\left(M\_m, \left(-0.125 \cdot M\_m\right) \cdot \left(\frac{D\_m \cdot D\_m}{\ell} \cdot h\right), d \cdot d\right)}{d \cdot d} \cdot t\_1\right) \cdot t\_2\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+148}:\\
\;\;\;\;t\_2 \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{\sqrt{h \cdot \ell}}{\left|d\right|}\right)}^{-1}\\
\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)))) < -9.9999999999999991e-97Initial program 79.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites75.5%
Taylor expanded in d around 0
lower-/.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-*r*N/A
associate-/l*N/A
lower-fma.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6454.4
Applied rewrites54.4%
Applied rewrites57.1%
if -9.9999999999999991e-97 < (*.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 35.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6457.6
Applied rewrites57.6%
Applied rewrites68.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)))) < 4.0000000000000002e148Initial program 97.7%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6436.9
Applied rewrites36.9%
Applied rewrites97.5%
if 4.0000000000000002e148 < (*.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 26.3%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6428.7
Applied rewrites28.7%
Applied rewrites58.0%
Applied rewrites58.0%
Final simplification67.8%
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 h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(*
(* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0))
(/ h l)))))
(t_1 (sqrt (/ d h)))
(t_2 (sqrt (/ d l))))
(if (<= t_0 -1e-96)
(*
(* (* (* (* (* h (/ (* M_m M_m) l)) -0.125) D_m) (/ (/ D_m d) d)) t_1)
t_2)
(if (<= t_0 0.0)
(fabs (/ d (sqrt (* l h))))
(if (<= t_0 4e+148)
(* t_2 t_1)
(pow (/ (sqrt (* h l)) (fabs d)) -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 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = sqrt((d / h));
double t_2 = sqrt((d / l));
double tmp;
if (t_0 <= -1e-96) {
tmp = (((((h * ((M_m * M_m) / l)) * -0.125) * D_m) * ((D_m / d) / d)) * t_1) * t_2;
} else if (t_0 <= 0.0) {
tmp = fabs((d / sqrt((l * h))));
} else if (t_0 <= 4e+148) {
tmp = t_2 * t_1;
} else {
tmp = pow((sqrt((h * l)) / fabs(d)), -1.0);
}
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = (((d / h) ** (2.0d0 ** (-1.0d0))) * ((d / l) ** (2.0d0 ** (-1.0d0)))) * (1.0d0 - (((2.0d0 ** (-1.0d0)) * (((m_m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
t_1 = sqrt((d / h))
t_2 = sqrt((d / l))
if (t_0 <= (-1d-96)) then
tmp = (((((h * ((m_m * m_m) / l)) * (-0.125d0)) * d_m) * ((d_m / d) / d)) * t_1) * t_2
else if (t_0 <= 0.0d0) then
tmp = abs((d / sqrt((l * h))))
else if (t_0 <= 4d+148) then
tmp = t_2 * t_1
else
tmp = (sqrt((h * l)) / abs(d)) ** (-1.0d0)
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 / h), Math.pow(2.0, -1.0)) * Math.pow((d / l), Math.pow(2.0, -1.0))) * (1.0 - ((Math.pow(2.0, -1.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = Math.sqrt((d / h));
double t_2 = Math.sqrt((d / l));
double tmp;
if (t_0 <= -1e-96) {
tmp = (((((h * ((M_m * M_m) / l)) * -0.125) * D_m) * ((D_m / d) / d)) * t_1) * t_2;
} else if (t_0 <= 0.0) {
tmp = Math.abs((d / Math.sqrt((l * h))));
} else if (t_0 <= 4e+148) {
tmp = t_2 * t_1;
} else {
tmp = Math.pow((Math.sqrt((h * l)) / Math.abs(d)), -1.0);
}
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 / h), math.pow(2.0, -1.0)) * math.pow((d / l), math.pow(2.0, -1.0))) * (1.0 - ((math.pow(2.0, -1.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l))) t_1 = math.sqrt((d / h)) t_2 = math.sqrt((d / l)) tmp = 0 if t_0 <= -1e-96: tmp = (((((h * ((M_m * M_m) / l)) * -0.125) * D_m) * ((D_m / d) / d)) * t_1) * t_2 elif t_0 <= 0.0: tmp = math.fabs((d / math.sqrt((l * h)))) elif t_0 <= 4e+148: tmp = t_2 * t_1 else: tmp = math.pow((math.sqrt((h * l)) / math.fabs(d)), -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 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = sqrt(Float64(d / h)) t_2 = sqrt(Float64(d / l)) tmp = 0.0 if (t_0 <= -1e-96) tmp = Float64(Float64(Float64(Float64(Float64(Float64(h * Float64(Float64(M_m * M_m) / l)) * -0.125) * D_m) * Float64(Float64(D_m / d) / d)) * t_1) * t_2); elseif (t_0 <= 0.0) tmp = abs(Float64(d / sqrt(Float64(l * h)))); elseif (t_0 <= 4e+148) tmp = Float64(t_2 * t_1); else tmp = Float64(sqrt(Float64(h * l)) / abs(d)) ^ -1.0; 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 / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
t_1 = sqrt((d / h));
t_2 = sqrt((d / l));
tmp = 0.0;
if (t_0 <= -1e-96)
tmp = (((((h * ((M_m * M_m) / l)) * -0.125) * D_m) * ((D_m / d) / d)) * t_1) * t_2;
elseif (t_0 <= 0.0)
tmp = abs((d / sqrt((l * h))));
elseif (t_0 <= 4e+148)
tmp = t_2 * t_1;
else
tmp = (sqrt((h * l)) / abs(d)) ^ -1.0;
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 / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -1e-96], N[(N[(N[(N[(N[(N[(h * N[(N[(M$95$m * M$95$m), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(N[(D$95$m / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$0, 4e+148], N[(t$95$2 * t$95$1), $MachinePrecision], N[Power[N[(N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision] / N[Abs[d], $MachinePrecision]), $MachinePrecision], -1.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 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \sqrt{\frac{d}{h}}\\
t_2 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-96}:\\
\;\;\;\;\left(\left(\left(\left(\left(h \cdot \frac{M\_m \cdot M\_m}{\ell}\right) \cdot -0.125\right) \cdot D\_m\right) \cdot \frac{\frac{D\_m}{d}}{d}\right) \cdot t\_1\right) \cdot t\_2\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+148}:\\
\;\;\;\;t\_2 \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{\sqrt{h \cdot \ell}}{\left|d\right|}\right)}^{-1}\\
\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)))) < -9.9999999999999991e-97Initial program 79.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites75.5%
Taylor expanded in d around 0
lower-/.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-*r*N/A
associate-/l*N/A
lower-fma.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6454.4
Applied rewrites54.4%
Taylor expanded in d around 0
associate-*r/N/A
associate-/l/N/A
*-commutativeN/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
unpow2N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
Applied rewrites60.8%
if -9.9999999999999991e-97 < (*.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 35.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6457.6
Applied rewrites57.6%
Applied rewrites68.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)))) < 4.0000000000000002e148Initial program 97.7%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6436.9
Applied rewrites36.9%
Applied rewrites97.5%
if 4.0000000000000002e148 < (*.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 26.3%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6428.7
Applied rewrites28.7%
Applied rewrites58.0%
Applied rewrites58.0%
Final simplification69.2%
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 h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(*
(* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0))
(/ h l)))))
(t_1 (sqrt (/ d h)))
(t_2 (sqrt (/ d l))))
(if (<= t_0 -1e-96)
(*
(* (* h (* (* -0.125 (/ (* M_m M_m) l)) (* (/ (/ D_m d) d) D_m))) t_1)
t_2)
(if (<= t_0 0.0)
(fabs (/ d (sqrt (* l h))))
(if (<= t_0 4e+148)
(* t_2 t_1)
(pow (/ (sqrt (* h l)) (fabs d)) -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 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = sqrt((d / h));
double t_2 = sqrt((d / l));
double tmp;
if (t_0 <= -1e-96) {
tmp = ((h * ((-0.125 * ((M_m * M_m) / l)) * (((D_m / d) / d) * D_m))) * t_1) * t_2;
} else if (t_0 <= 0.0) {
tmp = fabs((d / sqrt((l * h))));
} else if (t_0 <= 4e+148) {
tmp = t_2 * t_1;
} else {
tmp = pow((sqrt((h * l)) / fabs(d)), -1.0);
}
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = (((d / h) ** (2.0d0 ** (-1.0d0))) * ((d / l) ** (2.0d0 ** (-1.0d0)))) * (1.0d0 - (((2.0d0 ** (-1.0d0)) * (((m_m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
t_1 = sqrt((d / h))
t_2 = sqrt((d / l))
if (t_0 <= (-1d-96)) then
tmp = ((h * (((-0.125d0) * ((m_m * m_m) / l)) * (((d_m / d) / d) * d_m))) * t_1) * t_2
else if (t_0 <= 0.0d0) then
tmp = abs((d / sqrt((l * h))))
else if (t_0 <= 4d+148) then
tmp = t_2 * t_1
else
tmp = (sqrt((h * l)) / abs(d)) ** (-1.0d0)
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 / h), Math.pow(2.0, -1.0)) * Math.pow((d / l), Math.pow(2.0, -1.0))) * (1.0 - ((Math.pow(2.0, -1.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = Math.sqrt((d / h));
double t_2 = Math.sqrt((d / l));
double tmp;
if (t_0 <= -1e-96) {
tmp = ((h * ((-0.125 * ((M_m * M_m) / l)) * (((D_m / d) / d) * D_m))) * t_1) * t_2;
} else if (t_0 <= 0.0) {
tmp = Math.abs((d / Math.sqrt((l * h))));
} else if (t_0 <= 4e+148) {
tmp = t_2 * t_1;
} else {
tmp = Math.pow((Math.sqrt((h * l)) / Math.abs(d)), -1.0);
}
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 / h), math.pow(2.0, -1.0)) * math.pow((d / l), math.pow(2.0, -1.0))) * (1.0 - ((math.pow(2.0, -1.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l))) t_1 = math.sqrt((d / h)) t_2 = math.sqrt((d / l)) tmp = 0 if t_0 <= -1e-96: tmp = ((h * ((-0.125 * ((M_m * M_m) / l)) * (((D_m / d) / d) * D_m))) * t_1) * t_2 elif t_0 <= 0.0: tmp = math.fabs((d / math.sqrt((l * h)))) elif t_0 <= 4e+148: tmp = t_2 * t_1 else: tmp = math.pow((math.sqrt((h * l)) / math.fabs(d)), -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 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = sqrt(Float64(d / h)) t_2 = sqrt(Float64(d / l)) tmp = 0.0 if (t_0 <= -1e-96) tmp = Float64(Float64(Float64(h * Float64(Float64(-0.125 * Float64(Float64(M_m * M_m) / l)) * Float64(Float64(Float64(D_m / d) / d) * D_m))) * t_1) * t_2); elseif (t_0 <= 0.0) tmp = abs(Float64(d / sqrt(Float64(l * h)))); elseif (t_0 <= 4e+148) tmp = Float64(t_2 * t_1); else tmp = Float64(sqrt(Float64(h * l)) / abs(d)) ^ -1.0; 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 / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
t_1 = sqrt((d / h));
t_2 = sqrt((d / l));
tmp = 0.0;
if (t_0 <= -1e-96)
tmp = ((h * ((-0.125 * ((M_m * M_m) / l)) * (((D_m / d) / d) * D_m))) * t_1) * t_2;
elseif (t_0 <= 0.0)
tmp = abs((d / sqrt((l * h))));
elseif (t_0 <= 4e+148)
tmp = t_2 * t_1;
else
tmp = (sqrt((h * l)) / abs(d)) ^ -1.0;
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 / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -1e-96], N[(N[(N[(h * N[(N[(-0.125 * N[(N[(M$95$m * M$95$m), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(D$95$m / d), $MachinePrecision] / d), $MachinePrecision] * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$0, 4e+148], N[(t$95$2 * t$95$1), $MachinePrecision], N[Power[N[(N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision] / N[Abs[d], $MachinePrecision]), $MachinePrecision], -1.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 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \sqrt{\frac{d}{h}}\\
t_2 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-96}:\\
\;\;\;\;\left(\left(h \cdot \left(\left(-0.125 \cdot \frac{M\_m \cdot M\_m}{\ell}\right) \cdot \left(\frac{\frac{D\_m}{d}}{d} \cdot D\_m\right)\right)\right) \cdot t\_1\right) \cdot t\_2\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+148}:\\
\;\;\;\;t\_2 \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{\sqrt{h \cdot \ell}}{\left|d\right|}\right)}^{-1}\\
\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)))) < -9.9999999999999991e-97Initial program 79.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites75.5%
Taylor expanded in d around 0
lower-/.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-*r*N/A
associate-/l*N/A
lower-fma.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6454.4
Applied rewrites54.4%
Taylor expanded in d around 0
associate-*r/N/A
associate-/l/N/A
*-commutativeN/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
unpow2N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
Applied rewrites60.8%
Applied rewrites59.7%
if -9.9999999999999991e-97 < (*.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 35.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6457.6
Applied rewrites57.6%
Applied rewrites68.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)))) < 4.0000000000000002e148Initial program 97.7%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6436.9
Applied rewrites36.9%
Applied rewrites97.5%
if 4.0000000000000002e148 < (*.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 26.3%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6428.7
Applied rewrites28.7%
Applied rewrites58.0%
Applied rewrites58.0%
Final simplification68.8%
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 h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(*
(* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0))
(/ h l)))))
(t_1 (sqrt (/ d h)))
(t_2 (sqrt (/ d l))))
(if (<= t_0 -5e-134)
(*
(* (/ (* (* (* (* h (/ (* M_m M_m) l)) -0.125) D_m) D_m) (* d d)) t_1)
t_2)
(if (<= t_0 0.0)
(fabs (/ d (sqrt (* l h))))
(if (<= t_0 4e+148)
(* t_2 t_1)
(pow (/ (sqrt (* h l)) (fabs d)) -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 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = sqrt((d / h));
double t_2 = sqrt((d / l));
double tmp;
if (t_0 <= -5e-134) {
tmp = ((((((h * ((M_m * M_m) / l)) * -0.125) * D_m) * D_m) / (d * d)) * t_1) * t_2;
} else if (t_0 <= 0.0) {
tmp = fabs((d / sqrt((l * h))));
} else if (t_0 <= 4e+148) {
tmp = t_2 * t_1;
} else {
tmp = pow((sqrt((h * l)) / fabs(d)), -1.0);
}
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = (((d / h) ** (2.0d0 ** (-1.0d0))) * ((d / l) ** (2.0d0 ** (-1.0d0)))) * (1.0d0 - (((2.0d0 ** (-1.0d0)) * (((m_m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
t_1 = sqrt((d / h))
t_2 = sqrt((d / l))
if (t_0 <= (-5d-134)) then
tmp = ((((((h * ((m_m * m_m) / l)) * (-0.125d0)) * d_m) * d_m) / (d * d)) * t_1) * t_2
else if (t_0 <= 0.0d0) then
tmp = abs((d / sqrt((l * h))))
else if (t_0 <= 4d+148) then
tmp = t_2 * t_1
else
tmp = (sqrt((h * l)) / abs(d)) ** (-1.0d0)
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 / h), Math.pow(2.0, -1.0)) * Math.pow((d / l), Math.pow(2.0, -1.0))) * (1.0 - ((Math.pow(2.0, -1.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = Math.sqrt((d / h));
double t_2 = Math.sqrt((d / l));
double tmp;
if (t_0 <= -5e-134) {
tmp = ((((((h * ((M_m * M_m) / l)) * -0.125) * D_m) * D_m) / (d * d)) * t_1) * t_2;
} else if (t_0 <= 0.0) {
tmp = Math.abs((d / Math.sqrt((l * h))));
} else if (t_0 <= 4e+148) {
tmp = t_2 * t_1;
} else {
tmp = Math.pow((Math.sqrt((h * l)) / Math.abs(d)), -1.0);
}
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 / h), math.pow(2.0, -1.0)) * math.pow((d / l), math.pow(2.0, -1.0))) * (1.0 - ((math.pow(2.0, -1.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l))) t_1 = math.sqrt((d / h)) t_2 = math.sqrt((d / l)) tmp = 0 if t_0 <= -5e-134: tmp = ((((((h * ((M_m * M_m) / l)) * -0.125) * D_m) * D_m) / (d * d)) * t_1) * t_2 elif t_0 <= 0.0: tmp = math.fabs((d / math.sqrt((l * h)))) elif t_0 <= 4e+148: tmp = t_2 * t_1 else: tmp = math.pow((math.sqrt((h * l)) / math.fabs(d)), -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 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = sqrt(Float64(d / h)) t_2 = sqrt(Float64(d / l)) tmp = 0.0 if (t_0 <= -5e-134) tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64(h * Float64(Float64(M_m * M_m) / l)) * -0.125) * D_m) * D_m) / Float64(d * d)) * t_1) * t_2); elseif (t_0 <= 0.0) tmp = abs(Float64(d / sqrt(Float64(l * h)))); elseif (t_0 <= 4e+148) tmp = Float64(t_2 * t_1); else tmp = Float64(sqrt(Float64(h * l)) / abs(d)) ^ -1.0; 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 / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
t_1 = sqrt((d / h));
t_2 = sqrt((d / l));
tmp = 0.0;
if (t_0 <= -5e-134)
tmp = ((((((h * ((M_m * M_m) / l)) * -0.125) * D_m) * D_m) / (d * d)) * t_1) * t_2;
elseif (t_0 <= 0.0)
tmp = abs((d / sqrt((l * h))));
elseif (t_0 <= 4e+148)
tmp = t_2 * t_1;
else
tmp = (sqrt((h * l)) / abs(d)) ^ -1.0;
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 / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -5e-134], N[(N[(N[(N[(N[(N[(N[(h * N[(N[(M$95$m * M$95$m), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$0, 4e+148], N[(t$95$2 * t$95$1), $MachinePrecision], N[Power[N[(N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision] / N[Abs[d], $MachinePrecision]), $MachinePrecision], -1.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 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \sqrt{\frac{d}{h}}\\
t_2 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-134}:\\
\;\;\;\;\left(\frac{\left(\left(\left(h \cdot \frac{M\_m \cdot M\_m}{\ell}\right) \cdot -0.125\right) \cdot D\_m\right) \cdot D\_m}{d \cdot d} \cdot t\_1\right) \cdot t\_2\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+148}:\\
\;\;\;\;t\_2 \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{\sqrt{h \cdot \ell}}{\left|d\right|}\right)}^{-1}\\
\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)))) < -5.0000000000000003e-134Initial program 79.5%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites76.0%
Taylor expanded in d around 0
lower-/.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-*r*N/A
associate-/l*N/A
lower-fma.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6453.3
Applied rewrites53.3%
Taylor expanded in d around 0
Applied rewrites57.2%
if -5.0000000000000003e-134 < (*.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 29.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6461.9
Applied rewrites61.9%
Applied rewrites74.5%
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)))) < 4.0000000000000002e148Initial program 97.7%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6436.9
Applied rewrites36.9%
Applied rewrites97.5%
if 4.0000000000000002e148 < (*.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 26.3%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6428.7
Applied rewrites28.7%
Applied rewrites58.0%
Applied rewrites58.0%
Final simplification68.3%
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 h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(*
(* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0))
(/ h l))))))
(if (<= t_0 -5e-134)
(*
(* (* D_m (* D_m (* M_m M_m))) (/ -0.125 (- d)))
(/ (sqrt (/ h l)) (fabs l)))
(if (<= t_0 0.0)
(fabs (/ d (sqrt (* l h))))
(if (<= t_0 4e+148)
(* (sqrt (/ d l)) (sqrt (/ d h)))
(pow (/ (sqrt (* h l)) (fabs d)) -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 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -5e-134) {
tmp = ((D_m * (D_m * (M_m * M_m))) * (-0.125 / -d)) * (sqrt((h / l)) / fabs(l));
} else if (t_0 <= 0.0) {
tmp = fabs((d / sqrt((l * h))));
} else if (t_0 <= 4e+148) {
tmp = sqrt((d / l)) * sqrt((d / h));
} else {
tmp = pow((sqrt((h * l)) / fabs(d)), -1.0);
}
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 / h) ** (2.0d0 ** (-1.0d0))) * ((d / l) ** (2.0d0 ** (-1.0d0)))) * (1.0d0 - (((2.0d0 ** (-1.0d0)) * (((m_m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
if (t_0 <= (-5d-134)) then
tmp = ((d_m * (d_m * (m_m * m_m))) * ((-0.125d0) / -d)) * (sqrt((h / l)) / abs(l))
else if (t_0 <= 0.0d0) then
tmp = abs((d / sqrt((l * h))))
else if (t_0 <= 4d+148) then
tmp = sqrt((d / l)) * sqrt((d / h))
else
tmp = (sqrt((h * l)) / abs(d)) ** (-1.0d0)
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 / h), Math.pow(2.0, -1.0)) * Math.pow((d / l), Math.pow(2.0, -1.0))) * (1.0 - ((Math.pow(2.0, -1.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -5e-134) {
tmp = ((D_m * (D_m * (M_m * M_m))) * (-0.125 / -d)) * (Math.sqrt((h / l)) / Math.abs(l));
} else if (t_0 <= 0.0) {
tmp = Math.abs((d / Math.sqrt((l * h))));
} else if (t_0 <= 4e+148) {
tmp = Math.sqrt((d / l)) * Math.sqrt((d / h));
} else {
tmp = Math.pow((Math.sqrt((h * l)) / Math.abs(d)), -1.0);
}
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 / h), math.pow(2.0, -1.0)) * math.pow((d / l), math.pow(2.0, -1.0))) * (1.0 - ((math.pow(2.0, -1.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l))) tmp = 0 if t_0 <= -5e-134: tmp = ((D_m * (D_m * (M_m * M_m))) * (-0.125 / -d)) * (math.sqrt((h / l)) / math.fabs(l)) elif t_0 <= 0.0: tmp = math.fabs((d / math.sqrt((l * h)))) elif t_0 <= 4e+148: tmp = math.sqrt((d / l)) * math.sqrt((d / h)) else: tmp = math.pow((math.sqrt((h * l)) / math.fabs(d)), -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 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_0 <= -5e-134) tmp = Float64(Float64(Float64(D_m * Float64(D_m * Float64(M_m * M_m))) * Float64(-0.125 / Float64(-d))) * Float64(sqrt(Float64(h / l)) / abs(l))); elseif (t_0 <= 0.0) tmp = abs(Float64(d / sqrt(Float64(l * h)))); elseif (t_0 <= 4e+148) tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))); else tmp = Float64(sqrt(Float64(h * l)) / abs(d)) ^ -1.0; 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 / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
tmp = 0.0;
if (t_0 <= -5e-134)
tmp = ((D_m * (D_m * (M_m * M_m))) * (-0.125 / -d)) * (sqrt((h / l)) / abs(l));
elseif (t_0 <= 0.0)
tmp = abs((d / sqrt((l * h))));
elseif (t_0 <= 4e+148)
tmp = sqrt((d / l)) * sqrt((d / h));
else
tmp = (sqrt((h * l)) / abs(d)) ^ -1.0;
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 / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-134], N[(N[(N[(D$95$m * N[(D$95$m * N[(M$95$m * M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-0.125 / (-d)), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] / N[Abs[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$0, 4e+148], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[N[(N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision] / N[Abs[d], $MachinePrecision]), $MachinePrecision], -1.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 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-134}:\\
\;\;\;\;\left(\left(D\_m \cdot \left(D\_m \cdot \left(M\_m \cdot M\_m\right)\right)\right) \cdot \frac{-0.125}{-d}\right) \cdot \frac{\sqrt{\frac{h}{\ell}}}{\left|\ell\right|}\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+148}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{\sqrt{h \cdot \ell}}{\left|d\right|}\right)}^{-1}\\
\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)))) < -5.0000000000000003e-134Initial program 79.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6410.3
Applied rewrites10.3%
Taylor expanded in h around -inf
associate-*r*N/A
lower-*.f64N/A
Applied rewrites30.6%
Applied rewrites37.2%
if -5.0000000000000003e-134 < (*.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 29.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6461.9
Applied rewrites61.9%
Applied rewrites74.5%
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)))) < 4.0000000000000002e148Initial program 97.7%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6436.9
Applied rewrites36.9%
Applied rewrites97.5%
if 4.0000000000000002e148 < (*.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 26.3%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6428.7
Applied rewrites28.7%
Applied rewrites58.0%
Applied rewrites58.0%
Final simplification61.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
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(*
(* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0))
(/ h l))))))
(if (<= t_0 -5000000000.0)
(* (- d) (sqrt (pow (* l h) -1.0)))
(if (<= t_0 0.0)
(fabs (/ d (sqrt (* l h))))
(if (<= t_0 4e+148)
(* (sqrt (/ d l)) (sqrt (/ d h)))
(pow (/ (sqrt (* h l)) (fabs d)) -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 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -5000000000.0) {
tmp = -d * sqrt(pow((l * h), -1.0));
} else if (t_0 <= 0.0) {
tmp = fabs((d / sqrt((l * h))));
} else if (t_0 <= 4e+148) {
tmp = sqrt((d / l)) * sqrt((d / h));
} else {
tmp = pow((sqrt((h * l)) / fabs(d)), -1.0);
}
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 / h) ** (2.0d0 ** (-1.0d0))) * ((d / l) ** (2.0d0 ** (-1.0d0)))) * (1.0d0 - (((2.0d0 ** (-1.0d0)) * (((m_m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
if (t_0 <= (-5000000000.0d0)) then
tmp = -d * sqrt(((l * h) ** (-1.0d0)))
else if (t_0 <= 0.0d0) then
tmp = abs((d / sqrt((l * h))))
else if (t_0 <= 4d+148) then
tmp = sqrt((d / l)) * sqrt((d / h))
else
tmp = (sqrt((h * l)) / abs(d)) ** (-1.0d0)
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 / h), Math.pow(2.0, -1.0)) * Math.pow((d / l), Math.pow(2.0, -1.0))) * (1.0 - ((Math.pow(2.0, -1.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -5000000000.0) {
tmp = -d * Math.sqrt(Math.pow((l * h), -1.0));
} else if (t_0 <= 0.0) {
tmp = Math.abs((d / Math.sqrt((l * h))));
} else if (t_0 <= 4e+148) {
tmp = Math.sqrt((d / l)) * Math.sqrt((d / h));
} else {
tmp = Math.pow((Math.sqrt((h * l)) / Math.abs(d)), -1.0);
}
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 / h), math.pow(2.0, -1.0)) * math.pow((d / l), math.pow(2.0, -1.0))) * (1.0 - ((math.pow(2.0, -1.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l))) tmp = 0 if t_0 <= -5000000000.0: tmp = -d * math.sqrt(math.pow((l * h), -1.0)) elif t_0 <= 0.0: tmp = math.fabs((d / math.sqrt((l * h)))) elif t_0 <= 4e+148: tmp = math.sqrt((d / l)) * math.sqrt((d / h)) else: tmp = math.pow((math.sqrt((h * l)) / math.fabs(d)), -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 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_0 <= -5000000000.0) tmp = Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0))); elseif (t_0 <= 0.0) tmp = abs(Float64(d / sqrt(Float64(l * h)))); elseif (t_0 <= 4e+148) tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))); else tmp = Float64(sqrt(Float64(h * l)) / abs(d)) ^ -1.0; 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 / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
tmp = 0.0;
if (t_0 <= -5000000000.0)
tmp = -d * sqrt(((l * h) ^ -1.0));
elseif (t_0 <= 0.0)
tmp = abs((d / sqrt((l * h))));
elseif (t_0 <= 4e+148)
tmp = sqrt((d / l)) * sqrt((d / h));
else
tmp = (sqrt((h * l)) / abs(d)) ^ -1.0;
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 / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5000000000.0], N[((-d) * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$0, 4e+148], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[N[(N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision] / N[Abs[d], $MachinePrecision]), $MachinePrecision], -1.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 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq -5000000000:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+148}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{\sqrt{h \cdot \ell}}{\left|d\right|}\right)}^{-1}\\
\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)))) < -5e9Initial program 77.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-*.f6413.4
Applied rewrites13.4%
if -5e9 < (*.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 49.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6446.5
Applied rewrites46.5%
Applied rewrites54.2%
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)))) < 4.0000000000000002e148Initial program 97.7%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6436.9
Applied rewrites36.9%
Applied rewrites97.5%
if 4.0000000000000002e148 < (*.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 26.3%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6428.7
Applied rewrites28.7%
Applied rewrites58.0%
Applied rewrites58.0%
Final simplification52.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 (<=
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l))))
-5000000000.0)
(* (- d) (sqrt (pow (* l h) -1.0)))
(fabs (/ 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 (((pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5000000000.0) {
tmp = -d * sqrt(pow((l * h), -1.0));
} else {
tmp = fabs((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 (((((d / h) ** (2.0d0 ** (-1.0d0))) * ((d / l) ** (2.0d0 ** (-1.0d0)))) * (1.0d0 - (((2.0d0 ** (-1.0d0)) * (((m_m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= (-5000000000.0d0)) then
tmp = -d * sqrt(((l * h) ** (-1.0d0)))
else
tmp = abs((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 (((Math.pow((d / h), Math.pow(2.0, -1.0)) * Math.pow((d / l), Math.pow(2.0, -1.0))) * (1.0 - ((Math.pow(2.0, -1.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5000000000.0) {
tmp = -d * Math.sqrt(Math.pow((l * h), -1.0));
} else {
tmp = Math.abs((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 ((math.pow((d / h), math.pow(2.0, -1.0)) * math.pow((d / l), math.pow(2.0, -1.0))) * (1.0 - ((math.pow(2.0, -1.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5000000000.0: tmp = -d * math.sqrt(math.pow((l * h), -1.0)) else: tmp = math.fabs((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 (Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= -5000000000.0) tmp = Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0))); else tmp = abs(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 (((((d / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= -5000000000.0)
tmp = -d * sqrt(((l * h) ^ -1.0));
else
tmp = abs((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[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5000000000.0], N[((-d) * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $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}\;\left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -5000000000:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\
\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)))) < -5e9Initial program 77.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-*.f6413.4
Applied rewrites13.4%
if -5e9 < (*.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 55.0%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6434.8
Applied rewrites34.8%
Applied rewrites65.1%
Final simplification48.2%
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 (<=
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l))))
-5e-134)
(* (sqrt (pow (* l h) -1.0)) d)
(fabs (/ 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 (((pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5e-134) {
tmp = sqrt(pow((l * h), -1.0)) * d;
} else {
tmp = fabs((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 (((((d / h) ** (2.0d0 ** (-1.0d0))) * ((d / l) ** (2.0d0 ** (-1.0d0)))) * (1.0d0 - (((2.0d0 ** (-1.0d0)) * (((m_m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= (-5d-134)) then
tmp = sqrt(((l * h) ** (-1.0d0))) * d
else
tmp = abs((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 (((Math.pow((d / h), Math.pow(2.0, -1.0)) * Math.pow((d / l), Math.pow(2.0, -1.0))) * (1.0 - ((Math.pow(2.0, -1.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5e-134) {
tmp = Math.sqrt(Math.pow((l * h), -1.0)) * d;
} else {
tmp = Math.abs((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 ((math.pow((d / h), math.pow(2.0, -1.0)) * math.pow((d / l), math.pow(2.0, -1.0))) * (1.0 - ((math.pow(2.0, -1.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5e-134: tmp = math.sqrt(math.pow((l * h), -1.0)) * d else: tmp = math.fabs((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 (Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= -5e-134) tmp = Float64(sqrt((Float64(l * h) ^ -1.0)) * d); else tmp = abs(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 (((((d / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= -5e-134)
tmp = sqrt(((l * h) ^ -1.0)) * d;
else
tmp = abs((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[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e-134], N[(N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $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}\;\left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -5 \cdot 10^{-134}:\\
\;\;\;\;\sqrt{{\left(\ell \cdot h\right)}^{-1}} \cdot d\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\
\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)))) < -5.0000000000000003e-134Initial program 79.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6410.3
Applied rewrites10.3%
if -5.0000000000000003e-134 < (*.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 52.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6436.4
Applied rewrites36.4%
Applied rewrites68.6%
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
(let* ((t_0 (/ d (sqrt (* l h)))))
(if (<=
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l))))
-5e-134)
t_0
(fabs 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 = d / sqrt((l * h));
double tmp;
if (((pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5e-134) {
tmp = t_0;
} else {
tmp = fabs(t_0);
}
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 / sqrt((l * h))
if (((((d / h) ** (2.0d0 ** (-1.0d0))) * ((d / l) ** (2.0d0 ** (-1.0d0)))) * (1.0d0 - (((2.0d0 ** (-1.0d0)) * (((m_m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= (-5d-134)) then
tmp = t_0
else
tmp = abs(t_0)
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 = d / Math.sqrt((l * h));
double tmp;
if (((Math.pow((d / h), Math.pow(2.0, -1.0)) * Math.pow((d / l), Math.pow(2.0, -1.0))) * (1.0 - ((Math.pow(2.0, -1.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5e-134) {
tmp = t_0;
} else {
tmp = Math.abs(t_0);
}
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 = d / math.sqrt((l * h)) tmp = 0 if ((math.pow((d / h), math.pow(2.0, -1.0)) * math.pow((d / l), math.pow(2.0, -1.0))) * (1.0 - ((math.pow(2.0, -1.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5e-134: tmp = t_0 else: tmp = math.fabs(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 = Float64(d / sqrt(Float64(l * h))) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= -5e-134) tmp = t_0; else tmp = abs(t_0); 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 / sqrt((l * h));
tmp = 0.0;
if (((((d / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= -5e-134)
tmp = t_0;
else
tmp = abs(t_0);
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[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e-134], t$95$0, N[Abs[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 := \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -5 \cdot 10^{-134}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left|t\_0\right|\\
\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)))) < -5.0000000000000003e-134Initial program 79.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6410.3
Applied rewrites10.3%
Applied rewrites9.3%
if -5.0000000000000003e-134 < (*.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 52.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6436.4
Applied rewrites36.4%
Applied rewrites68.6%
Final simplification47.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
(/ (* (* D_m (/ M_m d)) -0.5) l)
(* (* (/ M_m d) h) (* 0.25 D_m))
1.0)))
(if (<= d -5e-310)
(* (* t_0 (sqrt (/ d h))) (* (sqrt (- d)) (sqrt (pow (- l) -1.0))))
(if (<= d 1.75e-28)
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (/ (sqrt d) (sqrt l)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l))))
(* (* t_0 (/ (sqrt d) (sqrt h))) (sqrt (/ d 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 t_0 = fma((((D_m * (M_m / d)) * -0.5) / l), (((M_m / d) * h) * (0.25 * D_m)), 1.0);
double tmp;
if (d <= -5e-310) {
tmp = (t_0 * sqrt((d / h))) * (sqrt(-d) * sqrt(pow(-l, -1.0)));
} else if (d <= 1.75e-28) {
tmp = (pow((d / h), pow(2.0, -1.0)) * (sqrt(d) / sqrt(l))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
} else {
tmp = (t_0 * (sqrt(d) / sqrt(h))) * sqrt((d / 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) t_0 = fma(Float64(Float64(Float64(D_m * Float64(M_m / d)) * -0.5) / l), Float64(Float64(Float64(M_m / d) * h) * Float64(0.25 * D_m)), 1.0) tmp = 0.0 if (d <= -5e-310) tmp = Float64(Float64(t_0 * sqrt(Float64(d / h))) * Float64(sqrt(Float64(-d)) * sqrt((Float64(-l) ^ -1.0)))); elseif (d <= 1.75e-28) tmp = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * Float64(sqrt(d) / sqrt(l))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))); else tmp = Float64(Float64(t_0 * Float64(sqrt(d) / sqrt(h))) * sqrt(Float64(d / l))); 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[(N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision] / l), $MachinePrecision] * N[(N[(N[(M$95$m / d), $MachinePrecision] * h), $MachinePrecision] * N[(0.25 * D$95$m), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[d, -5e-310], N[(N[(t$95$0 * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[(-d)], $MachinePrecision] * N[Sqrt[N[Power[(-l), -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.75e-28], N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / 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}
t_0 := \mathsf{fma}\left(\frac{\left(D\_m \cdot \frac{M\_m}{d}\right) \cdot -0.5}{\ell}, \left(\frac{M\_m}{d} \cdot h\right) \cdot \left(0.25 \cdot D\_m\right), 1\right)\\
\mathbf{if}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(t\_0 \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(\sqrt{-d} \cdot \sqrt{{\left(-\ell\right)}^{-1}}\right)\\
\mathbf{elif}\;d \leq 1.75 \cdot 10^{-28}:\\
\;\;\;\;\left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right) \cdot \sqrt{\frac{d}{\ell}}\\
\end{array}
\end{array}
if d < -4.999999999999985e-310Initial program 61.5%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites62.0%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6461.5
Applied rewrites61.5%
Applied rewrites65.1%
lift-sqrt.f64N/A
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
div-invN/A
sqrt-prodN/A
lift-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-neg.f6473.2
Applied rewrites73.2%
if -4.999999999999985e-310 < d < 1.75e-28Initial program 58.0%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lift-/.f64N/A
sqrt-divN/A
pow1/2N/A
metadata-evalN/A
lift-/.f64N/A
lower-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lower-sqrt.f6480.8
Applied rewrites80.8%
if 1.75e-28 < d Initial program 67.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites66.2%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6467.8
Applied rewrites67.8%
Applied rewrites78.8%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
pow1/2N/A
metadata-evalN/A
pow1/2N/A
metadata-evalN/A
lower-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f6490.4
Applied rewrites90.4%
Final simplification78.8%
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 l)))
(t_1
(fma
(/ (* (* D_m (/ M_m d)) -0.5) l)
(* (* (/ M_m d) h) (* 0.25 D_m))
1.0))
(t_2 (sqrt (- d))))
(if (<= l -1.15e+120)
(* (* t_1 (sqrt (/ d h))) (/ t_2 (sqrt (- l))))
(if (<= l -1.15e-307)
(* (* t_1 (/ t_2 (sqrt (- h)))) t_0)
(if (<= l 6.6e+212)
(* (* t_1 (/ (sqrt d) (sqrt h))) t_0)
(/ d (* (sqrt l) (sqrt 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 t_0 = sqrt((d / l));
double t_1 = fma((((D_m * (M_m / d)) * -0.5) / l), (((M_m / d) * h) * (0.25 * D_m)), 1.0);
double t_2 = sqrt(-d);
double tmp;
if (l <= -1.15e+120) {
tmp = (t_1 * sqrt((d / h))) * (t_2 / sqrt(-l));
} else if (l <= -1.15e-307) {
tmp = (t_1 * (t_2 / sqrt(-h))) * t_0;
} else if (l <= 6.6e+212) {
tmp = (t_1 * (sqrt(d) / sqrt(h))) * t_0;
} else {
tmp = d / (sqrt(l) * sqrt(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) t_0 = sqrt(Float64(d / l)) t_1 = fma(Float64(Float64(Float64(D_m * Float64(M_m / d)) * -0.5) / l), Float64(Float64(Float64(M_m / d) * h) * Float64(0.25 * D_m)), 1.0) t_2 = sqrt(Float64(-d)) tmp = 0.0 if (l <= -1.15e+120) tmp = Float64(Float64(t_1 * sqrt(Float64(d / h))) * Float64(t_2 / sqrt(Float64(-l)))); elseif (l <= -1.15e-307) tmp = Float64(Float64(t_1 * Float64(t_2 / sqrt(Float64(-h)))) * t_0); elseif (l <= 6.6e+212) tmp = Float64(Float64(t_1 * Float64(sqrt(d) / sqrt(h))) * t_0); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); 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[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision] / l), $MachinePrecision] * N[(N[(N[(M$95$m / d), $MachinePrecision] * h), $MachinePrecision] * N[(0.25 * D$95$m), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[(-d)], $MachinePrecision]}, If[LessEqual[l, -1.15e+120], N[(N[(t$95$1 * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(t$95$2 / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -1.15e-307], N[(N[(t$95$1 * N[(t$95$2 / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[l, 6.6e+212], N[(N[(t$95$1 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[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}
t_0 := \sqrt{\frac{d}{\ell}}\\
t_1 := \mathsf{fma}\left(\frac{\left(D\_m \cdot \frac{M\_m}{d}\right) \cdot -0.5}{\ell}, \left(\frac{M\_m}{d} \cdot h\right) \cdot \left(0.25 \cdot D\_m\right), 1\right)\\
t_2 := \sqrt{-d}\\
\mathbf{if}\;\ell \leq -1.15 \cdot 10^{+120}:\\
\;\;\;\;\left(t\_1 \cdot \sqrt{\frac{d}{h}}\right) \cdot \frac{t\_2}{\sqrt{-\ell}}\\
\mathbf{elif}\;\ell \leq -1.15 \cdot 10^{-307}:\\
\;\;\;\;\left(t\_1 \cdot \frac{t\_2}{\sqrt{-h}}\right) \cdot t\_0\\
\mathbf{elif}\;\ell \leq 6.6 \cdot 10^{+212}:\\
\;\;\;\;\left(t\_1 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < -1.14999999999999996e120Initial program 47.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites51.3%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6447.7
Applied rewrites47.7%
Applied rewrites55.4%
lift-sqrt.f64N/A
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f6468.3
Applied rewrites68.3%
if -1.14999999999999996e120 < l < -1.1499999999999999e-307Initial program 68.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.6%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6468.9
Applied rewrites68.9%
Applied rewrites70.2%
lift-sqrt.f64N/A
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
lift-neg.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lower-/.f6481.7
Applied rewrites81.7%
if -1.1499999999999999e-307 < l < 6.6e212Initial program 72.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.9%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6472.2
Applied rewrites72.2%
Applied rewrites73.3%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
pow1/2N/A
metadata-evalN/A
pow1/2N/A
metadata-evalN/A
lower-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f6480.3
Applied rewrites80.3%
if 6.6e212 < l Initial program 17.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6460.0
Applied rewrites60.0%
Applied rewrites59.8%
Applied rewrites70.8%
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
(/ (* (* D_m (/ M_m d)) -0.5) l)
(* (* (/ M_m d) h) (* 0.25 D_m))
1.0)))
(if (<= l -1.36e-291)
(* (* t_0 (sqrt (/ d h))) (/ (sqrt (- d)) (sqrt (- l))))
(if (<= l 6.6e+212)
(* (* t_0 (/ (sqrt d) (sqrt h))) (sqrt (/ d l)))
(/ d (* (sqrt l) (sqrt 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 t_0 = fma((((D_m * (M_m / d)) * -0.5) / l), (((M_m / d) * h) * (0.25 * D_m)), 1.0);
double tmp;
if (l <= -1.36e-291) {
tmp = (t_0 * sqrt((d / h))) * (sqrt(-d) / sqrt(-l));
} else if (l <= 6.6e+212) {
tmp = (t_0 * (sqrt(d) / sqrt(h))) * sqrt((d / l));
} else {
tmp = d / (sqrt(l) * sqrt(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) t_0 = fma(Float64(Float64(Float64(D_m * Float64(M_m / d)) * -0.5) / l), Float64(Float64(Float64(M_m / d) * h) * Float64(0.25 * D_m)), 1.0) tmp = 0.0 if (l <= -1.36e-291) tmp = Float64(Float64(t_0 * sqrt(Float64(d / h))) * Float64(sqrt(Float64(-d)) / sqrt(Float64(-l)))); elseif (l <= 6.6e+212) tmp = Float64(Float64(t_0 * Float64(sqrt(d) / sqrt(h))) * sqrt(Float64(d / l))); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); 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[(N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision] / l), $MachinePrecision] * N[(N[(N[(M$95$m / d), $MachinePrecision] * h), $MachinePrecision] * N[(0.25 * D$95$m), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[l, -1.36e-291], N[(N[(t$95$0 * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6.6e+212], N[(N[(t$95$0 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[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}
t_0 := \mathsf{fma}\left(\frac{\left(D\_m \cdot \frac{M\_m}{d}\right) \cdot -0.5}{\ell}, \left(\frac{M\_m}{d} \cdot h\right) \cdot \left(0.25 \cdot D\_m\right), 1\right)\\
\mathbf{if}\;\ell \leq -1.36 \cdot 10^{-291}:\\
\;\;\;\;\left(t\_0 \cdot \sqrt{\frac{d}{h}}\right) \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\\
\mathbf{elif}\;\ell \leq 6.6 \cdot 10^{+212}:\\
\;\;\;\;\left(t\_0 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < -1.36000000000000007e-291Initial program 61.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites62.2%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6461.6
Applied rewrites61.6%
Applied rewrites65.3%
lift-sqrt.f64N/A
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f6473.5
Applied rewrites73.5%
if -1.36000000000000007e-291 < l < 6.6e212Initial program 71.4%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.2%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6471.4
Applied rewrites71.4%
Applied rewrites72.5%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
pow1/2N/A
metadata-evalN/A
pow1/2N/A
metadata-evalN/A
lower-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f6479.5
Applied rewrites79.5%
if 6.6e212 < l Initial program 17.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6460.0
Applied rewrites60.0%
Applied rewrites59.8%
Applied rewrites70.8%
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 62.4%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6426.9
Applied rewrites26.9%
Applied rewrites26.8%
herbie shell --seed 2024315
(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)))))