
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.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(w0, m, d, h, l, d_1)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
code = w0 * sqrt((1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.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(w0, m, d, h, l, d_1)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
code = w0 * sqrt((1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\end{array}
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(if (or (<= (* M_m D_m) 2e-171) (not (<= (* M_m D_m) 5e+180)))
(*
w0
(sqrt (- 1.0 (* (* D_m (/ (* h M_m) (* 4.0 d))) (/ (* D_m (/ M_m d)) l)))))
(*
w0
(sqrt
(- 1.0 (* (/ (* (* M_m D_m) (/ h (* 4.0 d))) (* l d)) (* M_m D_m)))))))D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (((M_m * D_m) <= 2e-171) || !((M_m * D_m) <= 5e+180)) {
tmp = w0 * sqrt((1.0 - ((D_m * ((h * M_m) / (4.0 * d))) * ((D_m * (M_m / d)) / l))));
} else {
tmp = w0 * sqrt((1.0 - ((((M_m * D_m) * (h / (4.0 * d))) / (l * d)) * (M_m * D_m))));
}
return tmp;
}
D_m = private
M_m = private
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(w0, m_m, d_m, h, l, d)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
real(8) :: tmp
if (((m_m * d_m) <= 2d-171) .or. (.not. ((m_m * d_m) <= 5d+180))) then
tmp = w0 * sqrt((1.0d0 - ((d_m * ((h * m_m) / (4.0d0 * d))) * ((d_m * (m_m / d)) / l))))
else
tmp = w0 * sqrt((1.0d0 - ((((m_m * d_m) * (h / (4.0d0 * d))) / (l * d)) * (m_m * d_m))))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (((M_m * D_m) <= 2e-171) || !((M_m * D_m) <= 5e+180)) {
tmp = w0 * Math.sqrt((1.0 - ((D_m * ((h * M_m) / (4.0 * d))) * ((D_m * (M_m / d)) / l))));
} else {
tmp = w0 * Math.sqrt((1.0 - ((((M_m * D_m) * (h / (4.0 * d))) / (l * d)) * (M_m * D_m))));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): tmp = 0 if ((M_m * D_m) <= 2e-171) or not ((M_m * D_m) <= 5e+180): tmp = w0 * math.sqrt((1.0 - ((D_m * ((h * M_m) / (4.0 * d))) * ((D_m * (M_m / d)) / l)))) else: tmp = w0 * math.sqrt((1.0 - ((((M_m * D_m) * (h / (4.0 * d))) / (l * d)) * (M_m * D_m)))) return tmp
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if ((Float64(M_m * D_m) <= 2e-171) || !(Float64(M_m * D_m) <= 5e+180)) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(D_m * Float64(Float64(h * M_m) / Float64(4.0 * d))) * Float64(Float64(D_m * Float64(M_m / d)) / l))))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(M_m * D_m) * Float64(h / Float64(4.0 * d))) / Float64(l * d)) * Float64(M_m * D_m))))); end return tmp end
D_m = abs(D);
M_m = abs(M);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
tmp = 0.0;
if (((M_m * D_m) <= 2e-171) || ~(((M_m * D_m) <= 5e+180)))
tmp = w0 * sqrt((1.0 - ((D_m * ((h * M_m) / (4.0 * d))) * ((D_m * (M_m / d)) / l))));
else
tmp = w0 * sqrt((1.0 - ((((M_m * D_m) * (h / (4.0 * d))) / (l * d)) * (M_m * D_m))));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[Or[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 2e-171], N[Not[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 5e+180]], $MachinePrecision]], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(D$95$m * N[(N[(h * M$95$m), $MachinePrecision] / N[(4.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(h / N[(4.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \cdot D\_m \leq 2 \cdot 10^{-171} \lor \neg \left(M\_m \cdot D\_m \leq 5 \cdot 10^{+180}\right):\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(D\_m \cdot \frac{h \cdot M\_m}{4 \cdot d}\right) \cdot \frac{D\_m \cdot \frac{M\_m}{d}}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(M\_m \cdot D\_m\right) \cdot \frac{h}{4 \cdot d}}{\ell \cdot d} \cdot \left(M\_m \cdot D\_m\right)}\\
\end{array}
\end{array}
if (*.f64 M D) < 2e-171 or 4.9999999999999996e180 < (*.f64 M D) Initial program 82.3%
Applied rewrites82.4%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6484.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6484.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6484.5
Applied rewrites84.5%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
Applied rewrites91.2%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
metadata-eval86.7
Applied rewrites86.7%
if 2e-171 < (*.f64 M D) < 4.9999999999999996e180Initial program 83.7%
Applied rewrites87.7%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6491.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6491.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6491.4
Applied rewrites91.4%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
Applied rewrites86.5%
Applied rewrites92.7%
Final simplification88.6%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(let* ((t_0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l))))
(if (<= t_0 -1e+304)
(fma (* w0 (* M_m (* (* h M_m) (* (/ D_m d) (/ (/ D_m l) d))))) -0.125 w0)
(if (<= t_0 -5e+49)
(*
w0
(sqrt (* (* (* (* (/ h (* d d)) M_m) (/ M_m l)) (* -0.25 D_m)) D_m)))
(* w0 1.0)))))D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double t_0 = pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l);
double tmp;
if (t_0 <= -1e+304) {
tmp = fma((w0 * (M_m * ((h * M_m) * ((D_m / d) * ((D_m / l) / d))))), -0.125, w0);
} else if (t_0 <= -5e+49) {
tmp = w0 * sqrt((((((h / (d * d)) * M_m) * (M_m / l)) * (-0.25 * D_m)) * D_m));
} else {
tmp = w0 * 1.0;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) t_0 = Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) tmp = 0.0 if (t_0 <= -1e+304) tmp = fma(Float64(w0 * Float64(M_m * Float64(Float64(h * M_m) * Float64(Float64(D_m / d) * Float64(Float64(D_m / l) / d))))), -0.125, w0); elseif (t_0 <= -5e+49) tmp = Float64(w0 * sqrt(Float64(Float64(Float64(Float64(Float64(h / Float64(d * d)) * M_m) * Float64(M_m / l)) * Float64(-0.25 * D_m)) * D_m))); else tmp = Float64(w0 * 1.0); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := Block[{t$95$0 = N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+304], N[(N[(w0 * N[(M$95$m * N[(N[(h * M$95$m), $MachinePrecision] * N[(N[(D$95$m / d), $MachinePrecision] * N[(N[(D$95$m / l), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125 + w0), $MachinePrecision], If[LessEqual[t$95$0, -5e+49], N[(w0 * N[Sqrt[N[(N[(N[(N[(N[(h / N[(d * d), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(M$95$m / l), $MachinePrecision]), $MachinePrecision] * N[(-0.25 * D$95$m), $MachinePrecision]), $MachinePrecision] * D$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+304}:\\
\;\;\;\;\mathsf{fma}\left(w0 \cdot \left(M\_m \cdot \left(\left(h \cdot M\_m\right) \cdot \left(\frac{D\_m}{d} \cdot \frac{\frac{D\_m}{\ell}}{d}\right)\right)\right), -0.125, w0\right)\\
\mathbf{elif}\;t\_0 \leq -5 \cdot 10^{+49}:\\
\;\;\;\;w0 \cdot \sqrt{\left(\left(\left(\frac{h}{d \cdot d} \cdot M\_m\right) \cdot \frac{M\_m}{\ell}\right) \cdot \left(-0.25 \cdot D\_m\right)\right) \cdot D\_m}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot 1\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -9.9999999999999994e303Initial program 67.1%
Applied rewrites66.7%
Taylor expanded in M around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6445.2
Applied rewrites45.2%
Applied rewrites51.3%
Applied rewrites63.4%
if -9.9999999999999994e303 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -5.0000000000000004e49Initial program 99.5%
Taylor expanded in M around inf
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6433.7
Applied rewrites33.7%
Applied rewrites41.8%
if -5.0000000000000004e49 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 85.7%
Taylor expanded in M around 0
Applied rewrites92.3%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(let* ((t_0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l))))
(if (<= t_0 -2e+280)
(fma (* w0 (* M_m (* (* h M_m) (* (/ D_m d) (/ (/ D_m l) d))))) -0.125 w0)
(if (<= t_0 -20.0)
(*
w0
(sqrt
(fma (* h -0.25) (/ (* (* (* M_m M_m) D_m) D_m) (* (* d d) l)) 1.0)))
(* w0 1.0)))))D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double t_0 = pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l);
double tmp;
if (t_0 <= -2e+280) {
tmp = fma((w0 * (M_m * ((h * M_m) * ((D_m / d) * ((D_m / l) / d))))), -0.125, w0);
} else if (t_0 <= -20.0) {
tmp = w0 * sqrt(fma((h * -0.25), ((((M_m * M_m) * D_m) * D_m) / ((d * d) * l)), 1.0));
} else {
tmp = w0 * 1.0;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) t_0 = Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) tmp = 0.0 if (t_0 <= -2e+280) tmp = fma(Float64(w0 * Float64(M_m * Float64(Float64(h * M_m) * Float64(Float64(D_m / d) * Float64(Float64(D_m / l) / d))))), -0.125, w0); elseif (t_0 <= -20.0) tmp = Float64(w0 * sqrt(fma(Float64(h * -0.25), Float64(Float64(Float64(Float64(M_m * M_m) * D_m) * D_m) / Float64(Float64(d * d) * l)), 1.0))); else tmp = Float64(w0 * 1.0); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := Block[{t$95$0 = N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+280], N[(N[(w0 * N[(M$95$m * N[(N[(h * M$95$m), $MachinePrecision] * N[(N[(D$95$m / d), $MachinePrecision] * N[(N[(D$95$m / l), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125 + w0), $MachinePrecision], If[LessEqual[t$95$0, -20.0], N[(w0 * N[Sqrt[N[(N[(h * -0.25), $MachinePrecision] * N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+280}:\\
\;\;\;\;\mathsf{fma}\left(w0 \cdot \left(M\_m \cdot \left(\left(h \cdot M\_m\right) \cdot \left(\frac{D\_m}{d} \cdot \frac{\frac{D\_m}{\ell}}{d}\right)\right)\right), -0.125, w0\right)\\
\mathbf{elif}\;t\_0 \leq -20:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(h \cdot -0.25, \frac{\left(\left(M\_m \cdot M\_m\right) \cdot D\_m\right) \cdot D\_m}{\left(d \cdot d\right) \cdot \ell}, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot 1\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -2.0000000000000001e280Initial program 68.3%
Applied rewrites64.3%
Taylor expanded in M around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6443.5
Applied rewrites43.5%
Applied rewrites49.4%
Applied rewrites61.1%
if -2.0000000000000001e280 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -20Initial program 99.4%
Taylor expanded in h around inf
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
rgt-mult-inverseN/A
lower-fma.f64N/A
Applied rewrites23.1%
if -20 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 85.5%
Taylor expanded in M around 0
Applied rewrites93.5%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(let* ((t_0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l))))
(if (<= t_0 -2e+280)
(*
w0
(sqrt
(- 1.0 (/ (* (* (* D_m M_m) h) (* (- D_m) M_m)) (* (* -2.0 d) l)))))
(if (<= t_0 -20.0)
(*
w0
(sqrt
(fma (* h -0.25) (/ (* (* (* M_m M_m) D_m) D_m) (* (* d d) l)) 1.0)))
(* w0 1.0)))))D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double t_0 = pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l);
double tmp;
if (t_0 <= -2e+280) {
tmp = w0 * sqrt((1.0 - ((((D_m * M_m) * h) * (-D_m * M_m)) / ((-2.0 * d) * l))));
} else if (t_0 <= -20.0) {
tmp = w0 * sqrt(fma((h * -0.25), ((((M_m * M_m) * D_m) * D_m) / ((d * d) * l)), 1.0));
} else {
tmp = w0 * 1.0;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) t_0 = Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) tmp = 0.0 if (t_0 <= -2e+280) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(D_m * M_m) * h) * Float64(Float64(-D_m) * M_m)) / Float64(Float64(-2.0 * d) * l))))); elseif (t_0 <= -20.0) tmp = Float64(w0 * sqrt(fma(Float64(h * -0.25), Float64(Float64(Float64(Float64(M_m * M_m) * D_m) * D_m) / Float64(Float64(d * d) * l)), 1.0))); else tmp = Float64(w0 * 1.0); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := Block[{t$95$0 = N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+280], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] * N[((-D$95$m) * M$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(-2.0 * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -20.0], N[(w0 * N[Sqrt[N[(N[(h * -0.25), $MachinePrecision] * N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+280}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(\left(D\_m \cdot M\_m\right) \cdot h\right) \cdot \left(\left(-D\_m\right) \cdot M\_m\right)}{\left(-2 \cdot d\right) \cdot \ell}}\\
\mathbf{elif}\;t\_0 \leq -20:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(h \cdot -0.25, \frac{\left(\left(M\_m \cdot M\_m\right) \cdot D\_m\right) \cdot D\_m}{\left(d \cdot d\right) \cdot \ell}, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot 1\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -2.0000000000000001e280Initial program 68.3%
Applied rewrites19.3%
Taylor expanded in M around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6413.9
Applied rewrites13.9%
Applied rewrites19.4%
if -2.0000000000000001e280 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -20Initial program 99.4%
Taylor expanded in h around inf
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
rgt-mult-inverseN/A
lower-fma.f64N/A
Applied rewrites23.1%
if -20 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 85.5%
Taylor expanded in M around 0
Applied rewrites93.5%
Final simplification73.5%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(let* ((t_0
(*
w0
(sqrt (- 1.0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)))))))
(if (<= t_0 4e+145)
t_0
(*
w0
(sqrt
(-
1.0
(*
(/ (/ (* (* D_m M_m) h) -2.0) (* d -2.0))
(/ (* D_m (/ M_m d)) l))))))))D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double t_0 = w0 * sqrt((1.0 - (pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l))));
double tmp;
if (t_0 <= 4e+145) {
tmp = t_0;
} else {
tmp = w0 * sqrt((1.0 - (((((D_m * M_m) * h) / -2.0) / (d * -2.0)) * ((D_m * (M_m / d)) / l))));
}
return tmp;
}
D_m = private
M_m = private
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(w0, m_m, d_m, h, l, d)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = w0 * sqrt((1.0d0 - ((((m_m * d_m) / (2.0d0 * d)) ** 2.0d0) * (h / l))))
if (t_0 <= 4d+145) then
tmp = t_0
else
tmp = w0 * sqrt((1.0d0 - (((((d_m * m_m) * h) / (-2.0d0)) / (d * (-2.0d0))) * ((d_m * (m_m / d)) / l))))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
double t_0 = w0 * Math.sqrt((1.0 - (Math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l))));
double tmp;
if (t_0 <= 4e+145) {
tmp = t_0;
} else {
tmp = w0 * Math.sqrt((1.0 - (((((D_m * M_m) * h) / -2.0) / (d * -2.0)) * ((D_m * (M_m / d)) / l))));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): t_0 = w0 * math.sqrt((1.0 - (math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)))) tmp = 0 if t_0 <= 4e+145: tmp = t_0 else: tmp = w0 * math.sqrt((1.0 - (((((D_m * M_m) * h) / -2.0) / (d * -2.0)) * ((D_m * (M_m / d)) / l)))) return tmp
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) t_0 = Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))))) tmp = 0.0 if (t_0 <= 4e+145) tmp = t_0; else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(Float64(D_m * M_m) * h) / -2.0) / Float64(d * -2.0)) * Float64(Float64(D_m * Float64(M_m / d)) / l))))); end return tmp end
D_m = abs(D);
M_m = abs(M);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
t_0 = w0 * sqrt((1.0 - ((((M_m * D_m) / (2.0 * d)) ^ 2.0) * (h / l))));
tmp = 0.0;
if (t_0 <= 4e+145)
tmp = t_0;
else
tmp = w0 * sqrt((1.0 - (((((D_m * M_m) * h) / -2.0) / (d * -2.0)) * ((D_m * (M_m / d)) / l))));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := Block[{t$95$0 = N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 4e+145], t$95$0, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] / -2.0), $MachinePrecision] / N[(d * -2.0), $MachinePrecision]), $MachinePrecision] * N[(N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
t_0 := w0 \cdot \sqrt{1 - {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\\
\mathbf{if}\;t\_0 \leq 4 \cdot 10^{+145}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{\left(D\_m \cdot M\_m\right) \cdot h}{-2}}{d \cdot -2} \cdot \frac{D\_m \cdot \frac{M\_m}{d}}{\ell}}\\
\end{array}
\end{array}
if (*.f64 w0 (sqrt.f64 (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))))) < 4e145Initial program 94.0%
if 4e145 < (*.f64 w0 (sqrt.f64 (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))))) Initial program 50.4%
Applied rewrites82.4%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6485.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6485.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6485.3
Applied rewrites85.3%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
Applied rewrites82.3%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(if (<= (sqrt (- 1.0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)))) 1.0)
(* w0 1.0)
(*
w0
(sqrt
(-
1.0
(/
(* (* D_m M_m) (/ (* (* D_m M_m) h) (* d -2.0)))
(* (* -2.0 d) l)))))))D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (sqrt((1.0 - (pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)))) <= 1.0) {
tmp = w0 * 1.0;
} else {
tmp = w0 * sqrt((1.0 - (((D_m * M_m) * (((D_m * M_m) * h) / (d * -2.0))) / ((-2.0 * d) * l))));
}
return tmp;
}
D_m = private
M_m = private
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(w0, m_m, d_m, h, l, d)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
real(8) :: tmp
if (sqrt((1.0d0 - ((((m_m * d_m) / (2.0d0 * d)) ** 2.0d0) * (h / l)))) <= 1.0d0) then
tmp = w0 * 1.0d0
else
tmp = w0 * sqrt((1.0d0 - (((d_m * m_m) * (((d_m * m_m) * h) / (d * (-2.0d0)))) / (((-2.0d0) * d) * l))))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (Math.sqrt((1.0 - (Math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)))) <= 1.0) {
tmp = w0 * 1.0;
} else {
tmp = w0 * Math.sqrt((1.0 - (((D_m * M_m) * (((D_m * M_m) * h) / (d * -2.0))) / ((-2.0 * d) * l))));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): tmp = 0 if math.sqrt((1.0 - (math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)))) <= 1.0: tmp = w0 * 1.0 else: tmp = w0 * math.sqrt((1.0 - (((D_m * M_m) * (((D_m * M_m) * h) / (d * -2.0))) / ((-2.0 * d) * l)))) return tmp
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (sqrt(Float64(1.0 - Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)))) <= 1.0) tmp = Float64(w0 * 1.0); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(D_m * M_m) * Float64(Float64(Float64(D_m * M_m) * h) / Float64(d * -2.0))) / Float64(Float64(-2.0 * d) * l))))); end return tmp end
D_m = abs(D);
M_m = abs(M);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
tmp = 0.0;
if (sqrt((1.0 - ((((M_m * D_m) / (2.0 * d)) ^ 2.0) * (h / l)))) <= 1.0)
tmp = w0 * 1.0;
else
tmp = w0 * sqrt((1.0 - (((D_m * M_m) * (((D_m * M_m) * h) / (d * -2.0))) / ((-2.0 * d) * l))));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0], N[(w0 * 1.0), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] / N[(d * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(-2.0 * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;\sqrt{1 - {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq 1:\\
\;\;\;\;w0 \cdot 1\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(D\_m \cdot M\_m\right) \cdot \frac{\left(D\_m \cdot M\_m\right) \cdot h}{d \cdot -2}}{\left(-2 \cdot d\right) \cdot \ell}}\\
\end{array}
\end{array}
if (sqrt.f64 (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)))) < 1Initial program 100.0%
Taylor expanded in M around 0
Applied rewrites100.0%
if 1 < (sqrt.f64 (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)))) Initial program 56.2%
Applied rewrites70.4%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6474.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6474.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6474.9
Applied rewrites74.9%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6474.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6474.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6474.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6474.9
Applied rewrites74.9%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d) :precision binary64 (if (<= (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)) -5e+49) (* w0 (sqrt (* (* -0.25 (* D_m D_m)) (/ (* (* (/ h (* d d)) M_m) M_m) l)))) (* w0 1.0)))
D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if ((pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -5e+49) {
tmp = w0 * sqrt(((-0.25 * (D_m * D_m)) * ((((h / (d * d)) * M_m) * M_m) / l)));
} else {
tmp = w0 * 1.0;
}
return tmp;
}
D_m = private
M_m = private
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(w0, m_m, d_m, h, l, d)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
real(8) :: tmp
if (((((m_m * d_m) / (2.0d0 * d)) ** 2.0d0) * (h / l)) <= (-5d+49)) then
tmp = w0 * sqrt((((-0.25d0) * (d_m * d_m)) * ((((h / (d * d)) * m_m) * m_m) / l)))
else
tmp = w0 * 1.0d0
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if ((Math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -5e+49) {
tmp = w0 * Math.sqrt(((-0.25 * (D_m * D_m)) * ((((h / (d * d)) * M_m) * M_m) / l)));
} else {
tmp = w0 * 1.0;
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): tmp = 0 if (math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -5e+49: tmp = w0 * math.sqrt(((-0.25 * (D_m * D_m)) * ((((h / (d * d)) * M_m) * M_m) / l))) else: tmp = w0 * 1.0 return tmp
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -5e+49) tmp = Float64(w0 * sqrt(Float64(Float64(-0.25 * Float64(D_m * D_m)) * Float64(Float64(Float64(Float64(h / Float64(d * d)) * M_m) * M_m) / l)))); else tmp = Float64(w0 * 1.0); end return tmp end
D_m = abs(D);
M_m = abs(M);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
tmp = 0.0;
if (((((M_m * D_m) / (2.0 * d)) ^ 2.0) * (h / l)) <= -5e+49)
tmp = w0 * sqrt(((-0.25 * (D_m * D_m)) * ((((h / (d * d)) * M_m) * M_m) / l)));
else
tmp = w0 * 1.0;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -5e+49], N[(w0 * N[Sqrt[N[(N[(-0.25 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(h / N[(d * d), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -5 \cdot 10^{+49}:\\
\;\;\;\;w0 \cdot \sqrt{\left(-0.25 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot \frac{\left(\frac{h}{d \cdot d} \cdot M\_m\right) \cdot M\_m}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot 1\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -5.0000000000000004e49Initial program 74.4%
Taylor expanded in M around inf
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6442.8
Applied rewrites42.8%
Applied rewrites51.9%
if -5.0000000000000004e49 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 85.7%
Taylor expanded in M around 0
Applied rewrites92.3%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d) :precision binary64 (if (<= (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)) (- INFINITY)) (* w0 (fma -0.25 (* (/ (* D_m D_m) d) (/ (* (* M_m M_m) h) l)) 1.0)) (* w0 1.0)))
D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if ((pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -((double) INFINITY)) {
tmp = w0 * fma(-0.25, (((D_m * D_m) / d) * (((M_m * M_m) * h) / l)), 1.0);
} else {
tmp = w0 * 1.0;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= Float64(-Inf)) tmp = Float64(w0 * fma(-0.25, Float64(Float64(Float64(D_m * D_m) / d) * Float64(Float64(Float64(M_m * M_m) * h) / l)), 1.0)); else tmp = Float64(w0 * 1.0); end return tmp end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], (-Infinity)], N[(w0 * N[(-0.25 * N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision] * N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -\infty:\\
\;\;\;\;w0 \cdot \mathsf{fma}\left(-0.25, \frac{D\_m \cdot D\_m}{d} \cdot \frac{\left(M\_m \cdot M\_m\right) \cdot h}{\ell}, 1\right)\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot 1\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -inf.0Initial program 66.5%
Applied rewrites18.4%
Taylor expanded in M around 0
+-commutativeN/A
lower-fma.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6418.8
Applied rewrites18.8%
if -inf.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 86.8%
Taylor expanded in M around 0
Applied rewrites85.6%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d) :precision binary64 (if (<= (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)) -1e+304) (* (/ (* M_m (* (* h M_m) (* (* D_m D_m) w0))) (* (* d d) l)) -0.125) (* w0 1.0)))
D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if ((pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -1e+304) {
tmp = ((M_m * ((h * M_m) * ((D_m * D_m) * w0))) / ((d * d) * l)) * -0.125;
} else {
tmp = w0 * 1.0;
}
return tmp;
}
D_m = private
M_m = private
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(w0, m_m, d_m, h, l, d)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
real(8) :: tmp
if (((((m_m * d_m) / (2.0d0 * d)) ** 2.0d0) * (h / l)) <= (-1d+304)) then
tmp = ((m_m * ((h * m_m) * ((d_m * d_m) * w0))) / ((d * d) * l)) * (-0.125d0)
else
tmp = w0 * 1.0d0
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if ((Math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -1e+304) {
tmp = ((M_m * ((h * M_m) * ((D_m * D_m) * w0))) / ((d * d) * l)) * -0.125;
} else {
tmp = w0 * 1.0;
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): tmp = 0 if (math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -1e+304: tmp = ((M_m * ((h * M_m) * ((D_m * D_m) * w0))) / ((d * d) * l)) * -0.125 else: tmp = w0 * 1.0 return tmp
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -1e+304) tmp = Float64(Float64(Float64(M_m * Float64(Float64(h * M_m) * Float64(Float64(D_m * D_m) * w0))) / Float64(Float64(d * d) * l)) * -0.125); else tmp = Float64(w0 * 1.0); end return tmp end
D_m = abs(D);
M_m = abs(M);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
tmp = 0.0;
if (((((M_m * D_m) / (2.0 * d)) ^ 2.0) * (h / l)) <= -1e+304)
tmp = ((M_m * ((h * M_m) * ((D_m * D_m) * w0))) / ((d * d) * l)) * -0.125;
else
tmp = w0 * 1.0;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -1e+304], N[(N[(N[(M$95$m * N[(N[(h * M$95$m), $MachinePrecision] * N[(N[(D$95$m * D$95$m), $MachinePrecision] * w0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -1 \cdot 10^{+304}:\\
\;\;\;\;\frac{M\_m \cdot \left(\left(h \cdot M\_m\right) \cdot \left(\left(D\_m \cdot D\_m\right) \cdot w0\right)\right)}{\left(d \cdot d\right) \cdot \ell} \cdot -0.125\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot 1\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -9.9999999999999994e303Initial program 67.1%
Applied rewrites66.7%
Taylor expanded in M around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6445.2
Applied rewrites45.2%
Taylor expanded in M around inf
Applied rewrites45.0%
Applied rewrites51.3%
if -9.9999999999999994e303 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 86.7%
Taylor expanded in M around 0
Applied rewrites86.0%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(if (<= (* M_m D_m) 2e-171)
(* w0 1.0)
(if (<= (* M_m D_m) 5e+278)
(*
w0
(sqrt
(- 1.0 (* (/ (* (* M_m D_m) (/ h (* 4.0 d))) (* l d)) (* M_m D_m)))))
(*
w0
(sqrt
(fma (* (/ (* -0.5 (* (* M_m M_m) h)) d) (/ D_m l)) (/ D_m d) 1.0))))))D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if ((M_m * D_m) <= 2e-171) {
tmp = w0 * 1.0;
} else if ((M_m * D_m) <= 5e+278) {
tmp = w0 * sqrt((1.0 - ((((M_m * D_m) * (h / (4.0 * d))) / (l * d)) * (M_m * D_m))));
} else {
tmp = w0 * sqrt(fma((((-0.5 * ((M_m * M_m) * h)) / d) * (D_m / l)), (D_m / d), 1.0));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (Float64(M_m * D_m) <= 2e-171) tmp = Float64(w0 * 1.0); elseif (Float64(M_m * D_m) <= 5e+278) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(M_m * D_m) * Float64(h / Float64(4.0 * d))) / Float64(l * d)) * Float64(M_m * D_m))))); else tmp = Float64(w0 * sqrt(fma(Float64(Float64(Float64(-0.5 * Float64(Float64(M_m * M_m) * h)) / d) * Float64(D_m / l)), Float64(D_m / d), 1.0))); end return tmp end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 2e-171], N[(w0 * 1.0), $MachinePrecision], If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 5e+278], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(h / N[(4.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(N[(N[(N[(-0.5 * N[(N[(M$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * N[(D$95$m / l), $MachinePrecision]), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \cdot D\_m \leq 2 \cdot 10^{-171}:\\
\;\;\;\;w0 \cdot 1\\
\mathbf{elif}\;M\_m \cdot D\_m \leq 5 \cdot 10^{+278}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(M\_m \cdot D\_m\right) \cdot \frac{h}{4 \cdot d}}{\ell \cdot d} \cdot \left(M\_m \cdot D\_m\right)}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-0.5 \cdot \left(\left(M\_m \cdot M\_m\right) \cdot h\right)}{d} \cdot \frac{D\_m}{\ell}, \frac{D\_m}{d}, 1\right)}\\
\end{array}
\end{array}
if (*.f64 M D) < 2e-171Initial program 83.4%
Taylor expanded in M around 0
Applied rewrites76.1%
if 2e-171 < (*.f64 M D) < 5.00000000000000029e278Initial program 82.1%
Applied rewrites83.5%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6488.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6488.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6488.2
Applied rewrites88.2%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
Applied rewrites84.8%
Applied rewrites90.8%
if 5.00000000000000029e278 < (*.f64 M D) Initial program 79.3%
Applied rewrites79.3%
Taylor expanded in M around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6465.0
Applied rewrites65.0%
Applied rewrites79.3%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(let* ((t_0 (/ (* D_m (/ M_m d)) l)))
(if (<= d 3e+83)
(* w0 (sqrt (- 1.0 (* (/ (/ (* (* D_m M_m) h) -2.0) (* d -2.0)) t_0))))
(* w0 (sqrt (- 1.0 (* (* D_m (/ (* h M_m) (* 4.0 d))) t_0)))))))D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double t_0 = (D_m * (M_m / d)) / l;
double tmp;
if (d <= 3e+83) {
tmp = w0 * sqrt((1.0 - (((((D_m * M_m) * h) / -2.0) / (d * -2.0)) * t_0)));
} else {
tmp = w0 * sqrt((1.0 - ((D_m * ((h * M_m) / (4.0 * d))) * t_0)));
}
return tmp;
}
D_m = private
M_m = private
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(w0, m_m, d_m, h, l, d)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (d_m * (m_m / d)) / l
if (d <= 3d+83) then
tmp = w0 * sqrt((1.0d0 - (((((d_m * m_m) * h) / (-2.0d0)) / (d * (-2.0d0))) * t_0)))
else
tmp = w0 * sqrt((1.0d0 - ((d_m * ((h * m_m) / (4.0d0 * d))) * t_0)))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
double t_0 = (D_m * (M_m / d)) / l;
double tmp;
if (d <= 3e+83) {
tmp = w0 * Math.sqrt((1.0 - (((((D_m * M_m) * h) / -2.0) / (d * -2.0)) * t_0)));
} else {
tmp = w0 * Math.sqrt((1.0 - ((D_m * ((h * M_m) / (4.0 * d))) * t_0)));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): t_0 = (D_m * (M_m / d)) / l tmp = 0 if d <= 3e+83: tmp = w0 * math.sqrt((1.0 - (((((D_m * M_m) * h) / -2.0) / (d * -2.0)) * t_0))) else: tmp = w0 * math.sqrt((1.0 - ((D_m * ((h * M_m) / (4.0 * d))) * t_0))) return tmp
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) t_0 = Float64(Float64(D_m * Float64(M_m / d)) / l) tmp = 0.0 if (d <= 3e+83) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(Float64(D_m * M_m) * h) / -2.0) / Float64(d * -2.0)) * t_0)))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(D_m * Float64(Float64(h * M_m) / Float64(4.0 * d))) * t_0)))); end return tmp end
D_m = abs(D);
M_m = abs(M);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
t_0 = (D_m * (M_m / d)) / l;
tmp = 0.0;
if (d <= 3e+83)
tmp = w0 * sqrt((1.0 - (((((D_m * M_m) * h) / -2.0) / (d * -2.0)) * t_0)));
else
tmp = w0 * sqrt((1.0 - ((D_m * ((h * M_m) / (4.0 * d))) * t_0)));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := Block[{t$95$0 = N[(N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]}, If[LessEqual[d, 3e+83], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] / -2.0), $MachinePrecision] / N[(d * -2.0), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(D$95$m * N[(N[(h * M$95$m), $MachinePrecision] / N[(4.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
t_0 := \frac{D\_m \cdot \frac{M\_m}{d}}{\ell}\\
\mathbf{if}\;d \leq 3 \cdot 10^{+83}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{\left(D\_m \cdot M\_m\right) \cdot h}{-2}}{d \cdot -2} \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(D\_m \cdot \frac{h \cdot M\_m}{4 \cdot d}\right) \cdot t\_0}\\
\end{array}
\end{array}
if d < 3e83Initial program 83.2%
Applied rewrites85.3%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6487.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6487.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6487.9
Applied rewrites87.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
Applied rewrites90.8%
if 3e83 < d Initial program 80.4%
Applied rewrites78.2%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6480.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6480.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6480.3
Applied rewrites80.3%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
Applied rewrites85.1%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
metadata-eval85.0
Applied rewrites85.0%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(if (<= (* M_m D_m) 2e-171)
(* w0 1.0)
(if (<= (* M_m D_m) 5e+278)
(*
w0
(sqrt
(- 1.0 (* (/ (* (* M_m D_m) (/ h (* 4.0 d))) (* l d)) (* M_m D_m)))))
(fma
(* w0 (* M_m (* (* h M_m) (* (/ D_m d) (/ (/ D_m l) d)))))
-0.125
w0))))D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if ((M_m * D_m) <= 2e-171) {
tmp = w0 * 1.0;
} else if ((M_m * D_m) <= 5e+278) {
tmp = w0 * sqrt((1.0 - ((((M_m * D_m) * (h / (4.0 * d))) / (l * d)) * (M_m * D_m))));
} else {
tmp = fma((w0 * (M_m * ((h * M_m) * ((D_m / d) * ((D_m / l) / d))))), -0.125, w0);
}
return tmp;
}
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (Float64(M_m * D_m) <= 2e-171) tmp = Float64(w0 * 1.0); elseif (Float64(M_m * D_m) <= 5e+278) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(M_m * D_m) * Float64(h / Float64(4.0 * d))) / Float64(l * d)) * Float64(M_m * D_m))))); else tmp = fma(Float64(w0 * Float64(M_m * Float64(Float64(h * M_m) * Float64(Float64(D_m / d) * Float64(Float64(D_m / l) / d))))), -0.125, w0); end return tmp end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 2e-171], N[(w0 * 1.0), $MachinePrecision], If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 5e+278], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(h / N[(4.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(w0 * N[(M$95$m * N[(N[(h * M$95$m), $MachinePrecision] * N[(N[(D$95$m / d), $MachinePrecision] * N[(N[(D$95$m / l), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125 + w0), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \cdot D\_m \leq 2 \cdot 10^{-171}:\\
\;\;\;\;w0 \cdot 1\\
\mathbf{elif}\;M\_m \cdot D\_m \leq 5 \cdot 10^{+278}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(M\_m \cdot D\_m\right) \cdot \frac{h}{4 \cdot d}}{\ell \cdot d} \cdot \left(M\_m \cdot D\_m\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(w0 \cdot \left(M\_m \cdot \left(\left(h \cdot M\_m\right) \cdot \left(\frac{D\_m}{d} \cdot \frac{\frac{D\_m}{\ell}}{d}\right)\right)\right), -0.125, w0\right)\\
\end{array}
\end{array}
if (*.f64 M D) < 2e-171Initial program 83.4%
Taylor expanded in M around 0
Applied rewrites76.1%
if 2e-171 < (*.f64 M D) < 5.00000000000000029e278Initial program 82.1%
Applied rewrites83.5%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6488.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6488.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6488.2
Applied rewrites88.2%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
Applied rewrites84.8%
Applied rewrites90.8%
if 5.00000000000000029e278 < (*.f64 M D) Initial program 79.3%
Applied rewrites65.0%
Taylor expanded in M around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6443.3
Applied rewrites43.3%
Applied rewrites50.5%
Applied rewrites79.4%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(if (<= (/ (* M_m D_m) (* 2.0 d)) 1e+76)
(* w0 1.0)
(*
w0
(sqrt
(- 1.0 (/ (* (* (* D_m M_m) h) (* (- D_m) M_m)) (* (* -2.0 d) l)))))))D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (((M_m * D_m) / (2.0 * d)) <= 1e+76) {
tmp = w0 * 1.0;
} else {
tmp = w0 * sqrt((1.0 - ((((D_m * M_m) * h) * (-D_m * M_m)) / ((-2.0 * d) * l))));
}
return tmp;
}
D_m = private
M_m = private
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(w0, m_m, d_m, h, l, d)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
real(8) :: tmp
if (((m_m * d_m) / (2.0d0 * d)) <= 1d+76) then
tmp = w0 * 1.0d0
else
tmp = w0 * sqrt((1.0d0 - ((((d_m * m_m) * h) * (-d_m * m_m)) / (((-2.0d0) * d) * l))))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (((M_m * D_m) / (2.0 * d)) <= 1e+76) {
tmp = w0 * 1.0;
} else {
tmp = w0 * Math.sqrt((1.0 - ((((D_m * M_m) * h) * (-D_m * M_m)) / ((-2.0 * d) * l))));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): tmp = 0 if ((M_m * D_m) / (2.0 * d)) <= 1e+76: tmp = w0 * 1.0 else: tmp = w0 * math.sqrt((1.0 - ((((D_m * M_m) * h) * (-D_m * M_m)) / ((-2.0 * d) * l)))) return tmp
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) <= 1e+76) tmp = Float64(w0 * 1.0); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(D_m * M_m) * h) * Float64(Float64(-D_m) * M_m)) / Float64(Float64(-2.0 * d) * l))))); end return tmp end
D_m = abs(D);
M_m = abs(M);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
tmp = 0.0;
if (((M_m * D_m) / (2.0 * d)) <= 1e+76)
tmp = w0 * 1.0;
else
tmp = w0 * sqrt((1.0 - ((((D_m * M_m) * h) * (-D_m * M_m)) / ((-2.0 * d) * l))));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 1e+76], N[(w0 * 1.0), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] * N[((-D$95$m) * M$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(-2.0 * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{M\_m \cdot D\_m}{2 \cdot d} \leq 10^{+76}:\\
\;\;\;\;w0 \cdot 1\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(\left(D\_m \cdot M\_m\right) \cdot h\right) \cdot \left(\left(-D\_m\right) \cdot M\_m\right)}{\left(-2 \cdot d\right) \cdot \ell}}\\
\end{array}
\end{array}
if (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) < 1e76Initial program 87.9%
Taylor expanded in M around 0
Applied rewrites79.1%
if 1e76 < (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) Initial program 52.4%
Applied rewrites19.7%
Taylor expanded in M around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f646.5
Applied rewrites6.5%
Applied rewrites19.7%
Final simplification70.5%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(if (<= (* M_m D_m) 2e-183)
(*
w0
(sqrt (- 1.0 (* (* D_m (/ (* h M_m) (* 4.0 d))) (/ (* D_m (/ M_m d)) l)))))
(*
w0
(sqrt
(- 1.0 (* (/ (* (/ M_m d) D_m) l) (* (* M_m D_m) (/ h (* 4.0 d)))))))))D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if ((M_m * D_m) <= 2e-183) {
tmp = w0 * sqrt((1.0 - ((D_m * ((h * M_m) / (4.0 * d))) * ((D_m * (M_m / d)) / l))));
} else {
tmp = w0 * sqrt((1.0 - ((((M_m / d) * D_m) / l) * ((M_m * D_m) * (h / (4.0 * d))))));
}
return tmp;
}
D_m = private
M_m = private
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(w0, m_m, d_m, h, l, d)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
real(8) :: tmp
if ((m_m * d_m) <= 2d-183) then
tmp = w0 * sqrt((1.0d0 - ((d_m * ((h * m_m) / (4.0d0 * d))) * ((d_m * (m_m / d)) / l))))
else
tmp = w0 * sqrt((1.0d0 - ((((m_m / d) * d_m) / l) * ((m_m * d_m) * (h / (4.0d0 * d))))))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if ((M_m * D_m) <= 2e-183) {
tmp = w0 * Math.sqrt((1.0 - ((D_m * ((h * M_m) / (4.0 * d))) * ((D_m * (M_m / d)) / l))));
} else {
tmp = w0 * Math.sqrt((1.0 - ((((M_m / d) * D_m) / l) * ((M_m * D_m) * (h / (4.0 * d))))));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): tmp = 0 if (M_m * D_m) <= 2e-183: tmp = w0 * math.sqrt((1.0 - ((D_m * ((h * M_m) / (4.0 * d))) * ((D_m * (M_m / d)) / l)))) else: tmp = w0 * math.sqrt((1.0 - ((((M_m / d) * D_m) / l) * ((M_m * D_m) * (h / (4.0 * d)))))) return tmp
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (Float64(M_m * D_m) <= 2e-183) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(D_m * Float64(Float64(h * M_m) / Float64(4.0 * d))) * Float64(Float64(D_m * Float64(M_m / d)) / l))))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(M_m / d) * D_m) / l) * Float64(Float64(M_m * D_m) * Float64(h / Float64(4.0 * d))))))); end return tmp end
D_m = abs(D);
M_m = abs(M);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
tmp = 0.0;
if ((M_m * D_m) <= 2e-183)
tmp = w0 * sqrt((1.0 - ((D_m * ((h * M_m) / (4.0 * d))) * ((D_m * (M_m / d)) / l))));
else
tmp = w0 * sqrt((1.0 - ((((M_m / d) * D_m) / l) * ((M_m * D_m) * (h / (4.0 * d))))));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 2e-183], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(D$95$m * N[(N[(h * M$95$m), $MachinePrecision] / N[(4.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(M$95$m / d), $MachinePrecision] * D$95$m), $MachinePrecision] / l), $MachinePrecision] * N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(h / N[(4.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \cdot D\_m \leq 2 \cdot 10^{-183}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(D\_m \cdot \frac{h \cdot M\_m}{4 \cdot d}\right) \cdot \frac{D\_m \cdot \frac{M\_m}{d}}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{M\_m}{d} \cdot D\_m}{\ell} \cdot \left(\left(M\_m \cdot D\_m\right) \cdot \frac{h}{4 \cdot d}\right)}\\
\end{array}
\end{array}
if (*.f64 M D) < 2.00000000000000001e-183Initial program 83.3%
Applied rewrites86.5%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6488.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6488.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6488.2
Applied rewrites88.2%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
Applied rewrites93.2%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
metadata-eval86.4
Applied rewrites86.4%
if 2.00000000000000001e-183 < (*.f64 M D) Initial program 81.9%
Applied rewrites80.0%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6483.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6483.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6483.9
Applied rewrites83.9%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
Applied rewrites84.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6484.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6484.1
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
metadata-eval84.1
Applied rewrites84.1%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d) :precision binary64 (* w0 1.0))
D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0 * 1.0;
}
D_m = private
M_m = private
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(w0, m_m, d_m, h, l, d)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
code = w0 * 1.0d0
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0 * 1.0;
}
D_m = math.fabs(D) M_m = math.fabs(M) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): return w0 * 1.0
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) return Float64(w0 * 1.0) end
D_m = abs(D);
M_m = abs(M);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp = code(w0, M_m, D_m, h, l, d)
tmp = w0 * 1.0;
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := N[(w0 * 1.0), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
w0 \cdot 1
\end{array}
Initial program 82.7%
Taylor expanded in M around 0
Applied rewrites69.5%
herbie shell --seed 2024347
(FPCore (w0 M D h l d)
:name "Henrywood and Agarwal, Equation (9a)"
:precision binary64
(* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))