
(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 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (- 1.0 (/ (* (* (pow (* (/ M_m 2.0) (/ D_m d)) 2.0) 0.5) h) l))))
(if (<= l -5e-310)
(* (* d (- (pow (* h l) -0.5))) t_0)
(if (<= l 5.6e+94)
(* (* (pow (* l h) -0.5) d) t_0)
(*
(sqrt (/ d l))
(*
(/ (sqrt d) (sqrt h))
(- 1.0 (/ (* (pow (* (/ D_m d) (/ M_m 2.0)) 2.0) (* 0.5 h)) l))))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = 1.0 - (((pow(((M_m / 2.0) * (D_m / d)), 2.0) * 0.5) * h) / l);
double tmp;
if (l <= -5e-310) {
tmp = (d * -pow((h * l), -0.5)) * t_0;
} else if (l <= 5.6e+94) {
tmp = (pow((l * h), -0.5) * d) * t_0;
} else {
tmp = sqrt((d / l)) * ((sqrt(d) / sqrt(h)) * (1.0 - ((pow(((D_m / d) * (M_m / 2.0)), 2.0) * (0.5 * h)) / l)));
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - ((((((m_m / 2.0d0) * (d_m / d)) ** 2.0d0) * 0.5d0) * h) / l)
if (l <= (-5d-310)) then
tmp = (d * -((h * l) ** (-0.5d0))) * t_0
else if (l <= 5.6d+94) then
tmp = (((l * h) ** (-0.5d0)) * d) * t_0
else
tmp = sqrt((d / l)) * ((sqrt(d) / sqrt(h)) * (1.0d0 - (((((d_m / d) * (m_m / 2.0d0)) ** 2.0d0) * (0.5d0 * h)) / l)))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = 1.0 - (((Math.pow(((M_m / 2.0) * (D_m / d)), 2.0) * 0.5) * h) / l);
double tmp;
if (l <= -5e-310) {
tmp = (d * -Math.pow((h * l), -0.5)) * t_0;
} else if (l <= 5.6e+94) {
tmp = (Math.pow((l * h), -0.5) * d) * t_0;
} else {
tmp = Math.sqrt((d / l)) * ((Math.sqrt(d) / Math.sqrt(h)) * (1.0 - ((Math.pow(((D_m / d) * (M_m / 2.0)), 2.0) * (0.5 * h)) / l)));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = 1.0 - (((math.pow(((M_m / 2.0) * (D_m / d)), 2.0) * 0.5) * h) / l) tmp = 0 if l <= -5e-310: tmp = (d * -math.pow((h * l), -0.5)) * t_0 elif l <= 5.6e+94: tmp = (math.pow((l * h), -0.5) * d) * t_0 else: tmp = math.sqrt((d / l)) * ((math.sqrt(d) / math.sqrt(h)) * (1.0 - ((math.pow(((D_m / d) * (M_m / 2.0)), 2.0) * (0.5 * h)) / l))) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(1.0 - Float64(Float64(Float64((Float64(Float64(M_m / 2.0) * Float64(D_m / d)) ^ 2.0) * 0.5) * h) / l)) tmp = 0.0 if (l <= -5e-310) tmp = Float64(Float64(d * Float64(-(Float64(h * l) ^ -0.5))) * t_0); elseif (l <= 5.6e+94) tmp = Float64(Float64((Float64(l * h) ^ -0.5) * d) * t_0); else tmp = Float64(sqrt(Float64(d / l)) * Float64(Float64(sqrt(d) / sqrt(h)) * Float64(1.0 - Float64(Float64((Float64(Float64(D_m / d) * Float64(M_m / 2.0)) ^ 2.0) * Float64(0.5 * h)) / l)))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = 1.0 - ((((((M_m / 2.0) * (D_m / d)) ^ 2.0) * 0.5) * h) / l);
tmp = 0.0;
if (l <= -5e-310)
tmp = (d * -((h * l) ^ -0.5)) * t_0;
elseif (l <= 5.6e+94)
tmp = (((l * h) ^ -0.5) * d) * t_0;
else
tmp = sqrt((d / l)) * ((sqrt(d) / sqrt(h)) * (1.0 - (((((D_m / d) * (M_m / 2.0)) ^ 2.0) * (0.5 * h)) / l)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(1.0 - N[(N[(N[(N[Power[N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -5e-310], N[(N[(d * (-N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision])), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[l, 5.6e+94], N[(N[(N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision] * d), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(0.5 * h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := 1 - \frac{\left({\left(\frac{M\_m}{2} \cdot \frac{D\_m}{d}\right)}^{2} \cdot 0.5\right) \cdot h}{\ell}\\
\mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\right) \cdot t\_0\\
\mathbf{elif}\;\ell \leq 5.6 \cdot 10^{+94}:\\
\;\;\;\;\left({\left(\ell \cdot h\right)}^{-0.5} \cdot d\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\frac{\sqrt{d}}{\sqrt{h}} \cdot \left(1 - \frac{{\left(\frac{D\_m}{d} \cdot \frac{M\_m}{2}\right)}^{2} \cdot \left(0.5 \cdot h\right)}{\ell}\right)\right)\\
\end{array}
\end{array}
if l < -4.999999999999985e-310Initial program 65.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 rewrites66.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-/.f6466.2
Applied rewrites66.2%
Taylor expanded in h around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
inv-powN/A
*-commutativeN/A
sqrt-pow1N/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval72.9
Applied rewrites72.9%
if -4.999999999999985e-310 < l < 5.59999999999999997e94Initial program 73.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 rewrites75.6%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
inv-powN/A
*-commutativeN/A
sqrt-pow1N/A
lower-pow.f64N/A
lift-*.f64N/A
metadata-eval83.8
Applied rewrites83.8%
if 5.59999999999999997e94 < l Initial program 53.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 rewrites51.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-/.f6451.4
Applied rewrites51.4%
Applied rewrites51.4%
lift-/.f64N/A
lift-sqrt.f64N/A
sqrt-divN/A
lower-/.f64N/A
lift-sqrt.f64N/A
lower-sqrt.f6463.2
Applied rewrites63.2%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l))))))
(if (<= t_0 -5e+120)
(*
(* -0.125 (* (* D_m D_m) (/ (* M_m M_m) d)))
(sqrt (/ h (* (* l l) l))))
(if (<= t_0 1e+233)
(* (sqrt (/ d l)) (sqrt (/ d h)))
(* (sqrt (/ 1.0 (* l h))) d)))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -5e+120) {
tmp = (-0.125 * ((D_m * D_m) * ((M_m * M_m) / d))) * sqrt((h / ((l * l) * l)));
} else if (t_0 <= 1e+233) {
tmp = sqrt((d / l)) * sqrt((d / h));
} else {
tmp = sqrt((1.0 / (l * h))) * d;
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
if (t_0 <= (-5d+120)) then
tmp = ((-0.125d0) * ((d_m * d_m) * ((m_m * m_m) / d))) * sqrt((h / ((l * l) * l)))
else if (t_0 <= 1d+233) then
tmp = sqrt((d / l)) * sqrt((d / h))
else
tmp = sqrt((1.0d0 / (l * h))) * d
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -5e+120) {
tmp = (-0.125 * ((D_m * D_m) * ((M_m * M_m) / d))) * Math.sqrt((h / ((l * l) * l)));
} else if (t_0 <= 1e+233) {
tmp = Math.sqrt((d / l)) * Math.sqrt((d / h));
} else {
tmp = Math.sqrt((1.0 / (l * h))) * d;
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l))) tmp = 0 if t_0 <= -5e+120: tmp = (-0.125 * ((D_m * D_m) * ((M_m * M_m) / d))) * math.sqrt((h / ((l * l) * l))) elif t_0 <= 1e+233: tmp = math.sqrt((d / l)) * math.sqrt((d / h)) else: tmp = math.sqrt((1.0 / (l * h))) * d return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_0 <= -5e+120) tmp = Float64(Float64(-0.125 * Float64(Float64(D_m * D_m) * Float64(Float64(M_m * M_m) / d))) * sqrt(Float64(h / Float64(Float64(l * l) * l)))); elseif (t_0 <= 1e+233) tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))); else tmp = Float64(sqrt(Float64(1.0 / Float64(l * h))) * d); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
tmp = 0.0;
if (t_0 <= -5e+120)
tmp = (-0.125 * ((D_m * D_m) * ((M_m * M_m) / d))) * sqrt((h / ((l * l) * l)));
elseif (t_0 <= 1e+233)
tmp = sqrt((d / l)) * sqrt((d / h));
else
tmp = sqrt((1.0 / (l * h))) * d;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+120], N[(N[(-0.125 * N[(N[(D$95$m * D$95$m), $MachinePrecision] * N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+233], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+120}:\\
\;\;\;\;\left(-0.125 \cdot \left(\left(D\_m \cdot D\_m\right) \cdot \frac{M\_m \cdot M\_m}{d}\right)\right) \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\
\mathbf{elif}\;t\_0 \leq 10^{+233}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{1}{\ell \cdot h}} \cdot d\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -5.00000000000000019e120Initial program 84.9%
Taylor expanded in d around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow-prod-downN/A
*-commutativeN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-pow.f6439.7
Applied rewrites39.7%
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6434.2
Applied rewrites34.2%
lift-pow.f64N/A
unpow3N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6434.2
Applied rewrites34.2%
if -5.00000000000000019e120 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 9.99999999999999974e232Initial program 88.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 rewrites84.0%
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.0
Applied rewrites84.0%
Applied rewrites84.0%
Taylor expanded in d around inf
lift-sqrt.f64N/A
lift-/.f6476.9
Applied rewrites76.9%
if 9.99999999999999974e232 < (*.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 22.9%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6427.5
Applied rewrites27.5%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lift-*.f6427.5
Applied rewrites27.5%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l))))))
(if (<= t_0 0.0)
(/ (/ (* (* (* d d) -1.0) (sqrt (/ h l))) h) d)
(if (<= t_0 1e+233)
(* (sqrt (/ d l)) (sqrt (/ d h)))
(* (sqrt (/ 1.0 (* l h))) d)))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= 0.0) {
tmp = ((((d * d) * -1.0) * sqrt((h / l))) / h) / d;
} else if (t_0 <= 1e+233) {
tmp = sqrt((d / l)) * sqrt((d / h));
} else {
tmp = sqrt((1.0 / (l * h))) * d;
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
if (t_0 <= 0.0d0) then
tmp = ((((d * d) * (-1.0d0)) * sqrt((h / l))) / h) / d
else if (t_0 <= 1d+233) then
tmp = sqrt((d / l)) * sqrt((d / h))
else
tmp = sqrt((1.0d0 / (l * h))) * d
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= 0.0) {
tmp = ((((d * d) * -1.0) * Math.sqrt((h / l))) / h) / d;
} else if (t_0 <= 1e+233) {
tmp = Math.sqrt((d / l)) * Math.sqrt((d / h));
} else {
tmp = Math.sqrt((1.0 / (l * h))) * d;
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l))) tmp = 0 if t_0 <= 0.0: tmp = ((((d * d) * -1.0) * math.sqrt((h / l))) / h) / d elif t_0 <= 1e+233: tmp = math.sqrt((d / l)) * math.sqrt((d / h)) else: tmp = math.sqrt((1.0 / (l * h))) * d return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(Float64(Float64(Float64(Float64(d * d) * -1.0) * sqrt(Float64(h / l))) / h) / d); elseif (t_0 <= 1e+233) tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))); else tmp = Float64(sqrt(Float64(1.0 / Float64(l * h))) * d); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
tmp = 0.0;
if (t_0 <= 0.0)
tmp = ((((d * d) * -1.0) * sqrt((h / l))) / h) / d;
elseif (t_0 <= 1e+233)
tmp = sqrt((d / l)) * sqrt((d / h));
else
tmp = sqrt((1.0 / (l * h))) * d;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(N[(N[(N[(d * d), $MachinePrecision] * -1.0), $MachinePrecision] * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[t$95$0, 1e+233], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\frac{\frac{\left(\left(d \cdot d\right) \cdot -1\right) \cdot \sqrt{\frac{h}{\ell}}}{h}}{d}\\
\mathbf{elif}\;t\_0 \leq 10^{+233}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{1}{\ell \cdot h}} \cdot d\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0Initial program 79.2%
Taylor expanded in d around 0
lower-/.f64N/A
Applied rewrites25.6%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites42.5%
Taylor expanded in l around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-/.f6430.1
Applied rewrites30.1%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 9.99999999999999974e232Initial program 98.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 rewrites97.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-/.f6497.6
Applied rewrites97.6%
Applied rewrites97.6%
Taylor expanded in d around inf
lift-sqrt.f64N/A
lift-/.f6497.8
Applied rewrites97.8%
if 9.99999999999999974e232 < (*.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 22.9%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6427.5
Applied rewrites27.5%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lift-*.f6427.5
Applied rewrites27.5%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (* (/ M_m 2.0) (/ D_m d))))
(if (<=
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l))))
1e+233)
(*
(sqrt (/ d l))
(* (sqrt (/ d h)) (- 1.0 (/ (* (* t_0 t_0) (* 0.5 h)) l))))
(* (sqrt (/ 1.0 (* l h))) d))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (M_m / 2.0) * (D_m / d);
double tmp;
if (((pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 1e+233) {
tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0 - (((t_0 * t_0) * (0.5 * h)) / l)));
} else {
tmp = sqrt((1.0 / (l * h))) * d;
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = (m_m / 2.0d0) * (d_m / d)
if (((((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= 1d+233) then
tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0d0 - (((t_0 * t_0) * (0.5d0 * h)) / l)))
else
tmp = sqrt((1.0d0 / (l * h))) * d
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (M_m / 2.0) * (D_m / d);
double tmp;
if (((Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 1e+233) {
tmp = Math.sqrt((d / l)) * (Math.sqrt((d / h)) * (1.0 - (((t_0 * t_0) * (0.5 * h)) / l)));
} else {
tmp = Math.sqrt((1.0 / (l * h))) * d;
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = (M_m / 2.0) * (D_m / d) tmp = 0 if ((math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 1e+233: tmp = math.sqrt((d / l)) * (math.sqrt((d / h)) * (1.0 - (((t_0 * t_0) * (0.5 * h)) / l))) else: tmp = math.sqrt((1.0 / (l * h))) * d return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(M_m / 2.0) * Float64(D_m / d)) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= 1e+233) tmp = Float64(sqrt(Float64(d / l)) * Float64(sqrt(Float64(d / h)) * Float64(1.0 - Float64(Float64(Float64(t_0 * t_0) * Float64(0.5 * h)) / l)))); else tmp = Float64(sqrt(Float64(1.0 / Float64(l * h))) * d); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = (M_m / 2.0) * (D_m / d);
tmp = 0.0;
if (((((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= 1e+233)
tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0 - (((t_0 * t_0) * (0.5 * h)) / l)));
else
tmp = sqrt((1.0 / (l * h))) * d;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+233], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[(0.5 * h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{M\_m}{2} \cdot \frac{D\_m}{d}\\
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq 10^{+233}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 - \frac{\left(t\_0 \cdot t\_0\right) \cdot \left(0.5 \cdot h\right)}{\ell}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{1}{\ell \cdot h}} \cdot d\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 9.99999999999999974e232Initial program 86.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.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-/.f6484.9
Applied rewrites84.9%
Applied rewrites84.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f6484.9
lift-pow.f64N/A
unpow2N/A
lower-*.f6484.9
Applied rewrites84.9%
if 9.99999999999999974e232 < (*.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 22.9%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6427.5
Applied rewrites27.5%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lift-*.f6427.5
Applied rewrites27.5%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (* (/ M_m 2.0) (/ D_m d))) (t_1 (sqrt (/ d l))))
(if (<= h -4.3e+122)
(* t_1 (* (sqrt (/ d h)) (- 1.0 (/ (* (* t_0 t_0) (* 0.5 h)) l))))
(if (<= h -5e-310)
(*
(* (* -1.0 d) (/ 1.0 (sqrt (* l h))))
(- 1.0 (* (* (pow t_0 2.0) 0.5) (/ h l))))
(*
t_1
(*
(/ (sqrt d) (sqrt h))
(- 1.0 (/ (* (pow (* (/ D_m d) (/ M_m 2.0)) 2.0) (* 0.5 h)) l))))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (M_m / 2.0) * (D_m / d);
double t_1 = sqrt((d / l));
double tmp;
if (h <= -4.3e+122) {
tmp = t_1 * (sqrt((d / h)) * (1.0 - (((t_0 * t_0) * (0.5 * h)) / l)));
} else if (h <= -5e-310) {
tmp = ((-1.0 * d) * (1.0 / sqrt((l * h)))) * (1.0 - ((pow(t_0, 2.0) * 0.5) * (h / l)));
} else {
tmp = t_1 * ((sqrt(d) / sqrt(h)) * (1.0 - ((pow(((D_m / d) * (M_m / 2.0)), 2.0) * (0.5 * h)) / l)));
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (m_m / 2.0d0) * (d_m / d)
t_1 = sqrt((d / l))
if (h <= (-4.3d+122)) then
tmp = t_1 * (sqrt((d / h)) * (1.0d0 - (((t_0 * t_0) * (0.5d0 * h)) / l)))
else if (h <= (-5d-310)) then
tmp = (((-1.0d0) * d) * (1.0d0 / sqrt((l * h)))) * (1.0d0 - (((t_0 ** 2.0d0) * 0.5d0) * (h / l)))
else
tmp = t_1 * ((sqrt(d) / sqrt(h)) * (1.0d0 - (((((d_m / d) * (m_m / 2.0d0)) ** 2.0d0) * (0.5d0 * h)) / l)))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (M_m / 2.0) * (D_m / d);
double t_1 = Math.sqrt((d / l));
double tmp;
if (h <= -4.3e+122) {
tmp = t_1 * (Math.sqrt((d / h)) * (1.0 - (((t_0 * t_0) * (0.5 * h)) / l)));
} else if (h <= -5e-310) {
tmp = ((-1.0 * d) * (1.0 / Math.sqrt((l * h)))) * (1.0 - ((Math.pow(t_0, 2.0) * 0.5) * (h / l)));
} else {
tmp = t_1 * ((Math.sqrt(d) / Math.sqrt(h)) * (1.0 - ((Math.pow(((D_m / d) * (M_m / 2.0)), 2.0) * (0.5 * h)) / l)));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = (M_m / 2.0) * (D_m / d) t_1 = math.sqrt((d / l)) tmp = 0 if h <= -4.3e+122: tmp = t_1 * (math.sqrt((d / h)) * (1.0 - (((t_0 * t_0) * (0.5 * h)) / l))) elif h <= -5e-310: tmp = ((-1.0 * d) * (1.0 / math.sqrt((l * h)))) * (1.0 - ((math.pow(t_0, 2.0) * 0.5) * (h / l))) else: tmp = t_1 * ((math.sqrt(d) / math.sqrt(h)) * (1.0 - ((math.pow(((D_m / d) * (M_m / 2.0)), 2.0) * (0.5 * h)) / l))) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(M_m / 2.0) * Float64(D_m / d)) t_1 = sqrt(Float64(d / l)) tmp = 0.0 if (h <= -4.3e+122) tmp = Float64(t_1 * Float64(sqrt(Float64(d / h)) * Float64(1.0 - Float64(Float64(Float64(t_0 * t_0) * Float64(0.5 * h)) / l)))); elseif (h <= -5e-310) tmp = Float64(Float64(Float64(-1.0 * d) * Float64(1.0 / sqrt(Float64(l * h)))) * Float64(1.0 - Float64(Float64((t_0 ^ 2.0) * 0.5) * Float64(h / l)))); else tmp = Float64(t_1 * Float64(Float64(sqrt(d) / sqrt(h)) * Float64(1.0 - Float64(Float64((Float64(Float64(D_m / d) * Float64(M_m / 2.0)) ^ 2.0) * Float64(0.5 * h)) / l)))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = (M_m / 2.0) * (D_m / d);
t_1 = sqrt((d / l));
tmp = 0.0;
if (h <= -4.3e+122)
tmp = t_1 * (sqrt((d / h)) * (1.0 - (((t_0 * t_0) * (0.5 * h)) / l)));
elseif (h <= -5e-310)
tmp = ((-1.0 * d) * (1.0 / sqrt((l * h)))) * (1.0 - (((t_0 ^ 2.0) * 0.5) * (h / l)));
else
tmp = t_1 * ((sqrt(d) / sqrt(h)) * (1.0 - (((((D_m / d) * (M_m / 2.0)) ^ 2.0) * (0.5 * h)) / l)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[h, -4.3e+122], N[(t$95$1 * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[(0.5 * h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -5e-310], N[(N[(N[(-1.0 * d), $MachinePrecision] * N[(1.0 / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[t$95$0, 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[N[(N[(D$95$m / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(0.5 * h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{M\_m}{2} \cdot \frac{D\_m}{d}\\
t_1 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;h \leq -4.3 \cdot 10^{+122}:\\
\;\;\;\;t\_1 \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 - \frac{\left(t\_0 \cdot t\_0\right) \cdot \left(0.5 \cdot h\right)}{\ell}\right)\right)\\
\mathbf{elif}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\left(-1 \cdot d\right) \cdot \frac{1}{\sqrt{\ell \cdot h}}\right) \cdot \left(1 - \left({t\_0}^{2} \cdot 0.5\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(\frac{\sqrt{d}}{\sqrt{h}} \cdot \left(1 - \frac{{\left(\frac{D\_m}{d} \cdot \frac{M\_m}{2}\right)}^{2} \cdot \left(0.5 \cdot h\right)}{\ell}\right)\right)\\
\end{array}
\end{array}
if h < -4.29999999999999971e122Initial program 53.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 rewrites55.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-/.f6455.5
Applied rewrites55.5%
Applied rewrites55.5%
lift-*.f64N/A
*-commutativeN/A
lift-*.f6455.5
lift-pow.f64N/A
unpow2N/A
lower-*.f6455.5
Applied rewrites55.5%
if -4.29999999999999971e122 < h < -4.999999999999985e-310Initial program 70.1%
Taylor expanded in h around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6477.9
Applied rewrites77.9%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6478.1
Applied rewrites78.1%
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
frac-timesN/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f6477.0
Applied rewrites77.0%
if -4.999999999999985e-310 < h Initial program 66.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 rewrites67.3%
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-/.f6467.3
Applied rewrites67.3%
Applied rewrites67.3%
lift-/.f64N/A
lift-sqrt.f64N/A
sqrt-divN/A
lower-/.f64N/A
lift-sqrt.f64N/A
lower-sqrt.f6478.4
Applied rewrites78.4%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (* (/ M_m 2.0) (/ D_m d))) (t_1 (sqrt (/ d h))))
(if (<= h -4.3e+122)
(* (sqrt (/ d l)) (* t_1 (- 1.0 (/ (* (* t_0 t_0) (* 0.5 h)) l))))
(if (<= h -5e-310)
(*
(* (* -1.0 d) (/ 1.0 (sqrt (* l h))))
(- 1.0 (* (* (pow t_0 2.0) 0.5) (/ h l))))
(*
(* (/ (sqrt d) (sqrt l)) t_1)
(- 1.0 (/ (* (* (pow (* (* 0.5 M_m) (/ D_m d)) 2.0) 0.5) h) l)))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (M_m / 2.0) * (D_m / d);
double t_1 = sqrt((d / h));
double tmp;
if (h <= -4.3e+122) {
tmp = sqrt((d / l)) * (t_1 * (1.0 - (((t_0 * t_0) * (0.5 * h)) / l)));
} else if (h <= -5e-310) {
tmp = ((-1.0 * d) * (1.0 / sqrt((l * h)))) * (1.0 - ((pow(t_0, 2.0) * 0.5) * (h / l)));
} else {
tmp = ((sqrt(d) / sqrt(l)) * t_1) * (1.0 - (((pow(((0.5 * M_m) * (D_m / d)), 2.0) * 0.5) * h) / l));
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (m_m / 2.0d0) * (d_m / d)
t_1 = sqrt((d / h))
if (h <= (-4.3d+122)) then
tmp = sqrt((d / l)) * (t_1 * (1.0d0 - (((t_0 * t_0) * (0.5d0 * h)) / l)))
else if (h <= (-5d-310)) then
tmp = (((-1.0d0) * d) * (1.0d0 / sqrt((l * h)))) * (1.0d0 - (((t_0 ** 2.0d0) * 0.5d0) * (h / l)))
else
tmp = ((sqrt(d) / sqrt(l)) * t_1) * (1.0d0 - ((((((0.5d0 * m_m) * (d_m / d)) ** 2.0d0) * 0.5d0) * h) / l))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (M_m / 2.0) * (D_m / d);
double t_1 = Math.sqrt((d / h));
double tmp;
if (h <= -4.3e+122) {
tmp = Math.sqrt((d / l)) * (t_1 * (1.0 - (((t_0 * t_0) * (0.5 * h)) / l)));
} else if (h <= -5e-310) {
tmp = ((-1.0 * d) * (1.0 / Math.sqrt((l * h)))) * (1.0 - ((Math.pow(t_0, 2.0) * 0.5) * (h / l)));
} else {
tmp = ((Math.sqrt(d) / Math.sqrt(l)) * t_1) * (1.0 - (((Math.pow(((0.5 * M_m) * (D_m / d)), 2.0) * 0.5) * h) / l));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = (M_m / 2.0) * (D_m / d) t_1 = math.sqrt((d / h)) tmp = 0 if h <= -4.3e+122: tmp = math.sqrt((d / l)) * (t_1 * (1.0 - (((t_0 * t_0) * (0.5 * h)) / l))) elif h <= -5e-310: tmp = ((-1.0 * d) * (1.0 / math.sqrt((l * h)))) * (1.0 - ((math.pow(t_0, 2.0) * 0.5) * (h / l))) else: tmp = ((math.sqrt(d) / math.sqrt(l)) * t_1) * (1.0 - (((math.pow(((0.5 * M_m) * (D_m / d)), 2.0) * 0.5) * h) / l)) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(M_m / 2.0) * Float64(D_m / d)) t_1 = sqrt(Float64(d / h)) tmp = 0.0 if (h <= -4.3e+122) tmp = Float64(sqrt(Float64(d / l)) * Float64(t_1 * Float64(1.0 - Float64(Float64(Float64(t_0 * t_0) * Float64(0.5 * h)) / l)))); elseif (h <= -5e-310) tmp = Float64(Float64(Float64(-1.0 * d) * Float64(1.0 / sqrt(Float64(l * h)))) * Float64(1.0 - Float64(Float64((t_0 ^ 2.0) * 0.5) * Float64(h / l)))); else tmp = Float64(Float64(Float64(sqrt(d) / sqrt(l)) * t_1) * Float64(1.0 - Float64(Float64(Float64((Float64(Float64(0.5 * M_m) * Float64(D_m / d)) ^ 2.0) * 0.5) * h) / l))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = (M_m / 2.0) * (D_m / d);
t_1 = sqrt((d / h));
tmp = 0.0;
if (h <= -4.3e+122)
tmp = sqrt((d / l)) * (t_1 * (1.0 - (((t_0 * t_0) * (0.5 * h)) / l)));
elseif (h <= -5e-310)
tmp = ((-1.0 * d) * (1.0 / sqrt((l * h)))) * (1.0 - (((t_0 ^ 2.0) * 0.5) * (h / l)));
else
tmp = ((sqrt(d) / sqrt(l)) * t_1) * (1.0 - ((((((0.5 * M_m) * (D_m / d)) ^ 2.0) * 0.5) * h) / l));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[h, -4.3e+122], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(t$95$1 * N[(1.0 - N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[(0.5 * h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -5e-310], N[(N[(N[(-1.0 * d), $MachinePrecision] * N[(1.0 / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[t$95$0, 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[Power[N[(N[(0.5 * M$95$m), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{M\_m}{2} \cdot \frac{D\_m}{d}\\
t_1 := \sqrt{\frac{d}{h}}\\
\mathbf{if}\;h \leq -4.3 \cdot 10^{+122}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(t\_1 \cdot \left(1 - \frac{\left(t\_0 \cdot t\_0\right) \cdot \left(0.5 \cdot h\right)}{\ell}\right)\right)\\
\mathbf{elif}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\left(-1 \cdot d\right) \cdot \frac{1}{\sqrt{\ell \cdot h}}\right) \cdot \left(1 - \left({t\_0}^{2} \cdot 0.5\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot t\_1\right) \cdot \left(1 - \frac{\left({\left(\left(0.5 \cdot M\_m\right) \cdot \frac{D\_m}{d}\right)}^{2} \cdot 0.5\right) \cdot h}{\ell}\right)\\
\end{array}
\end{array}
if h < -4.29999999999999971e122Initial program 53.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 rewrites55.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-/.f6455.5
Applied rewrites55.5%
Applied rewrites55.5%
lift-*.f64N/A
*-commutativeN/A
lift-*.f6455.5
lift-pow.f64N/A
unpow2N/A
lower-*.f6455.5
Applied rewrites55.5%
if -4.29999999999999971e122 < h < -4.999999999999985e-310Initial program 70.1%
Taylor expanded in h around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6477.9
Applied rewrites77.9%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6478.1
Applied rewrites78.1%
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
frac-timesN/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f6477.0
Applied rewrites77.0%
if -4.999999999999985e-310 < h Initial program 66.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 rewrites67.3%
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-/.f6467.3
Applied rewrites67.3%
lift-/.f64N/A
lift-sqrt.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6473.7
Applied rewrites73.7%
Taylor expanded in M around 0
lower-*.f6473.7
Applied rewrites73.7%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (* (/ M_m 2.0) (/ D_m d))))
(if (<= d -2.4e-294)
(*
(* (* -1.0 d) (/ 1.0 (sqrt (* l h))))
(- 1.0 (* (* (pow t_0 2.0) 0.5) (/ h l))))
(if (<= d 1.05e+98)
(*
(sqrt (/ d l))
(* (sqrt (/ d h)) (- 1.0 (/ (* (* t_0 t_0) (* 0.5 h)) l))))
(* (/ 1.0 (* (sqrt l) (sqrt h))) d)))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (M_m / 2.0) * (D_m / d);
double tmp;
if (d <= -2.4e-294) {
tmp = ((-1.0 * d) * (1.0 / sqrt((l * h)))) * (1.0 - ((pow(t_0, 2.0) * 0.5) * (h / l)));
} else if (d <= 1.05e+98) {
tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0 - (((t_0 * t_0) * (0.5 * h)) / l)));
} else {
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = (m_m / 2.0d0) * (d_m / d)
if (d <= (-2.4d-294)) then
tmp = (((-1.0d0) * d) * (1.0d0 / sqrt((l * h)))) * (1.0d0 - (((t_0 ** 2.0d0) * 0.5d0) * (h / l)))
else if (d <= 1.05d+98) then
tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0d0 - (((t_0 * t_0) * (0.5d0 * h)) / l)))
else
tmp = (1.0d0 / (sqrt(l) * sqrt(h))) * d
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (M_m / 2.0) * (D_m / d);
double tmp;
if (d <= -2.4e-294) {
tmp = ((-1.0 * d) * (1.0 / Math.sqrt((l * h)))) * (1.0 - ((Math.pow(t_0, 2.0) * 0.5) * (h / l)));
} else if (d <= 1.05e+98) {
tmp = Math.sqrt((d / l)) * (Math.sqrt((d / h)) * (1.0 - (((t_0 * t_0) * (0.5 * h)) / l)));
} else {
tmp = (1.0 / (Math.sqrt(l) * Math.sqrt(h))) * d;
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = (M_m / 2.0) * (D_m / d) tmp = 0 if d <= -2.4e-294: tmp = ((-1.0 * d) * (1.0 / math.sqrt((l * h)))) * (1.0 - ((math.pow(t_0, 2.0) * 0.5) * (h / l))) elif d <= 1.05e+98: tmp = math.sqrt((d / l)) * (math.sqrt((d / h)) * (1.0 - (((t_0 * t_0) * (0.5 * h)) / l))) else: tmp = (1.0 / (math.sqrt(l) * math.sqrt(h))) * d return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(M_m / 2.0) * Float64(D_m / d)) tmp = 0.0 if (d <= -2.4e-294) tmp = Float64(Float64(Float64(-1.0 * d) * Float64(1.0 / sqrt(Float64(l * h)))) * Float64(1.0 - Float64(Float64((t_0 ^ 2.0) * 0.5) * Float64(h / l)))); elseif (d <= 1.05e+98) tmp = Float64(sqrt(Float64(d / l)) * Float64(sqrt(Float64(d / h)) * Float64(1.0 - Float64(Float64(Float64(t_0 * t_0) * Float64(0.5 * h)) / l)))); else tmp = Float64(Float64(1.0 / Float64(sqrt(l) * sqrt(h))) * d); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = (M_m / 2.0) * (D_m / d);
tmp = 0.0;
if (d <= -2.4e-294)
tmp = ((-1.0 * d) * (1.0 / sqrt((l * h)))) * (1.0 - (((t_0 ^ 2.0) * 0.5) * (h / l)));
elseif (d <= 1.05e+98)
tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0 - (((t_0 * t_0) * (0.5 * h)) / l)));
else
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.4e-294], N[(N[(N[(-1.0 * d), $MachinePrecision] * N[(1.0 / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[t$95$0, 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.05e+98], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[(0.5 * h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{M\_m}{2} \cdot \frac{D\_m}{d}\\
\mathbf{if}\;d \leq -2.4 \cdot 10^{-294}:\\
\;\;\;\;\left(\left(-1 \cdot d\right) \cdot \frac{1}{\sqrt{\ell \cdot h}}\right) \cdot \left(1 - \left({t\_0}^{2} \cdot 0.5\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{elif}\;d \leq 1.05 \cdot 10^{+98}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 - \frac{\left(t\_0 \cdot t\_0\right) \cdot \left(0.5 \cdot h\right)}{\ell}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\ell} \cdot \sqrt{h}} \cdot d\\
\end{array}
\end{array}
if d < -2.39999999999999997e-294Initial program 65.9%
Taylor expanded in h around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6469.1
Applied rewrites69.1%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6469.3
Applied rewrites69.3%
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
frac-timesN/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f6468.5
Applied rewrites68.5%
if -2.39999999999999997e-294 < d < 1.05000000000000002e98Initial program 62.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 rewrites62.0%
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-/.f6462.0
Applied rewrites62.0%
Applied rewrites62.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f6462.0
lift-pow.f64N/A
unpow2N/A
lower-*.f6462.0
Applied rewrites62.0%
if 1.05000000000000002e98 < d Initial program 72.7%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6462.9
Applied rewrites62.9%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6462.8
Applied rewrites62.8%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lift-sqrt.f64N/A
lower-sqrt.f6472.8
Applied rewrites72.8%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= d 5.5e-298)
(* (- d) (pow (* l h) -0.5))
(if (<= d 1.35e-42)
(*
(* -0.125 (* (* D_m D_m) (/ (* M_m M_m) d)))
(sqrt (/ h (* (* l l) l))))
(* (/ 1.0 (* (sqrt l) (sqrt h))) d))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (d <= 5.5e-298) {
tmp = -d * pow((l * h), -0.5);
} else if (d <= 1.35e-42) {
tmp = (-0.125 * ((D_m * D_m) * ((M_m * M_m) / d))) * sqrt((h / ((l * l) * l)));
} else {
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: tmp
if (d <= 5.5d-298) then
tmp = -d * ((l * h) ** (-0.5d0))
else if (d <= 1.35d-42) then
tmp = ((-0.125d0) * ((d_m * d_m) * ((m_m * m_m) / d))) * sqrt((h / ((l * l) * l)))
else
tmp = (1.0d0 / (sqrt(l) * sqrt(h))) * d
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (d <= 5.5e-298) {
tmp = -d * Math.pow((l * h), -0.5);
} else if (d <= 1.35e-42) {
tmp = (-0.125 * ((D_m * D_m) * ((M_m * M_m) / d))) * Math.sqrt((h / ((l * l) * l)));
} else {
tmp = (1.0 / (Math.sqrt(l) * Math.sqrt(h))) * d;
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if d <= 5.5e-298: tmp = -d * math.pow((l * h), -0.5) elif d <= 1.35e-42: tmp = (-0.125 * ((D_m * D_m) * ((M_m * M_m) / d))) * math.sqrt((h / ((l * l) * l))) else: tmp = (1.0 / (math.sqrt(l) * math.sqrt(h))) * d return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (d <= 5.5e-298) tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5)); elseif (d <= 1.35e-42) tmp = Float64(Float64(-0.125 * Float64(Float64(D_m * D_m) * Float64(Float64(M_m * M_m) / d))) * sqrt(Float64(h / Float64(Float64(l * l) * l)))); else tmp = Float64(Float64(1.0 / Float64(sqrt(l) * sqrt(h))) * d); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (d <= 5.5e-298)
tmp = -d * ((l * h) ^ -0.5);
elseif (d <= 1.35e-42)
tmp = (-0.125 * ((D_m * D_m) * ((M_m * M_m) / d))) * sqrt((h / ((l * l) * l)));
else
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[d, 5.5e-298], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.35e-42], N[(N[(-0.125 * N[(N[(D$95$m * D$95$m), $MachinePrecision] * N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 5.5 \cdot 10^{-298}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{elif}\;d \leq 1.35 \cdot 10^{-42}:\\
\;\;\;\;\left(-0.125 \cdot \left(\left(D\_m \cdot D\_m\right) \cdot \frac{M\_m \cdot M\_m}{d}\right)\right) \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\ell} \cdot \sqrt{h}} \cdot d\\
\end{array}
\end{array}
if d < 5.4999999999999996e-298Initial program 64.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 rewrites65.5%
Taylor expanded in l around -inf
metadata-evalN/A
metadata-evalN/A
Applied rewrites41.9%
if 5.4999999999999996e-298 < d < 1.35e-42Initial program 54.6%
Taylor expanded in d around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow-prod-downN/A
*-commutativeN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-pow.f6445.7
Applied rewrites45.7%
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6437.5
Applied rewrites37.5%
lift-pow.f64N/A
unpow3N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6437.5
Applied rewrites37.5%
if 1.35e-42 < d Initial program 76.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6454.1
Applied rewrites54.1%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6454.1
Applied rewrites54.1%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lift-sqrt.f64N/A
lower-sqrt.f6464.1
Applied rewrites64.1%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= l -1e-249)
(* (sqrt (/ d l)) (sqrt (/ d h)))
(if (<= l 2.2e-299)
(* (/ 1.0 (sqrt (* l h))) d)
(* (/ 1.0 (* (sqrt l) (sqrt h))) d))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= -1e-249) {
tmp = sqrt((d / l)) * sqrt((d / h));
} else if (l <= 2.2e-299) {
tmp = (1.0 / sqrt((l * h))) * d;
} else {
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: tmp
if (l <= (-1d-249)) then
tmp = sqrt((d / l)) * sqrt((d / h))
else if (l <= 2.2d-299) then
tmp = (1.0d0 / sqrt((l * h))) * d
else
tmp = (1.0d0 / (sqrt(l) * sqrt(h))) * d
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= -1e-249) {
tmp = Math.sqrt((d / l)) * Math.sqrt((d / h));
} else if (l <= 2.2e-299) {
tmp = (1.0 / Math.sqrt((l * h))) * d;
} else {
tmp = (1.0 / (Math.sqrt(l) * Math.sqrt(h))) * d;
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if l <= -1e-249: tmp = math.sqrt((d / l)) * math.sqrt((d / h)) elif l <= 2.2e-299: tmp = (1.0 / math.sqrt((l * h))) * d else: tmp = (1.0 / (math.sqrt(l) * math.sqrt(h))) * d return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (l <= -1e-249) tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))); elseif (l <= 2.2e-299) tmp = Float64(Float64(1.0 / sqrt(Float64(l * h))) * d); else tmp = Float64(Float64(1.0 / Float64(sqrt(l) * sqrt(h))) * d); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (l <= -1e-249)
tmp = sqrt((d / l)) * sqrt((d / h));
elseif (l <= 2.2e-299)
tmp = (1.0 / sqrt((l * h))) * d;
else
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -1e-249], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.2e-299], N[(N[(1.0 / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision], N[(N[(1.0 / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1 \cdot 10^{-249}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{elif}\;\ell \leq 2.2 \cdot 10^{-299}:\\
\;\;\;\;\frac{1}{\sqrt{\ell \cdot h}} \cdot d\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\ell} \cdot \sqrt{h}} \cdot d\\
\end{array}
\end{array}
if l < -1.00000000000000005e-249Initial program 64.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 rewrites65.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-/.f6465.2
Applied rewrites65.2%
Applied rewrites65.2%
Taylor expanded in d around inf
lift-sqrt.f64N/A
lift-/.f6439.4
Applied rewrites39.4%
if -1.00000000000000005e-249 < l < 2.2e-299Initial program 70.0%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6426.2
Applied rewrites26.2%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6425.6
Applied rewrites25.6%
if 2.2e-299 < l Initial program 66.4%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6441.3
Applied rewrites41.3%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6441.5
Applied rewrites41.5%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lift-sqrt.f64N/A
lower-sqrt.f6449.1
Applied rewrites49.1%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (if (<= h 5.8e-291) (* (sqrt (/ 1.0 (* l h))) d) (* (/ 1.0 (* (sqrt l) (sqrt h))) d)))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (h <= 5.8e-291) {
tmp = sqrt((1.0 / (l * h))) * d;
} else {
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: tmp
if (h <= 5.8d-291) then
tmp = sqrt((1.0d0 / (l * h))) * d
else
tmp = (1.0d0 / (sqrt(l) * sqrt(h))) * d
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (h <= 5.8e-291) {
tmp = Math.sqrt((1.0 / (l * h))) * d;
} else {
tmp = (1.0 / (Math.sqrt(l) * Math.sqrt(h))) * d;
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if h <= 5.8e-291: tmp = math.sqrt((1.0 / (l * h))) * d else: tmp = (1.0 / (math.sqrt(l) * math.sqrt(h))) * d return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (h <= 5.8e-291) tmp = Float64(sqrt(Float64(1.0 / Float64(l * h))) * d); else tmp = Float64(Float64(1.0 / Float64(sqrt(l) * sqrt(h))) * d); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (h <= 5.8e-291)
tmp = sqrt((1.0 / (l * h))) * d;
else
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[h, 5.8e-291], N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision], N[(N[(1.0 / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq 5.8 \cdot 10^{-291}:\\
\;\;\;\;\sqrt{\frac{1}{\ell \cdot h}} \cdot d\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\ell} \cdot \sqrt{h}} \cdot d\\
\end{array}
\end{array}
if h < 5.80000000000000003e-291Initial program 65.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6411.3
Applied rewrites11.3%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lift-*.f6411.3
Applied rewrites11.3%
if 5.80000000000000003e-291 < h Initial program 66.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6440.7
Applied rewrites40.7%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6440.9
Applied rewrites40.9%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lift-sqrt.f64N/A
lower-sqrt.f6448.5
Applied rewrites48.5%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (* (sqrt (/ (/ 1.0 l) h)) d))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
return sqrt(((1.0 / l) / h)) * d;
}
M_m = private
D_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
code = sqrt(((1.0d0 / l) / h)) * d
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
return Math.sqrt(((1.0 / l) / h)) * d;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): return math.sqrt(((1.0 / l) / h)) * d
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) return Float64(sqrt(Float64(Float64(1.0 / l) / h)) * d) end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
tmp = sqrt(((1.0 / l) / h)) * d;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := N[(N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\sqrt{\frac{\frac{1}{\ell}}{h}} \cdot d
\end{array}
Initial program 65.8%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6425.9
Applied rewrites25.9%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lift-*.f6425.9
Applied rewrites25.9%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6426.0
Applied rewrites26.0%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (* (sqrt (/ 1.0 (* l h))) d))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
return sqrt((1.0 / (l * h))) * d;
}
M_m = private
D_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
code = sqrt((1.0d0 / (l * h))) * d
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
return Math.sqrt((1.0 / (l * h))) * d;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): return math.sqrt((1.0 / (l * h))) * d
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) return Float64(sqrt(Float64(1.0 / Float64(l * h))) * d) end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
tmp = sqrt((1.0 / (l * h))) * d;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\sqrt{\frac{1}{\ell \cdot h}} \cdot d
\end{array}
Initial program 65.8%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6425.9
Applied rewrites25.9%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lift-*.f6425.9
Applied rewrites25.9%
herbie shell --seed 2025100
(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)))))