
(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 23 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (* l h))) (t_1 (/ (fabs d_m) t_0)))
(if (<= l -5e+15)
(*
t_1
(-
1.0
(* (/ 0.125 d_m) (/ (* (* (* (* M_m M_m) h) D_m) D_m) (* l d_m)))))
(if (<= l -1e-147)
(/
(fma
(* (/ (* (* (* D_m M_m) M_m) D_m) d_m) -0.125)
t_0
(* (sqrt (* (* l l) (/ l h))) d_m))
(* l l))
(if (<= l 1e-292)
(*
t_1
(-
1.0
(* (/ (* h (* (* (* D_m M_m) D_m) (/ M_m (* d_m d_m)))) l) 0.125)))
(*
(* (/ (sqrt (/ 1.0 l)) (sqrt h)) d_m)
(-
1.0
(*
(* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0))
(/ h l)))))))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((l * h));
double t_1 = fabs(d_m) / t_0;
double tmp;
if (l <= -5e+15) {
tmp = t_1 * (1.0 - ((0.125 / d_m) * (((((M_m * M_m) * h) * D_m) * D_m) / (l * d_m))));
} else if (l <= -1e-147) {
tmp = fma((((((D_m * M_m) * M_m) * D_m) / d_m) * -0.125), t_0, (sqrt(((l * l) * (l / h))) * d_m)) / (l * l);
} else if (l <= 1e-292) {
tmp = t_1 * (1.0 - (((h * (((D_m * M_m) * D_m) * (M_m / (d_m * d_m)))) / l) * 0.125));
} else {
tmp = ((sqrt((1.0 / l)) / sqrt(h)) * d_m) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
}
return tmp;
}
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = sqrt(Float64(l * h)) t_1 = Float64(abs(d_m) / t_0) tmp = 0.0 if (l <= -5e+15) tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(0.125 / d_m) * Float64(Float64(Float64(Float64(Float64(M_m * M_m) * h) * D_m) * D_m) / Float64(l * d_m))))); elseif (l <= -1e-147) tmp = Float64(fma(Float64(Float64(Float64(Float64(Float64(D_m * M_m) * M_m) * D_m) / d_m) * -0.125), t_0, Float64(sqrt(Float64(Float64(l * l) * Float64(l / h))) * d_m)) / Float64(l * l)); elseif (l <= 1e-292) tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(Float64(h * Float64(Float64(Float64(D_m * M_m) * D_m) * Float64(M_m / Float64(d_m * d_m)))) / l) * 0.125))); else tmp = Float64(Float64(Float64(sqrt(Float64(1.0 / l)) / sqrt(h)) * d_m) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))); end return tmp end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Abs[d$95$m], $MachinePrecision] / t$95$0), $MachinePrecision]}, If[LessEqual[l, -5e+15], N[(t$95$1 * N[(1.0 - N[(N[(0.125 / d$95$m), $MachinePrecision] * N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] / N[(l * d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -1e-147], N[(N[(N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] / d$95$m), $MachinePrecision] * -0.125), $MachinePrecision] * t$95$0 + N[(N[Sqrt[N[(N[(l * l), $MachinePrecision] * N[(l / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision]), $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1e-292], N[(t$95$1 * N[(1.0 - N[(N[(N[(h * N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(M$95$m / N[(d$95$m * d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Sqrt[N[(1.0 / l), $MachinePrecision]], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
t_1 := \frac{\left|d\_m\right|}{t\_0}\\
\mathbf{if}\;\ell \leq -5 \cdot 10^{+15}:\\
\;\;\;\;t\_1 \cdot \left(1 - \frac{0.125}{d\_m} \cdot \frac{\left(\left(\left(M\_m \cdot M\_m\right) \cdot h\right) \cdot D\_m\right) \cdot D\_m}{\ell \cdot d\_m}\right)\\
\mathbf{elif}\;\ell \leq -1 \cdot 10^{-147}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{\left(\left(D\_m \cdot M\_m\right) \cdot M\_m\right) \cdot D\_m}{d\_m} \cdot -0.125, t\_0, \sqrt{\left(\ell \cdot \ell\right) \cdot \frac{\ell}{h}} \cdot d\_m\right)}{\ell \cdot \ell}\\
\mathbf{elif}\;\ell \leq 10^{-292}:\\
\;\;\;\;t\_1 \cdot \left(1 - \frac{h \cdot \left(\left(\left(D\_m \cdot M\_m\right) \cdot D\_m\right) \cdot \frac{M\_m}{d\_m \cdot d\_m}\right)}{\ell} \cdot 0.125\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}} \cdot d\_m\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\end{array}
\end{array}
if l < -5e15Initial program 2.0%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f640.3
Applied rewrites0.3%
Applied rewrites48.9%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
pow2N/A
pow-prod-downN/A
associate-*r*N/A
Applied rewrites59.8%
if -5e15 < l < -9.9999999999999997e-148Initial program 3.5%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites81.0%
Taylor expanded in l around 0
Applied rewrites75.8%
if -9.9999999999999997e-148 < l < 1.0000000000000001e-292Initial program 17.5%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6413.6
Applied rewrites13.6%
Applied rewrites67.6%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
pow2N/A
pow-prod-downN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lower-/.f64N/A
associate-/r*N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites66.0%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
associate-*l/N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*l*N/A
unpow2N/A
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/l*N/A
Applied rewrites73.2%
if 1.0000000000000001e-292 < l Initial program 66.1%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.2%
lift-*.f64N/A
lift-/.f64N/A
lower-sqrt.f64N/A
associate-/r*N/A
inv-powN/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-/.f64N/A
lower-sqrt.f6480.6
Applied rewrites80.6%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0 (* (/ D_m (+ d_m d_m)) M_m))
(t_1 (sqrt (* l h)))
(t_2 (/ (fabs d_m) t_1)))
(if (<= l -5e+15)
(*
t_2
(-
1.0
(* (/ 0.125 d_m) (/ (* (* (* (* M_m M_m) h) D_m) D_m) (* l d_m)))))
(if (<= l -1e-147)
(/
(fma
(* (/ (* (* (* D_m M_m) M_m) D_m) d_m) -0.125)
t_1
(* (sqrt (* (* l l) (/ l h))) d_m))
(* l l))
(if (<= l 1e-292)
(*
t_2
(-
1.0
(* (/ (* h (* (* (* D_m M_m) D_m) (/ M_m (* d_m d_m)))) l) 0.125)))
(*
(* (/ (sqrt (/ 1.0 l)) (sqrt h)) d_m)
(- 1.0 (* (* t_0 (* t_0 0.5)) (/ h l)))))))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (D_m / (d_m + d_m)) * M_m;
double t_1 = sqrt((l * h));
double t_2 = fabs(d_m) / t_1;
double tmp;
if (l <= -5e+15) {
tmp = t_2 * (1.0 - ((0.125 / d_m) * (((((M_m * M_m) * h) * D_m) * D_m) / (l * d_m))));
} else if (l <= -1e-147) {
tmp = fma((((((D_m * M_m) * M_m) * D_m) / d_m) * -0.125), t_1, (sqrt(((l * l) * (l / h))) * d_m)) / (l * l);
} else if (l <= 1e-292) {
tmp = t_2 * (1.0 - (((h * (((D_m * M_m) * D_m) * (M_m / (d_m * d_m)))) / l) * 0.125));
} else {
tmp = ((sqrt((1.0 / l)) / sqrt(h)) * d_m) * (1.0 - ((t_0 * (t_0 * 0.5)) * (h / l)));
}
return tmp;
}
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = Float64(Float64(D_m / Float64(d_m + d_m)) * M_m) t_1 = sqrt(Float64(l * h)) t_2 = Float64(abs(d_m) / t_1) tmp = 0.0 if (l <= -5e+15) tmp = Float64(t_2 * Float64(1.0 - Float64(Float64(0.125 / d_m) * Float64(Float64(Float64(Float64(Float64(M_m * M_m) * h) * D_m) * D_m) / Float64(l * d_m))))); elseif (l <= -1e-147) tmp = Float64(fma(Float64(Float64(Float64(Float64(Float64(D_m * M_m) * M_m) * D_m) / d_m) * -0.125), t_1, Float64(sqrt(Float64(Float64(l * l) * Float64(l / h))) * d_m)) / Float64(l * l)); elseif (l <= 1e-292) tmp = Float64(t_2 * Float64(1.0 - Float64(Float64(Float64(h * Float64(Float64(Float64(D_m * M_m) * D_m) * Float64(M_m / Float64(d_m * d_m)))) / l) * 0.125))); else tmp = Float64(Float64(Float64(sqrt(Float64(1.0 / l)) / sqrt(h)) * d_m) * Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * 0.5)) * Float64(h / l)))); end return tmp end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(D$95$m / N[(d$95$m + d$95$m), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Abs[d$95$m], $MachinePrecision] / t$95$1), $MachinePrecision]}, If[LessEqual[l, -5e+15], N[(t$95$2 * N[(1.0 - N[(N[(0.125 / d$95$m), $MachinePrecision] * N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] / N[(l * d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -1e-147], N[(N[(N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] / d$95$m), $MachinePrecision] * -0.125), $MachinePrecision] * t$95$1 + N[(N[Sqrt[N[(N[(l * l), $MachinePrecision] * N[(l / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision]), $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1e-292], N[(t$95$2 * N[(1.0 - N[(N[(N[(h * N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(M$95$m / N[(d$95$m * d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Sqrt[N[(1.0 / l), $MachinePrecision]], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision] * N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * 0.5), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{D\_m}{d\_m + d\_m} \cdot M\_m\\
t_1 := \sqrt{\ell \cdot h}\\
t_2 := \frac{\left|d\_m\right|}{t\_1}\\
\mathbf{if}\;\ell \leq -5 \cdot 10^{+15}:\\
\;\;\;\;t\_2 \cdot \left(1 - \frac{0.125}{d\_m} \cdot \frac{\left(\left(\left(M\_m \cdot M\_m\right) \cdot h\right) \cdot D\_m\right) \cdot D\_m}{\ell \cdot d\_m}\right)\\
\mathbf{elif}\;\ell \leq -1 \cdot 10^{-147}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{\left(\left(D\_m \cdot M\_m\right) \cdot M\_m\right) \cdot D\_m}{d\_m} \cdot -0.125, t\_1, \sqrt{\left(\ell \cdot \ell\right) \cdot \frac{\ell}{h}} \cdot d\_m\right)}{\ell \cdot \ell}\\
\mathbf{elif}\;\ell \leq 10^{-292}:\\
\;\;\;\;t\_2 \cdot \left(1 - \frac{h \cdot \left(\left(\left(D\_m \cdot M\_m\right) \cdot D\_m\right) \cdot \frac{M\_m}{d\_m \cdot d\_m}\right)}{\ell} \cdot 0.125\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}} \cdot d\_m\right) \cdot \left(1 - \left(t\_0 \cdot \left(t\_0 \cdot 0.5\right)\right) \cdot \frac{h}{\ell}\right)\\
\end{array}
\end{array}
if l < -5e15Initial program 2.0%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f640.3
Applied rewrites0.3%
Applied rewrites48.9%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
pow2N/A
pow-prod-downN/A
associate-*r*N/A
Applied rewrites59.8%
if -5e15 < l < -9.9999999999999997e-148Initial program 3.5%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites81.0%
Taylor expanded in l around 0
Applied rewrites75.8%
if -9.9999999999999997e-148 < l < 1.0000000000000001e-292Initial program 17.5%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6413.6
Applied rewrites13.6%
Applied rewrites67.6%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
pow2N/A
pow-prod-downN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lower-/.f64N/A
associate-/r*N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites66.0%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
associate-*l/N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*l*N/A
unpow2N/A
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/l*N/A
Applied rewrites73.2%
if 1.0000000000000001e-292 < l Initial program 66.1%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.2%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
count-2-revN/A
lift-+.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
count-2-revN/A
lift-+.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6469.5
lift-/.f64N/A
Applied rewrites69.5%
lift-*.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-sqrt.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lift-/.f64N/A
lower-sqrt.f6479.7
Applied rewrites79.7%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0 (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0))
(t_1
(*
(* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) t_0) (/ h l)))))
(t_2 (* (/ d_m (sqrt (* l h))) (- 1.0 (* (* 0.5 t_0) (/ h l))))))
(if (<= t_1 5e-169)
t_2
(if (<= t_1 4e+270)
(*
(*
(fma
(/ (* (* (* (* D_m M_m) M_m) (/ D_m (* 4.0 d_m))) -0.5) d_m)
(/ h l)
1.0)
(sqrt (/ d_m l)))
(sqrt (/ d_m h)))
t_2))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = pow(((M_m * D_m) / (2.0 * d_m)), 2.0);
double t_1 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * t_0) * (h / l)));
double t_2 = (d_m / sqrt((l * h))) * (1.0 - ((0.5 * t_0) * (h / l)));
double tmp;
if (t_1 <= 5e-169) {
tmp = t_2;
} else if (t_1 <= 4e+270) {
tmp = (fma((((((D_m * M_m) * M_m) * (D_m / (4.0 * d_m))) * -0.5) / d_m), (h / l), 1.0) * sqrt((d_m / l))) * sqrt((d_m / h));
} else {
tmp = t_2;
}
return tmp;
}
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0 t_1 = Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * t_0) * Float64(h / l)))) t_2 = Float64(Float64(d_m / sqrt(Float64(l * h))) * Float64(1.0 - Float64(Float64(0.5 * t_0) * Float64(h / l)))) tmp = 0.0 if (t_1 <= 5e-169) tmp = t_2; elseif (t_1 <= 4e+270) tmp = Float64(Float64(fma(Float64(Float64(Float64(Float64(Float64(D_m * M_m) * M_m) * Float64(D_m / Float64(4.0 * d_m))) * -0.5) / d_m), Float64(h / l), 1.0) * sqrt(Float64(d_m / l))) * sqrt(Float64(d_m / h))); else tmp = t_2; end return tmp end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * t$95$0), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(d$95$m / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(0.5 * t$95$0), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 5e-169], t$95$2, If[LessEqual[t$95$1, 4e+270], N[(N[(N[(N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(D$95$m / N[(4.0 * d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision] / d$95$m), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d$95$m / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d$95$m / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2}\\
t_1 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot t\_0\right) \cdot \frac{h}{\ell}\right)\\
t_2 := \frac{d\_m}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(0.5 \cdot t\_0\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{-169}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+270}:\\
\;\;\;\;\left(\mathsf{fma}\left(\frac{\left(\left(\left(D\_m \cdot M\_m\right) \cdot M\_m\right) \cdot \frac{D\_m}{4 \cdot d\_m}\right) \cdot -0.5}{d\_m}, \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d\_m}{\ell}}\right) \cdot \sqrt{\frac{d\_m}{h}}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\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.0000000000000002e-169 or 4.0000000000000002e270 < (*.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 26.0%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites68.4%
lift-/.f64N/A
metadata-eval68.4
Applied rewrites68.4%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
metadata-evalN/A
lift-sqrt.f64N/A
lift-*.f64N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f6468.6
Applied rewrites68.6%
if 5.0000000000000002e-169 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 4.0000000000000002e270Initial program 99.1%
Applied rewrites49.0%
Applied rewrites90.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lower-/.f64N/A
lift-*.f6497.6
Applied rewrites97.6%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
(-
1.0
(*
(* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0))
(/ h l))))))
(if (<= t_0 0.0)
(*
(* (sqrt (/ 1.0 (* l h))) d_m)
(-
1.0
(*
(* (* (/ D_m (+ d_m d_m)) M_m) (* (/ (* D_m M_m) d_m) 0.25))
(/ h l))))
(if (<= t_0 4e+238)
(/ d_m (* (sqrt l) (sqrt h)))
(*
(/ (fabs d_m) (sqrt (* l h)))
(-
1.0
(*
(* M_m (* (* D_m M_m) (/ (* D_m h) (* (* d_m d_m) l))))
0.125)))))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= 0.0) {
tmp = (sqrt((1.0 / (l * h))) * d_m) * (1.0 - ((((D_m / (d_m + d_m)) * M_m) * (((D_m * M_m) / d_m) * 0.25)) * (h / l)));
} else if (t_0 <= 4e+238) {
tmp = d_m / (sqrt(l) * sqrt(h));
} else {
tmp = (fabs(d_m) / sqrt((l * h))) * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125));
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: t_0
real(8) :: tmp
t_0 = (((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m_1) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
if (t_0 <= 0.0d0) then
tmp = (sqrt((1.0d0 / (l * h))) * d_m) * (1.0d0 - ((((d_m_1 / (d_m + d_m)) * m_m) * (((d_m_1 * m_m) / d_m) * 0.25d0)) * (h / l)))
else if (t_0 <= 4d+238) then
tmp = d_m / (sqrt(l) * sqrt(h))
else
tmp = (abs(d_m) / sqrt((l * h))) * (1.0d0 - ((m_m * ((d_m_1 * m_m) * ((d_m_1 * h) / ((d_m * d_m) * l)))) * 0.125d0))
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= 0.0) {
tmp = (Math.sqrt((1.0 / (l * h))) * d_m) * (1.0 - ((((D_m / (d_m + d_m)) * M_m) * (((D_m * M_m) / d_m) * 0.25)) * (h / l)));
} else if (t_0 <= 4e+238) {
tmp = d_m / (Math.sqrt(l) * Math.sqrt(h));
} else {
tmp = (Math.abs(d_m) / Math.sqrt((l * h))) * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125));
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): t_0 = (math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l))) tmp = 0 if t_0 <= 0.0: tmp = (math.sqrt((1.0 / (l * h))) * d_m) * (1.0 - ((((D_m / (d_m + d_m)) * M_m) * (((D_m * M_m) / d_m) * 0.25)) * (h / l))) elif t_0 <= 4e+238: tmp = d_m / (math.sqrt(l) * math.sqrt(h)) else: tmp = (math.fabs(d_m) / math.sqrt((l * h))) * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125)) return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m) * Float64(1.0 - Float64(Float64(Float64(Float64(D_m / Float64(d_m + d_m)) * M_m) * Float64(Float64(Float64(D_m * M_m) / d_m) * 0.25)) * Float64(h / l)))); elseif (t_0 <= 4e+238) tmp = Float64(d_m / Float64(sqrt(l) * sqrt(h))); else tmp = Float64(Float64(abs(d_m) / sqrt(Float64(l * h))) * Float64(1.0 - Float64(Float64(M_m * Float64(Float64(D_m * M_m) * Float64(Float64(D_m * h) / Float64(Float64(d_m * d_m) * l)))) * 0.125))); end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
t_0 = (((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d_m)) ^ 2.0)) * (h / l)));
tmp = 0.0;
if (t_0 <= 0.0)
tmp = (sqrt((1.0 / (l * h))) * d_m) * (1.0 - ((((D_m / (d_m + d_m)) * M_m) * (((D_m * M_m) / d_m) * 0.25)) * (h / l)));
elseif (t_0 <= 4e+238)
tmp = d_m / (sqrt(l) * sqrt(h));
else
tmp = (abs(d_m) / sqrt((l * h))) * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125));
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(D$95$m / N[(d$95$m + d$95$m), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] / d$95$m), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e+238], N[(d$95$m / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Abs[d$95$m], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(M$95$m * N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(N[(D$95$m * h), $MachinePrecision] / N[(N[(d$95$m * d$95$m), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\right) \cdot \left(1 - \left(\left(\frac{D\_m}{d\_m + d\_m} \cdot M\_m\right) \cdot \left(\frac{D\_m \cdot M\_m}{d\_m} \cdot 0.25\right)\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+238}:\\
\;\;\;\;\frac{d\_m}{\sqrt{\ell} \cdot \sqrt{h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|d\_m\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(M\_m \cdot \left(\left(D\_m \cdot M\_m\right) \cdot \frac{D\_m \cdot h}{\left(d\_m \cdot d\_m\right) \cdot \ell}\right)\right) \cdot 0.125\right)\\
\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 79.9%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites79.6%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
count-2-revN/A
lift-+.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
count-2-revN/A
lift-+.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6478.1
lift-/.f64N/A
Applied rewrites78.1%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f6477.6
Applied rewrites77.6%
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)))) < 4.0000000000000002e238Initial program 98.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.7%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
metadata-evalN/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6475.9
Applied rewrites75.9%
Applied rewrites76.0%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6498.7
Applied rewrites98.7%
if 4.0000000000000002e238 < (*.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 8.2%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f648.2
Applied rewrites8.2%
Applied rewrites59.2%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lower-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f6462.2
Applied rewrites62.2%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (* l h)))
(t_1 (* (/ D_m (+ d_m d_m)) M_m))
(t_2
(*
(* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
(-
1.0
(*
(* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0))
(/ h l))))))
(if (<= t_2 0.0)
(* (/ d_m t_0) (- 1.0 (* (* t_1 (* t_1 0.5)) (/ h l))))
(if (<= t_2 4e+238)
(/ d_m (* (sqrt l) (sqrt h)))
(*
(/ (fabs d_m) t_0)
(-
1.0
(*
(* M_m (* (* D_m M_m) (/ (* D_m h) (* (* d_m d_m) l))))
0.125)))))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((l * h));
double t_1 = (D_m / (d_m + d_m)) * M_m;
double t_2 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double tmp;
if (t_2 <= 0.0) {
tmp = (d_m / t_0) * (1.0 - ((t_1 * (t_1 * 0.5)) * (h / l)));
} else if (t_2 <= 4e+238) {
tmp = d_m / (sqrt(l) * sqrt(h));
} else {
tmp = (fabs(d_m) / t_0) * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125));
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sqrt((l * h))
t_1 = (d_m_1 / (d_m + d_m)) * m_m
t_2 = (((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m_1) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
if (t_2 <= 0.0d0) then
tmp = (d_m / t_0) * (1.0d0 - ((t_1 * (t_1 * 0.5d0)) * (h / l)))
else if (t_2 <= 4d+238) then
tmp = d_m / (sqrt(l) * sqrt(h))
else
tmp = (abs(d_m) / t_0) * (1.0d0 - ((m_m * ((d_m_1 * m_m) * ((d_m_1 * h) / ((d_m * d_m) * l)))) * 0.125d0))
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = Math.sqrt((l * h));
double t_1 = (D_m / (d_m + d_m)) * M_m;
double t_2 = (Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double tmp;
if (t_2 <= 0.0) {
tmp = (d_m / t_0) * (1.0 - ((t_1 * (t_1 * 0.5)) * (h / l)));
} else if (t_2 <= 4e+238) {
tmp = d_m / (Math.sqrt(l) * Math.sqrt(h));
} else {
tmp = (Math.abs(d_m) / t_0) * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125));
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): t_0 = math.sqrt((l * h)) t_1 = (D_m / (d_m + d_m)) * M_m t_2 = (math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l))) tmp = 0 if t_2 <= 0.0: tmp = (d_m / t_0) * (1.0 - ((t_1 * (t_1 * 0.5)) * (h / l))) elif t_2 <= 4e+238: tmp = d_m / (math.sqrt(l) * math.sqrt(h)) else: tmp = (math.fabs(d_m) / t_0) * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125)) return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = sqrt(Float64(l * h)) t_1 = Float64(Float64(D_m / Float64(d_m + d_m)) * M_m) t_2 = Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_2 <= 0.0) tmp = Float64(Float64(d_m / t_0) * Float64(1.0 - Float64(Float64(t_1 * Float64(t_1 * 0.5)) * Float64(h / l)))); elseif (t_2 <= 4e+238) tmp = Float64(d_m / Float64(sqrt(l) * sqrt(h))); else tmp = Float64(Float64(abs(d_m) / t_0) * Float64(1.0 - Float64(Float64(M_m * Float64(Float64(D_m * M_m) * Float64(Float64(D_m * h) / Float64(Float64(d_m * d_m) * l)))) * 0.125))); end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
t_0 = sqrt((l * h));
t_1 = (D_m / (d_m + d_m)) * M_m;
t_2 = (((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d_m)) ^ 2.0)) * (h / l)));
tmp = 0.0;
if (t_2 <= 0.0)
tmp = (d_m / t_0) * (1.0 - ((t_1 * (t_1 * 0.5)) * (h / l)));
elseif (t_2 <= 4e+238)
tmp = d_m / (sqrt(l) * sqrt(h));
else
tmp = (abs(d_m) / t_0) * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125));
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(D$95$m / N[(d$95$m + d$95$m), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, 0.0], N[(N[(d$95$m / t$95$0), $MachinePrecision] * N[(1.0 - N[(N[(t$95$1 * N[(t$95$1 * 0.5), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 4e+238], N[(d$95$m / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Abs[d$95$m], $MachinePrecision] / t$95$0), $MachinePrecision] * N[(1.0 - N[(N[(M$95$m * N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(N[(D$95$m * h), $MachinePrecision] / N[(N[(d$95$m * d$95$m), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
t_1 := \frac{D\_m}{d\_m + d\_m} \cdot M\_m\\
t_2 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_2 \leq 0:\\
\;\;\;\;\frac{d\_m}{t\_0} \cdot \left(1 - \left(t\_1 \cdot \left(t\_1 \cdot 0.5\right)\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+238}:\\
\;\;\;\;\frac{d\_m}{\sqrt{\ell} \cdot \sqrt{h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|d\_m\right|}{t\_0} \cdot \left(1 - \left(M\_m \cdot \left(\left(D\_m \cdot M\_m\right) \cdot \frac{D\_m \cdot h}{\left(d\_m \cdot d\_m\right) \cdot \ell}\right)\right) \cdot 0.125\right)\\
\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 79.9%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites79.6%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
count-2-revN/A
lift-+.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
count-2-revN/A
lift-+.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6478.1
lift-/.f64N/A
Applied rewrites78.1%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
metadata-evalN/A
lift-sqrt.f64N/A
lift-*.f64N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f6478.2
Applied rewrites78.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)))) < 4.0000000000000002e238Initial program 98.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.7%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
metadata-evalN/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6475.9
Applied rewrites75.9%
Applied rewrites76.0%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6498.7
Applied rewrites98.7%
if 4.0000000000000002e238 < (*.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 8.2%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f648.2
Applied rewrites8.2%
Applied rewrites59.2%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lower-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f6462.2
Applied rewrites62.2%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0)) (/ h l)))))
(t_1 (/ (fabs d_m) (sqrt (* l h)))))
(if (<= t_0 0.0)
(*
t_1
(-
1.0
(* (/ 0.125 d_m) (/ (* (* (* (* M_m M_m) h) D_m) D_m) (* l d_m)))))
(if (<= t_0 4e+238)
(/ d_m (* (sqrt l) (sqrt h)))
(*
t_1
(-
1.0
(*
(* M_m (* (* D_m M_m) (/ (* D_m h) (* (* d_m d_m) l))))
0.125)))))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double t_1 = fabs(d_m) / sqrt((l * h));
double tmp;
if (t_0 <= 0.0) {
tmp = t_1 * (1.0 - ((0.125 / d_m) * (((((M_m * M_m) * h) * D_m) * D_m) / (l * d_m))));
} else if (t_0 <= 4e+238) {
tmp = d_m / (sqrt(l) * sqrt(h));
} else {
tmp = t_1 * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125));
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m_1) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
t_1 = abs(d_m) / sqrt((l * h))
if (t_0 <= 0.0d0) then
tmp = t_1 * (1.0d0 - ((0.125d0 / d_m) * (((((m_m * m_m) * h) * d_m_1) * d_m_1) / (l * d_m))))
else if (t_0 <= 4d+238) then
tmp = d_m / (sqrt(l) * sqrt(h))
else
tmp = t_1 * (1.0d0 - ((m_m * ((d_m_1 * m_m) * ((d_m_1 * h) / ((d_m * d_m) * l)))) * 0.125d0))
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double t_1 = Math.abs(d_m) / Math.sqrt((l * h));
double tmp;
if (t_0 <= 0.0) {
tmp = t_1 * (1.0 - ((0.125 / d_m) * (((((M_m * M_m) * h) * D_m) * D_m) / (l * d_m))));
} else if (t_0 <= 4e+238) {
tmp = d_m / (Math.sqrt(l) * Math.sqrt(h));
} else {
tmp = t_1 * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125));
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): t_0 = (math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l))) t_1 = math.fabs(d_m) / math.sqrt((l * h)) tmp = 0 if t_0 <= 0.0: tmp = t_1 * (1.0 - ((0.125 / d_m) * (((((M_m * M_m) * h) * D_m) * D_m) / (l * d_m)))) elif t_0 <= 4e+238: tmp = d_m / (math.sqrt(l) * math.sqrt(h)) else: tmp = t_1 * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125)) return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(abs(d_m) / sqrt(Float64(l * h))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(0.125 / d_m) * Float64(Float64(Float64(Float64(Float64(M_m * M_m) * h) * D_m) * D_m) / Float64(l * d_m))))); elseif (t_0 <= 4e+238) tmp = Float64(d_m / Float64(sqrt(l) * sqrt(h))); else tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(M_m * Float64(Float64(D_m * M_m) * Float64(Float64(D_m * h) / Float64(Float64(d_m * d_m) * l)))) * 0.125))); end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
t_0 = (((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d_m)) ^ 2.0)) * (h / l)));
t_1 = abs(d_m) / sqrt((l * h));
tmp = 0.0;
if (t_0 <= 0.0)
tmp = t_1 * (1.0 - ((0.125 / d_m) * (((((M_m * M_m) * h) * D_m) * D_m) / (l * d_m))));
elseif (t_0 <= 4e+238)
tmp = d_m / (sqrt(l) * sqrt(h));
else
tmp = t_1 * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125));
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Abs[d$95$m], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(t$95$1 * N[(1.0 - N[(N[(0.125 / d$95$m), $MachinePrecision] * N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] / N[(l * d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e+238], N[(d$95$m / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(1.0 - N[(N[(M$95$m * N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(N[(D$95$m * h), $MachinePrecision] / N[(N[(d$95$m * d$95$m), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \frac{\left|d\_m\right|}{\sqrt{\ell \cdot h}}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;t\_1 \cdot \left(1 - \frac{0.125}{d\_m} \cdot \frac{\left(\left(\left(M\_m \cdot M\_m\right) \cdot h\right) \cdot D\_m\right) \cdot D\_m}{\ell \cdot d\_m}\right)\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+238}:\\
\;\;\;\;\frac{d\_m}{\sqrt{\ell} \cdot \sqrt{h}}\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(1 - \left(M\_m \cdot \left(\left(D\_m \cdot M\_m\right) \cdot \frac{D\_m \cdot h}{\left(d\_m \cdot d\_m\right) \cdot \ell}\right)\right) \cdot 0.125\right)\\
\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 79.9%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6447.6
Applied rewrites47.6%
Applied rewrites53.1%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*l/N/A
associate-*l*N/A
*-commutativeN/A
pow2N/A
pow-prod-downN/A
associate-*r*N/A
Applied rewrites65.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)))) < 4.0000000000000002e238Initial program 98.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.7%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
metadata-evalN/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6475.9
Applied rewrites75.9%
Applied rewrites76.0%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6498.7
Applied rewrites98.7%
if 4.0000000000000002e238 < (*.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 8.2%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f648.2
Applied rewrites8.2%
Applied rewrites59.2%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lower-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f6462.2
Applied rewrites62.2%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0)) (/ h l)))))
(t_1 (/ (fabs d_m) (sqrt (* l h)))))
(if (<= t_0 0.0)
(*
t_1
(-
1.0
(* (/ (/ (* (* (* (* M_m M_m) h) D_m) D_m) d_m) (* l d_m)) 0.125)))
(if (<= t_0 4e+238)
(/ d_m (* (sqrt l) (sqrt h)))
(*
t_1
(-
1.0
(*
(* M_m (* (* D_m M_m) (/ (* D_m h) (* (* d_m d_m) l))))
0.125)))))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double t_1 = fabs(d_m) / sqrt((l * h));
double tmp;
if (t_0 <= 0.0) {
tmp = t_1 * (1.0 - (((((((M_m * M_m) * h) * D_m) * D_m) / d_m) / (l * d_m)) * 0.125));
} else if (t_0 <= 4e+238) {
tmp = d_m / (sqrt(l) * sqrt(h));
} else {
tmp = t_1 * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125));
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m_1) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
t_1 = abs(d_m) / sqrt((l * h))
if (t_0 <= 0.0d0) then
tmp = t_1 * (1.0d0 - (((((((m_m * m_m) * h) * d_m_1) * d_m_1) / d_m) / (l * d_m)) * 0.125d0))
else if (t_0 <= 4d+238) then
tmp = d_m / (sqrt(l) * sqrt(h))
else
tmp = t_1 * (1.0d0 - ((m_m * ((d_m_1 * m_m) * ((d_m_1 * h) / ((d_m * d_m) * l)))) * 0.125d0))
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double t_1 = Math.abs(d_m) / Math.sqrt((l * h));
double tmp;
if (t_0 <= 0.0) {
tmp = t_1 * (1.0 - (((((((M_m * M_m) * h) * D_m) * D_m) / d_m) / (l * d_m)) * 0.125));
} else if (t_0 <= 4e+238) {
tmp = d_m / (Math.sqrt(l) * Math.sqrt(h));
} else {
tmp = t_1 * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125));
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): t_0 = (math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l))) t_1 = math.fabs(d_m) / math.sqrt((l * h)) tmp = 0 if t_0 <= 0.0: tmp = t_1 * (1.0 - (((((((M_m * M_m) * h) * D_m) * D_m) / d_m) / (l * d_m)) * 0.125)) elif t_0 <= 4e+238: tmp = d_m / (math.sqrt(l) * math.sqrt(h)) else: tmp = t_1 * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125)) return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(abs(d_m) / sqrt(Float64(l * h))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(Float64(Float64(Float64(Float64(Float64(M_m * M_m) * h) * D_m) * D_m) / d_m) / Float64(l * d_m)) * 0.125))); elseif (t_0 <= 4e+238) tmp = Float64(d_m / Float64(sqrt(l) * sqrt(h))); else tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(M_m * Float64(Float64(D_m * M_m) * Float64(Float64(D_m * h) / Float64(Float64(d_m * d_m) * l)))) * 0.125))); end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
t_0 = (((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d_m)) ^ 2.0)) * (h / l)));
t_1 = abs(d_m) / sqrt((l * h));
tmp = 0.0;
if (t_0 <= 0.0)
tmp = t_1 * (1.0 - (((((((M_m * M_m) * h) * D_m) * D_m) / d_m) / (l * d_m)) * 0.125));
elseif (t_0 <= 4e+238)
tmp = d_m / (sqrt(l) * sqrt(h));
else
tmp = t_1 * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125));
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Abs[d$95$m], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(t$95$1 * N[(1.0 - N[(N[(N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] / d$95$m), $MachinePrecision] / N[(l * d$95$m), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e+238], N[(d$95$m / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(1.0 - N[(N[(M$95$m * N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(N[(D$95$m * h), $MachinePrecision] / N[(N[(d$95$m * d$95$m), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \frac{\left|d\_m\right|}{\sqrt{\ell \cdot h}}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;t\_1 \cdot \left(1 - \frac{\frac{\left(\left(\left(M\_m \cdot M\_m\right) \cdot h\right) \cdot D\_m\right) \cdot D\_m}{d\_m}}{\ell \cdot d\_m} \cdot 0.125\right)\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+238}:\\
\;\;\;\;\frac{d\_m}{\sqrt{\ell} \cdot \sqrt{h}}\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(1 - \left(M\_m \cdot \left(\left(D\_m \cdot M\_m\right) \cdot \frac{D\_m \cdot h}{\left(d\_m \cdot d\_m\right) \cdot \ell}\right)\right) \cdot 0.125\right)\\
\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 79.9%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6447.6
Applied rewrites47.6%
Applied rewrites53.1%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
associate-*l*N/A
*-commutativeN/A
pow2N/A
pow-prod-downN/A
associate-*r*N/A
lower-/.f64N/A
Applied rewrites65.1%
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)))) < 4.0000000000000002e238Initial program 98.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.7%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
metadata-evalN/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6475.9
Applied rewrites75.9%
Applied rewrites76.0%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6498.7
Applied rewrites98.7%
if 4.0000000000000002e238 < (*.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 8.2%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f648.2
Applied rewrites8.2%
Applied rewrites59.2%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lower-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f6462.2
Applied rewrites62.2%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0)) (/ h l)))))
(t_1 (/ (fabs d_m) (sqrt (* l h)))))
(if (<= t_0 -2e-180)
(*
t_1
(-
1.0
(* (/ (* (/ h d_m) (* (* (* D_m M_m) M_m) D_m)) (* l d_m)) 0.125)))
(if (<= t_0 4e+238)
(* (/ (sqrt (/ 1.0 h)) (sqrt l)) d_m)
(*
t_1
(-
1.0
(*
(* M_m (* (* D_m M_m) (/ (* D_m h) (* (* d_m d_m) l))))
0.125)))))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double t_1 = fabs(d_m) / sqrt((l * h));
double tmp;
if (t_0 <= -2e-180) {
tmp = t_1 * (1.0 - ((((h / d_m) * (((D_m * M_m) * M_m) * D_m)) / (l * d_m)) * 0.125));
} else if (t_0 <= 4e+238) {
tmp = (sqrt((1.0 / h)) / sqrt(l)) * d_m;
} else {
tmp = t_1 * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125));
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m_1) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
t_1 = abs(d_m) / sqrt((l * h))
if (t_0 <= (-2d-180)) then
tmp = t_1 * (1.0d0 - ((((h / d_m) * (((d_m_1 * m_m) * m_m) * d_m_1)) / (l * d_m)) * 0.125d0))
else if (t_0 <= 4d+238) then
tmp = (sqrt((1.0d0 / h)) / sqrt(l)) * d_m
else
tmp = t_1 * (1.0d0 - ((m_m * ((d_m_1 * m_m) * ((d_m_1 * h) / ((d_m * d_m) * l)))) * 0.125d0))
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double t_1 = Math.abs(d_m) / Math.sqrt((l * h));
double tmp;
if (t_0 <= -2e-180) {
tmp = t_1 * (1.0 - ((((h / d_m) * (((D_m * M_m) * M_m) * D_m)) / (l * d_m)) * 0.125));
} else if (t_0 <= 4e+238) {
tmp = (Math.sqrt((1.0 / h)) / Math.sqrt(l)) * d_m;
} else {
tmp = t_1 * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125));
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): t_0 = (math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l))) t_1 = math.fabs(d_m) / math.sqrt((l * h)) tmp = 0 if t_0 <= -2e-180: tmp = t_1 * (1.0 - ((((h / d_m) * (((D_m * M_m) * M_m) * D_m)) / (l * d_m)) * 0.125)) elif t_0 <= 4e+238: tmp = (math.sqrt((1.0 / h)) / math.sqrt(l)) * d_m else: tmp = t_1 * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125)) return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(abs(d_m) / sqrt(Float64(l * h))) tmp = 0.0 if (t_0 <= -2e-180) tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(Float64(Float64(h / d_m) * Float64(Float64(Float64(D_m * M_m) * M_m) * D_m)) / Float64(l * d_m)) * 0.125))); elseif (t_0 <= 4e+238) tmp = Float64(Float64(sqrt(Float64(1.0 / h)) / sqrt(l)) * d_m); else tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(M_m * Float64(Float64(D_m * M_m) * Float64(Float64(D_m * h) / Float64(Float64(d_m * d_m) * l)))) * 0.125))); end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
t_0 = (((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d_m)) ^ 2.0)) * (h / l)));
t_1 = abs(d_m) / sqrt((l * h));
tmp = 0.0;
if (t_0 <= -2e-180)
tmp = t_1 * (1.0 - ((((h / d_m) * (((D_m * M_m) * M_m) * D_m)) / (l * d_m)) * 0.125));
elseif (t_0 <= 4e+238)
tmp = (sqrt((1.0 / h)) / sqrt(l)) * d_m;
else
tmp = t_1 * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125));
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Abs[d$95$m], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e-180], N[(t$95$1 * N[(1.0 - N[(N[(N[(N[(h / d$95$m), $MachinePrecision] * N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(l * d$95$m), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e+238], N[(N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision], N[(t$95$1 * N[(1.0 - N[(N[(M$95$m * N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(N[(D$95$m * h), $MachinePrecision] / N[(N[(d$95$m * d$95$m), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \frac{\left|d\_m\right|}{\sqrt{\ell \cdot h}}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-180}:\\
\;\;\;\;t\_1 \cdot \left(1 - \frac{\frac{h}{d\_m} \cdot \left(\left(\left(D\_m \cdot M\_m\right) \cdot M\_m\right) \cdot D\_m\right)}{\ell \cdot d\_m} \cdot 0.125\right)\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+238}:\\
\;\;\;\;\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}} \cdot d\_m\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(1 - \left(M\_m \cdot \left(\left(D\_m \cdot M\_m\right) \cdot \frac{D\_m \cdot h}{\left(d\_m \cdot d\_m\right) \cdot \ell}\right)\right) \cdot 0.125\right)\\
\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)))) < -2e-180Initial program 86.6%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6455.4
Applied rewrites55.4%
Applied rewrites59.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
pow2N/A
pow-prod-downN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lower-/.f64N/A
associate-/r*N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites56.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
associate-/r*N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*l*N/A
unpow2N/A
frac-timesN/A
lower-/.f64N/A
Applied rewrites71.0%
if -2e-180 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 4.0000000000000002e238Initial program 88.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.5%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-/r*N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6491.9
Applied rewrites91.9%
if 4.0000000000000002e238 < (*.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 8.2%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f648.2
Applied rewrites8.2%
Applied rewrites59.2%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lower-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f6462.2
Applied rewrites62.2%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0 (/ (fabs d_m) (sqrt (* l h))))
(t_1
(*
t_0
(-
1.0
(*
(* (/ (* (* M_m M_m) h) d_m) (/ (* D_m D_m) (* l d_m)))
0.125)))))
(if (<= (* M_m D_m) 2e-118)
t_1
(if (<= (* M_m D_m) 5e+261)
(*
t_0
(-
1.0
(* (* (* (/ h (* (* d_m d_m) l)) (* D_m M_m)) (* D_m M_m)) 0.125)))
t_1))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = fabs(d_m) / sqrt((l * h));
double t_1 = t_0 * (1.0 - (((((M_m * M_m) * h) / d_m) * ((D_m * D_m) / (l * d_m))) * 0.125));
double tmp;
if ((M_m * D_m) <= 2e-118) {
tmp = t_1;
} else if ((M_m * D_m) <= 5e+261) {
tmp = t_0 * (1.0 - ((((h / ((d_m * d_m) * l)) * (D_m * M_m)) * (D_m * M_m)) * 0.125));
} else {
tmp = t_1;
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = abs(d_m) / sqrt((l * h))
t_1 = t_0 * (1.0d0 - (((((m_m * m_m) * h) / d_m) * ((d_m_1 * d_m_1) / (l * d_m))) * 0.125d0))
if ((m_m * d_m_1) <= 2d-118) then
tmp = t_1
else if ((m_m * d_m_1) <= 5d+261) then
tmp = t_0 * (1.0d0 - ((((h / ((d_m * d_m) * l)) * (d_m_1 * m_m)) * (d_m_1 * m_m)) * 0.125d0))
else
tmp = t_1
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = Math.abs(d_m) / Math.sqrt((l * h));
double t_1 = t_0 * (1.0 - (((((M_m * M_m) * h) / d_m) * ((D_m * D_m) / (l * d_m))) * 0.125));
double tmp;
if ((M_m * D_m) <= 2e-118) {
tmp = t_1;
} else if ((M_m * D_m) <= 5e+261) {
tmp = t_0 * (1.0 - ((((h / ((d_m * d_m) * l)) * (D_m * M_m)) * (D_m * M_m)) * 0.125));
} else {
tmp = t_1;
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): t_0 = math.fabs(d_m) / math.sqrt((l * h)) t_1 = t_0 * (1.0 - (((((M_m * M_m) * h) / d_m) * ((D_m * D_m) / (l * d_m))) * 0.125)) tmp = 0 if (M_m * D_m) <= 2e-118: tmp = t_1 elif (M_m * D_m) <= 5e+261: tmp = t_0 * (1.0 - ((((h / ((d_m * d_m) * l)) * (D_m * M_m)) * (D_m * M_m)) * 0.125)) else: tmp = t_1 return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = Float64(abs(d_m) / sqrt(Float64(l * h))) t_1 = Float64(t_0 * Float64(1.0 - Float64(Float64(Float64(Float64(Float64(M_m * M_m) * h) / d_m) * Float64(Float64(D_m * D_m) / Float64(l * d_m))) * 0.125))) tmp = 0.0 if (Float64(M_m * D_m) <= 2e-118) tmp = t_1; elseif (Float64(M_m * D_m) <= 5e+261) tmp = Float64(t_0 * Float64(1.0 - Float64(Float64(Float64(Float64(h / Float64(Float64(d_m * d_m) * l)) * Float64(D_m * M_m)) * Float64(D_m * M_m)) * 0.125))); else tmp = t_1; end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
t_0 = abs(d_m) / sqrt((l * h));
t_1 = t_0 * (1.0 - (((((M_m * M_m) * h) / d_m) * ((D_m * D_m) / (l * d_m))) * 0.125));
tmp = 0.0;
if ((M_m * D_m) <= 2e-118)
tmp = t_1;
elseif ((M_m * D_m) <= 5e+261)
tmp = t_0 * (1.0 - ((((h / ((d_m * d_m) * l)) * (D_m * M_m)) * (D_m * M_m)) * 0.125));
else
tmp = t_1;
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[Abs[d$95$m], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(1.0 - N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] / d$95$m), $MachinePrecision] * N[(N[(D$95$m * D$95$m), $MachinePrecision] / N[(l * d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 2e-118], t$95$1, If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 5e+261], N[(t$95$0 * N[(1.0 - N[(N[(N[(N[(h / N[(N[(d$95$m * d$95$m), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\left|d\_m\right|}{\sqrt{\ell \cdot h}}\\
t_1 := t\_0 \cdot \left(1 - \left(\frac{\left(M\_m \cdot M\_m\right) \cdot h}{d\_m} \cdot \frac{D\_m \cdot D\_m}{\ell \cdot d\_m}\right) \cdot 0.125\right)\\
\mathbf{if}\;M\_m \cdot D\_m \leq 2 \cdot 10^{-118}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;M\_m \cdot D\_m \leq 5 \cdot 10^{+261}:\\
\;\;\;\;t\_0 \cdot \left(1 - \left(\left(\frac{h}{\left(d\_m \cdot d\_m\right) \cdot \ell} \cdot \left(D\_m \cdot M\_m\right)\right) \cdot \left(D\_m \cdot M\_m\right)\right) \cdot 0.125\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 M D) < 1.99999999999999997e-118 or 5.0000000000000001e261 < (*.f64 M D) Initial program 36.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6425.9
Applied rewrites25.9%
Applied rewrites55.5%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
*-commutativeN/A
pow2N/A
pow-prod-downN/A
associate-*r*N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
Applied rewrites71.3%
if 1.99999999999999997e-118 < (*.f64 M D) < 5.0000000000000001e261Initial program 34.5%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6427.5
Applied rewrites27.5%
Applied rewrites61.8%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f6467.8
Applied rewrites67.8%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0)) (/ h l)))))
(t_1 (/ (fabs d_m) (sqrt (* l h)))))
(if (<= t_0 -2e-180)
(*
t_1
(-
1.0
(* (* (* (* (* D_m M_m) M_m) D_m) (/ (/ h d_m) (* l d_m))) 0.125)))
(if (<= t_0 4e+238)
(* (/ (sqrt (/ 1.0 h)) (sqrt l)) d_m)
(*
t_1
(-
1.0
(*
(* M_m (* (* D_m M_m) (/ (* D_m h) (* (* d_m d_m) l))))
0.125)))))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double t_1 = fabs(d_m) / sqrt((l * h));
double tmp;
if (t_0 <= -2e-180) {
tmp = t_1 * (1.0 - (((((D_m * M_m) * M_m) * D_m) * ((h / d_m) / (l * d_m))) * 0.125));
} else if (t_0 <= 4e+238) {
tmp = (sqrt((1.0 / h)) / sqrt(l)) * d_m;
} else {
tmp = t_1 * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125));
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m_1) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
t_1 = abs(d_m) / sqrt((l * h))
if (t_0 <= (-2d-180)) then
tmp = t_1 * (1.0d0 - (((((d_m_1 * m_m) * m_m) * d_m_1) * ((h / d_m) / (l * d_m))) * 0.125d0))
else if (t_0 <= 4d+238) then
tmp = (sqrt((1.0d0 / h)) / sqrt(l)) * d_m
else
tmp = t_1 * (1.0d0 - ((m_m * ((d_m_1 * m_m) * ((d_m_1 * h) / ((d_m * d_m) * l)))) * 0.125d0))
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double t_1 = Math.abs(d_m) / Math.sqrt((l * h));
double tmp;
if (t_0 <= -2e-180) {
tmp = t_1 * (1.0 - (((((D_m * M_m) * M_m) * D_m) * ((h / d_m) / (l * d_m))) * 0.125));
} else if (t_0 <= 4e+238) {
tmp = (Math.sqrt((1.0 / h)) / Math.sqrt(l)) * d_m;
} else {
tmp = t_1 * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125));
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): t_0 = (math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l))) t_1 = math.fabs(d_m) / math.sqrt((l * h)) tmp = 0 if t_0 <= -2e-180: tmp = t_1 * (1.0 - (((((D_m * M_m) * M_m) * D_m) * ((h / d_m) / (l * d_m))) * 0.125)) elif t_0 <= 4e+238: tmp = (math.sqrt((1.0 / h)) / math.sqrt(l)) * d_m else: tmp = t_1 * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125)) return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(abs(d_m) / sqrt(Float64(l * h))) tmp = 0.0 if (t_0 <= -2e-180) tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(Float64(Float64(Float64(D_m * M_m) * M_m) * D_m) * Float64(Float64(h / d_m) / Float64(l * d_m))) * 0.125))); elseif (t_0 <= 4e+238) tmp = Float64(Float64(sqrt(Float64(1.0 / h)) / sqrt(l)) * d_m); else tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(M_m * Float64(Float64(D_m * M_m) * Float64(Float64(D_m * h) / Float64(Float64(d_m * d_m) * l)))) * 0.125))); end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
t_0 = (((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d_m)) ^ 2.0)) * (h / l)));
t_1 = abs(d_m) / sqrt((l * h));
tmp = 0.0;
if (t_0 <= -2e-180)
tmp = t_1 * (1.0 - (((((D_m * M_m) * M_m) * D_m) * ((h / d_m) / (l * d_m))) * 0.125));
elseif (t_0 <= 4e+238)
tmp = (sqrt((1.0 / h)) / sqrt(l)) * d_m;
else
tmp = t_1 * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125));
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Abs[d$95$m], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e-180], N[(t$95$1 * N[(1.0 - N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(N[(h / d$95$m), $MachinePrecision] / N[(l * d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e+238], N[(N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision], N[(t$95$1 * N[(1.0 - N[(N[(M$95$m * N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(N[(D$95$m * h), $MachinePrecision] / N[(N[(d$95$m * d$95$m), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \frac{\left|d\_m\right|}{\sqrt{\ell \cdot h}}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-180}:\\
\;\;\;\;t\_1 \cdot \left(1 - \left(\left(\left(\left(D\_m \cdot M\_m\right) \cdot M\_m\right) \cdot D\_m\right) \cdot \frac{\frac{h}{d\_m}}{\ell \cdot d\_m}\right) \cdot 0.125\right)\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+238}:\\
\;\;\;\;\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}} \cdot d\_m\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(1 - \left(M\_m \cdot \left(\left(D\_m \cdot M\_m\right) \cdot \frac{D\_m \cdot h}{\left(d\_m \cdot d\_m\right) \cdot \ell}\right)\right) \cdot 0.125\right)\\
\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)))) < -2e-180Initial program 86.6%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6455.4
Applied rewrites55.4%
Applied rewrites59.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6467.5
Applied rewrites67.5%
if -2e-180 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 4.0000000000000002e238Initial program 88.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.5%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-/r*N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6491.9
Applied rewrites91.9%
if 4.0000000000000002e238 < (*.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 8.2%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f648.2
Applied rewrites8.2%
Applied rewrites59.2%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lower-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f6462.2
Applied rewrites62.2%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0)) (/ h l)))))
(t_1 (/ (fabs d_m) (sqrt (* l h)))))
(if (<= t_0 -2e-180)
(*
t_1
(-
1.0
(* (* (* (* (* D_m M_m) M_m) D_m) (/ h (* (* l d_m) d_m))) 0.125)))
(if (<= t_0 4e+238)
(* (/ (sqrt (/ 1.0 h)) (sqrt l)) d_m)
(*
t_1
(-
1.0
(*
(* M_m (* (* D_m M_m) (/ (* D_m h) (* (* d_m d_m) l))))
0.125)))))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double t_1 = fabs(d_m) / sqrt((l * h));
double tmp;
if (t_0 <= -2e-180) {
tmp = t_1 * (1.0 - (((((D_m * M_m) * M_m) * D_m) * (h / ((l * d_m) * d_m))) * 0.125));
} else if (t_0 <= 4e+238) {
tmp = (sqrt((1.0 / h)) / sqrt(l)) * d_m;
} else {
tmp = t_1 * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125));
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m_1) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
t_1 = abs(d_m) / sqrt((l * h))
if (t_0 <= (-2d-180)) then
tmp = t_1 * (1.0d0 - (((((d_m_1 * m_m) * m_m) * d_m_1) * (h / ((l * d_m) * d_m))) * 0.125d0))
else if (t_0 <= 4d+238) then
tmp = (sqrt((1.0d0 / h)) / sqrt(l)) * d_m
else
tmp = t_1 * (1.0d0 - ((m_m * ((d_m_1 * m_m) * ((d_m_1 * h) / ((d_m * d_m) * l)))) * 0.125d0))
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double t_1 = Math.abs(d_m) / Math.sqrt((l * h));
double tmp;
if (t_0 <= -2e-180) {
tmp = t_1 * (1.0 - (((((D_m * M_m) * M_m) * D_m) * (h / ((l * d_m) * d_m))) * 0.125));
} else if (t_0 <= 4e+238) {
tmp = (Math.sqrt((1.0 / h)) / Math.sqrt(l)) * d_m;
} else {
tmp = t_1 * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125));
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): t_0 = (math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l))) t_1 = math.fabs(d_m) / math.sqrt((l * h)) tmp = 0 if t_0 <= -2e-180: tmp = t_1 * (1.0 - (((((D_m * M_m) * M_m) * D_m) * (h / ((l * d_m) * d_m))) * 0.125)) elif t_0 <= 4e+238: tmp = (math.sqrt((1.0 / h)) / math.sqrt(l)) * d_m else: tmp = t_1 * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125)) return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(abs(d_m) / sqrt(Float64(l * h))) tmp = 0.0 if (t_0 <= -2e-180) tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(Float64(Float64(Float64(D_m * M_m) * M_m) * D_m) * Float64(h / Float64(Float64(l * d_m) * d_m))) * 0.125))); elseif (t_0 <= 4e+238) tmp = Float64(Float64(sqrt(Float64(1.0 / h)) / sqrt(l)) * d_m); else tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(M_m * Float64(Float64(D_m * M_m) * Float64(Float64(D_m * h) / Float64(Float64(d_m * d_m) * l)))) * 0.125))); end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
t_0 = (((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d_m)) ^ 2.0)) * (h / l)));
t_1 = abs(d_m) / sqrt((l * h));
tmp = 0.0;
if (t_0 <= -2e-180)
tmp = t_1 * (1.0 - (((((D_m * M_m) * M_m) * D_m) * (h / ((l * d_m) * d_m))) * 0.125));
elseif (t_0 <= 4e+238)
tmp = (sqrt((1.0 / h)) / sqrt(l)) * d_m;
else
tmp = t_1 * (1.0 - ((M_m * ((D_m * M_m) * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125));
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Abs[d$95$m], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e-180], N[(t$95$1 * N[(1.0 - N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(h / N[(N[(l * d$95$m), $MachinePrecision] * d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e+238], N[(N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision], N[(t$95$1 * N[(1.0 - N[(N[(M$95$m * N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(N[(D$95$m * h), $MachinePrecision] / N[(N[(d$95$m * d$95$m), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \frac{\left|d\_m\right|}{\sqrt{\ell \cdot h}}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-180}:\\
\;\;\;\;t\_1 \cdot \left(1 - \left(\left(\left(\left(D\_m \cdot M\_m\right) \cdot M\_m\right) \cdot D\_m\right) \cdot \frac{h}{\left(\ell \cdot d\_m\right) \cdot d\_m}\right) \cdot 0.125\right)\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+238}:\\
\;\;\;\;\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}} \cdot d\_m\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(1 - \left(M\_m \cdot \left(\left(D\_m \cdot M\_m\right) \cdot \frac{D\_m \cdot h}{\left(d\_m \cdot d\_m\right) \cdot \ell}\right)\right) \cdot 0.125\right)\\
\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)))) < -2e-180Initial program 86.6%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6455.4
Applied rewrites55.4%
Applied rewrites59.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6464.8
Applied rewrites64.8%
if -2e-180 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 4.0000000000000002e238Initial program 88.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.5%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-/r*N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6491.9
Applied rewrites91.9%
if 4.0000000000000002e238 < (*.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 8.2%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f648.2
Applied rewrites8.2%
Applied rewrites59.2%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lower-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f6462.2
Applied rewrites62.2%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0)) (/ h l)))))
(t_1 (/ (fabs d_m) (sqrt (* l h)))))
(if (<= t_0 -2e-180)
(*
t_1
(-
1.0
(* (* (* (* (* D_m M_m) M_m) D_m) (/ h (* (* l d_m) d_m))) 0.125)))
(if (<= t_0 4e+238)
(* (/ (sqrt (/ 1.0 h)) (sqrt l)) d_m)
(*
t_1
(-
1.0
(*
(* (* D_m M_m) (* M_m (/ (* D_m h) (* (* d_m d_m) l))))
0.125)))))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double t_1 = fabs(d_m) / sqrt((l * h));
double tmp;
if (t_0 <= -2e-180) {
tmp = t_1 * (1.0 - (((((D_m * M_m) * M_m) * D_m) * (h / ((l * d_m) * d_m))) * 0.125));
} else if (t_0 <= 4e+238) {
tmp = (sqrt((1.0 / h)) / sqrt(l)) * d_m;
} else {
tmp = t_1 * (1.0 - (((D_m * M_m) * (M_m * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125));
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m_1) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
t_1 = abs(d_m) / sqrt((l * h))
if (t_0 <= (-2d-180)) then
tmp = t_1 * (1.0d0 - (((((d_m_1 * m_m) * m_m) * d_m_1) * (h / ((l * d_m) * d_m))) * 0.125d0))
else if (t_0 <= 4d+238) then
tmp = (sqrt((1.0d0 / h)) / sqrt(l)) * d_m
else
tmp = t_1 * (1.0d0 - (((d_m_1 * m_m) * (m_m * ((d_m_1 * h) / ((d_m * d_m) * l)))) * 0.125d0))
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double t_1 = Math.abs(d_m) / Math.sqrt((l * h));
double tmp;
if (t_0 <= -2e-180) {
tmp = t_1 * (1.0 - (((((D_m * M_m) * M_m) * D_m) * (h / ((l * d_m) * d_m))) * 0.125));
} else if (t_0 <= 4e+238) {
tmp = (Math.sqrt((1.0 / h)) / Math.sqrt(l)) * d_m;
} else {
tmp = t_1 * (1.0 - (((D_m * M_m) * (M_m * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125));
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): t_0 = (math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l))) t_1 = math.fabs(d_m) / math.sqrt((l * h)) tmp = 0 if t_0 <= -2e-180: tmp = t_1 * (1.0 - (((((D_m * M_m) * M_m) * D_m) * (h / ((l * d_m) * d_m))) * 0.125)) elif t_0 <= 4e+238: tmp = (math.sqrt((1.0 / h)) / math.sqrt(l)) * d_m else: tmp = t_1 * (1.0 - (((D_m * M_m) * (M_m * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125)) return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(abs(d_m) / sqrt(Float64(l * h))) tmp = 0.0 if (t_0 <= -2e-180) tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(Float64(Float64(Float64(D_m * M_m) * M_m) * D_m) * Float64(h / Float64(Float64(l * d_m) * d_m))) * 0.125))); elseif (t_0 <= 4e+238) tmp = Float64(Float64(sqrt(Float64(1.0 / h)) / sqrt(l)) * d_m); else tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(Float64(D_m * M_m) * Float64(M_m * Float64(Float64(D_m * h) / Float64(Float64(d_m * d_m) * l)))) * 0.125))); end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
t_0 = (((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d_m)) ^ 2.0)) * (h / l)));
t_1 = abs(d_m) / sqrt((l * h));
tmp = 0.0;
if (t_0 <= -2e-180)
tmp = t_1 * (1.0 - (((((D_m * M_m) * M_m) * D_m) * (h / ((l * d_m) * d_m))) * 0.125));
elseif (t_0 <= 4e+238)
tmp = (sqrt((1.0 / h)) / sqrt(l)) * d_m;
else
tmp = t_1 * (1.0 - (((D_m * M_m) * (M_m * ((D_m * h) / ((d_m * d_m) * l)))) * 0.125));
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Abs[d$95$m], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e-180], N[(t$95$1 * N[(1.0 - N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(h / N[(N[(l * d$95$m), $MachinePrecision] * d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e+238], N[(N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision], N[(t$95$1 * N[(1.0 - N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(M$95$m * N[(N[(D$95$m * h), $MachinePrecision] / N[(N[(d$95$m * d$95$m), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \frac{\left|d\_m\right|}{\sqrt{\ell \cdot h}}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-180}:\\
\;\;\;\;t\_1 \cdot \left(1 - \left(\left(\left(\left(D\_m \cdot M\_m\right) \cdot M\_m\right) \cdot D\_m\right) \cdot \frac{h}{\left(\ell \cdot d\_m\right) \cdot d\_m}\right) \cdot 0.125\right)\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+238}:\\
\;\;\;\;\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}} \cdot d\_m\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(1 - \left(\left(D\_m \cdot M\_m\right) \cdot \left(M\_m \cdot \frac{D\_m \cdot h}{\left(d\_m \cdot d\_m\right) \cdot \ell}\right)\right) \cdot 0.125\right)\\
\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)))) < -2e-180Initial program 86.6%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6455.4
Applied rewrites55.4%
Applied rewrites59.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6464.8
Applied rewrites64.8%
if -2e-180 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 4.0000000000000002e238Initial program 88.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.5%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-/r*N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6491.9
Applied rewrites91.9%
if 4.0000000000000002e238 < (*.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 8.2%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f648.2
Applied rewrites8.2%
Applied rewrites59.2%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lower-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f6462.4
Applied rewrites62.4%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (* l h)))
(t_1
(*
(* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0)) (/ h l)))))
(t_2 (* (* d_m d_m) l)))
(if (<= t_1 -2e-180)
(/
(*
(- 1.0 (* (* (* (* (* D_m M_m) M_m) D_m) (/ h t_2)) 0.125))
(fabs d_m))
t_0)
(if (<= t_1 4e+238)
(* (/ (sqrt (/ 1.0 h)) (sqrt l)) d_m)
(*
(/ (fabs d_m) t_0)
(- 1.0 (* (* (* D_m M_m) (* M_m (/ (* D_m h) t_2))) 0.125)))))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((l * h));
double t_1 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double t_2 = (d_m * d_m) * l;
double tmp;
if (t_1 <= -2e-180) {
tmp = ((1.0 - (((((D_m * M_m) * M_m) * D_m) * (h / t_2)) * 0.125)) * fabs(d_m)) / t_0;
} else if (t_1 <= 4e+238) {
tmp = (sqrt((1.0 / h)) / sqrt(l)) * d_m;
} else {
tmp = (fabs(d_m) / t_0) * (1.0 - (((D_m * M_m) * (M_m * ((D_m * h) / t_2))) * 0.125));
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sqrt((l * h))
t_1 = (((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m_1) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
t_2 = (d_m * d_m) * l
if (t_1 <= (-2d-180)) then
tmp = ((1.0d0 - (((((d_m_1 * m_m) * m_m) * d_m_1) * (h / t_2)) * 0.125d0)) * abs(d_m)) / t_0
else if (t_1 <= 4d+238) then
tmp = (sqrt((1.0d0 / h)) / sqrt(l)) * d_m
else
tmp = (abs(d_m) / t_0) * (1.0d0 - (((d_m_1 * m_m) * (m_m * ((d_m_1 * h) / t_2))) * 0.125d0))
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = Math.sqrt((l * h));
double t_1 = (Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double t_2 = (d_m * d_m) * l;
double tmp;
if (t_1 <= -2e-180) {
tmp = ((1.0 - (((((D_m * M_m) * M_m) * D_m) * (h / t_2)) * 0.125)) * Math.abs(d_m)) / t_0;
} else if (t_1 <= 4e+238) {
tmp = (Math.sqrt((1.0 / h)) / Math.sqrt(l)) * d_m;
} else {
tmp = (Math.abs(d_m) / t_0) * (1.0 - (((D_m * M_m) * (M_m * ((D_m * h) / t_2))) * 0.125));
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): t_0 = math.sqrt((l * h)) t_1 = (math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l))) t_2 = (d_m * d_m) * l tmp = 0 if t_1 <= -2e-180: tmp = ((1.0 - (((((D_m * M_m) * M_m) * D_m) * (h / t_2)) * 0.125)) * math.fabs(d_m)) / t_0 elif t_1 <= 4e+238: tmp = (math.sqrt((1.0 / h)) / math.sqrt(l)) * d_m else: tmp = (math.fabs(d_m) / t_0) * (1.0 - (((D_m * M_m) * (M_m * ((D_m * h) / t_2))) * 0.125)) return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = sqrt(Float64(l * h)) t_1 = Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))) t_2 = Float64(Float64(d_m * d_m) * l) tmp = 0.0 if (t_1 <= -2e-180) tmp = Float64(Float64(Float64(1.0 - Float64(Float64(Float64(Float64(Float64(D_m * M_m) * M_m) * D_m) * Float64(h / t_2)) * 0.125)) * abs(d_m)) / t_0); elseif (t_1 <= 4e+238) tmp = Float64(Float64(sqrt(Float64(1.0 / h)) / sqrt(l)) * d_m); else tmp = Float64(Float64(abs(d_m) / t_0) * Float64(1.0 - Float64(Float64(Float64(D_m * M_m) * Float64(M_m * Float64(Float64(D_m * h) / t_2))) * 0.125))); end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
t_0 = sqrt((l * h));
t_1 = (((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d_m)) ^ 2.0)) * (h / l)));
t_2 = (d_m * d_m) * l;
tmp = 0.0;
if (t_1 <= -2e-180)
tmp = ((1.0 - (((((D_m * M_m) * M_m) * D_m) * (h / t_2)) * 0.125)) * abs(d_m)) / t_0;
elseif (t_1 <= 4e+238)
tmp = (sqrt((1.0 / h)) / sqrt(l)) * d_m;
else
tmp = (abs(d_m) / t_0) * (1.0 - (((D_m * M_m) * (M_m * ((D_m * h) / t_2))) * 0.125));
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(d$95$m * d$95$m), $MachinePrecision] * l), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-180], N[(N[(N[(1.0 - N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(h / t$95$2), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision] * N[Abs[d$95$m], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[t$95$1, 4e+238], N[(N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision], N[(N[(N[Abs[d$95$m], $MachinePrecision] / t$95$0), $MachinePrecision] * N[(1.0 - N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(M$95$m * N[(N[(D$95$m * h), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
t_1 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_2 := \left(d\_m \cdot d\_m\right) \cdot \ell\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-180}:\\
\;\;\;\;\frac{\left(1 - \left(\left(\left(\left(D\_m \cdot M\_m\right) \cdot M\_m\right) \cdot D\_m\right) \cdot \frac{h}{t\_2}\right) \cdot 0.125\right) \cdot \left|d\_m\right|}{t\_0}\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+238}:\\
\;\;\;\;\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}} \cdot d\_m\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|d\_m\right|}{t\_0} \cdot \left(1 - \left(\left(D\_m \cdot M\_m\right) \cdot \left(M\_m \cdot \frac{D\_m \cdot h}{t\_2}\right)\right) \cdot 0.125\right)\\
\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)))) < -2e-180Initial program 86.6%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6455.4
Applied rewrites55.4%
Applied rewrites59.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
pow2N/A
pow-prod-downN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lower-/.f64N/A
associate-/r*N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites56.5%
Applied rewrites59.5%
if -2e-180 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 4.0000000000000002e238Initial program 88.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.5%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-/r*N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6491.9
Applied rewrites91.9%
if 4.0000000000000002e238 < (*.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 8.2%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f648.2
Applied rewrites8.2%
Applied rewrites59.2%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lower-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f6462.4
Applied rewrites62.4%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (* l h))) (t_1 (/ d_m t_0)))
(if (<= (* M_m D_m) 1e-196)
t_1
(if (<= (* M_m D_m) 2e+25)
(*
t_1
(-
1.0
(* (* (* (* (* D_m M_m) D_m) (/ M_m (* d_m d_m))) 0.125) (/ h l))))
(/
(*
(-
1.0
(* (/ (* (* (* (* M_m M_m) h) D_m) D_m) (* (* d_m d_m) l)) 0.125))
(fabs d_m))
t_0)))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((l * h));
double t_1 = d_m / t_0;
double tmp;
if ((M_m * D_m) <= 1e-196) {
tmp = t_1;
} else if ((M_m * D_m) <= 2e+25) {
tmp = t_1 * (1.0 - (((((D_m * M_m) * D_m) * (M_m / (d_m * d_m))) * 0.125) * (h / l)));
} else {
tmp = ((1.0 - ((((((M_m * M_m) * h) * D_m) * D_m) / ((d_m * d_m) * l)) * 0.125)) * fabs(d_m)) / t_0;
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sqrt((l * h))
t_1 = d_m / t_0
if ((m_m * d_m_1) <= 1d-196) then
tmp = t_1
else if ((m_m * d_m_1) <= 2d+25) then
tmp = t_1 * (1.0d0 - (((((d_m_1 * m_m) * d_m_1) * (m_m / (d_m * d_m))) * 0.125d0) * (h / l)))
else
tmp = ((1.0d0 - ((((((m_m * m_m) * h) * d_m_1) * d_m_1) / ((d_m * d_m) * l)) * 0.125d0)) * abs(d_m)) / t_0
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = Math.sqrt((l * h));
double t_1 = d_m / t_0;
double tmp;
if ((M_m * D_m) <= 1e-196) {
tmp = t_1;
} else if ((M_m * D_m) <= 2e+25) {
tmp = t_1 * (1.0 - (((((D_m * M_m) * D_m) * (M_m / (d_m * d_m))) * 0.125) * (h / l)));
} else {
tmp = ((1.0 - ((((((M_m * M_m) * h) * D_m) * D_m) / ((d_m * d_m) * l)) * 0.125)) * Math.abs(d_m)) / t_0;
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): t_0 = math.sqrt((l * h)) t_1 = d_m / t_0 tmp = 0 if (M_m * D_m) <= 1e-196: tmp = t_1 elif (M_m * D_m) <= 2e+25: tmp = t_1 * (1.0 - (((((D_m * M_m) * D_m) * (M_m / (d_m * d_m))) * 0.125) * (h / l))) else: tmp = ((1.0 - ((((((M_m * M_m) * h) * D_m) * D_m) / ((d_m * d_m) * l)) * 0.125)) * math.fabs(d_m)) / t_0 return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = sqrt(Float64(l * h)) t_1 = Float64(d_m / t_0) tmp = 0.0 if (Float64(M_m * D_m) <= 1e-196) tmp = t_1; elseif (Float64(M_m * D_m) <= 2e+25) tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(Float64(Float64(Float64(D_m * M_m) * D_m) * Float64(M_m / Float64(d_m * d_m))) * 0.125) * Float64(h / l)))); else tmp = Float64(Float64(Float64(1.0 - Float64(Float64(Float64(Float64(Float64(Float64(M_m * M_m) * h) * D_m) * D_m) / Float64(Float64(d_m * d_m) * l)) * 0.125)) * abs(d_m)) / t_0); end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
t_0 = sqrt((l * h));
t_1 = d_m / t_0;
tmp = 0.0;
if ((M_m * D_m) <= 1e-196)
tmp = t_1;
elseif ((M_m * D_m) <= 2e+25)
tmp = t_1 * (1.0 - (((((D_m * M_m) * D_m) * (M_m / (d_m * d_m))) * 0.125) * (h / l)));
else
tmp = ((1.0 - ((((((M_m * M_m) * h) * D_m) * D_m) / ((d_m * d_m) * l)) * 0.125)) * abs(d_m)) / t_0;
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(d$95$m / t$95$0), $MachinePrecision]}, If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 1e-196], t$95$1, If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 2e+25], N[(t$95$1 * N[(1.0 - N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(M$95$m / N[(d$95$m * d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 - N[(N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] / N[(N[(d$95$m * d$95$m), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision] * N[Abs[d$95$m], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
t_1 := \frac{d\_m}{t\_0}\\
\mathbf{if}\;M\_m \cdot D\_m \leq 10^{-196}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;M\_m \cdot D\_m \leq 2 \cdot 10^{+25}:\\
\;\;\;\;t\_1 \cdot \left(1 - \left(\left(\left(\left(D\_m \cdot M\_m\right) \cdot D\_m\right) \cdot \frac{M\_m}{d\_m \cdot d\_m}\right) \cdot 0.125\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 - \frac{\left(\left(\left(M\_m \cdot M\_m\right) \cdot h\right) \cdot D\_m\right) \cdot D\_m}{\left(d\_m \cdot d\_m\right) \cdot \ell} \cdot 0.125\right) \cdot \left|d\_m\right|}{t\_0}\\
\end{array}
\end{array}
if (*.f64 M D) < 1e-196Initial program 37.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites77.6%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
metadata-evalN/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6477.8
Applied rewrites77.8%
Applied rewrites77.9%
if 1e-196 < (*.f64 M D) < 2.00000000000000018e25Initial program 34.4%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.6%
lift-/.f64N/A
metadata-eval66.6
Applied rewrites66.6%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
metadata-evalN/A
lift-sqrt.f64N/A
lift-*.f64N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f6467.0
Applied rewrites67.0%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6460.7
Applied rewrites60.7%
if 2.00000000000000018e25 < (*.f64 M D) Initial program 35.4%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6425.7
Applied rewrites25.7%
Applied rewrites58.9%
Applied rewrites59.6%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(if (<= d_m 1.55e-193)
(*
(* (* (* (/ (* M_m M_m) d_m) (sqrt (/ h (* (* l l) l)))) -0.125) D_m)
D_m)
(if (<= d_m 1.65e+133)
(*
(/ d_m (sqrt (* l h)))
(-
1.0
(* (* (* (* (* D_m M_m) D_m) (/ M_m (* d_m d_m))) 0.125) (/ h l))))
(* (sqrt (/ 1.0 (* l h))) d_m))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double tmp;
if (d_m <= 1.55e-193) {
tmp = (((((M_m * M_m) / d_m) * sqrt((h / ((l * l) * l)))) * -0.125) * D_m) * D_m;
} else if (d_m <= 1.65e+133) {
tmp = (d_m / sqrt((l * h))) * (1.0 - (((((D_m * M_m) * D_m) * (M_m / (d_m * d_m))) * 0.125) * (h / l)));
} else {
tmp = sqrt((1.0 / (l * h))) * d_m;
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: tmp
if (d_m <= 1.55d-193) then
tmp = (((((m_m * m_m) / d_m) * sqrt((h / ((l * l) * l)))) * (-0.125d0)) * d_m_1) * d_m_1
else if (d_m <= 1.65d+133) then
tmp = (d_m / sqrt((l * h))) * (1.0d0 - (((((d_m_1 * m_m) * d_m_1) * (m_m / (d_m * d_m))) * 0.125d0) * (h / l)))
else
tmp = sqrt((1.0d0 / (l * h))) * d_m
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double tmp;
if (d_m <= 1.55e-193) {
tmp = (((((M_m * M_m) / d_m) * Math.sqrt((h / ((l * l) * l)))) * -0.125) * D_m) * D_m;
} else if (d_m <= 1.65e+133) {
tmp = (d_m / Math.sqrt((l * h))) * (1.0 - (((((D_m * M_m) * D_m) * (M_m / (d_m * d_m))) * 0.125) * (h / l)));
} else {
tmp = Math.sqrt((1.0 / (l * h))) * d_m;
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): tmp = 0 if d_m <= 1.55e-193: tmp = (((((M_m * M_m) / d_m) * math.sqrt((h / ((l * l) * l)))) * -0.125) * D_m) * D_m elif d_m <= 1.65e+133: tmp = (d_m / math.sqrt((l * h))) * (1.0 - (((((D_m * M_m) * D_m) * (M_m / (d_m * d_m))) * 0.125) * (h / l))) else: tmp = math.sqrt((1.0 / (l * h))) * d_m return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) tmp = 0.0 if (d_m <= 1.55e-193) tmp = Float64(Float64(Float64(Float64(Float64(Float64(M_m * M_m) / d_m) * sqrt(Float64(h / Float64(Float64(l * l) * l)))) * -0.125) * D_m) * D_m); elseif (d_m <= 1.65e+133) tmp = Float64(Float64(d_m / sqrt(Float64(l * h))) * Float64(1.0 - Float64(Float64(Float64(Float64(Float64(D_m * M_m) * D_m) * Float64(M_m / Float64(d_m * d_m))) * 0.125) * Float64(h / l)))); else tmp = Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m); end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
tmp = 0.0;
if (d_m <= 1.55e-193)
tmp = (((((M_m * M_m) / d_m) * sqrt((h / ((l * l) * l)))) * -0.125) * D_m) * D_m;
elseif (d_m <= 1.65e+133)
tmp = (d_m / sqrt((l * h))) * (1.0 - (((((D_m * M_m) * D_m) * (M_m / (d_m * d_m))) * 0.125) * (h / l)));
else
tmp = sqrt((1.0 / (l * h))) * d_m;
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[d$95$m, 1.55e-193], N[(N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] / d$95$m), $MachinePrecision] * N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision], If[LessEqual[d$95$m, 1.65e+133], N[(N[(d$95$m / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(M$95$m / N[(d$95$m * d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d\_m \leq 1.55 \cdot 10^{-193}:\\
\;\;\;\;\left(\left(\left(\frac{M\_m \cdot M\_m}{d\_m} \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\right) \cdot -0.125\right) \cdot D\_m\right) \cdot D\_m\\
\mathbf{elif}\;d\_m \leq 1.65 \cdot 10^{+133}:\\
\;\;\;\;\frac{d\_m}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\left(\left(\left(D\_m \cdot M\_m\right) \cdot D\_m\right) \cdot \frac{M\_m}{d\_m \cdot d\_m}\right) \cdot 0.125\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\\
\end{array}
\end{array}
if d < 1.5500000000000001e-193Initial program 23.3%
Taylor expanded in d around 0
*-commutativeN/A
associate-/l*N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites43.1%
if 1.5500000000000001e-193 < d < 1.65e133Initial program 36.3%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.5%
lift-/.f64N/A
metadata-eval70.5
Applied rewrites70.5%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
metadata-evalN/A
lift-sqrt.f64N/A
lift-*.f64N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f6470.9
Applied rewrites70.9%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6465.4
Applied rewrites65.4%
if 1.65e133 < d Initial program 42.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.9%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0 (* (* d_m d_m) l)) (t_1 (/ d_m (sqrt (* l h)))))
(if (<= (* M_m D_m) 1e+45)
t_1
(if (<= (* M_m D_m) 1e+161)
(* t_1 (* (* (* (* (/ h t_0) (* M_m M_m)) -0.125) D_m) D_m))
(if (<= (* M_m D_m) 5e+220)
(* (sqrt (/ (/ 1.0 h) l)) d_m)
(*
(* (sqrt (/ 1.0 (* l h))) d_m)
(* (* (* -0.125 (* D_m D_m)) (* M_m (/ M_m t_0))) h)))))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (d_m * d_m) * l;
double t_1 = d_m / sqrt((l * h));
double tmp;
if ((M_m * D_m) <= 1e+45) {
tmp = t_1;
} else if ((M_m * D_m) <= 1e+161) {
tmp = t_1 * (((((h / t_0) * (M_m * M_m)) * -0.125) * D_m) * D_m);
} else if ((M_m * D_m) <= 5e+220) {
tmp = sqrt(((1.0 / h) / l)) * d_m;
} else {
tmp = (sqrt((1.0 / (l * h))) * d_m) * (((-0.125 * (D_m * D_m)) * (M_m * (M_m / t_0))) * h);
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (d_m * d_m) * l
t_1 = d_m / sqrt((l * h))
if ((m_m * d_m_1) <= 1d+45) then
tmp = t_1
else if ((m_m * d_m_1) <= 1d+161) then
tmp = t_1 * (((((h / t_0) * (m_m * m_m)) * (-0.125d0)) * d_m_1) * d_m_1)
else if ((m_m * d_m_1) <= 5d+220) then
tmp = sqrt(((1.0d0 / h) / l)) * d_m
else
tmp = (sqrt((1.0d0 / (l * h))) * d_m) * ((((-0.125d0) * (d_m_1 * d_m_1)) * (m_m * (m_m / t_0))) * h)
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (d_m * d_m) * l;
double t_1 = d_m / Math.sqrt((l * h));
double tmp;
if ((M_m * D_m) <= 1e+45) {
tmp = t_1;
} else if ((M_m * D_m) <= 1e+161) {
tmp = t_1 * (((((h / t_0) * (M_m * M_m)) * -0.125) * D_m) * D_m);
} else if ((M_m * D_m) <= 5e+220) {
tmp = Math.sqrt(((1.0 / h) / l)) * d_m;
} else {
tmp = (Math.sqrt((1.0 / (l * h))) * d_m) * (((-0.125 * (D_m * D_m)) * (M_m * (M_m / t_0))) * h);
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): t_0 = (d_m * d_m) * l t_1 = d_m / math.sqrt((l * h)) tmp = 0 if (M_m * D_m) <= 1e+45: tmp = t_1 elif (M_m * D_m) <= 1e+161: tmp = t_1 * (((((h / t_0) * (M_m * M_m)) * -0.125) * D_m) * D_m) elif (M_m * D_m) <= 5e+220: tmp = math.sqrt(((1.0 / h) / l)) * d_m else: tmp = (math.sqrt((1.0 / (l * h))) * d_m) * (((-0.125 * (D_m * D_m)) * (M_m * (M_m / t_0))) * h) return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = Float64(Float64(d_m * d_m) * l) t_1 = Float64(d_m / sqrt(Float64(l * h))) tmp = 0.0 if (Float64(M_m * D_m) <= 1e+45) tmp = t_1; elseif (Float64(M_m * D_m) <= 1e+161) tmp = Float64(t_1 * Float64(Float64(Float64(Float64(Float64(h / t_0) * Float64(M_m * M_m)) * -0.125) * D_m) * D_m)); elseif (Float64(M_m * D_m) <= 5e+220) tmp = Float64(sqrt(Float64(Float64(1.0 / h) / l)) * d_m); else tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m) * Float64(Float64(Float64(-0.125 * Float64(D_m * D_m)) * Float64(M_m * Float64(M_m / t_0))) * h)); end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
t_0 = (d_m * d_m) * l;
t_1 = d_m / sqrt((l * h));
tmp = 0.0;
if ((M_m * D_m) <= 1e+45)
tmp = t_1;
elseif ((M_m * D_m) <= 1e+161)
tmp = t_1 * (((((h / t_0) * (M_m * M_m)) * -0.125) * D_m) * D_m);
elseif ((M_m * D_m) <= 5e+220)
tmp = sqrt(((1.0 / h) / l)) * d_m;
else
tmp = (sqrt((1.0 / (l * h))) * d_m) * (((-0.125 * (D_m * D_m)) * (M_m * (M_m / t_0))) * h);
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(d$95$m * d$95$m), $MachinePrecision] * l), $MachinePrecision]}, Block[{t$95$1 = N[(d$95$m / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 1e+45], t$95$1, If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 1e+161], N[(t$95$1 * N[(N[(N[(N[(N[(h / t$95$0), $MachinePrecision] * N[(M$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 5e+220], N[(N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision] * N[(N[(N[(-0.125 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * N[(M$95$m / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left(d\_m \cdot d\_m\right) \cdot \ell\\
t_1 := \frac{d\_m}{\sqrt{\ell \cdot h}}\\
\mathbf{if}\;M\_m \cdot D\_m \leq 10^{+45}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;M\_m \cdot D\_m \leq 10^{+161}:\\
\;\;\;\;t\_1 \cdot \left(\left(\left(\left(\frac{h}{t\_0} \cdot \left(M\_m \cdot M\_m\right)\right) \cdot -0.125\right) \cdot D\_m\right) \cdot D\_m\right)\\
\mathbf{elif}\;M\_m \cdot D\_m \leq 5 \cdot 10^{+220}:\\
\;\;\;\;\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d\_m\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\right) \cdot \left(\left(\left(-0.125 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot \left(M\_m \cdot \frac{M\_m}{t\_0}\right)\right) \cdot h\right)\\
\end{array}
\end{array}
if (*.f64 M D) < 9.9999999999999993e44Initial program 35.9%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites62.2%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
metadata-evalN/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6462.4
Applied rewrites62.4%
Applied rewrites62.5%
if 9.9999999999999993e44 < (*.f64 M D) < 1e161Initial program 34.2%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.5%
lift-/.f64N/A
metadata-eval70.5
Applied rewrites70.5%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
metadata-evalN/A
lift-sqrt.f64N/A
lift-*.f64N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f6470.7
Applied rewrites70.7%
Taylor expanded in d around 0
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites34.7%
if 1e161 < (*.f64 M D) < 5.0000000000000002e220Initial program 35.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites19.9%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6420.2
Applied rewrites20.2%
if 5.0000000000000002e220 < (*.f64 M D) Initial program 36.1%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites71.7%
lift-/.f64N/A
metadata-eval71.7
Applied rewrites71.7%
Taylor expanded in d around 0
Applied rewrites56.0%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
(-
1.0
(*
(* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0))
(/ h l))))))
(if (<= t_0 -2e-180)
(*
(* (* (* (/ (* M_m M_m) d_m) (sqrt (/ h (* (* l l) l)))) -0.125) D_m)
D_m)
(if (<= t_0 4e+238)
(* (/ (sqrt (/ 1.0 h)) (sqrt l)) d_m)
(* (/ 1.0 (sqrt (* l h))) d_m)))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -2e-180) {
tmp = (((((M_m * M_m) / d_m) * sqrt((h / ((l * l) * l)))) * -0.125) * D_m) * D_m;
} else if (t_0 <= 4e+238) {
tmp = (sqrt((1.0 / h)) / sqrt(l)) * d_m;
} else {
tmp = (1.0 / sqrt((l * h))) * d_m;
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: t_0
real(8) :: tmp
t_0 = (((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m_1) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
if (t_0 <= (-2d-180)) then
tmp = (((((m_m * m_m) / d_m) * sqrt((h / ((l * l) * l)))) * (-0.125d0)) * d_m_1) * d_m_1
else if (t_0 <= 4d+238) then
tmp = (sqrt((1.0d0 / h)) / sqrt(l)) * d_m
else
tmp = (1.0d0 / sqrt((l * h))) * d_m
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -2e-180) {
tmp = (((((M_m * M_m) / d_m) * Math.sqrt((h / ((l * l) * l)))) * -0.125) * D_m) * D_m;
} else if (t_0 <= 4e+238) {
tmp = (Math.sqrt((1.0 / h)) / Math.sqrt(l)) * d_m;
} else {
tmp = (1.0 / Math.sqrt((l * h))) * d_m;
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): t_0 = (math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l))) tmp = 0 if t_0 <= -2e-180: tmp = (((((M_m * M_m) / d_m) * math.sqrt((h / ((l * l) * l)))) * -0.125) * D_m) * D_m elif t_0 <= 4e+238: tmp = (math.sqrt((1.0 / h)) / math.sqrt(l)) * d_m else: tmp = (1.0 / math.sqrt((l * h))) * d_m return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_0 <= -2e-180) tmp = Float64(Float64(Float64(Float64(Float64(Float64(M_m * M_m) / d_m) * sqrt(Float64(h / Float64(Float64(l * l) * l)))) * -0.125) * D_m) * D_m); elseif (t_0 <= 4e+238) tmp = Float64(Float64(sqrt(Float64(1.0 / h)) / sqrt(l)) * d_m); else tmp = Float64(Float64(1.0 / sqrt(Float64(l * h))) * d_m); end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
t_0 = (((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d_m)) ^ 2.0)) * (h / l)));
tmp = 0.0;
if (t_0 <= -2e-180)
tmp = (((((M_m * M_m) / d_m) * sqrt((h / ((l * l) * l)))) * -0.125) * D_m) * D_m;
elseif (t_0 <= 4e+238)
tmp = (sqrt((1.0 / h)) / sqrt(l)) * d_m;
else
tmp = (1.0 / sqrt((l * h))) * d_m;
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e-180], N[(N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] / d$95$m), $MachinePrecision] * N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision], If[LessEqual[t$95$0, 4e+238], N[(N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision], N[(N[(1.0 / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-180}:\\
\;\;\;\;\left(\left(\left(\frac{M\_m \cdot M\_m}{d\_m} \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\right) \cdot -0.125\right) \cdot D\_m\right) \cdot D\_m\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+238}:\\
\;\;\;\;\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}} \cdot d\_m\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\ell \cdot h}} \cdot d\_m\\
\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)))) < -2e-180Initial program 86.6%
Taylor expanded in d around 0
*-commutativeN/A
associate-/l*N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites63.6%
if -2e-180 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 4.0000000000000002e238Initial program 88.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.5%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-/r*N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6491.9
Applied rewrites91.9%
if 4.0000000000000002e238 < (*.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 8.2%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites45.3%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
metadata-evalN/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6445.4
Applied rewrites45.4%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0 (/ d_m (sqrt (* l h)))))
(if (<= (* M_m D_m) 1e+45)
t_0
(*
t_0
(* (* (* (* (/ h (* (* d_m d_m) l)) (* M_m M_m)) -0.125) D_m) D_m)))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = d_m / sqrt((l * h));
double tmp;
if ((M_m * D_m) <= 1e+45) {
tmp = t_0;
} else {
tmp = t_0 * (((((h / ((d_m * d_m) * l)) * (M_m * M_m)) * -0.125) * D_m) * D_m);
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: t_0
real(8) :: tmp
t_0 = d_m / sqrt((l * h))
if ((m_m * d_m_1) <= 1d+45) then
tmp = t_0
else
tmp = t_0 * (((((h / ((d_m * d_m) * l)) * (m_m * m_m)) * (-0.125d0)) * d_m_1) * d_m_1)
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = d_m / Math.sqrt((l * h));
double tmp;
if ((M_m * D_m) <= 1e+45) {
tmp = t_0;
} else {
tmp = t_0 * (((((h / ((d_m * d_m) * l)) * (M_m * M_m)) * -0.125) * D_m) * D_m);
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): t_0 = d_m / math.sqrt((l * h)) tmp = 0 if (M_m * D_m) <= 1e+45: tmp = t_0 else: tmp = t_0 * (((((h / ((d_m * d_m) * l)) * (M_m * M_m)) * -0.125) * D_m) * D_m) return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = Float64(d_m / sqrt(Float64(l * h))) tmp = 0.0 if (Float64(M_m * D_m) <= 1e+45) tmp = t_0; else tmp = Float64(t_0 * Float64(Float64(Float64(Float64(Float64(h / Float64(Float64(d_m * d_m) * l)) * Float64(M_m * M_m)) * -0.125) * D_m) * D_m)); end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
t_0 = d_m / sqrt((l * h));
tmp = 0.0;
if ((M_m * D_m) <= 1e+45)
tmp = t_0;
else
tmp = t_0 * (((((h / ((d_m * d_m) * l)) * (M_m * M_m)) * -0.125) * D_m) * D_m);
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(d$95$m / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 1e+45], t$95$0, N[(t$95$0 * N[(N[(N[(N[(N[(h / N[(N[(d$95$m * d$95$m), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{d\_m}{\sqrt{\ell \cdot h}}\\
\mathbf{if}\;M\_m \cdot D\_m \leq 10^{+45}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(\left(\left(\left(\frac{h}{\left(d\_m \cdot d\_m\right) \cdot \ell} \cdot \left(M\_m \cdot M\_m\right)\right) \cdot -0.125\right) \cdot D\_m\right) \cdot D\_m\right)\\
\end{array}
\end{array}
if (*.f64 M D) < 9.9999999999999993e44Initial program 35.9%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites62.2%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
metadata-evalN/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6462.4
Applied rewrites62.4%
Applied rewrites62.5%
if 9.9999999999999993e44 < (*.f64 M D) Initial program 35.2%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites71.1%
lift-/.f64N/A
metadata-eval71.1
Applied rewrites71.1%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
metadata-evalN/A
lift-sqrt.f64N/A
lift-*.f64N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f6471.2
Applied rewrites71.2%
Taylor expanded in d around 0
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites46.5%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
(-
1.0
(*
(* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0))
(/ h l))))))
(if (<= t_0 -2e-180)
(* (- d_m) (sqrt (/ 1.0 (* l h))))
(if (<= t_0 4e+238)
(* (/ (sqrt (/ 1.0 h)) (sqrt l)) d_m)
(* (/ 1.0 (sqrt (* l h))) d_m)))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -2e-180) {
tmp = -d_m * sqrt((1.0 / (l * h)));
} else if (t_0 <= 4e+238) {
tmp = (sqrt((1.0 / h)) / sqrt(l)) * d_m;
} else {
tmp = (1.0 / sqrt((l * h))) * d_m;
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: t_0
real(8) :: tmp
t_0 = (((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m_1) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
if (t_0 <= (-2d-180)) then
tmp = -d_m * sqrt((1.0d0 / (l * h)))
else if (t_0 <= 4d+238) then
tmp = (sqrt((1.0d0 / h)) / sqrt(l)) * d_m
else
tmp = (1.0d0 / sqrt((l * h))) * d_m
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -2e-180) {
tmp = -d_m * Math.sqrt((1.0 / (l * h)));
} else if (t_0 <= 4e+238) {
tmp = (Math.sqrt((1.0 / h)) / Math.sqrt(l)) * d_m;
} else {
tmp = (1.0 / Math.sqrt((l * h))) * d_m;
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): t_0 = (math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l))) tmp = 0 if t_0 <= -2e-180: tmp = -d_m * math.sqrt((1.0 / (l * h))) elif t_0 <= 4e+238: tmp = (math.sqrt((1.0 / h)) / math.sqrt(l)) * d_m else: tmp = (1.0 / math.sqrt((l * h))) * d_m return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_0 <= -2e-180) tmp = Float64(Float64(-d_m) * sqrt(Float64(1.0 / Float64(l * h)))); elseif (t_0 <= 4e+238) tmp = Float64(Float64(sqrt(Float64(1.0 / h)) / sqrt(l)) * d_m); else tmp = Float64(Float64(1.0 / sqrt(Float64(l * h))) * d_m); end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
t_0 = (((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d_m)) ^ 2.0)) * (h / l)));
tmp = 0.0;
if (t_0 <= -2e-180)
tmp = -d_m * sqrt((1.0 / (l * h)));
elseif (t_0 <= 4e+238)
tmp = (sqrt((1.0 / h)) / sqrt(l)) * d_m;
else
tmp = (1.0 / sqrt((l * h))) * d_m;
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e-180], N[((-d$95$m) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e+238], N[(N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision], N[(N[(1.0 / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-180}:\\
\;\;\;\;\left(-d\_m\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+238}:\\
\;\;\;\;\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}} \cdot d\_m\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\ell \cdot h}} \cdot d\_m\\
\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)))) < -2e-180Initial program 86.6%
Taylor expanded in l around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
inv-powN/A
sqr-powN/A
sqrt-pow1N/A
inv-powN/A
sqrt-pow1N/A
inv-powN/A
lower-sqrt.f64N/A
Applied rewrites23.8%
if -2e-180 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 4.0000000000000002e238Initial program 88.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.5%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-/r*N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6491.9
Applied rewrites91.9%
if 4.0000000000000002e238 < (*.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 8.2%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites45.3%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
metadata-evalN/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6445.4
Applied rewrites45.4%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
(-
1.0
(*
(* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0))
(/ h l))))))
(if (<= t_0 -2e-180)
(* (- d_m) (sqrt (/ 1.0 (* l h))))
(if (<= t_0 4e+238)
(/ d_m (* (sqrt l) (sqrt h)))
(* (/ 1.0 (sqrt (* l h))) d_m)))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -2e-180) {
tmp = -d_m * sqrt((1.0 / (l * h)));
} else if (t_0 <= 4e+238) {
tmp = d_m / (sqrt(l) * sqrt(h));
} else {
tmp = (1.0 / sqrt((l * h))) * d_m;
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: t_0
real(8) :: tmp
t_0 = (((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m_1) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
if (t_0 <= (-2d-180)) then
tmp = -d_m * sqrt((1.0d0 / (l * h)))
else if (t_0 <= 4d+238) then
tmp = d_m / (sqrt(l) * sqrt(h))
else
tmp = (1.0d0 / sqrt((l * h))) * d_m
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = (Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -2e-180) {
tmp = -d_m * Math.sqrt((1.0 / (l * h)));
} else if (t_0 <= 4e+238) {
tmp = d_m / (Math.sqrt(l) * Math.sqrt(h));
} else {
tmp = (1.0 / Math.sqrt((l * h))) * d_m;
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): t_0 = (math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l))) tmp = 0 if t_0 <= -2e-180: tmp = -d_m * math.sqrt((1.0 / (l * h))) elif t_0 <= 4e+238: tmp = d_m / (math.sqrt(l) * math.sqrt(h)) else: tmp = (1.0 / math.sqrt((l * h))) * d_m return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_0 <= -2e-180) tmp = Float64(Float64(-d_m) * sqrt(Float64(1.0 / Float64(l * h)))); elseif (t_0 <= 4e+238) tmp = Float64(d_m / Float64(sqrt(l) * sqrt(h))); else tmp = Float64(Float64(1.0 / sqrt(Float64(l * h))) * d_m); end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
t_0 = (((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d_m)) ^ 2.0)) * (h / l)));
tmp = 0.0;
if (t_0 <= -2e-180)
tmp = -d_m * sqrt((1.0 / (l * h)));
elseif (t_0 <= 4e+238)
tmp = d_m / (sqrt(l) * sqrt(h));
else
tmp = (1.0 / sqrt((l * h))) * d_m;
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e-180], N[((-d$95$m) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e+238], N[(d$95$m / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-180}:\\
\;\;\;\;\left(-d\_m\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+238}:\\
\;\;\;\;\frac{d\_m}{\sqrt{\ell} \cdot \sqrt{h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\ell \cdot h}} \cdot d\_m\\
\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)))) < -2e-180Initial program 86.6%
Taylor expanded in l around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
inv-powN/A
sqr-powN/A
sqrt-pow1N/A
inv-powN/A
sqrt-pow1N/A
inv-powN/A
lower-sqrt.f64N/A
Applied rewrites23.8%
if -2e-180 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 4.0000000000000002e238Initial program 88.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.5%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
metadata-evalN/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6475.7
Applied rewrites75.7%
Applied rewrites75.8%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6492.0
Applied rewrites92.0%
if 4.0000000000000002e238 < (*.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 8.2%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites45.3%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
metadata-evalN/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6445.4
Applied rewrites45.4%
d_m = (fabs.f64 d) M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d_m h l M_m D_m) :precision binary64 (if (<= h -1e-307) (/ d_m (sqrt (* l h))) (/ d_m (* (sqrt l) (sqrt h)))))
d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double tmp;
if (h <= -1e-307) {
tmp = d_m / sqrt((l * h));
} else {
tmp = d_m / (sqrt(l) * sqrt(h));
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: tmp
if (h <= (-1d-307)) then
tmp = d_m / sqrt((l * h))
else
tmp = d_m / (sqrt(l) * sqrt(h))
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double tmp;
if (h <= -1e-307) {
tmp = d_m / Math.sqrt((l * h));
} else {
tmp = d_m / (Math.sqrt(l) * Math.sqrt(h));
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): tmp = 0 if h <= -1e-307: tmp = d_m / math.sqrt((l * h)) else: tmp = d_m / (math.sqrt(l) * math.sqrt(h)) return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) tmp = 0.0 if (h <= -1e-307) tmp = Float64(d_m / sqrt(Float64(l * h))); else tmp = Float64(d_m / Float64(sqrt(l) * sqrt(h))); end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
tmp = 0.0;
if (h <= -1e-307)
tmp = d_m / sqrt((l * h));
else
tmp = d_m / (sqrt(l) * sqrt(h));
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[h, -1e-307], N[(d$95$m / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d$95$m / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -1 \cdot 10^{-307}:\\
\;\;\;\;\frac{d\_m}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d\_m}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if h < -9.99999999999999909e-308Initial program 4.8%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites42.4%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
metadata-evalN/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6442.6
Applied rewrites42.6%
Applied rewrites42.6%
if -9.99999999999999909e-308 < h Initial program 66.3%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites43.2%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
metadata-evalN/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6443.3
Applied rewrites43.3%
Applied rewrites43.3%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6450.6
Applied rewrites50.6%
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0 (/ d_m (sqrt (* l h)))))
(if (<=
(*
(* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0)) (/ h l))))
-2e-180)
(- t_0)
t_0)))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = d_m / sqrt((l * h));
double tmp;
if (((pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)))) <= -2e-180) {
tmp = -t_0;
} else {
tmp = t_0;
}
return tmp;
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: t_0
real(8) :: tmp
t_0 = d_m / sqrt((l * h))
if (((((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m_1) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))) <= (-2d-180)) then
tmp = -t_0
else
tmp = t_0
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = d_m / Math.sqrt((l * h));
double tmp;
if (((Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)))) <= -2e-180) {
tmp = -t_0;
} else {
tmp = t_0;
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): t_0 = d_m / math.sqrt((l * h)) tmp = 0 if ((math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)))) <= -2e-180: tmp = -t_0 else: tmp = t_0 return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) t_0 = Float64(d_m / sqrt(Float64(l * h))) tmp = 0.0 if (Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))) <= -2e-180) tmp = Float64(-t_0); else tmp = t_0; end return tmp end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
t_0 = d_m / sqrt((l * h));
tmp = 0.0;
if (((((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d_m)) ^ 2.0)) * (h / l)))) <= -2e-180)
tmp = -t_0;
else
tmp = t_0;
end
tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(d$95$m / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e-180], (-t$95$0), t$95$0]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{d\_m}{\sqrt{\ell \cdot h}}\\
\mathbf{if}\;\left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -2 \cdot 10^{-180}:\\
\;\;\;\;-t\_0\\
\mathbf{else}:\\
\;\;\;\;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)))) < -2e-180Initial program 86.6%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites79.7%
lift-/.f64N/A
metadata-eval79.7
Applied rewrites79.7%
Taylor expanded in l around -inf
Applied rewrites22.6%
if -2e-180 < (*.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 24.8%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites51.6%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
metadata-evalN/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6451.7
Applied rewrites51.7%
Applied rewrites51.8%
d_m = (fabs.f64 d) M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d_m h l M_m D_m) :precision binary64 (/ d_m (sqrt (* l h))))
d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
return d_m / sqrt((l * h));
}
d_m = private
M_m = private
D_m = private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
code = d_m / sqrt((l * h))
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
return d_m / Math.sqrt((l * h));
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) [d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m]) def code(d_m, h, l, M_m, D_m): return d_m / math.sqrt((l * h))
d_m = abs(d) M_m = abs(M) D_m = abs(D) d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m]) function code(d_m, h, l, M_m, D_m) return Float64(d_m / sqrt(Float64(l * h))) end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp = code(d_m, h, l, M_m, D_m)
tmp = d_m / sqrt((l * h));
end
d_m = N[Abs[d], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := N[(d$95$m / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\frac{d\_m}{\sqrt{\ell \cdot h}}
\end{array}
Initial program 35.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites42.8%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-divN/A
metadata-evalN/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6442.9
Applied rewrites42.9%
Applied rewrites43.0%
herbie shell --seed 2025130
(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)))))