
(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 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
d_m = (fabs.f64 d)
NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d_m h l M D)
:precision binary64
(let* ((t_0 (/ (* M D) (+ d_m d_m))))
(if (<= d_m 3.1e-287)
(*
-0.125
(/
(* (pow D 2.0) (* (pow M 2.0) (* h (sqrt (/ 1.0 (* h l))))))
(* d_m l)))
(*
(* d_m (sqrt (/ (/ 1.0 l) h)))
(- 1.0 (* (* t_0 (* t_0 0.5)) (/ h l)))))))d_m = fabs(d);
assert(d_m < h && h < l && l < M && M < D);
double code(double d_m, double h, double l, double M, double D) {
double t_0 = (M * D) / (d_m + d_m);
double tmp;
if (d_m <= 3.1e-287) {
tmp = -0.125 * ((pow(D, 2.0) * (pow(M, 2.0) * (h * sqrt((1.0 / (h * l)))))) / (d_m * l));
} else {
tmp = (d_m * sqrt(((1.0 / l) / h))) * (1.0 - ((t_0 * (t_0 * 0.5)) * (h / l)));
}
return tmp;
}
d_m = private
NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m, d)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (m * d) / (d_m + d_m)
if (d_m <= 3.1d-287) then
tmp = (-0.125d0) * (((d ** 2.0d0) * ((m ** 2.0d0) * (h * sqrt((1.0d0 / (h * l)))))) / (d_m * l))
else
tmp = (d_m * sqrt(((1.0d0 / l) / h))) * (1.0d0 - ((t_0 * (t_0 * 0.5d0)) * (h / l)))
end if
code = tmp
end function
d_m = Math.abs(d);
assert d_m < h && h < l && l < M && M < D;
public static double code(double d_m, double h, double l, double M, double D) {
double t_0 = (M * D) / (d_m + d_m);
double tmp;
if (d_m <= 3.1e-287) {
tmp = -0.125 * ((Math.pow(D, 2.0) * (Math.pow(M, 2.0) * (h * Math.sqrt((1.0 / (h * l)))))) / (d_m * l));
} else {
tmp = (d_m * Math.sqrt(((1.0 / l) / h))) * (1.0 - ((t_0 * (t_0 * 0.5)) * (h / l)));
}
return tmp;
}
d_m = math.fabs(d) [d_m, h, l, M, D] = sort([d_m, h, l, M, D]) def code(d_m, h, l, M, D): t_0 = (M * D) / (d_m + d_m) tmp = 0 if d_m <= 3.1e-287: tmp = -0.125 * ((math.pow(D, 2.0) * (math.pow(M, 2.0) * (h * math.sqrt((1.0 / (h * l)))))) / (d_m * l)) else: tmp = (d_m * math.sqrt(((1.0 / l) / h))) * (1.0 - ((t_0 * (t_0 * 0.5)) * (h / l))) return tmp
d_m = abs(d) d_m, h, l, M, D = sort([d_m, h, l, M, D]) function code(d_m, h, l, M, D) t_0 = Float64(Float64(M * D) / Float64(d_m + d_m)) tmp = 0.0 if (d_m <= 3.1e-287) tmp = Float64(-0.125 * Float64(Float64((D ^ 2.0) * Float64((M ^ 2.0) * Float64(h * sqrt(Float64(1.0 / Float64(h * l)))))) / Float64(d_m * l))); else tmp = Float64(Float64(d_m * sqrt(Float64(Float64(1.0 / l) / h))) * Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * 0.5)) * Float64(h / l)))); end return tmp end
d_m = abs(d);
d_m, h, l, M, D = num2cell(sort([d_m, h, l, M, D])){:}
function tmp_2 = code(d_m, h, l, M, D)
t_0 = (M * D) / (d_m + d_m);
tmp = 0.0;
if (d_m <= 3.1e-287)
tmp = -0.125 * (((D ^ 2.0) * ((M ^ 2.0) * (h * sqrt((1.0 / (h * l)))))) / (d_m * l));
else
tmp = (d_m * sqrt(((1.0 / l) / h))) * (1.0 - ((t_0 * (t_0 * 0.5)) * (h / l)));
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(M * D), $MachinePrecision] / N[(d$95$m + d$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d$95$m, 3.1e-287], N[(-0.125 * N[(N[(N[Power[D, 2.0], $MachinePrecision] * N[(N[Power[M, 2.0], $MachinePrecision] * N[(h * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d$95$m * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d$95$m * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * 0.5), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|
\\
[d_m, h, l, M, D] = \mathsf{sort}([d_m, h, l, M, D])\\
\\
\begin{array}{l}
t_0 := \frac{M \cdot D}{d\_m + d\_m}\\
\mathbf{if}\;d\_m \leq 3.1 \cdot 10^{-287}:\\
\;\;\;\;-0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\right)}{d\_m \cdot \ell}\\
\mathbf{else}:\\
\;\;\;\;\left(d\_m \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right) \cdot \left(1 - \left(t\_0 \cdot \left(t\_0 \cdot 0.5\right)\right) \cdot \frac{h}{\ell}\right)\\
\end{array}
\end{array}
if d < 3.1000000000000001e-287Initial program 35.3%
Applied rewrites42.6%
Taylor expanded in d around 0
Applied rewrites32.5%
if 3.1000000000000001e-287 < d Initial program 35.3%
Applied rewrites42.6%
Taylor expanded in d around 0
Applied rewrites69.1%
Applied rewrites69.6%
Applied rewrites69.6%
d_m = (fabs.f64 d)
NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d_m h l M D)
:precision binary64
(let* ((t_0 (/ (* M D) (+ d_m d_m))))
(if (<= h 5.6e+222)
(* (* d_m (sqrt (/ 1.0 (* h l)))) (- 1.0 (* (* t_0 (* t_0 0.5)) (/ h l))))
(/ (* (* -1.0 (* d_m (sqrt (/ h d_m)))) (sqrt (/ d_m l))) h))))d_m = fabs(d);
assert(d_m < h && h < l && l < M && M < D);
double code(double d_m, double h, double l, double M, double D) {
double t_0 = (M * D) / (d_m + d_m);
double tmp;
if (h <= 5.6e+222) {
tmp = (d_m * sqrt((1.0 / (h * l)))) * (1.0 - ((t_0 * (t_0 * 0.5)) * (h / l)));
} else {
tmp = ((-1.0 * (d_m * sqrt((h / d_m)))) * sqrt((d_m / l))) / h;
}
return tmp;
}
d_m = private
NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m, d)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (m * d) / (d_m + d_m)
if (h <= 5.6d+222) then
tmp = (d_m * sqrt((1.0d0 / (h * l)))) * (1.0d0 - ((t_0 * (t_0 * 0.5d0)) * (h / l)))
else
tmp = (((-1.0d0) * (d_m * sqrt((h / d_m)))) * sqrt((d_m / l))) / h
end if
code = tmp
end function
d_m = Math.abs(d);
assert d_m < h && h < l && l < M && M < D;
public static double code(double d_m, double h, double l, double M, double D) {
double t_0 = (M * D) / (d_m + d_m);
double tmp;
if (h <= 5.6e+222) {
tmp = (d_m * Math.sqrt((1.0 / (h * l)))) * (1.0 - ((t_0 * (t_0 * 0.5)) * (h / l)));
} else {
tmp = ((-1.0 * (d_m * Math.sqrt((h / d_m)))) * Math.sqrt((d_m / l))) / h;
}
return tmp;
}
d_m = math.fabs(d) [d_m, h, l, M, D] = sort([d_m, h, l, M, D]) def code(d_m, h, l, M, D): t_0 = (M * D) / (d_m + d_m) tmp = 0 if h <= 5.6e+222: tmp = (d_m * math.sqrt((1.0 / (h * l)))) * (1.0 - ((t_0 * (t_0 * 0.5)) * (h / l))) else: tmp = ((-1.0 * (d_m * math.sqrt((h / d_m)))) * math.sqrt((d_m / l))) / h return tmp
d_m = abs(d) d_m, h, l, M, D = sort([d_m, h, l, M, D]) function code(d_m, h, l, M, D) t_0 = Float64(Float64(M * D) / Float64(d_m + d_m)) tmp = 0.0 if (h <= 5.6e+222) tmp = Float64(Float64(d_m * sqrt(Float64(1.0 / Float64(h * l)))) * Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * 0.5)) * Float64(h / l)))); else tmp = Float64(Float64(Float64(-1.0 * Float64(d_m * sqrt(Float64(h / d_m)))) * sqrt(Float64(d_m / l))) / h); end return tmp end
d_m = abs(d);
d_m, h, l, M, D = num2cell(sort([d_m, h, l, M, D])){:}
function tmp_2 = code(d_m, h, l, M, D)
t_0 = (M * D) / (d_m + d_m);
tmp = 0.0;
if (h <= 5.6e+222)
tmp = (d_m * sqrt((1.0 / (h * l)))) * (1.0 - ((t_0 * (t_0 * 0.5)) * (h / l)));
else
tmp = ((-1.0 * (d_m * sqrt((h / d_m)))) * sqrt((d_m / l))) / h;
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(M * D), $MachinePrecision] / N[(d$95$m + d$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, 5.6e+222], N[(N[(d$95$m * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * 0.5), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-1.0 * N[(d$95$m * N[Sqrt[N[(h / d$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d$95$m / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|
\\
[d_m, h, l, M, D] = \mathsf{sort}([d_m, h, l, M, D])\\
\\
\begin{array}{l}
t_0 := \frac{M \cdot D}{d\_m + d\_m}\\
\mathbf{if}\;h \leq 5.6 \cdot 10^{+222}:\\
\;\;\;\;\left(d\_m \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \cdot \left(1 - \left(t\_0 \cdot \left(t\_0 \cdot 0.5\right)\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-1 \cdot \left(d\_m \cdot \sqrt{\frac{h}{d\_m}}\right)\right) \cdot \sqrt{\frac{d\_m}{\ell}}}{h}\\
\end{array}
\end{array}
if h < 5.6000000000000003e222Initial program 35.3%
Applied rewrites42.6%
Taylor expanded in d around 0
Applied rewrites69.1%
Applied rewrites69.1%
if 5.6000000000000003e222 < h Initial program 35.3%
Taylor expanded in h around 0
Applied rewrites17.9%
Taylor expanded in d around -inf
Applied rewrites5.9%
d_m = (fabs.f64 d) NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function. (FPCore (d_m h l M D) :precision binary64 (let* ((t_0 (/ (* M D) (+ d_m d_m)))) (* (* d_m (sqrt (/ (/ 1.0 l) h))) (- 1.0 (* (* t_0 (* t_0 0.5)) (/ h l))))))
d_m = fabs(d);
assert(d_m < h && h < l && l < M && M < D);
double code(double d_m, double h, double l, double M, double D) {
double t_0 = (M * D) / (d_m + d_m);
return (d_m * sqrt(((1.0 / l) / h))) * (1.0 - ((t_0 * (t_0 * 0.5)) * (h / l)));
}
d_m = private
NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m, d)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8) :: t_0
t_0 = (m * d) / (d_m + d_m)
code = (d_m * sqrt(((1.0d0 / l) / h))) * (1.0d0 - ((t_0 * (t_0 * 0.5d0)) * (h / l)))
end function
d_m = Math.abs(d);
assert d_m < h && h < l && l < M && M < D;
public static double code(double d_m, double h, double l, double M, double D) {
double t_0 = (M * D) / (d_m + d_m);
return (d_m * Math.sqrt(((1.0 / l) / h))) * (1.0 - ((t_0 * (t_0 * 0.5)) * (h / l)));
}
d_m = math.fabs(d) [d_m, h, l, M, D] = sort([d_m, h, l, M, D]) def code(d_m, h, l, M, D): t_0 = (M * D) / (d_m + d_m) return (d_m * math.sqrt(((1.0 / l) / h))) * (1.0 - ((t_0 * (t_0 * 0.5)) * (h / l)))
d_m = abs(d) d_m, h, l, M, D = sort([d_m, h, l, M, D]) function code(d_m, h, l, M, D) t_0 = Float64(Float64(M * D) / Float64(d_m + d_m)) return Float64(Float64(d_m * sqrt(Float64(Float64(1.0 / l) / h))) * Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * 0.5)) * Float64(h / l)))) end
d_m = abs(d);
d_m, h, l, M, D = num2cell(sort([d_m, h, l, M, D])){:}
function tmp = code(d_m, h, l, M, D)
t_0 = (M * D) / (d_m + d_m);
tmp = (d_m * sqrt(((1.0 / l) / h))) * (1.0 - ((t_0 * (t_0 * 0.5)) * (h / l)));
end
d_m = N[Abs[d], $MachinePrecision]
NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(M * D), $MachinePrecision] / N[(d$95$m + d$95$m), $MachinePrecision]), $MachinePrecision]}, N[(N[(d$95$m * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * 0.5), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|
\\
[d_m, h, l, M, D] = \mathsf{sort}([d_m, h, l, M, D])\\
\\
\begin{array}{l}
t_0 := \frac{M \cdot D}{d\_m + d\_m}\\
\left(d\_m \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right) \cdot \left(1 - \left(t\_0 \cdot \left(t\_0 \cdot 0.5\right)\right) \cdot \frac{h}{\ell}\right)
\end{array}
\end{array}
Initial program 35.3%
Applied rewrites42.6%
Taylor expanded in d around 0
Applied rewrites69.1%
Applied rewrites69.6%
Applied rewrites69.6%
d_m = (fabs.f64 d)
NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d_m h l M D)
:precision binary64
(if (<= M 2.85e-75)
(* (* d_m (sqrt (/ (/ 1.0 l) h))) 1.0)
(/
(*
(- l (/ (* (* (/ (* (* M M) (* D D)) d_m) 0.125) h) d_m))
(sqrt (/ (* d_m d_m) (* l h))))
l)))d_m = fabs(d);
assert(d_m < h && h < l && l < M && M < D);
double code(double d_m, double h, double l, double M, double D) {
double tmp;
if (M <= 2.85e-75) {
tmp = (d_m * sqrt(((1.0 / l) / h))) * 1.0;
} else {
tmp = ((l - ((((((M * M) * (D * D)) / d_m) * 0.125) * h) / d_m)) * sqrt(((d_m * d_m) / (l * h)))) / l;
}
return tmp;
}
d_m = private
NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m, d)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8) :: tmp
if (m <= 2.85d-75) then
tmp = (d_m * sqrt(((1.0d0 / l) / h))) * 1.0d0
else
tmp = ((l - ((((((m * m) * (d * d)) / d_m) * 0.125d0) * h) / d_m)) * sqrt(((d_m * d_m) / (l * h)))) / l
end if
code = tmp
end function
d_m = Math.abs(d);
assert d_m < h && h < l && l < M && M < D;
public static double code(double d_m, double h, double l, double M, double D) {
double tmp;
if (M <= 2.85e-75) {
tmp = (d_m * Math.sqrt(((1.0 / l) / h))) * 1.0;
} else {
tmp = ((l - ((((((M * M) * (D * D)) / d_m) * 0.125) * h) / d_m)) * Math.sqrt(((d_m * d_m) / (l * h)))) / l;
}
return tmp;
}
d_m = math.fabs(d) [d_m, h, l, M, D] = sort([d_m, h, l, M, D]) def code(d_m, h, l, M, D): tmp = 0 if M <= 2.85e-75: tmp = (d_m * math.sqrt(((1.0 / l) / h))) * 1.0 else: tmp = ((l - ((((((M * M) * (D * D)) / d_m) * 0.125) * h) / d_m)) * math.sqrt(((d_m * d_m) / (l * h)))) / l return tmp
d_m = abs(d) d_m, h, l, M, D = sort([d_m, h, l, M, D]) function code(d_m, h, l, M, D) tmp = 0.0 if (M <= 2.85e-75) tmp = Float64(Float64(d_m * sqrt(Float64(Float64(1.0 / l) / h))) * 1.0); else tmp = Float64(Float64(Float64(l - Float64(Float64(Float64(Float64(Float64(Float64(M * M) * Float64(D * D)) / d_m) * 0.125) * h) / d_m)) * sqrt(Float64(Float64(d_m * d_m) / Float64(l * h)))) / l); end return tmp end
d_m = abs(d);
d_m, h, l, M, D = num2cell(sort([d_m, h, l, M, D])){:}
function tmp_2 = code(d_m, h, l, M, D)
tmp = 0.0;
if (M <= 2.85e-75)
tmp = (d_m * sqrt(((1.0 / l) / h))) * 1.0;
else
tmp = ((l - ((((((M * M) * (D * D)) / d_m) * 0.125) * h) / d_m)) * sqrt(((d_m * d_m) / (l * h)))) / l;
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision] NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function. code[d$95$m_, h_, l_, M_, D_] := If[LessEqual[M, 2.85e-75], N[(N[(d$95$m * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(N[(l - N[(N[(N[(N[(N[(N[(M * M), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision] / d$95$m), $MachinePrecision] * 0.125), $MachinePrecision] * h), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[(d$95$m * d$95$m), $MachinePrecision] / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|
\\
[d_m, h, l, M, D] = \mathsf{sort}([d_m, h, l, M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 2.85 \cdot 10^{-75}:\\
\;\;\;\;\left(d\_m \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\ell - \frac{\left(\frac{\left(M \cdot M\right) \cdot \left(D \cdot D\right)}{d\_m} \cdot 0.125\right) \cdot h}{d\_m}\right) \cdot \sqrt{\frac{d\_m \cdot d\_m}{\ell \cdot h}}}{\ell}\\
\end{array}
\end{array}
if M < 2.84999999999999983e-75Initial program 35.3%
Applied rewrites42.6%
Taylor expanded in d around 0
Applied rewrites69.1%
Applied rewrites69.6%
Taylor expanded in d around inf
Applied rewrites42.5%
if 2.84999999999999983e-75 < M Initial program 35.3%
Applied rewrites31.1%
Applied rewrites37.4%
d_m = (fabs.f64 d)
NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d_m h l M D)
:precision binary64
(if (<= M 2.9e-75)
(* (* d_m (sqrt (/ (/ 1.0 l) h))) 1.0)
(/
(*
(- l (* (* (/ (* (* M M) (* D D)) d_m) 0.125) (/ h d_m)))
(sqrt (/ (* d_m d_m) (* l h))))
l)))d_m = fabs(d);
assert(d_m < h && h < l && l < M && M < D);
double code(double d_m, double h, double l, double M, double D) {
double tmp;
if (M <= 2.9e-75) {
tmp = (d_m * sqrt(((1.0 / l) / h))) * 1.0;
} else {
tmp = ((l - (((((M * M) * (D * D)) / d_m) * 0.125) * (h / d_m))) * sqrt(((d_m * d_m) / (l * h)))) / l;
}
return tmp;
}
d_m = private
NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m, d)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8) :: tmp
if (m <= 2.9d-75) then
tmp = (d_m * sqrt(((1.0d0 / l) / h))) * 1.0d0
else
tmp = ((l - (((((m * m) * (d * d)) / d_m) * 0.125d0) * (h / d_m))) * sqrt(((d_m * d_m) / (l * h)))) / l
end if
code = tmp
end function
d_m = Math.abs(d);
assert d_m < h && h < l && l < M && M < D;
public static double code(double d_m, double h, double l, double M, double D) {
double tmp;
if (M <= 2.9e-75) {
tmp = (d_m * Math.sqrt(((1.0 / l) / h))) * 1.0;
} else {
tmp = ((l - (((((M * M) * (D * D)) / d_m) * 0.125) * (h / d_m))) * Math.sqrt(((d_m * d_m) / (l * h)))) / l;
}
return tmp;
}
d_m = math.fabs(d) [d_m, h, l, M, D] = sort([d_m, h, l, M, D]) def code(d_m, h, l, M, D): tmp = 0 if M <= 2.9e-75: tmp = (d_m * math.sqrt(((1.0 / l) / h))) * 1.0 else: tmp = ((l - (((((M * M) * (D * D)) / d_m) * 0.125) * (h / d_m))) * math.sqrt(((d_m * d_m) / (l * h)))) / l return tmp
d_m = abs(d) d_m, h, l, M, D = sort([d_m, h, l, M, D]) function code(d_m, h, l, M, D) tmp = 0.0 if (M <= 2.9e-75) tmp = Float64(Float64(d_m * sqrt(Float64(Float64(1.0 / l) / h))) * 1.0); else tmp = Float64(Float64(Float64(l - Float64(Float64(Float64(Float64(Float64(M * M) * Float64(D * D)) / d_m) * 0.125) * Float64(h / d_m))) * sqrt(Float64(Float64(d_m * d_m) / Float64(l * h)))) / l); end return tmp end
d_m = abs(d);
d_m, h, l, M, D = num2cell(sort([d_m, h, l, M, D])){:}
function tmp_2 = code(d_m, h, l, M, D)
tmp = 0.0;
if (M <= 2.9e-75)
tmp = (d_m * sqrt(((1.0 / l) / h))) * 1.0;
else
tmp = ((l - (((((M * M) * (D * D)) / d_m) * 0.125) * (h / d_m))) * sqrt(((d_m * d_m) / (l * h)))) / l;
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision] NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function. code[d$95$m_, h_, l_, M_, D_] := If[LessEqual[M, 2.9e-75], N[(N[(d$95$m * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(N[(l - N[(N[(N[(N[(N[(M * M), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision] / d$95$m), $MachinePrecision] * 0.125), $MachinePrecision] * N[(h / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[(d$95$m * d$95$m), $MachinePrecision] / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|
\\
[d_m, h, l, M, D] = \mathsf{sort}([d_m, h, l, M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 2.9 \cdot 10^{-75}:\\
\;\;\;\;\left(d\_m \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\ell - \left(\frac{\left(M \cdot M\right) \cdot \left(D \cdot D\right)}{d\_m} \cdot 0.125\right) \cdot \frac{h}{d\_m}\right) \cdot \sqrt{\frac{d\_m \cdot d\_m}{\ell \cdot h}}}{\ell}\\
\end{array}
\end{array}
if M < 2.9000000000000002e-75Initial program 35.3%
Applied rewrites42.6%
Taylor expanded in d around 0
Applied rewrites69.1%
Applied rewrites69.6%
Taylor expanded in d around inf
Applied rewrites42.5%
if 2.9000000000000002e-75 < M Initial program 35.3%
Applied rewrites31.1%
Applied rewrites34.6%
d_m = (fabs.f64 d) NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function. (FPCore (d_m h l M D) :precision binary64 (if (<= (* M D) 2.15e+173) (* (* d_m (sqrt (/ (/ 1.0 l) h))) 1.0) (/ (* -1.0 (* d_m (* l (sqrt (/ 1.0 (* h l)))))) l)))
d_m = fabs(d);
assert(d_m < h && h < l && l < M && M < D);
double code(double d_m, double h, double l, double M, double D) {
double tmp;
if ((M * D) <= 2.15e+173) {
tmp = (d_m * sqrt(((1.0 / l) / h))) * 1.0;
} else {
tmp = (-1.0 * (d_m * (l * sqrt((1.0 / (h * l)))))) / l;
}
return tmp;
}
d_m = private
NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m, d)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8) :: tmp
if ((m * d) <= 2.15d+173) then
tmp = (d_m * sqrt(((1.0d0 / l) / h))) * 1.0d0
else
tmp = ((-1.0d0) * (d_m * (l * sqrt((1.0d0 / (h * l)))))) / l
end if
code = tmp
end function
d_m = Math.abs(d);
assert d_m < h && h < l && l < M && M < D;
public static double code(double d_m, double h, double l, double M, double D) {
double tmp;
if ((M * D) <= 2.15e+173) {
tmp = (d_m * Math.sqrt(((1.0 / l) / h))) * 1.0;
} else {
tmp = (-1.0 * (d_m * (l * Math.sqrt((1.0 / (h * l)))))) / l;
}
return tmp;
}
d_m = math.fabs(d) [d_m, h, l, M, D] = sort([d_m, h, l, M, D]) def code(d_m, h, l, M, D): tmp = 0 if (M * D) <= 2.15e+173: tmp = (d_m * math.sqrt(((1.0 / l) / h))) * 1.0 else: tmp = (-1.0 * (d_m * (l * math.sqrt((1.0 / (h * l)))))) / l return tmp
d_m = abs(d) d_m, h, l, M, D = sort([d_m, h, l, M, D]) function code(d_m, h, l, M, D) tmp = 0.0 if (Float64(M * D) <= 2.15e+173) tmp = Float64(Float64(d_m * sqrt(Float64(Float64(1.0 / l) / h))) * 1.0); else tmp = Float64(Float64(-1.0 * Float64(d_m * Float64(l * sqrt(Float64(1.0 / Float64(h * l)))))) / l); end return tmp end
d_m = abs(d);
d_m, h, l, M, D = num2cell(sort([d_m, h, l, M, D])){:}
function tmp_2 = code(d_m, h, l, M, D)
tmp = 0.0;
if ((M * D) <= 2.15e+173)
tmp = (d_m * sqrt(((1.0 / l) / h))) * 1.0;
else
tmp = (-1.0 * (d_m * (l * sqrt((1.0 / (h * l)))))) / l;
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision] NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function. code[d$95$m_, h_, l_, M_, D_] := If[LessEqual[N[(M * D), $MachinePrecision], 2.15e+173], N[(N[(d$95$m * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(-1.0 * N[(d$95$m * N[(l * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|
\\
[d_m, h, l, M, D] = \mathsf{sort}([d_m, h, l, M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;M \cdot D \leq 2.15 \cdot 10^{+173}:\\
\;\;\;\;\left(d\_m \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\frac{-1 \cdot \left(d\_m \cdot \left(\ell \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\right)}{\ell}\\
\end{array}
\end{array}
if (*.f64 M D) < 2.15000000000000013e173Initial program 35.3%
Applied rewrites42.6%
Taylor expanded in d around 0
Applied rewrites69.1%
Applied rewrites69.6%
Taylor expanded in d around inf
Applied rewrites42.5%
if 2.15000000000000013e173 < (*.f64 M D) Initial program 35.3%
Applied rewrites31.1%
Taylor expanded in d around -inf
Applied rewrites10.6%
d_m = (fabs.f64 d) NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function. (FPCore (d_m h l M D) :precision binary64 (let* ((t_0 (* d_m (sqrt (/ (/ 1.0 l) h))))) (if (<= (* M D) 2.15e+173) (* t_0 1.0) (* -1.0 t_0))))
d_m = fabs(d);
assert(d_m < h && h < l && l < M && M < D);
double code(double d_m, double h, double l, double M, double D) {
double t_0 = d_m * sqrt(((1.0 / l) / h));
double tmp;
if ((M * D) <= 2.15e+173) {
tmp = t_0 * 1.0;
} else {
tmp = -1.0 * t_0;
}
return tmp;
}
d_m = private
NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m, d)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = d_m * sqrt(((1.0d0 / l) / h))
if ((m * d) <= 2.15d+173) then
tmp = t_0 * 1.0d0
else
tmp = (-1.0d0) * t_0
end if
code = tmp
end function
d_m = Math.abs(d);
assert d_m < h && h < l && l < M && M < D;
public static double code(double d_m, double h, double l, double M, double D) {
double t_0 = d_m * Math.sqrt(((1.0 / l) / h));
double tmp;
if ((M * D) <= 2.15e+173) {
tmp = t_0 * 1.0;
} else {
tmp = -1.0 * t_0;
}
return tmp;
}
d_m = math.fabs(d) [d_m, h, l, M, D] = sort([d_m, h, l, M, D]) def code(d_m, h, l, M, D): t_0 = d_m * math.sqrt(((1.0 / l) / h)) tmp = 0 if (M * D) <= 2.15e+173: tmp = t_0 * 1.0 else: tmp = -1.0 * t_0 return tmp
d_m = abs(d) d_m, h, l, M, D = sort([d_m, h, l, M, D]) function code(d_m, h, l, M, D) t_0 = Float64(d_m * sqrt(Float64(Float64(1.0 / l) / h))) tmp = 0.0 if (Float64(M * D) <= 2.15e+173) tmp = Float64(t_0 * 1.0); else tmp = Float64(-1.0 * t_0); end return tmp end
d_m = abs(d);
d_m, h, l, M, D = num2cell(sort([d_m, h, l, M, D])){:}
function tmp_2 = code(d_m, h, l, M, D)
t_0 = d_m * sqrt(((1.0 / l) / h));
tmp = 0.0;
if ((M * D) <= 2.15e+173)
tmp = t_0 * 1.0;
else
tmp = -1.0 * t_0;
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(d$95$m * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(M * D), $MachinePrecision], 2.15e+173], N[(t$95$0 * 1.0), $MachinePrecision], N[(-1.0 * t$95$0), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|
\\
[d_m, h, l, M, D] = \mathsf{sort}([d_m, h, l, M, D])\\
\\
\begin{array}{l}
t_0 := d\_m \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\
\mathbf{if}\;M \cdot D \leq 2.15 \cdot 10^{+173}:\\
\;\;\;\;t\_0 \cdot 1\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot t\_0\\
\end{array}
\end{array}
if (*.f64 M D) < 2.15000000000000013e173Initial program 35.3%
Applied rewrites42.6%
Taylor expanded in d around 0
Applied rewrites69.1%
Applied rewrites69.6%
Taylor expanded in d around inf
Applied rewrites42.5%
if 2.15000000000000013e173 < (*.f64 M D) Initial program 35.3%
Applied rewrites42.6%
Taylor expanded in d around -inf
Applied rewrites10.4%
Applied rewrites10.4%
d_m = (fabs.f64 d) NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function. (FPCore (d_m h l M D) :precision binary64 (if (<= (* M D) 2.15e+173) (* (* d_m (sqrt (/ 1.0 (* h l)))) 1.0) (* -1.0 (* d_m (sqrt (/ (/ 1.0 l) h))))))
d_m = fabs(d);
assert(d_m < h && h < l && l < M && M < D);
double code(double d_m, double h, double l, double M, double D) {
double tmp;
if ((M * D) <= 2.15e+173) {
tmp = (d_m * sqrt((1.0 / (h * l)))) * 1.0;
} else {
tmp = -1.0 * (d_m * sqrt(((1.0 / l) / h)));
}
return tmp;
}
d_m = private
NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m, d)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8) :: tmp
if ((m * d) <= 2.15d+173) then
tmp = (d_m * sqrt((1.0d0 / (h * l)))) * 1.0d0
else
tmp = (-1.0d0) * (d_m * sqrt(((1.0d0 / l) / h)))
end if
code = tmp
end function
d_m = Math.abs(d);
assert d_m < h && h < l && l < M && M < D;
public static double code(double d_m, double h, double l, double M, double D) {
double tmp;
if ((M * D) <= 2.15e+173) {
tmp = (d_m * Math.sqrt((1.0 / (h * l)))) * 1.0;
} else {
tmp = -1.0 * (d_m * Math.sqrt(((1.0 / l) / h)));
}
return tmp;
}
d_m = math.fabs(d) [d_m, h, l, M, D] = sort([d_m, h, l, M, D]) def code(d_m, h, l, M, D): tmp = 0 if (M * D) <= 2.15e+173: tmp = (d_m * math.sqrt((1.0 / (h * l)))) * 1.0 else: tmp = -1.0 * (d_m * math.sqrt(((1.0 / l) / h))) return tmp
d_m = abs(d) d_m, h, l, M, D = sort([d_m, h, l, M, D]) function code(d_m, h, l, M, D) tmp = 0.0 if (Float64(M * D) <= 2.15e+173) tmp = Float64(Float64(d_m * sqrt(Float64(1.0 / Float64(h * l)))) * 1.0); else tmp = Float64(-1.0 * Float64(d_m * sqrt(Float64(Float64(1.0 / l) / h)))); end return tmp end
d_m = abs(d);
d_m, h, l, M, D = num2cell(sort([d_m, h, l, M, D])){:}
function tmp_2 = code(d_m, h, l, M, D)
tmp = 0.0;
if ((M * D) <= 2.15e+173)
tmp = (d_m * sqrt((1.0 / (h * l)))) * 1.0;
else
tmp = -1.0 * (d_m * sqrt(((1.0 / l) / h)));
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision] NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function. code[d$95$m_, h_, l_, M_, D_] := If[LessEqual[N[(M * D), $MachinePrecision], 2.15e+173], N[(N[(d$95$m * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], N[(-1.0 * N[(d$95$m * N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|
\\
[d_m, h, l, M, D] = \mathsf{sort}([d_m, h, l, M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;M \cdot D \leq 2.15 \cdot 10^{+173}:\\
\;\;\;\;\left(d\_m \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \left(d\_m \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\
\end{array}
\end{array}
if (*.f64 M D) < 2.15000000000000013e173Initial program 35.3%
Applied rewrites42.6%
Taylor expanded in d around 0
Applied rewrites69.1%
Taylor expanded in d around inf
Applied rewrites42.2%
if 2.15000000000000013e173 < (*.f64 M D) Initial program 35.3%
Applied rewrites42.6%
Taylor expanded in d around -inf
Applied rewrites10.4%
Applied rewrites10.4%
d_m = (fabs.f64 d) NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function. (FPCore (d_m h l M D) :precision binary64 (let* ((t_0 (sqrt (/ 1.0 (* h l))))) (if (<= (* M D) 2.15e+173) (* (* d_m t_0) 1.0) (* t_0 (- d_m)))))
d_m = fabs(d);
assert(d_m < h && h < l && l < M && M < D);
double code(double d_m, double h, double l, double M, double D) {
double t_0 = sqrt((1.0 / (h * l)));
double tmp;
if ((M * D) <= 2.15e+173) {
tmp = (d_m * t_0) * 1.0;
} else {
tmp = t_0 * -d_m;
}
return tmp;
}
d_m = private
NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m, d)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((1.0d0 / (h * l)))
if ((m * d) <= 2.15d+173) then
tmp = (d_m * t_0) * 1.0d0
else
tmp = t_0 * -d_m
end if
code = tmp
end function
d_m = Math.abs(d);
assert d_m < h && h < l && l < M && M < D;
public static double code(double d_m, double h, double l, double M, double D) {
double t_0 = Math.sqrt((1.0 / (h * l)));
double tmp;
if ((M * D) <= 2.15e+173) {
tmp = (d_m * t_0) * 1.0;
} else {
tmp = t_0 * -d_m;
}
return tmp;
}
d_m = math.fabs(d) [d_m, h, l, M, D] = sort([d_m, h, l, M, D]) def code(d_m, h, l, M, D): t_0 = math.sqrt((1.0 / (h * l))) tmp = 0 if (M * D) <= 2.15e+173: tmp = (d_m * t_0) * 1.0 else: tmp = t_0 * -d_m return tmp
d_m = abs(d) d_m, h, l, M, D = sort([d_m, h, l, M, D]) function code(d_m, h, l, M, D) t_0 = sqrt(Float64(1.0 / Float64(h * l))) tmp = 0.0 if (Float64(M * D) <= 2.15e+173) tmp = Float64(Float64(d_m * t_0) * 1.0); else tmp = Float64(t_0 * Float64(-d_m)); end return tmp end
d_m = abs(d);
d_m, h, l, M, D = num2cell(sort([d_m, h, l, M, D])){:}
function tmp_2 = code(d_m, h, l, M, D)
t_0 = sqrt((1.0 / (h * l)));
tmp = 0.0;
if ((M * D) <= 2.15e+173)
tmp = (d_m * t_0) * 1.0;
else
tmp = t_0 * -d_m;
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(M * D), $MachinePrecision], 2.15e+173], N[(N[(d$95$m * t$95$0), $MachinePrecision] * 1.0), $MachinePrecision], N[(t$95$0 * (-d$95$m)), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|
\\
[d_m, h, l, M, D] = \mathsf{sort}([d_m, h, l, M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{1}{h \cdot \ell}}\\
\mathbf{if}\;M \cdot D \leq 2.15 \cdot 10^{+173}:\\
\;\;\;\;\left(d\_m \cdot t\_0\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(-d\_m\right)\\
\end{array}
\end{array}
if (*.f64 M D) < 2.15000000000000013e173Initial program 35.3%
Applied rewrites42.6%
Taylor expanded in d around 0
Applied rewrites69.1%
Taylor expanded in d around inf
Applied rewrites42.2%
if 2.15000000000000013e173 < (*.f64 M D) Initial program 35.3%
Applied rewrites42.6%
Taylor expanded in d around -inf
Applied rewrites10.4%
Applied rewrites10.4%
d_m = (fabs.f64 d)
NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d_m h l M D)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d_m)) 2.0)) (/ h l)))))
(t_1 (* (sqrt (/ 1.0 (* h l))) (- d_m))))
(if (<= t_0 -2e-117)
t_1
(if (<= t_0 INFINITY) (/ (* d_m (sqrt (/ l h))) l) t_1))))d_m = fabs(d);
assert(d_m < h && h < l && l < M && M < D);
double code(double d_m, double h, double l, double M, double D) {
double t_0 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
double t_1 = sqrt((1.0 / (h * l))) * -d_m;
double tmp;
if (t_0 <= -2e-117) {
tmp = t_1;
} else if (t_0 <= ((double) INFINITY)) {
tmp = (d_m * sqrt((l / h))) / l;
} else {
tmp = t_1;
}
return tmp;
}
d_m = Math.abs(d);
assert d_m < h && h < l && l < M && M < D;
public static double code(double d_m, double h, double l, double M, double D) {
double t_0 = (Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
double t_1 = Math.sqrt((1.0 / (h * l))) * -d_m;
double tmp;
if (t_0 <= -2e-117) {
tmp = t_1;
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = (d_m * Math.sqrt((l / h))) / l;
} else {
tmp = t_1;
}
return tmp;
}
d_m = math.fabs(d) [d_m, h, l, M, D] = sort([d_m, h, l, M, D]) def code(d_m, h, l, M, D): t_0 = (math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l))) t_1 = math.sqrt((1.0 / (h * l))) * -d_m tmp = 0 if t_0 <= -2e-117: tmp = t_1 elif t_0 <= math.inf: tmp = (d_m * math.sqrt((l / h))) / l else: tmp = t_1 return tmp
d_m = abs(d) d_m, h, l, M, D = sort([d_m, h, l, M, D]) function code(d_m, h, l, M, D) t_0 = Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(sqrt(Float64(1.0 / Float64(h * l))) * Float64(-d_m)) tmp = 0.0 if (t_0 <= -2e-117) tmp = t_1; elseif (t_0 <= Inf) tmp = Float64(Float64(d_m * sqrt(Float64(l / h))) / l); else tmp = t_1; end return tmp end
d_m = abs(d);
d_m, h, l, M, D = num2cell(sort([d_m, h, l, M, D])){:}
function tmp_2 = code(d_m, h, l, M, D)
t_0 = (((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d_m)) ^ 2.0)) * (h / l)));
t_1 = sqrt((1.0 / (h * l))) * -d_m;
tmp = 0.0;
if (t_0 <= -2e-117)
tmp = t_1;
elseif (t_0 <= Inf)
tmp = (d_m * sqrt((l / h))) / l;
else
tmp = t_1;
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / 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$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-d$95$m)), $MachinePrecision]}, If[LessEqual[t$95$0, -2e-117], t$95$1, If[LessEqual[t$95$0, Infinity], N[(N[(d$95$m * N[Sqrt[N[(l / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
[d_m, h, l, M, D] = \mathsf{sort}([d_m, h, l, M, D])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \sqrt{\frac{1}{h \cdot \ell}} \cdot \left(-d\_m\right)\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-117}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{d\_m \cdot \sqrt{\frac{\ell}{h}}}{\ell}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -2.00000000000000006e-117 or +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 35.3%
Applied rewrites42.6%
Taylor expanded in d around -inf
Applied rewrites10.4%
Applied rewrites10.4%
if -2.00000000000000006e-117 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 35.3%
Applied rewrites31.1%
Taylor expanded in d around inf
Applied rewrites36.9%
Taylor expanded in l around 0
Applied rewrites21.2%
d_m = (fabs.f64 d) NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function. (FPCore (d_m h l M D) :precision binary64 (/ (* d_m (sqrt (/ l h))) l))
d_m = fabs(d);
assert(d_m < h && h < l && l < M && M < D);
double code(double d_m, double h, double l, double M, double D) {
return (d_m * sqrt((l / h))) / l;
}
d_m = private
NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m, d)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d
code = (d_m * sqrt((l / h))) / l
end function
d_m = Math.abs(d);
assert d_m < h && h < l && l < M && M < D;
public static double code(double d_m, double h, double l, double M, double D) {
return (d_m * Math.sqrt((l / h))) / l;
}
d_m = math.fabs(d) [d_m, h, l, M, D] = sort([d_m, h, l, M, D]) def code(d_m, h, l, M, D): return (d_m * math.sqrt((l / h))) / l
d_m = abs(d) d_m, h, l, M, D = sort([d_m, h, l, M, D]) function code(d_m, h, l, M, D) return Float64(Float64(d_m * sqrt(Float64(l / h))) / l) end
d_m = abs(d);
d_m, h, l, M, D = num2cell(sort([d_m, h, l, M, D])){:}
function tmp = code(d_m, h, l, M, D)
tmp = (d_m * sqrt((l / h))) / l;
end
d_m = N[Abs[d], $MachinePrecision] NOTE: d_m, h, l, M, and D should be sorted in increasing order before calling this function. code[d$95$m_, h_, l_, M_, D_] := N[(N[(d$95$m * N[Sqrt[N[(l / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]
\begin{array}{l}
d_m = \left|d\right|
\\
[d_m, h, l, M, D] = \mathsf{sort}([d_m, h, l, M, D])\\
\\
\frac{d\_m \cdot \sqrt{\frac{\ell}{h}}}{\ell}
\end{array}
Initial program 35.3%
Applied rewrites31.1%
Taylor expanded in d around inf
Applied rewrites36.9%
Taylor expanded in l around 0
Applied rewrites21.2%
herbie shell --seed 2025161
(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)))))