
(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)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
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 24 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)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
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 (pow (/ d l) (pow 2.0 -1.0)))
(t_1 (* (/ (/ D_m d) 2.0) M_m))
(t_2 (- 1.0 (/ (* t_1 (* t_1 (* 0.5 h))) l))))
(if (<= d -2e-310)
(* (* (/ (sqrt (- d)) (sqrt (- h))) t_0) t_2)
(if (<= d 7.2e+165)
(* (* (/ (sqrt d) (sqrt h)) t_0) t_2)
(* (/ (sqrt (pow l -1.0)) (sqrt h)) d)))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = pow((d / l), pow(2.0, -1.0));
double t_1 = ((D_m / d) / 2.0) * M_m;
double t_2 = 1.0 - ((t_1 * (t_1 * (0.5 * h))) / l);
double tmp;
if (d <= -2e-310) {
tmp = ((sqrt(-d) / sqrt(-h)) * t_0) * t_2;
} else if (d <= 7.2e+165) {
tmp = ((sqrt(d) / sqrt(h)) * t_0) * t_2;
} else {
tmp = (sqrt(pow(l, -1.0)) / sqrt(h)) * d;
}
return tmp;
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = (d / l) ** (2.0d0 ** (-1.0d0))
t_1 = ((d_m / d) / 2.0d0) * m_m
t_2 = 1.0d0 - ((t_1 * (t_1 * (0.5d0 * h))) / l)
if (d <= (-2d-310)) then
tmp = ((sqrt(-d) / sqrt(-h)) * t_0) * t_2
else if (d <= 7.2d+165) then
tmp = ((sqrt(d) / sqrt(h)) * t_0) * t_2
else
tmp = (sqrt((l ** (-1.0d0))) / sqrt(h)) * d
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = Math.pow((d / l), Math.pow(2.0, -1.0));
double t_1 = ((D_m / d) / 2.0) * M_m;
double t_2 = 1.0 - ((t_1 * (t_1 * (0.5 * h))) / l);
double tmp;
if (d <= -2e-310) {
tmp = ((Math.sqrt(-d) / Math.sqrt(-h)) * t_0) * t_2;
} else if (d <= 7.2e+165) {
tmp = ((Math.sqrt(d) / Math.sqrt(h)) * t_0) * t_2;
} else {
tmp = (Math.sqrt(Math.pow(l, -1.0)) / Math.sqrt(h)) * d;
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = math.pow((d / l), math.pow(2.0, -1.0)) t_1 = ((D_m / d) / 2.0) * M_m t_2 = 1.0 - ((t_1 * (t_1 * (0.5 * h))) / l) tmp = 0 if d <= -2e-310: tmp = ((math.sqrt(-d) / math.sqrt(-h)) * t_0) * t_2 elif d <= 7.2e+165: tmp = ((math.sqrt(d) / math.sqrt(h)) * t_0) * t_2 else: tmp = (math.sqrt(math.pow(l, -1.0)) / math.sqrt(h)) * d return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(d / l) ^ (2.0 ^ -1.0) t_1 = Float64(Float64(Float64(D_m / d) / 2.0) * M_m) t_2 = Float64(1.0 - Float64(Float64(t_1 * Float64(t_1 * Float64(0.5 * h))) / l)) tmp = 0.0 if (d <= -2e-310) tmp = Float64(Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * t_0) * t_2); elseif (d <= 7.2e+165) tmp = Float64(Float64(Float64(sqrt(d) / sqrt(h)) * t_0) * t_2); else tmp = Float64(Float64(sqrt((l ^ -1.0)) / sqrt(h)) * d); end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = (d / l) ^ (2.0 ^ -1.0);
t_1 = ((D_m / d) / 2.0) * M_m;
t_2 = 1.0 - ((t_1 * (t_1 * (0.5 * h))) / l);
tmp = 0.0;
if (d <= -2e-310)
tmp = ((sqrt(-d) / sqrt(-h)) * t_0) * t_2;
elseif (d <= 7.2e+165)
tmp = ((sqrt(d) / sqrt(h)) * t_0) * t_2;
else
tmp = (sqrt((l ^ -1.0)) / sqrt(h)) * d;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - N[(N[(t$95$1 * N[(t$95$1 * N[(0.5 * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2e-310], N[(N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[d, 7.2e+165], N[(N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$2), $MachinePrecision], N[(N[(N[Sqrt[N[Power[l, -1.0], $MachinePrecision]], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * d), $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(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\\
t_1 := \frac{\frac{D\_m}{d}}{2} \cdot M\_m\\
t_2 := 1 - \frac{t\_1 \cdot \left(t\_1 \cdot \left(0.5 \cdot h\right)\right)}{\ell}\\
\mathbf{if}\;d \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot t\_0\right) \cdot t\_2\\
\mathbf{elif}\;d \leq 7.2 \cdot 10^{+165}:\\
\;\;\;\;\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot t\_0\right) \cdot t\_2\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{{\ell}^{-1}}}{\sqrt{h}} \cdot d\\
\end{array}
\end{array}
if d < -1.999999999999994e-310Initial program 72.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6474.1
lift-/.f64N/A
metadata-eval74.1
Applied rewrites74.1%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6474.1
Applied rewrites74.1%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lift-/.f64N/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites72.4%
lift-/.f64N/A
metadata-eval72.4
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
frac-2negN/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-neg.f6482.8
Applied rewrites82.8%
if -1.999999999999994e-310 < d < 7.1999999999999996e165Initial program 59.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6459.5
lift-/.f64N/A
metadata-eval59.5
Applied rewrites59.5%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6460.4
Applied rewrites60.4%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lift-/.f64N/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites61.3%
lift-/.f64N/A
metadata-eval61.3
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6474.4
Applied rewrites74.4%
if 7.1999999999999996e165 < d Initial program 68.2%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6477.4
Applied rewrites77.4%
Applied rewrites94.6%
Final simplification80.9%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(*
(* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0))
(/ h l)))))
(t_1 (sqrt (* (/ d l) (/ d h)))))
(if (<= t_0 -2e-173)
(*
(fma
(* -0.5 (/ (* (* M_m D_m) (* M_m D_m)) (* d (* 4.0 d))))
(/ h l)
1.0)
t_1)
(if (<= t_0 1e-165)
(/ d (sqrt (* l h)))
(if (<= t_0 5e+166)
(* 1.0 t_1)
(* (pow (* (sqrt l) (sqrt h)) -1.0) d))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = sqrt(((d / l) * (d / h)));
double tmp;
if (t_0 <= -2e-173) {
tmp = fma((-0.5 * (((M_m * D_m) * (M_m * D_m)) / (d * (4.0 * d)))), (h / l), 1.0) * t_1;
} else if (t_0 <= 1e-165) {
tmp = d / sqrt((l * h));
} else if (t_0 <= 5e+166) {
tmp = 1.0 * t_1;
} else {
tmp = pow((sqrt(l) * sqrt(h)), -1.0) * d;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = sqrt(Float64(Float64(d / l) * Float64(d / h))) tmp = 0.0 if (t_0 <= -2e-173) tmp = Float64(fma(Float64(-0.5 * Float64(Float64(Float64(M_m * D_m) * Float64(M_m * D_m)) / Float64(d * Float64(4.0 * d)))), Float64(h / l), 1.0) * t_1); elseif (t_0 <= 1e-165) tmp = Float64(d / sqrt(Float64(l * h))); elseif (t_0 <= 5e+166) tmp = Float64(1.0 * t_1); else tmp = Float64((Float64(sqrt(l) * sqrt(h)) ^ -1.0) * d); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -2e-173], N[(N[(N[(-0.5 * N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(d * N[(4.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[t$95$0, 1e-165], N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+166], N[(1.0 * t$95$1), $MachinePrecision], N[(N[Power[N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision] * d), $MachinePrecision]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-173}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 \cdot \frac{\left(M\_m \cdot D\_m\right) \cdot \left(M\_m \cdot D\_m\right)}{d \cdot \left(4 \cdot d\right)}, \frac{h}{\ell}, 1\right) \cdot t\_1\\
\mathbf{elif}\;t\_0 \leq 10^{-165}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+166}:\\
\;\;\;\;1 \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{\ell} \cdot \sqrt{h}\right)}^{-1} \cdot d\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -2.0000000000000001e-173Initial program 82.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6482.7
Applied rewrites64.4%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6463.3
Applied rewrites63.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6452.1
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
metadata-eval52.1
Applied rewrites52.1%
if -2.0000000000000001e-173 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 1e-165Initial program 67.2%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6467.1
Applied rewrites67.1%
Applied rewrites67.1%
Applied rewrites67.2%
if 1e-165 < (*.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.0000000000000002e166Initial program 99.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.4
Applied rewrites93.3%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6493.3
Applied rewrites93.3%
Taylor expanded in d around inf
Applied rewrites93.3%
if 5.0000000000000002e166 < (*.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 28.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6437.1
Applied rewrites37.1%
Applied rewrites37.1%
Applied rewrites37.7%
Final simplification57.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 (sqrt (* (/ d l) (/ d h))))
(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))))))
(if (<= t_1 -1e+118)
(* t_0 (* (* (/ (* (* M_m M_m) h) l) -0.125) (/ (/ (* D_m D_m) d) d)))
(if (<= t_1 1e-165)
(/ d (sqrt (* l h)))
(if (<= t_1 5e+166)
(* 1.0 t_0)
(* (pow (* (sqrt l) (sqrt h)) -1.0) d))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = sqrt(((d / l) * (d / h)));
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 tmp;
if (t_1 <= -1e+118) {
tmp = t_0 * (((((M_m * M_m) * h) / l) * -0.125) * (((D_m * D_m) / d) / d));
} else if (t_1 <= 1e-165) {
tmp = d / sqrt((l * h));
} else if (t_1 <= 5e+166) {
tmp = 1.0 * t_0;
} else {
tmp = pow((sqrt(l) * sqrt(h)), -1.0) * d;
}
return tmp;
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sqrt(((d / l) * (d / h)))
t_1 = (((d / h) ** (2.0d0 ** (-1.0d0))) * ((d / l) ** (2.0d0 ** (-1.0d0)))) * (1.0d0 - (((2.0d0 ** (-1.0d0)) * (((m_m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
if (t_1 <= (-1d+118)) then
tmp = t_0 * (((((m_m * m_m) * h) / l) * (-0.125d0)) * (((d_m * d_m) / d) / d))
else if (t_1 <= 1d-165) then
tmp = d / sqrt((l * h))
else if (t_1 <= 5d+166) then
tmp = 1.0d0 * t_0
else
tmp = ((sqrt(l) * sqrt(h)) ** (-1.0d0)) * d
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = Math.sqrt(((d / l) * (d / h)));
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 tmp;
if (t_1 <= -1e+118) {
tmp = t_0 * (((((M_m * M_m) * h) / l) * -0.125) * (((D_m * D_m) / d) / d));
} else if (t_1 <= 1e-165) {
tmp = d / Math.sqrt((l * h));
} else if (t_1 <= 5e+166) {
tmp = 1.0 * t_0;
} else {
tmp = Math.pow((Math.sqrt(l) * Math.sqrt(h)), -1.0) * d;
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = math.sqrt(((d / l) * (d / h))) 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))) tmp = 0 if t_1 <= -1e+118: tmp = t_0 * (((((M_m * M_m) * h) / l) * -0.125) * (((D_m * D_m) / d) / d)) elif t_1 <= 1e-165: tmp = d / math.sqrt((l * h)) elif t_1 <= 5e+166: tmp = 1.0 * t_0 else: tmp = math.pow((math.sqrt(l) * math.sqrt(h)), -1.0) * d return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = sqrt(Float64(Float64(d / l) * Float64(d / h))) 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)))) tmp = 0.0 if (t_1 <= -1e+118) tmp = Float64(t_0 * Float64(Float64(Float64(Float64(Float64(M_m * M_m) * h) / l) * -0.125) * Float64(Float64(Float64(D_m * D_m) / d) / d))); elseif (t_1 <= 1e-165) tmp = Float64(d / sqrt(Float64(l * h))); elseif (t_1 <= 5e+166) tmp = Float64(1.0 * t_0); else tmp = Float64((Float64(sqrt(l) * sqrt(h)) ^ -1.0) * d); end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = sqrt(((d / l) * (d / h)));
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)));
tmp = 0.0;
if (t_1 <= -1e+118)
tmp = t_0 * (((((M_m * M_m) * h) / l) * -0.125) * (((D_m * D_m) / d) / d));
elseif (t_1 <= 1e-165)
tmp = d / sqrt((l * h));
elseif (t_1 <= 5e+166)
tmp = 1.0 * t_0;
else
tmp = ((sqrt(l) * sqrt(h)) ^ -1.0) * d;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $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]}, If[LessEqual[t$95$1, -1e+118], N[(t$95$0 * N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision] * -0.125), $MachinePrecision] * N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-165], N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+166], N[(1.0 * t$95$0), $MachinePrecision], N[(N[Power[N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision] * d), $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} \cdot \frac{d}{h}}\\
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)\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+118}:\\
\;\;\;\;t\_0 \cdot \left(\left(\frac{\left(M\_m \cdot M\_m\right) \cdot h}{\ell} \cdot -0.125\right) \cdot \frac{\frac{D\_m \cdot D\_m}{d}}{d}\right)\\
\mathbf{elif}\;t\_1 \leq 10^{-165}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+166}:\\
\;\;\;\;1 \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{\ell} \cdot \sqrt{h}\right)}^{-1} \cdot d\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -9.99999999999999967e117Initial program 81.4%
Taylor expanded in d around 0
times-fracN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6457.3
Applied rewrites57.3%
Applied rewrites43.6%
if -9.99999999999999967e117 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 1e-165Initial program 76.2%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6448.9
Applied rewrites48.9%
Applied rewrites48.9%
Applied rewrites49.0%
if 1e-165 < (*.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.0000000000000002e166Initial program 99.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.4
Applied rewrites93.3%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6493.3
Applied rewrites93.3%
Taylor expanded in d around inf
Applied rewrites93.3%
if 5.0000000000000002e166 < (*.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 28.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6437.1
Applied rewrites37.1%
Applied rewrites37.1%
Applied rewrites37.7%
Final simplification53.7%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(*
(* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0))
(/ h l)))))
(t_1 (sqrt (* (/ d l) (/ d h)))))
(if (<= t_0 -2e-122)
(* (* (* h -0.125) (* (* (* M_m M_m) D_m) (/ D_m (* (* d d) l)))) t_1)
(if (<= t_0 1e-165)
(/ d (sqrt (* l h)))
(if (<= t_0 5e+166)
(* 1.0 t_1)
(* (pow (* (sqrt l) (sqrt h)) -1.0) d))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = sqrt(((d / l) * (d / h)));
double tmp;
if (t_0 <= -2e-122) {
tmp = ((h * -0.125) * (((M_m * M_m) * D_m) * (D_m / ((d * d) * l)))) * t_1;
} else if (t_0 <= 1e-165) {
tmp = d / sqrt((l * h));
} else if (t_0 <= 5e+166) {
tmp = 1.0 * t_1;
} else {
tmp = pow((sqrt(l) * sqrt(h)), -1.0) * d;
}
return tmp;
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (((d / h) ** (2.0d0 ** (-1.0d0))) * ((d / l) ** (2.0d0 ** (-1.0d0)))) * (1.0d0 - (((2.0d0 ** (-1.0d0)) * (((m_m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
t_1 = sqrt(((d / l) * (d / h)))
if (t_0 <= (-2d-122)) then
tmp = ((h * (-0.125d0)) * (((m_m * m_m) * d_m) * (d_m / ((d * d) * l)))) * t_1
else if (t_0 <= 1d-165) then
tmp = d / sqrt((l * h))
else if (t_0 <= 5d+166) then
tmp = 1.0d0 * t_1
else
tmp = ((sqrt(l) * sqrt(h)) ** (-1.0d0)) * d
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (Math.pow((d / h), Math.pow(2.0, -1.0)) * Math.pow((d / l), Math.pow(2.0, -1.0))) * (1.0 - ((Math.pow(2.0, -1.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = Math.sqrt(((d / l) * (d / h)));
double tmp;
if (t_0 <= -2e-122) {
tmp = ((h * -0.125) * (((M_m * M_m) * D_m) * (D_m / ((d * d) * l)))) * t_1;
} else if (t_0 <= 1e-165) {
tmp = d / Math.sqrt((l * h));
} else if (t_0 <= 5e+166) {
tmp = 1.0 * t_1;
} else {
tmp = Math.pow((Math.sqrt(l) * Math.sqrt(h)), -1.0) * d;
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = (math.pow((d / h), math.pow(2.0, -1.0)) * math.pow((d / l), math.pow(2.0, -1.0))) * (1.0 - ((math.pow(2.0, -1.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l))) t_1 = math.sqrt(((d / l) * (d / h))) tmp = 0 if t_0 <= -2e-122: tmp = ((h * -0.125) * (((M_m * M_m) * D_m) * (D_m / ((d * d) * l)))) * t_1 elif t_0 <= 1e-165: tmp = d / math.sqrt((l * h)) elif t_0 <= 5e+166: tmp = 1.0 * t_1 else: tmp = math.pow((math.sqrt(l) * math.sqrt(h)), -1.0) * d return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = sqrt(Float64(Float64(d / l) * Float64(d / h))) tmp = 0.0 if (t_0 <= -2e-122) tmp = Float64(Float64(Float64(h * -0.125) * Float64(Float64(Float64(M_m * M_m) * D_m) * Float64(D_m / Float64(Float64(d * d) * l)))) * t_1); elseif (t_0 <= 1e-165) tmp = Float64(d / sqrt(Float64(l * h))); elseif (t_0 <= 5e+166) tmp = Float64(1.0 * t_1); else tmp = Float64((Float64(sqrt(l) * sqrt(h)) ^ -1.0) * d); end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = (((d / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
t_1 = sqrt(((d / l) * (d / h)));
tmp = 0.0;
if (t_0 <= -2e-122)
tmp = ((h * -0.125) * (((M_m * M_m) * D_m) * (D_m / ((d * d) * l)))) * t_1;
elseif (t_0 <= 1e-165)
tmp = d / sqrt((l * h));
elseif (t_0 <= 5e+166)
tmp = 1.0 * t_1;
else
tmp = ((sqrt(l) * sqrt(h)) ^ -1.0) * d;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -2e-122], N[(N[(N[(h * -0.125), $MachinePrecision] * N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(D$95$m / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[t$95$0, 1e-165], N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+166], N[(1.0 * t$95$1), $MachinePrecision], N[(N[Power[N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision] * d), $MachinePrecision]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-122}:\\
\;\;\;\;\left(\left(h \cdot -0.125\right) \cdot \left(\left(\left(M\_m \cdot M\_m\right) \cdot D\_m\right) \cdot \frac{D\_m}{\left(d \cdot d\right) \cdot \ell}\right)\right) \cdot t\_1\\
\mathbf{elif}\;t\_0 \leq 10^{-165}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+166}:\\
\;\;\;\;1 \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{\ell} \cdot \sqrt{h}\right)}^{-1} \cdot d\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -2.00000000000000012e-122Initial program 82.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6482.5
Applied rewrites65.1%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6464.0
Applied rewrites64.0%
Taylor expanded in d around 0
associate-*r/N/A
associate-*r*N/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6443.3
Applied rewrites43.3%
if -2.00000000000000012e-122 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 1e-165Initial program 69.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6463.7
Applied rewrites63.7%
Applied rewrites63.7%
Applied rewrites63.7%
if 1e-165 < (*.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.0000000000000002e166Initial program 99.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.4
Applied rewrites93.3%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6493.3
Applied rewrites93.3%
Taylor expanded in d around inf
Applied rewrites93.3%
if 5.0000000000000002e166 < (*.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 28.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6437.1
Applied rewrites37.1%
Applied rewrites37.1%
Applied rewrites37.7%
Final simplification54.5%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(*
(* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0))
(/ h l))))))
(if (<= t_0 5e+218)
(*
(*
(fma (* -0.5 (pow (/ (* M_m D_m) (* d 2.0)) 2.0)) (/ h l) 1.0)
(sqrt (/ d h)))
(sqrt (/ d l)))
(if (<= t_0 INFINITY)
(* (/ (sqrt (pow l -1.0)) (sqrt h)) d)
(fma
(* (/ (sqrt h) (pow l 1.5)) (* (* (* (/ D_m d) D_m) -0.125) M_m))
M_m
(/ 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+218) {
tmp = (fma((-0.5 * pow(((M_m * D_m) / (d * 2.0)), 2.0)), (h / l), 1.0) * sqrt((d / h))) * sqrt((d / l));
} else if (t_0 <= ((double) INFINITY)) {
tmp = (sqrt(pow(l, -1.0)) / sqrt(h)) * d;
} else {
tmp = fma(((sqrt(h) / pow(l, 1.5)) * ((((D_m / d) * D_m) * -0.125) * M_m)), M_m, (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+218) tmp = Float64(Float64(fma(Float64(-0.5 * (Float64(Float64(M_m * D_m) / Float64(d * 2.0)) ^ 2.0)), Float64(h / l), 1.0) * sqrt(Float64(d / h))) * sqrt(Float64(d / l))); elseif (t_0 <= Inf) tmp = Float64(Float64(sqrt((l ^ -1.0)) / sqrt(h)) * d); else tmp = fma(Float64(Float64(sqrt(h) / (l ^ 1.5)) * Float64(Float64(Float64(Float64(D_m / d) * D_m) * -0.125) * M_m)), M_m, 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+218], N[(N[(N[(N[(-0.5 * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $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[Power[l, -1.0], $MachinePrecision]], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision], N[(N[(N[(N[Sqrt[h], $MachinePrecision] / N[Power[l, 1.5], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(D$95$m / d), $MachinePrecision] * D$95$m), $MachinePrecision] * -0.125), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] * M$95$m + 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^{+218}:\\
\;\;\;\;\left(\mathsf{fma}\left(-0.5 \cdot {\left(\frac{M\_m \cdot D\_m}{d \cdot 2}\right)}^{2}, \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{\sqrt{{\ell}^{-1}}}{\sqrt{h}} \cdot d\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \left(\left(\left(\frac{D\_m}{d} \cdot D\_m\right) \cdot -0.125\right) \cdot M\_m\right), M\_m, \frac{d}{\sqrt{\ell \cdot h}}\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 4.99999999999999983e218Initial program 87.4%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites86.8%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6487.4
Applied rewrites87.4%
if 4.99999999999999983e218 < (*.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 53.7%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6464.4
Applied rewrites64.4%
Applied rewrites66.6%
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%
Taylor expanded in d around 0
Applied rewrites19.2%
Applied rewrites19.4%
Applied rewrites31.6%
Final simplification74.0%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (* (/ (/ D_m d) 2.0) M_m))
(t_1
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(*
(* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0))
(/ h l))))))
(if (<= t_1 5e+218)
(*
(* (fma (* t_0 (* t_0 -0.5)) (/ h l) 1.0) (sqrt (/ d h)))
(sqrt (/ d l)))
(if (<= t_1 INFINITY)
(* (/ (sqrt (pow l -1.0)) (sqrt h)) d)
(fma
(* (/ (sqrt h) (pow l 1.5)) (* (* (* (/ D_m d) D_m) -0.125) M_m))
M_m
(/ 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 = ((D_m / d) / 2.0) * M_m;
double t_1 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_1 <= 5e+218) {
tmp = (fma((t_0 * (t_0 * -0.5)), (h / l), 1.0) * sqrt((d / h))) * sqrt((d / l));
} else if (t_1 <= ((double) INFINITY)) {
tmp = (sqrt(pow(l, -1.0)) / sqrt(h)) * d;
} else {
tmp = fma(((sqrt(h) / pow(l, 1.5)) * ((((D_m / d) * D_m) * -0.125) * M_m)), M_m, (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_m / d) / 2.0) * M_m) t_1 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_1 <= 5e+218) tmp = Float64(Float64(fma(Float64(t_0 * Float64(t_0 * -0.5)), Float64(h / l), 1.0) * sqrt(Float64(d / h))) * sqrt(Float64(d / l))); elseif (t_1 <= Inf) tmp = Float64(Float64(sqrt((l ^ -1.0)) / sqrt(h)) * d); else tmp = fma(Float64(Float64(sqrt(h) / (l ^ 1.5)) * Float64(Float64(Float64(Float64(D_m / d) * D_m) * -0.125) * M_m)), M_m, 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[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 5e+218], N[(N[(N[(N[(t$95$0 * N[(t$95$0 * -0.5), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(N[Sqrt[N[Power[l, -1.0], $MachinePrecision]], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision], N[(N[(N[(N[Sqrt[h], $MachinePrecision] / N[Power[l, 1.5], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(D$95$m / d), $MachinePrecision] * D$95$m), $MachinePrecision] * -0.125), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] * M$95$m + 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 := \frac{\frac{D\_m}{d}}{2} \cdot M\_m\\
t_1 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{+218}:\\
\;\;\;\;\left(\mathsf{fma}\left(t\_0 \cdot \left(t\_0 \cdot -0.5\right), \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\sqrt{{\ell}^{-1}}}{\sqrt{h}} \cdot d\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \left(\left(\left(\frac{D\_m}{d} \cdot D\_m\right) \cdot -0.125\right) \cdot M\_m\right), M\_m, \frac{d}{\sqrt{\ell \cdot h}}\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 4.99999999999999983e218Initial program 87.4%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites86.8%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6486.2
Applied rewrites86.8%
if 4.99999999999999983e218 < (*.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 53.7%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6464.4
Applied rewrites64.4%
Applied rewrites66.6%
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%
Taylor expanded in d around 0
Applied rewrites19.2%
Applied rewrites19.4%
Applied rewrites31.6%
Final simplification73.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 (* (/ (/ D_m d) 2.0) M_m))
(t_1
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(*
(* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0))
(/ h l))))))
(if (<= t_1 5e+218)
(*
(* (fma (* t_0 (* t_0 -0.5)) (/ h l) 1.0) (sqrt (/ d h)))
(sqrt (/ d l)))
(if (<= t_1 INFINITY)
(* (/ (sqrt (pow l -1.0)) (sqrt h)) d)
(fma
(* (/ (sqrt h) (pow l 1.5)) M_m)
(* (* (* (/ D_m d) D_m) -0.125) M_m)
(/ 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 = ((D_m / d) / 2.0) * M_m;
double t_1 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_1 <= 5e+218) {
tmp = (fma((t_0 * (t_0 * -0.5)), (h / l), 1.0) * sqrt((d / h))) * sqrt((d / l));
} else if (t_1 <= ((double) INFINITY)) {
tmp = (sqrt(pow(l, -1.0)) / sqrt(h)) * d;
} else {
tmp = fma(((sqrt(h) / pow(l, 1.5)) * M_m), ((((D_m / d) * D_m) * -0.125) * M_m), (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_m / d) / 2.0) * M_m) t_1 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_1 <= 5e+218) tmp = Float64(Float64(fma(Float64(t_0 * Float64(t_0 * -0.5)), Float64(h / l), 1.0) * sqrt(Float64(d / h))) * sqrt(Float64(d / l))); elseif (t_1 <= Inf) tmp = Float64(Float64(sqrt((l ^ -1.0)) / sqrt(h)) * d); else tmp = fma(Float64(Float64(sqrt(h) / (l ^ 1.5)) * M_m), Float64(Float64(Float64(Float64(D_m / d) * D_m) * -0.125) * M_m), 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[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 5e+218], N[(N[(N[(N[(t$95$0 * N[(t$95$0 * -0.5), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(N[Sqrt[N[Power[l, -1.0], $MachinePrecision]], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision], N[(N[(N[(N[Sqrt[h], $MachinePrecision] / N[Power[l, 1.5], $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(N[(N[(N[(D$95$m / d), $MachinePrecision] * D$95$m), $MachinePrecision] * -0.125), $MachinePrecision] * M$95$m), $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 := \frac{\frac{D\_m}{d}}{2} \cdot M\_m\\
t_1 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{+218}:\\
\;\;\;\;\left(\mathsf{fma}\left(t\_0 \cdot \left(t\_0 \cdot -0.5\right), \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\sqrt{{\ell}^{-1}}}{\sqrt{h}} \cdot d\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot M\_m, \left(\left(\frac{D\_m}{d} \cdot D\_m\right) \cdot -0.125\right) \cdot M\_m, \frac{d}{\sqrt{\ell \cdot h}}\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 4.99999999999999983e218Initial program 87.4%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites86.8%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6486.2
Applied rewrites86.8%
if 4.99999999999999983e218 < (*.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 53.7%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6464.4
Applied rewrites64.4%
Applied rewrites66.6%
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%
Taylor expanded in d around 0
Applied rewrites19.2%
Applied rewrites19.4%
Applied rewrites31.5%
Final simplification73.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 (* (/ (/ D_m d) 2.0) M_m)))
(if (<=
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l))))
5e+218)
(*
(* (fma (* t_0 (* t_0 -0.5)) (/ h l) 1.0) (sqrt (/ d h)))
(sqrt (/ d l)))
(* (/ (sqrt (pow l -1.0)) (sqrt h)) d))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = ((D_m / d) / 2.0) * M_m;
double tmp;
if (((pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 5e+218) {
tmp = (fma((t_0 * (t_0 * -0.5)), (h / l), 1.0) * sqrt((d / h))) * sqrt((d / l));
} else {
tmp = (sqrt(pow(l, -1.0)) / sqrt(h)) * d;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(Float64(D_m / d) / 2.0) * M_m) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= 5e+218) tmp = Float64(Float64(fma(Float64(t_0 * Float64(t_0 * -0.5)), Float64(h / l), 1.0) * sqrt(Float64(d / h))) * sqrt(Float64(d / l))); else tmp = Float64(Float64(sqrt((l ^ -1.0)) / sqrt(h)) * d); 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[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision]}, If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+218], N[(N[(N[(N[(t$95$0 * N[(t$95$0 * -0.5), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[Power[l, -1.0], $MachinePrecision]], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{D\_m}{d}}{2} \cdot M\_m\\
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq 5 \cdot 10^{+218}:\\
\;\;\;\;\left(\mathsf{fma}\left(t\_0 \cdot \left(t\_0 \cdot -0.5\right), \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{{\ell}^{-1}}}{\sqrt{h}} \cdot d\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 4.99999999999999983e218Initial program 87.4%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites86.8%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6486.2
Applied rewrites86.8%
if 4.99999999999999983e218 < (*.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 25.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6437.2
Applied rewrites37.2%
Applied rewrites38.0%
Final simplification70.0%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (* (/ (/ D_m d) 2.0) M_m)))
(if (<=
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l))))
5e+218)
(*
(* (fma (* t_0 (* t_0 -0.5)) (/ h l) 1.0) (sqrt (/ d h)))
(sqrt (/ d l)))
(* (pow (* (sqrt l) (sqrt h)) -1.0) d))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = ((D_m / d) / 2.0) * M_m;
double tmp;
if (((pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 5e+218) {
tmp = (fma((t_0 * (t_0 * -0.5)), (h / l), 1.0) * sqrt((d / h))) * sqrt((d / l));
} else {
tmp = pow((sqrt(l) * sqrt(h)), -1.0) * d;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(Float64(D_m / d) / 2.0) * M_m) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= 5e+218) tmp = Float64(Float64(fma(Float64(t_0 * Float64(t_0 * -0.5)), Float64(h / l), 1.0) * sqrt(Float64(d / h))) * sqrt(Float64(d / l))); else tmp = Float64((Float64(sqrt(l) * sqrt(h)) ^ -1.0) * d); 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[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision]}, If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+218], N[(N[(N[(N[(t$95$0 * N[(t$95$0 * -0.5), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision] * d), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{D\_m}{d}}{2} \cdot M\_m\\
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq 5 \cdot 10^{+218}:\\
\;\;\;\;\left(\mathsf{fma}\left(t\_0 \cdot \left(t\_0 \cdot -0.5\right), \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{\ell} \cdot \sqrt{h}\right)}^{-1} \cdot d\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 4.99999999999999983e218Initial program 87.4%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites86.8%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6486.2
Applied rewrites86.8%
if 4.99999999999999983e218 < (*.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 25.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6437.2
Applied rewrites37.2%
Applied rewrites37.2%
Applied rewrites37.8%
Final simplification70.0%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<=
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l))))
5e+166)
(*
(fma (* -0.5 (/ (* (* M_m D_m) (* M_m (/ D_m (* 4.0 d)))) d)) (/ h l) 1.0)
(sqrt (* (/ d l) (/ d h))))
(* (pow (* (sqrt l) (sqrt h)) -1.0) d)))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (((pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 5e+166) {
tmp = fma((-0.5 * (((M_m * D_m) * (M_m * (D_m / (4.0 * d)))) / d)), (h / l), 1.0) * sqrt(((d / l) * (d / h)));
} else {
tmp = pow((sqrt(l) * sqrt(h)), -1.0) * d;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= 5e+166) tmp = Float64(fma(Float64(-0.5 * Float64(Float64(Float64(M_m * D_m) * Float64(M_m * Float64(D_m / Float64(4.0 * d)))) / d)), Float64(h / l), 1.0) * sqrt(Float64(Float64(d / l) * Float64(d / h)))); else tmp = Float64((Float64(sqrt(l) * sqrt(h)) ^ -1.0) * d); 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[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+166], N[(N[(N[(-0.5 * N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(M$95$m * N[(D$95$m / N[(4.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision] * d), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq 5 \cdot 10^{+166}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 \cdot \frac{\left(M\_m \cdot D\_m\right) \cdot \left(M\_m \cdot \frac{D\_m}{4 \cdot d}\right)}{d}, \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{\ell} \cdot \sqrt{h}\right)}^{-1} \cdot d\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 5.0000000000000002e166Initial program 87.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6487.2
Applied rewrites71.3%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6470.7
Applied rewrites70.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites70.7%
if 5.0000000000000002e166 < (*.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 28.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6437.1
Applied rewrites37.1%
Applied rewrites37.1%
Applied rewrites37.7%
Final simplification59.0%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (* (/ (/ D_m d) 2.0) M_m)))
(if (<= d 4.3e-308)
(*
(*
(fma (* -0.5 (pow (/ (* M_m D_m) (* d 2.0)) 2.0)) (/ h l) 1.0)
(sqrt (/ d h)))
(sqrt (/ d l)))
(if (<= d 7.2e+165)
(*
(* (/ (sqrt d) (sqrt h)) (pow (/ d l) (pow 2.0 -1.0)))
(- 1.0 (/ (* t_0 (* t_0 (* 0.5 h))) l)))
(* (/ (sqrt (pow l -1.0)) (sqrt h)) d)))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = ((D_m / d) / 2.0) * M_m;
double tmp;
if (d <= 4.3e-308) {
tmp = (fma((-0.5 * pow(((M_m * D_m) / (d * 2.0)), 2.0)), (h / l), 1.0) * sqrt((d / h))) * sqrt((d / l));
} else if (d <= 7.2e+165) {
tmp = ((sqrt(d) / sqrt(h)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((t_0 * (t_0 * (0.5 * h))) / l));
} else {
tmp = (sqrt(pow(l, -1.0)) / sqrt(h)) * d;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(Float64(D_m / d) / 2.0) * M_m) tmp = 0.0 if (d <= 4.3e-308) tmp = Float64(Float64(fma(Float64(-0.5 * (Float64(Float64(M_m * D_m) / Float64(d * 2.0)) ^ 2.0)), Float64(h / l), 1.0) * sqrt(Float64(d / h))) * sqrt(Float64(d / l))); elseif (d <= 7.2e+165) tmp = Float64(Float64(Float64(sqrt(d) / sqrt(h)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * Float64(0.5 * h))) / l))); else tmp = Float64(Float64(sqrt((l ^ -1.0)) / sqrt(h)) * d); 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[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision]}, If[LessEqual[d, 4.3e-308], N[(N[(N[(N[(-0.5 * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7.2e+165], N[(N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * N[(0.5 * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[Power[l, -1.0], $MachinePrecision]], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{D\_m}{d}}{2} \cdot M\_m\\
\mathbf{if}\;d \leq 4.3 \cdot 10^{-308}:\\
\;\;\;\;\left(\mathsf{fma}\left(-0.5 \cdot {\left(\frac{M\_m \cdot D\_m}{d \cdot 2}\right)}^{2}, \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{elif}\;d \leq 7.2 \cdot 10^{+165}:\\
\;\;\;\;\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \frac{t\_0 \cdot \left(t\_0 \cdot \left(0.5 \cdot h\right)\right)}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{{\ell}^{-1}}}{\sqrt{h}} \cdot d\\
\end{array}
\end{array}
if d < 4.3000000000000002e-308Initial program 71.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites72.0%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6471.9
Applied rewrites71.9%
if 4.3000000000000002e-308 < d < 7.1999999999999996e165Initial program 59.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6460.0
lift-/.f64N/A
metadata-eval60.0
Applied rewrites60.0%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6460.9
Applied rewrites60.9%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lift-/.f64N/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites61.9%
lift-/.f64N/A
metadata-eval61.9
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6475.1
Applied rewrites75.1%
if 7.1999999999999996e165 < d Initial program 68.2%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6477.4
Applied rewrites77.4%
Applied rewrites94.6%
Final simplification76.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 (* (/ D_m d) M_m))
(t_1
(*
(* (- h) (- (* (/ 0.125 l) (* t_0 t_0)) (pow h -1.0)))
(sqrt (* (/ d l) (/ d h))))))
(if (<= d -1.08e-244)
t_1
(if (<= d 1.05e-87)
(*
(*
(fma (* (* -0.125 (* D_m D_m)) (/ (/ (* M_m M_m) d) d)) (/ h l) 1.0)
(sqrt (/ d h)))
(sqrt (/ d l)))
(if (<= d 6.8e+167) t_1 (/ d (* (sqrt l) (sqrt h))))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (D_m / d) * M_m;
double t_1 = (-h * (((0.125 / l) * (t_0 * t_0)) - pow(h, -1.0))) * sqrt(((d / l) * (d / h)));
double tmp;
if (d <= -1.08e-244) {
tmp = t_1;
} else if (d <= 1.05e-87) {
tmp = (fma(((-0.125 * (D_m * D_m)) * (((M_m * M_m) / d) / d)), (h / l), 1.0) * sqrt((d / h))) * sqrt((d / l));
} else if (d <= 6.8e+167) {
tmp = t_1;
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(D_m / d) * M_m) t_1 = Float64(Float64(Float64(-h) * Float64(Float64(Float64(0.125 / l) * Float64(t_0 * t_0)) - (h ^ -1.0))) * sqrt(Float64(Float64(d / l) * Float64(d / h)))) tmp = 0.0 if (d <= -1.08e-244) tmp = t_1; elseif (d <= 1.05e-87) tmp = Float64(Float64(fma(Float64(Float64(-0.125 * Float64(D_m * D_m)) * Float64(Float64(Float64(M_m * M_m) / d) / d)), Float64(h / l), 1.0) * sqrt(Float64(d / h))) * sqrt(Float64(d / l))); elseif (d <= 6.8e+167) tmp = t_1; else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(D$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(N[((-h) * N[(N[(N[(0.125 / l), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] - N[Power[h, -1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.08e-244], t$95$1, If[LessEqual[d, 1.05e-87], N[(N[(N[(N[(N[(-0.125 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 6.8e+167], t$95$1, N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{D\_m}{d} \cdot M\_m\\
t_1 := \left(\left(-h\right) \cdot \left(\frac{0.125}{\ell} \cdot \left(t\_0 \cdot t\_0\right) - {h}^{-1}\right)\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{if}\;d \leq -1.08 \cdot 10^{-244}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq 1.05 \cdot 10^{-87}:\\
\;\;\;\;\left(\mathsf{fma}\left(\left(-0.125 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot \frac{\frac{M\_m \cdot M\_m}{d}}{d}, \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{elif}\;d \leq 6.8 \cdot 10^{+167}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if d < -1.07999999999999996e-244 or 1.05000000000000004e-87 < d < 6.8000000000000001e167Initial program 76.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6476.2
Applied rewrites65.3%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6464.6
Applied rewrites64.6%
Taylor expanded in h around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
Applied rewrites67.2%
if -1.07999999999999996e-244 < d < 1.05000000000000004e-87Initial program 44.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites44.8%
Taylor expanded in d around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6437.4
Applied rewrites37.4%
if 6.8000000000000001e167 < d Initial program 67.4%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6479.3
Applied rewrites79.3%
Applied rewrites79.3%
Applied rewrites79.3%
Applied rewrites94.4%
Final simplification62.9%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (/ d l))))
(if (<= d 4.3e-308)
(*
(*
(fma (* -0.5 (pow (/ (* M_m D_m) (* d 2.0)) 2.0)) (/ h l) 1.0)
(sqrt (/ d h)))
t_0)
(if (<= d 7.1e+165)
(/
(*
(sqrt d)
(*
(fma (* (/ h l) -0.5) (pow (* (/ (/ D_m d) 2.0) M_m) 2.0) 1.0)
t_0))
(sqrt h))
(* (/ (sqrt (pow l -1.0)) (sqrt h)) d)))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((d / l));
double tmp;
if (d <= 4.3e-308) {
tmp = (fma((-0.5 * pow(((M_m * D_m) / (d * 2.0)), 2.0)), (h / l), 1.0) * sqrt((d / h))) * t_0;
} else if (d <= 7.1e+165) {
tmp = (sqrt(d) * (fma(((h / l) * -0.5), pow((((D_m / d) / 2.0) * M_m), 2.0), 1.0) * t_0)) / sqrt(h);
} else {
tmp = (sqrt(pow(l, -1.0)) / sqrt(h)) * d;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = sqrt(Float64(d / l)) tmp = 0.0 if (d <= 4.3e-308) tmp = Float64(Float64(fma(Float64(-0.5 * (Float64(Float64(M_m * D_m) / Float64(d * 2.0)) ^ 2.0)), Float64(h / l), 1.0) * sqrt(Float64(d / h))) * t_0); elseif (d <= 7.1e+165) tmp = Float64(Float64(sqrt(d) * Float64(fma(Float64(Float64(h / l) * -0.5), (Float64(Float64(Float64(D_m / d) / 2.0) * M_m) ^ 2.0), 1.0) * t_0)) / sqrt(h)); else tmp = Float64(Float64(sqrt((l ^ -1.0)) / sqrt(h)) * d); 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[d, 4.3e-308], N[(N[(N[(N[(-0.5 * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[d, 7.1e+165], N[(N[(N[Sqrt[d], $MachinePrecision] * N[(N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision], 2.0], $MachinePrecision] + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[Power[l, -1.0], $MachinePrecision]], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * d), $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}\;d \leq 4.3 \cdot 10^{-308}:\\
\;\;\;\;\left(\mathsf{fma}\left(-0.5 \cdot {\left(\frac{M\_m \cdot D\_m}{d \cdot 2}\right)}^{2}, \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot t\_0\\
\mathbf{elif}\;d \leq 7.1 \cdot 10^{+165}:\\
\;\;\;\;\frac{\sqrt{d} \cdot \left(\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{\frac{D\_m}{d}}{2} \cdot M\_m\right)}^{2}, 1\right) \cdot t\_0\right)}{\sqrt{h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{{\ell}^{-1}}}{\sqrt{h}} \cdot d\\
\end{array}
\end{array}
if d < 4.3000000000000002e-308Initial program 71.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites72.0%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6471.9
Applied rewrites71.9%
if 4.3000000000000002e-308 < d < 7.09999999999999976e165Initial program 59.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites58.9%
Applied rewrites71.4%
if 7.09999999999999976e165 < d Initial program 68.2%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6477.4
Applied rewrites77.4%
Applied rewrites94.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 (* (/ M_m d) D_m)))
(if (<= d -1.04e-244)
(*
(fma (* -0.5 (/ (* t_0 t_0) 4.0)) (/ h l) 1.0)
(sqrt (* (/ d l) (/ d h))))
(if (<= d 4.6e+64)
(*
(*
(fma (* (* -0.125 (* D_m D_m)) (/ (/ (* M_m M_m) d) d)) (/ h l) 1.0)
(sqrt (/ d h)))
(sqrt (/ d l)))
(* (pow (* (sqrt l) (sqrt h)) -1.0) d)))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (M_m / d) * D_m;
double tmp;
if (d <= -1.04e-244) {
tmp = fma((-0.5 * ((t_0 * t_0) / 4.0)), (h / l), 1.0) * sqrt(((d / l) * (d / h)));
} else if (d <= 4.6e+64) {
tmp = (fma(((-0.125 * (D_m * D_m)) * (((M_m * M_m) / d) / d)), (h / l), 1.0) * sqrt((d / h))) * sqrt((d / l));
} else {
tmp = pow((sqrt(l) * sqrt(h)), -1.0) * d;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(M_m / d) * D_m) tmp = 0.0 if (d <= -1.04e-244) tmp = Float64(fma(Float64(-0.5 * Float64(Float64(t_0 * t_0) / 4.0)), Float64(h / l), 1.0) * sqrt(Float64(Float64(d / l) * Float64(d / h)))); elseif (d <= 4.6e+64) tmp = Float64(Float64(fma(Float64(Float64(-0.125 * Float64(D_m * D_m)) * Float64(Float64(Float64(M_m * M_m) / d) / d)), Float64(h / l), 1.0) * sqrt(Float64(d / h))) * sqrt(Float64(d / l))); else tmp = Float64((Float64(sqrt(l) * sqrt(h)) ^ -1.0) * d); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(M$95$m / d), $MachinePrecision] * D$95$m), $MachinePrecision]}, If[LessEqual[d, -1.04e-244], N[(N[(N[(-0.5 * N[(N[(t$95$0 * t$95$0), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.6e+64], N[(N[(N[(N[(N[(-0.125 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision] * d), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{M\_m}{d} \cdot D\_m\\
\mathbf{if}\;d \leq -1.04 \cdot 10^{-244}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 \cdot \frac{t\_0 \cdot t\_0}{4}, \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{elif}\;d \leq 4.6 \cdot 10^{+64}:\\
\;\;\;\;\left(\mathsf{fma}\left(\left(-0.125 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot \frac{\frac{M\_m \cdot M\_m}{d}}{d}, \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{\ell} \cdot \sqrt{h}\right)}^{-1} \cdot d\\
\end{array}
\end{array}
if d < -1.04000000000000003e-244Initial program 75.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.5
Applied rewrites64.7%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval64.7
Applied rewrites64.7%
if -1.04000000000000003e-244 < d < 4.6e64Initial program 57.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites57.0%
Taylor expanded in d around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6446.2
Applied rewrites46.2%
if 4.6e64 < d Initial program 67.0%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6467.8
Applied rewrites67.8%
Applied rewrites67.9%
Applied rewrites84.2%
Final simplification61.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
(if (<= d -1.04e-244)
(*
(fma
(* -0.5 (/ (* (/ (* M_m D_m) d) (* D_m M_m)) (* 2.0 (* d 2.0))))
(/ h l)
1.0)
(sqrt (* (/ d l) (/ d h))))
(if (<= d 4.6e+64)
(*
(*
(fma (* (* -0.125 (* D_m D_m)) (/ (/ (* M_m M_m) d) d)) (/ h l) 1.0)
(sqrt (/ d h)))
(sqrt (/ d l)))
(* (pow (* (sqrt l) (sqrt h)) -1.0) d))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (d <= -1.04e-244) {
tmp = fma((-0.5 * ((((M_m * D_m) / d) * (D_m * M_m)) / (2.0 * (d * 2.0)))), (h / l), 1.0) * sqrt(((d / l) * (d / h)));
} else if (d <= 4.6e+64) {
tmp = (fma(((-0.125 * (D_m * D_m)) * (((M_m * M_m) / d) / d)), (h / l), 1.0) * sqrt((d / h))) * sqrt((d / l));
} else {
tmp = pow((sqrt(l) * sqrt(h)), -1.0) * d;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (d <= -1.04e-244) tmp = Float64(fma(Float64(-0.5 * Float64(Float64(Float64(Float64(M_m * D_m) / d) * Float64(D_m * M_m)) / Float64(2.0 * Float64(d * 2.0)))), Float64(h / l), 1.0) * sqrt(Float64(Float64(d / l) * Float64(d / h)))); elseif (d <= 4.6e+64) tmp = Float64(Float64(fma(Float64(Float64(-0.125 * Float64(D_m * D_m)) * Float64(Float64(Float64(M_m * M_m) / d) / d)), Float64(h / l), 1.0) * sqrt(Float64(d / h))) * sqrt(Float64(d / l))); else tmp = Float64((Float64(sqrt(l) * sqrt(h)) ^ -1.0) * d); 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[d, -1.04e-244], N[(N[(N[(-0.5 * N[(N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision] * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] / N[(2.0 * N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.6e+64], N[(N[(N[(N[(N[(-0.125 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision] * d), $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}\;d \leq -1.04 \cdot 10^{-244}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 \cdot \frac{\frac{M\_m \cdot D\_m}{d} \cdot \left(D\_m \cdot M\_m\right)}{2 \cdot \left(d \cdot 2\right)}, \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{elif}\;d \leq 4.6 \cdot 10^{+64}:\\
\;\;\;\;\left(\mathsf{fma}\left(\left(-0.125 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot \frac{\frac{M\_m \cdot M\_m}{d}}{d}, \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{\ell} \cdot \sqrt{h}\right)}^{-1} \cdot d\\
\end{array}
\end{array}
if d < -1.04000000000000003e-244Initial program 75.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.5
Applied rewrites64.7%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6463.6
Applied rewrites63.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6463.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6463.7
Applied rewrites63.7%
if -1.04000000000000003e-244 < d < 4.6e64Initial program 57.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites57.0%
Taylor expanded in d around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6446.2
Applied rewrites46.2%
if 4.6e64 < d Initial program 67.0%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6467.8
Applied rewrites67.8%
Applied rewrites67.9%
Applied rewrites84.2%
Final simplification61.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
(if (<= d -1.04e-244)
(*
(fma
(* -0.5 (/ (* (* (/ M_m d) D_m) (* D_m M_m)) (* 2.0 (* d 2.0))))
(/ h l)
1.0)
(sqrt (* (/ d l) (/ d h))))
(if (<= d 4.6e+64)
(*
(*
(fma (* (* -0.125 (* D_m D_m)) (/ (/ (* M_m M_m) d) d)) (/ h l) 1.0)
(sqrt (/ d h)))
(sqrt (/ d l)))
(* (pow (* (sqrt l) (sqrt h)) -1.0) d))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (d <= -1.04e-244) {
tmp = fma((-0.5 * ((((M_m / d) * D_m) * (D_m * M_m)) / (2.0 * (d * 2.0)))), (h / l), 1.0) * sqrt(((d / l) * (d / h)));
} else if (d <= 4.6e+64) {
tmp = (fma(((-0.125 * (D_m * D_m)) * (((M_m * M_m) / d) / d)), (h / l), 1.0) * sqrt((d / h))) * sqrt((d / l));
} else {
tmp = pow((sqrt(l) * sqrt(h)), -1.0) * d;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (d <= -1.04e-244) tmp = Float64(fma(Float64(-0.5 * Float64(Float64(Float64(Float64(M_m / d) * D_m) * Float64(D_m * M_m)) / Float64(2.0 * Float64(d * 2.0)))), Float64(h / l), 1.0) * sqrt(Float64(Float64(d / l) * Float64(d / h)))); elseif (d <= 4.6e+64) tmp = Float64(Float64(fma(Float64(Float64(-0.125 * Float64(D_m * D_m)) * Float64(Float64(Float64(M_m * M_m) / d) / d)), Float64(h / l), 1.0) * sqrt(Float64(d / h))) * sqrt(Float64(d / l))); else tmp = Float64((Float64(sqrt(l) * sqrt(h)) ^ -1.0) * d); 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[d, -1.04e-244], N[(N[(N[(-0.5 * N[(N[(N[(N[(M$95$m / d), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] / N[(2.0 * N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.6e+64], N[(N[(N[(N[(N[(-0.125 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision] * d), $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}\;d \leq -1.04 \cdot 10^{-244}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 \cdot \frac{\left(\frac{M\_m}{d} \cdot D\_m\right) \cdot \left(D\_m \cdot M\_m\right)}{2 \cdot \left(d \cdot 2\right)}, \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{elif}\;d \leq 4.6 \cdot 10^{+64}:\\
\;\;\;\;\left(\mathsf{fma}\left(\left(-0.125 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot \frac{\frac{M\_m \cdot M\_m}{d}}{d}, \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{\ell} \cdot \sqrt{h}\right)}^{-1} \cdot d\\
\end{array}
\end{array}
if d < -1.04000000000000003e-244Initial program 75.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.5
Applied rewrites64.7%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6463.6
Applied rewrites63.6%
if -1.04000000000000003e-244 < d < 4.6e64Initial program 57.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites57.0%
Taylor expanded in d around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6446.2
Applied rewrites46.2%
if 4.6e64 < d Initial program 67.0%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6467.8
Applied rewrites67.8%
Applied rewrites67.9%
Applied rewrites84.2%
Final simplification61.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
(if (<= d -3.1e-11)
(*
(fma (* -0.5 (/ (* (* M_m D_m) (* M_m (/ D_m (* 4.0 d)))) d)) (/ h l) 1.0)
(sqrt (* (/ d l) (/ d h))))
(if (<= d 4.6e+64)
(*
(*
(fma (* (* -0.125 (* D_m D_m)) (/ (/ (* M_m M_m) d) d)) (/ h l) 1.0)
(sqrt (/ d h)))
(sqrt (/ d l)))
(* (pow (* (sqrt l) (sqrt h)) -1.0) d))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (d <= -3.1e-11) {
tmp = fma((-0.5 * (((M_m * D_m) * (M_m * (D_m / (4.0 * d)))) / d)), (h / l), 1.0) * sqrt(((d / l) * (d / h)));
} else if (d <= 4.6e+64) {
tmp = (fma(((-0.125 * (D_m * D_m)) * (((M_m * M_m) / d) / d)), (h / l), 1.0) * sqrt((d / h))) * sqrt((d / l));
} else {
tmp = pow((sqrt(l) * sqrt(h)), -1.0) * d;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (d <= -3.1e-11) tmp = Float64(fma(Float64(-0.5 * Float64(Float64(Float64(M_m * D_m) * Float64(M_m * Float64(D_m / Float64(4.0 * d)))) / d)), Float64(h / l), 1.0) * sqrt(Float64(Float64(d / l) * Float64(d / h)))); elseif (d <= 4.6e+64) tmp = Float64(Float64(fma(Float64(Float64(-0.125 * Float64(D_m * D_m)) * Float64(Float64(Float64(M_m * M_m) / d) / d)), Float64(h / l), 1.0) * sqrt(Float64(d / h))) * sqrt(Float64(d / l))); else tmp = Float64((Float64(sqrt(l) * sqrt(h)) ^ -1.0) * d); 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[d, -3.1e-11], N[(N[(N[(-0.5 * N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(M$95$m * N[(D$95$m / N[(4.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.6e+64], N[(N[(N[(N[(N[(-0.125 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision] * d), $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}\;d \leq -3.1 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 \cdot \frac{\left(M\_m \cdot D\_m\right) \cdot \left(M\_m \cdot \frac{D\_m}{4 \cdot d}\right)}{d}, \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{elif}\;d \leq 4.6 \cdot 10^{+64}:\\
\;\;\;\;\left(\mathsf{fma}\left(\left(-0.125 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot \frac{\frac{M\_m \cdot M\_m}{d}}{d}, \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{\ell} \cdot \sqrt{h}\right)}^{-1} \cdot d\\
\end{array}
\end{array}
if d < -3.10000000000000028e-11Initial program 78.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.0
Applied rewrites69.1%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6467.1
Applied rewrites67.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites67.2%
if -3.10000000000000028e-11 < d < 4.6e64Initial program 61.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites61.6%
Taylor expanded in d around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6448.5
Applied rewrites48.5%
if 4.6e64 < d Initial program 67.0%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6467.8
Applied rewrites67.8%
Applied rewrites67.9%
Applied rewrites84.2%
Final simplification60.4%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= d 6.4e+94)
(*
(fma
(* -0.5 (/ (* (* (/ M_m d) D_m) (* D_m M_m)) (* 2.0 (* d 2.0))))
(/ h l)
1.0)
(* (sqrt (/ d l)) (sqrt (/ d h))))
(* (pow (* (sqrt l) (sqrt h)) -1.0) d)))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (d <= 6.4e+94) {
tmp = fma((-0.5 * ((((M_m / d) * D_m) * (D_m * M_m)) / (2.0 * (d * 2.0)))), (h / l), 1.0) * (sqrt((d / l)) * sqrt((d / h)));
} else {
tmp = pow((sqrt(l) * sqrt(h)), -1.0) * d;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (d <= 6.4e+94) tmp = Float64(fma(Float64(-0.5 * Float64(Float64(Float64(Float64(M_m / d) * D_m) * Float64(D_m * M_m)) / Float64(2.0 * Float64(d * 2.0)))), Float64(h / l), 1.0) * Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h)))); else tmp = Float64((Float64(sqrt(l) * sqrt(h)) ^ -1.0) * d); 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[d, 6.4e+94], N[(N[(N[(-0.5 * N[(N[(N[(N[(M$95$m / d), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] / N[(2.0 * N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision] * d), $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}\;d \leq 6.4 \cdot 10^{+94}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 \cdot \frac{\left(\frac{M\_m}{d} \cdot D\_m\right) \cdot \left(D\_m \cdot M\_m\right)}{2 \cdot \left(d \cdot 2\right)}, \frac{h}{\ell}, 1\right) \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{\ell} \cdot \sqrt{h}\right)}^{-1} \cdot d\\
\end{array}
\end{array}
if d < 6.40000000000000028e94Initial program 66.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.1
Applied rewrites52.7%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6452.2
Applied rewrites52.2%
lift-sqrt.f64N/A
pow1/2N/A
lift-*.f64N/A
unpow-prod-downN/A
lift-pow.f64N/A
metadata-evalN/A
lift-/.f64N/A
lift-pow.f64N/A
metadata-evalN/A
lift-/.f64N/A
lower-*.f6465.6
lift-/.f64N/A
metadata-eval65.6
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6465.6
lift-/.f64N/A
metadata-eval65.6
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6465.6
Applied rewrites65.6%
if 6.40000000000000028e94 < d 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-*.f6469.0
Applied rewrites69.0%
Applied rewrites69.0%
Applied rewrites84.8%
Final simplification69.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
(if (<= d 6.4e+94)
(*
(fma (* -0.5 (* D_m (* (/ M_m d) (* M_m (/ D_m (* 4.0 d)))))) (/ h l) 1.0)
(sqrt (* (/ d l) (/ d h))))
(* (pow (* (sqrt l) (sqrt h)) -1.0) d)))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (d <= 6.4e+94) {
tmp = fma((-0.5 * (D_m * ((M_m / d) * (M_m * (D_m / (4.0 * d)))))), (h / l), 1.0) * sqrt(((d / l) * (d / h)));
} else {
tmp = pow((sqrt(l) * sqrt(h)), -1.0) * d;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (d <= 6.4e+94) tmp = Float64(fma(Float64(-0.5 * Float64(D_m * Float64(Float64(M_m / d) * Float64(M_m * Float64(D_m / Float64(4.0 * d)))))), Float64(h / l), 1.0) * sqrt(Float64(Float64(d / l) * Float64(d / h)))); else tmp = Float64((Float64(sqrt(l) * sqrt(h)) ^ -1.0) * d); 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[d, 6.4e+94], N[(N[(N[(-0.5 * N[(D$95$m * N[(N[(M$95$m / d), $MachinePrecision] * N[(M$95$m * N[(D$95$m / N[(4.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision] * d), $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}\;d \leq 6.4 \cdot 10^{+94}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 \cdot \left(D\_m \cdot \left(\frac{M\_m}{d} \cdot \left(M\_m \cdot \frac{D\_m}{4 \cdot d}\right)\right)\right), \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{\ell} \cdot \sqrt{h}\right)}^{-1} \cdot d\\
\end{array}
\end{array}
if d < 6.40000000000000028e94Initial program 66.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.1
Applied rewrites52.7%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6452.2
Applied rewrites52.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6450.7
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
metadata-eval50.7
Applied rewrites50.7%
if 6.40000000000000028e94 < d 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-*.f6469.0
Applied rewrites69.0%
Applied rewrites69.0%
Applied rewrites84.8%
Final simplification57.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 (<= h -1.45e+49)
(* 1.0 (sqrt (* (/ d l) (/ d h))))
(if (<= h 2.4e-296)
(* (- 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 (h <= -1.45e+49) {
tmp = 1.0 * sqrt(((d / l) * (d / h)));
} else if (h <= 2.4e-296) {
tmp = -d * sqrt(pow((l * h), -1.0));
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
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 (h <= (-1.45d+49)) then
tmp = 1.0d0 * sqrt(((d / l) * (d / h)))
else if (h <= 2.4d-296) 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 (h <= -1.45e+49) {
tmp = 1.0 * Math.sqrt(((d / l) * (d / h)));
} else if (h <= 2.4e-296) {
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 h <= -1.45e+49: tmp = 1.0 * math.sqrt(((d / l) * (d / h))) elif h <= 2.4e-296: 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 (h <= -1.45e+49) tmp = Float64(1.0 * sqrt(Float64(Float64(d / l) * Float64(d / h)))); elseif (h <= 2.4e-296) 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 (h <= -1.45e+49)
tmp = 1.0 * sqrt(((d / l) * (d / h)));
elseif (h <= 2.4e-296)
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[h, -1.45e+49], N[(1.0 * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[h, 2.4e-296], 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}\;h \leq -1.45 \cdot 10^{+49}:\\
\;\;\;\;1 \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{elif}\;h \leq 2.4 \cdot 10^{-296}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if h < -1.45e49Initial program 64.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6464.5
Applied rewrites56.3%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6454.3
Applied rewrites54.3%
Taylor expanded in d around inf
Applied rewrites29.2%
if -1.45e49 < h < 2.39999999999999996e-296Initial program 79.9%
Taylor expanded in l around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
*-commutativeN/A
mul-1-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6458.4
Applied rewrites58.4%
if 2.39999999999999996e-296 < h Initial program 60.9%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6441.1
Applied rewrites41.1%
Applied rewrites41.1%
Applied rewrites41.1%
Applied rewrites51.4%
Final simplification49.0%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (if (<= h 2.4e-296) (* (- 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 (h <= 2.4e-296) {
tmp = -d * sqrt(pow((l * h), -1.0));
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
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 (h <= 2.4d-296) 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 (h <= 2.4e-296) {
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 h <= 2.4e-296: 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 (h <= 2.4e-296) 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 (h <= 2.4e-296)
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[h, 2.4e-296], 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}\;h \leq 2.4 \cdot 10^{-296}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if h < 2.39999999999999996e-296Initial program 73.3%
Taylor expanded in l around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
*-commutativeN/A
mul-1-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6441.4
Applied rewrites41.4%
if 2.39999999999999996e-296 < h Initial program 60.9%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6441.1
Applied rewrites41.1%
Applied rewrites41.1%
Applied rewrites41.1%
Applied rewrites51.4%
Final simplification47.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 (pow (* l h) -1.0)))) (if (<= d -5.8e-179) (* (- d) t_0) (* t_0 d))))
D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = sqrt(pow((l * h), -1.0));
double tmp;
if (d <= -5.8e-179) {
tmp = -d * t_0;
} else {
tmp = t_0 * d;
}
return tmp;
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(((l * h) ** (-1.0d0)))
if (d <= (-5.8d-179)) then
tmp = -d * t_0
else
tmp = t_0 * d
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = Math.sqrt(Math.pow((l * h), -1.0));
double tmp;
if (d <= -5.8e-179) {
tmp = -d * t_0;
} else {
tmp = t_0 * d;
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = math.sqrt(math.pow((l * h), -1.0)) tmp = 0 if d <= -5.8e-179: tmp = -d * t_0 else: tmp = t_0 * d return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = sqrt((Float64(l * h) ^ -1.0)) tmp = 0.0 if (d <= -5.8e-179) tmp = Float64(Float64(-d) * t_0); else tmp = Float64(t_0 * d); end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = sqrt(((l * h) ^ -1.0));
tmp = 0.0;
if (d <= -5.8e-179)
tmp = -d * t_0;
else
tmp = t_0 * d;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -5.8e-179], N[((-d) * t$95$0), $MachinePrecision], N[(t$95$0 * d), $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{{\left(\ell \cdot h\right)}^{-1}}\\
\mathbf{if}\;d \leq -5.8 \cdot 10^{-179}:\\
\;\;\;\;\left(-d\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot d\\
\end{array}
\end{array}
if d < -5.7999999999999998e-179Initial program 76.6%
Taylor expanded in l around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
*-commutativeN/A
mul-1-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6449.0
Applied rewrites49.0%
if -5.7999999999999998e-179 < d Initial program 61.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6437.6
Applied rewrites37.6%
Final simplification41.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 (* (sqrt (pow (* l h) -1.0)) d))
D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
return sqrt(pow((l * h), -1.0)) * d;
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
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 = sqrt(((l * h) ** (-1.0d0))) * d
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 Math.sqrt(Math.pow((l * h), -1.0)) * d;
}
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 math.sqrt(math.pow((l * h), -1.0)) * d
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(sqrt((Float64(l * h) ^ -1.0)) * d) 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 = sqrt(((l * h) ^ -1.0)) * d;
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[(N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision] * d), $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])\\
\\
\sqrt{{\left(\ell \cdot h\right)}^{-1}} \cdot d
\end{array}
Initial program 66.2%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6427.3
Applied rewrites27.3%
Final simplification27.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 (/ 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 = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
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.2%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6427.3
Applied rewrites27.3%
Applied rewrites27.3%
Applied rewrites27.3%
herbie shell --seed 2024357
(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)))))