
(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 10 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}
M_m = (fabs.f64 M) NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (/ (* (* (* (/ M_m d) D) h) (/ (* D M_m) (* 2.0 d))) (* 2.0 l))))))
M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - (((((M_m / d) * D) * h) * ((D * M_m) / (2.0 * d))) / (2.0 * l))));
}
M_m = private
NOTE: w0, M_m, D, 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, h, l, d_1)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m_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_m / d_1) * d) * h) * ((d * m_m) / (2.0d0 * d_1))) / (2.0d0 * l))))
end function
M_m = Math.abs(M);
assert w0 < M_m && M_m < D && D < h && h < l && l < d;
public static double code(double w0, double M_m, double D, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - (((((M_m / d) * D) * h) * ((D * M_m) / (2.0 * d))) / (2.0 * l))));
}
M_m = math.fabs(M) [w0, M_m, D, h, l, d] = sort([w0, M_m, D, h, l, d]) def code(w0, M_m, D, h, l, d): return w0 * math.sqrt((1.0 - (((((M_m / d) * D) * h) * ((D * M_m) / (2.0 * d))) / (2.0 * l))))
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(Float64(M_m / d) * D) * h) * Float64(Float64(D * M_m) / Float64(2.0 * d))) / Float64(2.0 * l))))) end
M_m = abs(M);
w0, M_m, D, h, l, d = num2cell(sort([w0, M_m, D, h, l, d])){:}
function tmp = code(w0, M_m, D, h, l, d)
tmp = w0 * sqrt((1.0 - (((((M_m / d) * D) * h) * ((D * M_m) / (2.0 * d))) / (2.0 * l))));
end
M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(N[(M$95$m / d), $MachinePrecision] * D), $MachinePrecision] * h), $MachinePrecision] * N[(N[(D * M$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
w0 \cdot \sqrt{1 - \frac{\left(\left(\frac{M\_m}{d} \cdot D\right) \cdot h\right) \cdot \frac{D \cdot M\_m}{2 \cdot d}}{2 \cdot \ell}}
\end{array}
Initial program 82.3%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lift-/.f64N/A
frac-2negN/A
associate-*r/N/A
lift-*.f64N/A
count-2-revN/A
flip-+N/A
distribute-neg-fracN/A
+-inversesN/A
metadata-evalN/A
+-inversesN/A
flip-+N/A
count-2-revN/A
lift-*.f64N/A
lower-/.f64N/A
Applied rewrites81.5%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6483.8
Applied rewrites83.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lift-neg.f64N/A
metadata-evalN/A
frac-2negN/A
times-fracN/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites88.4%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
metadata-evalN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
lift-*.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f6488.3
Applied rewrites88.3%
M_m = (fabs.f64 M)
NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D h l d)
:precision binary64
(if (<= (sqrt (- 1.0 (* (pow (/ (* M_m D) (* 2.0 d)) 2.0) (/ h l)))) 2e+24)
(* w0 1.0)
(*
w0
(sqrt (fma (* h -0.25) (* D (* (/ M_m (* d d)) (/ (* D M_m) l))) 1.0)))))M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if (sqrt((1.0 - (pow(((M_m * D) / (2.0 * d)), 2.0) * (h / l)))) <= 2e+24) {
tmp = w0 * 1.0;
} else {
tmp = w0 * sqrt(fma((h * -0.25), (D * ((M_m / (d * d)) * ((D * M_m) / l))), 1.0));
}
return tmp;
}
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) tmp = 0.0 if (sqrt(Float64(1.0 - Float64((Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)))) <= 2e+24) tmp = Float64(w0 * 1.0); else tmp = Float64(w0 * sqrt(fma(Float64(h * -0.25), Float64(D * Float64(Float64(M_m / Float64(d * d)) * Float64(Float64(D * M_m) / l))), 1.0))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d_] := If[LessEqual[N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2e+24], N[(w0 * 1.0), $MachinePrecision], N[(w0 * N[Sqrt[N[(N[(h * -0.25), $MachinePrecision] * N[(D * N[(N[(M$95$m / N[(d * d), $MachinePrecision]), $MachinePrecision] * N[(N[(D * M$95$m), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;\sqrt{1 - {\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq 2 \cdot 10^{+24}:\\
\;\;\;\;w0 \cdot 1\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(h \cdot -0.25, D \cdot \left(\frac{M\_m}{d \cdot d} \cdot \frac{D \cdot M\_m}{\ell}\right), 1\right)}\\
\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)))) < 2e24Initial program 99.4%
Taylor expanded in M around 0
Applied rewrites96.7%
if 2e24 < (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 54.2%
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 rewrites47.8%
Applied rewrites51.0%
Applied rewrites60.0%
M_m = (fabs.f64 M) NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d) :precision binary64 (if (<= (* (pow (/ (* M_m D) (* 2.0 d)) 2.0) (/ h l)) -5e+59) (* w0 (sqrt (+ 1.0 (/ (* (* h (* M_m D)) (* D M_m)) (* l (* -2.0 d)))))) (* w0 1.0)))
M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if ((pow(((M_m * D) / (2.0 * d)), 2.0) * (h / l)) <= -5e+59) {
tmp = w0 * sqrt((1.0 + (((h * (M_m * D)) * (D * M_m)) / (l * (-2.0 * d)))));
} else {
tmp = w0 * 1.0;
}
return tmp;
}
M_m = private
NOTE: w0, M_m, D, 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, h, l, d_1)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
real(8) :: tmp
if (((((m_m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l)) <= (-5d+59)) then
tmp = w0 * sqrt((1.0d0 + (((h * (m_m * d)) * (d * m_m)) / (l * ((-2.0d0) * d_1)))))
else
tmp = w0 * 1.0d0
end if
code = tmp
end function
M_m = Math.abs(M);
assert w0 < M_m && M_m < D && D < h && h < l && l < d;
public static double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if ((Math.pow(((M_m * D) / (2.0 * d)), 2.0) * (h / l)) <= -5e+59) {
tmp = w0 * Math.sqrt((1.0 + (((h * (M_m * D)) * (D * M_m)) / (l * (-2.0 * d)))));
} else {
tmp = w0 * 1.0;
}
return tmp;
}
M_m = math.fabs(M) [w0, M_m, D, h, l, d] = sort([w0, M_m, D, h, l, d]) def code(w0, M_m, D, h, l, d): tmp = 0 if (math.pow(((M_m * D) / (2.0 * d)), 2.0) * (h / l)) <= -5e+59: tmp = w0 * math.sqrt((1.0 + (((h * (M_m * D)) * (D * M_m)) / (l * (-2.0 * d))))) else: tmp = w0 * 1.0 return tmp
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -5e+59) tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(Float64(Float64(h * Float64(M_m * D)) * Float64(D * M_m)) / Float64(l * Float64(-2.0 * d)))))); else tmp = Float64(w0 * 1.0); end return tmp end
M_m = abs(M);
w0, M_m, D, h, l, d = num2cell(sort([w0, M_m, D, h, l, d])){:}
function tmp_2 = code(w0, M_m, D, h, l, d)
tmp = 0.0;
if (((((M_m * D) / (2.0 * d)) ^ 2.0) * (h / l)) <= -5e+59)
tmp = w0 * sqrt((1.0 + (((h * (M_m * D)) * (D * M_m)) / (l * (-2.0 * d)))));
else
tmp = w0 * 1.0;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -5e+59], N[(w0 * N[Sqrt[N[(1.0 + N[(N[(N[(h * N[(M$95$m * D), $MachinePrecision]), $MachinePrecision] * N[(D * M$95$m), $MachinePrecision]), $MachinePrecision] / N[(l * N[(-2.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -5 \cdot 10^{+59}:\\
\;\;\;\;w0 \cdot \sqrt{1 + \frac{\left(h \cdot \left(M\_m \cdot D\right)\right) \cdot \left(D \cdot M\_m\right)}{\ell \cdot \left(-2 \cdot d\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)) < -4.9999999999999997e59Initial program 64.1%
Applied rewrites30.8%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6430.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6430.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6430.8
Applied rewrites30.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6430.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6430.9
Applied rewrites30.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
frac-timesN/A
lift-neg.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
lower-/.f64N/A
Applied rewrites30.9%
if -4.9999999999999997e59 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 90.8%
Taylor expanded in M around 0
Applied rewrites93.8%
Final simplification73.6%
M_m = (fabs.f64 M) NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d) :precision binary64 (if (<= (* (pow (/ (* M_m D) (* 2.0 d)) 2.0) (/ h l)) -5e+167) (* w0 (fma -0.125 (* (* (/ M_m d) M_m) (/ (* (* D D) h) (* l d))) 1.0)) (* w0 1.0)))
M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if ((pow(((M_m * D) / (2.0 * d)), 2.0) * (h / l)) <= -5e+167) {
tmp = w0 * fma(-0.125, (((M_m / d) * M_m) * (((D * D) * h) / (l * d))), 1.0);
} else {
tmp = w0 * 1.0;
}
return tmp;
}
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -5e+167) tmp = Float64(w0 * fma(-0.125, Float64(Float64(Float64(M_m / d) * M_m) * Float64(Float64(Float64(D * D) * h) / Float64(l * d))), 1.0)); else tmp = Float64(w0 * 1.0); end return tmp end
M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -5e+167], N[(w0 * N[(-0.125 * N[(N[(N[(M$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(N[(N[(D * D), $MachinePrecision] * h), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -5 \cdot 10^{+167}:\\
\;\;\;\;w0 \cdot \mathsf{fma}\left(-0.125, \left(\frac{M\_m}{d} \cdot M\_m\right) \cdot \frac{\left(D \cdot D\right) \cdot h}{\ell \cdot d}, 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)) < -4.9999999999999997e167Initial program 62.8%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
associate-*l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
Applied rewrites63.6%
Taylor expanded in M around 0
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6438.1
Applied rewrites38.1%
Applied rewrites47.2%
if -4.9999999999999997e167 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 91.0%
Taylor expanded in M around 0
Applied rewrites92.3%
Final simplification78.4%
M_m = (fabs.f64 M) NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d) :precision binary64 (if (<= (* (pow (/ (* M_m D) (* 2.0 d)) 2.0) (/ h l)) -5e+167) (* w0 (fma -0.125 (* (* (/ D d) D) (* M_m (/ (* h M_m) (* l d)))) 1.0)) (* w0 1.0)))
M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if ((pow(((M_m * D) / (2.0 * d)), 2.0) * (h / l)) <= -5e+167) {
tmp = w0 * fma(-0.125, (((D / d) * D) * (M_m * ((h * M_m) / (l * d)))), 1.0);
} else {
tmp = w0 * 1.0;
}
return tmp;
}
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -5e+167) tmp = Float64(w0 * fma(-0.125, Float64(Float64(Float64(D / d) * D) * Float64(M_m * Float64(Float64(h * M_m) / Float64(l * d)))), 1.0)); else tmp = Float64(w0 * 1.0); end return tmp end
M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -5e+167], N[(w0 * N[(-0.125 * N[(N[(N[(D / d), $MachinePrecision] * D), $MachinePrecision] * N[(M$95$m * N[(N[(h * M$95$m), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -5 \cdot 10^{+167}:\\
\;\;\;\;w0 \cdot \mathsf{fma}\left(-0.125, \left(\frac{D}{d} \cdot D\right) \cdot \left(M\_m \cdot \frac{h \cdot M\_m}{\ell \cdot d}\right), 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)) < -4.9999999999999997e167Initial program 62.8%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
associate-*l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
Applied rewrites63.6%
Taylor expanded in M around 0
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6438.1
Applied rewrites38.1%
Applied rewrites49.8%
Applied rewrites53.9%
if -4.9999999999999997e167 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 91.0%
Taylor expanded in M around 0
Applied rewrites92.3%
Final simplification80.5%
M_m = (fabs.f64 M) NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d) :precision binary64 (if (<= (* (pow (/ (* M_m D) (* 2.0 d)) 2.0) (/ h l)) -5e+59) (* w0 (* -0.125 (/ (* M_m (* M_m (* (* D D) h))) (* (* d d) l)))) (* w0 1.0)))
M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if ((pow(((M_m * D) / (2.0 * d)), 2.0) * (h / l)) <= -5e+59) {
tmp = w0 * (-0.125 * ((M_m * (M_m * ((D * D) * h))) / ((d * d) * l)));
} else {
tmp = w0 * 1.0;
}
return tmp;
}
M_m = private
NOTE: w0, M_m, D, 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, h, l, d_1)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
real(8) :: tmp
if (((((m_m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l)) <= (-5d+59)) then
tmp = w0 * ((-0.125d0) * ((m_m * (m_m * ((d * d) * h))) / ((d_1 * d_1) * l)))
else
tmp = w0 * 1.0d0
end if
code = tmp
end function
M_m = Math.abs(M);
assert w0 < M_m && M_m < D && D < h && h < l && l < d;
public static double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if ((Math.pow(((M_m * D) / (2.0 * d)), 2.0) * (h / l)) <= -5e+59) {
tmp = w0 * (-0.125 * ((M_m * (M_m * ((D * D) * h))) / ((d * d) * l)));
} else {
tmp = w0 * 1.0;
}
return tmp;
}
M_m = math.fabs(M) [w0, M_m, D, h, l, d] = sort([w0, M_m, D, h, l, d]) def code(w0, M_m, D, h, l, d): tmp = 0 if (math.pow(((M_m * D) / (2.0 * d)), 2.0) * (h / l)) <= -5e+59: tmp = w0 * (-0.125 * ((M_m * (M_m * ((D * D) * h))) / ((d * d) * l))) else: tmp = w0 * 1.0 return tmp
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -5e+59) tmp = Float64(w0 * Float64(-0.125 * Float64(Float64(M_m * Float64(M_m * Float64(Float64(D * D) * h))) / Float64(Float64(d * d) * l)))); else tmp = Float64(w0 * 1.0); end return tmp end
M_m = abs(M);
w0, M_m, D, h, l, d = num2cell(sort([w0, M_m, D, h, l, d])){:}
function tmp_2 = code(w0, M_m, D, h, l, d)
tmp = 0.0;
if (((((M_m * D) / (2.0 * d)) ^ 2.0) * (h / l)) <= -5e+59)
tmp = w0 * (-0.125 * ((M_m * (M_m * ((D * D) * h))) / ((d * d) * l)));
else
tmp = w0 * 1.0;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -5e+59], N[(w0 * N[(-0.125 * N[(N[(M$95$m * N[(M$95$m * N[(N[(D * D), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -5 \cdot 10^{+59}:\\
\;\;\;\;w0 \cdot \left(-0.125 \cdot \frac{M\_m \cdot \left(M\_m \cdot \left(\left(D \cdot D\right) \cdot h\right)\right)}{\left(d \cdot d\right) \cdot \ell}\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)) < -4.9999999999999997e59Initial program 64.1%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
associate-*l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
Applied rewrites63.8%
Taylor expanded in M around 0
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6436.8
Applied rewrites36.8%
Taylor expanded in M around inf
Applied rewrites36.8%
Applied rewrites40.8%
if -4.9999999999999997e59 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 90.8%
Taylor expanded in M around 0
Applied rewrites93.8%
Final simplification76.8%
M_m = (fabs.f64 M)
NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D h l d)
:precision binary64
(if (<= (* M_m D) 5e-166)
(* w0 (fma -0.125 (* (* (/ D d) D) (* (/ M_m l) (* h (/ M_m d)))) 1.0))
(if (<= (* M_m D) 5e+296)
(*
w0
(sqrt (fma (* h -0.25) (* D (* M_m (/ (* D M_m) (* (* d d) l)))) 1.0)))
(fma (* (/ (* D D) d) (/ (* (* (* M_m M_m) h) w0) l)) -0.25 w0))))M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if ((M_m * D) <= 5e-166) {
tmp = w0 * fma(-0.125, (((D / d) * D) * ((M_m / l) * (h * (M_m / d)))), 1.0);
} else if ((M_m * D) <= 5e+296) {
tmp = w0 * sqrt(fma((h * -0.25), (D * (M_m * ((D * M_m) / ((d * d) * l)))), 1.0));
} else {
tmp = fma((((D * D) / d) * ((((M_m * M_m) * h) * w0) / l)), -0.25, w0);
}
return tmp;
}
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) tmp = 0.0 if (Float64(M_m * D) <= 5e-166) tmp = Float64(w0 * fma(-0.125, Float64(Float64(Float64(D / d) * D) * Float64(Float64(M_m / l) * Float64(h * Float64(M_m / d)))), 1.0)); elseif (Float64(M_m * D) <= 5e+296) tmp = Float64(w0 * sqrt(fma(Float64(h * -0.25), Float64(D * Float64(M_m * Float64(Float64(D * M_m) / Float64(Float64(d * d) * l)))), 1.0))); else tmp = fma(Float64(Float64(Float64(D * D) / d) * Float64(Float64(Float64(Float64(M_m * M_m) * h) * w0) / l)), -0.25, w0); end return tmp end
M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d_] := If[LessEqual[N[(M$95$m * D), $MachinePrecision], 5e-166], N[(w0 * N[(-0.125 * N[(N[(N[(D / d), $MachinePrecision] * D), $MachinePrecision] * N[(N[(M$95$m / l), $MachinePrecision] * N[(h * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(M$95$m * D), $MachinePrecision], 5e+296], N[(w0 * N[Sqrt[N[(N[(h * -0.25), $MachinePrecision] * N[(D * N[(M$95$m * N[(N[(D * M$95$m), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(D * D), $MachinePrecision] / d), $MachinePrecision] * N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] * w0), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] * -0.25 + w0), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \cdot D \leq 5 \cdot 10^{-166}:\\
\;\;\;\;w0 \cdot \mathsf{fma}\left(-0.125, \left(\frac{D}{d} \cdot D\right) \cdot \left(\frac{M\_m}{\ell} \cdot \left(h \cdot \frac{M\_m}{d}\right)\right), 1\right)\\
\mathbf{elif}\;M\_m \cdot D \leq 5 \cdot 10^{+296}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(h \cdot -0.25, D \cdot \left(M\_m \cdot \frac{D \cdot M\_m}{\left(d \cdot d\right) \cdot \ell}\right), 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{D \cdot D}{d} \cdot \frac{\left(\left(M\_m \cdot M\_m\right) \cdot h\right) \cdot w0}{\ell}, -0.25, w0\right)\\
\end{array}
\end{array}
if (*.f64 M D) < 5e-166Initial program 83.8%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
associate-*l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
Applied rewrites81.8%
Taylor expanded in M around 0
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6462.7
Applied rewrites62.7%
Applied rewrites71.9%
Applied rewrites76.0%
if 5e-166 < (*.f64 M D) < 5.0000000000000001e296Initial program 81.2%
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 rewrites50.0%
Applied rewrites59.0%
Applied rewrites80.2%
if 5.0000000000000001e296 < (*.f64 M D) Initial program 67.1%
Applied rewrites25.0%
Taylor expanded in M around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6433.4
Applied rewrites33.4%
Final simplification75.2%
M_m = (fabs.f64 M)
NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D h l d)
:precision binary64
(if (<= (* M_m D) 5e-114)
(* w0 1.0)
(if (<= (* M_m D) 5e+296)
(*
w0
(sqrt (fma (* h -0.25) (* D (* M_m (/ (* D M_m) (* (* d d) l)))) 1.0)))
(fma (* (/ (* D D) d) (/ (* (* (* M_m M_m) h) w0) l)) -0.25 w0))))M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if ((M_m * D) <= 5e-114) {
tmp = w0 * 1.0;
} else if ((M_m * D) <= 5e+296) {
tmp = w0 * sqrt(fma((h * -0.25), (D * (M_m * ((D * M_m) / ((d * d) * l)))), 1.0));
} else {
tmp = fma((((D * D) / d) * ((((M_m * M_m) * h) * w0) / l)), -0.25, w0);
}
return tmp;
}
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) tmp = 0.0 if (Float64(M_m * D) <= 5e-114) tmp = Float64(w0 * 1.0); elseif (Float64(M_m * D) <= 5e+296) tmp = Float64(w0 * sqrt(fma(Float64(h * -0.25), Float64(D * Float64(M_m * Float64(Float64(D * M_m) / Float64(Float64(d * d) * l)))), 1.0))); else tmp = fma(Float64(Float64(Float64(D * D) / d) * Float64(Float64(Float64(Float64(M_m * M_m) * h) * w0) / l)), -0.25, w0); end return tmp end
M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d_] := If[LessEqual[N[(M$95$m * D), $MachinePrecision], 5e-114], N[(w0 * 1.0), $MachinePrecision], If[LessEqual[N[(M$95$m * D), $MachinePrecision], 5e+296], N[(w0 * N[Sqrt[N[(N[(h * -0.25), $MachinePrecision] * N[(D * N[(M$95$m * N[(N[(D * M$95$m), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(D * D), $MachinePrecision] / d), $MachinePrecision] * N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] * w0), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] * -0.25 + w0), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \cdot D \leq 5 \cdot 10^{-114}:\\
\;\;\;\;w0 \cdot 1\\
\mathbf{elif}\;M\_m \cdot D \leq 5 \cdot 10^{+296}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(h \cdot -0.25, D \cdot \left(M\_m \cdot \frac{D \cdot M\_m}{\left(d \cdot d\right) \cdot \ell}\right), 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{D \cdot D}{d} \cdot \frac{\left(\left(M\_m \cdot M\_m\right) \cdot h\right) \cdot w0}{\ell}, -0.25, w0\right)\\
\end{array}
\end{array}
if (*.f64 M D) < 4.99999999999999989e-114Initial program 83.7%
Taylor expanded in M around 0
Applied rewrites73.1%
if 4.99999999999999989e-114 < (*.f64 M D) < 5.0000000000000001e296Initial program 81.5%
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 rewrites49.9%
Applied rewrites59.5%
Applied rewrites80.4%
if 5.0000000000000001e296 < (*.f64 M D) Initial program 67.1%
Applied rewrites25.0%
Taylor expanded in M around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6433.4
Applied rewrites33.4%
M_m = (fabs.f64 M) NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d) :precision binary64 (* w0 (sqrt (fma (* h -0.25) (* D (/ (* (* D (/ M_m d)) M_m) (* l d))) 1.0))))
M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
return w0 * sqrt(fma((h * -0.25), (D * (((D * (M_m / d)) * M_m) / (l * d))), 1.0));
}
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) return Float64(w0 * sqrt(fma(Float64(h * -0.25), Float64(D * Float64(Float64(Float64(D * Float64(M_m / d)) * M_m) / Float64(l * d))), 1.0))) end
M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(N[(h * -0.25), $MachinePrecision] * N[(D * N[(N[(N[(D * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
w0 \cdot \sqrt{\mathsf{fma}\left(h \cdot -0.25, D \cdot \frac{\left(D \cdot \frac{M\_m}{d}\right) \cdot M\_m}{\ell \cdot d}, 1\right)}
\end{array}
Initial program 82.3%
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 rewrites61.5%
Applied rewrites66.2%
Applied rewrites83.8%
M_m = (fabs.f64 M) NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d) :precision binary64 (* w0 1.0))
M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
return w0 * 1.0;
}
M_m = private
NOTE: w0, M_m, D, 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, h, l, d_1)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
code = w0 * 1.0d0
end function
M_m = Math.abs(M);
assert w0 < M_m && M_m < D && D < h && h < l && l < d;
public static double code(double w0, double M_m, double D, double h, double l, double d) {
return w0 * 1.0;
}
M_m = math.fabs(M) [w0, M_m, D, h, l, d] = sort([w0, M_m, D, h, l, d]) def code(w0, M_m, D, h, l, d): return w0 * 1.0
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) return Float64(w0 * 1.0) end
M_m = abs(M);
w0, M_m, D, h, l, d = num2cell(sort([w0, M_m, D, h, l, d])){:}
function tmp = code(w0, M_m, D, h, l, d)
tmp = w0 * 1.0;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d_] := N[(w0 * 1.0), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
w0 \cdot 1
\end{array}
Initial program 82.3%
Taylor expanded in M around 0
Applied rewrites65.3%
herbie shell --seed 2024353
(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))))))