
(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 19 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}
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (* M (/ D (+ d d))))
(t_1 (- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l))))
(if (<= l -5e-311)
(* (* d (- (sqrt (/ 1.0 (* l h))))) t_1)
(* (/ (* (sqrt d) (sqrt (/ d l))) (sqrt h)) t_1))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = M * (D / (d + d));
double t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l);
double tmp;
if (l <= -5e-311) {
tmp = (d * -sqrt((1.0 / (l * h)))) * t_1;
} else {
tmp = ((sqrt(d) * sqrt((d / l))) / sqrt(h)) * t_1;
}
return tmp;
}
NOTE: d, 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, 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
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = m * (d_1 / (d + d))
t_1 = 1.0d0 - ((((t_0 * t_0) * 0.5d0) * h) / l)
if (l <= (-5d-311)) then
tmp = (d * -sqrt((1.0d0 / (l * h)))) * t_1
else
tmp = ((sqrt(d) * sqrt((d / l))) / sqrt(h)) * t_1
end if
code = tmp
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
double t_0 = M * (D / (d + d));
double t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l);
double tmp;
if (l <= -5e-311) {
tmp = (d * -Math.sqrt((1.0 / (l * h)))) * t_1;
} else {
tmp = ((Math.sqrt(d) * Math.sqrt((d / l))) / Math.sqrt(h)) * t_1;
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): t_0 = M * (D / (d + d)) t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l) tmp = 0 if l <= -5e-311: tmp = (d * -math.sqrt((1.0 / (l * h)))) * t_1 else: tmp = ((math.sqrt(d) * math.sqrt((d / l))) / math.sqrt(h)) * t_1 return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) t_0 = Float64(M * Float64(D / Float64(d + d))) t_1 = Float64(1.0 - Float64(Float64(Float64(Float64(t_0 * t_0) * 0.5) * h) / l)) tmp = 0.0 if (l <= -5e-311) tmp = Float64(Float64(d * Float64(-sqrt(Float64(1.0 / Float64(l * h))))) * t_1); else tmp = Float64(Float64(Float64(sqrt(d) * sqrt(Float64(d / l))) / sqrt(h)) * t_1); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
t_0 = M * (D / (d + d));
t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l);
tmp = 0.0;
if (l <= -5e-311)
tmp = (d * -sqrt((1.0 / (l * h)))) * t_1;
else
tmp = ((sqrt(d) * sqrt((d / l))) / sqrt(h)) * t_1;
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(M * N[(D / N[(d + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -5e-311], N[(N[(d * (-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
t_0 := M \cdot \frac{D}{d + d}\\
t_1 := 1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\\
\mathbf{if}\;\ell \leq -5 \cdot 10^{-311}:\\
\;\;\;\;\left(d \cdot \left(-\sqrt{\frac{1}{\ell \cdot h}}\right)\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{d} \cdot \sqrt{\frac{d}{\ell}}}{\sqrt{h}} \cdot t\_1\\
\end{array}
\end{array}
if l < -5.00000000000023e-311Initial program 66.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 rewrites67.8%
Taylor expanded in h around -inf
metadata-evalN/A
pow1/2N/A
sqrt-divN/A
metadata-evalN/A
metadata-evalN/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6473.3
Applied rewrites73.3%
if -5.00000000000023e-311 < l Initial program 67.7%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites68.4%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
pow1/2N/A
sqrt-divN/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-sqrt.f6478.2
Applied rewrites78.2%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (* M (/ D (+ d d))))
(t_1 (- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l)))
(t_2 (* d (- (sqrt (/ 1.0 (* l h)))))))
(if (<= l -5e-311) (* t_2 t_1) (* (- t_2) t_1))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = M * (D / (d + d));
double t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l);
double t_2 = d * -sqrt((1.0 / (l * h)));
double tmp;
if (l <= -5e-311) {
tmp = t_2 * t_1;
} else {
tmp = -t_2 * t_1;
}
return tmp;
}
NOTE: d, 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, 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
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = m * (d_1 / (d + d))
t_1 = 1.0d0 - ((((t_0 * t_0) * 0.5d0) * h) / l)
t_2 = d * -sqrt((1.0d0 / (l * h)))
if (l <= (-5d-311)) then
tmp = t_2 * t_1
else
tmp = -t_2 * t_1
end if
code = tmp
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
double t_0 = M * (D / (d + d));
double t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l);
double t_2 = d * -Math.sqrt((1.0 / (l * h)));
double tmp;
if (l <= -5e-311) {
tmp = t_2 * t_1;
} else {
tmp = -t_2 * t_1;
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): t_0 = M * (D / (d + d)) t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l) t_2 = d * -math.sqrt((1.0 / (l * h))) tmp = 0 if l <= -5e-311: tmp = t_2 * t_1 else: tmp = -t_2 * t_1 return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) t_0 = Float64(M * Float64(D / Float64(d + d))) t_1 = Float64(1.0 - Float64(Float64(Float64(Float64(t_0 * t_0) * 0.5) * h) / l)) t_2 = Float64(d * Float64(-sqrt(Float64(1.0 / Float64(l * h))))) tmp = 0.0 if (l <= -5e-311) tmp = Float64(t_2 * t_1); else tmp = Float64(Float64(-t_2) * t_1); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
t_0 = M * (D / (d + d));
t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l);
t_2 = d * -sqrt((1.0 / (l * h)));
tmp = 0.0;
if (l <= -5e-311)
tmp = t_2 * t_1;
else
tmp = -t_2 * t_1;
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(M * N[(D / N[(d + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(d * (-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]}, If[LessEqual[l, -5e-311], N[(t$95$2 * t$95$1), $MachinePrecision], N[((-t$95$2) * t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
t_0 := M \cdot \frac{D}{d + d}\\
t_1 := 1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\\
t_2 := d \cdot \left(-\sqrt{\frac{1}{\ell \cdot h}}\right)\\
\mathbf{if}\;\ell \leq -5 \cdot 10^{-311}:\\
\;\;\;\;t\_2 \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(-t\_2\right) \cdot t\_1\\
\end{array}
\end{array}
if l < -5.00000000000023e-311Initial program 66.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 rewrites67.8%
Taylor expanded in h around -inf
metadata-evalN/A
pow1/2N/A
sqrt-divN/A
metadata-evalN/A
metadata-evalN/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6473.3
Applied rewrites73.3%
if -5.00000000000023e-311 < l Initial program 67.7%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites68.4%
Taylor expanded in d around -inf
metadata-evalN/A
pow1/2N/A
sqrt-divN/A
metadata-evalN/A
metadata-evalN/A
mul-1-negN/A
lower-neg.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
Applied rewrites73.9%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (/ D (+ d d)))
(t_1 (* M t_0))
(t_2 (- 1.0 (/ (* (* (* t_1 t_1) 0.5) h) l)))
(t_3 (sqrt (/ 1.0 (* l h)))))
(if (<= l -7.2e-245)
(* (* d (- t_3)) t_2)
(if (<= l 4.5e-244)
(* (sqrt (* (/ d l) (/ d h))) t_2)
(* (- 1.0 (* (* 0.5 (* M (* t_0 (* t_0 M)))) (/ h l))) (* t_3 d))))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = D / (d + d);
double t_1 = M * t_0;
double t_2 = 1.0 - ((((t_1 * t_1) * 0.5) * h) / l);
double t_3 = sqrt((1.0 / (l * h)));
double tmp;
if (l <= -7.2e-245) {
tmp = (d * -t_3) * t_2;
} else if (l <= 4.5e-244) {
tmp = sqrt(((d / l) * (d / h))) * t_2;
} else {
tmp = (1.0 - ((0.5 * (M * (t_0 * (t_0 * M)))) * (h / l))) * (t_3 * d);
}
return tmp;
}
NOTE: d, 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, 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
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = d_1 / (d + d)
t_1 = m * t_0
t_2 = 1.0d0 - ((((t_1 * t_1) * 0.5d0) * h) / l)
t_3 = sqrt((1.0d0 / (l * h)))
if (l <= (-7.2d-245)) then
tmp = (d * -t_3) * t_2
else if (l <= 4.5d-244) then
tmp = sqrt(((d / l) * (d / h))) * t_2
else
tmp = (1.0d0 - ((0.5d0 * (m * (t_0 * (t_0 * m)))) * (h / l))) * (t_3 * d)
end if
code = tmp
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
double t_0 = D / (d + d);
double t_1 = M * t_0;
double t_2 = 1.0 - ((((t_1 * t_1) * 0.5) * h) / l);
double t_3 = Math.sqrt((1.0 / (l * h)));
double tmp;
if (l <= -7.2e-245) {
tmp = (d * -t_3) * t_2;
} else if (l <= 4.5e-244) {
tmp = Math.sqrt(((d / l) * (d / h))) * t_2;
} else {
tmp = (1.0 - ((0.5 * (M * (t_0 * (t_0 * M)))) * (h / l))) * (t_3 * d);
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): t_0 = D / (d + d) t_1 = M * t_0 t_2 = 1.0 - ((((t_1 * t_1) * 0.5) * h) / l) t_3 = math.sqrt((1.0 / (l * h))) tmp = 0 if l <= -7.2e-245: tmp = (d * -t_3) * t_2 elif l <= 4.5e-244: tmp = math.sqrt(((d / l) * (d / h))) * t_2 else: tmp = (1.0 - ((0.5 * (M * (t_0 * (t_0 * M)))) * (h / l))) * (t_3 * d) return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) t_0 = Float64(D / Float64(d + d)) t_1 = Float64(M * t_0) t_2 = Float64(1.0 - Float64(Float64(Float64(Float64(t_1 * t_1) * 0.5) * h) / l)) t_3 = sqrt(Float64(1.0 / Float64(l * h))) tmp = 0.0 if (l <= -7.2e-245) tmp = Float64(Float64(d * Float64(-t_3)) * t_2); elseif (l <= 4.5e-244) tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * t_2); else tmp = Float64(Float64(1.0 - Float64(Float64(0.5 * Float64(M * Float64(t_0 * Float64(t_0 * M)))) * Float64(h / l))) * Float64(t_3 * d)); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
t_0 = D / (d + d);
t_1 = M * t_0;
t_2 = 1.0 - ((((t_1 * t_1) * 0.5) * h) / l);
t_3 = sqrt((1.0 / (l * h)));
tmp = 0.0;
if (l <= -7.2e-245)
tmp = (d * -t_3) * t_2;
elseif (l <= 4.5e-244)
tmp = sqrt(((d / l) * (d / h))) * t_2;
else
tmp = (1.0 - ((0.5 * (M * (t_0 * (t_0 * M)))) * (h / l))) * (t_3 * d);
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(D / N[(d + d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(M * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - N[(N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -7.2e-245], N[(N[(d * (-t$95$3)), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[l, 4.5e-244], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$2), $MachinePrecision], N[(N[(1.0 - N[(N[(0.5 * N[(M * N[(t$95$0 * N[(t$95$0 * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(t$95$3 * d), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
t_0 := \frac{D}{d + d}\\
t_1 := M \cdot t\_0\\
t_2 := 1 - \frac{\left(\left(t\_1 \cdot t\_1\right) \cdot 0.5\right) \cdot h}{\ell}\\
t_3 := \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{if}\;\ell \leq -7.2 \cdot 10^{-245}:\\
\;\;\;\;\left(d \cdot \left(-t\_3\right)\right) \cdot t\_2\\
\mathbf{elif}\;\ell \leq 4.5 \cdot 10^{-244}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot t\_2\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \left(0.5 \cdot \left(M \cdot \left(t\_0 \cdot \left(t\_0 \cdot M\right)\right)\right)\right) \cdot \frac{h}{\ell}\right) \cdot \left(t\_3 \cdot d\right)\\
\end{array}
\end{array}
if l < -7.19999999999999999e-245Initial program 66.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.7%
Taylor expanded in h around -inf
metadata-evalN/A
pow1/2N/A
sqrt-divN/A
metadata-evalN/A
metadata-evalN/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6472.1
Applied rewrites72.1%
if -7.19999999999999999e-245 < l < 4.5000000000000002e-244Initial program 74.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 rewrites80.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-/.f6480.3
Applied rewrites80.3%
lift-*.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6477.7
Applied rewrites77.7%
if 4.5000000000000002e-244 < l Initial program 66.6%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6469.7
Applied rewrites69.7%
Applied rewrites68.3%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (/ D (+ d d))) (t_1 (* t_0 (* t_0 M))))
(if (<= l -1.35e-142)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (/ (* (* (* (/ (* (* M M) D) d) (/ D d)) 0.125) h) l)))
(if (<= l 4.5e-244)
(* (- 1.0 (/ (* (* (* t_1 M) 0.5) h) l)) (sqrt (* (/ d l) (/ d h))))
(*
(- 1.0 (* (* 0.5 (* M t_1)) (/ h l)))
(* (sqrt (/ 1.0 (* l h))) d))))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = D / (d + d);
double t_1 = t_0 * (t_0 * M);
double tmp;
if (l <= -1.35e-142) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (((((((M * M) * D) / d) * (D / d)) * 0.125) * h) / l));
} else if (l <= 4.5e-244) {
tmp = (1.0 - ((((t_1 * M) * 0.5) * h) / l)) * sqrt(((d / l) * (d / h)));
} else {
tmp = (1.0 - ((0.5 * (M * t_1)) * (h / l))) * (sqrt((1.0 / (l * h))) * d);
}
return tmp;
}
NOTE: d, 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, 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
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = d_1 / (d + d)
t_1 = t_0 * (t_0 * m)
if (l <= (-1.35d-142)) then
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0d0 - (((((((m * m) * d_1) / d) * (d_1 / d)) * 0.125d0) * h) / l))
else if (l <= 4.5d-244) then
tmp = (1.0d0 - ((((t_1 * m) * 0.5d0) * h) / l)) * sqrt(((d / l) * (d / h)))
else
tmp = (1.0d0 - ((0.5d0 * (m * t_1)) * (h / l))) * (sqrt((1.0d0 / (l * h))) * d)
end if
code = tmp
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
double t_0 = D / (d + d);
double t_1 = t_0 * (t_0 * M);
double tmp;
if (l <= -1.35e-142) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * (1.0 - (((((((M * M) * D) / d) * (D / d)) * 0.125) * h) / l));
} else if (l <= 4.5e-244) {
tmp = (1.0 - ((((t_1 * M) * 0.5) * h) / l)) * Math.sqrt(((d / l) * (d / h)));
} else {
tmp = (1.0 - ((0.5 * (M * t_1)) * (h / l))) * (Math.sqrt((1.0 / (l * h))) * d);
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): t_0 = D / (d + d) t_1 = t_0 * (t_0 * M) tmp = 0 if l <= -1.35e-142: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * (1.0 - (((((((M * M) * D) / d) * (D / d)) * 0.125) * h) / l)) elif l <= 4.5e-244: tmp = (1.0 - ((((t_1 * M) * 0.5) * h) / l)) * math.sqrt(((d / l) * (d / h))) else: tmp = (1.0 - ((0.5 * (M * t_1)) * (h / l))) * (math.sqrt((1.0 / (l * h))) * d) return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) t_0 = Float64(D / Float64(d + d)) t_1 = Float64(t_0 * Float64(t_0 * M)) tmp = 0.0 if (l <= -1.35e-142) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64(Float64(Float64(Float64(Float64(M * M) * D) / d) * Float64(D / d)) * 0.125) * h) / l))); elseif (l <= 4.5e-244) tmp = Float64(Float64(1.0 - Float64(Float64(Float64(Float64(t_1 * M) * 0.5) * h) / l)) * sqrt(Float64(Float64(d / l) * Float64(d / h)))); else tmp = Float64(Float64(1.0 - Float64(Float64(0.5 * Float64(M * t_1)) * Float64(h / l))) * Float64(sqrt(Float64(1.0 / Float64(l * h))) * d)); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
t_0 = D / (d + d);
t_1 = t_0 * (t_0 * M);
tmp = 0.0;
if (l <= -1.35e-142)
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (((((((M * M) * D) / d) * (D / d)) * 0.125) * h) / l));
elseif (l <= 4.5e-244)
tmp = (1.0 - ((((t_1 * M) * 0.5) * h) / l)) * sqrt(((d / l) * (d / h)));
else
tmp = (1.0 - ((0.5 * (M * t_1)) * (h / l))) * (sqrt((1.0 / (l * h))) * d);
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(D / N[(d + d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(t$95$0 * M), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.35e-142], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(N[(N[(N[(M * M), $MachinePrecision] * D), $MachinePrecision] / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 4.5e-244], N[(N[(1.0 - N[(N[(N[(N[(t$95$1 * M), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(N[(0.5 * N[(M * t$95$1), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
t_0 := \frac{D}{d + d}\\
t_1 := t\_0 \cdot \left(t\_0 \cdot M\right)\\
\mathbf{if}\;\ell \leq -1.35 \cdot 10^{-142}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \frac{\left(\left(\frac{\left(M \cdot M\right) \cdot D}{d} \cdot \frac{D}{d}\right) \cdot 0.125\right) \cdot h}{\ell}\right)\\
\mathbf{elif}\;\ell \leq 4.5 \cdot 10^{-244}:\\
\;\;\;\;\left(1 - \frac{\left(\left(t\_1 \cdot M\right) \cdot 0.5\right) \cdot h}{\ell}\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \left(0.5 \cdot \left(M \cdot t\_1\right)\right) \cdot \frac{h}{\ell}\right) \cdot \left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\right)\\
\end{array}
\end{array}
if l < -1.3499999999999999e-142Initial program 64.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 rewrites64.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-/.f6464.4
Applied rewrites64.4%
Taylor expanded in d around 0
Applied rewrites47.6%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lower-/.f6456.9
Applied rewrites56.9%
if -1.3499999999999999e-142 < l < 4.5000000000000002e-244Initial program 74.1%
Applied rewrites73.6%
lift-*.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6469.4
Applied rewrites69.4%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lift-/.f64N/A
associate-/l*N/A
lower-/.f64N/A
Applied rewrites73.2%
if 4.5000000000000002e-244 < l Initial program 66.6%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6469.7
Applied rewrites69.7%
Applied rewrites68.3%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (* (sqrt (/ d l)) (sqrt (/ d h)))))
(if (<= (* M D) 5e-114)
(* t_0 1.0)
(if (<= (* M D) 1.09e+109)
(* t_0 (- 1.0 (/ (* (* (/ (* (* D M) (* D M)) (* d d)) 0.125) h) l)))
(*
t_0
(- 1.0 (/ (* (* (* (/ (* (* M M) D) d) (/ D d)) 0.125) h) l)))))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = sqrt((d / l)) * sqrt((d / h));
double tmp;
if ((M * D) <= 5e-114) {
tmp = t_0 * 1.0;
} else if ((M * D) <= 1.09e+109) {
tmp = t_0 * (1.0 - ((((((D * M) * (D * M)) / (d * d)) * 0.125) * h) / l));
} else {
tmp = t_0 * (1.0 - (((((((M * M) * D) / d) * (D / d)) * 0.125) * h) / l));
}
return tmp;
}
NOTE: d, 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, 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
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((d / l)) * sqrt((d / h))
if ((m * d_1) <= 5d-114) then
tmp = t_0 * 1.0d0
else if ((m * d_1) <= 1.09d+109) then
tmp = t_0 * (1.0d0 - ((((((d_1 * m) * (d_1 * m)) / (d * d)) * 0.125d0) * h) / l))
else
tmp = t_0 * (1.0d0 - (((((((m * m) * d_1) / d) * (d_1 / d)) * 0.125d0) * h) / l))
end if
code = tmp
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
double t_0 = Math.sqrt((d / l)) * Math.sqrt((d / h));
double tmp;
if ((M * D) <= 5e-114) {
tmp = t_0 * 1.0;
} else if ((M * D) <= 1.09e+109) {
tmp = t_0 * (1.0 - ((((((D * M) * (D * M)) / (d * d)) * 0.125) * h) / l));
} else {
tmp = t_0 * (1.0 - (((((((M * M) * D) / d) * (D / d)) * 0.125) * h) / l));
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): t_0 = math.sqrt((d / l)) * math.sqrt((d / h)) tmp = 0 if (M * D) <= 5e-114: tmp = t_0 * 1.0 elif (M * D) <= 1.09e+109: tmp = t_0 * (1.0 - ((((((D * M) * (D * M)) / (d * d)) * 0.125) * h) / l)) else: tmp = t_0 * (1.0 - (((((((M * M) * D) / d) * (D / d)) * 0.125) * h) / l)) return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) t_0 = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) tmp = 0.0 if (Float64(M * D) <= 5e-114) tmp = Float64(t_0 * 1.0); elseif (Float64(M * D) <= 1.09e+109) tmp = Float64(t_0 * Float64(1.0 - Float64(Float64(Float64(Float64(Float64(Float64(D * M) * Float64(D * M)) / Float64(d * d)) * 0.125) * h) / l))); else tmp = Float64(t_0 * Float64(1.0 - Float64(Float64(Float64(Float64(Float64(Float64(Float64(M * M) * D) / d) * Float64(D / d)) * 0.125) * h) / l))); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
t_0 = sqrt((d / l)) * sqrt((d / h));
tmp = 0.0;
if ((M * D) <= 5e-114)
tmp = t_0 * 1.0;
elseif ((M * D) <= 1.09e+109)
tmp = t_0 * (1.0 - ((((((D * M) * (D * M)) / (d * d)) * 0.125) * h) / l));
else
tmp = t_0 * (1.0 - (((((((M * M) * D) / d) * (D / d)) * 0.125) * h) / l));
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(M * D), $MachinePrecision], 5e-114], N[(t$95$0 * 1.0), $MachinePrecision], If[LessEqual[N[(M * D), $MachinePrecision], 1.09e+109], N[(t$95$0 * N[(1.0 - N[(N[(N[(N[(N[(N[(D * M), $MachinePrecision] * N[(D * M), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(1.0 - N[(N[(N[(N[(N[(N[(N[(M * M), $MachinePrecision] * D), $MachinePrecision] / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{if}\;M \cdot D \leq 5 \cdot 10^{-114}:\\
\;\;\;\;t\_0 \cdot 1\\
\mathbf{elif}\;M \cdot D \leq 1.09 \cdot 10^{+109}:\\
\;\;\;\;t\_0 \cdot \left(1 - \frac{\left(\frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{d \cdot d} \cdot 0.125\right) \cdot h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(1 - \frac{\left(\left(\frac{\left(M \cdot M\right) \cdot D}{d} \cdot \frac{D}{d}\right) \cdot 0.125\right) \cdot h}{\ell}\right)\\
\end{array}
\end{array}
if (*.f64 M D) < 4.99999999999999989e-114Initial program 68.0%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites69.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-/.f6469.5
Applied rewrites69.5%
Taylor expanded in d around inf
Applied rewrites47.1%
if 4.99999999999999989e-114 < (*.f64 M D) < 1.09e109Initial program 64.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 rewrites63.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-/.f6463.6
Applied rewrites63.6%
Taylor expanded in d around 0
Applied rewrites46.1%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
pow2N/A
unswap-sqrN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6462.6
Applied rewrites62.6%
if 1.09e109 < (*.f64 M D) Initial program 66.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 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%
Taylor expanded in d around 0
Applied rewrites46.8%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lower-/.f6462.2
Applied rewrites62.2%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (/ D (+ d d))))
(if (<= l 3.9e-258)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (/ (* (* (* (/ (* (* M M) D) d) (/ D d)) 0.125) h) l)))
(*
(- 1.0 (* (* 0.5 (* M (* t_0 (* t_0 M)))) (/ h l)))
(* (sqrt (/ 1.0 (* l h))) d)))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = D / (d + d);
double tmp;
if (l <= 3.9e-258) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (((((((M * M) * D) / d) * (D / d)) * 0.125) * h) / l));
} else {
tmp = (1.0 - ((0.5 * (M * (t_0 * (t_0 * M)))) * (h / l))) * (sqrt((1.0 / (l * h))) * d);
}
return tmp;
}
NOTE: d, 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, 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
real(8) :: t_0
real(8) :: tmp
t_0 = d_1 / (d + d)
if (l <= 3.9d-258) then
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0d0 - (((((((m * m) * d_1) / d) * (d_1 / d)) * 0.125d0) * h) / l))
else
tmp = (1.0d0 - ((0.5d0 * (m * (t_0 * (t_0 * m)))) * (h / l))) * (sqrt((1.0d0 / (l * h))) * d)
end if
code = tmp
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
double t_0 = D / (d + d);
double tmp;
if (l <= 3.9e-258) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * (1.0 - (((((((M * M) * D) / d) * (D / d)) * 0.125) * h) / l));
} else {
tmp = (1.0 - ((0.5 * (M * (t_0 * (t_0 * M)))) * (h / l))) * (Math.sqrt((1.0 / (l * h))) * d);
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): t_0 = D / (d + d) tmp = 0 if l <= 3.9e-258: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * (1.0 - (((((((M * M) * D) / d) * (D / d)) * 0.125) * h) / l)) else: tmp = (1.0 - ((0.5 * (M * (t_0 * (t_0 * M)))) * (h / l))) * (math.sqrt((1.0 / (l * h))) * d) return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) t_0 = Float64(D / Float64(d + d)) tmp = 0.0 if (l <= 3.9e-258) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64(Float64(Float64(Float64(Float64(M * M) * D) / d) * Float64(D / d)) * 0.125) * h) / l))); else tmp = Float64(Float64(1.0 - Float64(Float64(0.5 * Float64(M * Float64(t_0 * Float64(t_0 * M)))) * Float64(h / l))) * Float64(sqrt(Float64(1.0 / Float64(l * h))) * d)); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
t_0 = D / (d + d);
tmp = 0.0;
if (l <= 3.9e-258)
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (((((((M * M) * D) / d) * (D / d)) * 0.125) * h) / l));
else
tmp = (1.0 - ((0.5 * (M * (t_0 * (t_0 * M)))) * (h / l))) * (sqrt((1.0 / (l * h))) * d);
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(D / N[(d + d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, 3.9e-258], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(N[(N[(N[(M * M), $MachinePrecision] * D), $MachinePrecision] / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(N[(0.5 * N[(M * N[(t$95$0 * N[(t$95$0 * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
t_0 := \frac{D}{d + d}\\
\mathbf{if}\;\ell \leq 3.9 \cdot 10^{-258}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \frac{\left(\left(\frac{\left(M \cdot M\right) \cdot D}{d} \cdot \frac{D}{d}\right) \cdot 0.125\right) \cdot h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \left(0.5 \cdot \left(M \cdot \left(t\_0 \cdot \left(t\_0 \cdot M\right)\right)\right)\right) \cdot \frac{h}{\ell}\right) \cdot \left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\right)\\
\end{array}
\end{array}
if l < 3.90000000000000004e-258Initial program 67.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 rewrites68.8%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6468.8
Applied rewrites68.8%
Taylor expanded in d around 0
Applied rewrites50.4%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lower-/.f6461.1
Applied rewrites61.1%
if 3.90000000000000004e-258 < l Initial program 66.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6469.8
Applied rewrites69.8%
Applied rewrites68.3%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(if (<= l 3.9e-258)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (/ (* (* (* (/ (* (* M M) D) d) (/ D d)) 0.125) h) l)))
(*
(- 1.0 (* (* (* (* (/ (* D M) (+ d d)) (/ D (+ d d))) M) 0.5) (/ h l)))
(* (sqrt (/ 1.0 (* h l))) d))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= 3.9e-258) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (((((((M * M) * D) / d) * (D / d)) * 0.125) * h) / l));
} else {
tmp = (1.0 - ((((((D * M) / (d + d)) * (D / (d + d))) * M) * 0.5) * (h / l))) * (sqrt((1.0 / (h * l))) * d);
}
return tmp;
}
NOTE: d, 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, 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
real(8) :: tmp
if (l <= 3.9d-258) then
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0d0 - (((((((m * m) * d_1) / d) * (d_1 / d)) * 0.125d0) * h) / l))
else
tmp = (1.0d0 - ((((((d_1 * m) / (d + d)) * (d_1 / (d + d))) * m) * 0.5d0) * (h / l))) * (sqrt((1.0d0 / (h * l))) * d)
end if
code = tmp
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= 3.9e-258) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * (1.0 - (((((((M * M) * D) / d) * (D / d)) * 0.125) * h) / l));
} else {
tmp = (1.0 - ((((((D * M) / (d + d)) * (D / (d + d))) * M) * 0.5) * (h / l))) * (Math.sqrt((1.0 / (h * l))) * d);
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): tmp = 0 if l <= 3.9e-258: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * (1.0 - (((((((M * M) * D) / d) * (D / d)) * 0.125) * h) / l)) else: tmp = (1.0 - ((((((D * M) / (d + d)) * (D / (d + d))) * M) * 0.5) * (h / l))) * (math.sqrt((1.0 / (h * l))) * d) return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) tmp = 0.0 if (l <= 3.9e-258) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64(Float64(Float64(Float64(Float64(M * M) * D) / d) * Float64(D / d)) * 0.125) * h) / l))); else tmp = Float64(Float64(1.0 - Float64(Float64(Float64(Float64(Float64(Float64(D * M) / Float64(d + d)) * Float64(D / Float64(d + d))) * M) * 0.5) * Float64(h / l))) * Float64(sqrt(Float64(1.0 / Float64(h * l))) * d)); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
tmp = 0.0;
if (l <= 3.9e-258)
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (((((((M * M) * D) / d) * (D / d)) * 0.125) * h) / l));
else
tmp = (1.0 - ((((((D * M) / (d + d)) * (D / (d + d))) * M) * 0.5) * (h / l))) * (sqrt((1.0 / (h * l))) * d);
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[l, 3.9e-258], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(N[(N[(N[(M * M), $MachinePrecision] * D), $MachinePrecision] / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(N[(N[(N[(N[(N[(D * M), $MachinePrecision] / N[(d + d), $MachinePrecision]), $MachinePrecision] * N[(D / N[(d + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * M), $MachinePrecision] * 0.5), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 3.9 \cdot 10^{-258}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \frac{\left(\left(\frac{\left(M \cdot M\right) \cdot D}{d} \cdot \frac{D}{d}\right) \cdot 0.125\right) \cdot h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \left(\left(\left(\frac{D \cdot M}{d + d} \cdot \frac{D}{d + d}\right) \cdot M\right) \cdot 0.5\right) \cdot \frac{h}{\ell}\right) \cdot \left(\sqrt{\frac{1}{h \cdot \ell}} \cdot d\right)\\
\end{array}
\end{array}
if l < 3.90000000000000004e-258Initial program 67.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 rewrites68.8%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6468.8
Applied rewrites68.8%
Taylor expanded in d around 0
Applied rewrites50.4%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lower-/.f6461.1
Applied rewrites61.1%
if 3.90000000000000004e-258 < l Initial program 66.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6469.8
Applied rewrites69.8%
Applied rewrites68.3%
Applied rewrites67.9%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
: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 D) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1 (* (sqrt (/ d l)) (sqrt (/ d h)))))
(if (<= t_0 -4e-55)
(* t_1 (- 1.0 (/ (* (* (/ (* (* D M) (* D M)) (* d d)) 0.125) h) l)))
(if (<= t_0 1e-209) (* (- (sqrt (/ 1.0 (* l h)))) d) (* t_1 1.0)))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
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 * D) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = sqrt((d / l)) * sqrt((d / h));
double tmp;
if (t_0 <= -4e-55) {
tmp = t_1 * (1.0 - ((((((D * M) * (D * M)) / (d * d)) * 0.125) * h) / l));
} else if (t_0 <= 1e-209) {
tmp = -sqrt((1.0 / (l * h))) * d;
} else {
tmp = t_1 * 1.0;
}
return tmp;
}
NOTE: d, 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, 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
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (((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)))
t_1 = sqrt((d / l)) * sqrt((d / h))
if (t_0 <= (-4d-55)) then
tmp = t_1 * (1.0d0 - ((((((d_1 * m) * (d_1 * m)) / (d * d)) * 0.125d0) * h) / l))
else if (t_0 <= 1d-209) then
tmp = -sqrt((1.0d0 / (l * h))) * d
else
tmp = t_1 * 1.0d0
end if
code = tmp
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
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 * D) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = Math.sqrt((d / l)) * Math.sqrt((d / h));
double tmp;
if (t_0 <= -4e-55) {
tmp = t_1 * (1.0 - ((((((D * M) * (D * M)) / (d * d)) * 0.125) * h) / l));
} else if (t_0 <= 1e-209) {
tmp = -Math.sqrt((1.0 / (l * h))) * d;
} else {
tmp = t_1 * 1.0;
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): 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 * D) / (2.0 * d)), 2.0)) * (h / l))) t_1 = math.sqrt((d / l)) * math.sqrt((d / h)) tmp = 0 if t_0 <= -4e-55: tmp = t_1 * (1.0 - ((((((D * M) * (D * M)) / (d * d)) * 0.125) * h) / l)) elif t_0 <= 1e-209: tmp = -math.sqrt((1.0 / (l * h))) * d else: tmp = t_1 * 1.0 return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) 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 * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) tmp = 0.0 if (t_0 <= -4e-55) tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(Float64(Float64(Float64(Float64(D * M) * Float64(D * M)) / Float64(d * d)) * 0.125) * h) / l))); elseif (t_0 <= 1e-209) tmp = Float64(Float64(-sqrt(Float64(1.0 / Float64(l * h)))) * d); else tmp = Float64(t_1 * 1.0); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
t_0 = (((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)));
t_1 = sqrt((d / l)) * sqrt((d / h));
tmp = 0.0;
if (t_0 <= -4e-55)
tmp = t_1 * (1.0 - ((((((D * M) * (D * M)) / (d * d)) * 0.125) * h) / l));
elseif (t_0 <= 1e-209)
tmp = -sqrt((1.0 / (l * h))) * d;
else
tmp = t_1 * 1.0;
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := 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 * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -4e-55], N[(t$95$1 * N[(1.0 - N[(N[(N[(N[(N[(N[(D * M), $MachinePrecision] * N[(D * M), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e-209], N[((-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * d), $MachinePrecision], N[(t$95$1 * 1.0), $MachinePrecision]]]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\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 \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{-55}:\\
\;\;\;\;t\_1 \cdot \left(1 - \frac{\left(\frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{d \cdot d} \cdot 0.125\right) \cdot h}{\ell}\right)\\
\mathbf{elif}\;t\_0 \leq 10^{-209}:\\
\;\;\;\;\left(-\sqrt{\frac{1}{\ell \cdot h}}\right) \cdot d\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot 1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -3.99999999999999998e-55Initial program 85.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 rewrites83.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-/.f6483.4
Applied rewrites83.4%
Taylor expanded in d around 0
Applied rewrites58.2%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
pow2N/A
unswap-sqrN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6465.2
Applied rewrites65.2%
if -3.99999999999999998e-55 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 1e-209Initial program 52.8%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6441.9
Applied rewrites41.9%
Taylor expanded in h around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6446.9
Applied rewrites46.9%
if 1e-209 < (*.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 58.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 rewrites61.8%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6461.8
Applied rewrites61.8%
Taylor expanded in d around inf
Applied rewrites61.6%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
: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 D) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1 (* (sqrt (/ d l)) (sqrt (/ d h)))))
(if (<= t_0 -100000000000.0)
(* t_1 (- 1.0 (* (* (* (* (* M M) D) (/ D (* d d))) 0.125) (/ h l))))
(if (<= t_0 1e-209) (* (- (sqrt (/ 1.0 (* l h)))) d) (* t_1 1.0)))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
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 * D) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = sqrt((d / l)) * sqrt((d / h));
double tmp;
if (t_0 <= -100000000000.0) {
tmp = t_1 * (1.0 - (((((M * M) * D) * (D / (d * d))) * 0.125) * (h / l)));
} else if (t_0 <= 1e-209) {
tmp = -sqrt((1.0 / (l * h))) * d;
} else {
tmp = t_1 * 1.0;
}
return tmp;
}
NOTE: d, 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, 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
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (((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)))
t_1 = sqrt((d / l)) * sqrt((d / h))
if (t_0 <= (-100000000000.0d0)) then
tmp = t_1 * (1.0d0 - (((((m * m) * d_1) * (d_1 / (d * d))) * 0.125d0) * (h / l)))
else if (t_0 <= 1d-209) then
tmp = -sqrt((1.0d0 / (l * h))) * d
else
tmp = t_1 * 1.0d0
end if
code = tmp
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
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 * D) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = Math.sqrt((d / l)) * Math.sqrt((d / h));
double tmp;
if (t_0 <= -100000000000.0) {
tmp = t_1 * (1.0 - (((((M * M) * D) * (D / (d * d))) * 0.125) * (h / l)));
} else if (t_0 <= 1e-209) {
tmp = -Math.sqrt((1.0 / (l * h))) * d;
} else {
tmp = t_1 * 1.0;
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): 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 * D) / (2.0 * d)), 2.0)) * (h / l))) t_1 = math.sqrt((d / l)) * math.sqrt((d / h)) tmp = 0 if t_0 <= -100000000000.0: tmp = t_1 * (1.0 - (((((M * M) * D) * (D / (d * d))) * 0.125) * (h / l))) elif t_0 <= 1e-209: tmp = -math.sqrt((1.0 / (l * h))) * d else: tmp = t_1 * 1.0 return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) 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 * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) tmp = 0.0 if (t_0 <= -100000000000.0) tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(Float64(Float64(Float64(M * M) * D) * Float64(D / Float64(d * d))) * 0.125) * Float64(h / l)))); elseif (t_0 <= 1e-209) tmp = Float64(Float64(-sqrt(Float64(1.0 / Float64(l * h)))) * d); else tmp = Float64(t_1 * 1.0); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
t_0 = (((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)));
t_1 = sqrt((d / l)) * sqrt((d / h));
tmp = 0.0;
if (t_0 <= -100000000000.0)
tmp = t_1 * (1.0 - (((((M * M) * D) * (D / (d * d))) * 0.125) * (h / l)));
elseif (t_0 <= 1e-209)
tmp = -sqrt((1.0 / (l * h))) * d;
else
tmp = t_1 * 1.0;
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := 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 * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -100000000000.0], N[(t$95$1 * N[(1.0 - N[(N[(N[(N[(N[(M * M), $MachinePrecision] * D), $MachinePrecision] * N[(D / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e-209], N[((-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * d), $MachinePrecision], N[(t$95$1 * 1.0), $MachinePrecision]]]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\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 \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{if}\;t\_0 \leq -100000000000:\\
\;\;\;\;t\_1 \cdot \left(1 - \left(\left(\left(\left(M \cdot M\right) \cdot D\right) \cdot \frac{D}{d \cdot d}\right) \cdot 0.125\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{elif}\;t\_0 \leq 10^{-209}:\\
\;\;\;\;\left(-\sqrt{\frac{1}{\ell \cdot h}}\right) \cdot d\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot 1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -1e11Initial program 84.9%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites83.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-/.f6483.9
Applied rewrites83.9%
Taylor expanded in d around 0
Applied rewrites59.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
Applied rewrites59.4%
if -1e11 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 1e-209Initial program 58.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6437.4
Applied rewrites37.4%
Taylor expanded in h around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6441.9
Applied rewrites41.9%
if 1e-209 < (*.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 58.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 rewrites61.8%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6461.8
Applied rewrites61.8%
Taylor expanded in d around inf
Applied rewrites61.6%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
: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 D) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1 (* (sqrt (/ d l)) (sqrt (/ d h)))))
(if (<= t_0 -1e+177)
(* t_1 (fma (/ (* (* (* M M) h) (* D D)) (* (* d d) l)) -0.125 1.0))
(if (<= t_0 -5e-41)
(/ (* (/ (* (sqrt (* l h)) (* (* D M) (* D M))) d) -0.125) (* l l))
(if (<= t_0 1e-209) (* (- (sqrt (/ 1.0 (* l h)))) d) (* t_1 1.0))))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
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 * D) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = sqrt((d / l)) * sqrt((d / h));
double tmp;
if (t_0 <= -1e+177) {
tmp = t_1 * fma(((((M * M) * h) * (D * D)) / ((d * d) * l)), -0.125, 1.0);
} else if (t_0 <= -5e-41) {
tmp = (((sqrt((l * h)) * ((D * M) * (D * M))) / d) * -0.125) / (l * l);
} else if (t_0 <= 1e-209) {
tmp = -sqrt((1.0 / (l * h))) * d;
} else {
tmp = t_1 * 1.0;
}
return tmp;
}
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) 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 * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) tmp = 0.0 if (t_0 <= -1e+177) tmp = Float64(t_1 * fma(Float64(Float64(Float64(Float64(M * M) * h) * Float64(D * D)) / Float64(Float64(d * d) * l)), -0.125, 1.0)); elseif (t_0 <= -5e-41) tmp = Float64(Float64(Float64(Float64(sqrt(Float64(l * h)) * Float64(Float64(D * M) * Float64(D * M))) / d) * -0.125) / Float64(l * l)); elseif (t_0 <= 1e-209) tmp = Float64(Float64(-sqrt(Float64(1.0 / Float64(l * h)))) * d); else tmp = Float64(t_1 * 1.0); end return tmp end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := 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 * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+177], N[(t$95$1 * N[(N[(N[(N[(N[(M * M), $MachinePrecision] * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -5e-41], N[(N[(N[(N[(N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision] * N[(N[(D * M), $MachinePrecision] * N[(D * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * -0.125), $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e-209], N[((-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * d), $MachinePrecision], N[(t$95$1 * 1.0), $MachinePrecision]]]]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\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 \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+177}:\\
\;\;\;\;t\_1 \cdot \mathsf{fma}\left(\frac{\left(\left(M \cdot M\right) \cdot h\right) \cdot \left(D \cdot D\right)}{\left(d \cdot d\right) \cdot \ell}, -0.125, 1\right)\\
\mathbf{elif}\;t\_0 \leq -5 \cdot 10^{-41}:\\
\;\;\;\;\frac{\frac{\sqrt{\ell \cdot h} \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)}{d} \cdot -0.125}{\ell \cdot \ell}\\
\mathbf{elif}\;t\_0 \leq 10^{-209}:\\
\;\;\;\;\left(-\sqrt{\frac{1}{\ell \cdot h}}\right) \cdot d\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot 1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -1e177Initial program 83.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 rewrites84.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-/.f6484.5
Applied rewrites84.5%
Taylor expanded in d around inf
Applied rewrites55.4%
if -1e177 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -4.9999999999999996e-41Initial program 98.4%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites11.6%
Taylor expanded in d around 0
*-commutativeN/A
associate-*l/N/A
*-commutativeN/A
pow2N/A
pow2N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites14.8%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
pow2N/A
unswap-sqrN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6422.4
Applied rewrites22.4%
if -4.9999999999999996e-41 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 1e-209Initial program 53.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6441.2
Applied rewrites41.2%
Taylor expanded in h around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6446.2
Applied rewrites46.2%
if 1e-209 < (*.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 58.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 rewrites61.8%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6461.8
Applied rewrites61.8%
Taylor expanded in d around inf
Applied rewrites61.6%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (* (sqrt (/ d l)) (sqrt (/ d h))))
(t_1
(*
(* (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))))))
(if (<= t_1 (- INFINITY))
(* t_0 (* (/ (* (* (* M M) h) (* D D)) (* (* d d) l)) -0.125))
(if (<= t_1 -5e-41)
(/ (* (/ (* (sqrt (* l h)) (* (* D M) (* D M))) d) -0.125) (* l l))
(if (<= t_1 1e-209) (* (- (sqrt (/ 1.0 (* l h)))) d) (* t_0 1.0))))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = sqrt((d / l)) * sqrt((d / h));
double t_1 = (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 tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_0 * (((((M * M) * h) * (D * D)) / ((d * d) * l)) * -0.125);
} else if (t_1 <= -5e-41) {
tmp = (((sqrt((l * h)) * ((D * M) * (D * M))) / d) * -0.125) / (l * l);
} else if (t_1 <= 1e-209) {
tmp = -sqrt((1.0 / (l * h))) * d;
} else {
tmp = t_0 * 1.0;
}
return tmp;
}
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
double t_0 = Math.sqrt((d / l)) * Math.sqrt((d / h));
double t_1 = (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)));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = t_0 * (((((M * M) * h) * (D * D)) / ((d * d) * l)) * -0.125);
} else if (t_1 <= -5e-41) {
tmp = (((Math.sqrt((l * h)) * ((D * M) * (D * M))) / d) * -0.125) / (l * l);
} else if (t_1 <= 1e-209) {
tmp = -Math.sqrt((1.0 / (l * h))) * d;
} else {
tmp = t_0 * 1.0;
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): t_0 = math.sqrt((d / l)) * math.sqrt((d / h)) t_1 = (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))) tmp = 0 if t_1 <= -math.inf: tmp = t_0 * (((((M * M) * h) * (D * D)) / ((d * d) * l)) * -0.125) elif t_1 <= -5e-41: tmp = (((math.sqrt((l * h)) * ((D * M) * (D * M))) / d) * -0.125) / (l * l) elif t_1 <= 1e-209: tmp = -math.sqrt((1.0 / (l * h))) * d else: tmp = t_0 * 1.0 return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) t_0 = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) t_1 = 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)))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(t_0 * Float64(Float64(Float64(Float64(Float64(M * M) * h) * Float64(D * D)) / Float64(Float64(d * d) * l)) * -0.125)); elseif (t_1 <= -5e-41) tmp = Float64(Float64(Float64(Float64(sqrt(Float64(l * h)) * Float64(Float64(D * M) * Float64(D * M))) / d) * -0.125) / Float64(l * l)); elseif (t_1 <= 1e-209) tmp = Float64(Float64(-sqrt(Float64(1.0 / Float64(l * h)))) * d); else tmp = Float64(t_0 * 1.0); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
t_0 = sqrt((d / l)) * sqrt((d / h));
t_1 = (((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)));
tmp = 0.0;
if (t_1 <= -Inf)
tmp = t_0 * (((((M * M) * h) * (D * D)) / ((d * d) * l)) * -0.125);
elseif (t_1 <= -5e-41)
tmp = (((sqrt((l * h)) * ((D * M) * (D * M))) / d) * -0.125) / (l * l);
elseif (t_1 <= 1e-209)
tmp = -sqrt((1.0 / (l * h))) * d;
else
tmp = t_0 * 1.0;
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = 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]}, If[LessEqual[t$95$1, (-Infinity)], N[(t$95$0 * N[(N[(N[(N[(N[(M * M), $MachinePrecision] * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -5e-41], N[(N[(N[(N[(N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision] * N[(N[(D * M), $MachinePrecision] * N[(D * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * -0.125), $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-209], N[((-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * d), $MachinePrecision], N[(t$95$0 * 1.0), $MachinePrecision]]]]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
t_1 := \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)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;t\_0 \cdot \left(\frac{\left(\left(M \cdot M\right) \cdot h\right) \cdot \left(D \cdot D\right)}{\left(d \cdot d\right) \cdot \ell} \cdot -0.125\right)\\
\mathbf{elif}\;t\_1 \leq -5 \cdot 10^{-41}:\\
\;\;\;\;\frac{\frac{\sqrt{\ell \cdot h} \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)}{d} \cdot -0.125}{\ell \cdot \ell}\\
\mathbf{elif}\;t\_1 \leq 10^{-209}:\\
\;\;\;\;\left(-\sqrt{\frac{1}{\ell \cdot h}}\right) \cdot d\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot 1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -inf.0Initial program 82.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.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-/.f6484.3
Applied rewrites84.3%
Taylor expanded in d around 0
Applied rewrites57.6%
if -inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -4.9999999999999996e-41Initial program 98.5%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites10.2%
Taylor expanded in d around 0
*-commutativeN/A
associate-*l/N/A
*-commutativeN/A
pow2N/A
pow2N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites13.5%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
pow2N/A
unswap-sqrN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6421.2
Applied rewrites21.2%
if -4.9999999999999996e-41 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 1e-209Initial program 53.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6441.2
Applied rewrites41.2%
Taylor expanded in h around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6446.2
Applied rewrites46.2%
if 1e-209 < (*.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 58.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 rewrites61.8%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6461.8
Applied rewrites61.8%
Taylor expanded in d around inf
Applied rewrites61.6%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
: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 D) (* 2.0 d)) 2.0)) (/ h l))))))
(if (<= t_0 -5e-41)
(/ (* (/ (* (sqrt (* l h)) (* (* D M) (* D M))) d) -0.125) (* l l))
(if (<= t_0 1e-209)
(* (- (sqrt (/ 1.0 (* l h)))) d)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
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 * D) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -5e-41) {
tmp = (((sqrt((l * h)) * ((D * M) * (D * M))) / d) * -0.125) / (l * l);
} else if (t_0 <= 1e-209) {
tmp = -sqrt((1.0 / (l * h))) * d;
} else {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
}
return tmp;
}
NOTE: d, 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, 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
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 * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
if (t_0 <= (-5d-41)) then
tmp = (((sqrt((l * h)) * ((d_1 * m) * (d_1 * m))) / d) * (-0.125d0)) / (l * l)
else if (t_0 <= 1d-209) then
tmp = -sqrt((1.0d0 / (l * h))) * d
else
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0d0
end if
code = tmp
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
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 * D) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -5e-41) {
tmp = (((Math.sqrt((l * h)) * ((D * M) * (D * M))) / d) * -0.125) / (l * l);
} else if (t_0 <= 1e-209) {
tmp = -Math.sqrt((1.0 / (l * h))) * d;
} else {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * 1.0;
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): 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 * D) / (2.0 * d)), 2.0)) * (h / l))) tmp = 0 if t_0 <= -5e-41: tmp = (((math.sqrt((l * h)) * ((D * M) * (D * M))) / d) * -0.125) / (l * l) elif t_0 <= 1e-209: tmp = -math.sqrt((1.0 / (l * h))) * d else: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * 1.0 return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) 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 * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_0 <= -5e-41) tmp = Float64(Float64(Float64(Float64(sqrt(Float64(l * h)) * Float64(Float64(D * M) * Float64(D * M))) / d) * -0.125) / Float64(l * l)); elseif (t_0 <= 1e-209) tmp = Float64(Float64(-sqrt(Float64(1.0 / Float64(l * h)))) * d); else tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
t_0 = (((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)));
tmp = 0.0;
if (t_0 <= -5e-41)
tmp = (((sqrt((l * h)) * ((D * M) * (D * M))) / d) * -0.125) / (l * l);
elseif (t_0 <= 1e-209)
tmp = -sqrt((1.0 / (l * h))) * d;
else
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := 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 * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-41], N[(N[(N[(N[(N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision] * N[(N[(D * M), $MachinePrecision] * N[(D * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * -0.125), $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e-209], N[((-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * d), $MachinePrecision], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\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 \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-41}:\\
\;\;\;\;\frac{\frac{\sqrt{\ell \cdot h} \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)}{d} \cdot -0.125}{\ell \cdot \ell}\\
\mathbf{elif}\;t\_0 \leq 10^{-209}:\\
\;\;\;\;\left(-\sqrt{\frac{1}{\ell \cdot h}}\right) \cdot d\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot 1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -4.9999999999999996e-41Initial program 85.2%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites25.2%
Taylor expanded in d around 0
*-commutativeN/A
associate-*l/N/A
*-commutativeN/A
pow2N/A
pow2N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites29.4%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
pow2N/A
unswap-sqrN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6432.6
Applied rewrites32.6%
if -4.9999999999999996e-41 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 1e-209Initial program 53.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6441.2
Applied rewrites41.2%
Taylor expanded in h around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6446.2
Applied rewrites46.2%
if 1e-209 < (*.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 58.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 rewrites61.8%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6461.8
Applied rewrites61.8%
Taylor expanded in d around inf
Applied rewrites61.6%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
: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 D) (* 2.0 d)) 2.0)) (/ h l))))))
(if (<= t_0 (- INFINITY))
(* (* -0.125 (* (* D D) (/ (* M M) d))) (sqrt (/ h (* (* l l) l))))
(if (<= t_0 1e-209)
(* (- (sqrt (/ 1.0 (* l h)))) d)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
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 * D) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (-0.125 * ((D * D) * ((M * M) / d))) * sqrt((h / ((l * l) * l)));
} else if (t_0 <= 1e-209) {
tmp = -sqrt((1.0 / (l * h))) * d;
} else {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
}
return tmp;
}
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
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 * D) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = (-0.125 * ((D * D) * ((M * M) / d))) * Math.sqrt((h / ((l * l) * l)));
} else if (t_0 <= 1e-209) {
tmp = -Math.sqrt((1.0 / (l * h))) * d;
} else {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * 1.0;
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): 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 * D) / (2.0 * d)), 2.0)) * (h / l))) tmp = 0 if t_0 <= -math.inf: tmp = (-0.125 * ((D * D) * ((M * M) / d))) * math.sqrt((h / ((l * l) * l))) elif t_0 <= 1e-209: tmp = -math.sqrt((1.0 / (l * h))) * d else: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * 1.0 return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) 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 * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(-0.125 * Float64(Float64(D * D) * Float64(Float64(M * M) / d))) * sqrt(Float64(h / Float64(Float64(l * l) * l)))); elseif (t_0 <= 1e-209) tmp = Float64(Float64(-sqrt(Float64(1.0 / Float64(l * h)))) * d); else tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
t_0 = (((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)));
tmp = 0.0;
if (t_0 <= -Inf)
tmp = (-0.125 * ((D * D) * ((M * M) / d))) * sqrt((h / ((l * l) * l)));
elseif (t_0 <= 1e-209)
tmp = -sqrt((1.0 / (l * h))) * d;
else
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := 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 * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(-0.125 * N[(N[(D * D), $MachinePrecision] * N[(N[(M * 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-209], N[((-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * d), $MachinePrecision], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\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 \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\left(-0.125 \cdot \left(\left(D \cdot D\right) \cdot \frac{M \cdot M}{d}\right)\right) \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\
\mathbf{elif}\;t\_0 \leq 10^{-209}:\\
\;\;\;\;\left(-\sqrt{\frac{1}{\ell \cdot h}}\right) \cdot d\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot 1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -inf.0Initial program 82.8%
Taylor expanded in d around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
unpow3N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6434.7
Applied rewrites34.7%
if -inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 1e-209Initial program 71.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6426.0
Applied rewrites26.0%
Taylor expanded in h around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6429.1
Applied rewrites29.1%
if 1e-209 < (*.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 58.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 rewrites61.8%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6461.8
Applied rewrites61.8%
Taylor expanded in d around inf
Applied rewrites61.6%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. (FPCore (d h l M D) :precision binary64 (if (<= d 3.8e-272) (* (- (sqrt (/ 1.0 (* l h)))) d) (/ (* 1.0 d) (* (sqrt l) (sqrt h)))))
assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (d <= 3.8e-272) {
tmp = -sqrt((1.0 / (l * h))) * d;
} else {
tmp = (1.0 * d) / (sqrt(l) * sqrt(h));
}
return tmp;
}
NOTE: d, 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, 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
real(8) :: tmp
if (d <= 3.8d-272) then
tmp = -sqrt((1.0d0 / (l * h))) * d
else
tmp = (1.0d0 * d) / (sqrt(l) * sqrt(h))
end if
code = tmp
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (d <= 3.8e-272) {
tmp = -Math.sqrt((1.0 / (l * h))) * d;
} else {
tmp = (1.0 * d) / (Math.sqrt(l) * Math.sqrt(h));
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): tmp = 0 if d <= 3.8e-272: tmp = -math.sqrt((1.0 / (l * h))) * d else: tmp = (1.0 * d) / (math.sqrt(l) * math.sqrt(h)) return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) tmp = 0.0 if (d <= 3.8e-272) tmp = Float64(Float64(-sqrt(Float64(1.0 / Float64(l * h)))) * d); else tmp = Float64(Float64(1.0 * d) / Float64(sqrt(l) * sqrt(h))); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
tmp = 0.0;
if (d <= 3.8e-272)
tmp = -sqrt((1.0 / (l * h))) * d;
else
tmp = (1.0 * d) / (sqrt(l) * sqrt(h));
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[d, 3.8e-272], N[((-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * d), $MachinePrecision], N[(N[(1.0 * d), $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 3.8 \cdot 10^{-272}:\\
\;\;\;\;\left(-\sqrt{\frac{1}{\ell \cdot h}}\right) \cdot d\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if d < 3.7999999999999997e-272Initial program 64.8%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6410.7
Applied rewrites10.7%
Taylor expanded in h around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6441.7
Applied rewrites41.7%
if 3.7999999999999997e-272 < d Initial program 69.7%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6443.3
Applied rewrites43.3%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
*-commutativeN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-*.f6443.5
Applied rewrites43.5%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
*-commutativeN/A
lower-*.f6443.5
Applied rewrites43.5%
lift-*.f64N/A
lift-sqrt.f64N/A
*-commutativeN/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6451.2
Applied rewrites51.2%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. (FPCore (d h l M D) :precision binary64 (if (<= d 3.8e-272) (* (- (sqrt (/ 1.0 (* l h)))) d) (* (/ 1.0 (* (sqrt l) (sqrt h))) d)))
assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (d <= 3.8e-272) {
tmp = -sqrt((1.0 / (l * h))) * d;
} else {
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
}
return tmp;
}
NOTE: d, 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, 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
real(8) :: tmp
if (d <= 3.8d-272) then
tmp = -sqrt((1.0d0 / (l * h))) * d
else
tmp = (1.0d0 / (sqrt(l) * sqrt(h))) * d
end if
code = tmp
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (d <= 3.8e-272) {
tmp = -Math.sqrt((1.0 / (l * h))) * d;
} else {
tmp = (1.0 / (Math.sqrt(l) * Math.sqrt(h))) * d;
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): tmp = 0 if d <= 3.8e-272: tmp = -math.sqrt((1.0 / (l * h))) * d else: tmp = (1.0 / (math.sqrt(l) * math.sqrt(h))) * d return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) tmp = 0.0 if (d <= 3.8e-272) tmp = Float64(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
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
tmp = 0.0;
if (d <= 3.8e-272)
tmp = -sqrt((1.0 / (l * h))) * d;
else
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[d, 3.8e-272], 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}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 3.8 \cdot 10^{-272}:\\
\;\;\;\;\left(-\sqrt{\frac{1}{\ell \cdot h}}\right) \cdot d\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\ell} \cdot \sqrt{h}} \cdot d\\
\end{array}
\end{array}
if d < 3.7999999999999997e-272Initial program 64.8%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6410.7
Applied rewrites10.7%
Taylor expanded in h around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6441.7
Applied rewrites41.7%
if 3.7999999999999997e-272 < d Initial program 69.7%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6443.3
Applied rewrites43.3%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
*-commutativeN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-*.f6443.5
Applied rewrites43.5%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6451.1
Applied rewrites51.1%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. (FPCore (d h l M D) :precision binary64 (if (<= h 5e-271) (* (- (sqrt (/ 1.0 (* l h)))) d) (/ d (sqrt (* l h)))))
assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (h <= 5e-271) {
tmp = -sqrt((1.0 / (l * h))) * d;
} else {
tmp = d / sqrt((l * h));
}
return tmp;
}
NOTE: d, 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, 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
real(8) :: tmp
if (h <= 5d-271) then
tmp = -sqrt((1.0d0 / (l * h))) * d
else
tmp = d / sqrt((l * h))
end if
code = tmp
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (h <= 5e-271) {
tmp = -Math.sqrt((1.0 / (l * h))) * d;
} else {
tmp = d / Math.sqrt((l * h));
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): tmp = 0 if h <= 5e-271: tmp = -math.sqrt((1.0 / (l * h))) * d else: tmp = d / math.sqrt((l * h)) return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) tmp = 0.0 if (h <= 5e-271) tmp = Float64(Float64(-sqrt(Float64(1.0 / Float64(l * h)))) * d); else tmp = Float64(d / sqrt(Float64(l * h))); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
tmp = 0.0;
if (h <= 5e-271)
tmp = -sqrt((1.0 / (l * h))) * d;
else
tmp = d / sqrt((l * h));
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[h, 5e-271], N[((-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * d), $MachinePrecision], N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq 5 \cdot 10^{-271}:\\
\;\;\;\;\left(-\sqrt{\frac{1}{\ell \cdot h}}\right) \cdot d\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\
\end{array}
\end{array}
if h < 5.0000000000000002e-271Initial program 66.3%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6412.6
Applied rewrites12.6%
Taylor expanded in h around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6441.7
Applied rewrites41.7%
if 5.0000000000000002e-271 < h Initial program 68.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6441.2
Applied rewrites41.2%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
*-commutativeN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-*.f6441.4
Applied rewrites41.4%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
*-commutativeN/A
lower-*.f6441.5
Applied rewrites41.5%
lift-*.f64N/A
*-lft-identity41.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.5
Applied rewrites41.5%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. (FPCore (d h l M D) :precision binary64 (* (sqrt (/ (/ 1.0 l) h)) d))
assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
return sqrt(((1.0 / l) / h)) * d;
}
NOTE: d, 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, 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 = sqrt(((1.0d0 / l) / h)) * d
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
return Math.sqrt(((1.0 / l) / h)) * d;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): return math.sqrt(((1.0 / l) / h)) * d
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) return Float64(sqrt(Float64(Float64(1.0 / l) / h)) * d) end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp = code(d, h, l, M, D)
tmp = sqrt(((1.0 / l) / h)) * d;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := N[(N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\sqrt{\frac{\frac{1}{\ell}}{h}} \cdot d
\end{array}
Initial program 67.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6426.1
Applied rewrites26.1%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6426.3
Applied rewrites26.3%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. (FPCore (d h l M D) :precision binary64 (* (sqrt (/ 1.0 (* l h))) d))
assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
return sqrt((1.0 / (l * h))) * d;
}
NOTE: d, 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, 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 = sqrt((1.0d0 / (l * h))) * d
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
return Math.sqrt((1.0 / (l * h))) * d;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): return math.sqrt((1.0 / (l * h))) * d
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) return Float64(sqrt(Float64(1.0 / Float64(l * h))) * d) end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp = code(d, h, l, M, D)
tmp = sqrt((1.0 / (l * h))) * d;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\sqrt{\frac{1}{\ell \cdot h}} \cdot d
\end{array}
Initial program 67.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6426.1
Applied rewrites26.1%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. (FPCore (d h l M D) :precision binary64 (/ d (sqrt (* l h))))
assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
return d / sqrt((l * h));
}
NOTE: d, 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, 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 / sqrt((l * h))
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
return d / Math.sqrt((l * h));
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): return d / math.sqrt((l * h))
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) return Float64(d / sqrt(Float64(l * h))) end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp = code(d, h, l, M, D)
tmp = d / sqrt((l * h));
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\frac{d}{\sqrt{\ell \cdot h}}
\end{array}
Initial program 67.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6426.1
Applied rewrites26.1%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
*-commutativeN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-*.f6426.0
Applied rewrites26.0%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
*-commutativeN/A
lower-*.f6426.0
Applied rewrites26.0%
lift-*.f64N/A
*-lft-identity26.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6426.0
Applied rewrites26.0%
herbie shell --seed 2025114
(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)))))