
(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 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (* l h)))
(t_1 (* (/ D_m (+ d_m d_m)) M_m))
(t_2
(fma
(/ (* (* M_m (* M_m h)) (* D_m D_m)) (* (* t_0 l) d_m))
-0.125
(/ d_m t_0))))
(if (<= h -5e+105)
t_2
(if (<= h 5.7e+175)
(* (/ (fabs d_m) t_0) (- 1.0 (* (* (* 0.5 t_1) t_1) (/ h l))))
t_2))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((l * h));
double t_1 = (D_m / (d_m + d_m)) * M_m;
double t_2 = fma((((M_m * (M_m * h)) * (D_m * D_m)) / ((t_0 * l) * d_m)), -0.125, (d_m / t_0));
double tmp;
if (h <= -5e+105) {
tmp = t_2;
} else if (h <= 5.7e+175) {
tmp = (fabs(d_m) / t_0) * (1.0 - (((0.5 * t_1) * t_1) * (h / l)));
} else {
tmp = t_2;
}
return tmp;
}
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = sqrt(Float64(l * h)) t_1 = Float64(Float64(D_m / Float64(d_m + d_m)) * M_m) t_2 = fma(Float64(Float64(Float64(M_m * Float64(M_m * h)) * Float64(D_m * D_m)) / Float64(Float64(t_0 * l) * d_m)), -0.125, Float64(d_m / t_0)) tmp = 0.0 if (h <= -5e+105) tmp = t_2; elseif (h <= 5.7e+175) tmp = Float64(Float64(abs(d_m) / t_0) * Float64(1.0 - Float64(Float64(Float64(0.5 * t_1) * t_1) * Float64(h / l)))); else tmp = t_2; end return tmp end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(D$95$m / N[(d$95$m + d$95$m), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(M$95$m * N[(M$95$m * h), $MachinePrecision]), $MachinePrecision] * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(t$95$0 * l), $MachinePrecision] * d$95$m), $MachinePrecision]), $MachinePrecision] * -0.125 + N[(d$95$m / t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -5e+105], t$95$2, If[LessEqual[h, 5.7e+175], N[(N[(N[Abs[d$95$m], $MachinePrecision] / t$95$0), $MachinePrecision] * N[(1.0 - N[(N[(N[(0.5 * t$95$1), $MachinePrecision] * t$95$1), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
t_1 := \frac{D\_m}{d\_m + d\_m} \cdot M\_m\\
t_2 := \mathsf{fma}\left(\frac{\left(M\_m \cdot \left(M\_m \cdot h\right)\right) \cdot \left(D\_m \cdot D\_m\right)}{\left(t\_0 \cdot \ell\right) \cdot d\_m}, -0.125, \frac{d\_m}{t\_0}\right)\\
\mathbf{if}\;h \leq -5 \cdot 10^{+105}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;h \leq 5.7 \cdot 10^{+175}:\\
\;\;\;\;\frac{\left|d\_m\right|}{t\_0} \cdot \left(1 - \left(\left(0.5 \cdot t\_1\right) \cdot t\_1\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if h < -5.00000000000000046e105 or 5.70000000000000024e175 < h Initial program 36.2%
Taylor expanded in l around inf
Applied rewrites27.1%
Taylor expanded in h around 0
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites50.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6452.4
Applied rewrites52.4%
if -5.00000000000000046e105 < h < 5.70000000000000024e175Initial program 36.2%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
frac-timesN/A
unpow2N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6443.0
Applied rewrites43.0%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
pow2N/A
sqrt-divN/A
pow1/2N/A
metadata-evalN/A
sqrt-unprodN/A
lower-/.f64N/A
metadata-evalN/A
pow1/2N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f6469.9
Applied rewrites69.9%
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
count-2-revN/A
lower-+.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
count-2-revN/A
lower-+.f6469.1
Applied rewrites69.1%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
metadata-eval69.1
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-+.f6469.1
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-+.f6469.1
Applied rewrites69.1%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (* l h))))
(if (<= l -5e-146)
(fma
(/ (/ (* (* (* (* M_m M_m) h) D_m) D_m) d_m) (* (sqrt (* h l)) l))
-0.125
(/ d_m t_0))
(if (<= l 6e-115)
(*
(/ (fabs d_m) t_0)
(fma
(* (/ (* (* D_m M_m) (* D_m M_m)) (* (* d_m d_m) l)) -0.125)
h
1.0))
(fma
(* (* (/ (* M_m M_m) (* (* l d_m) (sqrt (* (/ 1.0 h) l)))) -0.125) D_m)
D_m
(/ d_m (* (sqrt l) (sqrt h))))))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((l * h));
double tmp;
if (l <= -5e-146) {
tmp = fma(((((((M_m * M_m) * h) * D_m) * D_m) / d_m) / (sqrt((h * l)) * l)), -0.125, (d_m / t_0));
} else if (l <= 6e-115) {
tmp = (fabs(d_m) / t_0) * fma(((((D_m * M_m) * (D_m * M_m)) / ((d_m * d_m) * l)) * -0.125), h, 1.0);
} else {
tmp = fma(((((M_m * M_m) / ((l * d_m) * sqrt(((1.0 / h) * l)))) * -0.125) * D_m), D_m, (d_m / (sqrt(l) * sqrt(h))));
}
return tmp;
}
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = sqrt(Float64(l * h)) tmp = 0.0 if (l <= -5e-146) tmp = fma(Float64(Float64(Float64(Float64(Float64(Float64(M_m * M_m) * h) * D_m) * D_m) / d_m) / Float64(sqrt(Float64(h * l)) * l)), -0.125, Float64(d_m / t_0)); elseif (l <= 6e-115) tmp = Float64(Float64(abs(d_m) / t_0) * fma(Float64(Float64(Float64(Float64(D_m * M_m) * Float64(D_m * M_m)) / Float64(Float64(d_m * d_m) * l)) * -0.125), h, 1.0)); else tmp = fma(Float64(Float64(Float64(Float64(M_m * M_m) / Float64(Float64(l * d_m) * sqrt(Float64(Float64(1.0 / h) * l)))) * -0.125) * D_m), D_m, Float64(d_m / Float64(sqrt(l) * sqrt(h)))); end return tmp end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -5e-146], N[(N[(N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] / d$95$m), $MachinePrecision] / N[(N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * -0.125 + N[(d$95$m / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6e-115], N[(N[(N[Abs[d$95$m], $MachinePrecision] / t$95$0), $MachinePrecision] * N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(d$95$m * d$95$m), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * h + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] / N[(N[(l * d$95$m), $MachinePrecision] * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m + N[(d$95$m / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;\ell \leq -5 \cdot 10^{-146}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{\left(\left(\left(M\_m \cdot M\_m\right) \cdot h\right) \cdot D\_m\right) \cdot D\_m}{d\_m}}{\sqrt{h \cdot \ell} \cdot \ell}, -0.125, \frac{d\_m}{t\_0}\right)\\
\mathbf{elif}\;\ell \leq 6 \cdot 10^{-115}:\\
\;\;\;\;\frac{\left|d\_m\right|}{t\_0} \cdot \mathsf{fma}\left(\frac{\left(D\_m \cdot M\_m\right) \cdot \left(D\_m \cdot M\_m\right)}{\left(d\_m \cdot d\_m\right) \cdot \ell} \cdot -0.125, h, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{M\_m \cdot M\_m}{\left(\ell \cdot d\_m\right) \cdot \sqrt{\frac{1}{h} \cdot \ell}} \cdot -0.125\right) \cdot D\_m, D\_m, \frac{d\_m}{\sqrt{\ell} \cdot \sqrt{h}}\right)\\
\end{array}
\end{array}
if l < -4.99999999999999957e-146Initial program 36.2%
Taylor expanded in l around inf
Applied rewrites27.1%
Taylor expanded in h around 0
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites50.2%
Applied rewrites59.9%
if -4.99999999999999957e-146 < l < 6.0000000000000003e-115Initial program 36.2%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
frac-timesN/A
unpow2N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6443.0
Applied rewrites43.0%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
pow2N/A
sqrt-divN/A
pow1/2N/A
metadata-evalN/A
sqrt-unprodN/A
lower-/.f64N/A
metadata-evalN/A
pow1/2N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f6469.9
Applied rewrites69.9%
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
count-2-revN/A
lower-+.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
count-2-revN/A
lower-+.f6469.1
Applied rewrites69.1%
Taylor expanded in h around inf
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
distribute-rgt-inN/A
inv-powN/A
pow-plusN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
Applied rewrites60.1%
if 6.0000000000000003e-115 < l Initial program 36.2%
Taylor expanded in l around inf
Applied rewrites27.1%
Taylor expanded in h around inf
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6438.1
Applied rewrites38.1%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (* l h))))
(if (<= l -5e-146)
(fma
(/ (/ (* (* (* (* M_m M_m) h) D_m) D_m) d_m) (* (sqrt (* h l)) l))
-0.125
(/ d_m t_0))
(if (<= l 6e-115)
(*
(/ (fabs d_m) t_0)
(fma
(* (/ (* (* D_m M_m) (* D_m M_m)) (* (* d_m d_m) l)) -0.125)
h
1.0))
(fma
(* (* (/ (* M_m M_m) (* (* (sqrt (/ l h)) l) d_m)) -0.125) D_m)
D_m
(/ d_m (* (sqrt l) (sqrt h))))))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((l * h));
double tmp;
if (l <= -5e-146) {
tmp = fma(((((((M_m * M_m) * h) * D_m) * D_m) / d_m) / (sqrt((h * l)) * l)), -0.125, (d_m / t_0));
} else if (l <= 6e-115) {
tmp = (fabs(d_m) / t_0) * fma(((((D_m * M_m) * (D_m * M_m)) / ((d_m * d_m) * l)) * -0.125), h, 1.0);
} else {
tmp = fma(((((M_m * M_m) / ((sqrt((l / h)) * l) * d_m)) * -0.125) * D_m), D_m, (d_m / (sqrt(l) * sqrt(h))));
}
return tmp;
}
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = sqrt(Float64(l * h)) tmp = 0.0 if (l <= -5e-146) tmp = fma(Float64(Float64(Float64(Float64(Float64(Float64(M_m * M_m) * h) * D_m) * D_m) / d_m) / Float64(sqrt(Float64(h * l)) * l)), -0.125, Float64(d_m / t_0)); elseif (l <= 6e-115) tmp = Float64(Float64(abs(d_m) / t_0) * fma(Float64(Float64(Float64(Float64(D_m * M_m) * Float64(D_m * M_m)) / Float64(Float64(d_m * d_m) * l)) * -0.125), h, 1.0)); else tmp = fma(Float64(Float64(Float64(Float64(M_m * M_m) / Float64(Float64(sqrt(Float64(l / h)) * l) * d_m)) * -0.125) * D_m), D_m, Float64(d_m / Float64(sqrt(l) * sqrt(h)))); end return tmp end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -5e-146], N[(N[(N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] / d$95$m), $MachinePrecision] / N[(N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * -0.125 + N[(d$95$m / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6e-115], N[(N[(N[Abs[d$95$m], $MachinePrecision] / t$95$0), $MachinePrecision] * N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(d$95$m * d$95$m), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * h + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] / N[(N[(N[Sqrt[N[(l / h), $MachinePrecision]], $MachinePrecision] * l), $MachinePrecision] * d$95$m), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m + N[(d$95$m / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;\ell \leq -5 \cdot 10^{-146}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{\left(\left(\left(M\_m \cdot M\_m\right) \cdot h\right) \cdot D\_m\right) \cdot D\_m}{d\_m}}{\sqrt{h \cdot \ell} \cdot \ell}, -0.125, \frac{d\_m}{t\_0}\right)\\
\mathbf{elif}\;\ell \leq 6 \cdot 10^{-115}:\\
\;\;\;\;\frac{\left|d\_m\right|}{t\_0} \cdot \mathsf{fma}\left(\frac{\left(D\_m \cdot M\_m\right) \cdot \left(D\_m \cdot M\_m\right)}{\left(d\_m \cdot d\_m\right) \cdot \ell} \cdot -0.125, h, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{M\_m \cdot M\_m}{\left(\sqrt{\frac{\ell}{h}} \cdot \ell\right) \cdot d\_m} \cdot -0.125\right) \cdot D\_m, D\_m, \frac{d\_m}{\sqrt{\ell} \cdot \sqrt{h}}\right)\\
\end{array}
\end{array}
if l < -4.99999999999999957e-146Initial program 36.2%
Taylor expanded in l around inf
Applied rewrites27.1%
Taylor expanded in h around 0
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites50.2%
Applied rewrites59.9%
if -4.99999999999999957e-146 < l < 6.0000000000000003e-115Initial program 36.2%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
frac-timesN/A
unpow2N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6443.0
Applied rewrites43.0%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
pow2N/A
sqrt-divN/A
pow1/2N/A
metadata-evalN/A
sqrt-unprodN/A
lower-/.f64N/A
metadata-evalN/A
pow1/2N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f6469.9
Applied rewrites69.9%
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
count-2-revN/A
lower-+.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
count-2-revN/A
lower-+.f6469.1
Applied rewrites69.1%
Taylor expanded in h around inf
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
distribute-rgt-inN/A
inv-powN/A
pow-plusN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
Applied rewrites60.1%
if 6.0000000000000003e-115 < l Initial program 36.2%
Taylor expanded in l around inf
Applied rewrites27.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
associate-/l*N/A
lower-*.f64N/A
Applied rewrites27.8%
Taylor expanded in h around inf
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6436.9
Applied rewrites36.9%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (* h l))))
(if (<= (* M_m D_m) 2e-131)
(/ d_m t_0)
(if (<= (* M_m D_m) 2e+152)
(*
(/ (fabs d_m) (sqrt (* l h)))
(fma
(* (/ (* (* D_m M_m) (* D_m M_m)) (* (* d_m d_m) l)) -0.125)
h
1.0))
(* (* (* (* D_m (* M_m M_m)) h) (/ D_m (* (* l d_m) t_0))) -0.125)))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((h * l));
double tmp;
if ((M_m * D_m) <= 2e-131) {
tmp = d_m / t_0;
} else if ((M_m * D_m) <= 2e+152) {
tmp = (fabs(d_m) / sqrt((l * h))) * fma(((((D_m * M_m) * (D_m * M_m)) / ((d_m * d_m) * l)) * -0.125), h, 1.0);
} else {
tmp = (((D_m * (M_m * M_m)) * h) * (D_m / ((l * d_m) * t_0))) * -0.125;
}
return tmp;
}
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = sqrt(Float64(h * l)) tmp = 0.0 if (Float64(M_m * D_m) <= 2e-131) tmp = Float64(d_m / t_0); elseif (Float64(M_m * D_m) <= 2e+152) tmp = Float64(Float64(abs(d_m) / sqrt(Float64(l * h))) * fma(Float64(Float64(Float64(Float64(D_m * M_m) * Float64(D_m * M_m)) / Float64(Float64(d_m * d_m) * l)) * -0.125), h, 1.0)); else tmp = Float64(Float64(Float64(Float64(D_m * Float64(M_m * M_m)) * h) * Float64(D_m / Float64(Float64(l * d_m) * t_0))) * -0.125); end return tmp end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 2e-131], N[(d$95$m / t$95$0), $MachinePrecision], If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 2e+152], N[(N[(N[Abs[d$95$m], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(d$95$m * d$95$m), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * h + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(D$95$m * N[(M$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] * N[(D$95$m / N[(N[(l * d$95$m), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{h \cdot \ell}\\
\mathbf{if}\;M\_m \cdot D\_m \leq 2 \cdot 10^{-131}:\\
\;\;\;\;\frac{d\_m}{t\_0}\\
\mathbf{elif}\;M\_m \cdot D\_m \leq 2 \cdot 10^{+152}:\\
\;\;\;\;\frac{\left|d\_m\right|}{\sqrt{\ell \cdot h}} \cdot \mathsf{fma}\left(\frac{\left(D\_m \cdot M\_m\right) \cdot \left(D\_m \cdot M\_m\right)}{\left(d\_m \cdot d\_m\right) \cdot \ell} \cdot -0.125, h, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(D\_m \cdot \left(M\_m \cdot M\_m\right)\right) \cdot h\right) \cdot \frac{D\_m}{\left(\ell \cdot d\_m\right) \cdot t\_0}\right) \cdot -0.125\\
\end{array}
\end{array}
if (*.f64 M D) < 2e-131Initial program 36.2%
Taylor expanded in l around inf
Applied rewrites27.1%
Taylor expanded in h around 0
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites50.2%
Taylor expanded in d around 0
Applied rewrites31.2%
Taylor expanded in d around inf
sqrt-prodN/A
lower-/.f64N/A
lift-sqrt.f64N/A
lift-*.f6443.0
Applied rewrites43.0%
if 2e-131 < (*.f64 M D) < 2.0000000000000001e152Initial program 36.2%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
frac-timesN/A
unpow2N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6443.0
Applied rewrites43.0%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
pow2N/A
sqrt-divN/A
pow1/2N/A
metadata-evalN/A
sqrt-unprodN/A
lower-/.f64N/A
metadata-evalN/A
pow1/2N/A
pow2N/A
rem-sqrt-square-revN/A
lower-fabs.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f6469.9
Applied rewrites69.9%
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
count-2-revN/A
lower-+.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
count-2-revN/A
lower-+.f6469.1
Applied rewrites69.1%
Taylor expanded in h around inf
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
distribute-rgt-inN/A
inv-powN/A
pow-plusN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
Applied rewrites60.1%
if 2.0000000000000001e152 < (*.f64 M D) Initial program 36.2%
Taylor expanded in l around inf
Applied rewrites27.1%
Taylor expanded in h around 0
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites50.2%
Taylor expanded in d around 0
Applied rewrites31.2%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
Applied rewrites33.0%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (* h l))))
(if (<= (* M_m D_m) 5e-61)
(/ d_m t_0)
(* (/ (* (* (* D_m M_m) (* D_m M_m)) h) (* (* l d_m) t_0)) -0.125))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((h * l));
double tmp;
if ((M_m * D_m) <= 5e-61) {
tmp = d_m / t_0;
} else {
tmp = ((((D_m * M_m) * (D_m * M_m)) * h) / ((l * d_m) * t_0)) * -0.125;
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((h * l))
if ((m_m * d_m_1) <= 5d-61) then
tmp = d_m / t_0
else
tmp = ((((d_m_1 * m_m) * (d_m_1 * m_m)) * h) / ((l * d_m) * t_0)) * (-0.125d0)
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = Math.sqrt((h * l));
double tmp;
if ((M_m * D_m) <= 5e-61) {
tmp = d_m / t_0;
} else {
tmp = ((((D_m * M_m) * (D_m * M_m)) * h) / ((l * d_m) * t_0)) * -0.125;
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): t_0 = math.sqrt((h * l)) tmp = 0 if (M_m * D_m) <= 5e-61: tmp = d_m / t_0 else: tmp = ((((D_m * M_m) * (D_m * M_m)) * h) / ((l * d_m) * t_0)) * -0.125 return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = sqrt(Float64(h * l)) tmp = 0.0 if (Float64(M_m * D_m) <= 5e-61) tmp = Float64(d_m / t_0); else tmp = Float64(Float64(Float64(Float64(Float64(D_m * M_m) * Float64(D_m * M_m)) * h) / Float64(Float64(l * d_m) * t_0)) * -0.125); end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
t_0 = sqrt((h * l));
tmp = 0.0;
if ((M_m * D_m) <= 5e-61)
tmp = d_m / t_0;
else
tmp = ((((D_m * M_m) * (D_m * M_m)) * h) / ((l * d_m) * t_0)) * -0.125;
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 5e-61], N[(d$95$m / t$95$0), $MachinePrecision], N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] / N[(N[(l * d$95$m), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{h \cdot \ell}\\
\mathbf{if}\;M\_m \cdot D\_m \leq 5 \cdot 10^{-61}:\\
\;\;\;\;\frac{d\_m}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(D\_m \cdot M\_m\right) \cdot \left(D\_m \cdot M\_m\right)\right) \cdot h}{\left(\ell \cdot d\_m\right) \cdot t\_0} \cdot -0.125\\
\end{array}
\end{array}
if (*.f64 M D) < 4.9999999999999999e-61Initial program 36.2%
Taylor expanded in l around inf
Applied rewrites27.1%
Taylor expanded in h around 0
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites50.2%
Taylor expanded in d around 0
Applied rewrites31.2%
Taylor expanded in d around inf
sqrt-prodN/A
lower-/.f64N/A
lift-sqrt.f64N/A
lift-*.f6443.0
Applied rewrites43.0%
if 4.9999999999999999e-61 < (*.f64 M D) Initial program 36.2%
Taylor expanded in l around inf
Applied rewrites27.1%
Taylor expanded in h around 0
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites50.2%
Taylor expanded in d around 0
Applied rewrites31.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
pow-prod-downN/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6438.0
Applied rewrites38.0%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (* h l))))
(if (<= (* M_m D_m) 5e+67)
(/ d_m t_0)
(* (* (* (* D_m (* M_m M_m)) h) (/ D_m (* (* l d_m) t_0))) -0.125))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((h * l));
double tmp;
if ((M_m * D_m) <= 5e+67) {
tmp = d_m / t_0;
} else {
tmp = (((D_m * (M_m * M_m)) * h) * (D_m / ((l * d_m) * t_0))) * -0.125;
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((h * l))
if ((m_m * d_m_1) <= 5d+67) then
tmp = d_m / t_0
else
tmp = (((d_m_1 * (m_m * m_m)) * h) * (d_m_1 / ((l * d_m) * t_0))) * (-0.125d0)
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = Math.sqrt((h * l));
double tmp;
if ((M_m * D_m) <= 5e+67) {
tmp = d_m / t_0;
} else {
tmp = (((D_m * (M_m * M_m)) * h) * (D_m / ((l * d_m) * t_0))) * -0.125;
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): t_0 = math.sqrt((h * l)) tmp = 0 if (M_m * D_m) <= 5e+67: tmp = d_m / t_0 else: tmp = (((D_m * (M_m * M_m)) * h) * (D_m / ((l * d_m) * t_0))) * -0.125 return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = sqrt(Float64(h * l)) tmp = 0.0 if (Float64(M_m * D_m) <= 5e+67) tmp = Float64(d_m / t_0); else tmp = Float64(Float64(Float64(Float64(D_m * Float64(M_m * M_m)) * h) * Float64(D_m / Float64(Float64(l * d_m) * t_0))) * -0.125); end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
t_0 = sqrt((h * l));
tmp = 0.0;
if ((M_m * D_m) <= 5e+67)
tmp = d_m / t_0;
else
tmp = (((D_m * (M_m * M_m)) * h) * (D_m / ((l * d_m) * t_0))) * -0.125;
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 5e+67], N[(d$95$m / t$95$0), $MachinePrecision], N[(N[(N[(N[(D$95$m * N[(M$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] * N[(D$95$m / N[(N[(l * d$95$m), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{h \cdot \ell}\\
\mathbf{if}\;M\_m \cdot D\_m \leq 5 \cdot 10^{+67}:\\
\;\;\;\;\frac{d\_m}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(D\_m \cdot \left(M\_m \cdot M\_m\right)\right) \cdot h\right) \cdot \frac{D\_m}{\left(\ell \cdot d\_m\right) \cdot t\_0}\right) \cdot -0.125\\
\end{array}
\end{array}
if (*.f64 M D) < 4.99999999999999976e67Initial program 36.2%
Taylor expanded in l around inf
Applied rewrites27.1%
Taylor expanded in h around 0
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites50.2%
Taylor expanded in d around 0
Applied rewrites31.2%
Taylor expanded in d around inf
sqrt-prodN/A
lower-/.f64N/A
lift-sqrt.f64N/A
lift-*.f6443.0
Applied rewrites43.0%
if 4.99999999999999976e67 < (*.f64 M D) Initial program 36.2%
Taylor expanded in l around inf
Applied rewrites27.1%
Taylor expanded in h around 0
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites50.2%
Taylor expanded in d around 0
Applied rewrites31.2%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
Applied rewrites33.0%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (* h l))))
(if (<= M_m 1.5e-89)
(/ d_m t_0)
(* (* (* D_m D_m) (/ (* (* M_m M_m) h) (* (* l d_m) t_0))) -0.125))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((h * l));
double tmp;
if (M_m <= 1.5e-89) {
tmp = d_m / t_0;
} else {
tmp = ((D_m * D_m) * (((M_m * M_m) * h) / ((l * d_m) * t_0))) * -0.125;
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((h * l))
if (m_m <= 1.5d-89) then
tmp = d_m / t_0
else
tmp = ((d_m_1 * d_m_1) * (((m_m * m_m) * h) / ((l * d_m) * t_0))) * (-0.125d0)
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = Math.sqrt((h * l));
double tmp;
if (M_m <= 1.5e-89) {
tmp = d_m / t_0;
} else {
tmp = ((D_m * D_m) * (((M_m * M_m) * h) / ((l * d_m) * t_0))) * -0.125;
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): t_0 = math.sqrt((h * l)) tmp = 0 if M_m <= 1.5e-89: tmp = d_m / t_0 else: tmp = ((D_m * D_m) * (((M_m * M_m) * h) / ((l * d_m) * t_0))) * -0.125 return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = sqrt(Float64(h * l)) tmp = 0.0 if (M_m <= 1.5e-89) tmp = Float64(d_m / t_0); else tmp = Float64(Float64(Float64(D_m * D_m) * Float64(Float64(Float64(M_m * M_m) * h) / Float64(Float64(l * d_m) * t_0))) * -0.125); end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
t_0 = sqrt((h * l));
tmp = 0.0;
if (M_m <= 1.5e-89)
tmp = d_m / t_0;
else
tmp = ((D_m * D_m) * (((M_m * M_m) * h) / ((l * d_m) * t_0))) * -0.125;
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[M$95$m, 1.5e-89], N[(d$95$m / t$95$0), $MachinePrecision], N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] / N[(N[(l * d$95$m), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{h \cdot \ell}\\
\mathbf{if}\;M\_m \leq 1.5 \cdot 10^{-89}:\\
\;\;\;\;\frac{d\_m}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(D\_m \cdot D\_m\right) \cdot \frac{\left(M\_m \cdot M\_m\right) \cdot h}{\left(\ell \cdot d\_m\right) \cdot t\_0}\right) \cdot -0.125\\
\end{array}
\end{array}
if M < 1.5e-89Initial program 36.2%
Taylor expanded in l around inf
Applied rewrites27.1%
Taylor expanded in h around 0
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites50.2%
Taylor expanded in d around 0
Applied rewrites31.2%
Taylor expanded in d around inf
sqrt-prodN/A
lower-/.f64N/A
lift-sqrt.f64N/A
lift-*.f6443.0
Applied rewrites43.0%
if 1.5e-89 < M Initial program 36.2%
Taylor expanded in l around inf
Applied rewrites27.1%
Taylor expanded in h around 0
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites50.2%
Taylor expanded in d around 0
Applied rewrites31.2%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
associate-*l*N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
Applied rewrites30.3%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
(-
1.0
(*
(* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0))
(/ h l))))))
(if (<= t_0 -5e+77)
(* (/ (* (* D_m M_m) (* D_m M_m)) (* (* (sqrt (/ l h)) l) d_m)) -0.125)
(if (<= t_0 2e+221)
(/ (fabs d_m) (* (sqrt l) (sqrt h)))
(/ d_m (sqrt (* h l)))))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -5e+77) {
tmp = (((D_m * M_m) * (D_m * M_m)) / ((sqrt((l / h)) * l) * d_m)) * -0.125;
} else if (t_0 <= 2e+221) {
tmp = fabs(d_m) / (sqrt(l) * sqrt(h));
} else {
tmp = d_m / sqrt((h * l));
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: t_0
real(8) :: tmp
t_0 = (((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m_1) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
if (t_0 <= (-5d+77)) then
tmp = (((d_m_1 * m_m) * (d_m_1 * m_m)) / ((sqrt((l / h)) * l) * d_m)) * (-0.125d0)
else if (t_0 <= 2d+221) then
tmp = abs(d_m) / (sqrt(l) * sqrt(h))
else
tmp = d_m / sqrt((h * l))
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -5e+77) {
tmp = (((D_m * M_m) * (D_m * M_m)) / ((Math.sqrt((l / h)) * l) * d_m)) * -0.125;
} else if (t_0 <= 2e+221) {
tmp = Math.abs(d_m) / (Math.sqrt(l) * Math.sqrt(h));
} else {
tmp = d_m / Math.sqrt((h * l));
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): t_0 = (math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l))) tmp = 0 if t_0 <= -5e+77: tmp = (((D_m * M_m) * (D_m * M_m)) / ((math.sqrt((l / h)) * l) * d_m)) * -0.125 elif t_0 <= 2e+221: tmp = math.fabs(d_m) / (math.sqrt(l) * math.sqrt(h)) else: tmp = d_m / math.sqrt((h * l)) return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_0 <= -5e+77) tmp = Float64(Float64(Float64(Float64(D_m * M_m) * Float64(D_m * M_m)) / Float64(Float64(sqrt(Float64(l / h)) * l) * d_m)) * -0.125); elseif (t_0 <= 2e+221) tmp = Float64(abs(d_m) / Float64(sqrt(l) * sqrt(h))); else tmp = Float64(d_m / sqrt(Float64(h * l))); end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
t_0 = (((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d_m)) ^ 2.0)) * (h / l)));
tmp = 0.0;
if (t_0 <= -5e+77)
tmp = (((D_m * M_m) * (D_m * M_m)) / ((sqrt((l / h)) * l) * d_m)) * -0.125;
elseif (t_0 <= 2e+221)
tmp = abs(d_m) / (sqrt(l) * sqrt(h));
else
tmp = d_m / sqrt((h * l));
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+77], N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Sqrt[N[(l / h), $MachinePrecision]], $MachinePrecision] * l), $MachinePrecision] * d$95$m), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision], If[LessEqual[t$95$0, 2e+221], N[(N[Abs[d$95$m], $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d$95$m / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+77}:\\
\;\;\;\;\frac{\left(D\_m \cdot M\_m\right) \cdot \left(D\_m \cdot M\_m\right)}{\left(\sqrt{\frac{\ell}{h}} \cdot \ell\right) \cdot d\_m} \cdot -0.125\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+221}:\\
\;\;\;\;\frac{\left|d\_m\right|}{\sqrt{\ell} \cdot \sqrt{h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d\_m}{\sqrt{h \cdot \ell}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -5.00000000000000004e77Initial program 36.2%
Taylor expanded in l around inf
Applied rewrites27.1%
Taylor expanded in h around 0
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites50.2%
Taylor expanded in d around 0
Applied rewrites31.2%
Taylor expanded in h around inf
lower-/.f64N/A
pow-prod-downN/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6422.9
Applied rewrites22.9%
if -5.00000000000000004e77 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.0000000000000001e221Initial program 36.2%
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
frac-2negN/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-neg.f640.0
Applied rewrites0.0%
Taylor expanded in h around 0
Applied rewrites43.0%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lift-*.f6425.3
Applied rewrites25.3%
if 2.0000000000000001e221 < (*.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 36.2%
Taylor expanded in l around inf
Applied rewrites27.1%
Taylor expanded in h around 0
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites50.2%
Taylor expanded in d around 0
Applied rewrites31.2%
Taylor expanded in d around inf
sqrt-prodN/A
lower-/.f64N/A
lift-sqrt.f64N/A
lift-*.f6443.0
Applied rewrites43.0%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
(-
1.0
(*
(* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0))
(/ h l))))))
(if (<= t_0 -5e+77)
(* (/ (* (* M_m M_m) (* D_m D_m)) (* (* (sqrt (/ l h)) l) d_m)) -0.125)
(if (<= t_0 2e+221)
(/ (fabs d_m) (* (sqrt l) (sqrt h)))
(/ d_m (sqrt (* h l)))))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -5e+77) {
tmp = (((M_m * M_m) * (D_m * D_m)) / ((sqrt((l / h)) * l) * d_m)) * -0.125;
} else if (t_0 <= 2e+221) {
tmp = fabs(d_m) / (sqrt(l) * sqrt(h));
} else {
tmp = d_m / sqrt((h * l));
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: t_0
real(8) :: tmp
t_0 = (((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m_1) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
if (t_0 <= (-5d+77)) then
tmp = (((m_m * m_m) * (d_m_1 * d_m_1)) / ((sqrt((l / h)) * l) * d_m)) * (-0.125d0)
else if (t_0 <= 2d+221) then
tmp = abs(d_m) / (sqrt(l) * sqrt(h))
else
tmp = d_m / sqrt((h * l))
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -5e+77) {
tmp = (((M_m * M_m) * (D_m * D_m)) / ((Math.sqrt((l / h)) * l) * d_m)) * -0.125;
} else if (t_0 <= 2e+221) {
tmp = Math.abs(d_m) / (Math.sqrt(l) * Math.sqrt(h));
} else {
tmp = d_m / Math.sqrt((h * l));
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): t_0 = (math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l))) tmp = 0 if t_0 <= -5e+77: tmp = (((M_m * M_m) * (D_m * D_m)) / ((math.sqrt((l / h)) * l) * d_m)) * -0.125 elif t_0 <= 2e+221: tmp = math.fabs(d_m) / (math.sqrt(l) * math.sqrt(h)) else: tmp = d_m / math.sqrt((h * l)) return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_0 <= -5e+77) tmp = Float64(Float64(Float64(Float64(M_m * M_m) * Float64(D_m * D_m)) / Float64(Float64(sqrt(Float64(l / h)) * l) * d_m)) * -0.125); elseif (t_0 <= 2e+221) tmp = Float64(abs(d_m) / Float64(sqrt(l) * sqrt(h))); else tmp = Float64(d_m / sqrt(Float64(h * l))); end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
t_0 = (((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d_m)) ^ 2.0)) * (h / l)));
tmp = 0.0;
if (t_0 <= -5e+77)
tmp = (((M_m * M_m) * (D_m * D_m)) / ((sqrt((l / h)) * l) * d_m)) * -0.125;
elseif (t_0 <= 2e+221)
tmp = abs(d_m) / (sqrt(l) * sqrt(h));
else
tmp = d_m / sqrt((h * l));
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+77], N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Sqrt[N[(l / h), $MachinePrecision]], $MachinePrecision] * l), $MachinePrecision] * d$95$m), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision], If[LessEqual[t$95$0, 2e+221], N[(N[Abs[d$95$m], $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d$95$m / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+77}:\\
\;\;\;\;\frac{\left(M\_m \cdot M\_m\right) \cdot \left(D\_m \cdot D\_m\right)}{\left(\sqrt{\frac{\ell}{h}} \cdot \ell\right) \cdot d\_m} \cdot -0.125\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+221}:\\
\;\;\;\;\frac{\left|d\_m\right|}{\sqrt{\ell} \cdot \sqrt{h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d\_m}{\sqrt{h \cdot \ell}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -5.00000000000000004e77Initial program 36.2%
Taylor expanded in l around inf
Applied rewrites27.1%
Taylor expanded in h around 0
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites50.2%
Taylor expanded in h around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6418.7
Applied rewrites18.7%
if -5.00000000000000004e77 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.0000000000000001e221Initial program 36.2%
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
frac-2negN/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-neg.f640.0
Applied rewrites0.0%
Taylor expanded in h around 0
Applied rewrites43.0%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lift-*.f6425.3
Applied rewrites25.3%
if 2.0000000000000001e221 < (*.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 36.2%
Taylor expanded in l around inf
Applied rewrites27.1%
Taylor expanded in h around 0
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites50.2%
Taylor expanded in d around 0
Applied rewrites31.2%
Taylor expanded in d around inf
sqrt-prodN/A
lower-/.f64N/A
lift-sqrt.f64N/A
lift-*.f6443.0
Applied rewrites43.0%
d_m = (fabs.f64 d) M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d_m h l M_m D_m) :precision binary64 (if (<= (* M_m D_m) 7.5e+176) (/ d_m (sqrt (* h l))) (- (sqrt (* (/ d_m l) (/ d_m h))))))
d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double tmp;
if ((M_m * D_m) <= 7.5e+176) {
tmp = d_m / sqrt((h * l));
} else {
tmp = -sqrt(((d_m / l) * (d_m / h)));
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: tmp
if ((m_m * d_m_1) <= 7.5d+176) then
tmp = d_m / sqrt((h * l))
else
tmp = -sqrt(((d_m / l) * (d_m / h)))
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double tmp;
if ((M_m * D_m) <= 7.5e+176) {
tmp = d_m / Math.sqrt((h * l));
} else {
tmp = -Math.sqrt(((d_m / l) * (d_m / h)));
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): tmp = 0 if (M_m * D_m) <= 7.5e+176: tmp = d_m / math.sqrt((h * l)) else: tmp = -math.sqrt(((d_m / l) * (d_m / h))) return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) tmp = 0.0 if (Float64(M_m * D_m) <= 7.5e+176) tmp = Float64(d_m / sqrt(Float64(h * l))); else tmp = Float64(-sqrt(Float64(Float64(d_m / l) * Float64(d_m / h)))); end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
tmp = 0.0;
if ((M_m * D_m) <= 7.5e+176)
tmp = d_m / sqrt((h * l));
else
tmp = -sqrt(((d_m / l) * (d_m / h)));
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 7.5e+176], N[(d$95$m / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-N[Sqrt[N[(N[(d$95$m / l), $MachinePrecision] * N[(d$95$m / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \cdot D\_m \leq 7.5 \cdot 10^{+176}:\\
\;\;\;\;\frac{d\_m}{\sqrt{h \cdot \ell}}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{\frac{d\_m}{\ell} \cdot \frac{d\_m}{h}}\\
\end{array}
\end{array}
if (*.f64 M D) < 7.499999999999999e176Initial program 36.2%
Taylor expanded in l around inf
Applied rewrites27.1%
Taylor expanded in h around 0
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites50.2%
Taylor expanded in d around 0
Applied rewrites31.2%
Taylor expanded in d around inf
sqrt-prodN/A
lower-/.f64N/A
lift-sqrt.f64N/A
lift-*.f6443.0
Applied rewrites43.0%
if 7.499999999999999e176 < (*.f64 M D) Initial program 36.2%
Taylor expanded in h around 0
lower-/.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6421.7
Applied rewrites21.7%
Taylor expanded in h around -inf
mul-1-negN/A
pow2N/A
times-fracN/A
lift-/.f64N/A
sqrt-unprodN/A
lift-/.f64N/A
lower-neg.f64N/A
lift-/.f64N/A
sqrt-unprodN/A
lift-/.f64N/A
times-fracN/A
pow2N/A
sqrt-divN/A
pow1/2N/A
metadata-evalN/A
sqrt-unprodN/A
Applied rewrites9.7%
lift-fabs.f64N/A
lift-/.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
frac-timesN/A
sqrt-divN/A
sqrt-divN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6411.6
Applied rewrites11.6%
d_m = (fabs.f64 d) M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d_m h l M_m D_m) :precision binary64 (if (<= (* M_m D_m) 7.5e+176) (/ d_m (sqrt (* h l))) (- (sqrt (/ (* d_m d_m) (* h l))))))
d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double tmp;
if ((M_m * D_m) <= 7.5e+176) {
tmp = d_m / sqrt((h * l));
} else {
tmp = -sqrt(((d_m * d_m) / (h * l)));
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: tmp
if ((m_m * d_m_1) <= 7.5d+176) then
tmp = d_m / sqrt((h * l))
else
tmp = -sqrt(((d_m * d_m) / (h * l)))
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double tmp;
if ((M_m * D_m) <= 7.5e+176) {
tmp = d_m / Math.sqrt((h * l));
} else {
tmp = -Math.sqrt(((d_m * d_m) / (h * l)));
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): tmp = 0 if (M_m * D_m) <= 7.5e+176: tmp = d_m / math.sqrt((h * l)) else: tmp = -math.sqrt(((d_m * d_m) / (h * l))) return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) tmp = 0.0 if (Float64(M_m * D_m) <= 7.5e+176) tmp = Float64(d_m / sqrt(Float64(h * l))); else tmp = Float64(-sqrt(Float64(Float64(d_m * d_m) / Float64(h * l)))); end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
tmp = 0.0;
if ((M_m * D_m) <= 7.5e+176)
tmp = d_m / sqrt((h * l));
else
tmp = -sqrt(((d_m * d_m) / (h * l)));
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 7.5e+176], N[(d$95$m / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-N[Sqrt[N[(N[(d$95$m * d$95$m), $MachinePrecision] / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \cdot D\_m \leq 7.5 \cdot 10^{+176}:\\
\;\;\;\;\frac{d\_m}{\sqrt{h \cdot \ell}}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{\frac{d\_m \cdot d\_m}{h \cdot \ell}}\\
\end{array}
\end{array}
if (*.f64 M D) < 7.499999999999999e176Initial program 36.2%
Taylor expanded in l around inf
Applied rewrites27.1%
Taylor expanded in h around 0
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites50.2%
Taylor expanded in d around 0
Applied rewrites31.2%
Taylor expanded in d around inf
sqrt-prodN/A
lower-/.f64N/A
lift-sqrt.f64N/A
lift-*.f6443.0
Applied rewrites43.0%
if 7.499999999999999e176 < (*.f64 M D) Initial program 36.2%
Taylor expanded in h around 0
lower-/.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6421.7
Applied rewrites21.7%
Taylor expanded in h around -inf
mul-1-negN/A
pow2N/A
times-fracN/A
lift-/.f64N/A
sqrt-unprodN/A
lift-/.f64N/A
lower-neg.f64N/A
lift-/.f64N/A
sqrt-unprodN/A
lift-/.f64N/A
times-fracN/A
pow2N/A
sqrt-divN/A
pow1/2N/A
metadata-evalN/A
sqrt-unprodN/A
Applied rewrites9.7%
lift-fabs.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
rem-sqrt-square-revN/A
pow2N/A
*-commutativeN/A
sqrt-divN/A
lower-sqrt.f64N/A
lower-/.f64N/A
pow2N/A
lower-*.f64N/A
lift-*.f6412.2
Applied rewrites12.2%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
(-
1.0
(*
(* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0))
(/ h l))))))
(if (<= t_0 -5e+77)
(- (/ (fabs d_m) (sqrt (* l h))))
(if (<= t_0 2e+221)
(/ (fabs d_m) (* (sqrt l) (sqrt h)))
(/ d_m (sqrt (* h l)))))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -5e+77) {
tmp = -(fabs(d_m) / sqrt((l * h)));
} else if (t_0 <= 2e+221) {
tmp = fabs(d_m) / (sqrt(l) * sqrt(h));
} else {
tmp = d_m / sqrt((h * l));
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: t_0
real(8) :: tmp
t_0 = (((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m_1) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
if (t_0 <= (-5d+77)) then
tmp = -(abs(d_m) / sqrt((l * h)))
else if (t_0 <= 2d+221) then
tmp = abs(d_m) / (sqrt(l) * sqrt(h))
else
tmp = d_m / sqrt((h * l))
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -5e+77) {
tmp = -(Math.abs(d_m) / Math.sqrt((l * h)));
} else if (t_0 <= 2e+221) {
tmp = Math.abs(d_m) / (Math.sqrt(l) * Math.sqrt(h));
} else {
tmp = d_m / Math.sqrt((h * l));
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): t_0 = (math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l))) tmp = 0 if t_0 <= -5e+77: tmp = -(math.fabs(d_m) / math.sqrt((l * h))) elif t_0 <= 2e+221: tmp = math.fabs(d_m) / (math.sqrt(l) * math.sqrt(h)) else: tmp = d_m / math.sqrt((h * l)) return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_0 <= -5e+77) tmp = Float64(-Float64(abs(d_m) / sqrt(Float64(l * h)))); elseif (t_0 <= 2e+221) tmp = Float64(abs(d_m) / Float64(sqrt(l) * sqrt(h))); else tmp = Float64(d_m / sqrt(Float64(h * l))); end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
t_0 = (((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d_m)) ^ 2.0)) * (h / l)));
tmp = 0.0;
if (t_0 <= -5e+77)
tmp = -(abs(d_m) / sqrt((l * h)));
elseif (t_0 <= 2e+221)
tmp = abs(d_m) / (sqrt(l) * sqrt(h));
else
tmp = d_m / sqrt((h * l));
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+77], (-N[(N[Abs[d$95$m], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), If[LessEqual[t$95$0, 2e+221], N[(N[Abs[d$95$m], $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d$95$m / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+77}:\\
\;\;\;\;-\frac{\left|d\_m\right|}{\sqrt{\ell \cdot h}}\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+221}:\\
\;\;\;\;\frac{\left|d\_m\right|}{\sqrt{\ell} \cdot \sqrt{h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d\_m}{\sqrt{h \cdot \ell}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -5.00000000000000004e77Initial program 36.2%
Taylor expanded in h around 0
lower-/.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6421.7
Applied rewrites21.7%
Taylor expanded in h around -inf
mul-1-negN/A
pow2N/A
times-fracN/A
lift-/.f64N/A
sqrt-unprodN/A
lift-/.f64N/A
lower-neg.f64N/A
lift-/.f64N/A
sqrt-unprodN/A
lift-/.f64N/A
times-fracN/A
pow2N/A
sqrt-divN/A
pow1/2N/A
metadata-evalN/A
sqrt-unprodN/A
Applied rewrites9.7%
if -5.00000000000000004e77 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.0000000000000001e221Initial program 36.2%
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
frac-2negN/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-neg.f640.0
Applied rewrites0.0%
Taylor expanded in h around 0
Applied rewrites43.0%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lift-*.f6425.3
Applied rewrites25.3%
if 2.0000000000000001e221 < (*.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 36.2%
Taylor expanded in l around inf
Applied rewrites27.1%
Taylor expanded in h around 0
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites50.2%
Taylor expanded in d around 0
Applied rewrites31.2%
Taylor expanded in d around inf
sqrt-prodN/A
lower-/.f64N/A
lift-sqrt.f64N/A
lift-*.f6443.0
Applied rewrites43.0%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(if (<=
(*
(* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0)) (/ h l))))
-5e+77)
(- (/ (fabs d_m) (sqrt (* l h))))
(/ d_m (sqrt (* h l)))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double tmp;
if (((pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)))) <= -5e+77) {
tmp = -(fabs(d_m) / sqrt((l * h)));
} else {
tmp = d_m / sqrt((h * l));
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: tmp
if (((((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m_1) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))) <= (-5d+77)) then
tmp = -(abs(d_m) / sqrt((l * h)))
else
tmp = d_m / sqrt((h * l))
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double tmp;
if (((Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)))) <= -5e+77) {
tmp = -(Math.abs(d_m) / Math.sqrt((l * h)));
} else {
tmp = d_m / Math.sqrt((h * l));
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): tmp = 0 if ((math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)))) <= -5e+77: tmp = -(math.fabs(d_m) / math.sqrt((l * h))) else: tmp = d_m / math.sqrt((h * l)) return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) tmp = 0.0 if (Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))) <= -5e+77) tmp = Float64(-Float64(abs(d_m) / sqrt(Float64(l * h)))); else tmp = Float64(d_m / sqrt(Float64(h * l))); end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
tmp = 0.0;
if (((((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d_m)) ^ 2.0)) * (h / l)))) <= -5e+77)
tmp = -(abs(d_m) / sqrt((l * h)));
else
tmp = d_m / sqrt((h * l));
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e+77], (-N[(N[Abs[d$95$m], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), N[(d$95$m / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -5 \cdot 10^{+77}:\\
\;\;\;\;-\frac{\left|d\_m\right|}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d\_m}{\sqrt{h \cdot \ell}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -5.00000000000000004e77Initial program 36.2%
Taylor expanded in h around 0
lower-/.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6421.7
Applied rewrites21.7%
Taylor expanded in h around -inf
mul-1-negN/A
pow2N/A
times-fracN/A
lift-/.f64N/A
sqrt-unprodN/A
lift-/.f64N/A
lower-neg.f64N/A
lift-/.f64N/A
sqrt-unprodN/A
lift-/.f64N/A
times-fracN/A
pow2N/A
sqrt-divN/A
pow1/2N/A
metadata-evalN/A
sqrt-unprodN/A
Applied rewrites9.7%
if -5.00000000000000004e77 < (*.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 36.2%
Taylor expanded in l around inf
Applied rewrites27.1%
Taylor expanded in h around 0
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites50.2%
Taylor expanded in d around 0
Applied rewrites31.2%
Taylor expanded in d around inf
sqrt-prodN/A
lower-/.f64N/A
lift-sqrt.f64N/A
lift-*.f6443.0
Applied rewrites43.0%
d_m = (fabs.f64 d) M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d_m h l M_m D_m) :precision binary64 (/ d_m (sqrt (* h l))))
d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
return d_m / sqrt((h * l));
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
code = d_m / sqrt((h * l))
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
return d_m / Math.sqrt((h * l));
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): return d_m / math.sqrt((h * l))
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) return Float64(d_m / sqrt(Float64(h * l))) end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp = code(d_m, h, l, M_m, D_m)
tmp = d_m / sqrt((h * l));
end
d_m = N[Abs[d], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := N[(d$95$m / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\frac{d\_m}{\sqrt{h \cdot \ell}}
\end{array}
Initial program 36.2%
Taylor expanded in l around inf
Applied rewrites27.1%
Taylor expanded in h around 0
*-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites50.2%
Taylor expanded in d around 0
Applied rewrites31.2%
Taylor expanded in d around inf
sqrt-prodN/A
lower-/.f64N/A
lift-sqrt.f64N/A
lift-*.f6443.0
Applied rewrites43.0%
herbie shell --seed 2025142
(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)))))