
(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}
Herbie found 16 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}
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (sqrt (/ d h))) (t_1 (* (/ D d) (/ M_m 2.0))))
(if (<= h -1e+279)
(*
(* -0.125 (/ (* (* (* D M_m) (* D M_m)) -1.0) d))
(sqrt (/ h (pow l 3.0))))
(if (<= h -4.7e+163)
(* (* (sqrt (/ d l)) t_0) (- 1.0 (/ (* (* (* t_1 t_1) 0.5) h) l)))
(if (<= h -5e-310)
(*
(* (- d) (pow (* h l) -0.5))
(- 1.0 (/ (* (* (pow (* (/ M_m 2.0) (/ D d)) 2.0) 0.5) h) l)))
(*
(* (/ (sqrt d) (sqrt l)) t_0)
(- 1.0 (/ (* (* (pow (/ (* D M_m) (* 2.0 d)) 2.0) 0.5) h) l))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = sqrt((d / h));
double t_1 = (D / d) * (M_m / 2.0);
double tmp;
if (h <= -1e+279) {
tmp = (-0.125 * ((((D * M_m) * (D * M_m)) * -1.0) / d)) * sqrt((h / pow(l, 3.0)));
} else if (h <= -4.7e+163) {
tmp = (sqrt((d / l)) * t_0) * (1.0 - ((((t_1 * t_1) * 0.5) * h) / l));
} else if (h <= -5e-310) {
tmp = (-d * pow((h * l), -0.5)) * (1.0 - (((pow(((M_m / 2.0) * (D / d)), 2.0) * 0.5) * h) / l));
} else {
tmp = ((sqrt(d) / sqrt(l)) * t_0) * (1.0 - (((pow(((D * M_m) / (2.0 * d)), 2.0) * 0.5) * h) / l));
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_m, and D 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_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_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sqrt((d / h))
t_1 = (d_1 / d) * (m_m / 2.0d0)
if (h <= (-1d+279)) then
tmp = ((-0.125d0) * ((((d_1 * m_m) * (d_1 * m_m)) * (-1.0d0)) / d)) * sqrt((h / (l ** 3.0d0)))
else if (h <= (-4.7d+163)) then
tmp = (sqrt((d / l)) * t_0) * (1.0d0 - ((((t_1 * t_1) * 0.5d0) * h) / l))
else if (h <= (-5d-310)) then
tmp = (-d * ((h * l) ** (-0.5d0))) * (1.0d0 - ((((((m_m / 2.0d0) * (d_1 / d)) ** 2.0d0) * 0.5d0) * h) / l))
else
tmp = ((sqrt(d) / sqrt(l)) * t_0) * (1.0d0 - ((((((d_1 * m_m) / (2.0d0 * d)) ** 2.0d0) * 0.5d0) * h) / l))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = Math.sqrt((d / h));
double t_1 = (D / d) * (M_m / 2.0);
double tmp;
if (h <= -1e+279) {
tmp = (-0.125 * ((((D * M_m) * (D * M_m)) * -1.0) / d)) * Math.sqrt((h / Math.pow(l, 3.0)));
} else if (h <= -4.7e+163) {
tmp = (Math.sqrt((d / l)) * t_0) * (1.0 - ((((t_1 * t_1) * 0.5) * h) / l));
} else if (h <= -5e-310) {
tmp = (-d * Math.pow((h * l), -0.5)) * (1.0 - (((Math.pow(((M_m / 2.0) * (D / d)), 2.0) * 0.5) * h) / l));
} else {
tmp = ((Math.sqrt(d) / Math.sqrt(l)) * t_0) * (1.0 - (((Math.pow(((D * M_m) / (2.0 * d)), 2.0) * 0.5) * h) / l));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = math.sqrt((d / h)) t_1 = (D / d) * (M_m / 2.0) tmp = 0 if h <= -1e+279: tmp = (-0.125 * ((((D * M_m) * (D * M_m)) * -1.0) / d)) * math.sqrt((h / math.pow(l, 3.0))) elif h <= -4.7e+163: tmp = (math.sqrt((d / l)) * t_0) * (1.0 - ((((t_1 * t_1) * 0.5) * h) / l)) elif h <= -5e-310: tmp = (-d * math.pow((h * l), -0.5)) * (1.0 - (((math.pow(((M_m / 2.0) * (D / d)), 2.0) * 0.5) * h) / l)) else: tmp = ((math.sqrt(d) / math.sqrt(l)) * t_0) * (1.0 - (((math.pow(((D * M_m) / (2.0 * d)), 2.0) * 0.5) * h) / l)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = sqrt(Float64(d / h)) t_1 = Float64(Float64(D / d) * Float64(M_m / 2.0)) tmp = 0.0 if (h <= -1e+279) tmp = Float64(Float64(-0.125 * Float64(Float64(Float64(Float64(D * M_m) * Float64(D * M_m)) * -1.0) / d)) * sqrt(Float64(h / (l ^ 3.0)))); elseif (h <= -4.7e+163) tmp = Float64(Float64(sqrt(Float64(d / l)) * t_0) * Float64(1.0 - Float64(Float64(Float64(Float64(t_1 * t_1) * 0.5) * h) / l))); elseif (h <= -5e-310) tmp = Float64(Float64(Float64(-d) * (Float64(h * l) ^ -0.5)) * Float64(1.0 - Float64(Float64(Float64((Float64(Float64(M_m / 2.0) * Float64(D / d)) ^ 2.0) * 0.5) * h) / l))); else tmp = Float64(Float64(Float64(sqrt(d) / sqrt(l)) * t_0) * Float64(1.0 - Float64(Float64(Float64((Float64(Float64(D * M_m) / Float64(2.0 * d)) ^ 2.0) * 0.5) * h) / l))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = sqrt((d / h));
t_1 = (D / d) * (M_m / 2.0);
tmp = 0.0;
if (h <= -1e+279)
tmp = (-0.125 * ((((D * M_m) * (D * M_m)) * -1.0) / d)) * sqrt((h / (l ^ 3.0)));
elseif (h <= -4.7e+163)
tmp = (sqrt((d / l)) * t_0) * (1.0 - ((((t_1 * t_1) * 0.5) * h) / l));
elseif (h <= -5e-310)
tmp = (-d * ((h * l) ^ -0.5)) * (1.0 - ((((((M_m / 2.0) * (D / d)) ^ 2.0) * 0.5) * h) / l));
else
tmp = ((sqrt(d) / sqrt(l)) * t_0) * (1.0 - ((((((D * M_m) / (2.0 * d)) ^ 2.0) * 0.5) * h) / l));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(D / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -1e+279], N[(N[(-0.125 * N[(N[(N[(N[(D * M$95$m), $MachinePrecision] * N[(D * M$95$m), $MachinePrecision]), $MachinePrecision] * -1.0), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -4.7e+163], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -5e-310], N[(N[((-d) * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[Power[N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[Power[N[(N[(D * M$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h}}\\
t_1 := \frac{D}{d} \cdot \frac{M\_m}{2}\\
\mathbf{if}\;h \leq -1 \cdot 10^{+279}:\\
\;\;\;\;\left(-0.125 \cdot \frac{\left(\left(D \cdot M\_m\right) \cdot \left(D \cdot M\_m\right)\right) \cdot -1}{d}\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\\
\mathbf{elif}\;h \leq -4.7 \cdot 10^{+163}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot t\_0\right) \cdot \left(1 - \frac{\left(\left(t\_1 \cdot t\_1\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\
\mathbf{elif}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\left(-d\right) \cdot {\left(h \cdot \ell\right)}^{-0.5}\right) \cdot \left(1 - \frac{\left({\left(\frac{M\_m}{2} \cdot \frac{D}{d}\right)}^{2} \cdot 0.5\right) \cdot h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot t\_0\right) \cdot \left(1 - \frac{\left({\left(\frac{D \cdot M\_m}{2 \cdot d}\right)}^{2} \cdot 0.5\right) \cdot h}{\ell}\right)\\
\end{array}
\end{array}
if h < -1.00000000000000006e279Initial program 40.0%
Taylor expanded in h around -inf
associate-*r*N/A
lower-*.f64N/A
Applied rewrites39.8%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f6439.8
Applied rewrites39.8%
if -1.00000000000000006e279 < h < -4.70000000000000019e163Initial program 53.0%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6453.0
Applied rewrites53.0%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites56.1%
lift-pow.f64N/A
unpow2N/A
lower-*.f6456.1
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6456.1
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6456.1
Applied rewrites56.1%
if -4.70000000000000019e163 < h < -4.999999999999985e-310Initial program 70.6%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6470.6
Applied rewrites70.6%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites72.0%
Taylor expanded in h around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
unpow-1N/A
sqrt-pow1N/A
*-commutativeN/A
lower-pow.f64N/A
lift-*.f64N/A
metadata-eval80.4
Applied rewrites80.4%
if -4.999999999999985e-310 < h Initial program 66.7%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6466.7
Applied rewrites66.7%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites68.2%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6468.7
Applied rewrites68.7%
lift-/.f64N/A
lift-sqrt.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6475.3
Applied rewrites75.3%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<=
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l))))
INFINITY)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (/ (* (* (pow (/ (* D M_m) (* 2.0 d)) 2.0) 0.5) h) l)))
(/
(*
(fma
(* -0.125 (/ (* M_m M_m) d))
(pow (/ h l) 1.5)
(* (/ d (* D D)) (sqrt (/ h l))))
(* D D))
h)))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (((pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)))) <= ((double) INFINITY)) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (((pow(((D * M_m) / (2.0 * d)), 2.0) * 0.5) * h) / l));
} else {
tmp = (fma((-0.125 * ((M_m * M_m) / d)), pow((h / l), 1.5), ((d / (D * D)) * sqrt((h / l)))) * (D * D)) / h;
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (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_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= Inf) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64((Float64(Float64(D * M_m) / Float64(2.0 * d)) ^ 2.0) * 0.5) * h) / l))); else tmp = Float64(Float64(fma(Float64(-0.125 * Float64(Float64(M_m * M_m) / d)), (Float64(h / l) ^ 1.5), Float64(Float64(d / Float64(D * D)) * sqrt(Float64(h / l)))) * Float64(D * D)) / h); end return tmp end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[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$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[Power[N[(N[(D * M$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(-0.125 * N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[Power[N[(h / l), $MachinePrecision], 1.5], $MachinePrecision] + N[(N[(d / N[(D * D), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\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\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq \infty:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \frac{\left({\left(\frac{D \cdot M\_m}{2 \cdot d}\right)}^{2} \cdot 0.5\right) \cdot h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.125 \cdot \frac{M\_m \cdot M\_m}{d}, {\left(\frac{h}{\ell}\right)}^{1.5}, \frac{d}{D \cdot D} \cdot \sqrt{\frac{h}{\ell}}\right) \cdot \left(D \cdot D\right)}{h}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 81.5%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6481.5
Applied rewrites81.5%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites80.9%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6481.5
Applied rewrites81.5%
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 h around 0
lower-/.f64N/A
Applied rewrites19.7%
Taylor expanded in D around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites22.1%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<=
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l))))
INFINITY)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (/ (* (* (pow (/ (* D M_m) (* 2.0 d)) 2.0) 0.5) h) l)))
(/
(fma
(* -0.125 (/ (* (* M_m M_m) (* D D)) d))
(pow (/ h l) 1.5)
(* (sqrt (/ h l)) d))
h)))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (((pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)))) <= ((double) INFINITY)) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (((pow(((D * M_m) / (2.0 * d)), 2.0) * 0.5) * h) / l));
} else {
tmp = fma((-0.125 * (((M_m * M_m) * (D * D)) / d)), pow((h / l), 1.5), (sqrt((h / l)) * d)) / h;
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (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_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= Inf) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64((Float64(Float64(D * M_m) / Float64(2.0 * d)) ^ 2.0) * 0.5) * h) / l))); else tmp = Float64(fma(Float64(-0.125 * Float64(Float64(Float64(M_m * M_m) * Float64(D * D)) / d)), (Float64(h / l) ^ 1.5), Float64(sqrt(Float64(h / l)) * d)) / h); end return tmp end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[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$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[Power[N[(N[(D * M$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-0.125 * N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[Power[N[(h / l), $MachinePrecision], 1.5], $MachinePrecision] + N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\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\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq \infty:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \frac{\left({\left(\frac{D \cdot M\_m}{2 \cdot d}\right)}^{2} \cdot 0.5\right) \cdot h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.125 \cdot \frac{\left(M\_m \cdot M\_m\right) \cdot \left(D \cdot D\right)}{d}, {\left(\frac{h}{\ell}\right)}^{1.5}, \sqrt{\frac{h}{\ell}} \cdot d\right)}{h}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 81.5%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6481.5
Applied rewrites81.5%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites80.9%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6481.5
Applied rewrites81.5%
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 h around 0
lower-/.f64N/A
Applied rewrites19.7%
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6417.4
Applied rewrites17.4%
lift-sqrt.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
sqrt-pow1N/A
lower-pow.f64N/A
lift-/.f64N/A
metadata-eval21.9
Applied rewrites21.9%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (pow (/ (* M_m D) (* 2.0 d)) 2.0)))
(if (<=
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) t_0) (/ h l))))
INFINITY)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) (- 1.0 (* (* 0.5 t_0) (/ h l))))
(/
(fma
(* -0.125 (/ (* (* M_m M_m) (* D D)) d))
(pow (/ h l) 1.5)
(* (sqrt (/ h l)) d))
h))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = pow(((M_m * D) / (2.0 * d)), 2.0);
double tmp;
if (((pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * t_0) * (h / l)))) <= ((double) INFINITY)) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((0.5 * t_0) * (h / l)));
} else {
tmp = fma((-0.125 * (((M_m * M_m) * (D * D)) / d)), pow((h / l), 1.5), (sqrt((h / l)) * d)) / h;
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0 tmp = 0.0 if (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) * t_0) * Float64(h / l)))) <= Inf) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(0.5 * t_0) * Float64(h / l)))); else tmp = Float64(fma(Float64(-0.125 * Float64(Float64(Float64(M_m * M_m) * Float64(D * D)) / d)), (Float64(h / l) ^ 1.5), Float64(sqrt(Float64(h / l)) * d)) / h); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[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] * t$95$0), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(0.5 * t$95$0), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-0.125 * N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[Power[N[(h / l), $MachinePrecision], 1.5], $MachinePrecision] + N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2}\\
\mathbf{if}\;\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 t\_0\right) \cdot \frac{h}{\ell}\right) \leq \infty:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \left(0.5 \cdot t\_0\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.125 \cdot \frac{\left(M\_m \cdot M\_m\right) \cdot \left(D \cdot D\right)}{d}, {\left(\frac{h}{\ell}\right)}^{1.5}, \sqrt{\frac{h}{\ell}} \cdot d\right)}{h}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 81.5%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6481.5
Applied rewrites81.5%
lift-/.f64N/A
metadata-eval81.5
Applied rewrites81.5%
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 h around 0
lower-/.f64N/A
Applied rewrites19.7%
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6417.4
Applied rewrites17.4%
lift-sqrt.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
sqrt-pow1N/A
lower-pow.f64N/A
lift-/.f64N/A
metadata-eval21.9
Applied rewrites21.9%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* (/ D 2.0) (/ M_m d))))
(if (<=
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l))))
INFINITY)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l)))
(/
(fma
(* -0.125 (/ (* (* M_m M_m) (* D D)) d))
(pow (/ h l) 1.5)
(* (sqrt (/ h l)) d))
h))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = (D / 2.0) * (M_m / d);
double tmp;
if (((pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)))) <= ((double) INFINITY)) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
} else {
tmp = fma((-0.125 * (((M_m * M_m) * (D * D)) / d)), pow((h / l), 1.5), (sqrt((h / l)) * d)) / h;
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64(D / 2.0) * Float64(M_m / d)) tmp = 0.0 if (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_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= Inf) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64(Float64(t_0 * t_0) * 0.5) * h) / l))); else tmp = Float64(fma(Float64(-0.125 * Float64(Float64(Float64(M_m * M_m) * Float64(D * D)) / d)), (Float64(h / l) ^ 1.5), Float64(sqrt(Float64(h / l)) * d)) / h); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(D / 2.0), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[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$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-0.125 * N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[Power[N[(h / l), $MachinePrecision], 1.5], $MachinePrecision] + N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \frac{D}{2} \cdot \frac{M\_m}{d}\\
\mathbf{if}\;\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\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq \infty:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.125 \cdot \frac{\left(M\_m \cdot M\_m\right) \cdot \left(D \cdot D\right)}{d}, {\left(\frac{h}{\ell}\right)}^{1.5}, \sqrt{\frac{h}{\ell}} \cdot d\right)}{h}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 81.5%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6481.5
Applied rewrites81.5%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites80.9%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6481.5
Applied rewrites81.5%
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
frac-timesN/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
unpow2N/A
lower-*.f6480.9
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6480.1
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6481.1
Applied rewrites81.1%
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 h around 0
lower-/.f64N/A
Applied rewrites19.7%
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6417.4
Applied rewrites17.4%
lift-sqrt.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
sqrt-pow1N/A
lower-pow.f64N/A
lift-/.f64N/A
metadata-eval21.9
Applied rewrites21.9%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<=
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l))))
-2e-129)
(/ (* d (- (sqrt (/ h l)))) h)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (((pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)))) <= -2e-129) {
tmp = (d * -sqrt((h / l))) / h;
} else {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_m, and D 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_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_m
real(8), intent (in) :: d_1
real(8) :: tmp
if (((((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= (-2d-129)) then
tmp = (d * -sqrt((h / l))) / h
else
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0d0
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (((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_m * D) / (2.0 * d)), 2.0)) * (h / l)))) <= -2e-129) {
tmp = (d * -Math.sqrt((h / l))) / h;
} else {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * 1.0;
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if ((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_m * D) / (2.0 * d)), 2.0)) * (h / l)))) <= -2e-129: tmp = (d * -math.sqrt((h / l))) / h else: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * 1.0 return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (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_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= -2e-129) tmp = Float64(Float64(d * Float64(-sqrt(Float64(h / l)))) / h); else tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (((((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= -2e-129)
tmp = (d * -sqrt((h / l))) / h;
else
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[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$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e-129], N[(N[(d * (-N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\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\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -2 \cdot 10^{-129}:\\
\;\;\;\;\frac{d \cdot \left(-\sqrt{\frac{h}{\ell}}\right)}{h}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot 1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -1.9999999999999999e-129Initial program 85.8%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites50.4%
Taylor expanded in l around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-sqrt.f64N/A
lift-/.f6421.8
Applied rewrites21.8%
if -1.9999999999999999e-129 < (*.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 56.2%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6456.2
Applied rewrites56.2%
Taylor expanded in d around inf
Applied rewrites58.7%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (sqrt (/ h l))))
(if (<=
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l))))
-2e-129)
(/ (* d (- t_0)) h)
(/ (* t_0 d) h))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = sqrt((h / l));
double tmp;
if (((pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)))) <= -2e-129) {
tmp = (d * -t_0) / h;
} else {
tmp = (t_0 * d) / h;
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_m, and D 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_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_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((h / l))
if (((((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= (-2d-129)) then
tmp = (d * -t_0) / h
else
tmp = (t_0 * d) / h
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = Math.sqrt((h / l));
double tmp;
if (((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_m * D) / (2.0 * d)), 2.0)) * (h / l)))) <= -2e-129) {
tmp = (d * -t_0) / h;
} else {
tmp = (t_0 * d) / h;
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = math.sqrt((h / l)) tmp = 0 if ((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_m * D) / (2.0 * d)), 2.0)) * (h / l)))) <= -2e-129: tmp = (d * -t_0) / h else: tmp = (t_0 * d) / h return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = sqrt(Float64(h / l)) tmp = 0.0 if (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_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= -2e-129) tmp = Float64(Float64(d * Float64(-t_0)) / h); else tmp = Float64(Float64(t_0 * d) / h); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = sqrt((h / l));
tmp = 0.0;
if (((((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= -2e-129)
tmp = (d * -t_0) / h;
else
tmp = (t_0 * d) / h;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[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$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e-129], N[(N[(d * (-t$95$0)), $MachinePrecision] / h), $MachinePrecision], N[(N[(t$95$0 * d), $MachinePrecision] / h), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{h}{\ell}}\\
\mathbf{if}\;\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\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -2 \cdot 10^{-129}:\\
\;\;\;\;\frac{d \cdot \left(-t\_0\right)}{h}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 \cdot d}{h}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -1.9999999999999999e-129Initial program 85.8%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites50.4%
Taylor expanded in l around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-sqrt.f64N/A
lift-/.f6421.8
Applied rewrites21.8%
if -1.9999999999999999e-129 < (*.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 56.2%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites47.6%
Taylor expanded in d around inf
*-commutativeN/A
lift-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6455.5
Applied rewrites55.5%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<=
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l))))
-1e-64)
(* (sqrt (/ (/ 1.0 h) l)) d)
(/ (* (sqrt (/ h l)) d) h)))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (((pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)))) <= -1e-64) {
tmp = sqrt(((1.0 / h) / l)) * d;
} else {
tmp = (sqrt((h / l)) * d) / h;
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_m, and D 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_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_m
real(8), intent (in) :: d_1
real(8) :: tmp
if (((((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= (-1d-64)) then
tmp = sqrt(((1.0d0 / h) / l)) * d
else
tmp = (sqrt((h / l)) * d) / h
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (((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_m * D) / (2.0 * d)), 2.0)) * (h / l)))) <= -1e-64) {
tmp = Math.sqrt(((1.0 / h) / l)) * d;
} else {
tmp = (Math.sqrt((h / l)) * d) / h;
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if ((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_m * D) / (2.0 * d)), 2.0)) * (h / l)))) <= -1e-64: tmp = math.sqrt(((1.0 / h) / l)) * d else: tmp = (math.sqrt((h / l)) * d) / h return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (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_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= -1e-64) tmp = Float64(sqrt(Float64(Float64(1.0 / h) / l)) * d); else tmp = Float64(Float64(sqrt(Float64(h / l)) * d) / h); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (((((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= -1e-64)
tmp = sqrt(((1.0 / h) / l)) * d;
else
tmp = (sqrt((h / l)) * d) / h;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[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$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1e-64], N[(N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] / h), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\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\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -1 \cdot 10^{-64}:\\
\;\;\;\;\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot d}{h}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -9.99999999999999965e-65Initial program 85.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6411.2
Applied rewrites11.2%
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
associate-/r*N/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6411.2
Applied rewrites11.2%
lift-pow.f64N/A
inv-powN/A
lower-/.f6411.2
Applied rewrites11.2%
if -9.99999999999999965e-65 < (*.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 56.6%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites47.5%
Taylor expanded in d around inf
*-commutativeN/A
lift-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6455.0
Applied rewrites55.0%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* (/ D d) (/ M_m 2.0))) (t_1 (sqrt (/ d h))))
(if (<= d -1.9e-44)
(* (* (sqrt (/ d l)) t_1) (- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l)))
(if (<= d 2.8e-198)
(/
(/
(fma
(* (pow (/ h l) 1.5) (pow (* D M_m) 2.0))
-0.125
(* (sqrt (/ h l)) (* d d)))
d)
h)
(*
(* (/ (sqrt d) (sqrt l)) t_1)
(- 1.0 (/ (* (* (pow (/ (* D M_m) (* 2.0 d)) 2.0) 0.5) h) l)))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = (D / d) * (M_m / 2.0);
double t_1 = sqrt((d / h));
double tmp;
if (d <= -1.9e-44) {
tmp = (sqrt((d / l)) * t_1) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
} else if (d <= 2.8e-198) {
tmp = (fma((pow((h / l), 1.5) * pow((D * M_m), 2.0)), -0.125, (sqrt((h / l)) * (d * d))) / d) / h;
} else {
tmp = ((sqrt(d) / sqrt(l)) * t_1) * (1.0 - (((pow(((D * M_m) / (2.0 * d)), 2.0) * 0.5) * h) / l));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64(D / d) * Float64(M_m / 2.0)) t_1 = sqrt(Float64(d / h)) tmp = 0.0 if (d <= -1.9e-44) tmp = Float64(Float64(sqrt(Float64(d / l)) * t_1) * Float64(1.0 - Float64(Float64(Float64(Float64(t_0 * t_0) * 0.5) * h) / l))); elseif (d <= 2.8e-198) tmp = Float64(Float64(fma(Float64((Float64(h / l) ^ 1.5) * (Float64(D * M_m) ^ 2.0)), -0.125, Float64(sqrt(Float64(h / l)) * Float64(d * d))) / d) / h); else tmp = Float64(Float64(Float64(sqrt(d) / sqrt(l)) * t_1) * Float64(1.0 - Float64(Float64(Float64((Float64(Float64(D * M_m) / Float64(2.0 * d)) ^ 2.0) * 0.5) * h) / l))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(D / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -1.9e-44], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.8e-198], N[(N[(N[(N[(N[Power[N[(h / l), $MachinePrecision], 1.5], $MachinePrecision] * N[Power[N[(D * M$95$m), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * -0.125 + N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[Power[N[(N[(D * M$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \frac{D}{d} \cdot \frac{M\_m}{2}\\
t_1 := \sqrt{\frac{d}{h}}\\
\mathbf{if}\;d \leq -1.9 \cdot 10^{-44}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot t\_1\right) \cdot \left(1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\
\mathbf{elif}\;d \leq 2.8 \cdot 10^{-198}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left({\left(\frac{h}{\ell}\right)}^{1.5} \cdot {\left(D \cdot M\_m\right)}^{2}, -0.125, \sqrt{\frac{h}{\ell}} \cdot \left(d \cdot d\right)\right)}{d}}{h}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot t\_1\right) \cdot \left(1 - \frac{\left({\left(\frac{D \cdot M\_m}{2 \cdot d}\right)}^{2} \cdot 0.5\right) \cdot h}{\ell}\right)\\
\end{array}
\end{array}
if d < -1.9e-44Initial program 75.9%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6475.9
Applied rewrites75.9%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites79.3%
lift-pow.f64N/A
unpow2N/A
lower-*.f6479.3
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6479.3
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6479.3
Applied rewrites79.3%
if -1.9e-44 < d < 2.7999999999999999e-198Initial program 48.7%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites47.7%
Taylor expanded in d around 0
lower-/.f64N/A
Applied rewrites51.6%
if 2.7999999999999999e-198 < d Initial program 72.8%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6472.8
Applied rewrites72.8%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites75.0%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6475.3
Applied rewrites75.3%
lift-/.f64N/A
lift-sqrt.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6481.3
Applied rewrites81.3%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (- 1.0 (/ (* (* (pow (/ (* D M_m) (* 2.0 d)) 2.0) 0.5) h) l)))
(t_1 (sqrt (/ d h))))
(if (<= d -3.8e-208)
(* (* (sqrt (/ d l)) t_1) t_0)
(if (<= d -2e-310)
(*
(* -0.125 (/ (* (* (* D M_m) (* D M_m)) -1.0) d))
(sqrt (/ h (pow l 3.0))))
(* (* (/ (sqrt d) (sqrt l)) t_1) t_0)))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = 1.0 - (((pow(((D * M_m) / (2.0 * d)), 2.0) * 0.5) * h) / l);
double t_1 = sqrt((d / h));
double tmp;
if (d <= -3.8e-208) {
tmp = (sqrt((d / l)) * t_1) * t_0;
} else if (d <= -2e-310) {
tmp = (-0.125 * ((((D * M_m) * (D * M_m)) * -1.0) / d)) * sqrt((h / pow(l, 3.0)));
} else {
tmp = ((sqrt(d) / sqrt(l)) * t_1) * t_0;
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_m, and D 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_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_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - ((((((d_1 * m_m) / (2.0d0 * d)) ** 2.0d0) * 0.5d0) * h) / l)
t_1 = sqrt((d / h))
if (d <= (-3.8d-208)) then
tmp = (sqrt((d / l)) * t_1) * t_0
else if (d <= (-2d-310)) then
tmp = ((-0.125d0) * ((((d_1 * m_m) * (d_1 * m_m)) * (-1.0d0)) / d)) * sqrt((h / (l ** 3.0d0)))
else
tmp = ((sqrt(d) / sqrt(l)) * t_1) * t_0
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = 1.0 - (((Math.pow(((D * M_m) / (2.0 * d)), 2.0) * 0.5) * h) / l);
double t_1 = Math.sqrt((d / h));
double tmp;
if (d <= -3.8e-208) {
tmp = (Math.sqrt((d / l)) * t_1) * t_0;
} else if (d <= -2e-310) {
tmp = (-0.125 * ((((D * M_m) * (D * M_m)) * -1.0) / d)) * Math.sqrt((h / Math.pow(l, 3.0)));
} else {
tmp = ((Math.sqrt(d) / Math.sqrt(l)) * t_1) * t_0;
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = 1.0 - (((math.pow(((D * M_m) / (2.0 * d)), 2.0) * 0.5) * h) / l) t_1 = math.sqrt((d / h)) tmp = 0 if d <= -3.8e-208: tmp = (math.sqrt((d / l)) * t_1) * t_0 elif d <= -2e-310: tmp = (-0.125 * ((((D * M_m) * (D * M_m)) * -1.0) / d)) * math.sqrt((h / math.pow(l, 3.0))) else: tmp = ((math.sqrt(d) / math.sqrt(l)) * t_1) * t_0 return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(1.0 - Float64(Float64(Float64((Float64(Float64(D * M_m) / Float64(2.0 * d)) ^ 2.0) * 0.5) * h) / l)) t_1 = sqrt(Float64(d / h)) tmp = 0.0 if (d <= -3.8e-208) tmp = Float64(Float64(sqrt(Float64(d / l)) * t_1) * t_0); elseif (d <= -2e-310) tmp = Float64(Float64(-0.125 * Float64(Float64(Float64(Float64(D * M_m) * Float64(D * M_m)) * -1.0) / d)) * sqrt(Float64(h / (l ^ 3.0)))); else tmp = Float64(Float64(Float64(sqrt(d) / sqrt(l)) * t_1) * t_0); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = 1.0 - ((((((D * M_m) / (2.0 * d)) ^ 2.0) * 0.5) * h) / l);
t_1 = sqrt((d / h));
tmp = 0.0;
if (d <= -3.8e-208)
tmp = (sqrt((d / l)) * t_1) * t_0;
elseif (d <= -2e-310)
tmp = (-0.125 * ((((D * M_m) * (D * M_m)) * -1.0) / d)) * sqrt((h / (l ^ 3.0)));
else
tmp = ((sqrt(d) / sqrt(l)) * t_1) * t_0;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(1.0 - N[(N[(N[(N[Power[N[(N[(D * M$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -3.8e-208], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[d, -2e-310], N[(N[(-0.125 * N[(N[(N[(N[(D * M$95$m), $MachinePrecision] * N[(D * M$95$m), $MachinePrecision]), $MachinePrecision] * -1.0), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := 1 - \frac{\left({\left(\frac{D \cdot M\_m}{2 \cdot d}\right)}^{2} \cdot 0.5\right) \cdot h}{\ell}\\
t_1 := \sqrt{\frac{d}{h}}\\
\mathbf{if}\;d \leq -3.8 \cdot 10^{-208}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot t\_1\right) \cdot t\_0\\
\mathbf{elif}\;d \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\left(-0.125 \cdot \frac{\left(\left(D \cdot M\_m\right) \cdot \left(D \cdot M\_m\right)\right) \cdot -1}{d}\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot t\_1\right) \cdot t\_0\\
\end{array}
\end{array}
if d < -3.80000000000000011e-208Initial program 71.1%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6471.1
Applied rewrites71.1%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites73.6%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6473.8
Applied rewrites73.8%
if -3.80000000000000011e-208 < d < -1.999999999999994e-310Initial program 37.8%
Taylor expanded in h around -inf
associate-*r*N/A
lower-*.f64N/A
Applied rewrites51.2%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f6451.2
Applied rewrites51.2%
if -1.999999999999994e-310 < d Initial program 66.7%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6466.7
Applied rewrites66.7%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites68.2%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6468.7
Applied rewrites68.7%
lift-/.f64N/A
lift-sqrt.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6475.3
Applied rewrites75.3%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* (/ D 2.0) (/ M_m d))))
(if (<= l 2.5e+154)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l)))
(* (/ (sqrt (pow h -1.0)) (sqrt l)) d))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = (D / 2.0) * (M_m / d);
double tmp;
if (l <= 2.5e+154) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
} else {
tmp = (sqrt(pow(h, -1.0)) / sqrt(l)) * d;
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_m, and D 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_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_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = (d_1 / 2.0d0) * (m_m / d)
if (l <= 2.5d+154) then
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0d0 - ((((t_0 * t_0) * 0.5d0) * h) / l))
else
tmp = (sqrt((h ** (-1.0d0))) / sqrt(l)) * d
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = (D / 2.0) * (M_m / d);
double tmp;
if (l <= 2.5e+154) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
} else {
tmp = (Math.sqrt(Math.pow(h, -1.0)) / Math.sqrt(l)) * d;
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = (D / 2.0) * (M_m / d) tmp = 0 if l <= 2.5e+154: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l)) else: tmp = (math.sqrt(math.pow(h, -1.0)) / math.sqrt(l)) * d return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64(D / 2.0) * Float64(M_m / d)) tmp = 0.0 if (l <= 2.5e+154) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64(Float64(t_0 * t_0) * 0.5) * h) / l))); else tmp = Float64(Float64(sqrt((h ^ -1.0)) / sqrt(l)) * d); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = (D / 2.0) * (M_m / d);
tmp = 0.0;
if (l <= 2.5e+154)
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
else
tmp = (sqrt((h ^ -1.0)) / sqrt(l)) * d;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(D / 2.0), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, 2.5e+154], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[Power[h, -1.0], $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \frac{D}{2} \cdot \frac{M\_m}{d}\\
\mathbf{if}\;\ell \leq 2.5 \cdot 10^{+154}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{{h}^{-1}}}{\sqrt{\ell}} \cdot d\\
\end{array}
\end{array}
if l < 2.50000000000000002e154Initial program 68.3%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6468.3
Applied rewrites68.3%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites70.5%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6470.9
Applied rewrites70.9%
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
frac-timesN/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
unpow2N/A
lower-*.f6470.5
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6469.8
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6470.7
Applied rewrites70.7%
if 2.50000000000000002e154 < l Initial program 51.0%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6449.1
Applied rewrites49.1%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f6449.1
Applied rewrites49.1%
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-divN/A
associate-/r*N/A
inv-powN/A
lift-pow.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6465.9
Applied rewrites65.9%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* (/ D 2.0) (/ M_m d))))
(if (<= l 2.5e+154)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l)))
(* (/ 1.0 (* (sqrt h) (sqrt l))) d))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = (D / 2.0) * (M_m / d);
double tmp;
if (l <= 2.5e+154) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
} else {
tmp = (1.0 / (sqrt(h) * sqrt(l))) * d;
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_m, and D 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_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_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = (d_1 / 2.0d0) * (m_m / d)
if (l <= 2.5d+154) then
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0d0 - ((((t_0 * t_0) * 0.5d0) * h) / l))
else
tmp = (1.0d0 / (sqrt(h) * sqrt(l))) * d
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = (D / 2.0) * (M_m / d);
double tmp;
if (l <= 2.5e+154) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
} else {
tmp = (1.0 / (Math.sqrt(h) * Math.sqrt(l))) * d;
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = (D / 2.0) * (M_m / d) tmp = 0 if l <= 2.5e+154: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l)) else: tmp = (1.0 / (math.sqrt(h) * math.sqrt(l))) * d return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64(D / 2.0) * Float64(M_m / d)) tmp = 0.0 if (l <= 2.5e+154) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64(Float64(t_0 * t_0) * 0.5) * h) / l))); else tmp = Float64(Float64(1.0 / Float64(sqrt(h) * sqrt(l))) * d); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = (D / 2.0) * (M_m / d);
tmp = 0.0;
if (l <= 2.5e+154)
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
else
tmp = (1.0 / (sqrt(h) * sqrt(l))) * d;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(D / 2.0), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, 2.5e+154], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \frac{D}{2} \cdot \frac{M\_m}{d}\\
\mathbf{if}\;\ell \leq 2.5 \cdot 10^{+154}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{h} \cdot \sqrt{\ell}} \cdot d\\
\end{array}
\end{array}
if l < 2.50000000000000002e154Initial program 68.3%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6468.3
Applied rewrites68.3%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites70.5%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6470.9
Applied rewrites70.9%
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
frac-timesN/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
unpow2N/A
lower-*.f6470.5
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6469.8
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6470.7
Applied rewrites70.7%
if 2.50000000000000002e154 < l Initial program 51.0%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6449.1
Applied rewrites49.1%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f6449.1
Applied rewrites49.1%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6465.9
Applied rewrites65.9%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<= M_m 5.2e-93)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)
(/
(fma
(* -0.125 (/ (* (* M_m M_m) (* D D)) d))
(sqrt (* (/ h l) (* (/ h l) (/ h l))))
(* (sqrt (/ h l)) d))
h)))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (M_m <= 5.2e-93) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
} else {
tmp = fma((-0.125 * (((M_m * M_m) * (D * D)) / d)), sqrt(((h / l) * ((h / l) * (h / l)))), (sqrt((h / l)) * d)) / h;
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (M_m <= 5.2e-93) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); else tmp = Float64(fma(Float64(-0.125 * Float64(Float64(Float64(M_m * M_m) * Float64(D * D)) / d)), sqrt(Float64(Float64(h / l) * Float64(Float64(h / l) * Float64(h / l)))), Float64(sqrt(Float64(h / l)) * d)) / h); end return tmp end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[M$95$m, 5.2e-93], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(N[(-0.125 * N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[(h / l), $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \leq 5.2 \cdot 10^{-93}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.125 \cdot \frac{\left(M\_m \cdot M\_m\right) \cdot \left(D \cdot D\right)}{d}, \sqrt{\frac{h}{\ell} \cdot \left(\frac{h}{\ell} \cdot \frac{h}{\ell}\right)}, \sqrt{\frac{h}{\ell}} \cdot d\right)}{h}\\
\end{array}
\end{array}
if M < 5.1999999999999997e-93Initial program 66.2%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6466.2
Applied rewrites66.2%
Taylor expanded in d around inf
Applied rewrites45.1%
if 5.1999999999999997e-93 < M Initial program 66.4%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites45.5%
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6444.3
Applied rewrites44.3%
lift-/.f64N/A
lift-pow.f64N/A
cube-multN/A
lower-*.f64N/A
lift-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6444.3
Applied rewrites44.3%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (* (sqrt (/ (/ 1.0 h) l)) d))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
return sqrt(((1.0 / h) / l)) * d;
}
M_m = private
NOTE: d, h, l, M_m, and D 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_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_m
real(8), intent (in) :: d_1
code = sqrt(((1.0d0 / h) / l)) * d
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
return Math.sqrt(((1.0 / h) / l)) * d;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): return math.sqrt(((1.0 / h) / l)) * d
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) return Float64(sqrt(Float64(Float64(1.0 / h) / l)) * d) end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp = code(d, h, l, M_m, D)
tmp = sqrt(((1.0 / h) / l)) * d;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := N[(N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d
\end{array}
Initial program 66.2%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6426.2
Applied rewrites26.2%
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
associate-/r*N/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6426.5
Applied rewrites26.5%
lift-pow.f64N/A
inv-powN/A
lower-/.f6426.5
Applied rewrites26.5%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (* (/ 1.0 (sqrt (* h l))) d))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
return (1.0 / sqrt((h * l))) * d;
}
M_m = private
NOTE: d, h, l, M_m, and D 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_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_m
real(8), intent (in) :: d_1
code = (1.0d0 / sqrt((h * l))) * d
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
return (1.0 / Math.sqrt((h * l))) * d;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): return (1.0 / math.sqrt((h * l))) * d
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) return Float64(Float64(1.0 / sqrt(Float64(h * l))) * d) end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp = code(d, h, l, M_m, D)
tmp = (1.0 / sqrt((h * l))) * d;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := N[(N[(1.0 / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\frac{1}{\sqrt{h \cdot \ell}} \cdot d
\end{array}
Initial program 66.2%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6426.2
Applied rewrites26.2%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f6426.2
Applied rewrites26.2%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (* (sqrt (/ 1.0 (* h l))) d))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
return sqrt((1.0 / (h * l))) * d;
}
M_m = private
NOTE: d, h, l, M_m, and D 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_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_m
real(8), intent (in) :: d_1
code = sqrt((1.0d0 / (h * l))) * d
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
return Math.sqrt((1.0 / (h * l))) * d;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): return math.sqrt((1.0 / (h * l))) * d
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) return Float64(sqrt(Float64(1.0 / Float64(h * l))) * d) end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp = code(d, h, l, M_m, D)
tmp = sqrt((1.0 / (h * l))) * d;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := N[(N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\sqrt{\frac{1}{h \cdot \ell}} \cdot d
\end{array}
Initial program 66.2%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6426.2
Applied rewrites26.2%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6426.2
Applied rewrites26.2%
herbie shell --seed 2025103
(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)))))