
(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 19 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (pow (/ d l) (pow 2.0 -1.0))))
(if (<= d -2.4e-169)
(*
(* (/ (sqrt (- d)) (sqrt (- h))) t_0)
(-
1.0
(*
(/ (* (* (/ 0.5 d) M_m) D) l)
(/ (* (* 0.5 (* D 0.5)) (/ M_m d)) (pow h -1.0)))))
(if (<= d 5.9e-114)
(/
(* (sqrt (/ h l)) (fma (* -0.125 (/ (pow (* D M_m) 2.0) d)) (/ h l) d))
h)
(*
(* (/ (sqrt d) (sqrt h)) t_0)
(fma (/ (* -0.5 (pow (* (/ (/ d D) M_m) 2.0) -2.0)) l) h 1.0))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = pow((d / l), pow(2.0, -1.0));
double tmp;
if (d <= -2.4e-169) {
tmp = ((sqrt(-d) / sqrt(-h)) * t_0) * (1.0 - (((((0.5 / d) * M_m) * D) / l) * (((0.5 * (D * 0.5)) * (M_m / d)) / pow(h, -1.0))));
} else if (d <= 5.9e-114) {
tmp = (sqrt((h / l)) * fma((-0.125 * (pow((D * M_m), 2.0) / d)), (h / l), d)) / h;
} else {
tmp = ((sqrt(d) / sqrt(h)) * t_0) * fma(((-0.5 * pow((((d / D) / M_m) * 2.0), -2.0)) / l), h, 1.0);
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(d / l) ^ (2.0 ^ -1.0) tmp = 0.0 if (d <= -2.4e-169) tmp = Float64(Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * t_0) * Float64(1.0 - Float64(Float64(Float64(Float64(Float64(0.5 / d) * M_m) * D) / l) * Float64(Float64(Float64(0.5 * Float64(D * 0.5)) * Float64(M_m / d)) / (h ^ -1.0))))); elseif (d <= 5.9e-114) tmp = Float64(Float64(sqrt(Float64(h / l)) * fma(Float64(-0.125 * Float64((Float64(D * M_m) ^ 2.0) / d)), Float64(h / l), d)) / h); else tmp = Float64(Float64(Float64(sqrt(d) / sqrt(h)) * t_0) * fma(Float64(Float64(-0.5 * (Float64(Float64(Float64(d / D) / M_m) * 2.0) ^ -2.0)) / l), h, 1.0)); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -2.4e-169], N[(N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(N[(0.5 / d), $MachinePrecision] * M$95$m), $MachinePrecision] * D), $MachinePrecision] / l), $MachinePrecision] * N[(N[(N[(0.5 * N[(D * 0.5), $MachinePrecision]), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] / N[Power[h, -1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.9e-114], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * N[(N[(-0.125 * N[(N[Power[N[(D * M$95$m), $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * N[(N[(N[(-0.5 * N[Power[N[(N[(N[(d / D), $MachinePrecision] / M$95$m), $MachinePrecision] * 2.0), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * h + 1.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\\
\mathbf{if}\;d \leq -2.4 \cdot 10^{-169}:\\
\;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot t\_0\right) \cdot \left(1 - \frac{\left(\frac{0.5}{d} \cdot M\_m\right) \cdot D}{\ell} \cdot \frac{\left(0.5 \cdot \left(D \cdot 0.5\right)\right) \cdot \frac{M\_m}{d}}{{h}^{-1}}\right)\\
\mathbf{elif}\;d \leq 5.9 \cdot 10^{-114}:\\
\;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \mathsf{fma}\left(-0.125 \cdot \frac{{\left(D \cdot M\_m\right)}^{2}}{d}, \frac{h}{\ell}, d\right)}{h}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot t\_0\right) \cdot \mathsf{fma}\left(\frac{-0.5 \cdot {\left(\frac{\frac{d}{D}}{M\_m} \cdot 2\right)}^{-2}}{\ell}, h, 1\right)\\
\end{array}
\end{array}
if d < -2.40000000000000011e-169Initial program 69.2%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
div-invN/A
times-fracN/A
lower-*.f64N/A
Applied rewrites77.3%
lift-/.f64N/A
metadata-eval77.3
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f6489.3
Applied rewrites89.3%
if -2.40000000000000011e-169 < d < 5.9000000000000001e-114Initial program 59.6%
Taylor expanded in d around inf
Applied rewrites27.8%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites35.2%
Applied rewrites61.1%
Applied rewrites82.2%
if 5.9000000000000001e-114 < d Initial program 72.1%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites79.4%
lift-/.f64N/A
metadata-eval79.4
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
sqrt-divN/A
pow1/2N/A
lower-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lower-sqrt.f6494.6
Applied rewrites94.6%
Final simplification89.3%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* (/ D d) M_m))
(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) (* 2.0 d)) 2.0)) (/ h l)))))
(t_2 (sqrt (* l h)))
(t_3 (* (fma t_0 (* t_0 (* -0.125 h)) l) (/ (/ (fabs d) t_2) l)))
(t_4 (sqrt (* (/ d l) (/ d h)))))
(if (<= t_1 (- INFINITY))
t_3
(if (<= t_1 -1e-110)
(fma
(* (* (/ (- h) l) (* (/ M_m d) (* 0.25 D))) (* (/ 0.5 d) M_m))
(* D t_4)
t_4)
(if (<= t_1 0.0)
(/
(* (fma (* (pow (/ (/ d D) M_m) -2.0) -0.125) h l) (fabs d))
(* t_2 l))
(if (<= t_1 4e+282)
(* (* 1.0 (sqrt (/ d l))) (sqrt (/ d h)))
t_3))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = (D / d) * M_m;
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) / (2.0 * d)), 2.0)) * (h / l)));
double t_2 = sqrt((l * h));
double t_3 = fma(t_0, (t_0 * (-0.125 * h)), l) * ((fabs(d) / t_2) / l);
double t_4 = sqrt(((d / l) * (d / h)));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_3;
} else if (t_1 <= -1e-110) {
tmp = fma((((-h / l) * ((M_m / d) * (0.25 * D))) * ((0.5 / d) * M_m)), (D * t_4), t_4);
} else if (t_1 <= 0.0) {
tmp = (fma((pow(((d / D) / M_m), -2.0) * -0.125), h, l) * fabs(d)) / (t_2 * l);
} else if (t_1 <= 4e+282) {
tmp = (1.0 * sqrt((d / l))) * sqrt((d / h));
} else {
tmp = t_3;
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64(D / d) * M_m) 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) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_2 = sqrt(Float64(l * h)) t_3 = Float64(fma(t_0, Float64(t_0 * Float64(-0.125 * h)), l) * Float64(Float64(abs(d) / t_2) / l)) t_4 = sqrt(Float64(Float64(d / l) * Float64(d / h))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = t_3; elseif (t_1 <= -1e-110) tmp = fma(Float64(Float64(Float64(Float64(-h) / l) * Float64(Float64(M_m / d) * Float64(0.25 * D))) * Float64(Float64(0.5 / d) * M_m)), Float64(D * t_4), t_4); elseif (t_1 <= 0.0) tmp = Float64(Float64(fma(Float64((Float64(Float64(d / D) / M_m) ^ -2.0) * -0.125), h, l) * abs(d)) / Float64(t_2 * l)); elseif (t_1 <= 4e+282) tmp = Float64(Float64(1.0 * sqrt(Float64(d / l))) * sqrt(Float64(d / h))); else tmp = t_3; end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(D / d), $MachinePrecision] * M$95$m), $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), $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[(l * h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(t$95$0 * N[(t$95$0 * N[(-0.125 * h), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision] * N[(N[(N[Abs[d], $MachinePrecision] / t$95$2), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], t$95$3, If[LessEqual[t$95$1, -1e-110], N[(N[(N[(N[((-h) / l), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * N[(0.25 * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(0.5 / d), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] * N[(D * t$95$4), $MachinePrecision] + t$95$4), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(N[(N[(N[(N[Power[N[(N[(d / D), $MachinePrecision] / M$95$m), $MachinePrecision], -2.0], $MachinePrecision] * -0.125), $MachinePrecision] * h + l), $MachinePrecision] * N[Abs[d], $MachinePrecision]), $MachinePrecision] / N[(t$95$2 * l), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 4e+282], N[(N[(1.0 * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \frac{D}{d} \cdot M\_m\\
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}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_2 := \sqrt{\ell \cdot h}\\
t_3 := \mathsf{fma}\left(t\_0, t\_0 \cdot \left(-0.125 \cdot h\right), \ell\right) \cdot \frac{\frac{\left|d\right|}{t\_2}}{\ell}\\
t_4 := \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_1 \leq -1 \cdot 10^{-110}:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{-h}{\ell} \cdot \left(\frac{M\_m}{d} \cdot \left(0.25 \cdot D\right)\right)\right) \cdot \left(\frac{0.5}{d} \cdot M\_m\right), D \cdot t\_4, t\_4\right)\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\mathsf{fma}\left({\left(\frac{\frac{d}{D}}{M\_m}\right)}^{-2} \cdot -0.125, h, \ell\right) \cdot \left|d\right|}{t\_2 \cdot \ell}\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+282}:\\
\;\;\;\;\left(1 \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\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)))) < -inf.0 or 4.00000000000000013e282 < (*.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 49.3%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites59.2%
Applied rewrites24.1%
Applied rewrites40.9%
Applied rewrites81.3%
if -inf.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)))) < -1.0000000000000001e-110Initial program 99.0%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites83.3%
Applied rewrites72.3%
if -1.0000000000000001e-110 < (*.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 38.2%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites32.3%
Applied rewrites0.0%
Applied rewrites7.3%
Applied rewrites76.1%
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.00000000000000013e282Initial program 99.4%
Taylor expanded in d around inf
Applied rewrites98.7%
Applied rewrites98.7%
Final simplification85.7%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* (/ D d) M_m))
(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) (* 2.0 d)) 2.0)) (/ h l)))))
(t_2 (sqrt (* l h)))
(t_3 (* (fma t_0 (* t_0 (* -0.125 h)) l) (/ (/ (fabs d) t_2) l)))
(t_4 (sqrt (* (/ d l) (/ d h)))))
(if (<= t_1 (- INFINITY))
t_3
(if (<= t_1 -1e-110)
(fma
(* (* (/ (- h) l) (* (/ M_m d) (* 0.25 D))) (* (/ 0.5 d) M_m))
(* D t_4)
t_4)
(if (<= t_1 0.0)
(* (/ (sqrt (* d d)) t_2) 1.0)
(if (<= t_1 4e+282)
(* (* 1.0 (sqrt (/ d l))) (sqrt (/ d h)))
t_3))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = (D / d) * M_m;
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) / (2.0 * d)), 2.0)) * (h / l)));
double t_2 = sqrt((l * h));
double t_3 = fma(t_0, (t_0 * (-0.125 * h)), l) * ((fabs(d) / t_2) / l);
double t_4 = sqrt(((d / l) * (d / h)));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_3;
} else if (t_1 <= -1e-110) {
tmp = fma((((-h / l) * ((M_m / d) * (0.25 * D))) * ((0.5 / d) * M_m)), (D * t_4), t_4);
} else if (t_1 <= 0.0) {
tmp = (sqrt((d * d)) / t_2) * 1.0;
} else if (t_1 <= 4e+282) {
tmp = (1.0 * sqrt((d / l))) * sqrt((d / h));
} else {
tmp = t_3;
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64(D / d) * M_m) 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) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_2 = sqrt(Float64(l * h)) t_3 = Float64(fma(t_0, Float64(t_0 * Float64(-0.125 * h)), l) * Float64(Float64(abs(d) / t_2) / l)) t_4 = sqrt(Float64(Float64(d / l) * Float64(d / h))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = t_3; elseif (t_1 <= -1e-110) tmp = fma(Float64(Float64(Float64(Float64(-h) / l) * Float64(Float64(M_m / d) * Float64(0.25 * D))) * Float64(Float64(0.5 / d) * M_m)), Float64(D * t_4), t_4); elseif (t_1 <= 0.0) tmp = Float64(Float64(sqrt(Float64(d * d)) / t_2) * 1.0); elseif (t_1 <= 4e+282) tmp = Float64(Float64(1.0 * sqrt(Float64(d / l))) * sqrt(Float64(d / h))); else tmp = t_3; end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(D / d), $MachinePrecision] * M$95$m), $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), $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[(l * h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(t$95$0 * N[(t$95$0 * N[(-0.125 * h), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision] * N[(N[(N[Abs[d], $MachinePrecision] / t$95$2), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], t$95$3, If[LessEqual[t$95$1, -1e-110], N[(N[(N[(N[((-h) / l), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * N[(0.25 * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(0.5 / d), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] * N[(D * t$95$4), $MachinePrecision] + t$95$4), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(N[(N[Sqrt[N[(d * d), $MachinePrecision]], $MachinePrecision] / t$95$2), $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[t$95$1, 4e+282], N[(N[(1.0 * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \frac{D}{d} \cdot M\_m\\
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}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_2 := \sqrt{\ell \cdot h}\\
t_3 := \mathsf{fma}\left(t\_0, t\_0 \cdot \left(-0.125 \cdot h\right), \ell\right) \cdot \frac{\frac{\left|d\right|}{t\_2}}{\ell}\\
t_4 := \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_1 \leq -1 \cdot 10^{-110}:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{-h}{\ell} \cdot \left(\frac{M\_m}{d} \cdot \left(0.25 \cdot D\right)\right)\right) \cdot \left(\frac{0.5}{d} \cdot M\_m\right), D \cdot t\_4, t\_4\right)\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\sqrt{d \cdot d}}{t\_2} \cdot 1\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+282}:\\
\;\;\;\;\left(1 \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\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)))) < -inf.0 or 4.00000000000000013e282 < (*.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 49.3%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites59.2%
Applied rewrites24.1%
Applied rewrites40.9%
Applied rewrites81.3%
if -inf.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)))) < -1.0000000000000001e-110Initial program 99.0%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites83.3%
Applied rewrites72.3%
if -1.0000000000000001e-110 < (*.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 38.2%
Taylor expanded in d around inf
Applied rewrites38.2%
lift-/.f64N/A
metadata-eval38.2
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
clear-numN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f6438.2
Applied rewrites38.2%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
metadata-evalN/A
unpow1/2N/A
lift-/.f64N/A
metadata-evalN/A
lift-sqrt.f64N/A
sqrt-divN/A
lift-/.f64N/A
clear-numN/A
sqrt-unprodN/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f6466.1
Applied rewrites66.1%
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.00000000000000013e282Initial program 99.4%
Taylor expanded in d around inf
Applied rewrites98.7%
Applied rewrites98.7%
Final simplification85.0%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* (/ D d) M_m))
(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) (* 2.0 d)) 2.0)) (/ h l)))))
(t_2 (sqrt (* l h)))
(t_3 (* (fma t_0 (* t_0 (* -0.125 h)) l) (/ (/ (fabs d) t_2) l)))
(t_4 (sqrt (* (/ d l) (/ d h)))))
(if (<= t_1 (- INFINITY))
t_3
(if (<= t_1 -1e-110)
(fma
(* (* (/ 0.5 d) M_m) D)
(* (* (/ (- h) l) (* (/ M_m d) (* 0.25 D))) t_4)
t_4)
(if (<= t_1 0.0)
(* (/ (sqrt (* d d)) t_2) 1.0)
(if (<= t_1 4e+282)
(* (* 1.0 (sqrt (/ d l))) (sqrt (/ d h)))
t_3))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = (D / d) * M_m;
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) / (2.0 * d)), 2.0)) * (h / l)));
double t_2 = sqrt((l * h));
double t_3 = fma(t_0, (t_0 * (-0.125 * h)), l) * ((fabs(d) / t_2) / l);
double t_4 = sqrt(((d / l) * (d / h)));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_3;
} else if (t_1 <= -1e-110) {
tmp = fma((((0.5 / d) * M_m) * D), (((-h / l) * ((M_m / d) * (0.25 * D))) * t_4), t_4);
} else if (t_1 <= 0.0) {
tmp = (sqrt((d * d)) / t_2) * 1.0;
} else if (t_1 <= 4e+282) {
tmp = (1.0 * sqrt((d / l))) * sqrt((d / h));
} else {
tmp = t_3;
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64(D / d) * M_m) 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) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_2 = sqrt(Float64(l * h)) t_3 = Float64(fma(t_0, Float64(t_0 * Float64(-0.125 * h)), l) * Float64(Float64(abs(d) / t_2) / l)) t_4 = sqrt(Float64(Float64(d / l) * Float64(d / h))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = t_3; elseif (t_1 <= -1e-110) tmp = fma(Float64(Float64(Float64(0.5 / d) * M_m) * D), Float64(Float64(Float64(Float64(-h) / l) * Float64(Float64(M_m / d) * Float64(0.25 * D))) * t_4), t_4); elseif (t_1 <= 0.0) tmp = Float64(Float64(sqrt(Float64(d * d)) / t_2) * 1.0); elseif (t_1 <= 4e+282) tmp = Float64(Float64(1.0 * sqrt(Float64(d / l))) * sqrt(Float64(d / h))); else tmp = t_3; end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(D / d), $MachinePrecision] * M$95$m), $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), $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[(l * h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(t$95$0 * N[(t$95$0 * N[(-0.125 * h), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision] * N[(N[(N[Abs[d], $MachinePrecision] / t$95$2), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], t$95$3, If[LessEqual[t$95$1, -1e-110], N[(N[(N[(N[(0.5 / d), $MachinePrecision] * M$95$m), $MachinePrecision] * D), $MachinePrecision] * N[(N[(N[((-h) / l), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * N[(0.25 * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$4), $MachinePrecision] + t$95$4), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(N[(N[Sqrt[N[(d * d), $MachinePrecision]], $MachinePrecision] / t$95$2), $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[t$95$1, 4e+282], N[(N[(1.0 * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \frac{D}{d} \cdot M\_m\\
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}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_2 := \sqrt{\ell \cdot h}\\
t_3 := \mathsf{fma}\left(t\_0, t\_0 \cdot \left(-0.125 \cdot h\right), \ell\right) \cdot \frac{\frac{\left|d\right|}{t\_2}}{\ell}\\
t_4 := \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_1 \leq -1 \cdot 10^{-110}:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{0.5}{d} \cdot M\_m\right) \cdot D, \left(\frac{-h}{\ell} \cdot \left(\frac{M\_m}{d} \cdot \left(0.25 \cdot D\right)\right)\right) \cdot t\_4, t\_4\right)\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\sqrt{d \cdot d}}{t\_2} \cdot 1\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+282}:\\
\;\;\;\;\left(1 \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\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)))) < -inf.0 or 4.00000000000000013e282 < (*.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 49.3%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites59.2%
Applied rewrites24.1%
Applied rewrites40.9%
Applied rewrites81.3%
if -inf.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)))) < -1.0000000000000001e-110Initial program 99.0%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites83.3%
Applied rewrites93.5%
if -1.0000000000000001e-110 < (*.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 38.2%
Taylor expanded in d around inf
Applied rewrites38.2%
lift-/.f64N/A
metadata-eval38.2
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
clear-numN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f6438.2
Applied rewrites38.2%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
metadata-evalN/A
unpow1/2N/A
lift-/.f64N/A
metadata-evalN/A
lift-sqrt.f64N/A
sqrt-divN/A
lift-/.f64N/A
clear-numN/A
sqrt-unprodN/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f6466.1
Applied rewrites66.1%
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.00000000000000013e282Initial program 99.4%
Taylor expanded in d around inf
Applied rewrites98.7%
Applied rewrites98.7%
Final simplification86.5%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (sqrt (* (/ d l) (/ d h))))
(t_1 (* (/ D d) M_m))
(t_2
(*
(* (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) (* 2.0 d)) 2.0)) (/ h l)))))
(t_3 (sqrt (* l h)))
(t_4 (* (fma t_1 (* t_1 (* -0.125 h)) l) (/ (/ (fabs d) t_3) l))))
(if (<= t_2 (- INFINITY))
t_4
(if (<= t_2 -1e-110)
(fma
(* t_0 (* (* (/ (- h) l) (* (/ M_m d) (* 0.25 D))) (* (/ 0.5 d) M_m)))
D
t_0)
(if (<= t_2 0.0)
(* (/ (sqrt (* d d)) t_3) 1.0)
(if (<= t_2 4e+282)
(* (* 1.0 (sqrt (/ d l))) (sqrt (/ d h)))
t_4))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = sqrt(((d / l) * (d / h)));
double t_1 = (D / d) * M_m;
double t_2 = (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) / (2.0 * d)), 2.0)) * (h / l)));
double t_3 = sqrt((l * h));
double t_4 = fma(t_1, (t_1 * (-0.125 * h)), l) * ((fabs(d) / t_3) / l);
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_4;
} else if (t_2 <= -1e-110) {
tmp = fma((t_0 * (((-h / l) * ((M_m / d) * (0.25 * D))) * ((0.5 / d) * M_m))), D, t_0);
} else if (t_2 <= 0.0) {
tmp = (sqrt((d * d)) / t_3) * 1.0;
} else if (t_2 <= 4e+282) {
tmp = (1.0 * sqrt((d / l))) * sqrt((d / h));
} else {
tmp = t_4;
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = sqrt(Float64(Float64(d / l) * Float64(d / h))) t_1 = Float64(Float64(D / d) * M_m) t_2 = 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) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_3 = sqrt(Float64(l * h)) t_4 = Float64(fma(t_1, Float64(t_1 * Float64(-0.125 * h)), l) * Float64(Float64(abs(d) / t_3) / l)) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_4; elseif (t_2 <= -1e-110) tmp = fma(Float64(t_0 * Float64(Float64(Float64(Float64(-h) / l) * Float64(Float64(M_m / d) * Float64(0.25 * D))) * Float64(Float64(0.5 / d) * M_m))), D, t_0); elseif (t_2 <= 0.0) tmp = Float64(Float64(sqrt(Float64(d * d)) / t_3) * 1.0); elseif (t_2 <= 4e+282) tmp = Float64(Float64(1.0 * sqrt(Float64(d / l))) * sqrt(Float64(d / h))); else tmp = t_4; end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(D / d), $MachinePrecision] * M$95$m), $MachinePrecision]}, Block[{t$95$2 = 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), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(N[(t$95$1 * N[(t$95$1 * N[(-0.125 * h), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision] * N[(N[(N[Abs[d], $MachinePrecision] / t$95$3), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$4, If[LessEqual[t$95$2, -1e-110], N[(N[(t$95$0 * N[(N[(N[((-h) / l), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * N[(0.25 * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(0.5 / d), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * D + t$95$0), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(N[(N[Sqrt[N[(d * d), $MachinePrecision]], $MachinePrecision] / t$95$3), $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[t$95$2, 4e+282], N[(N[(1.0 * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$4]]]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
t_1 := \frac{D}{d} \cdot M\_m\\
t_2 := \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}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_3 := \sqrt{\ell \cdot h}\\
t_4 := \mathsf{fma}\left(t\_1, t\_1 \cdot \left(-0.125 \cdot h\right), \ell\right) \cdot \frac{\frac{\left|d\right|}{t\_3}}{\ell}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;t\_2 \leq -1 \cdot 10^{-110}:\\
\;\;\;\;\mathsf{fma}\left(t\_0 \cdot \left(\left(\frac{-h}{\ell} \cdot \left(\frac{M\_m}{d} \cdot \left(0.25 \cdot D\right)\right)\right) \cdot \left(\frac{0.5}{d} \cdot M\_m\right)\right), D, t\_0\right)\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;\frac{\sqrt{d \cdot d}}{t\_3} \cdot 1\\
\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+282}:\\
\;\;\;\;\left(1 \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;t\_4\\
\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)))) < -inf.0 or 4.00000000000000013e282 < (*.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 49.3%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites59.2%
Applied rewrites24.1%
Applied rewrites40.9%
Applied rewrites81.3%
if -inf.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)))) < -1.0000000000000001e-110Initial program 99.0%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites83.3%
Applied rewrites72.7%
if -1.0000000000000001e-110 < (*.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 38.2%
Taylor expanded in d around inf
Applied rewrites38.2%
lift-/.f64N/A
metadata-eval38.2
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
clear-numN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f6438.2
Applied rewrites38.2%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
metadata-evalN/A
unpow1/2N/A
lift-/.f64N/A
metadata-evalN/A
lift-sqrt.f64N/A
sqrt-divN/A
lift-/.f64N/A
clear-numN/A
sqrt-unprodN/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f6466.1
Applied rewrites66.1%
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.00000000000000013e282Initial program 99.4%
Taylor expanded in d around inf
Applied rewrites98.7%
Applied rewrites98.7%
Final simplification85.1%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
: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) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1 (sqrt (* l h)))
(t_2 (* (/ (sqrt (* d d)) t_1) 1.0))
(t_3
(*
(* (* -0.125 (* h (/ (* D D) d))) (/ (* M_m M_m) d))
(/ (/ (fabs d) t_1) l))))
(if (<= t_0 -500.0)
t_3
(if (<= t_0 0.0)
t_2
(if (<= t_0 4e+282)
(* (* 1.0 (sqrt (/ d l))) (sqrt (/ d h)))
(if (<= t_0 INFINITY) t_2 t_3))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
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) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = sqrt((l * h));
double t_2 = (sqrt((d * d)) / t_1) * 1.0;
double t_3 = ((-0.125 * (h * ((D * D) / d))) * ((M_m * M_m) / d)) * ((fabs(d) / t_1) / l);
double tmp;
if (t_0 <= -500.0) {
tmp = t_3;
} else if (t_0 <= 0.0) {
tmp = t_2;
} else if (t_0 <= 4e+282) {
tmp = (1.0 * sqrt((d / l))) * sqrt((d / h));
} else if (t_0 <= ((double) INFINITY)) {
tmp = t_2;
} else {
tmp = t_3;
}
return tmp;
}
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
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) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = Math.sqrt((l * h));
double t_2 = (Math.sqrt((d * d)) / t_1) * 1.0;
double t_3 = ((-0.125 * (h * ((D * D) / d))) * ((M_m * M_m) / d)) * ((Math.abs(d) / t_1) / l);
double tmp;
if (t_0 <= -500.0) {
tmp = t_3;
} else if (t_0 <= 0.0) {
tmp = t_2;
} else if (t_0 <= 4e+282) {
tmp = (1.0 * Math.sqrt((d / l))) * Math.sqrt((d / h));
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_2;
} else {
tmp = t_3;
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): 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) / (2.0 * d)), 2.0)) * (h / l))) t_1 = math.sqrt((l * h)) t_2 = (math.sqrt((d * d)) / t_1) * 1.0 t_3 = ((-0.125 * (h * ((D * D) / d))) * ((M_m * M_m) / d)) * ((math.fabs(d) / t_1) / l) tmp = 0 if t_0 <= -500.0: tmp = t_3 elif t_0 <= 0.0: tmp = t_2 elif t_0 <= 4e+282: tmp = (1.0 * math.sqrt((d / l))) * math.sqrt((d / h)) elif t_0 <= math.inf: tmp = t_2 else: tmp = t_3 return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) 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) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = sqrt(Float64(l * h)) t_2 = Float64(Float64(sqrt(Float64(d * d)) / t_1) * 1.0) t_3 = Float64(Float64(Float64(-0.125 * Float64(h * Float64(Float64(D * D) / d))) * Float64(Float64(M_m * M_m) / d)) * Float64(Float64(abs(d) / t_1) / l)) tmp = 0.0 if (t_0 <= -500.0) tmp = t_3; elseif (t_0 <= 0.0) tmp = t_2; elseif (t_0 <= 4e+282) tmp = Float64(Float64(1.0 * sqrt(Float64(d / l))) * sqrt(Float64(d / h))); elseif (t_0 <= Inf) tmp = t_2; else tmp = t_3; end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = (((d / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M_m * D) / (2.0 * d)) ^ 2.0)) * (h / l)));
t_1 = sqrt((l * h));
t_2 = (sqrt((d * d)) / t_1) * 1.0;
t_3 = ((-0.125 * (h * ((D * D) / d))) * ((M_m * M_m) / d)) * ((abs(d) / t_1) / l);
tmp = 0.0;
if (t_0 <= -500.0)
tmp = t_3;
elseif (t_0 <= 0.0)
tmp = t_2;
elseif (t_0 <= 4e+282)
tmp = (1.0 * sqrt((d / l))) * sqrt((d / h));
elseif (t_0 <= Inf)
tmp = t_2;
else
tmp = t_3;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := 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), $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[(l * h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Sqrt[N[(d * d), $MachinePrecision]], $MachinePrecision] / t$95$1), $MachinePrecision] * 1.0), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(-0.125 * N[(h * N[(N[(D * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(N[(N[Abs[d], $MachinePrecision] / t$95$1), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -500.0], t$95$3, If[LessEqual[t$95$0, 0.0], t$95$2, If[LessEqual[t$95$0, 4e+282], N[(N[(1.0 * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], t$95$2, t$95$3]]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\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}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \sqrt{\ell \cdot h}\\
t_2 := \frac{\sqrt{d \cdot d}}{t\_1} \cdot 1\\
t_3 := \left(\left(-0.125 \cdot \left(h \cdot \frac{D \cdot D}{d}\right)\right) \cdot \frac{M\_m \cdot M\_m}{d}\right) \cdot \frac{\frac{\left|d\right|}{t\_1}}{\ell}\\
\mathbf{if}\;t\_0 \leq -500:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+282}:\\
\;\;\;\;\left(1 \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \sqrt{\frac{d}{h}}\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\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)))) < -500 or +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 57.1%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites66.4%
Applied rewrites35.7%
Applied rewrites41.1%
Taylor expanded in d around 0
associate-*r/N/A
associate-*r*N/A
unpow2N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
times-fracN/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6459.0
Applied rewrites59.0%
if -500 < (*.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.0 or 4.00000000000000013e282 < (*.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)))) < +inf.0Initial program 45.4%
Taylor expanded in d around inf
Applied rewrites35.2%
lift-/.f64N/A
metadata-eval35.2
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
clear-numN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f6436.8
Applied rewrites36.8%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
metadata-evalN/A
unpow1/2N/A
lift-/.f64N/A
metadata-evalN/A
lift-sqrt.f64N/A
sqrt-divN/A
lift-/.f64N/A
clear-numN/A
sqrt-unprodN/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f6458.1
Applied rewrites58.1%
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.00000000000000013e282Initial program 99.4%
Taylor expanded in d around inf
Applied rewrites98.7%
Applied rewrites98.7%
Final simplification71.0%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* (/ D d) M_m))
(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) (* 2.0 d)) 2.0)) (/ h l)))))
(t_2 (sqrt (* l h)))
(t_3 (* (fma t_0 (* t_0 (* -0.125 h)) l) (/ (/ (fabs d) t_2) l))))
(if (<= t_1 -1e-110)
t_3
(if (<= t_1 0.0)
(* (/ (sqrt (* d d)) t_2) 1.0)
(if (<= t_1 4e+282) (* (* 1.0 (sqrt (/ d l))) (sqrt (/ d h))) t_3)))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = (D / d) * M_m;
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) / (2.0 * d)), 2.0)) * (h / l)));
double t_2 = sqrt((l * h));
double t_3 = fma(t_0, (t_0 * (-0.125 * h)), l) * ((fabs(d) / t_2) / l);
double tmp;
if (t_1 <= -1e-110) {
tmp = t_3;
} else if (t_1 <= 0.0) {
tmp = (sqrt((d * d)) / t_2) * 1.0;
} else if (t_1 <= 4e+282) {
tmp = (1.0 * sqrt((d / l))) * sqrt((d / h));
} else {
tmp = t_3;
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64(D / d) * M_m) 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) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_2 = sqrt(Float64(l * h)) t_3 = Float64(fma(t_0, Float64(t_0 * Float64(-0.125 * h)), l) * Float64(Float64(abs(d) / t_2) / l)) tmp = 0.0 if (t_1 <= -1e-110) tmp = t_3; elseif (t_1 <= 0.0) tmp = Float64(Float64(sqrt(Float64(d * d)) / t_2) * 1.0); elseif (t_1 <= 4e+282) tmp = Float64(Float64(1.0 * sqrt(Float64(d / l))) * sqrt(Float64(d / h))); else tmp = t_3; end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(D / d), $MachinePrecision] * M$95$m), $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), $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[(l * h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(t$95$0 * N[(t$95$0 * N[(-0.125 * h), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision] * N[(N[(N[Abs[d], $MachinePrecision] / t$95$2), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e-110], t$95$3, If[LessEqual[t$95$1, 0.0], N[(N[(N[Sqrt[N[(d * d), $MachinePrecision]], $MachinePrecision] / t$95$2), $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[t$95$1, 4e+282], N[(N[(1.0 * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \frac{D}{d} \cdot M\_m\\
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}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_2 := \sqrt{\ell \cdot h}\\
t_3 := \mathsf{fma}\left(t\_0, t\_0 \cdot \left(-0.125 \cdot h\right), \ell\right) \cdot \frac{\frac{\left|d\right|}{t\_2}}{\ell}\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{-110}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\sqrt{d \cdot d}}{t\_2} \cdot 1\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+282}:\\
\;\;\;\;\left(1 \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\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)))) < -1.0000000000000001e-110 or 4.00000000000000013e282 < (*.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 54.9%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites61.9%
Applied rewrites29.9%
Applied rewrites40.2%
Applied rewrites78.8%
if -1.0000000000000001e-110 < (*.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 38.2%
Taylor expanded in d around inf
Applied rewrites38.2%
lift-/.f64N/A
metadata-eval38.2
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
clear-numN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f6438.2
Applied rewrites38.2%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
metadata-evalN/A
unpow1/2N/A
lift-/.f64N/A
metadata-evalN/A
lift-sqrt.f64N/A
sqrt-divN/A
lift-/.f64N/A
clear-numN/A
sqrt-unprodN/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f6466.1
Applied rewrites66.1%
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.00000000000000013e282Initial program 99.4%
Taylor expanded in d around inf
Applied rewrites98.7%
Applied rewrites98.7%
Final simplification84.1%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* (/ D d) M_m))
(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) (* 2.0 d)) 2.0)) (/ h l))))))
(if (<= t_1 2e-183)
(/
(* (sqrt (/ h l)) (fma (* -0.125 (/ (pow (* D M_m) 2.0) d)) (/ h l) d))
h)
(if (<= t_1 4e+282)
(* (* 1.0 (sqrt (/ d l))) (sqrt (/ d h)))
(*
(fma t_0 (* t_0 (* -0.125 h)) l)
(/ (/ (fabs d) (sqrt (* l h))) l))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = (D / d) * M_m;
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) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_1 <= 2e-183) {
tmp = (sqrt((h / l)) * fma((-0.125 * (pow((D * M_m), 2.0) / d)), (h / l), d)) / h;
} else if (t_1 <= 4e+282) {
tmp = (1.0 * sqrt((d / l))) * sqrt((d / h));
} else {
tmp = fma(t_0, (t_0 * (-0.125 * h)), l) * ((fabs(d) / sqrt((l * h))) / l);
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64(D / d) * M_m) 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) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_1 <= 2e-183) tmp = Float64(Float64(sqrt(Float64(h / l)) * fma(Float64(-0.125 * Float64((Float64(D * M_m) ^ 2.0) / d)), Float64(h / l), d)) / h); elseif (t_1 <= 4e+282) tmp = Float64(Float64(1.0 * sqrt(Float64(d / l))) * sqrt(Float64(d / h))); else tmp = Float64(fma(t_0, Float64(t_0 * Float64(-0.125 * h)), l) * Float64(Float64(abs(d) / sqrt(Float64(l * h))) / l)); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(D / d), $MachinePrecision] * M$95$m), $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), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 2e-183], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * N[(N[(-0.125 * N[(N[Power[N[(D * M$95$m), $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], If[LessEqual[t$95$1, 4e+282], N[(N[(1.0 * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * N[(t$95$0 * N[(-0.125 * h), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision] * N[(N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \frac{D}{d} \cdot M\_m\\
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}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{-183}:\\
\;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \mathsf{fma}\left(-0.125 \cdot \frac{{\left(D \cdot M\_m\right)}^{2}}{d}, \frac{h}{\ell}, d\right)}{h}\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+282}:\\
\;\;\;\;\left(1 \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, t\_0 \cdot \left(-0.125 \cdot h\right), \ell\right) \cdot \frac{\frac{\left|d\right|}{\sqrt{\ell \cdot h}}}{\ell}\\
\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)))) < 2.00000000000000001e-183Initial program 80.4%
Taylor expanded in d around inf
Applied rewrites13.1%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites35.6%
Applied rewrites58.0%
Applied rewrites81.7%
if 2.00000000000000001e-183 < (*.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.00000000000000013e282Initial program 99.4%
Taylor expanded in d around inf
Applied rewrites98.7%
Applied rewrites98.7%
if 4.00000000000000013e282 < (*.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 17.9%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites31.5%
Applied rewrites5.5%
Applied rewrites30.7%
Applied rewrites73.8%
Final simplification84.2%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
: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) (* 2.0 d)) 2.0)) (/ h l))))))
(if (<= t_0 0.0)
(* (* (* D D) -0.125) (* (/ (* M_m M_m) d) (/ (sqrt (/ h l)) (fabs l))))
(if (<= t_0 4e+282)
(* (* 1.0 (sqrt (/ d l))) (sqrt (/ d h)))
(* (/ (sqrt (* d d)) (sqrt (* l h))) 1.0)))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
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) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= 0.0) {
tmp = ((D * D) * -0.125) * (((M_m * M_m) / d) * (sqrt((h / l)) / fabs(l)));
} else if (t_0 <= 4e+282) {
tmp = (1.0 * sqrt((d / l))) * sqrt((d / h));
} else {
tmp = (sqrt((d * d)) / sqrt((l * h))) * 1.0;
}
return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
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_1
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_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
if (t_0 <= 0.0d0) then
tmp = ((d_1 * d_1) * (-0.125d0)) * (((m_m * m_m) / d) * (sqrt((h / l)) / abs(l)))
else if (t_0 <= 4d+282) then
tmp = (1.0d0 * sqrt((d / l))) * sqrt((d / h))
else
tmp = (sqrt((d * d)) / sqrt((l * h))) * 1.0d0
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
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) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= 0.0) {
tmp = ((D * D) * -0.125) * (((M_m * M_m) / d) * (Math.sqrt((h / l)) / Math.abs(l)));
} else if (t_0 <= 4e+282) {
tmp = (1.0 * Math.sqrt((d / l))) * Math.sqrt((d / h));
} else {
tmp = (Math.sqrt((d * d)) / Math.sqrt((l * h))) * 1.0;
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): 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) / (2.0 * d)), 2.0)) * (h / l))) tmp = 0 if t_0 <= 0.0: tmp = ((D * D) * -0.125) * (((M_m * M_m) / d) * (math.sqrt((h / l)) / math.fabs(l))) elif t_0 <= 4e+282: tmp = (1.0 * math.sqrt((d / l))) * math.sqrt((d / h)) else: tmp = (math.sqrt((d * d)) / math.sqrt((l * h))) * 1.0 return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) 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) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(Float64(Float64(D * D) * -0.125) * Float64(Float64(Float64(M_m * M_m) / d) * Float64(sqrt(Float64(h / l)) / abs(l)))); elseif (t_0 <= 4e+282) tmp = Float64(Float64(1.0 * sqrt(Float64(d / l))) * sqrt(Float64(d / h))); else tmp = Float64(Float64(sqrt(Float64(d * d)) / sqrt(Float64(l * h))) * 1.0); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = (((d / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M_m * D) / (2.0 * d)) ^ 2.0)) * (h / l)));
tmp = 0.0;
if (t_0 <= 0.0)
tmp = ((D * D) * -0.125) * (((M_m * M_m) / d) * (sqrt((h / l)) / abs(l)));
elseif (t_0 <= 4e+282)
tmp = (1.0 * sqrt((d / l))) * sqrt((d / h));
else
tmp = (sqrt((d * d)) / sqrt((l * h))) * 1.0;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := 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), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(N[(D * D), $MachinePrecision] * -0.125), $MachinePrecision] * N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision] * N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] / N[Abs[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e+282], N[(N[(1.0 * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(d * d), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\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}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\left(\left(D \cdot D\right) \cdot -0.125\right) \cdot \left(\frac{M\_m \cdot M\_m}{d} \cdot \frac{\sqrt{\frac{h}{\ell}}}{\left|\ell\right|}\right)\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+282}:\\
\;\;\;\;\left(1 \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{d \cdot d}}{\sqrt{\ell \cdot h}} \cdot 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)))) < 0.0Initial program 79.4%
Taylor expanded in d around inf
Applied rewrites8.0%
Taylor expanded in d around 0
*-commutativeN/A
associate-/l*N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-pow.f6437.7
Applied rewrites37.7%
Applied rewrites41.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.00000000000000013e282Initial program 99.4%
Taylor expanded in d around inf
Applied rewrites98.7%
Applied rewrites98.7%
if 4.00000000000000013e282 < (*.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 17.9%
Taylor expanded in d around inf
Applied rewrites26.7%
lift-/.f64N/A
metadata-eval26.7
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
clear-numN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f6428.0
Applied rewrites28.0%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
metadata-evalN/A
unpow1/2N/A
lift-/.f64N/A
metadata-evalN/A
lift-sqrt.f64N/A
sqrt-divN/A
lift-/.f64N/A
clear-numN/A
sqrt-unprodN/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f6437.7
Applied rewrites37.7%
Final simplification58.1%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l))))
(t_1 (* (/ D d) M_m))
(t_2 (pow (/ d h) (pow 2.0 -1.0))))
(if (<= (* (* t_2 (pow (/ d l) (pow 2.0 -1.0))) t_0) 4e+282)
(* (* t_2 (sqrt (/ d l))) t_0)
(* (fma t_1 (* t_1 (* -0.125 h)) l) (/ (/ (fabs d) (sqrt (* l h))) l)))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = 1.0 - ((pow(2.0, -1.0) * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l));
double t_1 = (D / d) * M_m;
double t_2 = pow((d / h), pow(2.0, -1.0));
double tmp;
if (((t_2 * pow((d / l), pow(2.0, -1.0))) * t_0) <= 4e+282) {
tmp = (t_2 * sqrt((d / l))) * t_0;
} else {
tmp = fma(t_1, (t_1 * (-0.125 * h)), l) * ((fabs(d) / sqrt((l * h))) / l);
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l))) t_1 = Float64(Float64(D / d) * M_m) t_2 = Float64(d / h) ^ (2.0 ^ -1.0) tmp = 0.0 if (Float64(Float64(t_2 * (Float64(d / l) ^ (2.0 ^ -1.0))) * t_0) <= 4e+282) tmp = Float64(Float64(t_2 * sqrt(Float64(d / l))) * t_0); else tmp = Float64(fma(t_1, Float64(t_1 * Float64(-0.125 * h)), l) * Float64(Float64(abs(d) / sqrt(Float64(l * h))) / l)); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(D / d), $MachinePrecision] * M$95$m), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(t$95$2 * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], 4e+282], N[(N[(t$95$2 * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(t$95$1 * N[(t$95$1 * N[(-0.125 * h), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision] * N[(N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := 1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\\
t_1 := \frac{D}{d} \cdot M\_m\\
t_2 := {\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)}\\
\mathbf{if}\;\left(t\_2 \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot t\_0 \leq 4 \cdot 10^{+282}:\\
\;\;\;\;\left(t\_2 \cdot \sqrt{\frac{d}{\ell}}\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, t\_1 \cdot \left(-0.125 \cdot h\right), \ell\right) \cdot \frac{\frac{\left|d\right|}{\sqrt{\ell \cdot h}}}{\ell}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 4.00000000000000013e282Initial program 88.1%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6488.1
Applied rewrites88.1%
if 4.00000000000000013e282 < (*.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 17.9%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites31.5%
Applied rewrites5.5%
Applied rewrites30.7%
Applied rewrites73.8%
Final simplification83.9%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (pow (/ d h) (pow 2.0 -1.0))) (t_1 (* (/ D d) M_m)))
(if (<=
(*
(* t_0 (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l))))
4e+282)
(*
(* t_0 (sqrt (/ d l)))
(fma (/ (* -0.5 (pow (* (/ (/ d D) M_m) 2.0) -2.0)) l) h 1.0))
(* (fma t_1 (* t_1 (* -0.125 h)) l) (/ (/ (fabs d) (sqrt (* l h))) l)))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = pow((d / h), pow(2.0, -1.0));
double t_1 = (D / d) * M_m;
double tmp;
if (((t_0 * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)))) <= 4e+282) {
tmp = (t_0 * sqrt((d / l))) * fma(((-0.5 * pow((((d / D) / M_m) * 2.0), -2.0)) / l), h, 1.0);
} else {
tmp = fma(t_1, (t_1 * (-0.125 * h)), l) * ((fabs(d) / sqrt((l * h))) / l);
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(d / h) ^ (2.0 ^ -1.0) t_1 = Float64(Float64(D / d) * M_m) tmp = 0.0 if (Float64(Float64(t_0 * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= 4e+282) tmp = Float64(Float64(t_0 * sqrt(Float64(d / l))) * fma(Float64(Float64(-0.5 * (Float64(Float64(Float64(d / D) / M_m) * 2.0) ^ -2.0)) / l), h, 1.0)); else tmp = Float64(fma(t_1, Float64(t_1 * Float64(-0.125 * h)), l) * Float64(Float64(abs(d) / sqrt(Float64(l * h))) / l)); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(D / d), $MachinePrecision] * M$95$m), $MachinePrecision]}, If[LessEqual[N[(N[(t$95$0 * 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), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4e+282], N[(N[(t$95$0 * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(-0.5 * N[Power[N[(N[(N[(d / D), $MachinePrecision] / M$95$m), $MachinePrecision] * 2.0), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * h + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 * N[(t$95$1 * N[(-0.125 * h), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision] * N[(N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)}\\
t_1 := \frac{D}{d} \cdot M\_m\\
\mathbf{if}\;\left(t\_0 \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq 4 \cdot 10^{+282}:\\
\;\;\;\;\left(t\_0 \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left(\frac{-0.5 \cdot {\left(\frac{\frac{d}{D}}{M\_m} \cdot 2\right)}^{-2}}{\ell}, h, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, t\_1 \cdot \left(-0.125 \cdot h\right), \ell\right) \cdot \frac{\frac{\left|d\right|}{\sqrt{\ell \cdot h}}}{\ell}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 4.00000000000000013e282Initial program 88.1%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites87.5%
lift-/.f64N/A
metadata-eval87.5
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6487.5
Applied rewrites87.5%
if 4.00000000000000013e282 < (*.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 17.9%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites31.5%
Applied rewrites5.5%
Applied rewrites30.7%
Applied rewrites73.8%
Final simplification83.5%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (pow (/ d l) (pow 2.0 -1.0)))
(t_1 (fma (/ (* -0.5 (pow (* (/ (/ d D) M_m) 2.0) -2.0)) l) h 1.0)))
(if (<= d -5.8e-168)
(* (* (/ (sqrt (- d)) (sqrt (- h))) t_0) t_1)
(if (<= d 5.9e-114)
(/
(* (sqrt (/ h l)) (fma (* -0.125 (/ (pow (* D M_m) 2.0) d)) (/ h l) d))
h)
(* (* (/ (sqrt d) (sqrt h)) t_0) t_1)))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = pow((d / l), pow(2.0, -1.0));
double t_1 = fma(((-0.5 * pow((((d / D) / M_m) * 2.0), -2.0)) / l), h, 1.0);
double tmp;
if (d <= -5.8e-168) {
tmp = ((sqrt(-d) / sqrt(-h)) * t_0) * t_1;
} else if (d <= 5.9e-114) {
tmp = (sqrt((h / l)) * fma((-0.125 * (pow((D * M_m), 2.0) / d)), (h / l), d)) / h;
} else {
tmp = ((sqrt(d) / sqrt(h)) * t_0) * t_1;
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(d / l) ^ (2.0 ^ -1.0) t_1 = fma(Float64(Float64(-0.5 * (Float64(Float64(Float64(d / D) / M_m) * 2.0) ^ -2.0)) / l), h, 1.0) tmp = 0.0 if (d <= -5.8e-168) tmp = Float64(Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * t_0) * t_1); elseif (d <= 5.9e-114) tmp = Float64(Float64(sqrt(Float64(h / l)) * fma(Float64(-0.125 * Float64((Float64(D * M_m) ^ 2.0) / d)), Float64(h / l), d)) / h); else tmp = Float64(Float64(Float64(sqrt(d) / sqrt(h)) * t_0) * t_1); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(-0.5 * N[Power[N[(N[(N[(d / D), $MachinePrecision] / M$95$m), $MachinePrecision] * 2.0), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * h + 1.0), $MachinePrecision]}, If[LessEqual[d, -5.8e-168], N[(N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[d, 5.9e-114], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * N[(N[(-0.125 * N[(N[Power[N[(D * M$95$m), $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\\
t_1 := \mathsf{fma}\left(\frac{-0.5 \cdot {\left(\frac{\frac{d}{D}}{M\_m} \cdot 2\right)}^{-2}}{\ell}, h, 1\right)\\
\mathbf{if}\;d \leq -5.8 \cdot 10^{-168}:\\
\;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot t\_0\right) \cdot t\_1\\
\mathbf{elif}\;d \leq 5.9 \cdot 10^{-114}:\\
\;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \mathsf{fma}\left(-0.125 \cdot \frac{{\left(D \cdot M\_m\right)}^{2}}{d}, \frac{h}{\ell}, d\right)}{h}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot t\_0\right) \cdot t\_1\\
\end{array}
\end{array}
if d < -5.7999999999999997e-168Initial program 69.2%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites77.3%
lift-/.f64N/A
metadata-eval77.3
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f6488.7
Applied rewrites88.7%
if -5.7999999999999997e-168 < d < 5.9000000000000001e-114Initial program 59.6%
Taylor expanded in d around inf
Applied rewrites27.8%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites35.2%
Applied rewrites61.1%
Applied rewrites82.2%
if 5.9000000000000001e-114 < d Initial program 72.1%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites79.4%
lift-/.f64N/A
metadata-eval79.4
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
sqrt-divN/A
pow1/2N/A
lower-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lower-sqrt.f6494.6
Applied rewrites94.6%
Final simplification89.1%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (fma (/ (* -0.5 (pow (* (/ (/ d D) M_m) 2.0) -2.0)) l) h 1.0)))
(if (<= d -9.6e-54)
(* (* (pow (/ d h) (pow 2.0 -1.0)) (sqrt (/ d l))) t_0)
(if (<= d 5.9e-114)
(/
(* (sqrt (/ h l)) (fma (* -0.125 (/ (pow (* D M_m) 2.0) d)) (/ h l) d))
h)
(* (* (/ (sqrt d) (sqrt h)) (pow (/ d l) (pow 2.0 -1.0))) t_0)))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = fma(((-0.5 * pow((((d / D) / M_m) * 2.0), -2.0)) / l), h, 1.0);
double tmp;
if (d <= -9.6e-54) {
tmp = (pow((d / h), pow(2.0, -1.0)) * sqrt((d / l))) * t_0;
} else if (d <= 5.9e-114) {
tmp = (sqrt((h / l)) * fma((-0.125 * (pow((D * M_m), 2.0) / d)), (h / l), d)) / h;
} else {
tmp = ((sqrt(d) / sqrt(h)) * pow((d / l), pow(2.0, -1.0))) * t_0;
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = fma(Float64(Float64(-0.5 * (Float64(Float64(Float64(d / D) / M_m) * 2.0) ^ -2.0)) / l), h, 1.0) tmp = 0.0 if (d <= -9.6e-54) tmp = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * sqrt(Float64(d / l))) * t_0); elseif (d <= 5.9e-114) tmp = Float64(Float64(sqrt(Float64(h / l)) * fma(Float64(-0.125 * Float64((Float64(D * M_m) ^ 2.0) / d)), Float64(h / l), d)) / h); else tmp = Float64(Float64(Float64(sqrt(d) / sqrt(h)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * t_0); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(N[(-0.5 * N[Power[N[(N[(N[(d / D), $MachinePrecision] / M$95$m), $MachinePrecision] * 2.0), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * h + 1.0), $MachinePrecision]}, If[LessEqual[d, -9.6e-54], N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[d, 5.9e-114], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * N[(N[(-0.125 * N[(N[Power[N[(D * M$95$m), $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{-0.5 \cdot {\left(\frac{\frac{d}{D}}{M\_m} \cdot 2\right)}^{-2}}{\ell}, h, 1\right)\\
\mathbf{if}\;d \leq -9.6 \cdot 10^{-54}:\\
\;\;\;\;\left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot t\_0\\
\mathbf{elif}\;d \leq 5.9 \cdot 10^{-114}:\\
\;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \mathsf{fma}\left(-0.125 \cdot \frac{{\left(D \cdot M\_m\right)}^{2}}{d}, \frac{h}{\ell}, d\right)}{h}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot t\_0\\
\end{array}
\end{array}
if d < -9.60000000000000053e-54Initial program 76.0%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites83.8%
lift-/.f64N/A
metadata-eval83.8
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6483.8
Applied rewrites83.8%
if -9.60000000000000053e-54 < d < 5.9000000000000001e-114Initial program 56.9%
Taylor expanded in d around inf
Applied rewrites27.7%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites34.2%
Applied rewrites58.9%
Applied rewrites78.7%
if 5.9000000000000001e-114 < d Initial program 72.1%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites79.4%
lift-/.f64N/A
metadata-eval79.4
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
sqrt-divN/A
pow1/2N/A
lower-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lower-sqrt.f6494.6
Applied rewrites94.6%
Final simplification86.1%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<= l -3e-136)
(* (- d) (sqrt (pow (* l h) -1.0)))
(if (<= l -2.55e-306)
(* (/ (sqrt (* (/ (- d) h) d)) (sqrt (- l))) 1.0)
(if (<= l 5e-236)
(/ (* (- d) (sqrt (/ h l))) h)
(/ d (* (sqrt l) (sqrt h)))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= -3e-136) {
tmp = -d * sqrt(pow((l * h), -1.0));
} else if (l <= -2.55e-306) {
tmp = (sqrt(((-d / h) * d)) / sqrt(-l)) * 1.0;
} else if (l <= 5e-236) {
tmp = (-d * sqrt((h / l))) / h;
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
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_1
real(8) :: tmp
if (l <= (-3d-136)) then
tmp = -d * sqrt(((l * h) ** (-1.0d0)))
else if (l <= (-2.55d-306)) then
tmp = (sqrt(((-d / h) * d)) / sqrt(-l)) * 1.0d0
else if (l <= 5d-236) then
tmp = (-d * sqrt((h / l))) / h
else
tmp = d / (sqrt(l) * sqrt(h))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= -3e-136) {
tmp = -d * Math.sqrt(Math.pow((l * h), -1.0));
} else if (l <= -2.55e-306) {
tmp = (Math.sqrt(((-d / h) * d)) / Math.sqrt(-l)) * 1.0;
} else if (l <= 5e-236) {
tmp = (-d * Math.sqrt((h / l))) / h;
} else {
tmp = d / (Math.sqrt(l) * Math.sqrt(h));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if l <= -3e-136: tmp = -d * math.sqrt(math.pow((l * h), -1.0)) elif l <= -2.55e-306: tmp = (math.sqrt(((-d / h) * d)) / math.sqrt(-l)) * 1.0 elif l <= 5e-236: tmp = (-d * math.sqrt((h / l))) / h else: tmp = d / (math.sqrt(l) * math.sqrt(h)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (l <= -3e-136) tmp = Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0))); elseif (l <= -2.55e-306) tmp = Float64(Float64(sqrt(Float64(Float64(Float64(-d) / h) * d)) / sqrt(Float64(-l))) * 1.0); elseif (l <= 5e-236) tmp = Float64(Float64(Float64(-d) * sqrt(Float64(h / l))) / h); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (l <= -3e-136)
tmp = -d * sqrt(((l * h) ^ -1.0));
elseif (l <= -2.55e-306)
tmp = (sqrt(((-d / h) * d)) / sqrt(-l)) * 1.0;
elseif (l <= 5e-236)
tmp = (-d * sqrt((h / l))) / h;
else
tmp = d / (sqrt(l) * sqrt(h));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[l, -3e-136], N[((-d) * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -2.55e-306], N[(N[(N[Sqrt[N[(N[((-d) / h), $MachinePrecision] * d), $MachinePrecision]], $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[l, 5e-236], N[(N[((-d) * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3 \cdot 10^{-136}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\\
\mathbf{elif}\;\ell \leq -2.55 \cdot 10^{-306}:\\
\;\;\;\;\frac{\sqrt{\frac{-d}{h} \cdot d}}{\sqrt{-\ell}} \cdot 1\\
\mathbf{elif}\;\ell \leq 5 \cdot 10^{-236}:\\
\;\;\;\;\frac{\left(-d\right) \cdot \sqrt{\frac{h}{\ell}}}{h}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < -2.9999999999999998e-136Initial program 65.4%
Taylor expanded in d around inf
Applied rewrites46.3%
Taylor expanded in l around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6452.6
Applied rewrites52.6%
if -2.9999999999999998e-136 < l < -2.54999999999999986e-306Initial program 66.4%
Taylor expanded in d around inf
Applied rewrites40.8%
lift-/.f64N/A
metadata-eval40.8
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
clear-numN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f6443.5
Applied rewrites43.5%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
metadata-evalN/A
unpow1/2N/A
lift-/.f64N/A
metadata-evalN/A
lift-sqrt.f64N/A
sqrt-divN/A
lift-/.f64N/A
clear-numN/A
sqrt-unprodN/A
frac-2negN/A
associate-*r/N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-neg.f6446.2
Applied rewrites46.2%
if -2.54999999999999986e-306 < l < 4.9999999999999998e-236Initial program 93.2%
Taylor expanded in d around inf
Applied rewrites13.6%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites13.2%
Taylor expanded in l around -inf
Applied rewrites86.7%
if 4.9999999999999998e-236 < l Initial program 66.1%
Taylor expanded in d around inf
Applied rewrites42.2%
Taylor expanded in d around -inf
mul-1-negN/A
distribute-lft-neg-inN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6449.4
Applied rewrites49.4%
Applied rewrites49.9%
Applied rewrites56.1%
Final simplification55.6%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<= l -2.5e+143)
(* (- d) (sqrt (pow (* l h) -1.0)))
(if (<= l -1.38e-278)
(* (* 1.0 (sqrt (/ d l))) (sqrt (/ d h)))
(if (<= l 5e-236)
(/ (* (- d) (sqrt (/ h l))) h)
(/ d (* (sqrt l) (sqrt h)))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= -2.5e+143) {
tmp = -d * sqrt(pow((l * h), -1.0));
} else if (l <= -1.38e-278) {
tmp = (1.0 * sqrt((d / l))) * sqrt((d / h));
} else if (l <= 5e-236) {
tmp = (-d * sqrt((h / l))) / h;
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
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_1
real(8) :: tmp
if (l <= (-2.5d+143)) then
tmp = -d * sqrt(((l * h) ** (-1.0d0)))
else if (l <= (-1.38d-278)) then
tmp = (1.0d0 * sqrt((d / l))) * sqrt((d / h))
else if (l <= 5d-236) then
tmp = (-d * sqrt((h / l))) / h
else
tmp = d / (sqrt(l) * sqrt(h))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= -2.5e+143) {
tmp = -d * Math.sqrt(Math.pow((l * h), -1.0));
} else if (l <= -1.38e-278) {
tmp = (1.0 * Math.sqrt((d / l))) * Math.sqrt((d / h));
} else if (l <= 5e-236) {
tmp = (-d * Math.sqrt((h / l))) / h;
} else {
tmp = d / (Math.sqrt(l) * Math.sqrt(h));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if l <= -2.5e+143: tmp = -d * math.sqrt(math.pow((l * h), -1.0)) elif l <= -1.38e-278: tmp = (1.0 * math.sqrt((d / l))) * math.sqrt((d / h)) elif l <= 5e-236: tmp = (-d * math.sqrt((h / l))) / h else: tmp = d / (math.sqrt(l) * math.sqrt(h)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (l <= -2.5e+143) tmp = Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0))); elseif (l <= -1.38e-278) tmp = Float64(Float64(1.0 * sqrt(Float64(d / l))) * sqrt(Float64(d / h))); elseif (l <= 5e-236) tmp = Float64(Float64(Float64(-d) * sqrt(Float64(h / l))) / h); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (l <= -2.5e+143)
tmp = -d * sqrt(((l * h) ^ -1.0));
elseif (l <= -1.38e-278)
tmp = (1.0 * sqrt((d / l))) * sqrt((d / h));
elseif (l <= 5e-236)
tmp = (-d * sqrt((h / l))) / h;
else
tmp = d / (sqrt(l) * sqrt(h));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[l, -2.5e+143], N[((-d) * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -1.38e-278], N[(N[(1.0 * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5e-236], N[(N[((-d) * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.5 \cdot 10^{+143}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\\
\mathbf{elif}\;\ell \leq -1.38 \cdot 10^{-278}:\\
\;\;\;\;\left(1 \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \sqrt{\frac{d}{h}}\\
\mathbf{elif}\;\ell \leq 5 \cdot 10^{-236}:\\
\;\;\;\;\frac{\left(-d\right) \cdot \sqrt{\frac{h}{\ell}}}{h}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < -2.50000000000000006e143Initial program 51.7%
Taylor expanded in d around inf
Applied rewrites41.1%
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-*.f6461.1
Applied rewrites61.1%
if -2.50000000000000006e143 < l < -1.38000000000000005e-278Initial program 72.3%
Taylor expanded in d around inf
Applied rewrites48.0%
Applied rewrites48.0%
if -1.38000000000000005e-278 < l < 4.9999999999999998e-236Initial program 81.1%
Taylor expanded in d around inf
Applied rewrites14.9%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites9.5%
Taylor expanded in l around -inf
Applied rewrites67.5%
if 4.9999999999999998e-236 < l Initial program 66.1%
Taylor expanded in d around inf
Applied rewrites42.2%
Taylor expanded in d around -inf
mul-1-negN/A
distribute-lft-neg-inN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6449.4
Applied rewrites49.4%
Applied rewrites49.9%
Applied rewrites56.1%
Final simplification55.3%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<= l -2.75e-306)
(* (- d) (sqrt (pow (* l h) -1.0)))
(if (<= l 5e-236)
(/ (* (- d) (sqrt (/ h l))) h)
(/ d (* (sqrt l) (sqrt h))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= -2.75e-306) {
tmp = -d * sqrt(pow((l * h), -1.0));
} else if (l <= 5e-236) {
tmp = (-d * sqrt((h / l))) / h;
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
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_1
real(8) :: tmp
if (l <= (-2.75d-306)) then
tmp = -d * sqrt(((l * h) ** (-1.0d0)))
else if (l <= 5d-236) then
tmp = (-d * sqrt((h / l))) / h
else
tmp = d / (sqrt(l) * sqrt(h))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= -2.75e-306) {
tmp = -d * Math.sqrt(Math.pow((l * h), -1.0));
} else if (l <= 5e-236) {
tmp = (-d * Math.sqrt((h / l))) / h;
} else {
tmp = d / (Math.sqrt(l) * Math.sqrt(h));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if l <= -2.75e-306: tmp = -d * math.sqrt(math.pow((l * h), -1.0)) elif l <= 5e-236: tmp = (-d * math.sqrt((h / l))) / h else: tmp = d / (math.sqrt(l) * math.sqrt(h)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (l <= -2.75e-306) tmp = Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0))); elseif (l <= 5e-236) tmp = Float64(Float64(Float64(-d) * sqrt(Float64(h / l))) / h); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (l <= -2.75e-306)
tmp = -d * sqrt(((l * h) ^ -1.0));
elseif (l <= 5e-236)
tmp = (-d * sqrt((h / l))) / h;
else
tmp = d / (sqrt(l) * sqrt(h));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[l, -2.75e-306], N[((-d) * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5e-236], N[(N[((-d) * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.75 \cdot 10^{-306}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\\
\mathbf{elif}\;\ell \leq 5 \cdot 10^{-236}:\\
\;\;\;\;\frac{\left(-d\right) \cdot \sqrt{\frac{h}{\ell}}}{h}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < -2.74999999999999996e-306Initial program 65.7%
Taylor expanded in d around inf
Applied rewrites44.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-*.f6445.2
Applied rewrites45.2%
if -2.74999999999999996e-306 < l < 4.9999999999999998e-236Initial program 93.2%
Taylor expanded in d around inf
Applied rewrites13.6%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites13.2%
Taylor expanded in l around -inf
Applied rewrites86.7%
if 4.9999999999999998e-236 < l Initial program 66.1%
Taylor expanded in d around inf
Applied rewrites42.2%
Taylor expanded in d around -inf
mul-1-negN/A
distribute-lft-neg-inN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6449.4
Applied rewrites49.4%
Applied rewrites49.9%
Applied rewrites56.1%
Final simplification53.3%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (if (<= h 7.2e-294) (* (- d) (sqrt (pow (* l h) -1.0))) (/ d (* (sqrt l) (sqrt h)))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (h <= 7.2e-294) {
tmp = -d * sqrt(pow((l * h), -1.0));
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
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_1
real(8) :: tmp
if (h <= 7.2d-294) then
tmp = -d * sqrt(((l * h) ** (-1.0d0)))
else
tmp = d / (sqrt(l) * sqrt(h))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (h <= 7.2e-294) {
tmp = -d * Math.sqrt(Math.pow((l * h), -1.0));
} else {
tmp = d / (Math.sqrt(l) * Math.sqrt(h));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if h <= 7.2e-294: tmp = -d * math.sqrt(math.pow((l * h), -1.0)) else: tmp = d / (math.sqrt(l) * math.sqrt(h)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (h <= 7.2e-294) tmp = Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0))); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (h <= 7.2e-294)
tmp = -d * sqrt(((l * h) ^ -1.0));
else
tmp = d / (sqrt(l) * sqrt(h));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[h, 7.2e-294], N[((-d) * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq 7.2 \cdot 10^{-294}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if h < 7.2000000000000003e-294Initial program 63.6%
Taylor expanded in d around inf
Applied rewrites41.9%
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-*.f6445.2
Applied rewrites45.2%
if 7.2000000000000003e-294 < h Initial program 70.8%
Taylor expanded in d around inf
Applied rewrites41.1%
Taylor expanded in d around -inf
mul-1-negN/A
distribute-lft-neg-inN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6446.6
Applied rewrites46.6%
Applied rewrites47.1%
Applied rewrites53.7%
Final simplification49.9%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (if (<= h 7.5e-294) (* (- d) (sqrt (pow (* l h) -1.0))) (/ d (sqrt (* l h)))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (h <= 7.5e-294) {
tmp = -d * sqrt(pow((l * h), -1.0));
} else {
tmp = d / sqrt((l * h));
}
return tmp;
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
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_1
real(8) :: tmp
if (h <= 7.5d-294) then
tmp = -d * sqrt(((l * h) ** (-1.0d0)))
else
tmp = d / sqrt((l * h))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (h <= 7.5e-294) {
tmp = -d * Math.sqrt(Math.pow((l * h), -1.0));
} else {
tmp = d / Math.sqrt((l * h));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if h <= 7.5e-294: tmp = -d * math.sqrt(math.pow((l * h), -1.0)) else: tmp = d / math.sqrt((l * h)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (h <= 7.5e-294) tmp = Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0))); else tmp = Float64(d / sqrt(Float64(l * h))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (h <= 7.5e-294)
tmp = -d * sqrt(((l * h) ^ -1.0));
else
tmp = d / sqrt((l * h));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[h, 7.5e-294], N[((-d) * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq 7.5 \cdot 10^{-294}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\
\end{array}
\end{array}
if h < 7.5000000000000004e-294Initial program 63.6%
Taylor expanded in d around inf
Applied rewrites41.9%
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-*.f6445.2
Applied rewrites45.2%
if 7.5000000000000004e-294 < h Initial program 70.8%
Taylor expanded in d around inf
Applied rewrites41.1%
Taylor expanded in d around -inf
mul-1-negN/A
distribute-lft-neg-inN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6446.6
Applied rewrites46.6%
Applied rewrites47.1%
Final simplification46.2%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (/ d (sqrt (* l h))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
return d / sqrt((l * h));
}
M_m = abs(m)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_1)
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_1
code = d / sqrt((l * h))
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
return d / Math.sqrt((l * h));
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): return d / math.sqrt((l * h))
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) return Float64(d / sqrt(Float64(l * h))) end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp = code(d, h, l, M_m, D)
tmp = d / sqrt((l * h));
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\frac{d}{\sqrt{\ell \cdot h}}
\end{array}
Initial program 67.5%
Taylor expanded in d around inf
Applied rewrites41.5%
Taylor expanded in d around -inf
mul-1-negN/A
distribute-lft-neg-inN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6430.5
Applied rewrites30.5%
Applied rewrites30.8%
herbie shell --seed 2024312
(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)))))