
(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 20 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l))))
(t_1 (* M (/ D_m (+ d d))))
(t_2 (- 1.0 (/ (* (* (* t_1 t_1) 0.5) h) l))))
(if (<= l -7.5e+105)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) t_0)
(if (<= l -1e-310)
(* (* (- d) (sqrt (/ 1.0 (* h l)))) t_2)
(if (<= l 1.1e-21)
(* (* (sqrt (/ 1.0 (* l h))) d) t_2)
(* (* (/ (sqrt d) (sqrt h)) (pow (/ d l) (/ 1.0 2.0))) t_0))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = 1.0 - (((1.0 / 2.0) * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l));
double t_1 = M * (D_m / (d + d));
double t_2 = 1.0 - ((((t_1 * t_1) * 0.5) * h) / l);
double tmp;
if (l <= -7.5e+105) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * t_0;
} else if (l <= -1e-310) {
tmp = (-d * sqrt((1.0 / (h * l)))) * t_2;
} else if (l <= 1.1e-21) {
tmp = (sqrt((1.0 / (l * h))) * d) * t_2;
} else {
tmp = ((sqrt(d) / sqrt(h)) * pow((d / l), (1.0 / 2.0))) * t_0;
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = 1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l))
t_1 = m * (d_m / (d + d))
t_2 = 1.0d0 - ((((t_1 * t_1) * 0.5d0) * h) / l)
if (l <= (-7.5d+105)) then
tmp = (sqrt((d / l)) * sqrt((d / h))) * t_0
else if (l <= (-1d-310)) then
tmp = (-d * sqrt((1.0d0 / (h * l)))) * t_2
else if (l <= 1.1d-21) then
tmp = (sqrt((1.0d0 / (l * h))) * d) * t_2
else
tmp = ((sqrt(d) / sqrt(h)) * ((d / l) ** (1.0d0 / 2.0d0))) * t_0
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = 1.0 - (((1.0 / 2.0) * Math.pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l));
double t_1 = M * (D_m / (d + d));
double t_2 = 1.0 - ((((t_1 * t_1) * 0.5) * h) / l);
double tmp;
if (l <= -7.5e+105) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * t_0;
} else if (l <= -1e-310) {
tmp = (-d * Math.sqrt((1.0 / (h * l)))) * t_2;
} else if (l <= 1.1e-21) {
tmp = (Math.sqrt((1.0 / (l * h))) * d) * t_2;
} else {
tmp = ((Math.sqrt(d) / Math.sqrt(h)) * Math.pow((d / l), (1.0 / 2.0))) * t_0;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = 1.0 - (((1.0 / 2.0) * math.pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)) t_1 = M * (D_m / (d + d)) t_2 = 1.0 - ((((t_1 * t_1) * 0.5) * h) / l) tmp = 0 if l <= -7.5e+105: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * t_0 elif l <= -1e-310: tmp = (-d * math.sqrt((1.0 / (h * l)))) * t_2 elif l <= 1.1e-21: tmp = (math.sqrt((1.0 / (l * h))) * d) * t_2 else: tmp = ((math.sqrt(d) / math.sqrt(h)) * math.pow((d / l), (1.0 / 2.0))) * t_0 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l))) t_1 = Float64(M * Float64(D_m / Float64(d + d))) t_2 = Float64(1.0 - Float64(Float64(Float64(Float64(t_1 * t_1) * 0.5) * h) / l)) tmp = 0.0 if (l <= -7.5e+105) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * t_0); elseif (l <= -1e-310) tmp = Float64(Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(h * l)))) * t_2); elseif (l <= 1.1e-21) tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d) * t_2); else tmp = Float64(Float64(Float64(sqrt(d) / sqrt(h)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * t_0); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = 1.0 - (((1.0 / 2.0) * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l));
t_1 = M * (D_m / (d + d));
t_2 = 1.0 - ((((t_1 * t_1) * 0.5) * h) / l);
tmp = 0.0;
if (l <= -7.5e+105)
tmp = (sqrt((d / l)) * sqrt((d / h))) * t_0;
elseif (l <= -1e-310)
tmp = (-d * sqrt((1.0 / (h * l)))) * t_2;
elseif (l <= 1.1e-21)
tmp = (sqrt((1.0 / (l * h))) * d) * t_2;
else
tmp = ((sqrt(d) / sqrt(h)) * ((d / l) ^ (1.0 / 2.0))) * t_0;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(M * N[(D$95$m / N[(d + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - N[(N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -7.5e+105], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[l, -1e-310], N[(N[((-d) * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[l, 1.1e-21], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] * t$95$2), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := 1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\\
t_1 := M \cdot \frac{D\_m}{d + d}\\
t_2 := 1 - \frac{\left(\left(t\_1 \cdot t\_1\right) \cdot 0.5\right) \cdot h}{\ell}\\
\mathbf{if}\;\ell \leq -7.5 \cdot 10^{+105}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot t\_0\\
\mathbf{elif}\;\ell \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\left(\left(-d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \cdot t\_2\\
\mathbf{elif}\;\ell \leq 1.1 \cdot 10^{-21}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\right) \cdot t\_2\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot t\_0\\
\end{array}
\end{array}
if l < -7.5000000000000002e105Initial program 54.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-/.f6454.2
Applied rewrites54.2%
if -7.5000000000000002e105 < l < -9.999999999999969e-311Initial program 72.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 rewrites75.1%
Taylor expanded in d around 0
metadata-evalN/A
metadata-evalN/A
unpow-prod-downN/A
*-commutativeN/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f641.0
Applied rewrites1.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
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6483.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6483.1
Applied rewrites83.1%
if -9.999999999999969e-311 < l < 1.1e-21Initial program 72.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 rewrites75.6%
Taylor expanded in d around 0
metadata-evalN/A
metadata-evalN/A
unpow-prod-downN/A
*-commutativeN/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f6485.4
Applied rewrites85.4%
if 1.1e-21 < l Initial program 61.5%
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6471.5
Applied rewrites71.5%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* M (/ D_m (+ d d))))
(t_1 (- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l))))
(if (<= l -7.5e+105)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l))))
(if (<= l -1e-310)
(* (* (- d) (sqrt (/ 1.0 (* h l)))) t_1)
(* (* (sqrt (/ 1.0 (* l h))) d) t_1)))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = M * (D_m / (d + d));
double t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l);
double tmp;
if (l <= -7.5e+105) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (((1.0 / 2.0) * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)));
} else if (l <= -1e-310) {
tmp = (-d * sqrt((1.0 / (h * l)))) * t_1;
} else {
tmp = (sqrt((1.0 / (l * h))) * d) * t_1;
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = m * (d_m / (d + d))
t_1 = 1.0d0 - ((((t_0 * t_0) * 0.5d0) * h) / l)
if (l <= (-7.5d+105)) then
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
else if (l <= (-1d-310)) then
tmp = (-d * sqrt((1.0d0 / (h * l)))) * t_1
else
tmp = (sqrt((1.0d0 / (l * h))) * d) * t_1
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = M * (D_m / (d + d));
double t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l);
double tmp;
if (l <= -7.5e+105) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)));
} else if (l <= -1e-310) {
tmp = (-d * Math.sqrt((1.0 / (h * l)))) * t_1;
} else {
tmp = (Math.sqrt((1.0 / (l * h))) * d) * t_1;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = M * (D_m / (d + d)) t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l) tmp = 0 if l <= -7.5e+105: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l))) elif l <= -1e-310: tmp = (-d * math.sqrt((1.0 / (h * l)))) * t_1 else: tmp = (math.sqrt((1.0 / (l * h))) * d) * t_1 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(M * Float64(D_m / Float64(d + d))) t_1 = Float64(1.0 - Float64(Float64(Float64(Float64(t_0 * t_0) * 0.5) * h) / l)) tmp = 0.0 if (l <= -7.5e+105) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))); elseif (l <= -1e-310) tmp = Float64(Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(h * l)))) * t_1); else tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d) * t_1); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = M * (D_m / (d + d));
t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l);
tmp = 0.0;
if (l <= -7.5e+105)
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (((1.0 / 2.0) * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
elseif (l <= -1e-310)
tmp = (-d * sqrt((1.0 / (h * l)))) * t_1;
else
tmp = (sqrt((1.0 / (l * h))) * d) * t_1;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(M * N[(D$95$m / N[(d + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -7.5e+105], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -1e-310], N[(N[((-d) * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := M \cdot \frac{D\_m}{d + d}\\
t_1 := 1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\\
\mathbf{if}\;\ell \leq -7.5 \cdot 10^{+105}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{elif}\;\ell \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\left(\left(-d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\right) \cdot t\_1\\
\end{array}
\end{array}
if l < -7.5000000000000002e105Initial program 54.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-/.f6454.2
Applied rewrites54.2%
if -7.5000000000000002e105 < l < -9.999999999999969e-311Initial program 72.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 rewrites75.1%
Taylor expanded in d around 0
metadata-evalN/A
metadata-evalN/A
unpow-prod-downN/A
*-commutativeN/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f641.0
Applied rewrites1.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
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6483.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6483.1
Applied rewrites83.1%
if -9.999999999999969e-311 < l Initial program 66.4%
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 rewrites67.0%
Taylor expanded in d around 0
metadata-evalN/A
metadata-evalN/A
unpow-prod-downN/A
*-commutativeN/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f6473.0
Applied rewrites73.0%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* M (/ D_m (+ d d))))
(t_1 (* (* t_0 t_0) 0.5))
(t_2 (- 1.0 (/ (* t_1 h) l))))
(if (<= l -7.5e+105)
(* (sqrt (/ d h)) (* (sqrt (/ d l)) (- 1.0 (* t_1 (/ h l)))))
(if (<= l -1e-310)
(* (* (- d) (sqrt (/ 1.0 (* h l)))) t_2)
(* (* (sqrt (/ 1.0 (* l h))) d) t_2)))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = M * (D_m / (d + d));
double t_1 = (t_0 * t_0) * 0.5;
double t_2 = 1.0 - ((t_1 * h) / l);
double tmp;
if (l <= -7.5e+105) {
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 - (t_1 * (h / l))));
} else if (l <= -1e-310) {
tmp = (-d * sqrt((1.0 / (h * l)))) * t_2;
} else {
tmp = (sqrt((1.0 / (l * h))) * d) * t_2;
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = m * (d_m / (d + d))
t_1 = (t_0 * t_0) * 0.5d0
t_2 = 1.0d0 - ((t_1 * h) / l)
if (l <= (-7.5d+105)) then
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0d0 - (t_1 * (h / l))))
else if (l <= (-1d-310)) then
tmp = (-d * sqrt((1.0d0 / (h * l)))) * t_2
else
tmp = (sqrt((1.0d0 / (l * h))) * d) * t_2
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = M * (D_m / (d + d));
double t_1 = (t_0 * t_0) * 0.5;
double t_2 = 1.0 - ((t_1 * h) / l);
double tmp;
if (l <= -7.5e+105) {
tmp = Math.sqrt((d / h)) * (Math.sqrt((d / l)) * (1.0 - (t_1 * (h / l))));
} else if (l <= -1e-310) {
tmp = (-d * Math.sqrt((1.0 / (h * l)))) * t_2;
} else {
tmp = (Math.sqrt((1.0 / (l * h))) * d) * t_2;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = M * (D_m / (d + d)) t_1 = (t_0 * t_0) * 0.5 t_2 = 1.0 - ((t_1 * h) / l) tmp = 0 if l <= -7.5e+105: tmp = math.sqrt((d / h)) * (math.sqrt((d / l)) * (1.0 - (t_1 * (h / l)))) elif l <= -1e-310: tmp = (-d * math.sqrt((1.0 / (h * l)))) * t_2 else: tmp = (math.sqrt((1.0 / (l * h))) * d) * t_2 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(M * Float64(D_m / Float64(d + d))) t_1 = Float64(Float64(t_0 * t_0) * 0.5) t_2 = Float64(1.0 - Float64(Float64(t_1 * h) / l)) tmp = 0.0 if (l <= -7.5e+105) tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(d / l)) * Float64(1.0 - Float64(t_1 * Float64(h / l))))); elseif (l <= -1e-310) tmp = Float64(Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(h * l)))) * t_2); else tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d) * t_2); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = M * (D_m / (d + d));
t_1 = (t_0 * t_0) * 0.5;
t_2 = 1.0 - ((t_1 * h) / l);
tmp = 0.0;
if (l <= -7.5e+105)
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 - (t_1 * (h / l))));
elseif (l <= -1e-310)
tmp = (-d * sqrt((1.0 / (h * l)))) * t_2;
else
tmp = (sqrt((1.0 / (l * h))) * d) * t_2;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(M * N[(D$95$m / N[(d + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - N[(N[(t$95$1 * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -7.5e+105], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(t$95$1 * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -1e-310], N[(N[((-d) * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] * t$95$2), $MachinePrecision]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := M \cdot \frac{D\_m}{d + d}\\
t_1 := \left(t\_0 \cdot t\_0\right) \cdot 0.5\\
t_2 := 1 - \frac{t\_1 \cdot h}{\ell}\\
\mathbf{if}\;\ell \leq -7.5 \cdot 10^{+105}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - t\_1 \cdot \frac{h}{\ell}\right)\right)\\
\mathbf{elif}\;\ell \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\left(\left(-d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \cdot t\_2\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\right) \cdot t\_2\\
\end{array}
\end{array}
if l < -7.5000000000000002e105Initial program 54.2%
Applied rewrites54.5%
if -7.5000000000000002e105 < l < -9.999999999999969e-311Initial program 72.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 rewrites75.1%
Taylor expanded in d around 0
metadata-evalN/A
metadata-evalN/A
unpow-prod-downN/A
*-commutativeN/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f641.0
Applied rewrites1.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
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6483.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6483.1
Applied rewrites83.1%
if -9.999999999999969e-311 < l Initial program 66.4%
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 rewrites67.0%
Taylor expanded in d around 0
metadata-evalN/A
metadata-evalN/A
unpow-prod-downN/A
*-commutativeN/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f6473.0
Applied rewrites73.0%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* M (/ D_m (+ d d))))
(t_1 (- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l))))
(if (<= l -1.25e+226)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)
(if (<= l -1e-310)
(* (* (- d) (sqrt (/ 1.0 (* h l)))) t_1)
(* (* (sqrt (/ 1.0 (* l h))) d) t_1)))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = M * (D_m / (d + d));
double t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l);
double tmp;
if (l <= -1.25e+226) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
} else if (l <= -1e-310) {
tmp = (-d * sqrt((1.0 / (h * l)))) * t_1;
} else {
tmp = (sqrt((1.0 / (l * h))) * d) * t_1;
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = m * (d_m / (d + d))
t_1 = 1.0d0 - ((((t_0 * t_0) * 0.5d0) * h) / l)
if (l <= (-1.25d+226)) then
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0d0
else if (l <= (-1d-310)) then
tmp = (-d * sqrt((1.0d0 / (h * l)))) * t_1
else
tmp = (sqrt((1.0d0 / (l * h))) * d) * t_1
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = M * (D_m / (d + d));
double t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l);
double tmp;
if (l <= -1.25e+226) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * 1.0;
} else if (l <= -1e-310) {
tmp = (-d * Math.sqrt((1.0 / (h * l)))) * t_1;
} else {
tmp = (Math.sqrt((1.0 / (l * h))) * d) * t_1;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = M * (D_m / (d + d)) t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l) tmp = 0 if l <= -1.25e+226: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * 1.0 elif l <= -1e-310: tmp = (-d * math.sqrt((1.0 / (h * l)))) * t_1 else: tmp = (math.sqrt((1.0 / (l * h))) * d) * t_1 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(M * Float64(D_m / Float64(d + d))) t_1 = Float64(1.0 - Float64(Float64(Float64(Float64(t_0 * t_0) * 0.5) * h) / l)) tmp = 0.0 if (l <= -1.25e+226) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); elseif (l <= -1e-310) tmp = Float64(Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(h * l)))) * t_1); else tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d) * t_1); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = M * (D_m / (d + d));
t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l);
tmp = 0.0;
if (l <= -1.25e+226)
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
elseif (l <= -1e-310)
tmp = (-d * sqrt((1.0 / (h * l)))) * t_1;
else
tmp = (sqrt((1.0 / (l * h))) * d) * t_1;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(M * N[(D$95$m / N[(d + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.25e+226], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[l, -1e-310], N[(N[((-d) * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := M \cdot \frac{D\_m}{d + d}\\
t_1 := 1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\\
\mathbf{if}\;\ell \leq -1.25 \cdot 10^{+226}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot 1\\
\mathbf{elif}\;\ell \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\left(\left(-d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\right) \cdot t\_1\\
\end{array}
\end{array}
if l < -1.2500000000000001e226Initial program 47.2%
Taylor expanded in d around inf
Applied rewrites44.4%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6444.4
Applied rewrites44.4%
if -1.2500000000000001e226 < l < -9.999999999999969e-311Initial program 69.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 rewrites71.2%
Taylor expanded in d around 0
metadata-evalN/A
metadata-evalN/A
unpow-prod-downN/A
*-commutativeN/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f641.9
Applied rewrites1.9%
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
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6478.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.4
Applied rewrites78.4%
if -9.999999999999969e-311 < l Initial program 66.4%
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 rewrites67.0%
Taylor expanded in d around 0
metadata-evalN/A
metadata-evalN/A
unpow-prod-downN/A
*-commutativeN/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f6473.0
Applied rewrites73.0%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (sqrt (/ 1.0 (* l h))))
(t_1 (* M (/ D_m (+ d d))))
(t_2 (- 1.0 (/ (* (* (* t_1 t_1) 0.5) h) l))))
(if (<= l -5.2e+80)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)
(if (<= l -6.5e-66)
(-
(*
(fma
(* (/ (* (* (* M M) D_m) D_m) (* d d)) (sqrt (/ h (* (* l l) l))))
-0.125
t_0)
d))
(if (<= l -1e-310)
(* (sqrt (* d (/ d (* h l)))) t_2)
(* (* t_0 d) t_2))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = sqrt((1.0 / (l * h)));
double t_1 = M * (D_m / (d + d));
double t_2 = 1.0 - ((((t_1 * t_1) * 0.5) * h) / l);
double tmp;
if (l <= -5.2e+80) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
} else if (l <= -6.5e-66) {
tmp = -(fma((((((M * M) * D_m) * D_m) / (d * d)) * sqrt((h / ((l * l) * l)))), -0.125, t_0) * d);
} else if (l <= -1e-310) {
tmp = sqrt((d * (d / (h * l)))) * t_2;
} else {
tmp = (t_0 * d) * t_2;
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = sqrt(Float64(1.0 / Float64(l * h))) t_1 = Float64(M * Float64(D_m / Float64(d + d))) t_2 = Float64(1.0 - Float64(Float64(Float64(Float64(t_1 * t_1) * 0.5) * h) / l)) tmp = 0.0 if (l <= -5.2e+80) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); elseif (l <= -6.5e-66) tmp = Float64(-Float64(fma(Float64(Float64(Float64(Float64(Float64(M * M) * D_m) * D_m) / Float64(d * d)) * sqrt(Float64(h / Float64(Float64(l * l) * l)))), -0.125, t_0) * d)); elseif (l <= -1e-310) tmp = Float64(sqrt(Float64(d * Float64(d / Float64(h * l)))) * t_2); else tmp = Float64(Float64(t_0 * d) * t_2); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(M * N[(D$95$m / N[(d + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - N[(N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -5.2e+80], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[l, -6.5e-66], (-N[(N[(N[(N[(N[(N[(N[(M * M), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * -0.125 + t$95$0), $MachinePrecision] * d), $MachinePrecision]), If[LessEqual[l, -1e-310], N[(N[Sqrt[N[(d * N[(d / N[(h * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$2), $MachinePrecision], N[(N[(t$95$0 * d), $MachinePrecision] * t$95$2), $MachinePrecision]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{1}{\ell \cdot h}}\\
t_1 := M \cdot \frac{D\_m}{d + d}\\
t_2 := 1 - \frac{\left(\left(t\_1 \cdot t\_1\right) \cdot 0.5\right) \cdot h}{\ell}\\
\mathbf{if}\;\ell \leq -5.2 \cdot 10^{+80}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot 1\\
\mathbf{elif}\;\ell \leq -6.5 \cdot 10^{-66}:\\
\;\;\;\;-\mathsf{fma}\left(\frac{\left(\left(M \cdot M\right) \cdot D\_m\right) \cdot D\_m}{d \cdot d} \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}, -0.125, t\_0\right) \cdot d\\
\mathbf{elif}\;\ell \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\sqrt{d \cdot \frac{d}{h \cdot \ell}} \cdot t\_2\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 \cdot d\right) \cdot t\_2\\
\end{array}
\end{array}
if l < -5.19999999999999963e80Initial program 55.6%
Taylor expanded in d around inf
Applied rewrites44.6%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6444.6
Applied rewrites44.6%
if -5.19999999999999963e80 < l < -6.50000000000000024e-66Initial program 74.7%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6458.8
lift-/.f64N/A
metadata-eval58.8
Applied rewrites58.8%
Taylor expanded in d around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites62.2%
if -6.50000000000000024e-66 < l < -9.999999999999969e-311Initial program 72.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 rewrites76.4%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6476.4
Applied rewrites76.4%
lift-/.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
metadata-evalN/A
pow-prod-upN/A
pow2N/A
lower-pow.f64N/A
lift-pow.f64N/A
lift-/.f6476.3
Applied rewrites76.3%
lift-*.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
*-commutativeN/A
pow1/2N/A
pow-powN/A
metadata-evalN/A
pow-prod-downN/A
unpow1/2N/A
lower-sqrt.f64N/A
*-commutativeN/A
times-fracN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lift-*.f6466.5
Applied rewrites66.5%
if -9.999999999999969e-311 < l Initial program 66.4%
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 rewrites67.0%
Taylor expanded in d around 0
metadata-evalN/A
metadata-evalN/A
unpow-prod-downN/A
*-commutativeN/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f6473.0
Applied rewrites73.0%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (sqrt (/ 1.0 (* l h)))) (t_1 (* M (/ D_m (+ d d)))))
(if (<= d -9.2e+150)
(* d (- t_0))
(if (<= d -2.1e-113)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (/ (* (* (/ (* (* M M) (* D_m D_m)) (* d d)) 0.125) h) l)))
(if (<= d -2.5e-304)
(*
(* (* (* D_m D_m) (/ (* -1.0 (* M M)) d)) (sqrt (/ h (* (* l l) l))))
-0.125)
(* (* t_0 d) (- 1.0 (/ (* (* (* t_1 t_1) 0.5) h) l))))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = sqrt((1.0 / (l * h)));
double t_1 = M * (D_m / (d + d));
double tmp;
if (d <= -9.2e+150) {
tmp = d * -t_0;
} else if (d <= -2.1e-113) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((((((M * M) * (D_m * D_m)) / (d * d)) * 0.125) * h) / l));
} else if (d <= -2.5e-304) {
tmp = (((D_m * D_m) * ((-1.0 * (M * M)) / d)) * sqrt((h / ((l * l) * l)))) * -0.125;
} else {
tmp = (t_0 * d) * (1.0 - ((((t_1 * t_1) * 0.5) * h) / l));
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sqrt((1.0d0 / (l * h)))
t_1 = m * (d_m / (d + d))
if (d <= (-9.2d+150)) then
tmp = d * -t_0
else if (d <= (-2.1d-113)) then
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0d0 - ((((((m * m) * (d_m * d_m)) / (d * d)) * 0.125d0) * h) / l))
else if (d <= (-2.5d-304)) then
tmp = (((d_m * d_m) * (((-1.0d0) * (m * m)) / d)) * sqrt((h / ((l * l) * l)))) * (-0.125d0)
else
tmp = (t_0 * d) * (1.0d0 - ((((t_1 * t_1) * 0.5d0) * h) / l))
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = Math.sqrt((1.0 / (l * h)));
double t_1 = M * (D_m / (d + d));
double tmp;
if (d <= -9.2e+150) {
tmp = d * -t_0;
} else if (d <= -2.1e-113) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * (1.0 - ((((((M * M) * (D_m * D_m)) / (d * d)) * 0.125) * h) / l));
} else if (d <= -2.5e-304) {
tmp = (((D_m * D_m) * ((-1.0 * (M * M)) / d)) * Math.sqrt((h / ((l * l) * l)))) * -0.125;
} else {
tmp = (t_0 * d) * (1.0 - ((((t_1 * t_1) * 0.5) * h) / l));
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = math.sqrt((1.0 / (l * h))) t_1 = M * (D_m / (d + d)) tmp = 0 if d <= -9.2e+150: tmp = d * -t_0 elif d <= -2.1e-113: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * (1.0 - ((((((M * M) * (D_m * D_m)) / (d * d)) * 0.125) * h) / l)) elif d <= -2.5e-304: tmp = (((D_m * D_m) * ((-1.0 * (M * M)) / d)) * math.sqrt((h / ((l * l) * l)))) * -0.125 else: tmp = (t_0 * d) * (1.0 - ((((t_1 * t_1) * 0.5) * h) / l)) return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = sqrt(Float64(1.0 / Float64(l * h))) t_1 = Float64(M * Float64(D_m / Float64(d + d))) tmp = 0.0 if (d <= -9.2e+150) tmp = Float64(d * Float64(-t_0)); elseif (d <= -2.1e-113) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64(Float64(Float64(Float64(M * M) * Float64(D_m * D_m)) / Float64(d * d)) * 0.125) * h) / l))); elseif (d <= -2.5e-304) tmp = Float64(Float64(Float64(Float64(D_m * D_m) * Float64(Float64(-1.0 * Float64(M * M)) / d)) * sqrt(Float64(h / Float64(Float64(l * l) * l)))) * -0.125); else tmp = Float64(Float64(t_0 * d) * Float64(1.0 - Float64(Float64(Float64(Float64(t_1 * t_1) * 0.5) * h) / l))); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = sqrt((1.0 / (l * h)));
t_1 = M * (D_m / (d + d));
tmp = 0.0;
if (d <= -9.2e+150)
tmp = d * -t_0;
elseif (d <= -2.1e-113)
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((((((M * M) * (D_m * D_m)) / (d * d)) * 0.125) * h) / l));
elseif (d <= -2.5e-304)
tmp = (((D_m * D_m) * ((-1.0 * (M * M)) / d)) * sqrt((h / ((l * l) * l)))) * -0.125;
else
tmp = (t_0 * d) * (1.0 - ((((t_1 * t_1) * 0.5) * h) / l));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(M * N[(D$95$m / N[(d + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -9.2e+150], N[(d * (-t$95$0)), $MachinePrecision], If[LessEqual[d, -2.1e-113], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(N[(N[(M * M), $MachinePrecision] * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.5e-304], N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * N[(N[(-1.0 * N[(M * M), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision], N[(N[(t$95$0 * d), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{1}{\ell \cdot h}}\\
t_1 := M \cdot \frac{D\_m}{d + d}\\
\mathbf{if}\;d \leq -9.2 \cdot 10^{+150}:\\
\;\;\;\;d \cdot \left(-t\_0\right)\\
\mathbf{elif}\;d \leq -2.1 \cdot 10^{-113}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \frac{\left(\frac{\left(M \cdot M\right) \cdot \left(D\_m \cdot D\_m\right)}{d \cdot d} \cdot 0.125\right) \cdot h}{\ell}\right)\\
\mathbf{elif}\;d \leq -2.5 \cdot 10^{-304}:\\
\;\;\;\;\left(\left(\left(D\_m \cdot D\_m\right) \cdot \frac{-1 \cdot \left(M \cdot M\right)}{d}\right) \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\right) \cdot -0.125\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 \cdot d\right) \cdot \left(1 - \frac{\left(\left(t\_1 \cdot t\_1\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\
\end{array}
\end{array}
if d < -9.20000000000000004e150Initial program 71.5%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6462.7
lift-/.f64N/A
metadata-eval62.7
Applied rewrites62.7%
Taylor expanded in d around -inf
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6469.2
Applied rewrites69.2%
if -9.20000000000000004e150 < d < -2.1e-113Initial program 78.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 rewrites79.7%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6479.7
Applied rewrites79.7%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
unpow2N/A
lower-*.f6465.4
Applied rewrites65.4%
if -2.1e-113 < d < -2.49999999999999983e-304Initial program 48.2%
Taylor expanded in h around -inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites38.2%
if -2.49999999999999983e-304 < d Initial program 66.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 rewrites66.6%
Taylor expanded in d around 0
metadata-evalN/A
metadata-evalN/A
unpow-prod-downN/A
*-commutativeN/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f6472.5
Applied rewrites72.5%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (sqrt (/ h (* (* l l) l)))))
(if (<= d -9.2e+150)
(* d (- (sqrt (/ 1.0 (* l h)))))
(if (<= d -2.1e-113)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (/ (* (* (/ (* (* M M) (* D_m D_m)) (* d d)) 0.125) h) l)))
(if (<= d -2.5e-304)
(* (* (* (* D_m D_m) (/ (* -1.0 (* M M)) d)) t_0) -0.125)
(if (<= d 7.6e-150)
(* (* -0.125 (* (* D_m D_m) (* M (/ M d)))) t_0)
(if (<= d 1.55e+147)
(*
(-
1.0
(*
(* 0.5 (* M (/ (* 0.25 (* (* D_m D_m) M)) (* d d))))
(/ h l)))
(sqrt (/ (* d d) (* l h))))
(/ (* 1.0 d) (* (sqrt l) (sqrt h))))))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = sqrt((h / ((l * l) * l)));
double tmp;
if (d <= -9.2e+150) {
tmp = d * -sqrt((1.0 / (l * h)));
} else if (d <= -2.1e-113) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((((((M * M) * (D_m * D_m)) / (d * d)) * 0.125) * h) / l));
} else if (d <= -2.5e-304) {
tmp = (((D_m * D_m) * ((-1.0 * (M * M)) / d)) * t_0) * -0.125;
} else if (d <= 7.6e-150) {
tmp = (-0.125 * ((D_m * D_m) * (M * (M / d)))) * t_0;
} else if (d <= 1.55e+147) {
tmp = (1.0 - ((0.5 * (M * ((0.25 * ((D_m * D_m) * M)) / (d * d)))) * (h / l))) * sqrt(((d * d) / (l * h)));
} else {
tmp = (1.0 * d) / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((h / ((l * l) * l)))
if (d <= (-9.2d+150)) then
tmp = d * -sqrt((1.0d0 / (l * h)))
else if (d <= (-2.1d-113)) then
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0d0 - ((((((m * m) * (d_m * d_m)) / (d * d)) * 0.125d0) * h) / l))
else if (d <= (-2.5d-304)) then
tmp = (((d_m * d_m) * (((-1.0d0) * (m * m)) / d)) * t_0) * (-0.125d0)
else if (d <= 7.6d-150) then
tmp = ((-0.125d0) * ((d_m * d_m) * (m * (m / d)))) * t_0
else if (d <= 1.55d+147) then
tmp = (1.0d0 - ((0.5d0 * (m * ((0.25d0 * ((d_m * d_m) * m)) / (d * d)))) * (h / l))) * sqrt(((d * d) / (l * h)))
else
tmp = (1.0d0 * d) / (sqrt(l) * sqrt(h))
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = Math.sqrt((h / ((l * l) * l)));
double tmp;
if (d <= -9.2e+150) {
tmp = d * -Math.sqrt((1.0 / (l * h)));
} else if (d <= -2.1e-113) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * (1.0 - ((((((M * M) * (D_m * D_m)) / (d * d)) * 0.125) * h) / l));
} else if (d <= -2.5e-304) {
tmp = (((D_m * D_m) * ((-1.0 * (M * M)) / d)) * t_0) * -0.125;
} else if (d <= 7.6e-150) {
tmp = (-0.125 * ((D_m * D_m) * (M * (M / d)))) * t_0;
} else if (d <= 1.55e+147) {
tmp = (1.0 - ((0.5 * (M * ((0.25 * ((D_m * D_m) * M)) / (d * d)))) * (h / l))) * Math.sqrt(((d * d) / (l * h)));
} else {
tmp = (1.0 * d) / (Math.sqrt(l) * Math.sqrt(h));
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = math.sqrt((h / ((l * l) * l))) tmp = 0 if d <= -9.2e+150: tmp = d * -math.sqrt((1.0 / (l * h))) elif d <= -2.1e-113: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * (1.0 - ((((((M * M) * (D_m * D_m)) / (d * d)) * 0.125) * h) / l)) elif d <= -2.5e-304: tmp = (((D_m * D_m) * ((-1.0 * (M * M)) / d)) * t_0) * -0.125 elif d <= 7.6e-150: tmp = (-0.125 * ((D_m * D_m) * (M * (M / d)))) * t_0 elif d <= 1.55e+147: tmp = (1.0 - ((0.5 * (M * ((0.25 * ((D_m * D_m) * M)) / (d * d)))) * (h / l))) * math.sqrt(((d * d) / (l * h))) else: tmp = (1.0 * d) / (math.sqrt(l) * math.sqrt(h)) return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = sqrt(Float64(h / Float64(Float64(l * l) * l))) tmp = 0.0 if (d <= -9.2e+150) tmp = Float64(d * Float64(-sqrt(Float64(1.0 / Float64(l * h))))); elseif (d <= -2.1e-113) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64(Float64(Float64(Float64(M * M) * Float64(D_m * D_m)) / Float64(d * d)) * 0.125) * h) / l))); elseif (d <= -2.5e-304) tmp = Float64(Float64(Float64(Float64(D_m * D_m) * Float64(Float64(-1.0 * Float64(M * M)) / d)) * t_0) * -0.125); elseif (d <= 7.6e-150) tmp = Float64(Float64(-0.125 * Float64(Float64(D_m * D_m) * Float64(M * Float64(M / d)))) * t_0); elseif (d <= 1.55e+147) tmp = Float64(Float64(1.0 - Float64(Float64(0.5 * Float64(M * Float64(Float64(0.25 * Float64(Float64(D_m * D_m) * M)) / Float64(d * d)))) * Float64(h / l))) * sqrt(Float64(Float64(d * d) / Float64(l * h)))); else tmp = Float64(Float64(1.0 * d) / Float64(sqrt(l) * sqrt(h))); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = sqrt((h / ((l * l) * l)));
tmp = 0.0;
if (d <= -9.2e+150)
tmp = d * -sqrt((1.0 / (l * h)));
elseif (d <= -2.1e-113)
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((((((M * M) * (D_m * D_m)) / (d * d)) * 0.125) * h) / l));
elseif (d <= -2.5e-304)
tmp = (((D_m * D_m) * ((-1.0 * (M * M)) / d)) * t_0) * -0.125;
elseif (d <= 7.6e-150)
tmp = (-0.125 * ((D_m * D_m) * (M * (M / d)))) * t_0;
elseif (d <= 1.55e+147)
tmp = (1.0 - ((0.5 * (M * ((0.25 * ((D_m * D_m) * M)) / (d * d)))) * (h / l))) * sqrt(((d * d) / (l * h)));
else
tmp = (1.0 * d) / (sqrt(l) * sqrt(h));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -9.2e+150], N[(d * (-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[d, -2.1e-113], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(N[(N[(M * M), $MachinePrecision] * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.5e-304], N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * N[(N[(-1.0 * N[(M * M), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * -0.125), $MachinePrecision], If[LessEqual[d, 7.6e-150], N[(N[(-0.125 * N[(N[(D$95$m * D$95$m), $MachinePrecision] * N[(M * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[d, 1.55e+147], N[(N[(1.0 - N[(N[(0.5 * N[(M * N[(N[(0.25 * N[(N[(D$95$m * D$95$m), $MachinePrecision] * M), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[(d * d), $MachinePrecision] / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 * d), $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\
\mathbf{if}\;d \leq -9.2 \cdot 10^{+150}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{1}{\ell \cdot h}}\right)\\
\mathbf{elif}\;d \leq -2.1 \cdot 10^{-113}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \frac{\left(\frac{\left(M \cdot M\right) \cdot \left(D\_m \cdot D\_m\right)}{d \cdot d} \cdot 0.125\right) \cdot h}{\ell}\right)\\
\mathbf{elif}\;d \leq -2.5 \cdot 10^{-304}:\\
\;\;\;\;\left(\left(\left(D\_m \cdot D\_m\right) \cdot \frac{-1 \cdot \left(M \cdot M\right)}{d}\right) \cdot t\_0\right) \cdot -0.125\\
\mathbf{elif}\;d \leq 7.6 \cdot 10^{-150}:\\
\;\;\;\;\left(-0.125 \cdot \left(\left(D\_m \cdot D\_m\right) \cdot \left(M \cdot \frac{M}{d}\right)\right)\right) \cdot t\_0\\
\mathbf{elif}\;d \leq 1.55 \cdot 10^{+147}:\\
\;\;\;\;\left(1 - \left(0.5 \cdot \left(M \cdot \frac{0.25 \cdot \left(\left(D\_m \cdot D\_m\right) \cdot M\right)}{d \cdot d}\right)\right) \cdot \frac{h}{\ell}\right) \cdot \sqrt{\frac{d \cdot d}{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if d < -9.20000000000000004e150Initial program 71.5%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6462.7
lift-/.f64N/A
metadata-eval62.7
Applied rewrites62.7%
Taylor expanded in d around -inf
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6469.2
Applied rewrites69.2%
if -9.20000000000000004e150 < d < -2.1e-113Initial program 78.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 rewrites79.7%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6479.7
Applied rewrites79.7%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
unpow2N/A
lower-*.f6465.4
Applied rewrites65.4%
if -2.1e-113 < d < -2.49999999999999983e-304Initial program 48.2%
Taylor expanded in h around -inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites38.2%
if -2.49999999999999983e-304 < d < 7.5999999999999997e-150Initial program 42.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 rewrites40.6%
Taylor expanded in d around 0
Applied rewrites40.6%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6445.4
Applied rewrites45.4%
if 7.5999999999999997e-150 < d < 1.55e147Initial program 75.4%
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 rewrites76.5%
Applied rewrites57.5%
Taylor expanded in d around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6451.7
Applied rewrites51.7%
if 1.55e147 < d Initial program 72.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6467.3
Applied rewrites67.3%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
*-commutativeN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-*.f6467.3
Applied rewrites67.3%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
*-commutativeN/A
lower-*.f6467.3
Applied rewrites67.3%
lift-*.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6478.2
Applied rewrites78.2%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (/ (* (* (/ (* (* M M) (* D_m D_m)) (* d d)) 0.125) h) l))))
(t_1 (sqrt (/ h (* (* l l) l)))))
(if (<= d -9.2e+150)
(* d (- (sqrt (/ 1.0 (* l h)))))
(if (<= d -2.1e-113)
t_0
(if (<= d -2.5e-304)
(* (* (* (* D_m D_m) (/ (* -1.0 (* M M)) d)) t_1) -0.125)
(if (<= d 2.7e-155)
(* (* -0.125 (* (* D_m D_m) (* M (/ M d)))) t_1)
(if (<= d 1.75e+139) t_0 (/ (* 1.0 d) (* (sqrt l) (sqrt h))))))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((((((M * M) * (D_m * D_m)) / (d * d)) * 0.125) * h) / l));
double t_1 = sqrt((h / ((l * l) * l)));
double tmp;
if (d <= -9.2e+150) {
tmp = d * -sqrt((1.0 / (l * h)));
} else if (d <= -2.1e-113) {
tmp = t_0;
} else if (d <= -2.5e-304) {
tmp = (((D_m * D_m) * ((-1.0 * (M * M)) / d)) * t_1) * -0.125;
} else if (d <= 2.7e-155) {
tmp = (-0.125 * ((D_m * D_m) * (M * (M / d)))) * t_1;
} else if (d <= 1.75e+139) {
tmp = t_0;
} else {
tmp = (1.0 * d) / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (sqrt((d / l)) * sqrt((d / h))) * (1.0d0 - ((((((m * m) * (d_m * d_m)) / (d * d)) * 0.125d0) * h) / l))
t_1 = sqrt((h / ((l * l) * l)))
if (d <= (-9.2d+150)) then
tmp = d * -sqrt((1.0d0 / (l * h)))
else if (d <= (-2.1d-113)) then
tmp = t_0
else if (d <= (-2.5d-304)) then
tmp = (((d_m * d_m) * (((-1.0d0) * (m * m)) / d)) * t_1) * (-0.125d0)
else if (d <= 2.7d-155) then
tmp = ((-0.125d0) * ((d_m * d_m) * (m * (m / d)))) * t_1
else if (d <= 1.75d+139) then
tmp = t_0
else
tmp = (1.0d0 * d) / (sqrt(l) * sqrt(h))
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * (1.0 - ((((((M * M) * (D_m * D_m)) / (d * d)) * 0.125) * h) / l));
double t_1 = Math.sqrt((h / ((l * l) * l)));
double tmp;
if (d <= -9.2e+150) {
tmp = d * -Math.sqrt((1.0 / (l * h)));
} else if (d <= -2.1e-113) {
tmp = t_0;
} else if (d <= -2.5e-304) {
tmp = (((D_m * D_m) * ((-1.0 * (M * M)) / d)) * t_1) * -0.125;
} else if (d <= 2.7e-155) {
tmp = (-0.125 * ((D_m * D_m) * (M * (M / d)))) * t_1;
} else if (d <= 1.75e+139) {
tmp = t_0;
} else {
tmp = (1.0 * d) / (Math.sqrt(l) * Math.sqrt(h));
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = (math.sqrt((d / l)) * math.sqrt((d / h))) * (1.0 - ((((((M * M) * (D_m * D_m)) / (d * d)) * 0.125) * h) / l)) t_1 = math.sqrt((h / ((l * l) * l))) tmp = 0 if d <= -9.2e+150: tmp = d * -math.sqrt((1.0 / (l * h))) elif d <= -2.1e-113: tmp = t_0 elif d <= -2.5e-304: tmp = (((D_m * D_m) * ((-1.0 * (M * M)) / d)) * t_1) * -0.125 elif d <= 2.7e-155: tmp = (-0.125 * ((D_m * D_m) * (M * (M / d)))) * t_1 elif d <= 1.75e+139: tmp = t_0 else: tmp = (1.0 * d) / (math.sqrt(l) * math.sqrt(h)) return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64(Float64(Float64(Float64(M * M) * Float64(D_m * D_m)) / Float64(d * d)) * 0.125) * h) / l))) t_1 = sqrt(Float64(h / Float64(Float64(l * l) * l))) tmp = 0.0 if (d <= -9.2e+150) tmp = Float64(d * Float64(-sqrt(Float64(1.0 / Float64(l * h))))); elseif (d <= -2.1e-113) tmp = t_0; elseif (d <= -2.5e-304) tmp = Float64(Float64(Float64(Float64(D_m * D_m) * Float64(Float64(-1.0 * Float64(M * M)) / d)) * t_1) * -0.125); elseif (d <= 2.7e-155) tmp = Float64(Float64(-0.125 * Float64(Float64(D_m * D_m) * Float64(M * Float64(M / d)))) * t_1); elseif (d <= 1.75e+139) tmp = t_0; else tmp = Float64(Float64(1.0 * d) / Float64(sqrt(l) * sqrt(h))); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((((((M * M) * (D_m * D_m)) / (d * d)) * 0.125) * h) / l));
t_1 = sqrt((h / ((l * l) * l)));
tmp = 0.0;
if (d <= -9.2e+150)
tmp = d * -sqrt((1.0 / (l * h)));
elseif (d <= -2.1e-113)
tmp = t_0;
elseif (d <= -2.5e-304)
tmp = (((D_m * D_m) * ((-1.0 * (M * M)) / d)) * t_1) * -0.125;
elseif (d <= 2.7e-155)
tmp = (-0.125 * ((D_m * D_m) * (M * (M / d)))) * t_1;
elseif (d <= 1.75e+139)
tmp = t_0;
else
tmp = (1.0 * d) / (sqrt(l) * sqrt(h));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(N[(N[(M * M), $MachinePrecision] * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -9.2e+150], N[(d * (-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[d, -2.1e-113], t$95$0, If[LessEqual[d, -2.5e-304], N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * N[(N[(-1.0 * N[(M * M), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * -0.125), $MachinePrecision], If[LessEqual[d, 2.7e-155], N[(N[(-0.125 * N[(N[(D$95$m * D$95$m), $MachinePrecision] * N[(M * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[d, 1.75e+139], t$95$0, N[(N[(1.0 * d), $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \frac{\left(\frac{\left(M \cdot M\right) \cdot \left(D\_m \cdot D\_m\right)}{d \cdot d} \cdot 0.125\right) \cdot h}{\ell}\right)\\
t_1 := \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\
\mathbf{if}\;d \leq -9.2 \cdot 10^{+150}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{1}{\ell \cdot h}}\right)\\
\mathbf{elif}\;d \leq -2.1 \cdot 10^{-113}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -2.5 \cdot 10^{-304}:\\
\;\;\;\;\left(\left(\left(D\_m \cdot D\_m\right) \cdot \frac{-1 \cdot \left(M \cdot M\right)}{d}\right) \cdot t\_1\right) \cdot -0.125\\
\mathbf{elif}\;d \leq 2.7 \cdot 10^{-155}:\\
\;\;\;\;\left(-0.125 \cdot \left(\left(D\_m \cdot D\_m\right) \cdot \left(M \cdot \frac{M}{d}\right)\right)\right) \cdot t\_1\\
\mathbf{elif}\;d \leq 1.75 \cdot 10^{+139}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if d < -9.20000000000000004e150Initial program 71.5%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6462.7
lift-/.f64N/A
metadata-eval62.7
Applied rewrites62.7%
Taylor expanded in d around -inf
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6469.2
Applied rewrites69.2%
if -9.20000000000000004e150 < d < -2.1e-113 or 2.69999999999999981e-155 < d < 1.74999999999999989e139Initial program 76.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 rewrites77.9%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6477.9
Applied rewrites77.9%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
unpow2N/A
lower-*.f6464.3
Applied rewrites64.3%
if -2.1e-113 < d < -2.49999999999999983e-304Initial program 48.2%
Taylor expanded in h around -inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites38.2%
if -2.49999999999999983e-304 < d < 2.69999999999999981e-155Initial program 42.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 rewrites39.7%
Taylor expanded in d around 0
Applied rewrites41.2%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6446.2
Applied rewrites46.2%
if 1.74999999999999989e139 < d Initial program 76.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6423.6
Applied rewrites23.6%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
*-commutativeN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-*.f6423.4
Applied rewrites23.4%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
*-commutativeN/A
lower-*.f6423.4
Applied rewrites23.4%
lift-*.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6425.5
Applied rewrites25.5%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
: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 D_m) (* 2.0 d)) 2.0)) (/ h l))))
-5e-131)
(*
(- 1.0 (* (* (* (* (/ (* D_m M) (+ d d)) (/ D_m (+ d d))) M) 0.5) (/ h l)))
(sqrt (* d (/ d (* h l)))))
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
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 * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5e-131) {
tmp = (1.0 - ((((((D_m * M) / (d + d)) * (D_m / (d + d))) * M) * 0.5) * (h / l))) * sqrt((d * (d / (h * l))));
} else {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: tmp
if (((((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= (-5d-131)) then
tmp = (1.0d0 - ((((((d_m * m) / (d + d)) * (d_m / (d + d))) * m) * 0.5d0) * (h / l))) * sqrt((d * (d / (h * l))))
else
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0d0
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
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 * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5e-131) {
tmp = (1.0 - ((((((D_m * M) / (d + d)) * (D_m / (d + d))) * M) * 0.5) * (h / l))) * Math.sqrt((d * (d / (h * l))));
} else {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * 1.0;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): 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 * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5e-131: tmp = (1.0 - ((((((D_m * M) / (d + d)) * (D_m / (d + d))) * M) * 0.5) * (h / l))) * math.sqrt((d * (d / (h * l)))) else: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * 1.0 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) 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 * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= -5e-131) tmp = Float64(Float64(1.0 - Float64(Float64(Float64(Float64(Float64(Float64(D_m * M) / Float64(d + d)) * Float64(D_m / Float64(d + d))) * M) * 0.5) * Float64(h / l))) * sqrt(Float64(d * Float64(d / Float64(h * l))))); else tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
tmp = 0.0;
if (((((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= -5e-131)
tmp = (1.0 - ((((((D_m * M) / (d + d)) * (D_m / (d + d))) * M) * 0.5) * (h / l))) * sqrt((d * (d / (h * l))));
else
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := 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 * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e-131], N[(N[(1.0 - N[(N[(N[(N[(N[(N[(D$95$m * M), $MachinePrecision] / N[(d + d), $MachinePrecision]), $MachinePrecision] * N[(D$95$m / N[(d + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * M), $MachinePrecision] * 0.5), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d * N[(d / N[(h * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\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 \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -5 \cdot 10^{-131}:\\
\;\;\;\;\left(1 - \left(\left(\left(\frac{D\_m \cdot M}{d + d} \cdot \frac{D\_m}{d + d}\right) \cdot M\right) \cdot 0.5\right) \cdot \frac{h}{\ell}\right) \cdot \sqrt{d \cdot \frac{d}{h \cdot \ell}}\\
\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)))) < -5.0000000000000004e-131Initial program 85.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 rewrites84.6%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6484.6
Applied rewrites84.6%
lift-/.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
metadata-evalN/A
pow-prod-upN/A
pow2N/A
lower-pow.f64N/A
lift-pow.f64N/A
lift-/.f6484.6
Applied rewrites84.6%
Applied rewrites66.5%
if -5.0000000000000004e-131 < (*.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.5%
Taylor expanded in d around inf
Applied rewrites58.7%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6458.7
Applied rewrites58.7%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (sqrt (/ h (* (* l l) l)))))
(if (<= d -1.3e+75)
(* d (- (sqrt (/ 1.0 (* l h)))))
(if (<= d -2.1e-129)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)
(if (<= d -2.5e-304)
(* (* (* (* D_m D_m) (/ (* -1.0 (* M M)) d)) t_0) -0.125)
(if (<= d 6.8e-135)
(* (* -0.125 (* (* D_m D_m) (* M (/ M d)))) t_0)
(/ (* 1.0 d) (* (sqrt l) (sqrt h)))))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = sqrt((h / ((l * l) * l)));
double tmp;
if (d <= -1.3e+75) {
tmp = d * -sqrt((1.0 / (l * h)));
} else if (d <= -2.1e-129) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
} else if (d <= -2.5e-304) {
tmp = (((D_m * D_m) * ((-1.0 * (M * M)) / d)) * t_0) * -0.125;
} else if (d <= 6.8e-135) {
tmp = (-0.125 * ((D_m * D_m) * (M * (M / d)))) * t_0;
} else {
tmp = (1.0 * d) / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((h / ((l * l) * l)))
if (d <= (-1.3d+75)) then
tmp = d * -sqrt((1.0d0 / (l * h)))
else if (d <= (-2.1d-129)) then
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0d0
else if (d <= (-2.5d-304)) then
tmp = (((d_m * d_m) * (((-1.0d0) * (m * m)) / d)) * t_0) * (-0.125d0)
else if (d <= 6.8d-135) then
tmp = ((-0.125d0) * ((d_m * d_m) * (m * (m / d)))) * t_0
else
tmp = (1.0d0 * d) / (sqrt(l) * sqrt(h))
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = Math.sqrt((h / ((l * l) * l)));
double tmp;
if (d <= -1.3e+75) {
tmp = d * -Math.sqrt((1.0 / (l * h)));
} else if (d <= -2.1e-129) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * 1.0;
} else if (d <= -2.5e-304) {
tmp = (((D_m * D_m) * ((-1.0 * (M * M)) / d)) * t_0) * -0.125;
} else if (d <= 6.8e-135) {
tmp = (-0.125 * ((D_m * D_m) * (M * (M / d)))) * t_0;
} else {
tmp = (1.0 * d) / (Math.sqrt(l) * Math.sqrt(h));
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = math.sqrt((h / ((l * l) * l))) tmp = 0 if d <= -1.3e+75: tmp = d * -math.sqrt((1.0 / (l * h))) elif d <= -2.1e-129: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * 1.0 elif d <= -2.5e-304: tmp = (((D_m * D_m) * ((-1.0 * (M * M)) / d)) * t_0) * -0.125 elif d <= 6.8e-135: tmp = (-0.125 * ((D_m * D_m) * (M * (M / d)))) * t_0 else: tmp = (1.0 * d) / (math.sqrt(l) * math.sqrt(h)) return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = sqrt(Float64(h / Float64(Float64(l * l) * l))) tmp = 0.0 if (d <= -1.3e+75) tmp = Float64(d * Float64(-sqrt(Float64(1.0 / Float64(l * h))))); elseif (d <= -2.1e-129) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); elseif (d <= -2.5e-304) tmp = Float64(Float64(Float64(Float64(D_m * D_m) * Float64(Float64(-1.0 * Float64(M * M)) / d)) * t_0) * -0.125); elseif (d <= 6.8e-135) tmp = Float64(Float64(-0.125 * Float64(Float64(D_m * D_m) * Float64(M * Float64(M / d)))) * t_0); else tmp = Float64(Float64(1.0 * d) / Float64(sqrt(l) * sqrt(h))); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = sqrt((h / ((l * l) * l)));
tmp = 0.0;
if (d <= -1.3e+75)
tmp = d * -sqrt((1.0 / (l * h)));
elseif (d <= -2.1e-129)
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
elseif (d <= -2.5e-304)
tmp = (((D_m * D_m) * ((-1.0 * (M * M)) / d)) * t_0) * -0.125;
elseif (d <= 6.8e-135)
tmp = (-0.125 * ((D_m * D_m) * (M * (M / d)))) * t_0;
else
tmp = (1.0 * d) / (sqrt(l) * sqrt(h));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -1.3e+75], N[(d * (-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[d, -2.1e-129], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[d, -2.5e-304], N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * N[(N[(-1.0 * N[(M * M), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * -0.125), $MachinePrecision], If[LessEqual[d, 6.8e-135], N[(N[(-0.125 * N[(N[(D$95$m * D$95$m), $MachinePrecision] * N[(M * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(1.0 * d), $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\
\mathbf{if}\;d \leq -1.3 \cdot 10^{+75}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{1}{\ell \cdot h}}\right)\\
\mathbf{elif}\;d \leq -2.1 \cdot 10^{-129}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot 1\\
\mathbf{elif}\;d \leq -2.5 \cdot 10^{-304}:\\
\;\;\;\;\left(\left(\left(D\_m \cdot D\_m\right) \cdot \frac{-1 \cdot \left(M \cdot M\right)}{d}\right) \cdot t\_0\right) \cdot -0.125\\
\mathbf{elif}\;d \leq 6.8 \cdot 10^{-135}:\\
\;\;\;\;\left(-0.125 \cdot \left(\left(D\_m \cdot D\_m\right) \cdot \left(M \cdot \frac{M}{d}\right)\right)\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if d < -1.29999999999999992e75Initial program 72.8%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6463.4
lift-/.f64N/A
metadata-eval63.4
Applied rewrites63.4%
Taylor expanded in d around -inf
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6463.9
Applied rewrites63.9%
if -1.29999999999999992e75 < d < -2.1e-129Initial program 77.9%
Taylor expanded in d around inf
Applied rewrites41.5%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6441.5
Applied rewrites41.5%
if -2.1e-129 < d < -2.49999999999999983e-304Initial program 46.9%
Taylor expanded in h around -inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites38.7%
if -2.49999999999999983e-304 < d < 6.79999999999999978e-135Initial program 44.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 rewrites42.4%
Taylor expanded in d around 0
Applied rewrites40.0%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6444.3
Applied rewrites44.3%
if 6.79999999999999978e-135 < d Initial program 74.8%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6448.8
Applied rewrites48.8%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
*-commutativeN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-*.f6449.0
Applied rewrites49.0%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
*-commutativeN/A
lower-*.f6449.0
Applied rewrites49.0%
lift-*.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6459.3
Applied rewrites59.3%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* (sqrt (/ d l)) (sqrt (/ d h)))))
(if (<=
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l))))
-5e-142)
(* t_0 (* (/ (* (* (* M M) h) (* D_m D_m)) (* (* d d) l)) -0.125))
(* t_0 1.0))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = sqrt((d / l)) * sqrt((d / h));
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 * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5e-142) {
tmp = t_0 * (((((M * M) * h) * (D_m * D_m)) / ((d * d) * l)) * -0.125);
} else {
tmp = t_0 * 1.0;
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((d / l)) * sqrt((d / h))
if (((((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= (-5d-142)) then
tmp = t_0 * (((((m * m) * h) * (d_m * d_m)) / ((d * d) * l)) * (-0.125d0))
else
tmp = t_0 * 1.0d0
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = Math.sqrt((d / l)) * Math.sqrt((d / h));
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 * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5e-142) {
tmp = t_0 * (((((M * M) * h) * (D_m * D_m)) / ((d * d) * l)) * -0.125);
} else {
tmp = t_0 * 1.0;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = math.sqrt((d / l)) * math.sqrt((d / h)) 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 * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5e-142: tmp = t_0 * (((((M * M) * h) * (D_m * D_m)) / ((d * d) * l)) * -0.125) else: tmp = t_0 * 1.0 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) 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 * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= -5e-142) tmp = Float64(t_0 * Float64(Float64(Float64(Float64(Float64(M * M) * h) * Float64(D_m * D_m)) / Float64(Float64(d * d) * l)) * -0.125)); else tmp = Float64(t_0 * 1.0); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = sqrt((d / l)) * sqrt((d / h));
tmp = 0.0;
if (((((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= -5e-142)
tmp = t_0 * (((((M * M) * h) * (D_m * D_m)) / ((d * d) * l)) * -0.125);
else
tmp = t_0 * 1.0;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $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 * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e-142], N[(t$95$0 * N[(N[(N[(N[(N[(M * M), $MachinePrecision] * h), $MachinePrecision] * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * 1.0), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\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 \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -5 \cdot 10^{-142}:\\
\;\;\;\;t\_0 \cdot \left(\frac{\left(\left(M \cdot M\right) \cdot h\right) \cdot \left(D\_m \cdot D\_m\right)}{\left(d \cdot d\right) \cdot \ell} \cdot -0.125\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \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)))) < -5.0000000000000002e-142Initial program 85.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 rewrites84.6%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6484.6
Applied rewrites84.6%
Taylor expanded in d around 0
Applied rewrites51.0%
if -5.0000000000000002e-142 < (*.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.5%
Taylor expanded in d around inf
Applied rewrites58.8%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6458.8
Applied rewrites58.8%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
: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 D_m) (* 2.0 d)) 2.0)) (/ h l))))
0.0)
(* (* -0.125 (* (* D_m D_m) (* M (/ M d)))) (sqrt (/ h (* (* l l) l))))
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
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 * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 0.0) {
tmp = (-0.125 * ((D_m * D_m) * (M * (M / d)))) * sqrt((h / ((l * l) * l)));
} else {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: tmp
if (((((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= 0.0d0) then
tmp = ((-0.125d0) * ((d_m * d_m) * (m * (m / d)))) * sqrt((h / ((l * l) * l)))
else
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0d0
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
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 * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 0.0) {
tmp = (-0.125 * ((D_m * D_m) * (M * (M / d)))) * Math.sqrt((h / ((l * l) * l)));
} else {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * 1.0;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): 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 * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 0.0: tmp = (-0.125 * ((D_m * D_m) * (M * (M / d)))) * math.sqrt((h / ((l * l) * l))) else: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * 1.0 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) 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 * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= 0.0) tmp = Float64(Float64(-0.125 * Float64(Float64(D_m * D_m) * Float64(M * Float64(M / d)))) * sqrt(Float64(h / Float64(Float64(l * l) * l)))); else tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
tmp = 0.0;
if (((((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= 0.0)
tmp = (-0.125 * ((D_m * D_m) * (M * (M / d)))) * sqrt((h / ((l * l) * l)));
else
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := 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 * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(-0.125 * N[(N[(D$95$m * D$95$m), $MachinePrecision] * N[(M * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\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 \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq 0:\\
\;\;\;\;\left(-0.125 \cdot \left(\left(D\_m \cdot D\_m\right) \cdot \left(M \cdot \frac{M}{d}\right)\right)\right) \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\
\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)))) < 0.0Initial program 79.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 rewrites77.1%
Taylor expanded in d around 0
Applied rewrites31.3%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6432.5
Applied rewrites32.5%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 57.8%
Taylor expanded in d around inf
Applied rewrites60.8%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6460.8
Applied rewrites60.8%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
: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 D_m) (* 2.0 d)) 2.0)) (/ h l))))
0.0)
(* (* -0.125 (* D_m (* D_m (/ (* M M) d)))) (sqrt (/ h (* (* l l) l))))
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
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 * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 0.0) {
tmp = (-0.125 * (D_m * (D_m * ((M * M) / d)))) * sqrt((h / ((l * l) * l)));
} else {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: tmp
if (((((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= 0.0d0) then
tmp = ((-0.125d0) * (d_m * (d_m * ((m * m) / d)))) * sqrt((h / ((l * l) * l)))
else
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0d0
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
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 * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 0.0) {
tmp = (-0.125 * (D_m * (D_m * ((M * M) / d)))) * Math.sqrt((h / ((l * l) * l)));
} else {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * 1.0;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): 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 * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 0.0: tmp = (-0.125 * (D_m * (D_m * ((M * M) / d)))) * math.sqrt((h / ((l * l) * l))) else: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * 1.0 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) 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 * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= 0.0) tmp = Float64(Float64(-0.125 * Float64(D_m * Float64(D_m * Float64(Float64(M * M) / d)))) * sqrt(Float64(h / Float64(Float64(l * l) * l)))); else tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
tmp = 0.0;
if (((((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= 0.0)
tmp = (-0.125 * (D_m * (D_m * ((M * M) / d)))) * sqrt((h / ((l * l) * l)));
else
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := 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 * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(-0.125 * N[(D$95$m * N[(D$95$m * N[(N[(M * M), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\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 \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq 0:\\
\;\;\;\;\left(-0.125 \cdot \left(D\_m \cdot \left(D\_m \cdot \frac{M \cdot M}{d}\right)\right)\right) \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\
\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)))) < 0.0Initial program 79.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 rewrites77.1%
Taylor expanded in d around 0
Applied rewrites31.3%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f6432.8
Applied rewrites32.8%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 57.8%
Taylor expanded in d around inf
Applied rewrites60.8%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6460.8
Applied rewrites60.8%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
: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 D_m) (* 2.0 d)) 2.0)) (/ h l))))
-5e-73)
(/ (* (/ (* (sqrt (* l h)) (* (* D_m M) (* D_m M))) d) -0.125) (* l l))
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
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 * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5e-73) {
tmp = (((sqrt((l * h)) * ((D_m * M) * (D_m * M))) / d) * -0.125) / (l * l);
} else {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: tmp
if (((((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= (-5d-73)) then
tmp = (((sqrt((l * h)) * ((d_m * m) * (d_m * m))) / d) * (-0.125d0)) / (l * l)
else
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0d0
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
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 * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5e-73) {
tmp = (((Math.sqrt((l * h)) * ((D_m * M) * (D_m * M))) / d) * -0.125) / (l * l);
} else {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * 1.0;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): 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 * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5e-73: tmp = (((math.sqrt((l * h)) * ((D_m * M) * (D_m * M))) / d) * -0.125) / (l * l) else: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * 1.0 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) 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 * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= -5e-73) tmp = Float64(Float64(Float64(Float64(sqrt(Float64(l * h)) * Float64(Float64(D_m * M) * Float64(D_m * M))) / d) * -0.125) / Float64(l * l)); else tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
tmp = 0.0;
if (((((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= -5e-73)
tmp = (((sqrt((l * h)) * ((D_m * M) * (D_m * M))) / d) * -0.125) / (l * l);
else
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := 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 * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e-73], N[(N[(N[(N[(N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision] * N[(N[(D$95$m * M), $MachinePrecision] * N[(D$95$m * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * -0.125), $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\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 \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -5 \cdot 10^{-73}:\\
\;\;\;\;\frac{\frac{\sqrt{\ell \cdot h} \cdot \left(\left(D\_m \cdot M\right) \cdot \left(D\_m \cdot M\right)\right)}{d} \cdot -0.125}{\ell \cdot \ell}\\
\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)))) < -4.9999999999999998e-73Initial program 85.6%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites24.7%
Taylor expanded in d around 0
*-commutativeN/A
associate-*l/N/A
*-commutativeN/A
pow2N/A
pow2N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites28.5%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
pow2N/A
unswap-sqrN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6432.3
Applied rewrites32.3%
if -4.9999999999999998e-73 < (*.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.9%
Taylor expanded in d around inf
Applied rewrites58.2%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6458.2
Applied rewrites58.2%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
: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 D_m) (* 2.0 d)) 2.0)) (/ h l))))
0.0)
(* (* -0.125 (* (* D_m D_m) (/ (* M M) d))) (sqrt (/ h (* (* l l) l))))
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
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 * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 0.0) {
tmp = (-0.125 * ((D_m * D_m) * ((M * M) / d))) * sqrt((h / ((l * l) * l)));
} else {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: tmp
if (((((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= 0.0d0) then
tmp = ((-0.125d0) * ((d_m * d_m) * ((m * m) / d))) * sqrt((h / ((l * l) * l)))
else
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0d0
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
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 * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 0.0) {
tmp = (-0.125 * ((D_m * D_m) * ((M * M) / d))) * Math.sqrt((h / ((l * l) * l)));
} else {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * 1.0;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): 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 * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 0.0: tmp = (-0.125 * ((D_m * D_m) * ((M * M) / d))) * math.sqrt((h / ((l * l) * l))) else: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * 1.0 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) 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 * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= 0.0) tmp = Float64(Float64(-0.125 * Float64(Float64(D_m * D_m) * Float64(Float64(M * M) / d))) * sqrt(Float64(h / Float64(Float64(l * l) * l)))); else tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
tmp = 0.0;
if (((((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= 0.0)
tmp = (-0.125 * ((D_m * D_m) * ((M * M) / d))) * sqrt((h / ((l * l) * l)));
else
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := 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 * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(-0.125 * N[(N[(D$95$m * D$95$m), $MachinePrecision] * N[(N[(M * M), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\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 \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq 0:\\
\;\;\;\;\left(-0.125 \cdot \left(\left(D\_m \cdot D\_m\right) \cdot \frac{M \cdot M}{d}\right)\right) \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\
\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)))) < 0.0Initial program 79.1%
Taylor expanded in d around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
unpow3N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6431.3
Applied rewrites31.3%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 57.8%
Taylor expanded in d around inf
Applied rewrites60.8%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6460.8
Applied rewrites60.8%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
: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 D_m) (* 2.0 d)) 2.0)) (/ h l))))
0.0)
(* (sqrt (/ 1.0 (* l h))) d)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
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 * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 0.0) {
tmp = sqrt((1.0 / (l * h))) * d;
} else {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: tmp
if (((((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= 0.0d0) then
tmp = sqrt((1.0d0 / (l * h))) * d
else
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0d0
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
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 * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 0.0) {
tmp = Math.sqrt((1.0 / (l * h))) * d;
} else {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * 1.0;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): 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 * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 0.0: tmp = math.sqrt((1.0 / (l * h))) * d else: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * 1.0 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) 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 * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= 0.0) tmp = Float64(sqrt(Float64(1.0 / Float64(l * h))) * d); else tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
tmp = 0.0;
if (((((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= 0.0)
tmp = sqrt((1.0 / (l * h))) * d;
else
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := 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 * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\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 \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq 0:\\
\;\;\;\;\sqrt{\frac{1}{\ell \cdot h}} \cdot d\\
\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)))) < 0.0Initial program 79.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6417.6
Applied rewrites17.6%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 57.8%
Taylor expanded in d around inf
Applied rewrites60.8%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6460.8
Applied rewrites60.8%
D_m = (fabs.f64 D) NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M D_m) :precision binary64 (if (<= d 1.2e-218) (* d (- (sqrt (/ 1.0 (* l h))))) (/ (* 1.0 d) (* (sqrt l) (sqrt h)))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (d <= 1.2e-218) {
tmp = d * -sqrt((1.0 / (l * h)));
} else {
tmp = (1.0 * d) / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: tmp
if (d <= 1.2d-218) then
tmp = d * -sqrt((1.0d0 / (l * h)))
else
tmp = (1.0d0 * d) / (sqrt(l) * sqrt(h))
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (d <= 1.2e-218) {
tmp = d * -Math.sqrt((1.0 / (l * h)));
} else {
tmp = (1.0 * d) / (Math.sqrt(l) * Math.sqrt(h));
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): tmp = 0 if d <= 1.2e-218: tmp = d * -math.sqrt((1.0 / (l * h))) else: tmp = (1.0 * d) / (math.sqrt(l) * math.sqrt(h)) return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) tmp = 0.0 if (d <= 1.2e-218) tmp = Float64(d * Float64(-sqrt(Float64(1.0 / Float64(l * h))))); else tmp = Float64(Float64(1.0 * d) / Float64(sqrt(l) * sqrt(h))); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
tmp = 0.0;
if (d <= 1.2e-218)
tmp = d * -sqrt((1.0 / (l * h)));
else
tmp = (1.0 * d) / (sqrt(l) * sqrt(h));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[d, 1.2e-218], N[(d * (-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[(1.0 * d), $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 1.2 \cdot 10^{-218}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{1}{\ell \cdot h}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if d < 1.2e-218Initial program 62.9%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6452.3
lift-/.f64N/A
metadata-eval52.3
Applied rewrites52.3%
Taylor expanded in d around -inf
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6440.5
Applied rewrites40.5%
if 1.2e-218 < d Initial program 71.3%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6445.8
Applied rewrites45.8%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
*-commutativeN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-*.f6446.0
Applied rewrites46.0%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
*-commutativeN/A
lower-*.f6446.0
Applied rewrites46.0%
lift-*.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6455.1
Applied rewrites55.1%
D_m = (fabs.f64 D) NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M D_m) :precision binary64 (if (<= d 1.2e-218) (* d (- (sqrt (/ 1.0 (* l h))))) (* (/ 1.0 (* (sqrt l) (sqrt h))) d)))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (d <= 1.2e-218) {
tmp = d * -sqrt((1.0 / (l * h)));
} else {
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: tmp
if (d <= 1.2d-218) then
tmp = d * -sqrt((1.0d0 / (l * h)))
else
tmp = (1.0d0 / (sqrt(l) * sqrt(h))) * d
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (d <= 1.2e-218) {
tmp = d * -Math.sqrt((1.0 / (l * h)));
} else {
tmp = (1.0 / (Math.sqrt(l) * Math.sqrt(h))) * d;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): tmp = 0 if d <= 1.2e-218: tmp = d * -math.sqrt((1.0 / (l * h))) else: tmp = (1.0 / (math.sqrt(l) * math.sqrt(h))) * d return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) tmp = 0.0 if (d <= 1.2e-218) tmp = Float64(d * Float64(-sqrt(Float64(1.0 / Float64(l * h))))); else tmp = Float64(Float64(1.0 / Float64(sqrt(l) * sqrt(h))) * d); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
tmp = 0.0;
if (d <= 1.2e-218)
tmp = d * -sqrt((1.0 / (l * h)));
else
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[d, 1.2e-218], N[(d * (-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(N[(1.0 / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 1.2 \cdot 10^{-218}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{1}{\ell \cdot h}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\ell} \cdot \sqrt{h}} \cdot d\\
\end{array}
\end{array}
if d < 1.2e-218Initial program 62.9%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6452.3
lift-/.f64N/A
metadata-eval52.3
Applied rewrites52.3%
Taylor expanded in d around -inf
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6440.5
Applied rewrites40.5%
if 1.2e-218 < d Initial program 71.3%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6445.8
Applied rewrites45.8%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
*-commutativeN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-*.f6446.0
Applied rewrites46.0%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6455.1
Applied rewrites55.1%
D_m = (fabs.f64 D) NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M D_m) :precision binary64 (if (<= d -1.05e-112) (* d (- (sqrt (/ 1.0 (* l h))))) (/ d (sqrt (* h l)))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (d <= -1.05e-112) {
tmp = d * -sqrt((1.0 / (l * h)));
} else {
tmp = d / sqrt((h * l));
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: tmp
if (d <= (-1.05d-112)) then
tmp = d * -sqrt((1.0d0 / (l * h)))
else
tmp = d / sqrt((h * l))
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (d <= -1.05e-112) {
tmp = d * -Math.sqrt((1.0 / (l * h)));
} else {
tmp = d / Math.sqrt((h * l));
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): tmp = 0 if d <= -1.05e-112: tmp = d * -math.sqrt((1.0 / (l * h))) else: tmp = d / math.sqrt((h * l)) return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) tmp = 0.0 if (d <= -1.05e-112) tmp = Float64(d * Float64(-sqrt(Float64(1.0 / Float64(l * h))))); else tmp = Float64(d / sqrt(Float64(h * l))); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
tmp = 0.0;
if (d <= -1.05e-112)
tmp = d * -sqrt((1.0 / (l * h)));
else
tmp = d / sqrt((h * l));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[d, -1.05e-112], N[(d * (-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.05 \cdot 10^{-112}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{1}{\ell \cdot h}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\
\end{array}
\end{array}
if d < -1.05e-112Initial program 75.6%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6464.4
lift-/.f64N/A
metadata-eval64.4
Applied rewrites64.4%
Taylor expanded in d around -inf
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6452.8
Applied rewrites52.8%
if -1.05e-112 < d Initial program 61.9%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6435.8
Applied rewrites35.8%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
*-commutativeN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-*.f6435.8
Applied rewrites35.8%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
*-commutativeN/A
lower-*.f6435.8
Applied rewrites35.8%
Applied rewrites35.8%
D_m = (fabs.f64 D) NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M D_m) :precision binary64 (/ d (sqrt (* h l))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
return d / sqrt((h * l));
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
code = d / sqrt((h * l))
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
return d / Math.sqrt((h * l));
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): return d / math.sqrt((h * l))
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) return Float64(d / sqrt(Float64(h * l))) end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp = code(d, h, l, M, D_m)
tmp = d / sqrt((h * l));
end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\frac{d}{\sqrt{h \cdot \ell}}
\end{array}
Initial program 66.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6426.1
Applied rewrites26.1%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
*-commutativeN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-*.f6425.9
Applied rewrites25.9%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
*-commutativeN/A
lower-*.f6425.9
Applied rewrites25.9%
Applied rewrites25.9%
herbie shell --seed 2025116
(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)))))