
(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}
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (/ (* D_m M_m) d)) (t_1 (/ (fabs d) (sqrt (* h l)))))
(if (<= l -5e-31)
(fma
(*
(* (/ (fabs d) (* (* (sqrt (/ l h)) l) d)) (/ (* (* D_m M_m) M_m) d))
0.125)
D_m
t_1)
(if (<= l 3.4e+122)
(* t_1 (- 1.0 (* (* (* t_0 t_0) 0.125) (* h (/ 1.0 l)))))
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(-
1.0
(*
(* (/ 1.0 2.0) (/ (* (* (/ D_m (+ d d)) M_m) (* D_m M_m)) (+ d d)))
(/ h l))))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (D_m * M_m) / d;
double t_1 = fabs(d) / sqrt((h * l));
double tmp;
if (l <= -5e-31) {
tmp = fma((((fabs(d) / ((sqrt((l / h)) * l) * d)) * (((D_m * M_m) * M_m) / d)) * 0.125), D_m, t_1);
} else if (l <= 3.4e+122) {
tmp = t_1 * (1.0 - (((t_0 * t_0) * 0.125) * (h * (1.0 / l))));
} else {
tmp = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * ((((D_m / (d + d)) * M_m) * (D_m * M_m)) / (d + d))) * (h / l)));
}
return tmp;
}
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(D_m * M_m) / d) t_1 = Float64(abs(d) / sqrt(Float64(h * l))) tmp = 0.0 if (l <= -5e-31) tmp = fma(Float64(Float64(Float64(abs(d) / Float64(Float64(sqrt(Float64(l / h)) * l) * d)) * Float64(Float64(Float64(D_m * M_m) * M_m) / d)) * 0.125), D_m, t_1); elseif (l <= 3.4e+122) tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(Float64(t_0 * t_0) * 0.125) * Float64(h * Float64(1.0 / l))))); else tmp = 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(Float64(Float64(D_m / Float64(d + d)) * M_m) * Float64(D_m * M_m)) / Float64(d + d))) * Float64(h / l)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(D$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision]}, Block[{t$95$1 = N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -5e-31], N[(N[(N[(N[(N[Abs[d], $MachinePrecision] / N[(N[(N[Sqrt[N[(l / h), $MachinePrecision]], $MachinePrecision] * l), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision] * D$95$m + t$95$1), $MachinePrecision], If[LessEqual[l, 3.4e+122], N[(t$95$1 * N[(1.0 - N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.125), $MachinePrecision] * N[(h * N[(1.0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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[(N[(N[(N[(D$95$m / N[(d + d), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] / N[(d + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{D\_m \cdot M\_m}{d}\\
t_1 := \frac{\left|d\right|}{\sqrt{h \cdot \ell}}\\
\mathbf{if}\;\ell \leq -5 \cdot 10^{-31}:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{\left|d\right|}{\left(\sqrt{\frac{\ell}{h}} \cdot \ell\right) \cdot d} \cdot \frac{\left(D\_m \cdot M\_m\right) \cdot M\_m}{d}\right) \cdot 0.125, D\_m, t\_1\right)\\
\mathbf{elif}\;\ell \leq 3.4 \cdot 10^{+122}:\\
\;\;\;\;t\_1 \cdot \left(1 - \left(\left(t\_0 \cdot t\_0\right) \cdot 0.125\right) \cdot \left(h \cdot \frac{1}{\ell}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\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 \frac{\left(\frac{D\_m}{d + d} \cdot M\_m\right) \cdot \left(D\_m \cdot M\_m\right)}{d + d}\right) \cdot \frac{h}{\ell}\right)\\
\end{array}
\end{array}
if l < -5e-31Initial program 66.9%
Taylor expanded in l around inf
Applied rewrites48.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6450.1
Applied rewrites50.1%
Taylor expanded in h around -inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites40.1%
lift-/.f64N/A
lift-fabs.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
associate-*r*N/A
times-fracN/A
lower-*.f64N/A
Applied rewrites51.1%
if -5e-31 < l < 3.4e122Initial program 66.9%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
frac-timesN/A
unpow2N/A
fabs-pow2-revN/A
sqrt-div-sound-leftN/A
fabs-pow2-revN/A
unpow2N/A
rem-sqrt-square-revN/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-*.f6469.8
Applied rewrites69.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f6446.5
Applied rewrites46.5%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
unswap-sqrN/A
times-fracN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6469.8
Applied rewrites69.8%
lift-/.f64N/A
mult-flipN/A
lower-*.f64N/A
lower-/.f6469.8
Applied rewrites69.8%
if 3.4e122 < l Initial program 66.9%
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
count-2-revN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
count-2-revN/A
lower-+.f6465.0
Applied rewrites65.0%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (/ (* D_m M_m) d))
(t_1 (* (* t_0 t_0) 0.125))
(t_2 (/ (fabs d) (sqrt (* h l)))))
(if (<= l -5e-31)
(fma
(*
(* (/ (fabs d) (* (* (sqrt (/ l h)) l) d)) (/ (* (* D_m M_m) M_m) d))
0.125)
D_m
t_2)
(if (<= l 3.4e+122)
(* t_2 (- 1.0 (* t_1 (* h (/ 1.0 l)))))
(* (* (sqrt (/ d l)) (sqrt (/ d h))) (- 1.0 (* t_1 (/ h l))))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (D_m * M_m) / d;
double t_1 = (t_0 * t_0) * 0.125;
double t_2 = fabs(d) / sqrt((h * l));
double tmp;
if (l <= -5e-31) {
tmp = fma((((fabs(d) / ((sqrt((l / h)) * l) * d)) * (((D_m * M_m) * M_m) / d)) * 0.125), D_m, t_2);
} else if (l <= 3.4e+122) {
tmp = t_2 * (1.0 - (t_1 * (h * (1.0 / l))));
} else {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (t_1 * (h / l)));
}
return tmp;
}
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(D_m * M_m) / d) t_1 = Float64(Float64(t_0 * t_0) * 0.125) t_2 = Float64(abs(d) / sqrt(Float64(h * l))) tmp = 0.0 if (l <= -5e-31) tmp = fma(Float64(Float64(Float64(abs(d) / Float64(Float64(sqrt(Float64(l / h)) * l) * d)) * Float64(Float64(Float64(D_m * M_m) * M_m) / d)) * 0.125), D_m, t_2); elseif (l <= 3.4e+122) tmp = Float64(t_2 * Float64(1.0 - Float64(t_1 * Float64(h * Float64(1.0 / l))))); else tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(t_1 * Float64(h / l)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(D$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.125), $MachinePrecision]}, Block[{t$95$2 = N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -5e-31], N[(N[(N[(N[(N[Abs[d], $MachinePrecision] / N[(N[(N[Sqrt[N[(l / h), $MachinePrecision]], $MachinePrecision] * l), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision] * D$95$m + t$95$2), $MachinePrecision], If[LessEqual[l, 3.4e+122], N[(t$95$2 * N[(1.0 - N[(t$95$1 * N[(h * N[(1.0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(t$95$1 * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{D\_m \cdot M\_m}{d}\\
t_1 := \left(t\_0 \cdot t\_0\right) \cdot 0.125\\
t_2 := \frac{\left|d\right|}{\sqrt{h \cdot \ell}}\\
\mathbf{if}\;\ell \leq -5 \cdot 10^{-31}:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{\left|d\right|}{\left(\sqrt{\frac{\ell}{h}} \cdot \ell\right) \cdot d} \cdot \frac{\left(D\_m \cdot M\_m\right) \cdot M\_m}{d}\right) \cdot 0.125, D\_m, t\_2\right)\\
\mathbf{elif}\;\ell \leq 3.4 \cdot 10^{+122}:\\
\;\;\;\;t\_2 \cdot \left(1 - t\_1 \cdot \left(h \cdot \frac{1}{\ell}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - t\_1 \cdot \frac{h}{\ell}\right)\\
\end{array}
\end{array}
if l < -5e-31Initial program 66.9%
Taylor expanded in l around inf
Applied rewrites48.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6450.1
Applied rewrites50.1%
Taylor expanded in h around -inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites40.1%
lift-/.f64N/A
lift-fabs.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
associate-*r*N/A
times-fracN/A
lower-*.f64N/A
Applied rewrites51.1%
if -5e-31 < l < 3.4e122Initial program 66.9%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
frac-timesN/A
unpow2N/A
fabs-pow2-revN/A
sqrt-div-sound-leftN/A
fabs-pow2-revN/A
unpow2N/A
rem-sqrt-square-revN/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-*.f6469.8
Applied rewrites69.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f6446.5
Applied rewrites46.5%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
unswap-sqrN/A
times-fracN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6469.8
Applied rewrites69.8%
lift-/.f64N/A
mult-flipN/A
lower-*.f64N/A
lower-/.f6469.8
Applied rewrites69.8%
if 3.4e122 < l Initial program 66.9%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
frac-timesN/A
unpow2N/A
fabs-pow2-revN/A
sqrt-div-sound-leftN/A
fabs-pow2-revN/A
unpow2N/A
rem-sqrt-square-revN/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-*.f6469.8
Applied rewrites69.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f6446.5
Applied rewrites46.5%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
unswap-sqrN/A
times-fracN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6469.8
Applied rewrites69.8%
lift-fabs.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-undivN/A
pow2N/A
*-commutativeN/A
times-fracN/A
sqrt-unprodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f6466.9
Applied rewrites66.9%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (/ (* D_m M_m) d)) (t_1 (* (* t_0 t_0) 0.125)))
(if (<= h 20000000000.0)
(* (/ (fabs d) (sqrt (* h l))) (- 1.0 (* t_1 (* h (/ 1.0 l)))))
(* (/ (fabs d) (* (sqrt (/ l h)) h)) (- 1.0 (* t_1 (/ h l)))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (D_m * M_m) / d;
double t_1 = (t_0 * t_0) * 0.125;
double tmp;
if (h <= 20000000000.0) {
tmp = (fabs(d) / sqrt((h * l))) * (1.0 - (t_1 * (h * (1.0 / l))));
} else {
tmp = (fabs(d) / (sqrt((l / h)) * h)) * (1.0 - (t_1 * (h / l)));
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, 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, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (d_m * m_m) / d
t_1 = (t_0 * t_0) * 0.125d0
if (h <= 20000000000.0d0) then
tmp = (abs(d) / sqrt((h * l))) * (1.0d0 - (t_1 * (h * (1.0d0 / l))))
else
tmp = (abs(d) / (sqrt((l / h)) * h)) * (1.0d0 - (t_1 * (h / l)))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (D_m * M_m) / d;
double t_1 = (t_0 * t_0) * 0.125;
double tmp;
if (h <= 20000000000.0) {
tmp = (Math.abs(d) / Math.sqrt((h * l))) * (1.0 - (t_1 * (h * (1.0 / l))));
} else {
tmp = (Math.abs(d) / (Math.sqrt((l / h)) * h)) * (1.0 - (t_1 * (h / l)));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = (D_m * M_m) / d t_1 = (t_0 * t_0) * 0.125 tmp = 0 if h <= 20000000000.0: tmp = (math.fabs(d) / math.sqrt((h * l))) * (1.0 - (t_1 * (h * (1.0 / l)))) else: tmp = (math.fabs(d) / (math.sqrt((l / h)) * h)) * (1.0 - (t_1 * (h / l))) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(D_m * M_m) / d) t_1 = Float64(Float64(t_0 * t_0) * 0.125) tmp = 0.0 if (h <= 20000000000.0) tmp = Float64(Float64(abs(d) / sqrt(Float64(h * l))) * Float64(1.0 - Float64(t_1 * Float64(h * Float64(1.0 / l))))); else tmp = Float64(Float64(abs(d) / Float64(sqrt(Float64(l / h)) * h)) * Float64(1.0 - Float64(t_1 * Float64(h / l)))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = (D_m * M_m) / d;
t_1 = (t_0 * t_0) * 0.125;
tmp = 0.0;
if (h <= 20000000000.0)
tmp = (abs(d) / sqrt((h * l))) * (1.0 - (t_1 * (h * (1.0 / l))));
else
tmp = (abs(d) / (sqrt((l / h)) * h)) * (1.0 - (t_1 * (h / l)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(D$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.125), $MachinePrecision]}, If[LessEqual[h, 20000000000.0], N[(N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(t$95$1 * N[(h * N[(1.0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Abs[d], $MachinePrecision] / N[(N[Sqrt[N[(l / h), $MachinePrecision]], $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(t$95$1 * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{D\_m \cdot M\_m}{d}\\
t_1 := \left(t\_0 \cdot t\_0\right) \cdot 0.125\\
\mathbf{if}\;h \leq 20000000000:\\
\;\;\;\;\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \cdot \left(1 - t\_1 \cdot \left(h \cdot \frac{1}{\ell}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|d\right|}{\sqrt{\frac{\ell}{h}} \cdot h} \cdot \left(1 - t\_1 \cdot \frac{h}{\ell}\right)\\
\end{array}
\end{array}
if h < 2e10Initial program 66.9%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
frac-timesN/A
unpow2N/A
fabs-pow2-revN/A
sqrt-div-sound-leftN/A
fabs-pow2-revN/A
unpow2N/A
rem-sqrt-square-revN/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-*.f6469.8
Applied rewrites69.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f6446.5
Applied rewrites46.5%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
unswap-sqrN/A
times-fracN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6469.8
Applied rewrites69.8%
lift-/.f64N/A
mult-flipN/A
lower-*.f64N/A
lower-/.f6469.8
Applied rewrites69.8%
if 2e10 < h Initial program 66.9%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
frac-timesN/A
unpow2N/A
fabs-pow2-revN/A
sqrt-div-sound-leftN/A
fabs-pow2-revN/A
unpow2N/A
rem-sqrt-square-revN/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-*.f6469.8
Applied rewrites69.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f6446.5
Applied rewrites46.5%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
unswap-sqrN/A
times-fracN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6469.8
Applied rewrites69.8%
Taylor expanded in h around inf
*-commutativeN/A
lower-*.f64N/A
lift-sqrt.f64N/A
lift-/.f6438.2
Applied rewrites38.2%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (/ (fabs d) (sqrt (* h l))))
(t_1
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l)))))
(t_2 (/ (* D_m M_m) d))
(t_3 (* (* t_2 t_2) 0.125)))
(if (<= t_1 (- INFINITY))
(* (* (* (* (* t_0 h) (* (/ M_m d) (/ M_m (* l d)))) -0.125) D_m) D_m)
(if (<= t_1 5e-79)
(* (/ (fabs d) (* (sqrt (/ h l)) l)) (- 1.0 (* t_3 (/ h l))))
(* t_0 (- 1.0 (* t_3 (* h (/ 1.0 l)))))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = fabs(d) / sqrt((h * l));
double t_1 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_2 = (D_m * M_m) / d;
double t_3 = (t_2 * t_2) * 0.125;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = ((((t_0 * h) * ((M_m / d) * (M_m / (l * d)))) * -0.125) * D_m) * D_m;
} else if (t_1 <= 5e-79) {
tmp = (fabs(d) / (sqrt((h / l)) * l)) * (1.0 - (t_3 * (h / l)));
} else {
tmp = t_0 * (1.0 - (t_3 * (h * (1.0 / l))));
}
return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = Math.abs(d) / Math.sqrt((h * l));
double t_1 = (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_2 = (D_m * M_m) / d;
double t_3 = (t_2 * t_2) * 0.125;
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = ((((t_0 * h) * ((M_m / d) * (M_m / (l * d)))) * -0.125) * D_m) * D_m;
} else if (t_1 <= 5e-79) {
tmp = (Math.abs(d) / (Math.sqrt((h / l)) * l)) * (1.0 - (t_3 * (h / l)));
} else {
tmp = t_0 * (1.0 - (t_3 * (h * (1.0 / l))));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = math.fabs(d) / math.sqrt((h * l)) t_1 = (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l))) t_2 = (D_m * M_m) / d t_3 = (t_2 * t_2) * 0.125 tmp = 0 if t_1 <= -math.inf: tmp = ((((t_0 * h) * ((M_m / d) * (M_m / (l * d)))) * -0.125) * D_m) * D_m elif t_1 <= 5e-79: tmp = (math.fabs(d) / (math.sqrt((h / l)) * l)) * (1.0 - (t_3 * (h / l))) else: tmp = t_0 * (1.0 - (t_3 * (h * (1.0 / l)))) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(abs(d) / sqrt(Float64(h * l))) t_1 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_2 = Float64(Float64(D_m * M_m) / d) t_3 = Float64(Float64(t_2 * t_2) * 0.125) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(Float64(Float64(Float64(Float64(t_0 * h) * Float64(Float64(M_m / d) * Float64(M_m / Float64(l * d)))) * -0.125) * D_m) * D_m); elseif (t_1 <= 5e-79) tmp = Float64(Float64(abs(d) / Float64(sqrt(Float64(h / l)) * l)) * Float64(1.0 - Float64(t_3 * Float64(h / l)))); else tmp = Float64(t_0 * Float64(1.0 - Float64(t_3 * Float64(h * Float64(1.0 / l))))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = abs(d) / sqrt((h * l));
t_1 = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
t_2 = (D_m * M_m) / d;
t_3 = (t_2 * t_2) * 0.125;
tmp = 0.0;
if (t_1 <= -Inf)
tmp = ((((t_0 * h) * ((M_m / d) * (M_m / (l * d)))) * -0.125) * D_m) * D_m;
elseif (t_1 <= 5e-79)
tmp = (abs(d) / (sqrt((h / l)) * l)) * (1.0 - (t_3 * (h / l)));
else
tmp = t_0 * (1.0 - (t_3 * (h * (1.0 / l))));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(D$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision]}, Block[{t$95$3 = N[(N[(t$95$2 * t$95$2), $MachinePrecision] * 0.125), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(N[(N[(N[(t$95$0 * h), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * N[(M$95$m / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision], If[LessEqual[t$95$1, 5e-79], N[(N[(N[Abs[d], $MachinePrecision] / N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(t$95$3 * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(1.0 - N[(t$95$3 * N[(h * N[(1.0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\left|d\right|}{\sqrt{h \cdot \ell}}\\
t_1 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_2 := \frac{D\_m \cdot M\_m}{d}\\
t_3 := \left(t\_2 \cdot t\_2\right) \cdot 0.125\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\left(\left(\left(\left(t\_0 \cdot h\right) \cdot \left(\frac{M\_m}{d} \cdot \frac{M\_m}{\ell \cdot d}\right)\right) \cdot -0.125\right) \cdot D\_m\right) \cdot D\_m\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-79}:\\
\;\;\;\;\frac{\left|d\right|}{\sqrt{\frac{h}{\ell}} \cdot \ell} \cdot \left(1 - t\_3 \cdot \frac{h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(1 - t\_3 \cdot \left(h \cdot \frac{1}{\ell}\right)\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)))) < -inf.0Initial program 66.9%
Taylor expanded in d around 0
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites26.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6433.9
Applied rewrites33.9%
if -inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 4.99999999999999999e-79Initial program 66.9%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
frac-timesN/A
unpow2N/A
fabs-pow2-revN/A
sqrt-div-sound-leftN/A
fabs-pow2-revN/A
unpow2N/A
rem-sqrt-square-revN/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-*.f6469.8
Applied rewrites69.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f6446.5
Applied rewrites46.5%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
unswap-sqrN/A
times-fracN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6469.8
Applied rewrites69.8%
Taylor expanded in l around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lift-/.f6434.9
Applied rewrites34.9%
if 4.99999999999999999e-79 < (*.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 66.9%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
frac-timesN/A
unpow2N/A
fabs-pow2-revN/A
sqrt-div-sound-leftN/A
fabs-pow2-revN/A
unpow2N/A
rem-sqrt-square-revN/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-*.f6469.8
Applied rewrites69.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f6446.5
Applied rewrites46.5%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
unswap-sqrN/A
times-fracN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6469.8
Applied rewrites69.8%
lift-/.f64N/A
mult-flipN/A
lower-*.f64N/A
lower-/.f6469.8
Applied rewrites69.8%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (/ (* D_m M_m) d)) (t_1 (/ (fabs d) (sqrt (* h l)))))
(if (<=
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l))))
(- INFINITY))
(* (* (* (* (* t_1 h) (* (/ M_m d) (/ M_m (* l d)))) -0.125) D_m) D_m)
(* t_1 (- 1.0 (* (* (* t_0 t_0) 0.125) (* h (/ 1.0 l))))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (D_m * M_m) / d;
double t_1 = fabs(d) / sqrt((h * l));
double tmp;
if (((pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -((double) INFINITY)) {
tmp = ((((t_1 * h) * ((M_m / d) * (M_m / (l * d)))) * -0.125) * D_m) * D_m;
} else {
tmp = t_1 * (1.0 - (((t_0 * t_0) * 0.125) * (h * (1.0 / l))));
}
return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (D_m * M_m) / d;
double t_1 = Math.abs(d) / Math.sqrt((h * l));
double tmp;
if (((Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -Double.POSITIVE_INFINITY) {
tmp = ((((t_1 * h) * ((M_m / d) * (M_m / (l * d)))) * -0.125) * D_m) * D_m;
} else {
tmp = t_1 * (1.0 - (((t_0 * t_0) * 0.125) * (h * (1.0 / l))));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = (D_m * M_m) / d t_1 = math.fabs(d) / math.sqrt((h * l)) tmp = 0 if ((math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -math.inf: tmp = ((((t_1 * h) * ((M_m / d) * (M_m / (l * d)))) * -0.125) * D_m) * D_m else: tmp = t_1 * (1.0 - (((t_0 * t_0) * 0.125) * (h * (1.0 / l)))) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(D_m * M_m) / d) t_1 = Float64(abs(d) / sqrt(Float64(h * l))) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= Float64(-Inf)) tmp = Float64(Float64(Float64(Float64(Float64(t_1 * h) * Float64(Float64(M_m / d) * Float64(M_m / Float64(l * d)))) * -0.125) * D_m) * D_m); else tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(Float64(t_0 * t_0) * 0.125) * Float64(h * Float64(1.0 / l))))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = (D_m * M_m) / d;
t_1 = abs(d) / sqrt((h * l));
tmp = 0.0;
if (((((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= -Inf)
tmp = ((((t_1 * h) * ((M_m / d) * (M_m / (l * d)))) * -0.125) * D_m) * D_m;
else
tmp = t_1 * (1.0 - (((t_0 * t_0) * 0.125) * (h * (1.0 / l))));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(D$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision]}, Block[{t$95$1 = N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-Infinity)], N[(N[(N[(N[(N[(t$95$1 * h), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * N[(M$95$m / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision], N[(t$95$1 * N[(1.0 - N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.125), $MachinePrecision] * N[(h * N[(1.0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{D\_m \cdot M\_m}{d}\\
t_1 := \frac{\left|d\right|}{\sqrt{h \cdot \ell}}\\
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -\infty:\\
\;\;\;\;\left(\left(\left(\left(t\_1 \cdot h\right) \cdot \left(\frac{M\_m}{d} \cdot \frac{M\_m}{\ell \cdot d}\right)\right) \cdot -0.125\right) \cdot D\_m\right) \cdot D\_m\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(1 - \left(\left(t\_0 \cdot t\_0\right) \cdot 0.125\right) \cdot \left(h \cdot \frac{1}{\ell}\right)\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)))) < -inf.0Initial program 66.9%
Taylor expanded in d around 0
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites26.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6433.9
Applied rewrites33.9%
if -inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 66.9%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
frac-timesN/A
unpow2N/A
fabs-pow2-revN/A
sqrt-div-sound-leftN/A
fabs-pow2-revN/A
unpow2N/A
rem-sqrt-square-revN/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-*.f6469.8
Applied rewrites69.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f6446.5
Applied rewrites46.5%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
unswap-sqrN/A
times-fracN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6469.8
Applied rewrites69.8%
lift-/.f64N/A
mult-flipN/A
lower-*.f64N/A
lower-/.f6469.8
Applied rewrites69.8%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (/ (* D_m M_m) d)) (t_1 (/ (fabs d) (sqrt (* h l)))))
(if (<=
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l))))
(- INFINITY))
(* (* (* (* (* t_1 h) (* (/ M_m d) (/ M_m (* l d)))) -0.125) D_m) D_m)
(* t_1 (- 1.0 (* (* (* t_0 t_0) 0.125) (/ h l)))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (D_m * M_m) / d;
double t_1 = fabs(d) / sqrt((h * l));
double tmp;
if (((pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -((double) INFINITY)) {
tmp = ((((t_1 * h) * ((M_m / d) * (M_m / (l * d)))) * -0.125) * D_m) * D_m;
} else {
tmp = t_1 * (1.0 - (((t_0 * t_0) * 0.125) * (h / l)));
}
return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (D_m * M_m) / d;
double t_1 = Math.abs(d) / Math.sqrt((h * l));
double tmp;
if (((Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -Double.POSITIVE_INFINITY) {
tmp = ((((t_1 * h) * ((M_m / d) * (M_m / (l * d)))) * -0.125) * D_m) * D_m;
} else {
tmp = t_1 * (1.0 - (((t_0 * t_0) * 0.125) * (h / l)));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = (D_m * M_m) / d t_1 = math.fabs(d) / math.sqrt((h * l)) tmp = 0 if ((math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -math.inf: tmp = ((((t_1 * h) * ((M_m / d) * (M_m / (l * d)))) * -0.125) * D_m) * D_m else: tmp = t_1 * (1.0 - (((t_0 * t_0) * 0.125) * (h / l))) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(D_m * M_m) / d) t_1 = Float64(abs(d) / sqrt(Float64(h * l))) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= Float64(-Inf)) tmp = Float64(Float64(Float64(Float64(Float64(t_1 * h) * Float64(Float64(M_m / d) * Float64(M_m / Float64(l * d)))) * -0.125) * D_m) * D_m); else tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(Float64(t_0 * t_0) * 0.125) * Float64(h / l)))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = (D_m * M_m) / d;
t_1 = abs(d) / sqrt((h * l));
tmp = 0.0;
if (((((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= -Inf)
tmp = ((((t_1 * h) * ((M_m / d) * (M_m / (l * d)))) * -0.125) * D_m) * D_m;
else
tmp = t_1 * (1.0 - (((t_0 * t_0) * 0.125) * (h / l)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(D$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision]}, Block[{t$95$1 = N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-Infinity)], N[(N[(N[(N[(N[(t$95$1 * h), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * N[(M$95$m / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision], N[(t$95$1 * N[(1.0 - N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.125), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{D\_m \cdot M\_m}{d}\\
t_1 := \frac{\left|d\right|}{\sqrt{h \cdot \ell}}\\
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -\infty:\\
\;\;\;\;\left(\left(\left(\left(t\_1 \cdot h\right) \cdot \left(\frac{M\_m}{d} \cdot \frac{M\_m}{\ell \cdot d}\right)\right) \cdot -0.125\right) \cdot D\_m\right) \cdot D\_m\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(1 - \left(\left(t\_0 \cdot t\_0\right) \cdot 0.125\right) \cdot \frac{h}{\ell}\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)))) < -inf.0Initial program 66.9%
Taylor expanded in d around 0
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites26.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6433.9
Applied rewrites33.9%
if -inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 66.9%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
frac-timesN/A
unpow2N/A
fabs-pow2-revN/A
sqrt-div-sound-leftN/A
fabs-pow2-revN/A
unpow2N/A
rem-sqrt-square-revN/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-*.f6469.8
Applied rewrites69.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f6446.5
Applied rewrites46.5%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
unswap-sqrN/A
times-fracN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6469.8
Applied rewrites69.8%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (* l h))))
(if (<= (* M_m D_m) 5e-163)
(/ (fabs d) t_0)
(if (<= (* M_m D_m) 5e+130)
(*
(/ (fabs d) (sqrt (* h l)))
(- 1.0 (* (* (* (* D_m M_m) (/ (* D_m M_m) (* d d))) 0.125) (/ h l))))
(*
(fabs d)
(/
(- 1.0 (* (* (* (* (* M_m M_m) D_m) (/ D_m (* d d))) 0.125) (/ h l)))
t_0))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((l * h));
double tmp;
if ((M_m * D_m) <= 5e-163) {
tmp = fabs(d) / t_0;
} else if ((M_m * D_m) <= 5e+130) {
tmp = (fabs(d) / sqrt((h * l))) * (1.0 - ((((D_m * M_m) * ((D_m * M_m) / (d * d))) * 0.125) * (h / l)));
} else {
tmp = fabs(d) * ((1.0 - (((((M_m * M_m) * D_m) * (D_m / (d * d))) * 0.125) * (h / l))) / t_0);
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, 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, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((l * h))
if ((m_m * d_m) <= 5d-163) then
tmp = abs(d) / t_0
else if ((m_m * d_m) <= 5d+130) then
tmp = (abs(d) / sqrt((h * l))) * (1.0d0 - ((((d_m * m_m) * ((d_m * m_m) / (d * d))) * 0.125d0) * (h / l)))
else
tmp = abs(d) * ((1.0d0 - (((((m_m * m_m) * d_m) * (d_m / (d * d))) * 0.125d0) * (h / l))) / t_0)
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = Math.sqrt((l * h));
double tmp;
if ((M_m * D_m) <= 5e-163) {
tmp = Math.abs(d) / t_0;
} else if ((M_m * D_m) <= 5e+130) {
tmp = (Math.abs(d) / Math.sqrt((h * l))) * (1.0 - ((((D_m * M_m) * ((D_m * M_m) / (d * d))) * 0.125) * (h / l)));
} else {
tmp = Math.abs(d) * ((1.0 - (((((M_m * M_m) * D_m) * (D_m / (d * d))) * 0.125) * (h / l))) / t_0);
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = math.sqrt((l * h)) tmp = 0 if (M_m * D_m) <= 5e-163: tmp = math.fabs(d) / t_0 elif (M_m * D_m) <= 5e+130: tmp = (math.fabs(d) / math.sqrt((h * l))) * (1.0 - ((((D_m * M_m) * ((D_m * M_m) / (d * d))) * 0.125) * (h / l))) else: tmp = math.fabs(d) * ((1.0 - (((((M_m * M_m) * D_m) * (D_m / (d * d))) * 0.125) * (h / l))) / t_0) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = sqrt(Float64(l * h)) tmp = 0.0 if (Float64(M_m * D_m) <= 5e-163) tmp = Float64(abs(d) / t_0); elseif (Float64(M_m * D_m) <= 5e+130) tmp = Float64(Float64(abs(d) / sqrt(Float64(h * l))) * Float64(1.0 - Float64(Float64(Float64(Float64(D_m * M_m) * Float64(Float64(D_m * M_m) / Float64(d * d))) * 0.125) * Float64(h / l)))); else tmp = Float64(abs(d) * Float64(Float64(1.0 - Float64(Float64(Float64(Float64(Float64(M_m * M_m) * D_m) * Float64(D_m / Float64(d * d))) * 0.125) * Float64(h / l))) / t_0)); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = sqrt((l * h));
tmp = 0.0;
if ((M_m * D_m) <= 5e-163)
tmp = abs(d) / t_0;
elseif ((M_m * D_m) <= 5e+130)
tmp = (abs(d) / sqrt((h * l))) * (1.0 - ((((D_m * M_m) * ((D_m * M_m) / (d * d))) * 0.125) * (h / l)));
else
tmp = abs(d) * ((1.0 - (((((M_m * M_m) * D_m) * (D_m / (d * d))) * 0.125) * (h / l))) / t_0);
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 5e-163], N[(N[Abs[d], $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 5e+130], N[(N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(N[(D$95$m * M$95$m), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Abs[d], $MachinePrecision] * N[(N[(1.0 - N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(D$95$m / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;M\_m \cdot D\_m \leq 5 \cdot 10^{-163}:\\
\;\;\;\;\frac{\left|d\right|}{t\_0}\\
\mathbf{elif}\;M\_m \cdot D\_m \leq 5 \cdot 10^{+130}:\\
\;\;\;\;\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \cdot \left(1 - \left(\left(\left(D\_m \cdot M\_m\right) \cdot \frac{D\_m \cdot M\_m}{d \cdot d}\right) \cdot 0.125\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\left|d\right| \cdot \frac{1 - \left(\left(\left(\left(M\_m \cdot M\_m\right) \cdot D\_m\right) \cdot \frac{D\_m}{d \cdot d}\right) \cdot 0.125\right) \cdot \frac{h}{\ell}}{t\_0}\\
\end{array}
\end{array}
if (*.f64 M D) < 4.99999999999999977e-163Initial program 66.9%
Taylor expanded in h around 0
lower-/.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6421.1
Applied rewrites21.1%
Taylor expanded in h around inf
sqrt-undivN/A
pow2N/A
rem-sqrt-square-revN/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-fabs.f6442.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.7
Applied rewrites42.7%
if 4.99999999999999977e-163 < (*.f64 M D) < 4.9999999999999996e130Initial program 66.9%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
frac-timesN/A
unpow2N/A
fabs-pow2-revN/A
sqrt-div-sound-leftN/A
fabs-pow2-revN/A
unpow2N/A
rem-sqrt-square-revN/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-*.f6469.8
Applied rewrites69.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f6446.5
Applied rewrites46.5%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
unswap-sqrN/A
pow2N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6459.5
Applied rewrites59.5%
if 4.9999999999999996e130 < (*.f64 M D) Initial program 66.9%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
frac-timesN/A
unpow2N/A
fabs-pow2-revN/A
sqrt-div-sound-leftN/A
fabs-pow2-revN/A
unpow2N/A
rem-sqrt-square-revN/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-*.f6469.8
Applied rewrites69.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f6446.5
Applied rewrites46.5%
Applied rewrites54.9%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (/ (fabs d) (sqrt (* h l)))))
(if (<= D_m 1.1e+144)
(*
t_0
(- 1.0 (* (* (* (/ M_m d) (/ (* M_m (* D_m D_m)) d)) 0.125) (/ h l))))
(*
t_0
(- 1.0 (* (* (* (* D_m M_m) (/ (* D_m M_m) (* d d))) 0.125) (/ h l)))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = fabs(d) / sqrt((h * l));
double tmp;
if (D_m <= 1.1e+144) {
tmp = t_0 * (1.0 - ((((M_m / d) * ((M_m * (D_m * D_m)) / d)) * 0.125) * (h / l)));
} else {
tmp = t_0 * (1.0 - ((((D_m * M_m) * ((D_m * M_m) / (d * d))) * 0.125) * (h / l)));
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, 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, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = abs(d) / sqrt((h * l))
if (d_m <= 1.1d+144) then
tmp = t_0 * (1.0d0 - ((((m_m / d) * ((m_m * (d_m * d_m)) / d)) * 0.125d0) * (h / l)))
else
tmp = t_0 * (1.0d0 - ((((d_m * m_m) * ((d_m * m_m) / (d * d))) * 0.125d0) * (h / l)))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = Math.abs(d) / Math.sqrt((h * l));
double tmp;
if (D_m <= 1.1e+144) {
tmp = t_0 * (1.0 - ((((M_m / d) * ((M_m * (D_m * D_m)) / d)) * 0.125) * (h / l)));
} else {
tmp = t_0 * (1.0 - ((((D_m * M_m) * ((D_m * M_m) / (d * d))) * 0.125) * (h / l)));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = math.fabs(d) / math.sqrt((h * l)) tmp = 0 if D_m <= 1.1e+144: tmp = t_0 * (1.0 - ((((M_m / d) * ((M_m * (D_m * D_m)) / d)) * 0.125) * (h / l))) else: tmp = t_0 * (1.0 - ((((D_m * M_m) * ((D_m * M_m) / (d * d))) * 0.125) * (h / l))) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(abs(d) / sqrt(Float64(h * l))) tmp = 0.0 if (D_m <= 1.1e+144) tmp = Float64(t_0 * Float64(1.0 - Float64(Float64(Float64(Float64(M_m / d) * Float64(Float64(M_m * Float64(D_m * D_m)) / d)) * 0.125) * Float64(h / l)))); else tmp = Float64(t_0 * Float64(1.0 - Float64(Float64(Float64(Float64(D_m * M_m) * Float64(Float64(D_m * M_m) / Float64(d * d))) * 0.125) * Float64(h / l)))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = abs(d) / sqrt((h * l));
tmp = 0.0;
if (D_m <= 1.1e+144)
tmp = t_0 * (1.0 - ((((M_m / d) * ((M_m * (D_m * D_m)) / d)) * 0.125) * (h / l)));
else
tmp = t_0 * (1.0 - ((((D_m * M_m) * ((D_m * M_m) / (d * d))) * 0.125) * (h / l)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[D$95$m, 1.1e+144], N[(t$95$0 * N[(1.0 - N[(N[(N[(N[(M$95$m / d), $MachinePrecision] * N[(N[(M$95$m * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(1.0 - N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(N[(D$95$m * M$95$m), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\left|d\right|}{\sqrt{h \cdot \ell}}\\
\mathbf{if}\;D\_m \leq 1.1 \cdot 10^{+144}:\\
\;\;\;\;t\_0 \cdot \left(1 - \left(\left(\frac{M\_m}{d} \cdot \frac{M\_m \cdot \left(D\_m \cdot D\_m\right)}{d}\right) \cdot 0.125\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(1 - \left(\left(\left(D\_m \cdot M\_m\right) \cdot \frac{D\_m \cdot M\_m}{d \cdot d}\right) \cdot 0.125\right) \cdot \frac{h}{\ell}\right)\\
\end{array}
\end{array}
if D < 1.09999999999999994e144Initial program 66.9%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
frac-timesN/A
unpow2N/A
fabs-pow2-revN/A
sqrt-div-sound-leftN/A
fabs-pow2-revN/A
unpow2N/A
rem-sqrt-square-revN/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-*.f6469.8
Applied rewrites69.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f6446.5
Applied rewrites46.5%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6459.1
Applied rewrites59.1%
if 1.09999999999999994e144 < D Initial program 66.9%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
frac-timesN/A
unpow2N/A
fabs-pow2-revN/A
sqrt-div-sound-leftN/A
fabs-pow2-revN/A
unpow2N/A
rem-sqrt-square-revN/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-*.f6469.8
Applied rewrites69.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f6446.5
Applied rewrites46.5%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
unswap-sqrN/A
pow2N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6459.5
Applied rewrites59.5%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l))))))
(if (<= t_0 -2e-214)
(*
(*
(*
(* (* (/ (fabs d) (sqrt (* h l))) h) (* (/ M_m d) (/ M_m (* l d))))
-0.125)
D_m)
D_m)
(if (<= t_0 5e-79)
(* (sqrt (/ h l)) (/ d h))
(*
(fabs d)
(/
(- 1.0 (* (* (* (* (* M_m M_m) D_m) (/ D_m (* d d))) 0.125) (/ h l)))
(sqrt (* l h))))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -2e-214) {
tmp = (((((fabs(d) / sqrt((h * l))) * h) * ((M_m / d) * (M_m / (l * d)))) * -0.125) * D_m) * D_m;
} else if (t_0 <= 5e-79) {
tmp = sqrt((h / l)) * (d / h);
} else {
tmp = fabs(d) * ((1.0 - (((((M_m * M_m) * D_m) * (D_m / (d * d))) * 0.125) * (h / l))) / sqrt((l * h)));
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, 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, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
if (t_0 <= (-2d-214)) then
tmp = (((((abs(d) / sqrt((h * l))) * h) * ((m_m / d) * (m_m / (l * d)))) * (-0.125d0)) * d_m) * d_m
else if (t_0 <= 5d-79) then
tmp = sqrt((h / l)) * (d / h)
else
tmp = abs(d) * ((1.0d0 - (((((m_m * m_m) * d_m) * (d_m / (d * d))) * 0.125d0) * (h / l))) / sqrt((l * h)))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -2e-214) {
tmp = (((((Math.abs(d) / Math.sqrt((h * l))) * h) * ((M_m / d) * (M_m / (l * d)))) * -0.125) * D_m) * D_m;
} else if (t_0 <= 5e-79) {
tmp = Math.sqrt((h / l)) * (d / h);
} else {
tmp = Math.abs(d) * ((1.0 - (((((M_m * M_m) * D_m) * (D_m / (d * d))) * 0.125) * (h / l))) / Math.sqrt((l * h)));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l))) tmp = 0 if t_0 <= -2e-214: tmp = (((((math.fabs(d) / math.sqrt((h * l))) * h) * ((M_m / d) * (M_m / (l * d)))) * -0.125) * D_m) * D_m elif t_0 <= 5e-79: tmp = math.sqrt((h / l)) * (d / h) else: tmp = math.fabs(d) * ((1.0 - (((((M_m * M_m) * D_m) * (D_m / (d * d))) * 0.125) * (h / l))) / math.sqrt((l * h))) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_0 <= -2e-214) tmp = Float64(Float64(Float64(Float64(Float64(Float64(abs(d) / sqrt(Float64(h * l))) * h) * Float64(Float64(M_m / d) * Float64(M_m / Float64(l * d)))) * -0.125) * D_m) * D_m); elseif (t_0 <= 5e-79) tmp = Float64(sqrt(Float64(h / l)) * Float64(d / h)); else tmp = Float64(abs(d) * Float64(Float64(1.0 - Float64(Float64(Float64(Float64(Float64(M_m * M_m) * D_m) * Float64(D_m / Float64(d * d))) * 0.125) * Float64(h / l))) / sqrt(Float64(l * h)))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
tmp = 0.0;
if (t_0 <= -2e-214)
tmp = (((((abs(d) / sqrt((h * l))) * h) * ((M_m / d) * (M_m / (l * d)))) * -0.125) * D_m) * D_m;
elseif (t_0 <= 5e-79)
tmp = sqrt((h / l)) * (d / h);
else
tmp = abs(d) * ((1.0 - (((((M_m * M_m) * D_m) * (D_m / (d * d))) * 0.125) * (h / l))) / sqrt((l * h)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e-214], N[(N[(N[(N[(N[(N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * N[(M$95$m / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision], If[LessEqual[t$95$0, 5e-79], N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision], N[(N[Abs[d], $MachinePrecision] * N[(N[(1.0 - N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(D$95$m / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-214}:\\
\;\;\;\;\left(\left(\left(\left(\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \cdot h\right) \cdot \left(\frac{M\_m}{d} \cdot \frac{M\_m}{\ell \cdot d}\right)\right) \cdot -0.125\right) \cdot D\_m\right) \cdot D\_m\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-79}:\\
\;\;\;\;\sqrt{\frac{h}{\ell}} \cdot \frac{d}{h}\\
\mathbf{else}:\\
\;\;\;\;\left|d\right| \cdot \frac{1 - \left(\left(\left(\left(M\_m \cdot M\_m\right) \cdot D\_m\right) \cdot \frac{D\_m}{d \cdot d}\right) \cdot 0.125\right) \cdot \frac{h}{\ell}}{\sqrt{\ell \cdot h}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -1.99999999999999983e-214Initial program 66.9%
Taylor expanded in d around 0
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites26.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6433.9
Applied rewrites33.9%
if -1.99999999999999983e-214 < (*.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.99999999999999999e-79Initial program 66.9%
Taylor expanded in h around 0
lower-/.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6421.1
Applied rewrites21.1%
Taylor expanded in h around inf
sqrt-undivN/A
pow2N/A
rem-sqrt-square-revN/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-fabs.f6442.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.7
Applied rewrites42.7%
Taylor expanded in d around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lift-/.f64N/A
lower-/.f6436.9
Applied rewrites36.9%
if 4.99999999999999999e-79 < (*.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 66.9%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
frac-timesN/A
unpow2N/A
fabs-pow2-revN/A
sqrt-div-sound-leftN/A
fabs-pow2-revN/A
unpow2N/A
rem-sqrt-square-revN/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-*.f6469.8
Applied rewrites69.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f6446.5
Applied rewrites46.5%
Applied rewrites54.9%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (/ (fabs d) (sqrt (* h l))))
(t_1
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l))))))
(if (<= t_1 -2e-214)
(* (* (* (* (* t_0 h) (* (/ M_m d) (/ M_m (* l d)))) -0.125) D_m) D_m)
(if (<= t_1 INFINITY)
(/ (fabs d) (sqrt (* l h)))
(*
t_0
(fma
(* (* M_m (/ (* M_m (* D_m D_m)) (* (* d d) l))) -0.125)
h
1.0))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = fabs(d) / sqrt((h * l));
double t_1 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_1 <= -2e-214) {
tmp = ((((t_0 * h) * ((M_m / d) * (M_m / (l * d)))) * -0.125) * D_m) * D_m;
} else if (t_1 <= ((double) INFINITY)) {
tmp = fabs(d) / sqrt((l * h));
} else {
tmp = t_0 * fma(((M_m * ((M_m * (D_m * D_m)) / ((d * d) * l))) * -0.125), h, 1.0);
}
return tmp;
}
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(abs(d) / sqrt(Float64(h * l))) t_1 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_1 <= -2e-214) tmp = Float64(Float64(Float64(Float64(Float64(t_0 * h) * Float64(Float64(M_m / d) * Float64(M_m / Float64(l * d)))) * -0.125) * D_m) * D_m); elseif (t_1 <= Inf) tmp = Float64(abs(d) / sqrt(Float64(l * h))); else tmp = Float64(t_0 * fma(Float64(Float64(M_m * Float64(Float64(M_m * Float64(D_m * D_m)) / Float64(Float64(d * d) * l))) * -0.125), h, 1.0)); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-214], N[(N[(N[(N[(N[(t$95$0 * h), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * N[(M$95$m / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(N[(M$95$m * N[(N[(M$95$m * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * h + 1.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\left|d\right|}{\sqrt{h \cdot \ell}}\\
t_1 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-214}:\\
\;\;\;\;\left(\left(\left(\left(t\_0 \cdot h\right) \cdot \left(\frac{M\_m}{d} \cdot \frac{M\_m}{\ell \cdot d}\right)\right) \cdot -0.125\right) \cdot D\_m\right) \cdot D\_m\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\left|d\right|}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \mathsf{fma}\left(\left(M\_m \cdot \frac{M\_m \cdot \left(D\_m \cdot D\_m\right)}{\left(d \cdot d\right) \cdot \ell}\right) \cdot -0.125, h, 1\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)))) < -1.99999999999999983e-214Initial program 66.9%
Taylor expanded in d around 0
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites26.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6433.9
Applied rewrites33.9%
if -1.99999999999999983e-214 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 66.9%
Taylor expanded in h around 0
lower-/.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6421.1
Applied rewrites21.1%
Taylor expanded in h around inf
sqrt-undivN/A
pow2N/A
rem-sqrt-square-revN/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-fabs.f6442.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.7
Applied rewrites42.7%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 66.9%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
frac-timesN/A
unpow2N/A
fabs-pow2-revN/A
sqrt-div-sound-leftN/A
fabs-pow2-revN/A
unpow2N/A
rem-sqrt-square-revN/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-*.f6469.8
Applied rewrites69.8%
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
count-2-revN/A
lower-+.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
count-2-revN/A
lower-+.f6468.9
Applied rewrites68.9%
Taylor expanded in h around inf
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
distribute-rgt-inN/A
lft-mult-inverseN/A
lower-fma.f64N/A
Applied rewrites52.7%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= M_m 1.85e-24)
(/ (fabs d) (sqrt (* l h)))
(*
(*
(*
(* (* (/ (fabs d) (sqrt (* h l))) h) (* (/ M_m d) (/ M_m (* l d))))
-0.125)
D_m)
D_m)))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (M_m <= 1.85e-24) {
tmp = fabs(d) / sqrt((l * h));
} else {
tmp = (((((fabs(d) / sqrt((h * l))) * h) * ((M_m / d) * (M_m / (l * d)))) * -0.125) * D_m) * D_m;
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, 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, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: tmp
if (m_m <= 1.85d-24) then
tmp = abs(d) / sqrt((l * h))
else
tmp = (((((abs(d) / sqrt((h * l))) * h) * ((m_m / d) * (m_m / (l * d)))) * (-0.125d0)) * d_m) * d_m
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (M_m <= 1.85e-24) {
tmp = Math.abs(d) / Math.sqrt((l * h));
} else {
tmp = (((((Math.abs(d) / Math.sqrt((h * l))) * h) * ((M_m / d) * (M_m / (l * d)))) * -0.125) * D_m) * D_m;
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if M_m <= 1.85e-24: tmp = math.fabs(d) / math.sqrt((l * h)) else: tmp = (((((math.fabs(d) / math.sqrt((h * l))) * h) * ((M_m / d) * (M_m / (l * d)))) * -0.125) * D_m) * D_m return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (M_m <= 1.85e-24) tmp = Float64(abs(d) / sqrt(Float64(l * h))); else tmp = Float64(Float64(Float64(Float64(Float64(Float64(abs(d) / sqrt(Float64(h * l))) * h) * Float64(Float64(M_m / d) * Float64(M_m / Float64(l * d)))) * -0.125) * D_m) * D_m); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (M_m <= 1.85e-24)
tmp = abs(d) / sqrt((l * h));
else
tmp = (((((abs(d) / sqrt((h * l))) * h) * ((M_m / d) * (M_m / (l * d)))) * -0.125) * D_m) * D_m;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[M$95$m, 1.85e-24], N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * N[(M$95$m / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \leq 1.85 \cdot 10^{-24}:\\
\;\;\;\;\frac{\left|d\right|}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(\left(\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \cdot h\right) \cdot \left(\frac{M\_m}{d} \cdot \frac{M\_m}{\ell \cdot d}\right)\right) \cdot -0.125\right) \cdot D\_m\right) \cdot D\_m\\
\end{array}
\end{array}
if M < 1.8499999999999999e-24Initial program 66.9%
Taylor expanded in h around 0
lower-/.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6421.1
Applied rewrites21.1%
Taylor expanded in h around inf
sqrt-undivN/A
pow2N/A
rem-sqrt-square-revN/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-fabs.f6442.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.7
Applied rewrites42.7%
if 1.8499999999999999e-24 < M Initial program 66.9%
Taylor expanded in d around 0
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites26.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6433.9
Applied rewrites33.9%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= M_m 1.5e-30)
(/ (fabs d) (sqrt (* l h)))
(*
(/ (fabs d) (sqrt (* h l)))
(* (* (* D_m D_m) (* h (* (/ M_m (* (* d d) l)) M_m))) -0.125))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (M_m <= 1.5e-30) {
tmp = fabs(d) / sqrt((l * h));
} else {
tmp = (fabs(d) / sqrt((h * l))) * (((D_m * D_m) * (h * ((M_m / ((d * d) * l)) * M_m))) * -0.125);
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, 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, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: tmp
if (m_m <= 1.5d-30) then
tmp = abs(d) / sqrt((l * h))
else
tmp = (abs(d) / sqrt((h * l))) * (((d_m * d_m) * (h * ((m_m / ((d * d) * l)) * m_m))) * (-0.125d0))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (M_m <= 1.5e-30) {
tmp = Math.abs(d) / Math.sqrt((l * h));
} else {
tmp = (Math.abs(d) / Math.sqrt((h * l))) * (((D_m * D_m) * (h * ((M_m / ((d * d) * l)) * M_m))) * -0.125);
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if M_m <= 1.5e-30: tmp = math.fabs(d) / math.sqrt((l * h)) else: tmp = (math.fabs(d) / math.sqrt((h * l))) * (((D_m * D_m) * (h * ((M_m / ((d * d) * l)) * M_m))) * -0.125) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (M_m <= 1.5e-30) tmp = Float64(abs(d) / sqrt(Float64(l * h))); else tmp = Float64(Float64(abs(d) / sqrt(Float64(h * l))) * Float64(Float64(Float64(D_m * D_m) * Float64(h * Float64(Float64(M_m / Float64(Float64(d * d) * l)) * M_m))) * -0.125)); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (M_m <= 1.5e-30)
tmp = abs(d) / sqrt((l * h));
else
tmp = (abs(d) / sqrt((h * l))) * (((D_m * D_m) * (h * ((M_m / ((d * d) * l)) * M_m))) * -0.125);
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[M$95$m, 1.5e-30], N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * N[(h * N[(N[(M$95$m / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \leq 1.5 \cdot 10^{-30}:\\
\;\;\;\;\frac{\left|d\right|}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \cdot \left(\left(\left(D\_m \cdot D\_m\right) \cdot \left(h \cdot \left(\frac{M\_m}{\left(d \cdot d\right) \cdot \ell} \cdot M\_m\right)\right)\right) \cdot -0.125\right)\\
\end{array}
\end{array}
if M < 1.49999999999999995e-30Initial program 66.9%
Taylor expanded in h around 0
lower-/.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6421.1
Applied rewrites21.1%
Taylor expanded in h around inf
sqrt-undivN/A
pow2N/A
rem-sqrt-square-revN/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-fabs.f6442.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.7
Applied rewrites42.7%
if 1.49999999999999995e-30 < M Initial program 66.9%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
frac-timesN/A
unpow2N/A
fabs-pow2-revN/A
sqrt-div-sound-leftN/A
fabs-pow2-revN/A
unpow2N/A
rem-sqrt-square-revN/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-*.f6469.8
Applied rewrites69.8%
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
count-2-revN/A
lower-+.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
count-2-revN/A
lower-+.f6468.9
Applied rewrites68.9%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites26.2%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (* l h))))
(if (<= M_m 2.8e-31)
(/ (fabs d) t_0)
(*
(*
(* (* (* (/ (* (fabs d) h) t_0) M_m) (/ M_m (* (* d d) l))) -0.125)
D_m)
D_m))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((l * h));
double tmp;
if (M_m <= 2.8e-31) {
tmp = fabs(d) / t_0;
} else {
tmp = ((((((fabs(d) * h) / t_0) * M_m) * (M_m / ((d * d) * l))) * -0.125) * D_m) * D_m;
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, 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, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((l * h))
if (m_m <= 2.8d-31) then
tmp = abs(d) / t_0
else
tmp = ((((((abs(d) * h) / t_0) * m_m) * (m_m / ((d * d) * l))) * (-0.125d0)) * d_m) * d_m
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = Math.sqrt((l * h));
double tmp;
if (M_m <= 2.8e-31) {
tmp = Math.abs(d) / t_0;
} else {
tmp = ((((((Math.abs(d) * h) / t_0) * M_m) * (M_m / ((d * d) * l))) * -0.125) * D_m) * D_m;
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = math.sqrt((l * h)) tmp = 0 if M_m <= 2.8e-31: tmp = math.fabs(d) / t_0 else: tmp = ((((((math.fabs(d) * h) / t_0) * M_m) * (M_m / ((d * d) * l))) * -0.125) * D_m) * D_m return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = sqrt(Float64(l * h)) tmp = 0.0 if (M_m <= 2.8e-31) tmp = Float64(abs(d) / t_0); else tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64(abs(d) * h) / t_0) * M_m) * Float64(M_m / Float64(Float64(d * d) * l))) * -0.125) * D_m) * D_m); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = sqrt((l * h));
tmp = 0.0;
if (M_m <= 2.8e-31)
tmp = abs(d) / t_0;
else
tmp = ((((((abs(d) * h) / t_0) * M_m) * (M_m / ((d * d) * l))) * -0.125) * D_m) * D_m;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[M$95$m, 2.8e-31], N[(N[Abs[d], $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[(N[Abs[d], $MachinePrecision] * h), $MachinePrecision] / t$95$0), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(M$95$m / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;M\_m \leq 2.8 \cdot 10^{-31}:\\
\;\;\;\;\frac{\left|d\right|}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(\left(\frac{\left|d\right| \cdot h}{t\_0} \cdot M\_m\right) \cdot \frac{M\_m}{\left(d \cdot d\right) \cdot \ell}\right) \cdot -0.125\right) \cdot D\_m\right) \cdot D\_m\\
\end{array}
\end{array}
if M < 2.7999999999999999e-31Initial program 66.9%
Taylor expanded in h around 0
lower-/.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6421.1
Applied rewrites21.1%
Taylor expanded in h around inf
sqrt-undivN/A
pow2N/A
rem-sqrt-square-revN/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-fabs.f6442.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.7
Applied rewrites42.7%
if 2.7999999999999999e-31 < M Initial program 66.9%
Taylor expanded in d around 0
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites26.7%
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites24.1%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (* l h))))
(if (<= M_m 2.8e-31)
(/ (fabs d) t_0)
(*
(* (* (* (* M_m M_m) D_m) D_m) (* h (/ (fabs d) (* (* (* d d) l) t_0))))
-0.125))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((l * h));
double tmp;
if (M_m <= 2.8e-31) {
tmp = fabs(d) / t_0;
} else {
tmp = ((((M_m * M_m) * D_m) * D_m) * (h * (fabs(d) / (((d * d) * l) * t_0)))) * -0.125;
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, 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, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((l * h))
if (m_m <= 2.8d-31) then
tmp = abs(d) / t_0
else
tmp = ((((m_m * m_m) * d_m) * d_m) * (h * (abs(d) / (((d * d) * l) * t_0)))) * (-0.125d0)
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = Math.sqrt((l * h));
double tmp;
if (M_m <= 2.8e-31) {
tmp = Math.abs(d) / t_0;
} else {
tmp = ((((M_m * M_m) * D_m) * D_m) * (h * (Math.abs(d) / (((d * d) * l) * t_0)))) * -0.125;
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = math.sqrt((l * h)) tmp = 0 if M_m <= 2.8e-31: tmp = math.fabs(d) / t_0 else: tmp = ((((M_m * M_m) * D_m) * D_m) * (h * (math.fabs(d) / (((d * d) * l) * t_0)))) * -0.125 return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = sqrt(Float64(l * h)) tmp = 0.0 if (M_m <= 2.8e-31) tmp = Float64(abs(d) / t_0); else tmp = Float64(Float64(Float64(Float64(Float64(M_m * M_m) * D_m) * D_m) * Float64(h * Float64(abs(d) / Float64(Float64(Float64(d * d) * l) * t_0)))) * -0.125); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = sqrt((l * h));
tmp = 0.0;
if (M_m <= 2.8e-31)
tmp = abs(d) / t_0;
else
tmp = ((((M_m * M_m) * D_m) * D_m) * (h * (abs(d) / (((d * d) * l) * t_0)))) * -0.125;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[M$95$m, 2.8e-31], N[(N[Abs[d], $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(h * N[(N[Abs[d], $MachinePrecision] / N[(N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;M\_m \leq 2.8 \cdot 10^{-31}:\\
\;\;\;\;\frac{\left|d\right|}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(\left(M\_m \cdot M\_m\right) \cdot D\_m\right) \cdot D\_m\right) \cdot \left(h \cdot \frac{\left|d\right|}{\left(\left(d \cdot d\right) \cdot \ell\right) \cdot t\_0}\right)\right) \cdot -0.125\\
\end{array}
\end{array}
if M < 2.7999999999999999e-31Initial program 66.9%
Taylor expanded in h around 0
lower-/.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6421.1
Applied rewrites21.1%
Taylor expanded in h around inf
sqrt-undivN/A
pow2N/A
rem-sqrt-square-revN/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-fabs.f6442.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.7
Applied rewrites42.7%
if 2.7999999999999999e-31 < M Initial program 66.9%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
frac-timesN/A
unpow2N/A
fabs-pow2-revN/A
sqrt-div-sound-leftN/A
fabs-pow2-revN/A
unpow2N/A
rem-sqrt-square-revN/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-*.f6469.8
Applied rewrites69.8%
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
count-2-revN/A
lower-+.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
count-2-revN/A
lower-+.f6468.9
Applied rewrites68.9%
Taylor expanded in d around 0
Applied rewrites25.1%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (* l h))))
(if (<= M_m 2.8e-31)
(/ (fabs d) t_0)
(*
(*
(/ (* -0.125 (* (* (* M_m M_m) h) (fabs d))) (* (* (* d d) l) t_0))
D_m)
D_m))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((l * h));
double tmp;
if (M_m <= 2.8e-31) {
tmp = fabs(d) / t_0;
} else {
tmp = (((-0.125 * (((M_m * M_m) * h) * fabs(d))) / (((d * d) * l) * t_0)) * D_m) * D_m;
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, 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, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((l * h))
if (m_m <= 2.8d-31) then
tmp = abs(d) / t_0
else
tmp = ((((-0.125d0) * (((m_m * m_m) * h) * abs(d))) / (((d * d) * l) * t_0)) * d_m) * d_m
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = Math.sqrt((l * h));
double tmp;
if (M_m <= 2.8e-31) {
tmp = Math.abs(d) / t_0;
} else {
tmp = (((-0.125 * (((M_m * M_m) * h) * Math.abs(d))) / (((d * d) * l) * t_0)) * D_m) * D_m;
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = math.sqrt((l * h)) tmp = 0 if M_m <= 2.8e-31: tmp = math.fabs(d) / t_0 else: tmp = (((-0.125 * (((M_m * M_m) * h) * math.fabs(d))) / (((d * d) * l) * t_0)) * D_m) * D_m return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = sqrt(Float64(l * h)) tmp = 0.0 if (M_m <= 2.8e-31) tmp = Float64(abs(d) / t_0); else tmp = Float64(Float64(Float64(Float64(-0.125 * Float64(Float64(Float64(M_m * M_m) * h) * abs(d))) / Float64(Float64(Float64(d * d) * l) * t_0)) * D_m) * D_m); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = sqrt((l * h));
tmp = 0.0;
if (M_m <= 2.8e-31)
tmp = abs(d) / t_0;
else
tmp = (((-0.125 * (((M_m * M_m) * h) * abs(d))) / (((d * d) * l) * t_0)) * D_m) * D_m;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[M$95$m, 2.8e-31], N[(N[Abs[d], $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[(N[(-0.125 * N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] * N[Abs[d], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;M\_m \leq 2.8 \cdot 10^{-31}:\\
\;\;\;\;\frac{\left|d\right|}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{-0.125 \cdot \left(\left(\left(M\_m \cdot M\_m\right) \cdot h\right) \cdot \left|d\right|\right)}{\left(\left(d \cdot d\right) \cdot \ell\right) \cdot t\_0} \cdot D\_m\right) \cdot D\_m\\
\end{array}
\end{array}
if M < 2.7999999999999999e-31Initial program 66.9%
Taylor expanded in h around 0
lower-/.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6421.1
Applied rewrites21.1%
Taylor expanded in h around inf
sqrt-undivN/A
pow2N/A
rem-sqrt-square-revN/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-fabs.f6442.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.7
Applied rewrites42.7%
if 2.7999999999999999e-31 < M Initial program 66.9%
Taylor expanded in d around 0
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites26.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fabs.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
Applied rewrites21.7%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (* l h))))
(if (<= M_m 2.8e-31)
(/ (fabs d) t_0)
(*
(*
(/ (* (* (* D_m M_m) M_m) (* (fabs d) h)) (* (* (* d d) l) t_0))
-0.125)
D_m))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((l * h));
double tmp;
if (M_m <= 2.8e-31) {
tmp = fabs(d) / t_0;
} else {
tmp = (((((D_m * M_m) * M_m) * (fabs(d) * h)) / (((d * d) * l) * t_0)) * -0.125) * D_m;
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, 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, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((l * h))
if (m_m <= 2.8d-31) then
tmp = abs(d) / t_0
else
tmp = (((((d_m * m_m) * m_m) * (abs(d) * h)) / (((d * d) * l) * t_0)) * (-0.125d0)) * d_m
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = Math.sqrt((l * h));
double tmp;
if (M_m <= 2.8e-31) {
tmp = Math.abs(d) / t_0;
} else {
tmp = (((((D_m * M_m) * M_m) * (Math.abs(d) * h)) / (((d * d) * l) * t_0)) * -0.125) * D_m;
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = math.sqrt((l * h)) tmp = 0 if M_m <= 2.8e-31: tmp = math.fabs(d) / t_0 else: tmp = (((((D_m * M_m) * M_m) * (math.fabs(d) * h)) / (((d * d) * l) * t_0)) * -0.125) * D_m return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = sqrt(Float64(l * h)) tmp = 0.0 if (M_m <= 2.8e-31) tmp = Float64(abs(d) / t_0); else tmp = Float64(Float64(Float64(Float64(Float64(Float64(D_m * M_m) * M_m) * Float64(abs(d) * h)) / Float64(Float64(Float64(d * d) * l) * t_0)) * -0.125) * D_m); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = sqrt((l * h));
tmp = 0.0;
if (M_m <= 2.8e-31)
tmp = abs(d) / t_0;
else
tmp = (((((D_m * M_m) * M_m) * (abs(d) * h)) / (((d * d) * l) * t_0)) * -0.125) * D_m;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[M$95$m, 2.8e-31], N[(N[Abs[d], $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(N[Abs[d], $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * D$95$m), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;M\_m \leq 2.8 \cdot 10^{-31}:\\
\;\;\;\;\frac{\left|d\right|}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\left(\left(D\_m \cdot M\_m\right) \cdot M\_m\right) \cdot \left(\left|d\right| \cdot h\right)}{\left(\left(d \cdot d\right) \cdot \ell\right) \cdot t\_0} \cdot -0.125\right) \cdot D\_m\\
\end{array}
\end{array}
if M < 2.7999999999999999e-31Initial program 66.9%
Taylor expanded in h around 0
lower-/.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6421.1
Applied rewrites21.1%
Taylor expanded in h around inf
sqrt-undivN/A
pow2N/A
rem-sqrt-square-revN/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-fabs.f6442.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.7
Applied rewrites42.7%
if 2.7999999999999999e-31 < M Initial program 66.9%
Taylor expanded in d around 0
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites26.7%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites23.6%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<=
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l))))
-2e-181)
(*
(*
(/ (* (* (* D_m M_m) M_m) (fabs d)) (* (* (sqrt (/ l h)) l) (* d d)))
-0.125)
D_m)
(/ (fabs d) (sqrt (* l h)))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (((pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -2e-181) {
tmp = (((((D_m * M_m) * M_m) * fabs(d)) / ((sqrt((l / h)) * l) * (d * d))) * -0.125) * D_m;
} else {
tmp = fabs(d) / sqrt((l * h));
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, 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, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: tmp
if (((((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= (-2d-181)) then
tmp = (((((d_m * m_m) * m_m) * abs(d)) / ((sqrt((l / h)) * l) * (d * d))) * (-0.125d0)) * d_m
else
tmp = abs(d) / sqrt((l * h))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (((Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -2e-181) {
tmp = (((((D_m * M_m) * M_m) * Math.abs(d)) / ((Math.sqrt((l / h)) * l) * (d * d))) * -0.125) * D_m;
} else {
tmp = Math.abs(d) / Math.sqrt((l * h));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if ((math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -2e-181: tmp = (((((D_m * M_m) * M_m) * math.fabs(d)) / ((math.sqrt((l / h)) * l) * (d * d))) * -0.125) * D_m else: tmp = math.fabs(d) / math.sqrt((l * h)) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= -2e-181) tmp = Float64(Float64(Float64(Float64(Float64(Float64(D_m * M_m) * M_m) * abs(d)) / Float64(Float64(sqrt(Float64(l / h)) * l) * Float64(d * d))) * -0.125) * D_m); else tmp = Float64(abs(d) / sqrt(Float64(l * h))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (((((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= -2e-181)
tmp = (((((D_m * M_m) * M_m) * abs(d)) / ((sqrt((l / h)) * l) * (d * d))) * -0.125) * D_m;
else
tmp = abs(d) / sqrt((l * h));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e-181], N[(N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] * N[Abs[d], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Sqrt[N[(l / h), $MachinePrecision]], $MachinePrecision] * l), $MachinePrecision] * N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * D$95$m), $MachinePrecision], N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -2 \cdot 10^{-181}:\\
\;\;\;\;\left(\frac{\left(\left(D\_m \cdot M\_m\right) \cdot M\_m\right) \cdot \left|d\right|}{\left(\sqrt{\frac{\ell}{h}} \cdot \ell\right) \cdot \left(d \cdot d\right)} \cdot -0.125\right) \cdot D\_m\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|d\right|}{\sqrt{\ell \cdot h}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -2.00000000000000009e-181Initial program 66.9%
Taylor expanded in d around 0
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites26.7%
Taylor expanded in h around inf
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
pow2N/A
*-commutativeN/A
pow2N/A
lower-*.f64N/A
Applied rewrites14.9%
if -2.00000000000000009e-181 < (*.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 66.9%
Taylor expanded in h around 0
lower-/.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6421.1
Applied rewrites21.1%
Taylor expanded in h around inf
sqrt-undivN/A
pow2N/A
rem-sqrt-square-revN/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-fabs.f6442.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.7
Applied rewrites42.7%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<=
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l))))
-2e-214)
(* (* (* D_m D_m) (/ (* (sqrt (/ h l)) (* M_m M_m)) (* l d))) -0.125)
(/ (fabs d) (sqrt (* l h)))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (((pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -2e-214) {
tmp = ((D_m * D_m) * ((sqrt((h / l)) * (M_m * M_m)) / (l * d))) * -0.125;
} else {
tmp = fabs(d) / sqrt((l * h));
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, 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, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: tmp
if (((((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= (-2d-214)) then
tmp = ((d_m * d_m) * ((sqrt((h / l)) * (m_m * m_m)) / (l * d))) * (-0.125d0)
else
tmp = abs(d) / sqrt((l * h))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (((Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -2e-214) {
tmp = ((D_m * D_m) * ((Math.sqrt((h / l)) * (M_m * M_m)) / (l * d))) * -0.125;
} else {
tmp = Math.abs(d) / Math.sqrt((l * h));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if ((math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -2e-214: tmp = ((D_m * D_m) * ((math.sqrt((h / l)) * (M_m * M_m)) / (l * d))) * -0.125 else: tmp = math.fabs(d) / math.sqrt((l * h)) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= -2e-214) tmp = Float64(Float64(Float64(D_m * D_m) * Float64(Float64(sqrt(Float64(h / l)) * Float64(M_m * M_m)) / Float64(l * d))) * -0.125); else tmp = Float64(abs(d) / sqrt(Float64(l * h))); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (((((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= -2e-214)
tmp = ((D_m * D_m) * ((sqrt((h / l)) * (M_m * M_m)) / (l * d))) * -0.125;
else
tmp = abs(d) / sqrt((l * h));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e-214], N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * N[(M$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision], N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -2 \cdot 10^{-214}:\\
\;\;\;\;\left(\left(D\_m \cdot D\_m\right) \cdot \frac{\sqrt{\frac{h}{\ell}} \cdot \left(M\_m \cdot M\_m\right)}{\ell \cdot d}\right) \cdot -0.125\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|d\right|}{\sqrt{\ell \cdot h}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -1.99999999999999983e-214Initial program 66.9%
Taylor expanded in h around 0
Applied rewrites17.3%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites34.2%
if -1.99999999999999983e-214 < (*.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 66.9%
Taylor expanded in h around 0
lower-/.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6421.1
Applied rewrites21.1%
Taylor expanded in h around inf
sqrt-undivN/A
pow2N/A
rem-sqrt-square-revN/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-fabs.f6442.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.7
Applied rewrites42.7%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (/ h l))))
(if (<= h -2e+196)
(/ (* t_0 d) h)
(if (<= h 2.25e+57) (/ (fabs d) (sqrt (* l h))) (/ (fabs d) (* t_0 l))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((h / l));
double tmp;
if (h <= -2e+196) {
tmp = (t_0 * d) / h;
} else if (h <= 2.25e+57) {
tmp = fabs(d) / sqrt((l * h));
} else {
tmp = fabs(d) / (t_0 * l);
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, 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, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((h / l))
if (h <= (-2d+196)) then
tmp = (t_0 * d) / h
else if (h <= 2.25d+57) then
tmp = abs(d) / sqrt((l * h))
else
tmp = abs(d) / (t_0 * l)
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = Math.sqrt((h / l));
double tmp;
if (h <= -2e+196) {
tmp = (t_0 * d) / h;
} else if (h <= 2.25e+57) {
tmp = Math.abs(d) / Math.sqrt((l * h));
} else {
tmp = Math.abs(d) / (t_0 * l);
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = math.sqrt((h / l)) tmp = 0 if h <= -2e+196: tmp = (t_0 * d) / h elif h <= 2.25e+57: tmp = math.fabs(d) / math.sqrt((l * h)) else: tmp = math.fabs(d) / (t_0 * l) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = sqrt(Float64(h / l)) tmp = 0.0 if (h <= -2e+196) tmp = Float64(Float64(t_0 * d) / h); elseif (h <= 2.25e+57) tmp = Float64(abs(d) / sqrt(Float64(l * h))); else tmp = Float64(abs(d) / Float64(t_0 * l)); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = sqrt((h / l));
tmp = 0.0;
if (h <= -2e+196)
tmp = (t_0 * d) / h;
elseif (h <= 2.25e+57)
tmp = abs(d) / sqrt((l * h));
else
tmp = abs(d) / (t_0 * l);
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[h, -2e+196], N[(N[(t$95$0 * d), $MachinePrecision] / h), $MachinePrecision], If[LessEqual[h, 2.25e+57], N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Abs[d], $MachinePrecision] / N[(t$95$0 * l), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{h}{\ell}}\\
\mathbf{if}\;h \leq -2 \cdot 10^{+196}:\\
\;\;\;\;\frac{t\_0 \cdot d}{h}\\
\mathbf{elif}\;h \leq 2.25 \cdot 10^{+57}:\\
\;\;\;\;\frac{\left|d\right|}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|d\right|}{t\_0 \cdot \ell}\\
\end{array}
\end{array}
if h < -1.9999999999999999e196Initial program 66.9%
Taylor expanded in h around 0
lower-/.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6421.1
Applied rewrites21.1%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lift-/.f6437.2
Applied rewrites37.2%
if -1.9999999999999999e196 < h < 2.24999999999999998e57Initial program 66.9%
Taylor expanded in h around 0
lower-/.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6421.1
Applied rewrites21.1%
Taylor expanded in h around inf
sqrt-undivN/A
pow2N/A
rem-sqrt-square-revN/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-fabs.f6442.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.7
Applied rewrites42.7%
if 2.24999999999999998e57 < h Initial program 66.9%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
frac-timesN/A
unpow2N/A
fabs-pow2-revN/A
sqrt-div-sound-leftN/A
fabs-pow2-revN/A
unpow2N/A
rem-sqrt-square-revN/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-*.f6469.8
Applied rewrites69.8%
Taylor expanded in l around inf
rem-sqrt-square-revN/A
pow2N/A
sqrt-undivN/A
pow1/2N/A
metadata-evalN/A
pow2N/A
frac-timesN/A
pow-prod-downN/A
lower-/.f64N/A
lift-fabs.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lift-/.f6423.0
Applied rewrites23.0%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (/ h l))))
(if (<= h -2e+196)
(/ (* t_0 d) h)
(if (<= h 5.4e+69) (/ (fabs d) (sqrt (* l h))) (* t_0 (/ d h))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((h / l));
double tmp;
if (h <= -2e+196) {
tmp = (t_0 * d) / h;
} else if (h <= 5.4e+69) {
tmp = fabs(d) / sqrt((l * h));
} else {
tmp = t_0 * (d / h);
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, 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, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((h / l))
if (h <= (-2d+196)) then
tmp = (t_0 * d) / h
else if (h <= 5.4d+69) then
tmp = abs(d) / sqrt((l * h))
else
tmp = t_0 * (d / h)
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = Math.sqrt((h / l));
double tmp;
if (h <= -2e+196) {
tmp = (t_0 * d) / h;
} else if (h <= 5.4e+69) {
tmp = Math.abs(d) / Math.sqrt((l * h));
} else {
tmp = t_0 * (d / h);
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = math.sqrt((h / l)) tmp = 0 if h <= -2e+196: tmp = (t_0 * d) / h elif h <= 5.4e+69: tmp = math.fabs(d) / math.sqrt((l * h)) else: tmp = t_0 * (d / h) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = sqrt(Float64(h / l)) tmp = 0.0 if (h <= -2e+196) tmp = Float64(Float64(t_0 * d) / h); elseif (h <= 5.4e+69) tmp = Float64(abs(d) / sqrt(Float64(l * h))); else tmp = Float64(t_0 * Float64(d / h)); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = sqrt((h / l));
tmp = 0.0;
if (h <= -2e+196)
tmp = (t_0 * d) / h;
elseif (h <= 5.4e+69)
tmp = abs(d) / sqrt((l * h));
else
tmp = t_0 * (d / h);
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[h, -2e+196], N[(N[(t$95$0 * d), $MachinePrecision] / h), $MachinePrecision], If[LessEqual[h, 5.4e+69], N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(d / h), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{h}{\ell}}\\
\mathbf{if}\;h \leq -2 \cdot 10^{+196}:\\
\;\;\;\;\frac{t\_0 \cdot d}{h}\\
\mathbf{elif}\;h \leq 5.4 \cdot 10^{+69}:\\
\;\;\;\;\frac{\left|d\right|}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{d}{h}\\
\end{array}
\end{array}
if h < -1.9999999999999999e196Initial program 66.9%
Taylor expanded in h around 0
lower-/.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6421.1
Applied rewrites21.1%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lift-/.f6437.2
Applied rewrites37.2%
if -1.9999999999999999e196 < h < 5.3999999999999996e69Initial program 66.9%
Taylor expanded in h around 0
lower-/.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6421.1
Applied rewrites21.1%
Taylor expanded in h around inf
sqrt-undivN/A
pow2N/A
rem-sqrt-square-revN/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-fabs.f6442.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.7
Applied rewrites42.7%
if 5.3999999999999996e69 < h Initial program 66.9%
Taylor expanded in h around 0
lower-/.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6421.1
Applied rewrites21.1%
Taylor expanded in h around inf
sqrt-undivN/A
pow2N/A
rem-sqrt-square-revN/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-fabs.f6442.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.7
Applied rewrites42.7%
Taylor expanded in d around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lift-/.f64N/A
lower-/.f6436.9
Applied rewrites36.9%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (if (<= h 5.4e+69) (/ (fabs d) (sqrt (* l h))) (* (sqrt (/ h l)) (/ d h))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (h <= 5.4e+69) {
tmp = fabs(d) / sqrt((l * h));
} else {
tmp = sqrt((h / l)) * (d / h);
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, 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, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: tmp
if (h <= 5.4d+69) then
tmp = abs(d) / sqrt((l * h))
else
tmp = sqrt((h / l)) * (d / h)
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (h <= 5.4e+69) {
tmp = Math.abs(d) / Math.sqrt((l * h));
} else {
tmp = Math.sqrt((h / l)) * (d / h);
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if h <= 5.4e+69: tmp = math.fabs(d) / math.sqrt((l * h)) else: tmp = math.sqrt((h / l)) * (d / h) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (h <= 5.4e+69) tmp = Float64(abs(d) / sqrt(Float64(l * h))); else tmp = Float64(sqrt(Float64(h / l)) * Float64(d / h)); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (h <= 5.4e+69)
tmp = abs(d) / sqrt((l * h));
else
tmp = sqrt((h / l)) * (d / h);
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[h, 5.4e+69], N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq 5.4 \cdot 10^{+69}:\\
\;\;\;\;\frac{\left|d\right|}{\sqrt{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{h}{\ell}} \cdot \frac{d}{h}\\
\end{array}
\end{array}
if h < 5.3999999999999996e69Initial program 66.9%
Taylor expanded in h around 0
lower-/.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6421.1
Applied rewrites21.1%
Taylor expanded in h around inf
sqrt-undivN/A
pow2N/A
rem-sqrt-square-revN/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-fabs.f6442.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.7
Applied rewrites42.7%
if 5.3999999999999996e69 < h Initial program 66.9%
Taylor expanded in h around 0
lower-/.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6421.1
Applied rewrites21.1%
Taylor expanded in h around inf
sqrt-undivN/A
pow2N/A
rem-sqrt-square-revN/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-fabs.f6442.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.7
Applied rewrites42.7%
Taylor expanded in d around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lift-/.f64N/A
lower-/.f6436.9
Applied rewrites36.9%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (/ (fabs d) (sqrt (* l h)))))
(if (<=
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l))))
-2e-214)
(- t_0)
t_0)))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = fabs(d) / sqrt((l * h));
double tmp;
if (((pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -2e-214) {
tmp = -t_0;
} else {
tmp = t_0;
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, 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, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = abs(d) / sqrt((l * h))
if (((((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= (-2d-214)) then
tmp = -t_0
else
tmp = t_0
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = Math.abs(d) / Math.sqrt((l * h));
double tmp;
if (((Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -2e-214) {
tmp = -t_0;
} else {
tmp = t_0;
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = math.fabs(d) / math.sqrt((l * h)) tmp = 0 if ((math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -2e-214: tmp = -t_0 else: tmp = t_0 return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(abs(d) / sqrt(Float64(l * h))) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= -2e-214) tmp = Float64(-t_0); else tmp = t_0; end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = abs(d) / sqrt((l * h));
tmp = 0.0;
if (((((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= -2e-214)
tmp = -t_0;
else
tmp = t_0;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e-214], (-t$95$0), t$95$0]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\left|d\right|}{\sqrt{\ell \cdot h}}\\
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -2 \cdot 10^{-214}:\\
\;\;\;\;-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)))) < -1.99999999999999983e-214Initial program 66.9%
Taylor expanded in h around 0
lower-/.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6421.1
Applied rewrites21.1%
Taylor expanded in h around -inf
mul-1-negN/A
sqrt-undivN/A
pow2N/A
rem-sqrt-square-revN/A
lower-neg.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-fabs.f6410.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6410.1
Applied rewrites10.1%
if -1.99999999999999983e-214 < (*.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 66.9%
Taylor expanded in h around 0
lower-/.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6421.1
Applied rewrites21.1%
Taylor expanded in h around inf
sqrt-undivN/A
pow2N/A
rem-sqrt-square-revN/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-fabs.f6442.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.7
Applied rewrites42.7%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (/ (fabs d) (sqrt (* l h))))
M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
return fabs(d) / sqrt((l * h));
}
M_m = private
D_m = private
NOTE: d, 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, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
code = abs(d) / sqrt((l * h))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
return Math.abs(d) / Math.sqrt((l * h));
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): return math.fabs(d) / math.sqrt((l * h))
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) return Float64(abs(d) / sqrt(Float64(l * h))) end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
tmp = abs(d) / sqrt((l * h));
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\frac{\left|d\right|}{\sqrt{\ell \cdot h}}
\end{array}
Initial program 66.9%
Taylor expanded in h around 0
lower-/.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6421.1
Applied rewrites21.1%
Taylor expanded in h around inf
sqrt-undivN/A
pow2N/A
rem-sqrt-square-revN/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-fabs.f6442.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.7
Applied rewrites42.7%
herbie shell --seed 2025135
(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)))))