
(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 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (- l)))
(t_1 (* M_m (/ D_m d)))
(t_2 (sqrt (- d)))
(t_3 (/ t_2 (sqrt (- h))))
(t_4
(-
1.0
(/ (* (/ M_m d) (* 0.25 D_m)) (* l (* (pow h -1.0) (/ 2.0 t_1)))))))
(if (<= h -2.1e+154)
(/
(*
(* (fma (* (/ (* (* D_m 0.25) M_m) (* (- l) d)) (* t_1 0.5)) h 1.0) t_3)
t_2)
t_0)
(if (<= h -1.25e-141)
(/
(*
(*
(fma
(* (/ (/ (* M_m (* 0.25 D_m)) d) (- l)) (* (* D_m (/ M_m d)) 0.5))
h
1.0)
(sqrt (/ d h)))
t_2)
t_0)
(if (<= h -2e-310)
(* (* t_3 (pow (sqrt (/ l d)) -1.0)) t_4)
(if (<= h 6.4e+140)
(* (* (sqrt (pow (* l h) -1.0)) d) t_4)
(*
(*
(fma
(* (* 0.5 (* (/ D_m d) M_m)) h)
(* (/ M_m l) (* -0.25 (/ D_m d)))
1.0)
(/ (sqrt d) (sqrt h)))
(sqrt (/ d l)))))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = sqrt(-l);
double t_1 = M_m * (D_m / d);
double t_2 = sqrt(-d);
double t_3 = t_2 / sqrt(-h);
double t_4 = 1.0 - (((M_m / d) * (0.25 * D_m)) / (l * (pow(h, -1.0) * (2.0 / t_1))));
double tmp;
if (h <= -2.1e+154) {
tmp = ((fma(((((D_m * 0.25) * M_m) / (-l * d)) * (t_1 * 0.5)), h, 1.0) * t_3) * t_2) / t_0;
} else if (h <= -1.25e-141) {
tmp = ((fma(((((M_m * (0.25 * D_m)) / d) / -l) * ((D_m * (M_m / d)) * 0.5)), h, 1.0) * sqrt((d / h))) * t_2) / t_0;
} else if (h <= -2e-310) {
tmp = (t_3 * pow(sqrt((l / d)), -1.0)) * t_4;
} else if (h <= 6.4e+140) {
tmp = (sqrt(pow((l * h), -1.0)) * d) * t_4;
} else {
tmp = (fma(((0.5 * ((D_m / d) * M_m)) * h), ((M_m / l) * (-0.25 * (D_m / d))), 1.0) * (sqrt(d) / sqrt(h))) * sqrt((d / l));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = sqrt(Float64(-l)) t_1 = Float64(M_m * Float64(D_m / d)) t_2 = sqrt(Float64(-d)) t_3 = Float64(t_2 / sqrt(Float64(-h))) t_4 = Float64(1.0 - Float64(Float64(Float64(M_m / d) * Float64(0.25 * D_m)) / Float64(l * Float64((h ^ -1.0) * Float64(2.0 / t_1))))) tmp = 0.0 if (h <= -2.1e+154) tmp = Float64(Float64(Float64(fma(Float64(Float64(Float64(Float64(D_m * 0.25) * M_m) / Float64(Float64(-l) * d)) * Float64(t_1 * 0.5)), h, 1.0) * t_3) * t_2) / t_0); elseif (h <= -1.25e-141) tmp = Float64(Float64(Float64(fma(Float64(Float64(Float64(Float64(M_m * Float64(0.25 * D_m)) / d) / Float64(-l)) * Float64(Float64(D_m * Float64(M_m / d)) * 0.5)), h, 1.0) * sqrt(Float64(d / h))) * t_2) / t_0); elseif (h <= -2e-310) tmp = Float64(Float64(t_3 * (sqrt(Float64(l / d)) ^ -1.0)) * t_4); elseif (h <= 6.4e+140) tmp = Float64(Float64(sqrt((Float64(l * h) ^ -1.0)) * d) * t_4); else tmp = Float64(Float64(fma(Float64(Float64(0.5 * Float64(Float64(D_m / d) * M_m)) * h), Float64(Float64(M_m / l) * Float64(-0.25 * Float64(D_m / d))), 1.0) * Float64(sqrt(d) / sqrt(h))) * sqrt(Float64(d / l))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[(-l)], $MachinePrecision]}, Block[{t$95$1 = N[(M$95$m * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[(-d)], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(1.0 - N[(N[(N[(M$95$m / d), $MachinePrecision] * N[(0.25 * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(l * N[(N[Power[h, -1.0], $MachinePrecision] * N[(2.0 / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -2.1e+154], N[(N[(N[(N[(N[(N[(N[(N[(D$95$m * 0.25), $MachinePrecision] * M$95$m), $MachinePrecision] / N[((-l) * d), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * 0.5), $MachinePrecision]), $MachinePrecision] * h + 1.0), $MachinePrecision] * t$95$3), $MachinePrecision] * t$95$2), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[h, -1.25e-141], N[(N[(N[(N[(N[(N[(N[(N[(M$95$m * N[(0.25 * D$95$m), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] / (-l)), $MachinePrecision] * N[(N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] * h + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[h, -2e-310], N[(N[(t$95$3 * N[Power[N[Sqrt[N[(l / d), $MachinePrecision]], $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision] * t$95$4), $MachinePrecision], If[LessEqual[h, 6.4e+140], N[(N[(N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] * t$95$4), $MachinePrecision], N[(N[(N[(N[(N[(0.5 * N[(N[(D$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] * N[(N[(M$95$m / l), $MachinePrecision] * N[(-0.25 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{-\ell}\\
t_1 := M\_m \cdot \frac{D\_m}{d}\\
t_2 := \sqrt{-d}\\
t_3 := \frac{t\_2}{\sqrt{-h}}\\
t_4 := 1 - \frac{\frac{M\_m}{d} \cdot \left(0.25 \cdot D\_m\right)}{\ell \cdot \left({h}^{-1} \cdot \frac{2}{t\_1}\right)}\\
\mathbf{if}\;h \leq -2.1 \cdot 10^{+154}:\\
\;\;\;\;\frac{\left(\mathsf{fma}\left(\frac{\left(D\_m \cdot 0.25\right) \cdot M\_m}{\left(-\ell\right) \cdot d} \cdot \left(t\_1 \cdot 0.5\right), h, 1\right) \cdot t\_3\right) \cdot t\_2}{t\_0}\\
\mathbf{elif}\;h \leq -1.25 \cdot 10^{-141}:\\
\;\;\;\;\frac{\left(\mathsf{fma}\left(\frac{\frac{M\_m \cdot \left(0.25 \cdot D\_m\right)}{d}}{-\ell} \cdot \left(\left(D\_m \cdot \frac{M\_m}{d}\right) \cdot 0.5\right), h, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot t\_2}{t\_0}\\
\mathbf{elif}\;h \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\left(t\_3 \cdot {\left(\sqrt{\frac{\ell}{d}}\right)}^{-1}\right) \cdot t\_4\\
\mathbf{elif}\;h \leq 6.4 \cdot 10^{+140}:\\
\;\;\;\;\left(\sqrt{{\left(\ell \cdot h\right)}^{-1}} \cdot d\right) \cdot t\_4\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\left(0.5 \cdot \left(\frac{D\_m}{d} \cdot M\_m\right)\right) \cdot h, \frac{M\_m}{\ell} \cdot \left(-0.25 \cdot \frac{D\_m}{d}\right), 1\right) \cdot \frac{\sqrt{d}}{\sqrt{h}}\right) \cdot \sqrt{\frac{d}{\ell}}\\
\end{array}
\end{array}
if h < -2.09999999999999994e154Initial program 49.2%
Applied rewrites49.1%
Applied rewrites47.1%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
neg-mul-1N/A
associate-*r*N/A
*-commutativeN/A
neg-mul-1N/A
lift-neg.f64N/A
lower-*.f6446.8
Applied rewrites46.8%
lift-sqrt.f64N/A
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f6480.0
Applied rewrites80.0%
if -2.09999999999999994e154 < h < -1.25e-141Initial program 69.9%
Applied rewrites79.6%
Applied rewrites86.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
lift-/.f64N/A
lower-*.f6489.7
Applied rewrites89.7%
if -1.25e-141 < h < -1.999999999999994e-310Initial program 61.5%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lift-/.f64N/A
clear-numN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f6461.4
Applied rewrites61.4%
Applied rewrites65.1%
lift-/.f64N/A
lift-pow.f64N/A
metadata-evalN/A
pow1/2N/A
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
lift-neg.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lower-/.f6483.6
Applied rewrites83.6%
if -1.999999999999994e-310 < h < 6.40000000000000021e140Initial program 71.3%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lift-/.f64N/A
clear-numN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f6470.6
Applied rewrites70.6%
Applied rewrites73.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6489.4
Applied rewrites89.4%
if 6.40000000000000021e140 < h Initial program 67.5%
Applied rewrites0.0%
Applied rewrites0.0%
Applied rewrites78.6%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
pow1/2N/A
lower-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lower-sqrt.f6493.1
Applied rewrites93.1%
Final simplification88.1%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(*
(* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0))
(/ h l)))))
(t_1 (/ d (sqrt (* l h)))))
(if (<= t_0 -1e+278)
(*
(* (/ (* (* (* D_m D_m) h) -0.125) d) (/ (/ (* M_m M_m) l) d))
(sqrt (* (/ d l) (/ d h))))
(if (<= t_0 0.0)
(*
(fma
(* (* (* (* 0.5 M_m) (/ D_m d)) (* h (/ M_m l))) (/ D_m d))
-0.25
1.0)
t_1)
(if (<= t_0 5e+174)
(* (sqrt (/ d h)) (sqrt (/ d l)))
(if (<= t_0 INFINITY)
(/ (* (sqrt (/ h l)) d) h)
(*
(fma
(* -0.25 (/ D_m l))
(* (/ M_m d) (* (* h (* (/ D_m d) 0.5)) M_m))
1.0)
t_1)))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = d / sqrt((l * h));
double tmp;
if (t_0 <= -1e+278) {
tmp = (((((D_m * D_m) * h) * -0.125) / d) * (((M_m * M_m) / l) / d)) * sqrt(((d / l) * (d / h)));
} else if (t_0 <= 0.0) {
tmp = fma(((((0.5 * M_m) * (D_m / d)) * (h * (M_m / l))) * (D_m / d)), -0.25, 1.0) * t_1;
} else if (t_0 <= 5e+174) {
tmp = sqrt((d / h)) * sqrt((d / l));
} else if (t_0 <= ((double) INFINITY)) {
tmp = (sqrt((h / l)) * d) / h;
} else {
tmp = fma((-0.25 * (D_m / l)), ((M_m / d) * ((h * ((D_m / d) * 0.5)) * M_m)), 1.0) * t_1;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(d / sqrt(Float64(l * h))) tmp = 0.0 if (t_0 <= -1e+278) tmp = Float64(Float64(Float64(Float64(Float64(Float64(D_m * D_m) * h) * -0.125) / d) * Float64(Float64(Float64(M_m * M_m) / l) / d)) * sqrt(Float64(Float64(d / l) * Float64(d / h)))); elseif (t_0 <= 0.0) tmp = Float64(fma(Float64(Float64(Float64(Float64(0.5 * M_m) * Float64(D_m / d)) * Float64(h * Float64(M_m / l))) * Float64(D_m / d)), -0.25, 1.0) * t_1); elseif (t_0 <= 5e+174) tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))); elseif (t_0 <= Inf) tmp = Float64(Float64(sqrt(Float64(h / l)) * d) / h); else tmp = Float64(fma(Float64(-0.25 * Float64(D_m / l)), Float64(Float64(M_m / d) * Float64(Float64(h * Float64(Float64(D_m / d) * 0.5)) * M_m)), 1.0) * t_1); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+278], N[(N[(N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * h), $MachinePrecision] * -0.125), $MachinePrecision] / d), $MachinePrecision] * N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] / l), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(N[(N[(N[(N[(N[(0.5 * M$95$m), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision] * N[(h * N[(M$95$m / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision] * -0.25 + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[t$95$0, 5e+174], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[(-0.25 * N[(D$95$m / l), $MachinePrecision]), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * N[(N[(h * N[(N[(D$95$m / d), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+278}:\\
\;\;\;\;\left(\frac{\left(\left(D\_m \cdot D\_m\right) \cdot h\right) \cdot -0.125}{d} \cdot \frac{\frac{M\_m \cdot M\_m}{\ell}}{d}\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(\left(0.5 \cdot M\_m\right) \cdot \frac{D\_m}{d}\right) \cdot \left(h \cdot \frac{M\_m}{\ell}\right)\right) \cdot \frac{D\_m}{d}, -0.25, 1\right) \cdot t\_1\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+174}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot d}{h}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.25 \cdot \frac{D\_m}{\ell}, \frac{M\_m}{d} \cdot \left(\left(h \cdot \left(\frac{D\_m}{d} \cdot 0.5\right)\right) \cdot M\_m\right), 1\right) \cdot t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -9.99999999999999964e277Initial program 84.1%
Applied rewrites39.6%
Applied rewrites40.8%
Applied rewrites72.1%
Taylor expanded in d around 0
*-commutativeN/A
associate-*r*N/A
associate-*l/N/A
associate-*l*N/A
associate-*r/N/A
associate-*l/N/A
unpow2N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
Applied rewrites60.7%
if -9.99999999999999964e277 < (*.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 72.3%
Applied rewrites39.9%
Applied rewrites31.7%
Applied rewrites60.8%
Applied rewrites35.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.9999999999999997e174Initial program 99.0%
Applied rewrites42.1%
Applied rewrites40.9%
Applied rewrites97.8%
Taylor expanded in d around -inf
mul-1-negN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
mul-1-negN/A
remove-double-negN/A
lower-sqrt.f64N/A
lower-/.f6496.9
Applied rewrites96.9%
if 4.9999999999999997e174 < (*.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 57.2%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites41.3%
Taylor expanded in d around inf
Applied rewrites79.2%
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)))) Initial program 0.0%
Applied rewrites2.6%
Applied rewrites16.5%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
neg-mul-1N/A
associate-*r*N/A
*-commutativeN/A
neg-mul-1N/A
lift-neg.f64N/A
lower-*.f6416.2
Applied rewrites16.2%
Applied rewrites27.7%
Final simplification63.4%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (/ h l)))
(t_1 (/ (* t_0 d) h))
(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_m) (* 2.0 d)) 2.0))
(/ h l)))))
(t_3 (/ (* (- d) t_0) h)))
(if (<= t_2 -2e-190)
t_3
(if (<= t_2 5e-145)
t_1
(if (<= t_2 5e+147)
(* 1.0 (sqrt (* (/ d l) (/ d h))))
(if (<= t_2 INFINITY) t_1 t_3))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((h / l));
double t_1 = (t_0 * d) / h;
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_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_3 = (-d * t_0) / h;
double tmp;
if (t_2 <= -2e-190) {
tmp = t_3;
} else if (t_2 <= 5e-145) {
tmp = t_1;
} else if (t_2 <= 5e+147) {
tmp = 1.0 * sqrt(((d / l) * (d / h)));
} else if (t_2 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = t_3;
}
return tmp;
}
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = Math.sqrt((h / l));
double t_1 = (t_0 * d) / h;
double t_2 = (Math.pow((d / h), Math.pow(2.0, -1.0)) * Math.pow((d / l), Math.pow(2.0, -1.0))) * (1.0 - ((Math.pow(2.0, -1.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_3 = (-d * t_0) / h;
double tmp;
if (t_2 <= -2e-190) {
tmp = t_3;
} else if (t_2 <= 5e-145) {
tmp = t_1;
} else if (t_2 <= 5e+147) {
tmp = 1.0 * Math.sqrt(((d / l) * (d / h)));
} else if (t_2 <= Double.POSITIVE_INFINITY) {
tmp = t_1;
} else {
tmp = t_3;
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = math.sqrt((h / l)) t_1 = (t_0 * d) / h t_2 = (math.pow((d / h), math.pow(2.0, -1.0)) * math.pow((d / l), math.pow(2.0, -1.0))) * (1.0 - ((math.pow(2.0, -1.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l))) t_3 = (-d * t_0) / h tmp = 0 if t_2 <= -2e-190: tmp = t_3 elif t_2 <= 5e-145: tmp = t_1 elif t_2 <= 5e+147: tmp = 1.0 * math.sqrt(((d / l) * (d / h))) elif t_2 <= math.inf: tmp = t_1 else: tmp = t_3 return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = sqrt(Float64(h / l)) t_1 = Float64(Float64(t_0 * d) / h) 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_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_3 = Float64(Float64(Float64(-d) * t_0) / h) tmp = 0.0 if (t_2 <= -2e-190) tmp = t_3; elseif (t_2 <= 5e-145) tmp = t_1; elseif (t_2 <= 5e+147) tmp = Float64(1.0 * sqrt(Float64(Float64(d / l) * Float64(d / h)))); elseif (t_2 <= Inf) tmp = t_1; else tmp = t_3; end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = sqrt((h / l));
t_1 = (t_0 * d) / h;
t_2 = (((d / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
t_3 = (-d * t_0) / h;
tmp = 0.0;
if (t_2 <= -2e-190)
tmp = t_3;
elseif (t_2 <= 5e-145)
tmp = t_1;
elseif (t_2 <= 5e+147)
tmp = 1.0 * sqrt(((d / l) * (d / h)));
elseif (t_2 <= Inf)
tmp = t_1;
else
tmp = t_3;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * d), $MachinePrecision] / h), $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$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[((-d) * t$95$0), $MachinePrecision] / h), $MachinePrecision]}, If[LessEqual[t$95$2, -2e-190], t$95$3, If[LessEqual[t$95$2, 5e-145], t$95$1, If[LessEqual[t$95$2, 5e+147], N[(1.0 * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], t$95$1, t$95$3]]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{h}{\ell}}\\
t_1 := \frac{t\_0 \cdot d}{h}\\
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\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_3 := \frac{\left(-d\right) \cdot t\_0}{h}\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{-190}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-145}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+147}:\\
\;\;\;\;1 \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;t\_1\\
\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)))) < -2e-190 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 58.1%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites30.8%
Taylor expanded in l around -inf
Applied rewrites22.3%
if -2e-190 < (*.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.9999999999999998e-145 or 5.0000000000000002e147 < (*.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 62.8%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites45.5%
Taylor expanded in d around inf
Applied rewrites77.2%
if 4.9999999999999998e-145 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 5.0000000000000002e147Initial program 98.9%
Applied rewrites41.7%
Applied rewrites39.9%
Applied rewrites97.2%
Taylor expanded in d around inf
Applied rewrites96.9%
Final simplification51.8%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (/ h l)))
(t_1 (/ (* t_0 d) h))
(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_m) (* 2.0 d)) 2.0))
(/ h l)))))
(t_3 (/ (* (- d) t_0) h)))
(if (<= t_2 -2e-190)
t_3
(if (<= t_2 2e-98)
t_1
(if (<= t_2 5e+147)
(sqrt (* (/ (/ d l) h) d))
(if (<= t_2 INFINITY) t_1 t_3))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((h / l));
double t_1 = (t_0 * d) / h;
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_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_3 = (-d * t_0) / h;
double tmp;
if (t_2 <= -2e-190) {
tmp = t_3;
} else if (t_2 <= 2e-98) {
tmp = t_1;
} else if (t_2 <= 5e+147) {
tmp = sqrt((((d / l) / h) * d));
} else if (t_2 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = t_3;
}
return tmp;
}
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = Math.sqrt((h / l));
double t_1 = (t_0 * d) / h;
double t_2 = (Math.pow((d / h), Math.pow(2.0, -1.0)) * Math.pow((d / l), Math.pow(2.0, -1.0))) * (1.0 - ((Math.pow(2.0, -1.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_3 = (-d * t_0) / h;
double tmp;
if (t_2 <= -2e-190) {
tmp = t_3;
} else if (t_2 <= 2e-98) {
tmp = t_1;
} else if (t_2 <= 5e+147) {
tmp = Math.sqrt((((d / l) / h) * d));
} else if (t_2 <= Double.POSITIVE_INFINITY) {
tmp = t_1;
} else {
tmp = t_3;
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = math.sqrt((h / l)) t_1 = (t_0 * d) / h t_2 = (math.pow((d / h), math.pow(2.0, -1.0)) * math.pow((d / l), math.pow(2.0, -1.0))) * (1.0 - ((math.pow(2.0, -1.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l))) t_3 = (-d * t_0) / h tmp = 0 if t_2 <= -2e-190: tmp = t_3 elif t_2 <= 2e-98: tmp = t_1 elif t_2 <= 5e+147: tmp = math.sqrt((((d / l) / h) * d)) elif t_2 <= math.inf: tmp = t_1 else: tmp = t_3 return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = sqrt(Float64(h / l)) t_1 = Float64(Float64(t_0 * d) / h) 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_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_3 = Float64(Float64(Float64(-d) * t_0) / h) tmp = 0.0 if (t_2 <= -2e-190) tmp = t_3; elseif (t_2 <= 2e-98) tmp = t_1; elseif (t_2 <= 5e+147) tmp = sqrt(Float64(Float64(Float64(d / l) / h) * d)); elseif (t_2 <= Inf) tmp = t_1; else tmp = t_3; end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = sqrt((h / l));
t_1 = (t_0 * d) / h;
t_2 = (((d / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
t_3 = (-d * t_0) / h;
tmp = 0.0;
if (t_2 <= -2e-190)
tmp = t_3;
elseif (t_2 <= 2e-98)
tmp = t_1;
elseif (t_2 <= 5e+147)
tmp = sqrt((((d / l) / h) * d));
elseif (t_2 <= Inf)
tmp = t_1;
else
tmp = t_3;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * d), $MachinePrecision] / h), $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$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[((-d) * t$95$0), $MachinePrecision] / h), $MachinePrecision]}, If[LessEqual[t$95$2, -2e-190], t$95$3, If[LessEqual[t$95$2, 2e-98], t$95$1, If[LessEqual[t$95$2, 5e+147], N[Sqrt[N[(N[(N[(d / l), $MachinePrecision] / h), $MachinePrecision] * d), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$2, Infinity], t$95$1, t$95$3]]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{h}{\ell}}\\
t_1 := \frac{t\_0 \cdot d}{h}\\
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\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_3 := \frac{\left(-d\right) \cdot t\_0}{h}\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{-190}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-98}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+147}:\\
\;\;\;\;\sqrt{\frac{\frac{d}{\ell}}{h} \cdot d}\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;t\_1\\
\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)))) < -2e-190 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 58.1%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites30.8%
Taylor expanded in l around -inf
Applied rewrites22.3%
if -2e-190 < (*.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.99999999999999988e-98 or 5.0000000000000002e147 < (*.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 65.1%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites47.0%
Taylor expanded in d around inf
Applied rewrites77.7%
if 1.99999999999999988e-98 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 5.0000000000000002e147Initial program 99.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6444.0
Applied rewrites44.0%
Applied rewrites43.9%
Applied rewrites94.6%
Final simplification51.1%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(*
(* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0))
(/ h l))))))
(if (<= t_0 -2e-190)
(*
(fma
(* (* -0.25 (/ D_m d)) M_m)
(* (* 0.5 (* (/ D_m d) M_m)) (/ h l))
1.0)
(sqrt (* (/ d l) (/ d h))))
(if (<= t_0 5e+174)
(* (sqrt (/ d h)) (sqrt (/ d l)))
(if (<= t_0 INFINITY)
(/ (* (sqrt (/ h l)) d) h)
(*
(fma
(* -0.25 (/ D_m l))
(* (/ M_m d) (* (* h (* (/ D_m d) 0.5)) M_m))
1.0)
(/ d (sqrt (* l h)))))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -2e-190) {
tmp = fma(((-0.25 * (D_m / d)) * M_m), ((0.5 * ((D_m / d) * M_m)) * (h / l)), 1.0) * sqrt(((d / l) * (d / h)));
} else if (t_0 <= 5e+174) {
tmp = sqrt((d / h)) * sqrt((d / l));
} else if (t_0 <= ((double) INFINITY)) {
tmp = (sqrt((h / l)) * d) / h;
} else {
tmp = fma((-0.25 * (D_m / l)), ((M_m / d) * ((h * ((D_m / d) * 0.5)) * M_m)), 1.0) * (d / sqrt((l * h)));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_0 <= -2e-190) tmp = Float64(fma(Float64(Float64(-0.25 * Float64(D_m / d)) * M_m), Float64(Float64(0.5 * Float64(Float64(D_m / d) * M_m)) * Float64(h / l)), 1.0) * sqrt(Float64(Float64(d / l) * Float64(d / h)))); elseif (t_0 <= 5e+174) tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))); elseif (t_0 <= Inf) tmp = Float64(Float64(sqrt(Float64(h / l)) * d) / h); else tmp = Float64(fma(Float64(-0.25 * Float64(D_m / l)), Float64(Float64(M_m / d) * Float64(Float64(h * Float64(Float64(D_m / d) * 0.5)) * M_m)), 1.0) * Float64(d / sqrt(Float64(l * h)))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e-190], N[(N[(N[(N[(-0.25 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(N[(0.5 * N[(N[(D$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+174], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[(-0.25 * N[(D$95$m / l), $MachinePrecision]), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * N[(N[(h * N[(N[(D$95$m / d), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-190}:\\
\;\;\;\;\mathsf{fma}\left(\left(-0.25 \cdot \frac{D\_m}{d}\right) \cdot M\_m, \left(0.5 \cdot \left(\frac{D\_m}{d} \cdot M\_m\right)\right) \cdot \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+174}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot d}{h}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.25 \cdot \frac{D\_m}{\ell}, \frac{M\_m}{d} \cdot \left(\left(h \cdot \left(\frac{D\_m}{d} \cdot 0.5\right)\right) \cdot M\_m\right), 1\right) \cdot \frac{d}{\sqrt{\ell \cdot h}}\\
\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)))) < -2e-190Initial program 86.5%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lift-/.f64N/A
clear-numN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f6486.3
Applied rewrites86.3%
Applied rewrites89.3%
Applied rewrites74.9%
if -2e-190 < (*.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.9999999999999997e174Initial program 87.5%
Applied rewrites39.1%
Applied rewrites36.8%
Applied rewrites86.3%
Taylor expanded in d around -inf
mul-1-negN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
mul-1-negN/A
remove-double-negN/A
lower-sqrt.f64N/A
lower-/.f6485.8
Applied rewrites85.8%
if 4.9999999999999997e174 < (*.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 57.2%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites41.3%
Taylor expanded in d around inf
Applied rewrites79.2%
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)))) Initial program 0.0%
Applied rewrites2.6%
Applied rewrites16.5%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
neg-mul-1N/A
associate-*r*N/A
*-commutativeN/A
neg-mul-1N/A
lift-neg.f64N/A
lower-*.f6416.2
Applied rewrites16.2%
Applied rewrites27.7%
Final simplification70.7%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(*
(* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0))
(/ h l))))))
(if (<= t_0 -5e-45)
(*
(fma
(* (* 0.5 (* (/ D_m d) M_m)) h)
(/ (* (* -0.25 D_m) M_m) (* l d))
1.0)
(sqrt (* (/ d l) (/ d h))))
(if (<= t_0 5e+174)
(* (sqrt (/ d h)) (sqrt (/ d l)))
(if (<= t_0 INFINITY)
(/ (* (sqrt (/ h l)) d) h)
(*
(fma
(* -0.25 (/ D_m l))
(* (/ M_m d) (* (* h (* (/ D_m d) 0.5)) M_m))
1.0)
(/ d (sqrt (* l h)))))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -5e-45) {
tmp = fma(((0.5 * ((D_m / d) * M_m)) * h), (((-0.25 * D_m) * M_m) / (l * d)), 1.0) * sqrt(((d / l) * (d / h)));
} else if (t_0 <= 5e+174) {
tmp = sqrt((d / h)) * sqrt((d / l));
} else if (t_0 <= ((double) INFINITY)) {
tmp = (sqrt((h / l)) * d) / h;
} else {
tmp = fma((-0.25 * (D_m / l)), ((M_m / d) * ((h * ((D_m / d) * 0.5)) * M_m)), 1.0) * (d / sqrt((l * h)));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_0 <= -5e-45) tmp = Float64(fma(Float64(Float64(0.5 * Float64(Float64(D_m / d) * M_m)) * h), Float64(Float64(Float64(-0.25 * D_m) * M_m) / Float64(l * d)), 1.0) * sqrt(Float64(Float64(d / l) * Float64(d / h)))); elseif (t_0 <= 5e+174) tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))); elseif (t_0 <= Inf) tmp = Float64(Float64(sqrt(Float64(h / l)) * d) / h); else tmp = Float64(fma(Float64(-0.25 * Float64(D_m / l)), Float64(Float64(M_m / d) * Float64(Float64(h * Float64(Float64(D_m / d) * 0.5)) * M_m)), 1.0) * Float64(d / sqrt(Float64(l * h)))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-45], N[(N[(N[(N[(0.5 * N[(N[(D$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] * N[(N[(N[(-0.25 * D$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+174], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[(-0.25 * N[(D$95$m / l), $MachinePrecision]), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * N[(N[(h * N[(N[(D$95$m / d), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-45}:\\
\;\;\;\;\mathsf{fma}\left(\left(0.5 \cdot \left(\frac{D\_m}{d} \cdot M\_m\right)\right) \cdot h, \frac{\left(-0.25 \cdot D\_m\right) \cdot M\_m}{\ell \cdot d}, 1\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+174}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot d}{h}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.25 \cdot \frac{D\_m}{\ell}, \frac{M\_m}{d} \cdot \left(\left(h \cdot \left(\frac{D\_m}{d} \cdot 0.5\right)\right) \cdot M\_m\right), 1\right) \cdot \frac{d}{\sqrt{\ell \cdot h}}\\
\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.99999999999999976e-45Initial program 86.8%
Applied rewrites41.4%
Applied rewrites40.2%
Applied rewrites71.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
remove-double-negN/A
distribute-lft-neg-outN/A
lift-neg.f64N/A
lift-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
remove-double-negN/A
lower-*.f6469.1
Applied rewrites69.1%
if -4.99999999999999976e-45 < (*.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.9999999999999997e174Initial program 87.1%
Applied rewrites39.6%
Applied rewrites37.4%
Applied rewrites85.8%
Taylor expanded in d around -inf
mul-1-negN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
mul-1-negN/A
remove-double-negN/A
lower-sqrt.f64N/A
lower-/.f6481.6
Applied rewrites81.6%
if 4.9999999999999997e174 < (*.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 57.2%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites41.3%
Taylor expanded in d around inf
Applied rewrites79.2%
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)))) Initial program 0.0%
Applied rewrites2.6%
Applied rewrites16.5%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
neg-mul-1N/A
associate-*r*N/A
*-commutativeN/A
neg-mul-1N/A
lift-neg.f64N/A
lower-*.f6416.2
Applied rewrites16.2%
Applied rewrites27.7%
Final simplification67.7%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (/ h l)))
(t_1
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(*
(* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0))
(/ h l)))))
(t_2 (/ (* (- d) t_0) h)))
(if (<= t_1 -2e-190)
t_2
(if (<= t_1 5e+174)
(* (sqrt (/ d h)) (sqrt (/ d l)))
(if (<= t_1 INFINITY) (/ (* t_0 d) h) t_2)))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((h / l));
double t_1 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_2 = (-d * t_0) / h;
double tmp;
if (t_1 <= -2e-190) {
tmp = t_2;
} else if (t_1 <= 5e+174) {
tmp = sqrt((d / h)) * sqrt((d / l));
} else if (t_1 <= ((double) INFINITY)) {
tmp = (t_0 * d) / h;
} else {
tmp = t_2;
}
return tmp;
}
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = Math.sqrt((h / l));
double t_1 = (Math.pow((d / h), Math.pow(2.0, -1.0)) * Math.pow((d / l), Math.pow(2.0, -1.0))) * (1.0 - ((Math.pow(2.0, -1.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_2 = (-d * t_0) / h;
double tmp;
if (t_1 <= -2e-190) {
tmp = t_2;
} else if (t_1 <= 5e+174) {
tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = (t_0 * d) / h;
} else {
tmp = t_2;
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = math.sqrt((h / l)) t_1 = (math.pow((d / h), math.pow(2.0, -1.0)) * math.pow((d / l), math.pow(2.0, -1.0))) * (1.0 - ((math.pow(2.0, -1.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l))) t_2 = (-d * t_0) / h tmp = 0 if t_1 <= -2e-190: tmp = t_2 elif t_1 <= 5e+174: tmp = math.sqrt((d / h)) * math.sqrt((d / l)) elif t_1 <= math.inf: tmp = (t_0 * d) / h else: tmp = t_2 return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = sqrt(Float64(h / l)) t_1 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_2 = Float64(Float64(Float64(-d) * t_0) / h) tmp = 0.0 if (t_1 <= -2e-190) tmp = t_2; elseif (t_1 <= 5e+174) tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))); elseif (t_1 <= Inf) tmp = Float64(Float64(t_0 * d) / h); else tmp = t_2; end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = sqrt((h / l));
t_1 = (((d / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
t_2 = (-d * t_0) / h;
tmp = 0.0;
if (t_1 <= -2e-190)
tmp = t_2;
elseif (t_1 <= 5e+174)
tmp = sqrt((d / h)) * sqrt((d / l));
elseif (t_1 <= Inf)
tmp = (t_0 * d) / h;
else
tmp = t_2;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[((-d) * t$95$0), $MachinePrecision] / h), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-190], t$95$2, If[LessEqual[t$95$1, 5e+174], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(t$95$0 * d), $MachinePrecision] / h), $MachinePrecision], t$95$2]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{h}{\ell}}\\
t_1 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_2 := \frac{\left(-d\right) \cdot t\_0}{h}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-190}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+174}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{t\_0 \cdot d}{h}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\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)))) < -2e-190 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 58.1%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites30.8%
Taylor expanded in l around -inf
Applied rewrites22.3%
if -2e-190 < (*.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.9999999999999997e174Initial program 87.5%
Applied rewrites39.1%
Applied rewrites36.8%
Applied rewrites86.3%
Taylor expanded in d around -inf
mul-1-negN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
mul-1-negN/A
remove-double-negN/A
lower-sqrt.f64N/A
lower-/.f6485.8
Applied rewrites85.8%
if 4.9999999999999997e174 < (*.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 57.2%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites41.3%
Taylor expanded in d around inf
Applied rewrites79.2%
Final simplification51.3%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(*
(* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0))
(/ h l))))))
(if (<= t_0 5e+174)
(*
(*
(fma
(* (* -0.25 (/ D_m d)) M_m)
(* (* 0.5 (* (/ D_m d) M_m)) (/ h l))
1.0)
(sqrt (/ d h)))
(sqrt (/ d l)))
(if (<= t_0 INFINITY)
(/ (* (sqrt (/ h l)) d) h)
(*
(fma
(* -0.25 (/ D_m l))
(* (/ M_m d) (* (* h (* (/ D_m d) 0.5)) M_m))
1.0)
(/ d (sqrt (* l h))))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= 5e+174) {
tmp = (fma(((-0.25 * (D_m / d)) * M_m), ((0.5 * ((D_m / d) * M_m)) * (h / l)), 1.0) * sqrt((d / h))) * sqrt((d / l));
} else if (t_0 <= ((double) INFINITY)) {
tmp = (sqrt((h / l)) * d) / h;
} else {
tmp = fma((-0.25 * (D_m / l)), ((M_m / d) * ((h * ((D_m / d) * 0.5)) * M_m)), 1.0) * (d / sqrt((l * h)));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_0 <= 5e+174) tmp = Float64(Float64(fma(Float64(Float64(-0.25 * Float64(D_m / d)) * M_m), Float64(Float64(0.5 * Float64(Float64(D_m / d) * M_m)) * Float64(h / l)), 1.0) * sqrt(Float64(d / h))) * sqrt(Float64(d / l))); elseif (t_0 <= Inf) tmp = Float64(Float64(sqrt(Float64(h / l)) * d) / h); else tmp = Float64(fma(Float64(-0.25 * Float64(D_m / l)), Float64(Float64(M_m / d) * Float64(Float64(h * Float64(Float64(D_m / d) * 0.5)) * M_m)), 1.0) * Float64(d / sqrt(Float64(l * h)))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e+174], N[(N[(N[(N[(N[(-0.25 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(N[(0.5 * N[(N[(D$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[(-0.25 * N[(D$95$m / l), $MachinePrecision]), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * N[(N[(h * N[(N[(D$95$m / d), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{+174}:\\
\;\;\;\;\left(\mathsf{fma}\left(\left(-0.25 \cdot \frac{D\_m}{d}\right) \cdot M\_m, \left(0.5 \cdot \left(\frac{D\_m}{d} \cdot M\_m\right)\right) \cdot \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot d}{h}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.25 \cdot \frac{D\_m}{\ell}, \frac{M\_m}{d} \cdot \left(\left(h \cdot \left(\frac{D\_m}{d} \cdot 0.5\right)\right) \cdot M\_m\right), 1\right) \cdot \frac{d}{\sqrt{\ell \cdot h}}\\
\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.9999999999999997e174Initial program 87.0%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lift-/.f64N/A
clear-numN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f6486.4
Applied rewrites86.4%
Applied rewrites87.5%
Applied rewrites88.7%
if 4.9999999999999997e174 < (*.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 57.2%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites41.3%
Taylor expanded in d around inf
Applied rewrites79.2%
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)))) Initial program 0.0%
Applied rewrites2.6%
Applied rewrites16.5%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
neg-mul-1N/A
associate-*r*N/A
*-commutativeN/A
neg-mul-1N/A
lift-neg.f64N/A
lower-*.f6416.2
Applied rewrites16.2%
Applied rewrites27.7%
Final simplification76.4%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0
(fma
(* (* 0.5 (* (/ D_m d) M_m)) h)
(* (/ M_m l) (* -0.25 (/ D_m d)))
1.0))
(t_1 (sqrt (/ d l))))
(if (<= h -2e-310)
(* (* t_0 (/ (sqrt (- d)) (sqrt (- h)))) t_1)
(if (<= h 6.4e+140)
(*
(* (sqrt (pow (* l h) -1.0)) d)
(-
1.0
(/
(* (/ M_m d) (* 0.25 D_m))
(* l (* (pow h -1.0) (/ 2.0 (* M_m (/ D_m d))))))))
(* (* t_0 (/ (sqrt d) (sqrt h))) t_1)))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = fma(((0.5 * ((D_m / d) * M_m)) * h), ((M_m / l) * (-0.25 * (D_m / d))), 1.0);
double t_1 = sqrt((d / l));
double tmp;
if (h <= -2e-310) {
tmp = (t_0 * (sqrt(-d) / sqrt(-h))) * t_1;
} else if (h <= 6.4e+140) {
tmp = (sqrt(pow((l * h), -1.0)) * d) * (1.0 - (((M_m / d) * (0.25 * D_m)) / (l * (pow(h, -1.0) * (2.0 / (M_m * (D_m / d)))))));
} else {
tmp = (t_0 * (sqrt(d) / sqrt(h))) * t_1;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = fma(Float64(Float64(0.5 * Float64(Float64(D_m / d) * M_m)) * h), Float64(Float64(M_m / l) * Float64(-0.25 * Float64(D_m / d))), 1.0) t_1 = sqrt(Float64(d / l)) tmp = 0.0 if (h <= -2e-310) tmp = Float64(Float64(t_0 * Float64(sqrt(Float64(-d)) / sqrt(Float64(-h)))) * t_1); elseif (h <= 6.4e+140) tmp = Float64(Float64(sqrt((Float64(l * h) ^ -1.0)) * d) * Float64(1.0 - Float64(Float64(Float64(M_m / d) * Float64(0.25 * D_m)) / Float64(l * Float64((h ^ -1.0) * Float64(2.0 / Float64(M_m * Float64(D_m / d)))))))); else tmp = Float64(Float64(t_0 * Float64(sqrt(d) / sqrt(h))) * t_1); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[(0.5 * N[(N[(D$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] * N[(N[(M$95$m / l), $MachinePrecision] * N[(-0.25 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[h, -2e-310], N[(N[(t$95$0 * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[h, 6.4e+140], N[(N[(N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] * N[(1.0 - N[(N[(N[(M$95$m / d), $MachinePrecision] * N[(0.25 * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(l * N[(N[Power[h, -1.0], $MachinePrecision] * N[(2.0 / N[(M$95$m * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\left(0.5 \cdot \left(\frac{D\_m}{d} \cdot M\_m\right)\right) \cdot h, \frac{M\_m}{\ell} \cdot \left(-0.25 \cdot \frac{D\_m}{d}\right), 1\right)\\
t_1 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;h \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\left(t\_0 \cdot \frac{\sqrt{-d}}{\sqrt{-h}}\right) \cdot t\_1\\
\mathbf{elif}\;h \leq 6.4 \cdot 10^{+140}:\\
\;\;\;\;\left(\sqrt{{\left(\ell \cdot h\right)}^{-1}} \cdot d\right) \cdot \left(1 - \frac{\frac{M\_m}{d} \cdot \left(0.25 \cdot D\_m\right)}{\ell \cdot \left({h}^{-1} \cdot \frac{2}{M\_m \cdot \frac{D\_m}{d}}\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right) \cdot t\_1\\
\end{array}
\end{array}
if h < -1.999999999999994e-310Initial program 62.7%
Applied rewrites67.8%
Applied rewrites70.3%
Applied rewrites63.1%
lift-sqrt.f64N/A
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f6476.9
Applied rewrites76.9%
if -1.999999999999994e-310 < h < 6.40000000000000021e140Initial program 71.3%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lift-/.f64N/A
clear-numN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f6470.6
Applied rewrites70.6%
Applied rewrites73.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6489.4
Applied rewrites89.4%
if 6.40000000000000021e140 < h Initial program 67.5%
Applied rewrites0.0%
Applied rewrites0.0%
Applied rewrites78.6%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
pow1/2N/A
lower-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lower-sqrt.f6493.1
Applied rewrites93.1%
Final simplification83.5%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0
(fma
(* (* 0.5 (* (/ D_m d) M_m)) h)
(* (/ M_m l) (* -0.25 (/ D_m d)))
1.0))
(t_1 (sqrt (/ d l))))
(if (<= h -2e-310)
(* (* t_0 (/ (sqrt (- d)) (sqrt (- h)))) t_1)
(if (<= h 6.4e+140)
(*
(fma
(* (* (* (* 0.5 M_m) (/ D_m d)) (* h (/ M_m l))) (/ D_m d))
-0.25
1.0)
(/ d (sqrt (* l h))))
(* (* t_0 (/ (sqrt d) (sqrt h))) t_1)))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = fma(((0.5 * ((D_m / d) * M_m)) * h), ((M_m / l) * (-0.25 * (D_m / d))), 1.0);
double t_1 = sqrt((d / l));
double tmp;
if (h <= -2e-310) {
tmp = (t_0 * (sqrt(-d) / sqrt(-h))) * t_1;
} else if (h <= 6.4e+140) {
tmp = fma(((((0.5 * M_m) * (D_m / d)) * (h * (M_m / l))) * (D_m / d)), -0.25, 1.0) * (d / sqrt((l * h)));
} else {
tmp = (t_0 * (sqrt(d) / sqrt(h))) * t_1;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = fma(Float64(Float64(0.5 * Float64(Float64(D_m / d) * M_m)) * h), Float64(Float64(M_m / l) * Float64(-0.25 * Float64(D_m / d))), 1.0) t_1 = sqrt(Float64(d / l)) tmp = 0.0 if (h <= -2e-310) tmp = Float64(Float64(t_0 * Float64(sqrt(Float64(-d)) / sqrt(Float64(-h)))) * t_1); elseif (h <= 6.4e+140) tmp = Float64(fma(Float64(Float64(Float64(Float64(0.5 * M_m) * Float64(D_m / d)) * Float64(h * Float64(M_m / l))) * Float64(D_m / d)), -0.25, 1.0) * Float64(d / sqrt(Float64(l * h)))); else tmp = Float64(Float64(t_0 * Float64(sqrt(d) / sqrt(h))) * t_1); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[(0.5 * N[(N[(D$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] * N[(N[(M$95$m / l), $MachinePrecision] * N[(-0.25 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[h, -2e-310], N[(N[(t$95$0 * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[h, 6.4e+140], N[(N[(N[(N[(N[(N[(0.5 * M$95$m), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision] * N[(h * N[(M$95$m / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision] * -0.25 + 1.0), $MachinePrecision] * N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\left(0.5 \cdot \left(\frac{D\_m}{d} \cdot M\_m\right)\right) \cdot h, \frac{M\_m}{\ell} \cdot \left(-0.25 \cdot \frac{D\_m}{d}\right), 1\right)\\
t_1 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;h \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\left(t\_0 \cdot \frac{\sqrt{-d}}{\sqrt{-h}}\right) \cdot t\_1\\
\mathbf{elif}\;h \leq 6.4 \cdot 10^{+140}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(\left(0.5 \cdot M\_m\right) \cdot \frac{D\_m}{d}\right) \cdot \left(h \cdot \frac{M\_m}{\ell}\right)\right) \cdot \frac{D\_m}{d}, -0.25, 1\right) \cdot \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right) \cdot t\_1\\
\end{array}
\end{array}
if h < -1.999999999999994e-310Initial program 62.7%
Applied rewrites67.8%
Applied rewrites70.3%
Applied rewrites63.1%
lift-sqrt.f64N/A
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f6476.9
Applied rewrites76.9%
if -1.999999999999994e-310 < h < 6.40000000000000021e140Initial program 71.3%
Applied rewrites0.0%
Applied rewrites0.0%
Applied rewrites72.4%
Applied rewrites84.8%
if 6.40000000000000021e140 < h Initial program 67.5%
Applied rewrites0.0%
Applied rewrites0.0%
Applied rewrites78.6%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
pow1/2N/A
lower-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lower-sqrt.f6493.1
Applied rewrites93.1%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (/ d l))))
(if (<= h 3e-309)
(*
(*
(fma
(* (/ D_m d) 0.5)
(* M_m (* (* h (* -0.25 (/ M_m l))) (/ D_m d)))
1.0)
(sqrt (/ d h)))
t_0)
(if (<= h 6.4e+140)
(*
(fma
(* (* (* (* 0.5 M_m) (/ D_m d)) (* h (/ M_m l))) (/ D_m d))
-0.25
1.0)
(/ d (sqrt (* l h))))
(*
(*
(fma
(* (* 0.5 (* (/ D_m d) M_m)) h)
(* (/ M_m l) (* -0.25 (/ D_m d)))
1.0)
(/ (sqrt d) (sqrt h)))
t_0)))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((d / l));
double tmp;
if (h <= 3e-309) {
tmp = (fma(((D_m / d) * 0.5), (M_m * ((h * (-0.25 * (M_m / l))) * (D_m / d))), 1.0) * sqrt((d / h))) * t_0;
} else if (h <= 6.4e+140) {
tmp = fma(((((0.5 * M_m) * (D_m / d)) * (h * (M_m / l))) * (D_m / d)), -0.25, 1.0) * (d / sqrt((l * h)));
} else {
tmp = (fma(((0.5 * ((D_m / d) * M_m)) * h), ((M_m / l) * (-0.25 * (D_m / d))), 1.0) * (sqrt(d) / sqrt(h))) * t_0;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = sqrt(Float64(d / l)) tmp = 0.0 if (h <= 3e-309) tmp = Float64(Float64(fma(Float64(Float64(D_m / d) * 0.5), Float64(M_m * Float64(Float64(h * Float64(-0.25 * Float64(M_m / l))) * Float64(D_m / d))), 1.0) * sqrt(Float64(d / h))) * t_0); elseif (h <= 6.4e+140) tmp = Float64(fma(Float64(Float64(Float64(Float64(0.5 * M_m) * Float64(D_m / d)) * Float64(h * Float64(M_m / l))) * Float64(D_m / d)), -0.25, 1.0) * Float64(d / sqrt(Float64(l * h)))); else tmp = Float64(Float64(fma(Float64(Float64(0.5 * Float64(Float64(D_m / d) * M_m)) * h), Float64(Float64(M_m / l) * Float64(-0.25 * Float64(D_m / d))), 1.0) * Float64(sqrt(d) / sqrt(h))) * t_0); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[h, 3e-309], N[(N[(N[(N[(N[(D$95$m / d), $MachinePrecision] * 0.5), $MachinePrecision] * N[(M$95$m * N[(N[(h * N[(-0.25 * N[(M$95$m / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[h, 6.4e+140], N[(N[(N[(N[(N[(N[(0.5 * M$95$m), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision] * N[(h * N[(M$95$m / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision] * -0.25 + 1.0), $MachinePrecision] * N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(0.5 * N[(N[(D$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] * N[(N[(M$95$m / l), $MachinePrecision] * N[(-0.25 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;h \leq 3 \cdot 10^{-309}:\\
\;\;\;\;\left(\mathsf{fma}\left(\frac{D\_m}{d} \cdot 0.5, M\_m \cdot \left(\left(h \cdot \left(-0.25 \cdot \frac{M\_m}{\ell}\right)\right) \cdot \frac{D\_m}{d}\right), 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot t\_0\\
\mathbf{elif}\;h \leq 6.4 \cdot 10^{+140}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(\left(0.5 \cdot M\_m\right) \cdot \frac{D\_m}{d}\right) \cdot \left(h \cdot \frac{M\_m}{\ell}\right)\right) \cdot \frac{D\_m}{d}, -0.25, 1\right) \cdot \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\left(0.5 \cdot \left(\frac{D\_m}{d} \cdot M\_m\right)\right) \cdot h, \frac{M\_m}{\ell} \cdot \left(-0.25 \cdot \frac{D\_m}{d}\right), 1\right) \cdot \frac{\sqrt{d}}{\sqrt{h}}\right) \cdot t\_0\\
\end{array}
\end{array}
if h < 3.000000000000001e-309Initial program 62.7%
Applied rewrites67.8%
Applied rewrites70.3%
Applied rewrites63.1%
lift-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites62.0%
if 3.000000000000001e-309 < h < 6.40000000000000021e140Initial program 71.3%
Applied rewrites0.0%
Applied rewrites0.0%
Applied rewrites72.4%
Applied rewrites84.8%
if 6.40000000000000021e140 < h Initial program 67.5%
Applied rewrites0.0%
Applied rewrites0.0%
Applied rewrites78.6%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
pow1/2N/A
lower-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lower-sqrt.f6493.1
Applied rewrites93.1%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (if (<= l 3.6e-271) (* (- d) (sqrt (pow (* l h) -1.0))) (/ d (* (sqrt l) (sqrt h)))))
D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= 3.6e-271) {
tmp = -d * sqrt(pow((l * h), -1.0));
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = abs(d)
M_m = abs(m)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: tmp
if (l <= 3.6d-271) then
tmp = -d * sqrt(((l * h) ** (-1.0d0)))
else
tmp = d / (sqrt(l) * sqrt(h))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= 3.6e-271) {
tmp = -d * Math.sqrt(Math.pow((l * h), -1.0));
} else {
tmp = d / (Math.sqrt(l) * Math.sqrt(h));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if l <= 3.6e-271: tmp = -d * math.sqrt(math.pow((l * h), -1.0)) else: tmp = d / (math.sqrt(l) * math.sqrt(h)) return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (l <= 3.6e-271) tmp = Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0))); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (l <= 3.6e-271)
tmp = -d * sqrt(((l * h) ^ -1.0));
else
tmp = d / (sqrt(l) * sqrt(h));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, 3.6e-271], 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}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 3.6 \cdot 10^{-271}:\\
\;\;\;\;\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 l < 3.5999999999999998e-271Initial program 64.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-*.f6437.7
Applied rewrites37.7%
if 3.5999999999999998e-271 < l Initial program 69.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6445.7
Applied rewrites45.7%
Applied rewrites46.1%
Applied rewrites55.4%
Final simplification45.9%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (if (<= l 3.4e-269) (* (- d) (sqrt (pow (* l h) -1.0))) (/ d (sqrt (* l h)))))
D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= 3.4e-269) {
tmp = -d * sqrt(pow((l * h), -1.0));
} else {
tmp = d / sqrt((l * h));
}
return tmp;
}
D_m = abs(d)
M_m = abs(m)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: tmp
if (l <= 3.4d-269) then
tmp = -d * sqrt(((l * h) ** (-1.0d0)))
else
tmp = d / sqrt((l * h))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= 3.4e-269) {
tmp = -d * Math.sqrt(Math.pow((l * h), -1.0));
} else {
tmp = d / Math.sqrt((l * h));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if l <= 3.4e-269: tmp = -d * math.sqrt(math.pow((l * h), -1.0)) else: tmp = d / math.sqrt((l * h)) return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (l <= 3.4e-269) tmp = Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0))); else tmp = Float64(d / sqrt(Float64(l * h))); end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (l <= 3.4e-269)
tmp = -d * sqrt(((l * h) ^ -1.0));
else
tmp = d / sqrt((l * h));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, 3.4e-269], 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}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 3.4 \cdot 10^{-269}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\
\end{array}
\end{array}
if l < 3.3999999999999997e-269Initial program 64.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-*.f6437.7
Applied rewrites37.7%
if 3.3999999999999997e-269 < l Initial program 69.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6445.7
Applied rewrites45.7%
Applied rewrites46.1%
Final simplification41.6%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (* (* 0.5 (* (/ D_m d) M_m)) h))
(t_1
(*
(* (fma t_0 (/ (* (* -0.25 D_m) M_m) (* l d)) 1.0) (sqrt (/ d h)))
(sqrt (/ d l)))))
(if (<= h -1.85e-131)
t_1
(if (<= h 9e-309)
(*
(fma t_0 (* (/ M_m l) (* -0.25 (/ D_m d))) 1.0)
(sqrt (* (/ d l) (/ d h))))
(if (<= h 3.95e+186)
(*
(fma
(* (* (* (* 0.5 M_m) (/ D_m d)) (* h (/ M_m l))) (/ D_m d))
-0.25
1.0)
(/ d (sqrt (* l h))))
t_1)))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (0.5 * ((D_m / d) * M_m)) * h;
double t_1 = (fma(t_0, (((-0.25 * D_m) * M_m) / (l * d)), 1.0) * sqrt((d / h))) * sqrt((d / l));
double tmp;
if (h <= -1.85e-131) {
tmp = t_1;
} else if (h <= 9e-309) {
tmp = fma(t_0, ((M_m / l) * (-0.25 * (D_m / d))), 1.0) * sqrt(((d / l) * (d / h)));
} else if (h <= 3.95e+186) {
tmp = fma(((((0.5 * M_m) * (D_m / d)) * (h * (M_m / l))) * (D_m / d)), -0.25, 1.0) * (d / sqrt((l * h)));
} else {
tmp = t_1;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(0.5 * Float64(Float64(D_m / d) * M_m)) * h) t_1 = Float64(Float64(fma(t_0, Float64(Float64(Float64(-0.25 * D_m) * M_m) / Float64(l * d)), 1.0) * sqrt(Float64(d / h))) * sqrt(Float64(d / l))) tmp = 0.0 if (h <= -1.85e-131) tmp = t_1; elseif (h <= 9e-309) tmp = Float64(fma(t_0, Float64(Float64(M_m / l) * Float64(-0.25 * Float64(D_m / d))), 1.0) * sqrt(Float64(Float64(d / l) * Float64(d / h)))); elseif (h <= 3.95e+186) tmp = Float64(fma(Float64(Float64(Float64(Float64(0.5 * M_m) * Float64(D_m / d)) * Float64(h * Float64(M_m / l))) * Float64(D_m / d)), -0.25, 1.0) * Float64(d / sqrt(Float64(l * h)))); else tmp = t_1; end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(0.5 * N[(N[(D$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(t$95$0 * N[(N[(N[(-0.25 * D$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -1.85e-131], t$95$1, If[LessEqual[h, 9e-309], N[(N[(t$95$0 * N[(N[(M$95$m / l), $MachinePrecision] * N[(-0.25 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[h, 3.95e+186], N[(N[(N[(N[(N[(N[(0.5 * M$95$m), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision] * N[(h * N[(M$95$m / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision] * -0.25 + 1.0), $MachinePrecision] * N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left(0.5 \cdot \left(\frac{D\_m}{d} \cdot M\_m\right)\right) \cdot h\\
t_1 := \left(\mathsf{fma}\left(t\_0, \frac{\left(-0.25 \cdot D\_m\right) \cdot M\_m}{\ell \cdot d}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;h \leq -1.85 \cdot 10^{-131}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;h \leq 9 \cdot 10^{-309}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, \frac{M\_m}{\ell} \cdot \left(-0.25 \cdot \frac{D\_m}{d}\right), 1\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{elif}\;h \leq 3.95 \cdot 10^{+186}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(\left(0.5 \cdot M\_m\right) \cdot \frac{D\_m}{d}\right) \cdot \left(h \cdot \frac{M\_m}{\ell}\right)\right) \cdot \frac{D\_m}{d}, -0.25, 1\right) \cdot \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if h < -1.8500000000000001e-131 or 3.95000000000000001e186 < h Initial program 66.0%
Applied rewrites55.7%
Applied rewrites59.1%
Applied rewrites69.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
remove-double-negN/A
distribute-lft-neg-outN/A
lift-neg.f64N/A
lift-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
remove-double-negN/A
lower-*.f6466.1
Applied rewrites66.1%
if -1.8500000000000001e-131 < h < 9.0000000000000021e-309Initial program 59.2%
Applied rewrites62.6%
Applied rewrites60.3%
Applied rewrites53.9%
if 9.0000000000000021e-309 < h < 3.95000000000000001e186Initial program 69.2%
Applied rewrites0.0%
Applied rewrites0.0%
Applied rewrites72.0%
Applied rewrites84.1%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= l -1e-309)
(*
(fma (* (* 0.5 (* (/ D_m d) M_m)) h) (* (/ M_m l) (* -0.25 (/ D_m d))) 1.0)
(sqrt (* (/ d l) (/ d h))))
(if (<= l 1.08e+104)
(*
(fma
(* (* (* (* 0.5 M_m) (/ D_m d)) (* h (/ M_m l))) (/ D_m d))
-0.25
1.0)
(/ d (sqrt (* l h))))
(/ d (* (sqrt l) (sqrt h))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= -1e-309) {
tmp = fma(((0.5 * ((D_m / d) * M_m)) * h), ((M_m / l) * (-0.25 * (D_m / d))), 1.0) * sqrt(((d / l) * (d / h)));
} else if (l <= 1.08e+104) {
tmp = fma(((((0.5 * M_m) * (D_m / d)) * (h * (M_m / l))) * (D_m / d)), -0.25, 1.0) * (d / sqrt((l * h)));
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (l <= -1e-309) tmp = Float64(fma(Float64(Float64(0.5 * Float64(Float64(D_m / d) * M_m)) * h), Float64(Float64(M_m / l) * Float64(-0.25 * Float64(D_m / d))), 1.0) * sqrt(Float64(Float64(d / l) * Float64(d / h)))); elseif (l <= 1.08e+104) tmp = Float64(fma(Float64(Float64(Float64(Float64(0.5 * M_m) * Float64(D_m / d)) * Float64(h * Float64(M_m / l))) * Float64(D_m / d)), -0.25, 1.0) * Float64(d / sqrt(Float64(l * h)))); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); end return tmp end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -1e-309], N[(N[(N[(N[(0.5 * N[(N[(D$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] * N[(N[(M$95$m / l), $MachinePrecision] * N[(-0.25 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.08e+104], N[(N[(N[(N[(N[(N[(0.5 * M$95$m), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision] * N[(h * N[(M$95$m / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision] * -0.25 + 1.0), $MachinePrecision] * N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1 \cdot 10^{-309}:\\
\;\;\;\;\mathsf{fma}\left(\left(0.5 \cdot \left(\frac{D\_m}{d} \cdot M\_m\right)\right) \cdot h, \frac{M\_m}{\ell} \cdot \left(-0.25 \cdot \frac{D\_m}{d}\right), 1\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{elif}\;\ell \leq 1.08 \cdot 10^{+104}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(\left(0.5 \cdot M\_m\right) \cdot \frac{D\_m}{d}\right) \cdot \left(h \cdot \frac{M\_m}{\ell}\right)\right) \cdot \frac{D\_m}{d}, -0.25, 1\right) \cdot \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < -1.000000000000002e-309Initial program 62.7%
Applied rewrites67.8%
Applied rewrites70.3%
Applied rewrites52.7%
if -1.000000000000002e-309 < l < 1.07999999999999997e104Initial program 76.7%
Applied rewrites0.0%
Applied rewrites0.0%
Applied rewrites80.6%
Applied rewrites87.3%
if 1.07999999999999997e104 < l Initial program 59.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6451.2
Applied rewrites51.2%
Applied rewrites51.2%
Applied rewrites70.2%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= l -1e-309)
(/ (* (sqrt (/ d h)) (sqrt (- d))) (sqrt (- l)))
(if (<= l 1.08e+104)
(*
(fma
(* (* (* (* 0.5 M_m) (/ D_m d)) (* h (/ M_m l))) (/ D_m d))
-0.25
1.0)
(/ d (sqrt (* l h))))
(/ d (* (sqrt l) (sqrt h))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= -1e-309) {
tmp = (sqrt((d / h)) * sqrt(-d)) / sqrt(-l);
} else if (l <= 1.08e+104) {
tmp = fma(((((0.5 * M_m) * (D_m / d)) * (h * (M_m / l))) * (D_m / d)), -0.25, 1.0) * (d / sqrt((l * h)));
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (l <= -1e-309) tmp = Float64(Float64(sqrt(Float64(d / h)) * sqrt(Float64(-d))) / sqrt(Float64(-l))); elseif (l <= 1.08e+104) tmp = Float64(fma(Float64(Float64(Float64(Float64(0.5 * M_m) * Float64(D_m / d)) * Float64(h * Float64(M_m / l))) * Float64(D_m / d)), -0.25, 1.0) * Float64(d / sqrt(Float64(l * h)))); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); end return tmp end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -1e-309], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[(-d)], $MachinePrecision]), $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.08e+104], N[(N[(N[(N[(N[(N[(0.5 * M$95$m), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision] * N[(h * N[(M$95$m / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision] * -0.25 + 1.0), $MachinePrecision] * N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1 \cdot 10^{-309}:\\
\;\;\;\;\frac{\sqrt{\frac{d}{h}} \cdot \sqrt{-d}}{\sqrt{-\ell}}\\
\mathbf{elif}\;\ell \leq 1.08 \cdot 10^{+104}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(\left(0.5 \cdot M\_m\right) \cdot \frac{D\_m}{d}\right) \cdot \left(h \cdot \frac{M\_m}{\ell}\right)\right) \cdot \frac{D\_m}{d}, -0.25, 1\right) \cdot \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < -1.000000000000002e-309Initial program 62.7%
Applied rewrites67.8%
Applied rewrites70.3%
Taylor expanded in d around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
neg-mul-1N/A
mul-1-negN/A
remove-double-negN/A
lower-sqrt.f64N/A
lower-/.f6440.1
Applied rewrites40.1%
if -1.000000000000002e-309 < l < 1.07999999999999997e104Initial program 76.7%
Applied rewrites0.0%
Applied rewrites0.0%
Applied rewrites80.6%
Applied rewrites87.3%
if 1.07999999999999997e104 < l Initial program 59.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6451.2
Applied rewrites51.2%
Applied rewrites51.2%
Applied rewrites70.2%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= l -1e-309)
(/ (* (sqrt (/ d h)) (sqrt (- d))) (sqrt (- l)))
(if (<= l 4.9e+110)
(*
(fma
(* -0.25 (/ D_m l))
(* (/ M_m d) (* (* h (* (/ D_m d) 0.5)) M_m))
1.0)
(/ d (sqrt (* l h))))
(/ d (* (sqrt l) (sqrt h))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= -1e-309) {
tmp = (sqrt((d / h)) * sqrt(-d)) / sqrt(-l);
} else if (l <= 4.9e+110) {
tmp = fma((-0.25 * (D_m / l)), ((M_m / d) * ((h * ((D_m / d) * 0.5)) * M_m)), 1.0) * (d / sqrt((l * h)));
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (l <= -1e-309) tmp = Float64(Float64(sqrt(Float64(d / h)) * sqrt(Float64(-d))) / sqrt(Float64(-l))); elseif (l <= 4.9e+110) tmp = Float64(fma(Float64(-0.25 * Float64(D_m / l)), Float64(Float64(M_m / d) * Float64(Float64(h * Float64(Float64(D_m / d) * 0.5)) * M_m)), 1.0) * Float64(d / sqrt(Float64(l * h)))); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); end return tmp end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -1e-309], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[(-d)], $MachinePrecision]), $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 4.9e+110], N[(N[(N[(-0.25 * N[(D$95$m / l), $MachinePrecision]), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * N[(N[(h * N[(N[(D$95$m / d), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1 \cdot 10^{-309}:\\
\;\;\;\;\frac{\sqrt{\frac{d}{h}} \cdot \sqrt{-d}}{\sqrt{-\ell}}\\
\mathbf{elif}\;\ell \leq 4.9 \cdot 10^{+110}:\\
\;\;\;\;\mathsf{fma}\left(-0.25 \cdot \frac{D\_m}{\ell}, \frac{M\_m}{d} \cdot \left(\left(h \cdot \left(\frac{D\_m}{d} \cdot 0.5\right)\right) \cdot M\_m\right), 1\right) \cdot \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < -1.000000000000002e-309Initial program 62.7%
Applied rewrites67.8%
Applied rewrites70.3%
Taylor expanded in d around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
neg-mul-1N/A
mul-1-negN/A
remove-double-negN/A
lower-sqrt.f64N/A
lower-/.f6440.1
Applied rewrites40.1%
if -1.000000000000002e-309 < l < 4.90000000000000002e110Initial program 75.8%
Applied rewrites0.0%
Applied rewrites0.0%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
neg-mul-1N/A
associate-*r*N/A
*-commutativeN/A
neg-mul-1N/A
lift-neg.f64N/A
lower-*.f640.0
Applied rewrites0.0%
Applied rewrites88.6%
if 4.90000000000000002e110 < l Initial program 60.4%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6452.3
Applied rewrites52.3%
Applied rewrites52.3%
Applied rewrites71.8%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (/ d (sqrt (* l h))))
D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
return d / sqrt((l * h));
}
D_m = abs(d)
M_m = abs(m)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m_m, d_m)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
code = d / sqrt((l * h))
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
return d / Math.sqrt((l * h));
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): return d / math.sqrt((l * h))
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) return Float64(d / sqrt(Float64(l * h))) end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
tmp = d / sqrt((l * h));
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\frac{d}{\sqrt{\ell \cdot h}}
\end{array}
Initial program 66.4%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6426.6
Applied rewrites26.6%
Applied rewrites26.7%
herbie shell --seed 2024321
(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)))))