
(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}
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* M_m (/ D (+ d d)))))
(if (<= d 2.45e-306)
(*
(* d (- (sqrt (/ 1.0 (* l h)))))
(- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l)))
(*
(* (/ (sqrt d) (sqrt h)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l)))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = M_m * (D / (d + d));
double tmp;
if (d <= 2.45e-306) {
tmp = (d * -sqrt((1.0 / (l * h)))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
} else {
tmp = ((sqrt(d) / sqrt(h)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)));
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = m_m * (d_1 / (d + d))
if (d <= 2.45d-306) then
tmp = (d * -sqrt((1.0d0 / (l * h)))) * (1.0d0 - ((((t_0 * t_0) * 0.5d0) * h) / l))
else
tmp = ((sqrt(d) / sqrt(h)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = M_m * (D / (d + d));
double tmp;
if (d <= 2.45e-306) {
tmp = (d * -Math.sqrt((1.0 / (l * h)))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
} else {
tmp = ((Math.sqrt(d) / Math.sqrt(h)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = M_m * (D / (d + d)) tmp = 0 if d <= 2.45e-306: tmp = (d * -math.sqrt((1.0 / (l * h)))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l)) else: tmp = ((math.sqrt(d) / math.sqrt(h)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l))) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(M_m * Float64(D / Float64(d + d))) tmp = 0.0 if (d <= 2.45e-306) tmp = Float64(Float64(d * Float64(-sqrt(Float64(1.0 / Float64(l * h))))) * Float64(1.0 - Float64(Float64(Float64(Float64(t_0 * t_0) * 0.5) * h) / l))); else tmp = Float64(Float64(Float64(sqrt(d) / sqrt(h)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = M_m * (D / (d + d));
tmp = 0.0;
if (d <= 2.45e-306)
tmp = (d * -sqrt((1.0 / (l * h)))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
else
tmp = ((sqrt(d) / sqrt(h)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D) / (2.0 * d)) ^ 2.0)) * (h / l)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(M$95$m * N[(D / N[(d + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, 2.45e-306], N[(N[(d * (-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := M\_m \cdot \frac{D}{d + d}\\
\mathbf{if}\;d \leq 2.45 \cdot 10^{-306}:\\
\;\;\;\;\left(d \cdot \left(-\sqrt{\frac{1}{\ell \cdot h}}\right)\right) \cdot \left(1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\end{array}
\end{array}
if d < 2.45000000000000012e-306Initial program 66.2%
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.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
*-commutativeN/A
metadata-evalN/A
metadata-evalN/A
sqrt-pow2N/A
lower-*.f64N/A
Applied rewrites74.0%
if 2.45000000000000012e-306 < d Initial program 67.4%
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6476.8
Applied rewrites76.8%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* M_m (/ D (+ d d))))
(t_1 (- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l))))
(if (<= d 2.45e-306)
(* (* d (- (sqrt (/ 1.0 (* l h))))) t_1)
(* (/ (* (sqrt d) (sqrt (/ d l))) (sqrt h)) t_1))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = M_m * (D / (d + d));
double t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l);
double tmp;
if (d <= 2.45e-306) {
tmp = (d * -sqrt((1.0 / (l * h)))) * t_1;
} else {
tmp = ((sqrt(d) * sqrt((d / l))) / sqrt(h)) * t_1;
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = m_m * (d_1 / (d + d))
t_1 = 1.0d0 - ((((t_0 * t_0) * 0.5d0) * h) / l)
if (d <= 2.45d-306) 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
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = M_m * (D / (d + d));
double t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l);
double tmp;
if (d <= 2.45e-306) {
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;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = M_m * (D / (d + d)) t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l) tmp = 0 if d <= 2.45e-306: 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
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(M_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 (d <= 2.45e-306) 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
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = M_m * (D / (d + d));
t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l);
tmp = 0.0;
if (d <= 2.45e-306)
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
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(M$95$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[d, 2.45e-306], 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}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := M\_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}\;d \leq 2.45 \cdot 10^{-306}:\\
\;\;\;\;\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 d < 2.45000000000000012e-306Initial program 66.2%
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.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
*-commutativeN/A
metadata-evalN/A
metadata-evalN/A
sqrt-pow2N/A
lower-*.f64N/A
Applied rewrites74.0%
if 2.45000000000000012e-306 < d Initial 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.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%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* M_m (/ D (+ d d))))
(t_1 (* (* t_0 t_0) 0.5))
(t_2 (sqrt (/ 1.0 (* l h)))))
(if (<= d 1.2e-282)
(* (* d (- t_2)) (- 1.0 (/ (* t_1 h) l)))
(if (<= d 1.85e-155)
(fma
(* (sqrt (/ h (* (* l l) l))) (* D (* D (* (/ M_m d) M_m))))
-0.125
(* t_2 d))
(* (sqrt (/ d h)) (* (/ (sqrt d) (sqrt l)) (- 1.0 (* t_1 (/ h l)))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = M_m * (D / (d + d));
double t_1 = (t_0 * t_0) * 0.5;
double t_2 = sqrt((1.0 / (l * h)));
double tmp;
if (d <= 1.2e-282) {
tmp = (d * -t_2) * (1.0 - ((t_1 * h) / l));
} else if (d <= 1.85e-155) {
tmp = fma((sqrt((h / ((l * l) * l))) * (D * (D * ((M_m / d) * M_m)))), -0.125, (t_2 * d));
} else {
tmp = sqrt((d / h)) * ((sqrt(d) / sqrt(l)) * (1.0 - (t_1 * (h / l))));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(M_m * Float64(D / Float64(d + d))) t_1 = Float64(Float64(t_0 * t_0) * 0.5) t_2 = sqrt(Float64(1.0 / Float64(l * h))) tmp = 0.0 if (d <= 1.2e-282) tmp = Float64(Float64(d * Float64(-t_2)) * Float64(1.0 - Float64(Float64(t_1 * h) / l))); elseif (d <= 1.85e-155) tmp = fma(Float64(sqrt(Float64(h / Float64(Float64(l * l) * l))) * Float64(D * Float64(D * Float64(Float64(M_m / d) * M_m)))), -0.125, Float64(t_2 * d)); else tmp = Float64(sqrt(Float64(d / h)) * Float64(Float64(sqrt(d) / sqrt(l)) * Float64(1.0 - Float64(t_1 * Float64(h / l))))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(M$95$m * N[(D / N[(d + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, 1.2e-282], N[(N[(d * (-t$95$2)), $MachinePrecision] * N[(1.0 - N[(N[(t$95$1 * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.85e-155], N[(N[(N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(D * N[(D * N[(N[(M$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125 + N[(t$95$2 * d), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(t$95$1 * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := M\_m \cdot \frac{D}{d + d}\\
t_1 := \left(t\_0 \cdot t\_0\right) \cdot 0.5\\
t_2 := \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{if}\;d \leq 1.2 \cdot 10^{-282}:\\
\;\;\;\;\left(d \cdot \left(-t\_2\right)\right) \cdot \left(1 - \frac{t\_1 \cdot h}{\ell}\right)\\
\mathbf{elif}\;d \leq 1.85 \cdot 10^{-155}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}} \cdot \left(D \cdot \left(D \cdot \left(\frac{M\_m}{d} \cdot M\_m\right)\right)\right), -0.125, t\_2 \cdot d\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \left(1 - t\_1 \cdot \frac{h}{\ell}\right)\right)\\
\end{array}
\end{array}
if d < 1.19999999999999998e-282Initial program 64.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 rewrites66.4%
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
*-commutativeN/A
metadata-evalN/A
metadata-evalN/A
sqrt-pow2N/A
lower-*.f64N/A
Applied rewrites71.7%
if 1.19999999999999998e-282 < d < 1.85e-155Initial program 47.8%
Taylor expanded in l around inf
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6451.3
Applied rewrites51.3%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6453.4
Applied rewrites53.4%
if 1.85e-155 < d Initial program 74.5%
Applied rewrites74.2%
lift-/.f64N/A
lift-sqrt.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6477.9
Applied rewrites77.9%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* M_m (/ D (+ d d))))
(t_1 (- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l)))
(t_2 (sqrt (/ 1.0 (* l h)))))
(if (<= l -2e-311)
(* (* d (- t_2)) t_1)
(if (<= l 1.1e-86)
(* (* (sqrt (/ 1.0 (* h l))) d) t_1)
(if (<= l 2.15e+102)
(fma
(* (sqrt (/ h (* (* l l) l))) (* D (* D (* (/ M_m d) M_m))))
-0.125
(* t_2 d))
(/ (* 1.0 d) (* (sqrt h) (sqrt l))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = M_m * (D / (d + d));
double t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l);
double t_2 = sqrt((1.0 / (l * h)));
double tmp;
if (l <= -2e-311) {
tmp = (d * -t_2) * t_1;
} else if (l <= 1.1e-86) {
tmp = (sqrt((1.0 / (h * l))) * d) * t_1;
} else if (l <= 2.15e+102) {
tmp = fma((sqrt((h / ((l * l) * l))) * (D * (D * ((M_m / d) * M_m)))), -0.125, (t_2 * d));
} else {
tmp = (1.0 * d) / (sqrt(h) * sqrt(l));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(M_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 = sqrt(Float64(1.0 / Float64(l * h))) tmp = 0.0 if (l <= -2e-311) tmp = Float64(Float64(d * Float64(-t_2)) * t_1); elseif (l <= 1.1e-86) tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(h * l))) * d) * t_1); elseif (l <= 2.15e+102) tmp = fma(Float64(sqrt(Float64(h / Float64(Float64(l * l) * l))) * Float64(D * Float64(D * Float64(Float64(M_m / d) * M_m)))), -0.125, Float64(t_2 * d)); else tmp = Float64(Float64(1.0 * d) / Float64(sqrt(h) * sqrt(l))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(M$95$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[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -2e-311], N[(N[(d * (-t$95$2)), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[l, 1.1e-86], N[(N[(N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[l, 2.15e+102], N[(N[(N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(D * N[(D * N[(N[(M$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125 + N[(t$95$2 * d), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 * d), $MachinePrecision] / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := M\_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 := \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{if}\;\ell \leq -2 \cdot 10^{-311}:\\
\;\;\;\;\left(d \cdot \left(-t\_2\right)\right) \cdot t\_1\\
\mathbf{elif}\;\ell \leq 1.1 \cdot 10^{-86}:\\
\;\;\;\;\left(\sqrt{\frac{1}{h \cdot \ell}} \cdot d\right) \cdot t\_1\\
\mathbf{elif}\;\ell \leq 2.15 \cdot 10^{+102}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}} \cdot \left(D \cdot \left(D \cdot \left(\frac{M\_m}{d} \cdot M\_m\right)\right)\right), -0.125, t\_2 \cdot d\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if l < -1.9999999999999e-311Initial program 66.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 rewrites67.9%
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
*-commutativeN/A
metadata-evalN/A
metadata-evalN/A
sqrt-pow2N/A
lower-*.f64N/A
Applied rewrites74.2%
if -1.9999999999999e-311 < l < 1.1000000000000001e-86Initial program 73.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 rewrites76.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-/.f6476.8
Applied rewrites76.8%
Taylor expanded in d around 0
*-commutativeN/A
sqrt-divN/A
pow1/2N/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f6485.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6485.7
Applied rewrites85.7%
if 1.1000000000000001e-86 < l < 2.15e102Initial program 75.1%
Taylor expanded in l around inf
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites66.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6469.0
Applied rewrites69.0%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6477.8
Applied rewrites77.8%
if 2.15e102 < l Initial program 54.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6451.3
Applied rewrites51.3%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
*-commutativeN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6451.3
Applied rewrites51.3%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
*-commutativeN/A
lower-*.f6451.3
Applied rewrites51.3%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6464.7
Applied rewrites64.7%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* M_m (/ D (+ d d))))
(t_1 (- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l)))
(t_2 (sqrt (/ 1.0 (* l h)))))
(if (<= d 1.2e-282)
(* (* d (- t_2)) t_1)
(if (<= d 2.2e-155)
(fma
(* (sqrt (/ h (* (* l l) l))) (* D (* D (* (/ M_m d) M_m))))
-0.125
(* t_2 d))
(* (* (sqrt (/ d l)) (sqrt (/ d h))) t_1)))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = M_m * (D / (d + d));
double t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l);
double t_2 = sqrt((1.0 / (l * h)));
double tmp;
if (d <= 1.2e-282) {
tmp = (d * -t_2) * t_1;
} else if (d <= 2.2e-155) {
tmp = fma((sqrt((h / ((l * l) * l))) * (D * (D * ((M_m / d) * M_m)))), -0.125, (t_2 * d));
} else {
tmp = (sqrt((d / l)) * sqrt((d / h))) * t_1;
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(M_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 = sqrt(Float64(1.0 / Float64(l * h))) tmp = 0.0 if (d <= 1.2e-282) tmp = Float64(Float64(d * Float64(-t_2)) * t_1); elseif (d <= 2.2e-155) tmp = fma(Float64(sqrt(Float64(h / Float64(Float64(l * l) * l))) * Float64(D * Float64(D * Float64(Float64(M_m / d) * M_m)))), -0.125, Float64(t_2 * d)); else tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * t_1); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(M$95$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[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, 1.2e-282], N[(N[(d * (-t$95$2)), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[d, 2.2e-155], N[(N[(N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(D * N[(D * N[(N[(M$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125 + N[(t$95$2 * d), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := M\_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 := \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{if}\;d \leq 1.2 \cdot 10^{-282}:\\
\;\;\;\;\left(d \cdot \left(-t\_2\right)\right) \cdot t\_1\\
\mathbf{elif}\;d \leq 2.2 \cdot 10^{-155}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}} \cdot \left(D \cdot \left(D \cdot \left(\frac{M\_m}{d} \cdot M\_m\right)\right)\right), -0.125, t\_2 \cdot d\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot t\_1\\
\end{array}
\end{array}
if d < 1.19999999999999998e-282Initial program 64.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 rewrites66.4%
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
*-commutativeN/A
metadata-evalN/A
metadata-evalN/A
sqrt-pow2N/A
lower-*.f64N/A
Applied rewrites71.7%
if 1.19999999999999998e-282 < d < 2.1999999999999999e-155Initial program 47.8%
Taylor expanded in l around inf
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6451.3
Applied rewrites51.3%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6453.4
Applied rewrites53.4%
if 2.1999999999999999e-155 < d Initial program 74.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 rewrites76.2%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6476.2
Applied rewrites76.2%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* M_m (/ D (+ d d))))
(t_1 (* (* t_0 t_0) 0.5))
(t_2 (sqrt (/ 1.0 (* l h)))))
(if (<= d 1.2e-282)
(* (* d (- t_2)) (- 1.0 (/ (* t_1 h) l)))
(if (<= d 2.2e-155)
(fma
(* (sqrt (/ h (* (* l l) l))) (* D (* D (* (/ M_m d) M_m))))
-0.125
(* t_2 d))
(* (sqrt (/ d h)) (* (sqrt (/ d l)) (- 1.0 (* t_1 (/ h l)))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = M_m * (D / (d + d));
double t_1 = (t_0 * t_0) * 0.5;
double t_2 = sqrt((1.0 / (l * h)));
double tmp;
if (d <= 1.2e-282) {
tmp = (d * -t_2) * (1.0 - ((t_1 * h) / l));
} else if (d <= 2.2e-155) {
tmp = fma((sqrt((h / ((l * l) * l))) * (D * (D * ((M_m / d) * M_m)))), -0.125, (t_2 * d));
} else {
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 - (t_1 * (h / l))));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(M_m * Float64(D / Float64(d + d))) t_1 = Float64(Float64(t_0 * t_0) * 0.5) t_2 = sqrt(Float64(1.0 / Float64(l * h))) tmp = 0.0 if (d <= 1.2e-282) tmp = Float64(Float64(d * Float64(-t_2)) * Float64(1.0 - Float64(Float64(t_1 * h) / l))); elseif (d <= 2.2e-155) tmp = fma(Float64(sqrt(Float64(h / Float64(Float64(l * l) * l))) * Float64(D * Float64(D * Float64(Float64(M_m / d) * M_m)))), -0.125, Float64(t_2 * d)); else tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(d / l)) * Float64(1.0 - Float64(t_1 * Float64(h / l))))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(M$95$m * N[(D / N[(d + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, 1.2e-282], N[(N[(d * (-t$95$2)), $MachinePrecision] * N[(1.0 - N[(N[(t$95$1 * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.2e-155], N[(N[(N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(D * N[(D * N[(N[(M$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125 + N[(t$95$2 * d), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(t$95$1 * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := M\_m \cdot \frac{D}{d + d}\\
t_1 := \left(t\_0 \cdot t\_0\right) \cdot 0.5\\
t_2 := \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{if}\;d \leq 1.2 \cdot 10^{-282}:\\
\;\;\;\;\left(d \cdot \left(-t\_2\right)\right) \cdot \left(1 - \frac{t\_1 \cdot h}{\ell}\right)\\
\mathbf{elif}\;d \leq 2.2 \cdot 10^{-155}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}} \cdot \left(D \cdot \left(D \cdot \left(\frac{M\_m}{d} \cdot M\_m\right)\right)\right), -0.125, t\_2 \cdot d\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - t\_1 \cdot \frac{h}{\ell}\right)\right)\\
\end{array}
\end{array}
if d < 1.19999999999999998e-282Initial program 64.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 rewrites66.4%
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
*-commutativeN/A
metadata-evalN/A
metadata-evalN/A
sqrt-pow2N/A
lower-*.f64N/A
Applied rewrites71.7%
if 1.19999999999999998e-282 < d < 2.1999999999999999e-155Initial program 47.8%
Taylor expanded in l around inf
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6451.3
Applied rewrites51.3%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6453.4
Applied rewrites53.4%
if 2.1999999999999999e-155 < d Initial program 74.5%
Applied rewrites74.2%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (sqrt (/ 1.0 (* l h))))
(t_1 (* M_m (/ D (+ d d))))
(t_2 (* (* M_m (* D M_m)) D))
(t_3
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (/ (* (* (/ t_2 (* d d)) 0.125) h) l)))))
(if (<= d -9.8e+91)
(* (- t_0) d)
(if (<= d -1.9e-144)
t_3
(if (<= d -5e-310)
(* (* (/ (* t_2 -1.0) d) (sqrt (/ (/ h (* l l)) l))) -0.125)
(if (<= d 2.5e-155)
(fma
(* (sqrt (/ h (* (* l l) l))) (* D (* D (* (/ M_m d) M_m))))
-0.125
(* t_0 d))
(if (<= d 1e+136)
t_3
(*
(* (sqrt (/ 1.0 (* h l))) d)
(- 1.0 (/ (* (* (* t_1 t_1) 0.5) h) l))))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = sqrt((1.0 / (l * h)));
double t_1 = M_m * (D / (d + d));
double t_2 = (M_m * (D * M_m)) * D;
double t_3 = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((((t_2 / (d * d)) * 0.125) * h) / l));
double tmp;
if (d <= -9.8e+91) {
tmp = -t_0 * d;
} else if (d <= -1.9e-144) {
tmp = t_3;
} else if (d <= -5e-310) {
tmp = (((t_2 * -1.0) / d) * sqrt(((h / (l * l)) / l))) * -0.125;
} else if (d <= 2.5e-155) {
tmp = fma((sqrt((h / ((l * l) * l))) * (D * (D * ((M_m / d) * M_m)))), -0.125, (t_0 * d));
} else if (d <= 1e+136) {
tmp = t_3;
} else {
tmp = (sqrt((1.0 / (h * l))) * d) * (1.0 - ((((t_1 * t_1) * 0.5) * h) / l));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = sqrt(Float64(1.0 / Float64(l * h))) t_1 = Float64(M_m * Float64(D / Float64(d + d))) t_2 = Float64(Float64(M_m * Float64(D * M_m)) * D) t_3 = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64(Float64(t_2 / Float64(d * d)) * 0.125) * h) / l))) tmp = 0.0 if (d <= -9.8e+91) tmp = Float64(Float64(-t_0) * d); elseif (d <= -1.9e-144) tmp = t_3; elseif (d <= -5e-310) tmp = Float64(Float64(Float64(Float64(t_2 * -1.0) / d) * sqrt(Float64(Float64(h / Float64(l * l)) / l))) * -0.125); elseif (d <= 2.5e-155) tmp = fma(Float64(sqrt(Float64(h / Float64(Float64(l * l) * l))) * Float64(D * Float64(D * Float64(Float64(M_m / d) * M_m)))), -0.125, Float64(t_0 * d)); elseif (d <= 1e+136) tmp = t_3; else tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(h * l))) * d) * Float64(1.0 - Float64(Float64(Float64(Float64(t_1 * t_1) * 0.5) * h) / l))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(M$95$m * N[(D / N[(d + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(M$95$m * N[(D * M$95$m), $MachinePrecision]), $MachinePrecision] * D), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(t$95$2 / N[(d * d), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -9.8e+91], N[((-t$95$0) * d), $MachinePrecision], If[LessEqual[d, -1.9e-144], t$95$3, If[LessEqual[d, -5e-310], N[(N[(N[(N[(t$95$2 * -1.0), $MachinePrecision] / d), $MachinePrecision] * N[Sqrt[N[(N[(h / N[(l * l), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision], If[LessEqual[d, 2.5e-155], N[(N[(N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(D * N[(D * N[(N[(M$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125 + N[(t$95$0 * d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1e+136], t$95$3, N[(N[(N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{1}{\ell \cdot h}}\\
t_1 := M\_m \cdot \frac{D}{d + d}\\
t_2 := \left(M\_m \cdot \left(D \cdot M\_m\right)\right) \cdot D\\
t_3 := \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \frac{\left(\frac{t\_2}{d \cdot d} \cdot 0.125\right) \cdot h}{\ell}\right)\\
\mathbf{if}\;d \leq -9.8 \cdot 10^{+91}:\\
\;\;\;\;\left(-t\_0\right) \cdot d\\
\mathbf{elif}\;d \leq -1.9 \cdot 10^{-144}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\frac{t\_2 \cdot -1}{d} \cdot \sqrt{\frac{\frac{h}{\ell \cdot \ell}}{\ell}}\right) \cdot -0.125\\
\mathbf{elif}\;d \leq 2.5 \cdot 10^{-155}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}} \cdot \left(D \cdot \left(D \cdot \left(\frac{M\_m}{d} \cdot M\_m\right)\right)\right), -0.125, t\_0 \cdot d\right)\\
\mathbf{elif}\;d \leq 10^{+136}:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{1}{h \cdot \ell}} \cdot d\right) \cdot \left(1 - \frac{\left(\left(t\_1 \cdot t\_1\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\
\end{array}
\end{array}
if d < -9.8000000000000006e91Initial program 74.7%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites0.4%
Taylor expanded in l 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-*.f6466.9
Applied rewrites66.9%
if -9.8000000000000006e91 < d < -1.89999999999999996e-144 or 2.4999999999999999e-155 < d < 1.00000000000000006e136Initial program 74.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 rewrites76.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-/.f6476.5
Applied rewrites76.5%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
pow2N/A
associate-*l*N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6474.6
Applied rewrites74.6%
if -1.89999999999999996e-144 < d < -4.999999999999985e-310Initial program 44.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 rewrites42.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-/.f6442.9
Applied rewrites42.9%
Taylor expanded in h around -inf
Applied rewrites47.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f6449.7
Applied rewrites49.7%
if -4.999999999999985e-310 < d < 2.4999999999999999e-155Initial program 45.1%
Taylor expanded in l around inf
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites46.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6450.9
Applied rewrites50.9%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6453.3
Applied rewrites53.3%
if 1.00000000000000006e136 < d Initial program 73.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 rewrites75.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-/.f6475.5
Applied rewrites75.5%
Taylor expanded in d around 0
*-commutativeN/A
sqrt-divN/A
pow1/2N/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f6485.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6485.4
Applied rewrites85.4%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1
(-
(*
(*
(* 0.125 (/ (* (* M_m (* D M_m)) D) d))
(sqrt (/ 1.0 (* (* l l) (* h l)))))
h))))
(if (<= t_0 -4e-31)
t_1
(if (<= t_0 INFINITY) (* (sqrt (/ d h)) (sqrt (/ d l))) t_1))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = -(((0.125 * (((M_m * (D * M_m)) * D) / d)) * sqrt((1.0 / ((l * l) * (h * l))))) * h);
double tmp;
if (t_0 <= -4e-31) {
tmp = t_1;
} else if (t_0 <= ((double) INFINITY)) {
tmp = sqrt((d / h)) * sqrt((d / l));
} else {
tmp = t_1;
}
return tmp;
}
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = -(((0.125 * (((M_m * (D * M_m)) * D) / d)) * Math.sqrt((1.0 / ((l * l) * (h * l))))) * h);
double tmp;
if (t_0 <= -4e-31) {
tmp = t_1;
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
} else {
tmp = t_1;
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l))) t_1 = -(((0.125 * (((M_m * (D * M_m)) * D) / d)) * math.sqrt((1.0 / ((l * l) * (h * l))))) * h) tmp = 0 if t_0 <= -4e-31: tmp = t_1 elif t_0 <= math.inf: tmp = math.sqrt((d / h)) * math.sqrt((d / l)) else: tmp = t_1 return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(-Float64(Float64(Float64(0.125 * Float64(Float64(Float64(M_m * Float64(D * M_m)) * D) / d)) * sqrt(Float64(1.0 / Float64(Float64(l * l) * Float64(h * l))))) * h)) tmp = 0.0 if (t_0 <= -4e-31) tmp = t_1; elseif (t_0 <= Inf) tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))); else tmp = t_1; end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D) / (2.0 * d)) ^ 2.0)) * (h / l)));
t_1 = -(((0.125 * (((M_m * (D * M_m)) * D) / d)) * sqrt((1.0 / ((l * l) * (h * l))))) * h);
tmp = 0.0;
if (t_0 <= -4e-31)
tmp = t_1;
elseif (t_0 <= Inf)
tmp = sqrt((d / h)) * sqrt((d / l));
else
tmp = t_1;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = (-N[(N[(N[(0.125 * N[(N[(N[(M$95$m * N[(D * M$95$m), $MachinePrecision]), $MachinePrecision] * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 / N[(N[(l * l), $MachinePrecision] * N[(h * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision])}, If[LessEqual[t$95$0, -4e-31], t$95$1, If[LessEqual[t$95$0, Infinity], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := -\left(\left(0.125 \cdot \frac{\left(M\_m \cdot \left(D \cdot M\_m\right)\right) \cdot D}{d}\right) \cdot \sqrt{\frac{1}{\left(\ell \cdot \ell\right) \cdot \left(h \cdot \ell\right)}}\right) \cdot h\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{-31}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -4e-31 or +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 55.2%
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6431.5
Applied rewrites31.5%
Taylor expanded in h around -inf
Applied rewrites31.1%
Taylor expanded in d around 0
Applied rewrites56.2%
if -4e-31 < (*.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 78.7%
Applied rewrites78.0%
Taylor expanded in d around inf
lift-sqrt.f64N/A
lift-/.f6475.7
Applied rewrites75.7%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* (* M_m (* D M_m)) D)))
(if (<= l -1.18e-17)
(* (- (sqrt (/ 1.0 (* l h)))) d)
(if (<= l -4.8e-301)
(* (* (/ (* t_0 -1.0) d) (sqrt (/ (/ h (* l l)) l))) -0.125)
(if (<= l 7e+48)
(* (* -0.125 (/ t_0 d)) (sqrt (/ h (* (* l l) l))))
(/ (* 1.0 d) (* (sqrt h) (sqrt l))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = (M_m * (D * M_m)) * D;
double tmp;
if (l <= -1.18e-17) {
tmp = -sqrt((1.0 / (l * h))) * d;
} else if (l <= -4.8e-301) {
tmp = (((t_0 * -1.0) / d) * sqrt(((h / (l * l)) / l))) * -0.125;
} else if (l <= 7e+48) {
tmp = (-0.125 * (t_0 / d)) * sqrt((h / ((l * l) * l)));
} else {
tmp = (1.0 * d) / (sqrt(h) * sqrt(l));
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = (m_m * (d_1 * m_m)) * d_1
if (l <= (-1.18d-17)) then
tmp = -sqrt((1.0d0 / (l * h))) * d
else if (l <= (-4.8d-301)) then
tmp = (((t_0 * (-1.0d0)) / d) * sqrt(((h / (l * l)) / l))) * (-0.125d0)
else if (l <= 7d+48) then
tmp = ((-0.125d0) * (t_0 / d)) * sqrt((h / ((l * l) * l)))
else
tmp = (1.0d0 * d) / (sqrt(h) * sqrt(l))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = (M_m * (D * M_m)) * D;
double tmp;
if (l <= -1.18e-17) {
tmp = -Math.sqrt((1.0 / (l * h))) * d;
} else if (l <= -4.8e-301) {
tmp = (((t_0 * -1.0) / d) * Math.sqrt(((h / (l * l)) / l))) * -0.125;
} else if (l <= 7e+48) {
tmp = (-0.125 * (t_0 / d)) * Math.sqrt((h / ((l * l) * l)));
} else {
tmp = (1.0 * d) / (Math.sqrt(h) * Math.sqrt(l));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = (M_m * (D * M_m)) * D tmp = 0 if l <= -1.18e-17: tmp = -math.sqrt((1.0 / (l * h))) * d elif l <= -4.8e-301: tmp = (((t_0 * -1.0) / d) * math.sqrt(((h / (l * l)) / l))) * -0.125 elif l <= 7e+48: tmp = (-0.125 * (t_0 / d)) * math.sqrt((h / ((l * l) * l))) else: tmp = (1.0 * d) / (math.sqrt(h) * math.sqrt(l)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64(M_m * Float64(D * M_m)) * D) tmp = 0.0 if (l <= -1.18e-17) tmp = Float64(Float64(-sqrt(Float64(1.0 / Float64(l * h)))) * d); elseif (l <= -4.8e-301) tmp = Float64(Float64(Float64(Float64(t_0 * -1.0) / d) * sqrt(Float64(Float64(h / Float64(l * l)) / l))) * -0.125); elseif (l <= 7e+48) tmp = Float64(Float64(-0.125 * Float64(t_0 / d)) * sqrt(Float64(h / Float64(Float64(l * l) * l)))); else tmp = Float64(Float64(1.0 * d) / Float64(sqrt(h) * sqrt(l))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = (M_m * (D * M_m)) * D;
tmp = 0.0;
if (l <= -1.18e-17)
tmp = -sqrt((1.0 / (l * h))) * d;
elseif (l <= -4.8e-301)
tmp = (((t_0 * -1.0) / d) * sqrt(((h / (l * l)) / l))) * -0.125;
elseif (l <= 7e+48)
tmp = (-0.125 * (t_0 / d)) * sqrt((h / ((l * l) * l)));
else
tmp = (1.0 * d) / (sqrt(h) * sqrt(l));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(M$95$m * N[(D * M$95$m), $MachinePrecision]), $MachinePrecision] * D), $MachinePrecision]}, If[LessEqual[l, -1.18e-17], N[((-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * d), $MachinePrecision], If[LessEqual[l, -4.8e-301], N[(N[(N[(N[(t$95$0 * -1.0), $MachinePrecision] / d), $MachinePrecision] * N[Sqrt[N[(N[(h / N[(l * l), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision], If[LessEqual[l, 7e+48], N[(N[(-0.125 * N[(t$95$0 / d), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 * d), $MachinePrecision] / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \left(M\_m \cdot \left(D \cdot M\_m\right)\right) \cdot D\\
\mathbf{if}\;\ell \leq -1.18 \cdot 10^{-17}:\\
\;\;\;\;\left(-\sqrt{\frac{1}{\ell \cdot h}}\right) \cdot d\\
\mathbf{elif}\;\ell \leq -4.8 \cdot 10^{-301}:\\
\;\;\;\;\left(\frac{t\_0 \cdot -1}{d} \cdot \sqrt{\frac{\frac{h}{\ell \cdot \ell}}{\ell}}\right) \cdot -0.125\\
\mathbf{elif}\;\ell \leq 7 \cdot 10^{+48}:\\
\;\;\;\;\left(-0.125 \cdot \frac{t\_0}{d}\right) \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if l < -1.18000000000000004e-17Initial program 60.8%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites1.4%
Taylor expanded in l 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-*.f6449.6
Applied rewrites49.6%
if -1.18000000000000004e-17 < l < -4.79999999999999982e-301Initial program 72.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 rewrites76.2%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6476.2
Applied rewrites76.2%
Taylor expanded in h around -inf
Applied rewrites46.2%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f6446.8
Applied rewrites46.8%
if -4.79999999999999982e-301 < l < 6.9999999999999995e48Initial program 74.3%
Taylor expanded in l around inf
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites43.7%
Taylor expanded in d around 0
associate-*r*N/A
lower-*.f64N/A
Applied rewrites46.6%
if 6.9999999999999995e48 < l Initial program 58.0%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6452.3
Applied rewrites52.3%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
*-commutativeN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6452.2
Applied rewrites52.2%
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-*.f6452.3
Applied rewrites52.3%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6463.9
Applied rewrites63.9%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* (* M_m (* D M_m)) D)) (t_1 (sqrt (/ h (* (* l l) l)))))
(if (<= l -1.18e-17)
(* (- (sqrt (/ 1.0 (* l h)))) d)
(if (<= l -4.8e-301)
(* (* (/ (* t_0 -1.0) d) t_1) -0.125)
(if (<= l 7e+48)
(* (* -0.125 (/ t_0 d)) t_1)
(/ (* 1.0 d) (* (sqrt h) (sqrt l))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = (M_m * (D * M_m)) * D;
double t_1 = sqrt((h / ((l * l) * l)));
double tmp;
if (l <= -1.18e-17) {
tmp = -sqrt((1.0 / (l * h))) * d;
} else if (l <= -4.8e-301) {
tmp = (((t_0 * -1.0) / d) * t_1) * -0.125;
} else if (l <= 7e+48) {
tmp = (-0.125 * (t_0 / d)) * t_1;
} else {
tmp = (1.0 * d) / (sqrt(h) * sqrt(l));
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (m_m * (d_1 * m_m)) * d_1
t_1 = sqrt((h / ((l * l) * l)))
if (l <= (-1.18d-17)) then
tmp = -sqrt((1.0d0 / (l * h))) * d
else if (l <= (-4.8d-301)) then
tmp = (((t_0 * (-1.0d0)) / d) * t_1) * (-0.125d0)
else if (l <= 7d+48) then
tmp = ((-0.125d0) * (t_0 / d)) * t_1
else
tmp = (1.0d0 * d) / (sqrt(h) * sqrt(l))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = (M_m * (D * M_m)) * D;
double t_1 = Math.sqrt((h / ((l * l) * l)));
double tmp;
if (l <= -1.18e-17) {
tmp = -Math.sqrt((1.0 / (l * h))) * d;
} else if (l <= -4.8e-301) {
tmp = (((t_0 * -1.0) / d) * t_1) * -0.125;
} else if (l <= 7e+48) {
tmp = (-0.125 * (t_0 / d)) * t_1;
} else {
tmp = (1.0 * d) / (Math.sqrt(h) * Math.sqrt(l));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = (M_m * (D * M_m)) * D t_1 = math.sqrt((h / ((l * l) * l))) tmp = 0 if l <= -1.18e-17: tmp = -math.sqrt((1.0 / (l * h))) * d elif l <= -4.8e-301: tmp = (((t_0 * -1.0) / d) * t_1) * -0.125 elif l <= 7e+48: tmp = (-0.125 * (t_0 / d)) * t_1 else: tmp = (1.0 * d) / (math.sqrt(h) * math.sqrt(l)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64(M_m * Float64(D * M_m)) * D) t_1 = sqrt(Float64(h / Float64(Float64(l * l) * l))) tmp = 0.0 if (l <= -1.18e-17) tmp = Float64(Float64(-sqrt(Float64(1.0 / Float64(l * h)))) * d); elseif (l <= -4.8e-301) tmp = Float64(Float64(Float64(Float64(t_0 * -1.0) / d) * t_1) * -0.125); elseif (l <= 7e+48) tmp = Float64(Float64(-0.125 * Float64(t_0 / d)) * t_1); else tmp = Float64(Float64(1.0 * d) / Float64(sqrt(h) * sqrt(l))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = (M_m * (D * M_m)) * D;
t_1 = sqrt((h / ((l * l) * l)));
tmp = 0.0;
if (l <= -1.18e-17)
tmp = -sqrt((1.0 / (l * h))) * d;
elseif (l <= -4.8e-301)
tmp = (((t_0 * -1.0) / d) * t_1) * -0.125;
elseif (l <= 7e+48)
tmp = (-0.125 * (t_0 / d)) * t_1;
else
tmp = (1.0 * d) / (sqrt(h) * sqrt(l));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(M$95$m * N[(D * M$95$m), $MachinePrecision]), $MachinePrecision] * D), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -1.18e-17], N[((-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * d), $MachinePrecision], If[LessEqual[l, -4.8e-301], N[(N[(N[(N[(t$95$0 * -1.0), $MachinePrecision] / d), $MachinePrecision] * t$95$1), $MachinePrecision] * -0.125), $MachinePrecision], If[LessEqual[l, 7e+48], N[(N[(-0.125 * N[(t$95$0 / d), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(1.0 * d), $MachinePrecision] / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \left(M\_m \cdot \left(D \cdot M\_m\right)\right) \cdot D\\
t_1 := \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\
\mathbf{if}\;\ell \leq -1.18 \cdot 10^{-17}:\\
\;\;\;\;\left(-\sqrt{\frac{1}{\ell \cdot h}}\right) \cdot d\\
\mathbf{elif}\;\ell \leq -4.8 \cdot 10^{-301}:\\
\;\;\;\;\left(\frac{t\_0 \cdot -1}{d} \cdot t\_1\right) \cdot -0.125\\
\mathbf{elif}\;\ell \leq 7 \cdot 10^{+48}:\\
\;\;\;\;\left(-0.125 \cdot \frac{t\_0}{d}\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if l < -1.18000000000000004e-17Initial program 60.8%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites1.4%
Taylor expanded in l 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-*.f6449.6
Applied rewrites49.6%
if -1.18000000000000004e-17 < l < -4.79999999999999982e-301Initial program 72.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 rewrites76.2%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6476.2
Applied rewrites76.2%
Taylor expanded in h around -inf
Applied rewrites46.2%
if -4.79999999999999982e-301 < l < 6.9999999999999995e48Initial program 74.3%
Taylor expanded in l around inf
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites43.7%
Taylor expanded in d around 0
associate-*r*N/A
lower-*.f64N/A
Applied rewrites46.6%
if 6.9999999999999995e48 < l Initial program 58.0%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6452.3
Applied rewrites52.3%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
*-commutativeN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6452.2
Applied rewrites52.2%
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-*.f6452.3
Applied rewrites52.3%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6463.9
Applied rewrites63.9%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (sqrt (/ h (* (* l l) l)))))
(if (<= l -1.18e-17)
(* (- (sqrt (/ 1.0 (* l h)))) d)
(if (<= l -4.8e-301)
(* (* 0.125 (* (* (* D D) M_m) (/ M_m d))) t_0)
(if (<= l 7e+48)
(* (* -0.125 (/ (* (* M_m (* D M_m)) D) d)) t_0)
(/ (* 1.0 d) (* (sqrt h) (sqrt l))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = sqrt((h / ((l * l) * l)));
double tmp;
if (l <= -1.18e-17) {
tmp = -sqrt((1.0 / (l * h))) * d;
} else if (l <= -4.8e-301) {
tmp = (0.125 * (((D * D) * M_m) * (M_m / d))) * t_0;
} else if (l <= 7e+48) {
tmp = (-0.125 * (((M_m * (D * M_m)) * D) / d)) * t_0;
} else {
tmp = (1.0 * d) / (sqrt(h) * sqrt(l));
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((h / ((l * l) * l)))
if (l <= (-1.18d-17)) then
tmp = -sqrt((1.0d0 / (l * h))) * d
else if (l <= (-4.8d-301)) then
tmp = (0.125d0 * (((d_1 * d_1) * m_m) * (m_m / d))) * t_0
else if (l <= 7d+48) then
tmp = ((-0.125d0) * (((m_m * (d_1 * m_m)) * d_1) / d)) * t_0
else
tmp = (1.0d0 * d) / (sqrt(h) * sqrt(l))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = Math.sqrt((h / ((l * l) * l)));
double tmp;
if (l <= -1.18e-17) {
tmp = -Math.sqrt((1.0 / (l * h))) * d;
} else if (l <= -4.8e-301) {
tmp = (0.125 * (((D * D) * M_m) * (M_m / d))) * t_0;
} else if (l <= 7e+48) {
tmp = (-0.125 * (((M_m * (D * M_m)) * D) / d)) * t_0;
} else {
tmp = (1.0 * d) / (Math.sqrt(h) * Math.sqrt(l));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = math.sqrt((h / ((l * l) * l))) tmp = 0 if l <= -1.18e-17: tmp = -math.sqrt((1.0 / (l * h))) * d elif l <= -4.8e-301: tmp = (0.125 * (((D * D) * M_m) * (M_m / d))) * t_0 elif l <= 7e+48: tmp = (-0.125 * (((M_m * (D * M_m)) * D) / d)) * t_0 else: tmp = (1.0 * d) / (math.sqrt(h) * math.sqrt(l)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = sqrt(Float64(h / Float64(Float64(l * l) * l))) tmp = 0.0 if (l <= -1.18e-17) tmp = Float64(Float64(-sqrt(Float64(1.0 / Float64(l * h)))) * d); elseif (l <= -4.8e-301) tmp = Float64(Float64(0.125 * Float64(Float64(Float64(D * D) * M_m) * Float64(M_m / d))) * t_0); elseif (l <= 7e+48) tmp = Float64(Float64(-0.125 * Float64(Float64(Float64(M_m * Float64(D * M_m)) * D) / d)) * t_0); else tmp = Float64(Float64(1.0 * d) / Float64(sqrt(h) * sqrt(l))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = sqrt((h / ((l * l) * l)));
tmp = 0.0;
if (l <= -1.18e-17)
tmp = -sqrt((1.0 / (l * h))) * d;
elseif (l <= -4.8e-301)
tmp = (0.125 * (((D * D) * M_m) * (M_m / d))) * t_0;
elseif (l <= 7e+48)
tmp = (-0.125 * (((M_m * (D * M_m)) * D) / d)) * t_0;
else
tmp = (1.0 * d) / (sqrt(h) * sqrt(l));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -1.18e-17], N[((-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * d), $MachinePrecision], If[LessEqual[l, -4.8e-301], N[(N[(0.125 * N[(N[(N[(D * D), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[l, 7e+48], N[(N[(-0.125 * N[(N[(N[(M$95$m * N[(D * M$95$m), $MachinePrecision]), $MachinePrecision] * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(1.0 * d), $MachinePrecision] / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\
\mathbf{if}\;\ell \leq -1.18 \cdot 10^{-17}:\\
\;\;\;\;\left(-\sqrt{\frac{1}{\ell \cdot h}}\right) \cdot d\\
\mathbf{elif}\;\ell \leq -4.8 \cdot 10^{-301}:\\
\;\;\;\;\left(0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot M\_m\right) \cdot \frac{M\_m}{d}\right)\right) \cdot t\_0\\
\mathbf{elif}\;\ell \leq 7 \cdot 10^{+48}:\\
\;\;\;\;\left(-0.125 \cdot \frac{\left(M\_m \cdot \left(D \cdot M\_m\right)\right) \cdot D}{d}\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if l < -1.18000000000000004e-17Initial program 60.8%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites1.4%
Taylor expanded in l 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-*.f6449.6
Applied rewrites49.6%
if -1.18000000000000004e-17 < l < -4.79999999999999982e-301Initial program 72.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 rewrites76.2%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6476.2
Applied rewrites76.2%
Taylor expanded in h around -inf
Applied rewrites46.2%
Taylor expanded in d around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-/l*N/A
unpow2N/A
associate-*r/N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-/.f64N/A
pow3N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-sqrt.f6444.5
Applied rewrites44.5%
if -4.79999999999999982e-301 < l < 6.9999999999999995e48Initial program 74.3%
Taylor expanded in l around inf
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites43.7%
Taylor expanded in d around 0
associate-*r*N/A
lower-*.f64N/A
Applied rewrites46.6%
if 6.9999999999999995e48 < l Initial program 58.0%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6452.3
Applied rewrites52.3%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
*-commutativeN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6452.2
Applied rewrites52.2%
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-*.f6452.3
Applied rewrites52.3%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6463.9
Applied rewrites63.9%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* (* (* D D) M_m) (/ M_m d))) (t_1 (sqrt (/ h (* (* l l) l)))))
(if (<= l -1.18e-17)
(* (- (sqrt (/ 1.0 (* l h)))) d)
(if (<= l -4.8e-301)
(* (* 0.125 t_0) t_1)
(if (<= l 4.5e+48)
(* (* -0.125 t_0) t_1)
(/ (* 1.0 d) (* (sqrt h) (sqrt l))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = ((D * D) * M_m) * (M_m / d);
double t_1 = sqrt((h / ((l * l) * l)));
double tmp;
if (l <= -1.18e-17) {
tmp = -sqrt((1.0 / (l * h))) * d;
} else if (l <= -4.8e-301) {
tmp = (0.125 * t_0) * t_1;
} else if (l <= 4.5e+48) {
tmp = (-0.125 * t_0) * t_1;
} else {
tmp = (1.0 * d) / (sqrt(h) * sqrt(l));
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((d_1 * d_1) * m_m) * (m_m / d)
t_1 = sqrt((h / ((l * l) * l)))
if (l <= (-1.18d-17)) then
tmp = -sqrt((1.0d0 / (l * h))) * d
else if (l <= (-4.8d-301)) then
tmp = (0.125d0 * t_0) * t_1
else if (l <= 4.5d+48) then
tmp = ((-0.125d0) * t_0) * t_1
else
tmp = (1.0d0 * d) / (sqrt(h) * sqrt(l))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = ((D * D) * M_m) * (M_m / d);
double t_1 = Math.sqrt((h / ((l * l) * l)));
double tmp;
if (l <= -1.18e-17) {
tmp = -Math.sqrt((1.0 / (l * h))) * d;
} else if (l <= -4.8e-301) {
tmp = (0.125 * t_0) * t_1;
} else if (l <= 4.5e+48) {
tmp = (-0.125 * t_0) * t_1;
} else {
tmp = (1.0 * d) / (Math.sqrt(h) * Math.sqrt(l));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = ((D * D) * M_m) * (M_m / d) t_1 = math.sqrt((h / ((l * l) * l))) tmp = 0 if l <= -1.18e-17: tmp = -math.sqrt((1.0 / (l * h))) * d elif l <= -4.8e-301: tmp = (0.125 * t_0) * t_1 elif l <= 4.5e+48: tmp = (-0.125 * t_0) * t_1 else: tmp = (1.0 * d) / (math.sqrt(h) * math.sqrt(l)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64(Float64(D * D) * M_m) * Float64(M_m / d)) t_1 = sqrt(Float64(h / Float64(Float64(l * l) * l))) tmp = 0.0 if (l <= -1.18e-17) tmp = Float64(Float64(-sqrt(Float64(1.0 / Float64(l * h)))) * d); elseif (l <= -4.8e-301) tmp = Float64(Float64(0.125 * t_0) * t_1); elseif (l <= 4.5e+48) tmp = Float64(Float64(-0.125 * t_0) * t_1); else tmp = Float64(Float64(1.0 * d) / Float64(sqrt(h) * sqrt(l))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = ((D * D) * M_m) * (M_m / d);
t_1 = sqrt((h / ((l * l) * l)));
tmp = 0.0;
if (l <= -1.18e-17)
tmp = -sqrt((1.0 / (l * h))) * d;
elseif (l <= -4.8e-301)
tmp = (0.125 * t_0) * t_1;
elseif (l <= 4.5e+48)
tmp = (-0.125 * t_0) * t_1;
else
tmp = (1.0 * d) / (sqrt(h) * sqrt(l));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(N[(D * D), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -1.18e-17], N[((-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * d), $MachinePrecision], If[LessEqual[l, -4.8e-301], N[(N[(0.125 * t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[l, 4.5e+48], N[(N[(-0.125 * t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(1.0 * d), $MachinePrecision] / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \left(\left(D \cdot D\right) \cdot M\_m\right) \cdot \frac{M\_m}{d}\\
t_1 := \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\
\mathbf{if}\;\ell \leq -1.18 \cdot 10^{-17}:\\
\;\;\;\;\left(-\sqrt{\frac{1}{\ell \cdot h}}\right) \cdot d\\
\mathbf{elif}\;\ell \leq -4.8 \cdot 10^{-301}:\\
\;\;\;\;\left(0.125 \cdot t\_0\right) \cdot t\_1\\
\mathbf{elif}\;\ell \leq 4.5 \cdot 10^{+48}:\\
\;\;\;\;\left(-0.125 \cdot t\_0\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if l < -1.18000000000000004e-17Initial program 60.8%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites1.4%
Taylor expanded in l 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-*.f6449.6
Applied rewrites49.6%
if -1.18000000000000004e-17 < l < -4.79999999999999982e-301Initial program 72.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 rewrites76.2%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6476.2
Applied rewrites76.2%
Taylor expanded in h around -inf
Applied rewrites46.2%
Taylor expanded in d around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-/l*N/A
unpow2N/A
associate-*r/N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-/.f64N/A
pow3N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-sqrt.f6444.5
Applied rewrites44.5%
if -4.79999999999999982e-301 < l < 4.49999999999999995e48Initial program 74.4%
Taylor expanded in l around inf
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites43.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6446.1
Applied rewrites46.1%
Taylor expanded in d around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-/l*N/A
unpow2N/A
associate-*r/N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-/.f64N/A
pow3N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
Applied rewrites43.8%
if 4.49999999999999995e48 < l Initial program 58.0%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6452.2
Applied rewrites52.2%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
*-commutativeN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6452.1
Applied rewrites52.1%
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-*.f6452.2
Applied rewrites52.2%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6463.8
Applied rewrites63.8%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<= d -9.5e-33)
(* (- (sqrt (/ 1.0 (* l h)))) d)
(if (<= d -5e-310)
(* (* 0.125 (* (* (* D D) M_m) (/ M_m d))) (sqrt (/ h (* (* l l) l))))
(/ (* 1.0 d) (* (sqrt h) (sqrt l))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (d <= -9.5e-33) {
tmp = -sqrt((1.0 / (l * h))) * d;
} else if (d <= -5e-310) {
tmp = (0.125 * (((D * D) * M_m) * (M_m / d))) * sqrt((h / ((l * l) * l)));
} else {
tmp = (1.0 * d) / (sqrt(h) * sqrt(l));
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: tmp
if (d <= (-9.5d-33)) then
tmp = -sqrt((1.0d0 / (l * h))) * d
else if (d <= (-5d-310)) then
tmp = (0.125d0 * (((d_1 * d_1) * m_m) * (m_m / d))) * sqrt((h / ((l * l) * l)))
else
tmp = (1.0d0 * d) / (sqrt(h) * sqrt(l))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (d <= -9.5e-33) {
tmp = -Math.sqrt((1.0 / (l * h))) * d;
} else if (d <= -5e-310) {
tmp = (0.125 * (((D * D) * M_m) * (M_m / d))) * Math.sqrt((h / ((l * l) * l)));
} else {
tmp = (1.0 * d) / (Math.sqrt(h) * Math.sqrt(l));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if d <= -9.5e-33: tmp = -math.sqrt((1.0 / (l * h))) * d elif d <= -5e-310: tmp = (0.125 * (((D * D) * M_m) * (M_m / d))) * math.sqrt((h / ((l * l) * l))) else: tmp = (1.0 * d) / (math.sqrt(h) * math.sqrt(l)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (d <= -9.5e-33) tmp = Float64(Float64(-sqrt(Float64(1.0 / Float64(l * h)))) * d); elseif (d <= -5e-310) tmp = Float64(Float64(0.125 * Float64(Float64(Float64(D * D) * M_m) * Float64(M_m / d))) * sqrt(Float64(h / Float64(Float64(l * l) * l)))); else tmp = Float64(Float64(1.0 * d) / Float64(sqrt(h) * sqrt(l))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (d <= -9.5e-33)
tmp = -sqrt((1.0 / (l * h))) * d;
elseif (d <= -5e-310)
tmp = (0.125 * (((D * D) * M_m) * (M_m / d))) * sqrt((h / ((l * l) * l)));
else
tmp = (1.0 * d) / (sqrt(h) * sqrt(l));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[d, -9.5e-33], N[((-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * d), $MachinePrecision], If[LessEqual[d, -5e-310], N[(N[(0.125 * N[(N[(N[(D * D), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 * d), $MachinePrecision] / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -9.5 \cdot 10^{-33}:\\
\;\;\;\;\left(-\sqrt{\frac{1}{\ell \cdot h}}\right) \cdot d\\
\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(0.125 \cdot \left(\left(\left(D \cdot D\right) \cdot M\_m\right) \cdot \frac{M\_m}{d}\right)\right) \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if d < -9.50000000000000019e-33Initial program 77.3%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites0.6%
Taylor expanded in l 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-*.f6457.4
Applied rewrites57.4%
if -9.50000000000000019e-33 < d < -4.999999999999985e-310Initial program 52.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 rewrites51.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-/.f6451.8
Applied rewrites51.8%
Taylor expanded in h around -inf
Applied rewrites43.3%
Taylor expanded in d around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-/l*N/A
unpow2N/A
associate-*r/N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-/.f64N/A
pow3N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-sqrt.f6441.0
Applied rewrites41.0%
if -4.999999999999985e-310 < d Initial program 67.3%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6443.7
Applied rewrites43.7%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
*-commutativeN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6443.9
Applied rewrites43.9%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
*-commutativeN/A
lower-*.f6443.9
Applied rewrites43.9%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6451.6
Applied rewrites51.6%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l))))))
(if (<= t_0 -2e-90)
(- (* (- (* (- (sqrt (/ 1.0 (* (* (* h h) h) l)))) d)) h))
(if (<= t_0 INFINITY)
(* (sqrt (/ d h)) (sqrt (/ d l)))
(* (- (sqrt (/ 1.0 (* l h)))) d)))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -2e-90) {
tmp = -(-(-sqrt((1.0 / (((h * h) * h) * l))) * d) * h);
} else if (t_0 <= ((double) INFINITY)) {
tmp = sqrt((d / h)) * sqrt((d / l));
} else {
tmp = -sqrt((1.0 / (l * h))) * d;
}
return tmp;
}
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -2e-90) {
tmp = -(-(-Math.sqrt((1.0 / (((h * h) * h) * l))) * d) * h);
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
} else {
tmp = -Math.sqrt((1.0 / (l * h))) * d;
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l))) tmp = 0 if t_0 <= -2e-90: tmp = -(-(-math.sqrt((1.0 / (((h * h) * h) * l))) * d) * h) elif t_0 <= math.inf: tmp = math.sqrt((d / h)) * math.sqrt((d / l)) else: tmp = -math.sqrt((1.0 / (l * h))) * d return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_0 <= -2e-90) tmp = Float64(-Float64(Float64(-Float64(Float64(-sqrt(Float64(1.0 / Float64(Float64(Float64(h * h) * h) * l)))) * d)) * h)); elseif (t_0 <= Inf) tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))); else tmp = Float64(Float64(-sqrt(Float64(1.0 / Float64(l * h)))) * d); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D) / (2.0 * d)) ^ 2.0)) * (h / l)));
tmp = 0.0;
if (t_0 <= -2e-90)
tmp = -(-(-sqrt((1.0 / (((h * h) * h) * l))) * d) * h);
elseif (t_0 <= Inf)
tmp = sqrt((d / h)) * sqrt((d / l));
else
tmp = -sqrt((1.0 / (l * h))) * d;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e-90], (-N[((-N[((-N[Sqrt[N[(1.0 / N[(N[(N[(h * h), $MachinePrecision] * h), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * d), $MachinePrecision]) * h), $MachinePrecision]), If[LessEqual[t$95$0, Infinity], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * d), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_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\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-90}:\\
\;\;\;\;-\left(-\left(-\sqrt{\frac{1}{\left(\left(h \cdot h\right) \cdot h\right) \cdot \ell}}\right) \cdot d\right) \cdot h\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\left(-\sqrt{\frac{1}{\ell \cdot h}}\right) \cdot d\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -1.99999999999999999e-90Initial program 86.5%
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6443.5
Applied rewrites43.5%
Taylor expanded in h around -inf
Applied rewrites35.5%
Taylor expanded in l around -inf
mul-1-negN/A
lower-neg.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
associate-*r*N/A
mul-1-negN/A
pow3N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
Applied rewrites30.7%
if -1.99999999999999999e-90 < (*.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 78.5%
Applied rewrites77.8%
Taylor expanded in d around inf
lift-sqrt.f64N/A
lift-/.f6476.6
Applied rewrites76.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)))) Initial program 0.0%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites10.6%
Taylor expanded in l 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-*.f6413.7
Applied rewrites13.7%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (if (<= l 4.4e-283) (* (- (sqrt (/ 1.0 (* l h)))) d) (/ (* 1.0 d) (* (sqrt h) (sqrt l)))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= 4.4e-283) {
tmp = -sqrt((1.0 / (l * h))) * d;
} else {
tmp = (1.0 * d) / (sqrt(h) * sqrt(l));
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: tmp
if (l <= 4.4d-283) then
tmp = -sqrt((1.0d0 / (l * h))) * d
else
tmp = (1.0d0 * d) / (sqrt(h) * sqrt(l))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= 4.4e-283) {
tmp = -Math.sqrt((1.0 / (l * h))) * d;
} else {
tmp = (1.0 * d) / (Math.sqrt(h) * Math.sqrt(l));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if l <= 4.4e-283: tmp = -math.sqrt((1.0 / (l * h))) * d else: tmp = (1.0 * d) / (math.sqrt(h) * math.sqrt(l)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (l <= 4.4e-283) tmp = Float64(Float64(-sqrt(Float64(1.0 / Float64(l * h)))) * d); else tmp = Float64(Float64(1.0 * d) / Float64(sqrt(h) * sqrt(l))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (l <= 4.4e-283)
tmp = -sqrt((1.0 / (l * h))) * d;
else
tmp = (1.0 * d) / (sqrt(h) * sqrt(l));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[l, 4.4e-283], N[((-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * d), $MachinePrecision], N[(N[(1.0 * d), $MachinePrecision] / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 4.4 \cdot 10^{-283}:\\
\;\;\;\;\left(-\sqrt{\frac{1}{\ell \cdot h}}\right) \cdot d\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot d}{\sqrt{h} \cdot \sqrt{\ell}}\\
\end{array}
\end{array}
if l < 4.3999999999999996e-283Initial program 66.4%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites1.3%
Taylor expanded in l 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-*.f6442.4
Applied rewrites42.4%
if 4.3999999999999996e-283 < l Initial program 67.2%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6444.5
Applied rewrites44.5%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
*-commutativeN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6444.7
Applied rewrites44.7%
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-*.f6444.8
Applied rewrites44.8%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6452.3
Applied rewrites52.3%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (if (<= l 4.4e-283) (* (- (sqrt (/ 1.0 (* l h)))) d) (* (/ 1.0 (* (sqrt l) (sqrt h))) d)))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= 4.4e-283) {
tmp = -sqrt((1.0 / (l * h))) * d;
} else {
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: tmp
if (l <= 4.4d-283) then
tmp = -sqrt((1.0d0 / (l * h))) * d
else
tmp = (1.0d0 / (sqrt(l) * sqrt(h))) * d
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= 4.4e-283) {
tmp = -Math.sqrt((1.0 / (l * h))) * d;
} else {
tmp = (1.0 / (Math.sqrt(l) * Math.sqrt(h))) * d;
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if l <= 4.4e-283: tmp = -math.sqrt((1.0 / (l * h))) * d else: tmp = (1.0 / (math.sqrt(l) * math.sqrt(h))) * d return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (l <= 4.4e-283) 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
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (l <= 4.4e-283)
tmp = -sqrt((1.0 / (l * h))) * d;
else
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[l, 4.4e-283], N[((-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * d), $MachinePrecision], N[(N[(1.0 / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 4.4 \cdot 10^{-283}:\\
\;\;\;\;\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 l < 4.3999999999999996e-283Initial program 66.4%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites1.3%
Taylor expanded in l 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-*.f6442.4
Applied rewrites42.4%
if 4.3999999999999996e-283 < l Initial program 67.2%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6444.5
Applied rewrites44.5%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
*-commutativeN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6444.7
Applied rewrites44.7%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6452.3
Applied rewrites52.3%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (if (<= l 7.3e-208) (* (- (sqrt (/ 1.0 (* l h)))) d) (/ d (sqrt (* h l)))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= 7.3e-208) {
tmp = -sqrt((1.0 / (l * h))) * d;
} else {
tmp = d / sqrt((h * l));
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
real(8) :: tmp
if (l <= 7.3d-208) then
tmp = -sqrt((1.0d0 / (l * h))) * d
else
tmp = d / sqrt((h * l))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= 7.3e-208) {
tmp = -Math.sqrt((1.0 / (l * h))) * d;
} else {
tmp = d / Math.sqrt((h * l));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if l <= 7.3e-208: tmp = -math.sqrt((1.0 / (l * h))) * d else: tmp = d / math.sqrt((h * l)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (l <= 7.3e-208) tmp = Float64(Float64(-sqrt(Float64(1.0 / Float64(l * h)))) * d); else tmp = Float64(d / sqrt(Float64(h * l))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (l <= 7.3e-208)
tmp = -sqrt((1.0 / (l * h))) * d;
else
tmp = d / sqrt((h * l));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[l, 7.3e-208], N[((-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * d), $MachinePrecision], N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 7.3 \cdot 10^{-208}:\\
\;\;\;\;\left(-\sqrt{\frac{1}{\ell \cdot h}}\right) \cdot d\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\
\end{array}
\end{array}
if l < 7.30000000000000002e-208Initial program 67.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites3.6%
Taylor expanded in l 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-*.f6440.3
Applied rewrites40.3%
if 7.30000000000000002e-208 < l Initial program 66.3%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6446.8
Applied rewrites46.8%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
*-commutativeN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6446.9
Applied rewrites46.9%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
*-commutativeN/A
lower-*.f6447.0
Applied rewrites47.0%
lift-*.f64N/A
*-lft-identity47.0
Applied rewrites47.0%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (* (sqrt (/ 1.0 (* l h))) d))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
return sqrt((1.0 / (l * h))) * d;
}
M_m = private
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
code = sqrt((1.0d0 / (l * h))) * d
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
return Math.sqrt((1.0 / (l * h))) * d;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): return math.sqrt((1.0 / (l * h))) * d
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) return Float64(sqrt(Float64(1.0 / Float64(l * h))) * d) end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp = code(d, h, l, M_m, D)
tmp = sqrt((1.0 / (l * h))) * d;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\sqrt{\frac{1}{\ell \cdot h}} \cdot d
\end{array}
Initial program 66.8%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6426.3
Applied rewrites26.3%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (/ d (sqrt (* h l))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
return d / sqrt((h * l));
}
M_m = private
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_1
code = d / sqrt((h * l))
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
return d / Math.sqrt((h * l));
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): return d / math.sqrt((h * l))
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) return Float64(d / sqrt(Float64(h * l))) end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp = code(d, h, l, M_m, D)
tmp = d / sqrt((h * l));
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\frac{d}{\sqrt{h \cdot \ell}}
\end{array}
Initial program 66.8%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6426.3
Applied rewrites26.3%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
*-commutativeN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6426.2
Applied rewrites26.2%
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.2
Applied rewrites26.2%
lift-*.f64N/A
*-lft-identity26.2
Applied rewrites26.2%
herbie shell --seed 2025112
(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)))))