
(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 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (- 1.0 (/ (* (* (pow (* (/ M 2.0) (/ D_m d)) 2.0) 0.5) h) l))))
(if (<= d -3.4e-91)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) t_0)
(if (<= d -2.05e-282)
(*
(* (* -1.0 d) (pow (* l h) -0.5))
(- 1.0 (/ (* (* (pow (/ (* D_m M) (* 2.0 d)) 2.0) 0.5) h) l)))
(if (<= d 1.05e-166)
(/
(fma
(* -0.125 (/ (pow (* D_m M) 2.0) d))
(sqrt (pow (/ h l) 3.0))
(* (sqrt (/ h l)) d))
h)
(* (* (/ (sqrt d) (sqrt h)) (pow (/ d l) (/ 1.0 2.0))) t_0))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = 1.0 - (((pow(((M / 2.0) * (D_m / d)), 2.0) * 0.5) * h) / l);
double tmp;
if (d <= -3.4e-91) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * t_0;
} else if (d <= -2.05e-282) {
tmp = ((-1.0 * d) * pow((l * h), -0.5)) * (1.0 - (((pow(((D_m * M) / (2.0 * d)), 2.0) * 0.5) * h) / l));
} else if (d <= 1.05e-166) {
tmp = fma((-0.125 * (pow((D_m * M), 2.0) / d)), sqrt(pow((h / l), 3.0)), (sqrt((h / l)) * d)) / h;
} else {
tmp = ((sqrt(d) / sqrt(h)) * pow((d / l), (1.0 / 2.0))) * t_0;
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(1.0 - Float64(Float64(Float64((Float64(Float64(M / 2.0) * Float64(D_m / d)) ^ 2.0) * 0.5) * h) / l)) tmp = 0.0 if (d <= -3.4e-91) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * t_0); elseif (d <= -2.05e-282) tmp = Float64(Float64(Float64(-1.0 * d) * (Float64(l * h) ^ -0.5)) * Float64(1.0 - Float64(Float64(Float64((Float64(Float64(D_m * M) / Float64(2.0 * d)) ^ 2.0) * 0.5) * h) / l))); elseif (d <= 1.05e-166) tmp = Float64(fma(Float64(-0.125 * Float64((Float64(D_m * M) ^ 2.0) / d)), sqrt((Float64(h / l) ^ 3.0)), Float64(sqrt(Float64(h / l)) * d)) / h); else tmp = Float64(Float64(Float64(sqrt(d) / sqrt(h)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * t_0); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(1.0 - N[(N[(N[(N[Power[N[(N[(M / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.4e-91], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[d, -2.05e-282], N[(N[(N[(-1.0 * d), $MachinePrecision] * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[Power[N[(N[(D$95$m * M), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.05e-166], N[(N[(N[(-0.125 * N[(N[Power[N[(D$95$m * M), $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[Power[N[(h / l), $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision] + N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := 1 - \frac{\left({\left(\frac{M}{2} \cdot \frac{D\_m}{d}\right)}^{2} \cdot 0.5\right) \cdot h}{\ell}\\
\mathbf{if}\;d \leq -3.4 \cdot 10^{-91}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot t\_0\\
\mathbf{elif}\;d \leq -2.05 \cdot 10^{-282}:\\
\;\;\;\;\left(\left(-1 \cdot d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\right) \cdot \left(1 - \frac{\left({\left(\frac{D\_m \cdot M}{2 \cdot d}\right)}^{2} \cdot 0.5\right) \cdot h}{\ell}\right)\\
\mathbf{elif}\;d \leq 1.05 \cdot 10^{-166}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.125 \cdot \frac{{\left(D\_m \cdot M\right)}^{2}}{d}, \sqrt{{\left(\frac{h}{\ell}\right)}^{3}}, \sqrt{\frac{h}{\ell}} \cdot d\right)}{h}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot t\_0\\
\end{array}
\end{array}
if d < -3.40000000000000027e-91Initial program 76.7%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites78.8%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6478.8
Applied rewrites78.8%
if -3.40000000000000027e-91 < d < -2.04999999999999989e-282Initial program 49.3%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites48.3%
lift-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6449.7
Applied rewrites49.7%
Taylor expanded in h around -inf
metadata-evalN/A
metadata-evalN/A
pow1/2N/A
pow1/2N/A
*-commutativeN/A
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
sqrt-divN/A
*-commutativeN/A
sqrt-divN/A
inv-powN/A
sqrt-pow1N/A
lower-pow.f64N/A
lift-*.f64N/A
metadata-eval65.6
Applied rewrites65.6%
if -2.04999999999999989e-282 < d < 1.05e-166Initial program 39.2%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites44.0%
if 1.05e-166 < d Initial program 74.3%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites75.9%
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
pow1/2N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6484.9
Applied rewrites84.9%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (sqrt (/ d l))) (t_1 (sqrt (/ d h))))
(if (<=
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l))))
-2e-62)
(* t_1 (* t_0 (* (/ (* (* (* M D_m) (* M D_m)) h) (* (* d d) l)) -0.125)))
(* t_1 t_0))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = sqrt((d / l));
double t_1 = sqrt((d / h));
double tmp;
if (((pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -2e-62) {
tmp = t_1 * (t_0 * (((((M * D_m) * (M * D_m)) * h) / ((d * d) * l)) * -0.125));
} else {
tmp = t_1 * t_0;
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sqrt((d / l))
t_1 = sqrt((d / h))
if (((((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= (-2d-62)) then
tmp = t_1 * (t_0 * (((((m * d_m) * (m * d_m)) * h) / ((d * d) * l)) * (-0.125d0)))
else
tmp = t_1 * t_0
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = Math.sqrt((d / l));
double t_1 = Math.sqrt((d / h));
double tmp;
if (((Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -2e-62) {
tmp = t_1 * (t_0 * (((((M * D_m) * (M * D_m)) * h) / ((d * d) * l)) * -0.125));
} else {
tmp = t_1 * t_0;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = math.sqrt((d / l)) t_1 = math.sqrt((d / h)) tmp = 0 if ((math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -2e-62: tmp = t_1 * (t_0 * (((((M * D_m) * (M * D_m)) * h) / ((d * d) * l)) * -0.125)) else: tmp = t_1 * t_0 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = sqrt(Float64(d / l)) t_1 = sqrt(Float64(d / h)) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= -2e-62) tmp = Float64(t_1 * Float64(t_0 * Float64(Float64(Float64(Float64(Float64(M * D_m) * Float64(M * D_m)) * h) / Float64(Float64(d * d) * l)) * -0.125))); else tmp = Float64(t_1 * t_0); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = sqrt((d / l));
t_1 = sqrt((d / h));
tmp = 0.0;
if (((((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= -2e-62)
tmp = t_1 * (t_0 * (((((M * D_m) * (M * D_m)) * h) / ((d * d) * l)) * -0.125));
else
tmp = t_1 * t_0;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e-62], N[(t$95$1 * N[(t$95$0 * N[(N[(N[(N[(N[(M * D$95$m), $MachinePrecision] * N[(M * D$95$m), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
t_1 := \sqrt{\frac{d}{h}}\\
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -2 \cdot 10^{-62}:\\
\;\;\;\;t\_1 \cdot \left(t\_0 \cdot \left(\frac{\left(\left(M \cdot D\_m\right) \cdot \left(M \cdot D\_m\right)\right) \cdot h}{\left(d \cdot d\right) \cdot \ell} \cdot -0.125\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot t\_0\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -2.0000000000000001e-62Initial program 85.2%
Taylor expanded in d around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
pow-prod-downN/A
*-commutativeN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6464.7
Applied rewrites64.7%
Applied rewrites64.2%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f6464.2
Applied rewrites64.2%
if -2.0000000000000001e-62 < (*.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 57.0%
Taylor expanded in d around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
pow-prod-downN/A
*-commutativeN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f643.0
Applied rewrites3.0%
Applied rewrites3.1%
Taylor expanded in d around inf
lift-sqrt.f64N/A
lift-/.f6458.2
Applied rewrites58.2%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (sqrt (/ d l))) (t_1 (sqrt (/ d h))))
(if (<=
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l))))
-5e+41)
(* t_1 (* t_0 (* (* (* D_m D_m) (* (* M M) (/ h (* (* d d) l)))) -0.125)))
(* t_1 t_0))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = sqrt((d / l));
double t_1 = sqrt((d / h));
double tmp;
if (((pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5e+41) {
tmp = t_1 * (t_0 * (((D_m * D_m) * ((M * M) * (h / ((d * d) * l)))) * -0.125));
} else {
tmp = t_1 * t_0;
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sqrt((d / l))
t_1 = sqrt((d / h))
if (((((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= (-5d+41)) then
tmp = t_1 * (t_0 * (((d_m * d_m) * ((m * m) * (h / ((d * d) * l)))) * (-0.125d0)))
else
tmp = t_1 * t_0
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = Math.sqrt((d / l));
double t_1 = Math.sqrt((d / h));
double tmp;
if (((Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5e+41) {
tmp = t_1 * (t_0 * (((D_m * D_m) * ((M * M) * (h / ((d * d) * l)))) * -0.125));
} else {
tmp = t_1 * t_0;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = math.sqrt((d / l)) t_1 = math.sqrt((d / h)) tmp = 0 if ((math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5e+41: tmp = t_1 * (t_0 * (((D_m * D_m) * ((M * M) * (h / ((d * d) * l)))) * -0.125)) else: tmp = t_1 * t_0 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = sqrt(Float64(d / l)) t_1 = sqrt(Float64(d / h)) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= -5e+41) tmp = Float64(t_1 * Float64(t_0 * Float64(Float64(Float64(D_m * D_m) * Float64(Float64(M * M) * Float64(h / Float64(Float64(d * d) * l)))) * -0.125))); else tmp = Float64(t_1 * t_0); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = sqrt((d / l));
t_1 = sqrt((d / h));
tmp = 0.0;
if (((((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= -5e+41)
tmp = t_1 * (t_0 * (((D_m * D_m) * ((M * M) * (h / ((d * d) * l)))) * -0.125));
else
tmp = t_1 * t_0;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e+41], N[(t$95$1 * N[(t$95$0 * N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * N[(N[(M * M), $MachinePrecision] * N[(h / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
t_1 := \sqrt{\frac{d}{h}}\\
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -5 \cdot 10^{+41}:\\
\;\;\;\;t\_1 \cdot \left(t\_0 \cdot \left(\left(\left(D\_m \cdot D\_m\right) \cdot \left(\left(M \cdot M\right) \cdot \frac{h}{\left(d \cdot d\right) \cdot \ell}\right)\right) \cdot -0.125\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot t\_0\\
\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.00000000000000022e41Initial program 84.7%
Taylor expanded in d around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
pow-prod-downN/A
*-commutativeN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6465.4
Applied rewrites65.4%
Applied rewrites64.9%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f6454.4
Applied rewrites54.4%
if -5.00000000000000022e41 < (*.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 57.8%
Taylor expanded in d around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
pow-prod-downN/A
*-commutativeN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f643.9
Applied rewrites3.9%
Applied rewrites3.9%
Taylor expanded in d around inf
lift-sqrt.f64N/A
lift-/.f6457.2
Applied rewrites57.2%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (sqrt (/ d l))) (t_1 (sqrt (/ d h))))
(if (<=
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l))))
0.0)
(* t_1 (* t_0 -1.0))
(* t_1 t_0))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = sqrt((d / l));
double t_1 = sqrt((d / h));
double tmp;
if (((pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 0.0) {
tmp = t_1 * (t_0 * -1.0);
} else {
tmp = t_1 * t_0;
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sqrt((d / l))
t_1 = sqrt((d / h))
if (((((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= 0.0d0) then
tmp = t_1 * (t_0 * (-1.0d0))
else
tmp = t_1 * t_0
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = Math.sqrt((d / l));
double t_1 = Math.sqrt((d / h));
double tmp;
if (((Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 0.0) {
tmp = t_1 * (t_0 * -1.0);
} else {
tmp = t_1 * t_0;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = math.sqrt((d / l)) t_1 = math.sqrt((d / h)) tmp = 0 if ((math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 0.0: tmp = t_1 * (t_0 * -1.0) else: tmp = t_1 * t_0 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = sqrt(Float64(d / l)) t_1 = sqrt(Float64(d / h)) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= 0.0) tmp = Float64(t_1 * Float64(t_0 * -1.0)); else tmp = Float64(t_1 * t_0); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = sqrt((d / l));
t_1 = sqrt((d / h));
tmp = 0.0;
if (((((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= 0.0)
tmp = t_1 * (t_0 * -1.0);
else
tmp = t_1 * t_0;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(t$95$1 * N[(t$95$0 * -1.0), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
t_1 := \sqrt{\frac{d}{h}}\\
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq 0:\\
\;\;\;\;t\_1 \cdot \left(t\_0 \cdot -1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot t\_0\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0Initial program 78.6%
Taylor expanded in d around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
pow-prod-downN/A
*-commutativeN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6456.0
Applied rewrites56.0%
Applied rewrites55.5%
Taylor expanded in l around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
lift-sqrt.f64N/A
lift-/.f6419.2
Applied rewrites19.2%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 58.2%
Taylor expanded in d around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
pow-prod-downN/A
*-commutativeN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f641.9
Applied rewrites1.9%
Applied rewrites1.9%
Taylor expanded in d around inf
lift-sqrt.f64N/A
lift-/.f6461.1
Applied rewrites61.1%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (- 1.0 (/ (* (* (pow (* (/ M 2.0) (/ D_m d)) 2.0) 0.5) h) l)))
(t_1 (pow (* l h) -0.5)))
(if (<= d -3.4e-91)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) t_0)
(if (<= d -2.05e-282)
(*
(* (* -1.0 d) t_1)
(- 1.0 (/ (* (* (pow (/ (* D_m M) (* 2.0 d)) 2.0) 0.5) h) l)))
(if (<= d 1.15e-146)
(/
(fma
(* -0.125 (/ (pow (* D_m M) 2.0) d))
(sqrt (pow (/ h l) 3.0))
(* (sqrt (/ h l)) d))
h)
(* (* t_1 d) t_0))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = 1.0 - (((pow(((M / 2.0) * (D_m / d)), 2.0) * 0.5) * h) / l);
double t_1 = pow((l * h), -0.5);
double tmp;
if (d <= -3.4e-91) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * t_0;
} else if (d <= -2.05e-282) {
tmp = ((-1.0 * d) * t_1) * (1.0 - (((pow(((D_m * M) / (2.0 * d)), 2.0) * 0.5) * h) / l));
} else if (d <= 1.15e-146) {
tmp = fma((-0.125 * (pow((D_m * M), 2.0) / d)), sqrt(pow((h / l), 3.0)), (sqrt((h / l)) * d)) / h;
} else {
tmp = (t_1 * d) * t_0;
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(1.0 - Float64(Float64(Float64((Float64(Float64(M / 2.0) * Float64(D_m / d)) ^ 2.0) * 0.5) * h) / l)) t_1 = Float64(l * h) ^ -0.5 tmp = 0.0 if (d <= -3.4e-91) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * t_0); elseif (d <= -2.05e-282) tmp = Float64(Float64(Float64(-1.0 * d) * t_1) * Float64(1.0 - Float64(Float64(Float64((Float64(Float64(D_m * M) / Float64(2.0 * d)) ^ 2.0) * 0.5) * h) / l))); elseif (d <= 1.15e-146) tmp = Float64(fma(Float64(-0.125 * Float64((Float64(D_m * M) ^ 2.0) / d)), sqrt((Float64(h / l) ^ 3.0)), Float64(sqrt(Float64(h / l)) * d)) / h); else tmp = Float64(Float64(t_1 * d) * t_0); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(1.0 - N[(N[(N[(N[Power[N[(N[(M / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]}, If[LessEqual[d, -3.4e-91], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[d, -2.05e-282], N[(N[(N[(-1.0 * d), $MachinePrecision] * t$95$1), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[Power[N[(N[(D$95$m * M), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.15e-146], N[(N[(N[(-0.125 * N[(N[Power[N[(D$95$m * M), $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[Power[N[(h / l), $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision] + N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], N[(N[(t$95$1 * d), $MachinePrecision] * t$95$0), $MachinePrecision]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := 1 - \frac{\left({\left(\frac{M}{2} \cdot \frac{D\_m}{d}\right)}^{2} \cdot 0.5\right) \cdot h}{\ell}\\
t_1 := {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{if}\;d \leq -3.4 \cdot 10^{-91}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot t\_0\\
\mathbf{elif}\;d \leq -2.05 \cdot 10^{-282}:\\
\;\;\;\;\left(\left(-1 \cdot d\right) \cdot t\_1\right) \cdot \left(1 - \frac{\left({\left(\frac{D\_m \cdot M}{2 \cdot d}\right)}^{2} \cdot 0.5\right) \cdot h}{\ell}\right)\\
\mathbf{elif}\;d \leq 1.15 \cdot 10^{-146}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.125 \cdot \frac{{\left(D\_m \cdot M\right)}^{2}}{d}, \sqrt{{\left(\frac{h}{\ell}\right)}^{3}}, \sqrt{\frac{h}{\ell}} \cdot d\right)}{h}\\
\mathbf{else}:\\
\;\;\;\;\left(t\_1 \cdot d\right) \cdot t\_0\\
\end{array}
\end{array}
if d < -3.40000000000000027e-91Initial program 76.7%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites78.8%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6478.8
Applied rewrites78.8%
if -3.40000000000000027e-91 < d < -2.04999999999999989e-282Initial program 49.3%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites48.3%
lift-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6449.7
Applied rewrites49.7%
Taylor expanded in h around -inf
metadata-evalN/A
metadata-evalN/A
pow1/2N/A
pow1/2N/A
*-commutativeN/A
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
sqrt-divN/A
*-commutativeN/A
sqrt-divN/A
inv-powN/A
sqrt-pow1N/A
lower-pow.f64N/A
lift-*.f64N/A
metadata-eval65.6
Applied rewrites65.6%
if -2.04999999999999989e-282 < d < 1.15e-146Initial program 40.7%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites44.4%
if 1.15e-146 < d Initial program 75.0%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites76.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
inv-powN/A
*-commutativeN/A
sqrt-pow1N/A
lower-pow.f64N/A
lift-*.f64N/A
metadata-eval79.0
Applied rewrites79.0%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (- 1.0 (/ (* (* (pow (* (/ M 2.0) (/ D_m d)) 2.0) 0.5) h) l)))
(t_1 (pow (* l h) -0.5)))
(if (<= d -3.4e-91)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) t_0)
(if (<= d -2e-311)
(*
(* (* -1.0 d) t_1)
(- 1.0 (/ (* (* (pow (/ (* D_m M) (* 2.0 d)) 2.0) 0.5) h) l)))
(* (* t_1 d) t_0)))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = 1.0 - (((pow(((M / 2.0) * (D_m / d)), 2.0) * 0.5) * h) / l);
double t_1 = pow((l * h), -0.5);
double tmp;
if (d <= -3.4e-91) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * t_0;
} else if (d <= -2e-311) {
tmp = ((-1.0 * d) * t_1) * (1.0 - (((pow(((D_m * M) / (2.0 * d)), 2.0) * 0.5) * h) / l));
} else {
tmp = (t_1 * d) * t_0;
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - ((((((m / 2.0d0) * (d_m / d)) ** 2.0d0) * 0.5d0) * h) / l)
t_1 = (l * h) ** (-0.5d0)
if (d <= (-3.4d-91)) then
tmp = (sqrt((d / l)) * sqrt((d / h))) * t_0
else if (d <= (-2d-311)) then
tmp = (((-1.0d0) * d) * t_1) * (1.0d0 - ((((((d_m * m) / (2.0d0 * d)) ** 2.0d0) * 0.5d0) * h) / l))
else
tmp = (t_1 * d) * t_0
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = 1.0 - (((Math.pow(((M / 2.0) * (D_m / d)), 2.0) * 0.5) * h) / l);
double t_1 = Math.pow((l * h), -0.5);
double tmp;
if (d <= -3.4e-91) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * t_0;
} else if (d <= -2e-311) {
tmp = ((-1.0 * d) * t_1) * (1.0 - (((Math.pow(((D_m * M) / (2.0 * d)), 2.0) * 0.5) * h) / l));
} else {
tmp = (t_1 * d) * t_0;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = 1.0 - (((math.pow(((M / 2.0) * (D_m / d)), 2.0) * 0.5) * h) / l) t_1 = math.pow((l * h), -0.5) tmp = 0 if d <= -3.4e-91: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * t_0 elif d <= -2e-311: tmp = ((-1.0 * d) * t_1) * (1.0 - (((math.pow(((D_m * M) / (2.0 * d)), 2.0) * 0.5) * h) / l)) else: tmp = (t_1 * d) * t_0 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(1.0 - Float64(Float64(Float64((Float64(Float64(M / 2.0) * Float64(D_m / d)) ^ 2.0) * 0.5) * h) / l)) t_1 = Float64(l * h) ^ -0.5 tmp = 0.0 if (d <= -3.4e-91) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * t_0); elseif (d <= -2e-311) tmp = Float64(Float64(Float64(-1.0 * d) * t_1) * Float64(1.0 - Float64(Float64(Float64((Float64(Float64(D_m * M) / Float64(2.0 * d)) ^ 2.0) * 0.5) * h) / l))); else tmp = Float64(Float64(t_1 * d) * t_0); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = 1.0 - ((((((M / 2.0) * (D_m / d)) ^ 2.0) * 0.5) * h) / l);
t_1 = (l * h) ^ -0.5;
tmp = 0.0;
if (d <= -3.4e-91)
tmp = (sqrt((d / l)) * sqrt((d / h))) * t_0;
elseif (d <= -2e-311)
tmp = ((-1.0 * d) * t_1) * (1.0 - ((((((D_m * M) / (2.0 * d)) ^ 2.0) * 0.5) * h) / l));
else
tmp = (t_1 * d) * t_0;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(1.0 - N[(N[(N[(N[Power[N[(N[(M / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]}, If[LessEqual[d, -3.4e-91], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[d, -2e-311], N[(N[(N[(-1.0 * d), $MachinePrecision] * t$95$1), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[Power[N[(N[(D$95$m * M), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 * d), $MachinePrecision] * t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := 1 - \frac{\left({\left(\frac{M}{2} \cdot \frac{D\_m}{d}\right)}^{2} \cdot 0.5\right) \cdot h}{\ell}\\
t_1 := {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{if}\;d \leq -3.4 \cdot 10^{-91}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot t\_0\\
\mathbf{elif}\;d \leq -2 \cdot 10^{-311}:\\
\;\;\;\;\left(\left(-1 \cdot d\right) \cdot t\_1\right) \cdot \left(1 - \frac{\left({\left(\frac{D\_m \cdot M}{2 \cdot d}\right)}^{2} \cdot 0.5\right) \cdot h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_1 \cdot d\right) \cdot t\_0\\
\end{array}
\end{array}
if d < -3.40000000000000027e-91Initial program 76.7%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites78.8%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6478.8
Applied rewrites78.8%
if -3.40000000000000027e-91 < d < -1.9999999999999e-311Initial program 47.0%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites45.7%
lift-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6447.1
Applied rewrites47.1%
Taylor expanded in h around -inf
metadata-evalN/A
metadata-evalN/A
pow1/2N/A
pow1/2N/A
*-commutativeN/A
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
sqrt-divN/A
*-commutativeN/A
sqrt-divN/A
inv-powN/A
sqrt-pow1N/A
lower-pow.f64N/A
lift-*.f64N/A
metadata-eval63.1
Applied rewrites63.1%
if -1.9999999999999e-311 < d Initial program 66.6%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites67.6%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
inv-powN/A
*-commutativeN/A
sqrt-pow1N/A
lower-pow.f64N/A
lift-*.f64N/A
metadata-eval73.9
Applied rewrites73.9%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (/ (* (* (pow (* (/ M 2.0) (/ D_m d)) 2.0) 0.5) h) l)))))
(if (<= h -2.2e-17)
t_0
(if (<= h -5e-310)
(*
(* (* -1.0 d) (pow (* l h) -0.5))
(- 1.0 (/ (* (* (pow (/ (* D_m M) (* 2.0 d)) 2.0) 0.5) h) l)))
(if (<= h 1.3e+79)
(*
(* (sqrt (/ 1.0 (* l h))) d)
(- 1.0 (* (* 0.5 (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l))))
t_0)))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (((pow(((M / 2.0) * (D_m / d)), 2.0) * 0.5) * h) / l));
double tmp;
if (h <= -2.2e-17) {
tmp = t_0;
} else if (h <= -5e-310) {
tmp = ((-1.0 * d) * pow((l * h), -0.5)) * (1.0 - (((pow(((D_m * M) / (2.0 * d)), 2.0) * 0.5) * h) / l));
} else if (h <= 1.3e+79) {
tmp = (sqrt((1.0 / (l * h))) * d) * (1.0 - ((0.5 * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)));
} else {
tmp = t_0;
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = (sqrt((d / l)) * sqrt((d / h))) * (1.0d0 - ((((((m / 2.0d0) * (d_m / d)) ** 2.0d0) * 0.5d0) * h) / l))
if (h <= (-2.2d-17)) then
tmp = t_0
else if (h <= (-5d-310)) then
tmp = (((-1.0d0) * d) * ((l * h) ** (-0.5d0))) * (1.0d0 - ((((((d_m * m) / (2.0d0 * d)) ** 2.0d0) * 0.5d0) * h) / l))
else if (h <= 1.3d+79) then
tmp = (sqrt((1.0d0 / (l * h))) * d) * (1.0d0 - ((0.5d0 * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
else
tmp = t_0
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * (1.0 - (((Math.pow(((M / 2.0) * (D_m / d)), 2.0) * 0.5) * h) / l));
double tmp;
if (h <= -2.2e-17) {
tmp = t_0;
} else if (h <= -5e-310) {
tmp = ((-1.0 * d) * Math.pow((l * h), -0.5)) * (1.0 - (((Math.pow(((D_m * M) / (2.0 * d)), 2.0) * 0.5) * h) / l));
} else if (h <= 1.3e+79) {
tmp = (Math.sqrt((1.0 / (l * h))) * d) * (1.0 - ((0.5 * Math.pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)));
} else {
tmp = t_0;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = (math.sqrt((d / l)) * math.sqrt((d / h))) * (1.0 - (((math.pow(((M / 2.0) * (D_m / d)), 2.0) * 0.5) * h) / l)) tmp = 0 if h <= -2.2e-17: tmp = t_0 elif h <= -5e-310: tmp = ((-1.0 * d) * math.pow((l * h), -0.5)) * (1.0 - (((math.pow(((D_m * M) / (2.0 * d)), 2.0) * 0.5) * h) / l)) elif h <= 1.3e+79: tmp = (math.sqrt((1.0 / (l * h))) * d) * (1.0 - ((0.5 * math.pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l))) else: tmp = t_0 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64((Float64(Float64(M / 2.0) * Float64(D_m / d)) ^ 2.0) * 0.5) * h) / l))) tmp = 0.0 if (h <= -2.2e-17) tmp = t_0; elseif (h <= -5e-310) tmp = Float64(Float64(Float64(-1.0 * d) * (Float64(l * h) ^ -0.5)) * Float64(1.0 - Float64(Float64(Float64((Float64(Float64(D_m * M) / Float64(2.0 * d)) ^ 2.0) * 0.5) * h) / l))); elseif (h <= 1.3e+79) tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d) * Float64(1.0 - Float64(Float64(0.5 * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))); else tmp = t_0; end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((((((M / 2.0) * (D_m / d)) ^ 2.0) * 0.5) * h) / l));
tmp = 0.0;
if (h <= -2.2e-17)
tmp = t_0;
elseif (h <= -5e-310)
tmp = ((-1.0 * d) * ((l * h) ^ -0.5)) * (1.0 - ((((((D_m * M) / (2.0 * d)) ^ 2.0) * 0.5) * h) / l));
elseif (h <= 1.3e+79)
tmp = (sqrt((1.0 / (l * h))) * d) * (1.0 - ((0.5 * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
else
tmp = t_0;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[Power[N[(N[(M / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -2.2e-17], t$95$0, If[LessEqual[h, -5e-310], N[(N[(N[(-1.0 * d), $MachinePrecision] * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[Power[N[(N[(D$95$m * M), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, 1.3e+79], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] * N[(1.0 - N[(N[(0.5 * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \frac{\left({\left(\frac{M}{2} \cdot \frac{D\_m}{d}\right)}^{2} \cdot 0.5\right) \cdot h}{\ell}\right)\\
\mathbf{if}\;h \leq -2.2 \cdot 10^{-17}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\left(-1 \cdot d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\right) \cdot \left(1 - \frac{\left({\left(\frac{D\_m \cdot M}{2 \cdot d}\right)}^{2} \cdot 0.5\right) \cdot h}{\ell}\right)\\
\mathbf{elif}\;h \leq 1.3 \cdot 10^{+79}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\right) \cdot \left(1 - \left(0.5 \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if h < -2.2e-17 or 1.30000000000000007e79 < h Initial program 59.3%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites61.3%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6461.3
Applied rewrites61.3%
if -2.2e-17 < h < -4.999999999999985e-310Initial program 70.8%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites70.9%
lift-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6471.6
Applied rewrites71.6%
Taylor expanded in h around -inf
metadata-evalN/A
metadata-evalN/A
pow1/2N/A
pow1/2N/A
*-commutativeN/A
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
sqrt-divN/A
*-commutativeN/A
sqrt-divN/A
inv-powN/A
sqrt-pow1N/A
lower-pow.f64N/A
lift-*.f64N/A
metadata-eval81.4
Applied rewrites81.4%
if -4.999999999999985e-310 < h < 1.30000000000000007e79Initial program 73.2%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6480.4
Applied rewrites80.4%
lift-/.f64N/A
metadata-eval80.4
Applied rewrites80.4%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lift-*.f6480.4
Applied rewrites80.4%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (- 1.0 (* (* 0.5 (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l))))
(t_1
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (/ (* (* (pow (* (/ M 2.0) (/ D_m d)) 2.0) 0.5) h) l)))))
(if (<= h -2.2e-17)
t_1
(if (<= h -5e-310)
(* (* (* -1.0 d) (/ 1.0 (sqrt (* l h)))) t_0)
(if (<= h 1.3e+79) (* (* (sqrt (/ 1.0 (* l h))) d) t_0) t_1)))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = 1.0 - ((0.5 * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l));
double t_1 = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (((pow(((M / 2.0) * (D_m / d)), 2.0) * 0.5) * h) / l));
double tmp;
if (h <= -2.2e-17) {
tmp = t_1;
} else if (h <= -5e-310) {
tmp = ((-1.0 * d) * (1.0 / sqrt((l * h)))) * t_0;
} else if (h <= 1.3e+79) {
tmp = (sqrt((1.0 / (l * h))) * d) * t_0;
} else {
tmp = t_1;
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - ((0.5d0 * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l))
t_1 = (sqrt((d / l)) * sqrt((d / h))) * (1.0d0 - ((((((m / 2.0d0) * (d_m / d)) ** 2.0d0) * 0.5d0) * h) / l))
if (h <= (-2.2d-17)) then
tmp = t_1
else if (h <= (-5d-310)) then
tmp = (((-1.0d0) * d) * (1.0d0 / sqrt((l * h)))) * t_0
else if (h <= 1.3d+79) then
tmp = (sqrt((1.0d0 / (l * h))) * d) * t_0
else
tmp = t_1
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = 1.0 - ((0.5 * Math.pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l));
double t_1 = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * (1.0 - (((Math.pow(((M / 2.0) * (D_m / d)), 2.0) * 0.5) * h) / l));
double tmp;
if (h <= -2.2e-17) {
tmp = t_1;
} else if (h <= -5e-310) {
tmp = ((-1.0 * d) * (1.0 / Math.sqrt((l * h)))) * t_0;
} else if (h <= 1.3e+79) {
tmp = (Math.sqrt((1.0 / (l * h))) * d) * t_0;
} else {
tmp = t_1;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = 1.0 - ((0.5 * math.pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)) t_1 = (math.sqrt((d / l)) * math.sqrt((d / h))) * (1.0 - (((math.pow(((M / 2.0) * (D_m / d)), 2.0) * 0.5) * h) / l)) tmp = 0 if h <= -2.2e-17: tmp = t_1 elif h <= -5e-310: tmp = ((-1.0 * d) * (1.0 / math.sqrt((l * h)))) * t_0 elif h <= 1.3e+79: tmp = (math.sqrt((1.0 / (l * h))) * d) * t_0 else: tmp = t_1 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(1.0 - Float64(Float64(0.5 * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l))) t_1 = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64((Float64(Float64(M / 2.0) * Float64(D_m / d)) ^ 2.0) * 0.5) * h) / l))) tmp = 0.0 if (h <= -2.2e-17) tmp = t_1; elseif (h <= -5e-310) tmp = Float64(Float64(Float64(-1.0 * d) * Float64(1.0 / sqrt(Float64(l * h)))) * t_0); elseif (h <= 1.3e+79) tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d) * t_0); else tmp = t_1; end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = 1.0 - ((0.5 * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l));
t_1 = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((((((M / 2.0) * (D_m / d)) ^ 2.0) * 0.5) * h) / l));
tmp = 0.0;
if (h <= -2.2e-17)
tmp = t_1;
elseif (h <= -5e-310)
tmp = ((-1.0 * d) * (1.0 / sqrt((l * h)))) * t_0;
elseif (h <= 1.3e+79)
tmp = (sqrt((1.0 / (l * h))) * d) * t_0;
else
tmp = t_1;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(1.0 - N[(N[(0.5 * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[Power[N[(N[(M / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -2.2e-17], t$95$1, If[LessEqual[h, -5e-310], N[(N[(N[(-1.0 * d), $MachinePrecision] * N[(1.0 / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[h, 1.3e+79], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] * t$95$0), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := 1 - \left(0.5 \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\\
t_1 := \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \frac{\left({\left(\frac{M}{2} \cdot \frac{D\_m}{d}\right)}^{2} \cdot 0.5\right) \cdot h}{\ell}\right)\\
\mathbf{if}\;h \leq -2.2 \cdot 10^{-17}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\left(-1 \cdot d\right) \cdot \frac{1}{\sqrt{\ell \cdot h}}\right) \cdot t\_0\\
\mathbf{elif}\;h \leq 1.3 \cdot 10^{+79}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if h < -2.2e-17 or 1.30000000000000007e79 < h Initial program 59.3%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites61.3%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6461.3
Applied rewrites61.3%
if -2.2e-17 < h < -4.999999999999985e-310Initial program 70.8%
Taylor expanded in h around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6478.5
Applied rewrites78.5%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6479.1
Applied rewrites79.1%
lift-/.f64N/A
metadata-eval79.1
Applied rewrites79.1%
if -4.999999999999985e-310 < h < 1.30000000000000007e79Initial program 73.2%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6480.4
Applied rewrites80.4%
lift-/.f64N/A
metadata-eval80.4
Applied rewrites80.4%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lift-*.f6480.4
Applied rewrites80.4%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (- 1.0 (* (* 0.5 (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l)))))
(if (<= d -2.6e-91)
(*
(sqrt (/ d h))
(*
(sqrt (/ d l))
(- 1.0 (* (/ h l) (* (pow (* (/ M 2.0) (/ D_m d)) 2.0) 0.5)))))
(if (<= d -2e-311)
(* (* (* -1.0 d) (/ 1.0 (sqrt (* l h)))) t_0)
(* (* (sqrt (/ 1.0 (* l h))) d) t_0)))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = 1.0 - ((0.5 * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l));
double tmp;
if (d <= -2.6e-91) {
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 - ((h / l) * (pow(((M / 2.0) * (D_m / d)), 2.0) * 0.5))));
} else if (d <= -2e-311) {
tmp = ((-1.0 * d) * (1.0 / sqrt((l * h)))) * t_0;
} else {
tmp = (sqrt((1.0 / (l * h))) * d) * t_0;
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - ((0.5d0 * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l))
if (d <= (-2.6d-91)) then
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0d0 - ((h / l) * ((((m / 2.0d0) * (d_m / d)) ** 2.0d0) * 0.5d0))))
else if (d <= (-2d-311)) then
tmp = (((-1.0d0) * d) * (1.0d0 / sqrt((l * h)))) * t_0
else
tmp = (sqrt((1.0d0 / (l * h))) * d) * t_0
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = 1.0 - ((0.5 * Math.pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l));
double tmp;
if (d <= -2.6e-91) {
tmp = Math.sqrt((d / h)) * (Math.sqrt((d / l)) * (1.0 - ((h / l) * (Math.pow(((M / 2.0) * (D_m / d)), 2.0) * 0.5))));
} else if (d <= -2e-311) {
tmp = ((-1.0 * d) * (1.0 / Math.sqrt((l * h)))) * t_0;
} else {
tmp = (Math.sqrt((1.0 / (l * h))) * d) * t_0;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = 1.0 - ((0.5 * math.pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)) tmp = 0 if d <= -2.6e-91: tmp = math.sqrt((d / h)) * (math.sqrt((d / l)) * (1.0 - ((h / l) * (math.pow(((M / 2.0) * (D_m / d)), 2.0) * 0.5)))) elif d <= -2e-311: tmp = ((-1.0 * d) * (1.0 / math.sqrt((l * h)))) * t_0 else: tmp = (math.sqrt((1.0 / (l * h))) * d) * t_0 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(1.0 - Float64(Float64(0.5 * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l))) tmp = 0.0 if (d <= -2.6e-91) tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(d / l)) * Float64(1.0 - Float64(Float64(h / l) * Float64((Float64(Float64(M / 2.0) * Float64(D_m / d)) ^ 2.0) * 0.5))))); elseif (d <= -2e-311) tmp = Float64(Float64(Float64(-1.0 * d) * Float64(1.0 / sqrt(Float64(l * h)))) * t_0); else tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d) * t_0); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = 1.0 - ((0.5 * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l));
tmp = 0.0;
if (d <= -2.6e-91)
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 - ((h / l) * ((((M / 2.0) * (D_m / d)) ^ 2.0) * 0.5))));
elseif (d <= -2e-311)
tmp = ((-1.0 * d) * (1.0 / sqrt((l * h)))) * t_0;
else
tmp = (sqrt((1.0 / (l * h))) * d) * t_0;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(1.0 - N[(N[(0.5 * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.6e-91], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(M / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2e-311], N[(N[(N[(-1.0 * d), $MachinePrecision] * N[(1.0 / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := 1 - \left(0.5 \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\\
\mathbf{if}\;d \leq -2.6 \cdot 10^{-91}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - \frac{h}{\ell} \cdot \left({\left(\frac{M}{2} \cdot \frac{D\_m}{d}\right)}^{2} \cdot 0.5\right)\right)\right)\\
\mathbf{elif}\;d \leq -2 \cdot 10^{-311}:\\
\;\;\;\;\left(\left(-1 \cdot d\right) \cdot \frac{1}{\sqrt{\ell \cdot h}}\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\right) \cdot t\_0\\
\end{array}
\end{array}
if d < -2.60000000000000014e-91Initial program 76.7%
Applied rewrites76.8%
if -2.60000000000000014e-91 < d < -1.9999999999999e-311Initial program 47.0%
Taylor expanded in h around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6460.0
Applied rewrites60.0%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6460.3
Applied rewrites60.3%
lift-/.f64N/A
metadata-eval60.3
Applied rewrites60.3%
if -1.9999999999999e-311 < d Initial program 66.6%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6469.6
Applied rewrites69.6%
lift-/.f64N/A
metadata-eval69.6
Applied rewrites69.6%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lift-*.f6469.6
Applied rewrites69.6%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (- 1.0 (* (* 0.5 (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l)))))
(if (<= d -2.6e-91)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) t_0)
(if (<= d -2e-311)
(* (* (* -1.0 d) (/ 1.0 (sqrt (* l h)))) t_0)
(* (* (sqrt (/ 1.0 (* l h))) d) t_0)))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = 1.0 - ((0.5 * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l));
double tmp;
if (d <= -2.6e-91) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * t_0;
} else if (d <= -2e-311) {
tmp = ((-1.0 * d) * (1.0 / sqrt((l * h)))) * t_0;
} else {
tmp = (sqrt((1.0 / (l * h))) * d) * t_0;
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - ((0.5d0 * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l))
if (d <= (-2.6d-91)) then
tmp = (sqrt((d / l)) * sqrt((d / h))) * t_0
else if (d <= (-2d-311)) then
tmp = (((-1.0d0) * d) * (1.0d0 / sqrt((l * h)))) * t_0
else
tmp = (sqrt((1.0d0 / (l * h))) * d) * t_0
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = 1.0 - ((0.5 * Math.pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l));
double tmp;
if (d <= -2.6e-91) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * t_0;
} else if (d <= -2e-311) {
tmp = ((-1.0 * d) * (1.0 / Math.sqrt((l * h)))) * t_0;
} else {
tmp = (Math.sqrt((1.0 / (l * h))) * d) * t_0;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = 1.0 - ((0.5 * math.pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)) tmp = 0 if d <= -2.6e-91: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * t_0 elif d <= -2e-311: tmp = ((-1.0 * d) * (1.0 / math.sqrt((l * h)))) * t_0 else: tmp = (math.sqrt((1.0 / (l * h))) * d) * t_0 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(1.0 - Float64(Float64(0.5 * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l))) tmp = 0.0 if (d <= -2.6e-91) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * t_0); elseif (d <= -2e-311) tmp = Float64(Float64(Float64(-1.0 * d) * Float64(1.0 / sqrt(Float64(l * h)))) * t_0); else tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d) * t_0); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = 1.0 - ((0.5 * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l));
tmp = 0.0;
if (d <= -2.6e-91)
tmp = (sqrt((d / l)) * sqrt((d / h))) * t_0;
elseif (d <= -2e-311)
tmp = ((-1.0 * d) * (1.0 / sqrt((l * h)))) * t_0;
else
tmp = (sqrt((1.0 / (l * h))) * d) * t_0;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(1.0 - N[(N[(0.5 * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.6e-91], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[d, -2e-311], N[(N[(N[(-1.0 * d), $MachinePrecision] * N[(1.0 / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := 1 - \left(0.5 \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\\
\mathbf{if}\;d \leq -2.6 \cdot 10^{-91}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot t\_0\\
\mathbf{elif}\;d \leq -2 \cdot 10^{-311}:\\
\;\;\;\;\left(\left(-1 \cdot d\right) \cdot \frac{1}{\sqrt{\ell \cdot h}}\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\right) \cdot t\_0\\
\end{array}
\end{array}
if d < -2.60000000000000014e-91Initial program 76.7%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6476.7
Applied rewrites76.7%
lift-/.f64N/A
metadata-eval76.7
Applied rewrites76.7%
if -2.60000000000000014e-91 < d < -1.9999999999999e-311Initial program 47.0%
Taylor expanded in h around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6460.0
Applied rewrites60.0%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6460.3
Applied rewrites60.3%
lift-/.f64N/A
metadata-eval60.3
Applied rewrites60.3%
if -1.9999999999999e-311 < d Initial program 66.6%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6469.6
Applied rewrites69.6%
lift-/.f64N/A
metadata-eval69.6
Applied rewrites69.6%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lift-*.f6469.6
Applied rewrites69.6%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (- 1.0 (* (* 0.5 (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l)))))
(if (<= h -2.8e+253)
(*
(sqrt (* (/ d l) (/ d h)))
(- 1.0 (/ (* (* (pow (/ (* D_m M) (* 2.0 d)) 2.0) 0.5) h) l)))
(if (<= h -5e-310)
(* (* (* -1.0 d) (/ 1.0 (sqrt (* l h)))) t_0)
(if (<= h 2.3e+196)
(* (* (sqrt (/ 1.0 (* l h))) d) t_0)
(* (/ 1.0 (* (sqrt l) (sqrt h))) d))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = 1.0 - ((0.5 * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l));
double tmp;
if (h <= -2.8e+253) {
tmp = sqrt(((d / l) * (d / h))) * (1.0 - (((pow(((D_m * M) / (2.0 * d)), 2.0) * 0.5) * h) / l));
} else if (h <= -5e-310) {
tmp = ((-1.0 * d) * (1.0 / sqrt((l * h)))) * t_0;
} else if (h <= 2.3e+196) {
tmp = (sqrt((1.0 / (l * h))) * d) * t_0;
} else {
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - ((0.5d0 * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l))
if (h <= (-2.8d+253)) then
tmp = sqrt(((d / l) * (d / h))) * (1.0d0 - ((((((d_m * m) / (2.0d0 * d)) ** 2.0d0) * 0.5d0) * h) / l))
else if (h <= (-5d-310)) then
tmp = (((-1.0d0) * d) * (1.0d0 / sqrt((l * h)))) * t_0
else if (h <= 2.3d+196) then
tmp = (sqrt((1.0d0 / (l * h))) * d) * t_0
else
tmp = (1.0d0 / (sqrt(l) * sqrt(h))) * d
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = 1.0 - ((0.5 * Math.pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l));
double tmp;
if (h <= -2.8e+253) {
tmp = Math.sqrt(((d / l) * (d / h))) * (1.0 - (((Math.pow(((D_m * M) / (2.0 * d)), 2.0) * 0.5) * h) / l));
} else if (h <= -5e-310) {
tmp = ((-1.0 * d) * (1.0 / Math.sqrt((l * h)))) * t_0;
} else if (h <= 2.3e+196) {
tmp = (Math.sqrt((1.0 / (l * h))) * d) * t_0;
} else {
tmp = (1.0 / (Math.sqrt(l) * Math.sqrt(h))) * d;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = 1.0 - ((0.5 * math.pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)) tmp = 0 if h <= -2.8e+253: tmp = math.sqrt(((d / l) * (d / h))) * (1.0 - (((math.pow(((D_m * M) / (2.0 * d)), 2.0) * 0.5) * h) / l)) elif h <= -5e-310: tmp = ((-1.0 * d) * (1.0 / math.sqrt((l * h)))) * t_0 elif h <= 2.3e+196: tmp = (math.sqrt((1.0 / (l * h))) * d) * t_0 else: tmp = (1.0 / (math.sqrt(l) * math.sqrt(h))) * d return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(1.0 - Float64(Float64(0.5 * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l))) tmp = 0.0 if (h <= -2.8e+253) tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64((Float64(Float64(D_m * M) / Float64(2.0 * d)) ^ 2.0) * 0.5) * h) / l))); elseif (h <= -5e-310) tmp = Float64(Float64(Float64(-1.0 * d) * Float64(1.0 / sqrt(Float64(l * h)))) * t_0); elseif (h <= 2.3e+196) tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d) * t_0); else tmp = Float64(Float64(1.0 / Float64(sqrt(l) * sqrt(h))) * d); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = 1.0 - ((0.5 * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l));
tmp = 0.0;
if (h <= -2.8e+253)
tmp = sqrt(((d / l) * (d / h))) * (1.0 - ((((((D_m * M) / (2.0 * d)) ^ 2.0) * 0.5) * h) / l));
elseif (h <= -5e-310)
tmp = ((-1.0 * d) * (1.0 / sqrt((l * h)))) * t_0;
elseif (h <= 2.3e+196)
tmp = (sqrt((1.0 / (l * h))) * d) * t_0;
else
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(1.0 - N[(N[(0.5 * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -2.8e+253], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(N[(N[Power[N[(N[(D$95$m * M), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -5e-310], N[(N[(N[(-1.0 * d), $MachinePrecision] * N[(1.0 / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[h, 2.3e+196], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(1.0 / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := 1 - \left(0.5 \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\\
\mathbf{if}\;h \leq -2.8 \cdot 10^{+253}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 - \frac{\left({\left(\frac{D\_m \cdot M}{2 \cdot d}\right)}^{2} \cdot 0.5\right) \cdot h}{\ell}\right)\\
\mathbf{elif}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\left(-1 \cdot d\right) \cdot \frac{1}{\sqrt{\ell \cdot h}}\right) \cdot t\_0\\
\mathbf{elif}\;h \leq 2.3 \cdot 10^{+196}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\ell} \cdot \sqrt{h}} \cdot d\\
\end{array}
\end{array}
if h < -2.8e253Initial program 42.5%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites46.2%
lift-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6446.2
Applied rewrites46.2%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
pow1/2N/A
pow1/2N/A
*-commutativeN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6443.5
Applied rewrites43.5%
if -2.8e253 < h < -4.999999999999985e-310Initial program 68.3%
Taylor expanded in h around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6471.9
Applied rewrites71.9%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6472.2
Applied rewrites72.2%
lift-/.f64N/A
metadata-eval72.2
Applied rewrites72.2%
if -4.999999999999985e-310 < h < 2.2999999999999998e196Initial program 70.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6476.6
Applied rewrites76.6%
lift-/.f64N/A
metadata-eval76.6
Applied rewrites76.6%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lift-*.f6476.6
Applied rewrites76.6%
if 2.2999999999999998e196 < h Initial program 48.7%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6422.5
Applied rewrites22.5%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6422.4
Applied rewrites22.4%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6437.2
Applied rewrites37.2%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (- 1.0 (* (* 0.5 (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l)))))
(if (<= h -5e-310)
(* (* (* -1.0 d) (/ 1.0 (sqrt (* l h)))) t_0)
(if (<= h 2.3e+196)
(* (* (sqrt (/ 1.0 (* l h))) d) t_0)
(* (/ 1.0 (* (sqrt l) (sqrt h))) d)))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = 1.0 - ((0.5 * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l));
double tmp;
if (h <= -5e-310) {
tmp = ((-1.0 * d) * (1.0 / sqrt((l * h)))) * t_0;
} else if (h <= 2.3e+196) {
tmp = (sqrt((1.0 / (l * h))) * d) * t_0;
} else {
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - ((0.5d0 * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l))
if (h <= (-5d-310)) then
tmp = (((-1.0d0) * d) * (1.0d0 / sqrt((l * h)))) * t_0
else if (h <= 2.3d+196) then
tmp = (sqrt((1.0d0 / (l * h))) * d) * t_0
else
tmp = (1.0d0 / (sqrt(l) * sqrt(h))) * d
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = 1.0 - ((0.5 * Math.pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l));
double tmp;
if (h <= -5e-310) {
tmp = ((-1.0 * d) * (1.0 / Math.sqrt((l * h)))) * t_0;
} else if (h <= 2.3e+196) {
tmp = (Math.sqrt((1.0 / (l * h))) * d) * t_0;
} else {
tmp = (1.0 / (Math.sqrt(l) * Math.sqrt(h))) * d;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = 1.0 - ((0.5 * math.pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)) tmp = 0 if h <= -5e-310: tmp = ((-1.0 * d) * (1.0 / math.sqrt((l * h)))) * t_0 elif h <= 2.3e+196: tmp = (math.sqrt((1.0 / (l * h))) * d) * t_0 else: tmp = (1.0 / (math.sqrt(l) * math.sqrt(h))) * d return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(1.0 - Float64(Float64(0.5 * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l))) tmp = 0.0 if (h <= -5e-310) tmp = Float64(Float64(Float64(-1.0 * d) * Float64(1.0 / sqrt(Float64(l * h)))) * t_0); elseif (h <= 2.3e+196) tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d) * t_0); else tmp = Float64(Float64(1.0 / Float64(sqrt(l) * sqrt(h))) * d); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = 1.0 - ((0.5 * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l));
tmp = 0.0;
if (h <= -5e-310)
tmp = ((-1.0 * d) * (1.0 / sqrt((l * h)))) * t_0;
elseif (h <= 2.3e+196)
tmp = (sqrt((1.0 / (l * h))) * d) * t_0;
else
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(1.0 - N[(N[(0.5 * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -5e-310], N[(N[(N[(-1.0 * d), $MachinePrecision] * N[(1.0 / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[h, 2.3e+196], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(1.0 / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := 1 - \left(0.5 \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\\
\mathbf{if}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\left(-1 \cdot d\right) \cdot \frac{1}{\sqrt{\ell \cdot h}}\right) \cdot t\_0\\
\mathbf{elif}\;h \leq 2.3 \cdot 10^{+196}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\ell} \cdot \sqrt{h}} \cdot d\\
\end{array}
\end{array}
if h < -4.999999999999985e-310Initial program 66.0%
Taylor expanded in h around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6468.4
Applied rewrites68.4%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6468.7
Applied rewrites68.7%
lift-/.f64N/A
metadata-eval68.7
Applied rewrites68.7%
if -4.999999999999985e-310 < h < 2.2999999999999998e196Initial program 70.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6476.6
Applied rewrites76.6%
lift-/.f64N/A
metadata-eval76.6
Applied rewrites76.6%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lift-*.f6476.6
Applied rewrites76.6%
if 2.2999999999999998e196 < h Initial program 48.7%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6422.5
Applied rewrites22.5%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6422.4
Applied rewrites22.4%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6437.2
Applied rewrites37.2%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(if (<= h -2.2e-17)
(* (sqrt (/ d h)) (sqrt (/ d l)))
(if (<= h -5e-310)
(/ (* (- d) 1.0) (sqrt (* l h)))
(* (/ 1.0 (* (sqrt l) (sqrt h))) d))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (h <= -2.2e-17) {
tmp = sqrt((d / h)) * sqrt((d / l));
} else if (h <= -5e-310) {
tmp = (-d * 1.0) / sqrt((l * h));
} else {
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: tmp
if (h <= (-2.2d-17)) then
tmp = sqrt((d / h)) * sqrt((d / l))
else if (h <= (-5d-310)) then
tmp = (-d * 1.0d0) / sqrt((l * h))
else
tmp = (1.0d0 / (sqrt(l) * sqrt(h))) * d
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (h <= -2.2e-17) {
tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
} else if (h <= -5e-310) {
tmp = (-d * 1.0) / Math.sqrt((l * h));
} else {
tmp = (1.0 / (Math.sqrt(l) * Math.sqrt(h))) * d;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): tmp = 0 if h <= -2.2e-17: tmp = math.sqrt((d / h)) * math.sqrt((d / l)) elif h <= -5e-310: tmp = (-d * 1.0) / math.sqrt((l * h)) else: tmp = (1.0 / (math.sqrt(l) * math.sqrt(h))) * d return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) tmp = 0.0 if (h <= -2.2e-17) tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))); elseif (h <= -5e-310) tmp = Float64(Float64(Float64(-d) * 1.0) / sqrt(Float64(l * h))); else tmp = Float64(Float64(1.0 / Float64(sqrt(l) * sqrt(h))) * d); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
tmp = 0.0;
if (h <= -2.2e-17)
tmp = sqrt((d / h)) * sqrt((d / l));
elseif (h <= -5e-310)
tmp = (-d * 1.0) / sqrt((l * h));
else
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[h, -2.2e-17], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -5e-310], N[(N[((-d) * 1.0), $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -2.2 \cdot 10^{-17}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{elif}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{\left(-d\right) \cdot 1}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\ell} \cdot \sqrt{h}} \cdot d\\
\end{array}
\end{array}
if h < -2.2e-17Initial program 61.8%
Taylor expanded in d around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
pow-prod-downN/A
*-commutativeN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6422.7
Applied rewrites22.7%
Applied rewrites22.6%
Taylor expanded in d around inf
lift-sqrt.f64N/A
lift-/.f6436.3
Applied rewrites36.3%
if -2.2e-17 < h < -4.999999999999985e-310Initial program 70.8%
Taylor expanded in l around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6452.8
Applied rewrites52.8%
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
mul-1-negN/A
*-commutativeN/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
*-commutativeN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lift-sqrt.f64N/A
lift-*.f6453.4
Applied rewrites53.4%
if -4.999999999999985e-310 < h Initial program 66.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6442.2
Applied rewrites42.2%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6442.5
Applied rewrites42.5%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6450.4
Applied rewrites50.4%
D_m = (fabs.f64 D) NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M D_m) :precision binary64 (if (<= l 2.2e-290) (/ (* (- d) 1.0) (sqrt (* l h))) (* (/ 1.0 (* (sqrt l) (sqrt h))) d)))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (l <= 2.2e-290) {
tmp = (-d * 1.0) / sqrt((l * h));
} else {
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: tmp
if (l <= 2.2d-290) then
tmp = (-d * 1.0d0) / sqrt((l * h))
else
tmp = (1.0d0 / (sqrt(l) * sqrt(h))) * d
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (l <= 2.2e-290) {
tmp = (-d * 1.0) / Math.sqrt((l * h));
} else {
tmp = (1.0 / (Math.sqrt(l) * Math.sqrt(h))) * d;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): tmp = 0 if l <= 2.2e-290: tmp = (-d * 1.0) / math.sqrt((l * h)) else: tmp = (1.0 / (math.sqrt(l) * math.sqrt(h))) * d return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) tmp = 0.0 if (l <= 2.2e-290) tmp = Float64(Float64(Float64(-d) * 1.0) / sqrt(Float64(l * h))); else tmp = Float64(Float64(1.0 / Float64(sqrt(l) * sqrt(h))) * d); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
tmp = 0.0;
if (l <= 2.2e-290)
tmp = (-d * 1.0) / sqrt((l * h));
else
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[l, 2.2e-290], N[(N[((-d) * 1.0), $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 2.2 \cdot 10^{-290}:\\
\;\;\;\;\frac{\left(-d\right) \cdot 1}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\ell} \cdot \sqrt{h}} \cdot d\\
\end{array}
\end{array}
if l < 2.2000000000000001e-290Initial program 66.2%
Taylor expanded in l around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6441.7
Applied rewrites41.7%
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
mul-1-negN/A
*-commutativeN/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
*-commutativeN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lift-sqrt.f64N/A
lift-*.f6441.9
Applied rewrites41.9%
if 2.2000000000000001e-290 < l Initial program 66.4%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6442.8
Applied rewrites42.8%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6443.0
Applied rewrites43.0%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6450.8
Applied rewrites50.8%
D_m = (fabs.f64 D) NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M D_m) :precision binary64 (let* ((t_0 (sqrt (* l h)))) (if (<= l -9.2e-308) (/ (* (- d) 1.0) t_0) (/ (* 1.0 d) t_0))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = sqrt((l * h));
double tmp;
if (l <= -9.2e-308) {
tmp = (-d * 1.0) / t_0;
} else {
tmp = (1.0 * d) / t_0;
}
return tmp;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((l * h))
if (l <= (-9.2d-308)) then
tmp = (-d * 1.0d0) / t_0
else
tmp = (1.0d0 * d) / t_0
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = Math.sqrt((l * h));
double tmp;
if (l <= -9.2e-308) {
tmp = (-d * 1.0) / t_0;
} else {
tmp = (1.0 * d) / t_0;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = math.sqrt((l * h)) tmp = 0 if l <= -9.2e-308: tmp = (-d * 1.0) / t_0 else: tmp = (1.0 * d) / t_0 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = sqrt(Float64(l * h)) tmp = 0.0 if (l <= -9.2e-308) tmp = Float64(Float64(Float64(-d) * 1.0) / t_0); else tmp = Float64(Float64(1.0 * d) / t_0); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = sqrt((l * h));
tmp = 0.0;
if (l <= -9.2e-308)
tmp = (-d * 1.0) / t_0;
else
tmp = (1.0 * d) / t_0;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -9.2e-308], N[(N[((-d) * 1.0), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(1.0 * d), $MachinePrecision] / t$95$0), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;\ell \leq -9.2 \cdot 10^{-308}:\\
\;\;\;\;\frac{\left(-d\right) \cdot 1}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot d}{t\_0}\\
\end{array}
\end{array}
if l < -9.1999999999999996e-308Initial program 66.0%
Taylor expanded in l around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6442.2
Applied rewrites42.2%
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
mul-1-negN/A
*-commutativeN/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
*-commutativeN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lift-sqrt.f64N/A
lift-*.f6442.5
Applied rewrites42.5%
if -9.1999999999999996e-308 < l Initial program 66.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6442.2
Applied rewrites42.2%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6442.5
Applied rewrites42.5%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-sqrt.f64N/A
lift-*.f6442.5
Applied rewrites42.5%
D_m = (fabs.f64 D) NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M D_m) :precision binary64 (* (sqrt (/ 1.0 (* l h))) d))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
return sqrt((1.0 / (l * h))) * d;
}
D_m = private
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_m
code = sqrt((1.0d0 / (l * h))) * d
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
return Math.sqrt((1.0 / (l * h))) * d;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): return math.sqrt((1.0 / (l * h))) * d
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) return Float64(sqrt(Float64(1.0 / Float64(l * h))) * d) end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp = code(d, h, l, M, D_m)
tmp = sqrt((1.0 / (l * h))) * d;
end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\sqrt{\frac{1}{\ell \cdot h}} \cdot d
\end{array}
Initial program 66.3%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6426.1
Applied rewrites26.1%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lift-*.f6426.1
Applied rewrites26.1%
herbie shell --seed 2025091
(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)))))