
(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}
Herbie found 11 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}
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M D h l d) :precision binary64 (let* ((t_0 (* (/ D (+ d d)) M))) (* w0 (sqrt (- 1.0 (/ (* t_0 (* t_0 h)) l))))))
assert(w0 < M && M < D && D < h && h < l && l < d);
double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = (D / (d + d)) * M;
return w0 * sqrt((1.0 - ((t_0 * (t_0 * h)) / l)));
}
NOTE: w0, 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, 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
real(8) :: t_0
t_0 = (d / (d_1 + d_1)) * m
code = w0 * sqrt((1.0d0 - ((t_0 * (t_0 * h)) / l)))
end function
assert w0 < M && M < D && D < h && h < l && l < d;
public static double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = (D / (d + d)) * M;
return w0 * Math.sqrt((1.0 - ((t_0 * (t_0 * h)) / l)));
}
[w0, M, D, h, l, d] = sort([w0, M, D, h, l, d]) def code(w0, M, D, h, l, d): t_0 = (D / (d + d)) * M return w0 * math.sqrt((1.0 - ((t_0 * (t_0 * h)) / l)))
w0, M, D, h, l, d = sort([w0, M, D, h, l, d]) function code(w0, M, D, h, l, d) t_0 = Float64(Float64(D / Float64(d + d)) * M) return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * h)) / l)))) end
w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
function tmp = code(w0, M, D, h, l, d)
t_0 = (D / (d + d)) * M;
tmp = w0 * sqrt((1.0 - ((t_0 * (t_0 * h)) / l)));
end
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(N[(D / N[(d + d), $MachinePrecision]), $MachinePrecision] * M), $MachinePrecision]}, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
\\
\begin{array}{l}
t_0 := \frac{D}{d + d} \cdot M\\
w0 \cdot \sqrt{1 - \frac{t\_0 \cdot \left(t\_0 \cdot h\right)}{\ell}}
\end{array}
\end{array}
Initial program 81.1%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites86.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lower-*.f6488.2
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-+.f6488.2
Applied rewrites88.2%
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M D h l d) :precision binary64 (let* ((t_0 (* M (/ D (+ d d))))) (* w0 (sqrt (- 1.0 (/ (* (* t_0 t_0) h) l))))))
assert(w0 < M && M < D && D < h && h < l && l < d);
double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = M * (D / (d + d));
return w0 * sqrt((1.0 - (((t_0 * t_0) * h) / l)));
}
NOTE: w0, 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, 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
real(8) :: t_0
t_0 = m * (d / (d_1 + d_1))
code = w0 * sqrt((1.0d0 - (((t_0 * t_0) * h) / l)))
end function
assert w0 < M && M < D && D < h && h < l && l < d;
public static double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = M * (D / (d + d));
return w0 * Math.sqrt((1.0 - (((t_0 * t_0) * h) / l)));
}
[w0, M, D, h, l, d] = sort([w0, M, D, h, l, d]) def code(w0, M, D, h, l, d): t_0 = M * (D / (d + d)) return w0 * math.sqrt((1.0 - (((t_0 * t_0) * h) / l)))
w0, M, D, h, l, d = sort([w0, M, D, h, l, d]) function code(w0, M, D, h, l, d) t_0 = Float64(M * Float64(D / Float64(d + d))) return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(t_0 * t_0) * h) / l)))) end
w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
function tmp = code(w0, M, D, h, l, d)
t_0 = M * (D / (d + d));
tmp = w0 * sqrt((1.0 - (((t_0 * t_0) * h) / l)));
end
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(M * N[(D / N[(d + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
\\
\begin{array}{l}
t_0 := M \cdot \frac{D}{d + d}\\
w0 \cdot \sqrt{1 - \frac{\left(t\_0 \cdot t\_0\right) \cdot h}{\ell}}
\end{array}
\end{array}
Initial program 81.1%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites86.2%
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
:precision binary64
(if (<= (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)))) 5e+153)
(* w0 (sqrt (- 1.0 (* (* (* (/ (* M D) d) (* D (/ M d))) 0.25) (/ h l)))))
(*
(sqrt (- 1.0 (/ (* (* (/ (* M D) (+ d d)) (* h M)) (/ D (+ d d))) l)))
w0)))assert(w0 < M && M < D && D < h && h < l && l < d);
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l)))) <= 5e+153) {
tmp = w0 * sqrt((1.0 - (((((M * D) / d) * (D * (M / d))) * 0.25) * (h / l))));
} else {
tmp = sqrt((1.0 - (((((M * D) / (d + d)) * (h * M)) * (D / (d + d))) / l))) * w0;
}
return tmp;
}
NOTE: w0, 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, 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
real(8) :: tmp
if (sqrt((1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l)))) <= 5d+153) then
tmp = w0 * sqrt((1.0d0 - (((((m * d) / d_1) * (d * (m / d_1))) * 0.25d0) * (h / l))))
else
tmp = sqrt((1.0d0 - (((((m * d) / (d_1 + d_1)) * (h * m)) * (d / (d_1 + d_1))) / l))) * w0
end if
code = tmp
end function
assert w0 < M && M < D && D < h && h < l && l < d;
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)))) <= 5e+153) {
tmp = w0 * Math.sqrt((1.0 - (((((M * D) / d) * (D * (M / d))) * 0.25) * (h / l))));
} else {
tmp = Math.sqrt((1.0 - (((((M * D) / (d + d)) * (h * M)) * (D / (d + d))) / l))) * w0;
}
return tmp;
}
[w0, M, D, h, l, d] = sort([w0, M, D, h, l, d]) def code(w0, M, D, h, l, d): tmp = 0 if math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)))) <= 5e+153: tmp = w0 * math.sqrt((1.0 - (((((M * D) / d) * (D * (M / d))) * 0.25) * (h / l)))) else: tmp = math.sqrt((1.0 - (((((M * D) / (d + d)) * (h * M)) * (D / (d + d))) / l))) * w0 return tmp
w0, M, D, h, l, d = sort([w0, M, D, h, l, d]) function code(w0, M, D, h, l, d) tmp = 0.0 if (sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)))) <= 5e+153) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(Float64(M * D) / d) * Float64(D * Float64(M / d))) * 0.25) * Float64(h / l))))); else tmp = Float64(sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(Float64(M * D) / Float64(d + d)) * Float64(h * M)) * Float64(D / Float64(d + d))) / l))) * w0); end return tmp end
w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
function tmp_2 = code(w0, M, D, h, l, d)
tmp = 0.0;
if (sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)))) <= 5e+153)
tmp = w0 * sqrt((1.0 - (((((M * D) / d) * (D * (M / d))) * 0.25) * (h / l))));
else
tmp = sqrt((1.0 - (((((M * D) / (d + d)) * (h * M)) * (D / (d + d))) / l))) * w0;
end
tmp_2 = tmp;
end
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[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], 5e+153], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(N[(M * D), $MachinePrecision] / d), $MachinePrecision] * N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(1.0 - N[(N[(N[(N[(N[(M * D), $MachinePrecision] / N[(d + d), $MachinePrecision]), $MachinePrecision] * N[(h * M), $MachinePrecision]), $MachinePrecision] * N[(D / N[(d + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * w0), $MachinePrecision]]
\begin{array}{l}
[w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;\sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq 5 \cdot 10^{+153}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(\left(\frac{M \cdot D}{d} \cdot \left(D \cdot \frac{M}{d}\right)\right) \cdot 0.25\right) \cdot \frac{h}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \frac{\left(\frac{M \cdot D}{d + d} \cdot \left(h \cdot M\right)\right) \cdot \frac{D}{d + d}}{\ell}} \cdot w0\\
\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)))) < 5.00000000000000018e153Initial program 99.8%
Taylor expanded in M around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6463.3
Applied rewrites63.3%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
unswap-sqrN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6481.3
Applied rewrites81.3%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
*-commutativeN/A
lower-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6498.4
Applied rewrites98.4%
if 5.00000000000000018e153 < (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 41.9%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites61.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lower-*.f6467.6
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-+.f6467.6
Applied rewrites67.6%
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lower-*.f6467.0
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f6465.0
Applied rewrites65.0%
Applied rewrites61.5%
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
:precision binary64
(let* ((t_0 (* M (/ D d))))
(if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) 0.0)
(* w0 (sqrt (- 1.0 (* (* (* t_0 t_0) 0.25) (/ h l)))))
w0)))assert(w0 < M && M < D && D < h && h < l && l < d);
double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = M * (D / d);
double tmp;
if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= 0.0) {
tmp = w0 * sqrt((1.0 - (((t_0 * t_0) * 0.25) * (h / l))));
} else {
tmp = w0;
}
return tmp;
}
NOTE: w0, 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, 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
real(8) :: t_0
real(8) :: tmp
t_0 = m * (d / d_1)
if (((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l)) <= 0.0d0) then
tmp = w0 * sqrt((1.0d0 - (((t_0 * t_0) * 0.25d0) * (h / l))))
else
tmp = w0
end if
code = tmp
end function
assert w0 < M && M < D && D < h && h < l && l < d;
public static double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = M * (D / d);
double tmp;
if ((Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= 0.0) {
tmp = w0 * Math.sqrt((1.0 - (((t_0 * t_0) * 0.25) * (h / l))));
} else {
tmp = w0;
}
return tmp;
}
[w0, M, D, h, l, d] = sort([w0, M, D, h, l, d]) def code(w0, M, D, h, l, d): t_0 = M * (D / d) tmp = 0 if (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= 0.0: tmp = w0 * math.sqrt((1.0 - (((t_0 * t_0) * 0.25) * (h / l)))) else: tmp = w0 return tmp
w0, M, D, h, l, d = sort([w0, M, D, h, l, d]) function code(w0, M, D, h, l, d) t_0 = Float64(M * Float64(D / d)) tmp = 0.0 if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= 0.0) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(t_0 * t_0) * 0.25) * Float64(h / l))))); else tmp = w0; end return tmp end
w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
function tmp_2 = code(w0, M, D, h, l, d)
t_0 = M * (D / d);
tmp = 0.0;
if (((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)) <= 0.0)
tmp = w0 * sqrt((1.0 - (((t_0 * t_0) * 0.25) * (h / l))));
else
tmp = w0;
end
tmp_2 = tmp;
end
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(M * N[(D / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], 0.0], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.25), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]]
\begin{array}{l}
[w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
\\
\begin{array}{l}
t_0 := M \cdot \frac{D}{d}\\
\mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq 0:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(\left(t\_0 \cdot t\_0\right) \cdot 0.25\right) \cdot \frac{h}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\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)) < 0.0Initial program 87.1%
Taylor expanded in M around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6459.6
Applied rewrites59.6%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
unswap-sqrN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6473.3
Applied rewrites73.3%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6487.1
Applied rewrites87.1%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6486.3
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6486.9
Applied rewrites86.9%
if 0.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 47.2%
Taylor expanded in M around 0
Applied rewrites82.8%
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M D h l d) :precision binary64 (if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) -2e+60) (* w0 (sqrt (* (/ (* (* h M) M) d) (* (* D (/ D (* l d))) -0.25)))) w0))
assert(w0 < M && M < D && D < h && h < l && l < d);
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -2e+60) {
tmp = w0 * sqrt(((((h * M) * M) / d) * ((D * (D / (l * d))) * -0.25)));
} else {
tmp = w0;
}
return tmp;
}
NOTE: w0, 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, 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
real(8) :: tmp
if (((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l)) <= (-2d+60)) then
tmp = w0 * sqrt(((((h * m) * m) / d_1) * ((d * (d / (l * d_1))) * (-0.25d0))))
else
tmp = w0
end if
code = tmp
end function
assert w0 < M && M < D && D < h && h < l && l < d;
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -2e+60) {
tmp = w0 * Math.sqrt(((((h * M) * M) / d) * ((D * (D / (l * d))) * -0.25)));
} else {
tmp = w0;
}
return tmp;
}
[w0, M, D, h, l, d] = sort([w0, M, D, h, l, d]) def code(w0, M, D, h, l, d): tmp = 0 if (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -2e+60: tmp = w0 * math.sqrt(((((h * M) * M) / d) * ((D * (D / (l * d))) * -0.25))) else: tmp = w0 return tmp
w0, M, D, h, l, d = sort([w0, M, D, h, l, d]) function code(w0, M, D, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -2e+60) tmp = Float64(w0 * sqrt(Float64(Float64(Float64(Float64(h * M) * M) / d) * Float64(Float64(D * Float64(D / Float64(l * d))) * -0.25)))); else tmp = w0; end return tmp end
w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
function tmp_2 = code(w0, M, D, h, l, d)
tmp = 0.0;
if (((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)) <= -2e+60)
tmp = w0 * sqrt(((((h * M) * M) / d) * ((D * (D / (l * d))) * -0.25)));
else
tmp = w0;
end
tmp_2 = tmp;
end
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -2e+60], N[(w0 * N[Sqrt[N[(N[(N[(N[(h * M), $MachinePrecision] * M), $MachinePrecision] / d), $MachinePrecision] * N[(N[(D * N[(D / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
[w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{+60}:\\
\;\;\;\;w0 \cdot \sqrt{\frac{\left(h \cdot M\right) \cdot M}{d} \cdot \left(\left(D \cdot \frac{D}{\ell \cdot d}\right) \cdot -0.25\right)}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\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)) < -1.9999999999999999e60Initial program 63.1%
Taylor expanded in M around inf
*-commutativeN/A
lower-*.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-*.f6440.5
Applied rewrites40.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6442.4
Applied rewrites42.4%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6446.8
Applied rewrites46.8%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f6450.8
Applied rewrites50.8%
if -1.9999999999999999e60 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 88.6%
Taylor expanded in M around 0
Applied rewrites93.8%
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M D h l d) :precision binary64 (if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) -2e+72) (* w0 (sqrt (* (* (* (* h M) (/ M d)) (/ (* D D) (* l d))) -0.25))) w0))
assert(w0 < M && M < D && D < h && h < l && l < d);
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -2e+72) {
tmp = w0 * sqrt(((((h * M) * (M / d)) * ((D * D) / (l * d))) * -0.25));
} else {
tmp = w0;
}
return tmp;
}
NOTE: w0, 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, 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
real(8) :: tmp
if (((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l)) <= (-2d+72)) then
tmp = w0 * sqrt(((((h * m) * (m / d_1)) * ((d * d) / (l * d_1))) * (-0.25d0)))
else
tmp = w0
end if
code = tmp
end function
assert w0 < M && M < D && D < h && h < l && l < d;
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -2e+72) {
tmp = w0 * Math.sqrt(((((h * M) * (M / d)) * ((D * D) / (l * d))) * -0.25));
} else {
tmp = w0;
}
return tmp;
}
[w0, M, D, h, l, d] = sort([w0, M, D, h, l, d]) def code(w0, M, D, h, l, d): tmp = 0 if (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -2e+72: tmp = w0 * math.sqrt(((((h * M) * (M / d)) * ((D * D) / (l * d))) * -0.25)) else: tmp = w0 return tmp
w0, M, D, h, l, d = sort([w0, M, D, h, l, d]) function code(w0, M, D, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -2e+72) tmp = Float64(w0 * sqrt(Float64(Float64(Float64(Float64(h * M) * Float64(M / d)) * Float64(Float64(D * D) / Float64(l * d))) * -0.25))); else tmp = w0; end return tmp end
w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
function tmp_2 = code(w0, M, D, h, l, d)
tmp = 0.0;
if (((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)) <= -2e+72)
tmp = w0 * sqrt(((((h * M) * (M / d)) * ((D * D) / (l * d))) * -0.25));
else
tmp = w0;
end
tmp_2 = tmp;
end
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -2e+72], N[(w0 * N[Sqrt[N[(N[(N[(N[(h * M), $MachinePrecision] * N[(M / d), $MachinePrecision]), $MachinePrecision] * N[(N[(D * D), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
[w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{+72}:\\
\;\;\;\;w0 \cdot \sqrt{\left(\left(\left(h \cdot M\right) \cdot \frac{M}{d}\right) \cdot \frac{D \cdot D}{\ell \cdot d}\right) \cdot -0.25}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\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)) < -1.99999999999999989e72Initial program 62.7%
Taylor expanded in M around inf
*-commutativeN/A
lower-*.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-*.f6440.7
Applied rewrites40.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6442.6
Applied rewrites42.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6447.0
Applied rewrites47.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6449.8
Applied rewrites49.8%
if -1.99999999999999989e72 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 88.7%
Taylor expanded in M around 0
Applied rewrites93.4%
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M D h l d) :precision binary64 (if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) -1e+39) (* w0 (sqrt (* (/ (* (* (* (* M D) D) M) h) (* d (* d l))) -0.25))) w0))
assert(w0 < M && M < D && D < h && h < l && l < d);
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -1e+39) {
tmp = w0 * sqrt(((((((M * D) * D) * M) * h) / (d * (d * l))) * -0.25));
} else {
tmp = w0;
}
return tmp;
}
NOTE: w0, 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, 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
real(8) :: tmp
if (((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l)) <= (-1d+39)) then
tmp = w0 * sqrt(((((((m * d) * d) * m) * h) / (d_1 * (d_1 * l))) * (-0.25d0)))
else
tmp = w0
end if
code = tmp
end function
assert w0 < M && M < D && D < h && h < l && l < d;
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -1e+39) {
tmp = w0 * Math.sqrt(((((((M * D) * D) * M) * h) / (d * (d * l))) * -0.25));
} else {
tmp = w0;
}
return tmp;
}
[w0, M, D, h, l, d] = sort([w0, M, D, h, l, d]) def code(w0, M, D, h, l, d): tmp = 0 if (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -1e+39: tmp = w0 * math.sqrt(((((((M * D) * D) * M) * h) / (d * (d * l))) * -0.25)) else: tmp = w0 return tmp
w0, M, D, h, l, d = sort([w0, M, D, h, l, d]) function code(w0, M, D, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -1e+39) tmp = Float64(w0 * sqrt(Float64(Float64(Float64(Float64(Float64(Float64(M * D) * D) * M) * h) / Float64(d * Float64(d * l))) * -0.25))); else tmp = w0; end return tmp end
w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
function tmp_2 = code(w0, M, D, h, l, d)
tmp = 0.0;
if (((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)) <= -1e+39)
tmp = w0 * sqrt(((((((M * D) * D) * M) * h) / (d * (d * l))) * -0.25));
else
tmp = w0;
end
tmp_2 = tmp;
end
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -1e+39], N[(w0 * N[Sqrt[N[(N[(N[(N[(N[(N[(M * D), $MachinePrecision] * D), $MachinePrecision] * M), $MachinePrecision] * h), $MachinePrecision] / N[(d * N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
[w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -1 \cdot 10^{+39}:\\
\;\;\;\;w0 \cdot \sqrt{\frac{\left(\left(\left(M \cdot D\right) \cdot D\right) \cdot M\right) \cdot h}{d \cdot \left(d \cdot \ell\right)} \cdot -0.25}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\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.9999999999999994e38Initial program 63.9%
Taylor expanded in M around inf
*-commutativeN/A
lower-*.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-*.f6440.1
Applied rewrites40.1%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6442.1
Applied rewrites42.1%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
*-commutativeN/A
associate-*r*N/A
pow-prod-downN/A
pow2N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6451.7
Applied rewrites51.7%
if -9.9999999999999994e38 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 88.5%
Taylor expanded in M around 0
Applied rewrites94.6%
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M D h l d) :precision binary64 (if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) (- INFINITY)) (/ (* (* (* (* h M) M) (* w0 (* D D))) -0.125) (* d (* l d))) w0))
assert(w0 < M && M < D && D < h && h < l && l < d);
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -((double) INFINITY)) {
tmp = ((((h * M) * M) * (w0 * (D * D))) * -0.125) / (d * (l * d));
} else {
tmp = w0;
}
return tmp;
}
assert w0 < M && M < D && D < h && h < l && l < d;
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -Double.POSITIVE_INFINITY) {
tmp = ((((h * M) * M) * (w0 * (D * D))) * -0.125) / (d * (l * d));
} else {
tmp = w0;
}
return tmp;
}
[w0, M, D, h, l, d] = sort([w0, M, D, h, l, d]) def code(w0, M, D, h, l, d): tmp = 0 if (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -math.inf: tmp = ((((h * M) * M) * (w0 * (D * D))) * -0.125) / (d * (l * d)) else: tmp = w0 return tmp
w0, M, D, h, l, d = sort([w0, M, D, h, l, d]) function code(w0, M, D, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= Float64(-Inf)) tmp = Float64(Float64(Float64(Float64(Float64(h * M) * M) * Float64(w0 * Float64(D * D))) * -0.125) / Float64(d * Float64(l * d))); else tmp = w0; end return tmp end
w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
function tmp_2 = code(w0, M, D, h, l, d)
tmp = 0.0;
if (((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)) <= -Inf)
tmp = ((((h * M) * M) * (w0 * (D * D))) * -0.125) / (d * (l * d));
else
tmp = w0;
end
tmp_2 = tmp;
end
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], (-Infinity)], N[(N[(N[(N[(N[(h * M), $MachinePrecision] * M), $MachinePrecision] * N[(w0 * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] / N[(d * N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
[w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -\infty:\\
\;\;\;\;\frac{\left(\left(\left(h \cdot M\right) \cdot M\right) \cdot \left(w0 \cdot \left(D \cdot D\right)\right)\right) \cdot -0.125}{d \cdot \left(\ell \cdot d\right)}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\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 55.5%
Taylor expanded in M around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites43.5%
Taylor expanded in M around inf
Applied rewrites43.1%
Applied rewrites44.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f6446.6
Applied rewrites46.6%
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 89.3%
Taylor expanded in M around 0
Applied rewrites87.9%
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M D h l d) :precision binary64 (if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) (- INFINITY)) (/ (* (* (* h M) (* M (* (* D D) w0))) -0.125) (* (* d d) l)) w0))
assert(w0 < M && M < D && D < h && h < l && l < d);
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -((double) INFINITY)) {
tmp = (((h * M) * (M * ((D * D) * w0))) * -0.125) / ((d * d) * l);
} else {
tmp = w0;
}
return tmp;
}
assert w0 < M && M < D && D < h && h < l && l < d;
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -Double.POSITIVE_INFINITY) {
tmp = (((h * M) * (M * ((D * D) * w0))) * -0.125) / ((d * d) * l);
} else {
tmp = w0;
}
return tmp;
}
[w0, M, D, h, l, d] = sort([w0, M, D, h, l, d]) def code(w0, M, D, h, l, d): tmp = 0 if (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -math.inf: tmp = (((h * M) * (M * ((D * D) * w0))) * -0.125) / ((d * d) * l) else: tmp = w0 return tmp
w0, M, D, h, l, d = sort([w0, M, D, h, l, d]) function code(w0, M, D, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= Float64(-Inf)) tmp = Float64(Float64(Float64(Float64(h * M) * Float64(M * Float64(Float64(D * D) * w0))) * -0.125) / Float64(Float64(d * d) * l)); else tmp = w0; end return tmp end
w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
function tmp_2 = code(w0, M, D, h, l, d)
tmp = 0.0;
if (((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)) <= -Inf)
tmp = (((h * M) * (M * ((D * D) * w0))) * -0.125) / ((d * d) * l);
else
tmp = w0;
end
tmp_2 = tmp;
end
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], (-Infinity)], N[(N[(N[(N[(h * M), $MachinePrecision] * N[(M * N[(N[(D * D), $MachinePrecision] * w0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
[w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -\infty:\\
\;\;\;\;\frac{\left(\left(h \cdot M\right) \cdot \left(M \cdot \left(\left(D \cdot D\right) \cdot w0\right)\right)\right) \cdot -0.125}{\left(d \cdot d\right) \cdot \ell}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\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 55.5%
Taylor expanded in M around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites43.5%
Taylor expanded in M around inf
Applied rewrites43.1%
Applied rewrites44.9%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
pow2N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6446.5
Applied rewrites46.5%
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 89.3%
Taylor expanded in M around 0
Applied rewrites87.9%
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M D h l d) :precision binary64 (if (<= (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)) -2e+246) (* (* (* (* D (* h w0)) (* M (/ M (* (* d d) l)))) D) -0.125) w0))
assert(w0 < M && M < D && D < h && h < l && l < d);
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -2e+246) {
tmp = (((D * (h * w0)) * (M * (M / ((d * d) * l)))) * D) * -0.125;
} else {
tmp = w0;
}
return tmp;
}
NOTE: w0, 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, 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
real(8) :: tmp
if (((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l)) <= (-2d+246)) then
tmp = (((d * (h * w0)) * (m * (m / ((d_1 * d_1) * l)))) * d) * (-0.125d0)
else
tmp = w0
end if
code = tmp
end function
assert w0 < M && M < D && D < h && h < l && l < d;
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -2e+246) {
tmp = (((D * (h * w0)) * (M * (M / ((d * d) * l)))) * D) * -0.125;
} else {
tmp = w0;
}
return tmp;
}
[w0, M, D, h, l, d] = sort([w0, M, D, h, l, d]) def code(w0, M, D, h, l, d): tmp = 0 if (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l)) <= -2e+246: tmp = (((D * (h * w0)) * (M * (M / ((d * d) * l)))) * D) * -0.125 else: tmp = w0 return tmp
w0, M, D, h, l, d = sort([w0, M, D, h, l, d]) function code(w0, M, D, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -2e+246) tmp = Float64(Float64(Float64(Float64(D * Float64(h * w0)) * Float64(M * Float64(M / Float64(Float64(d * d) * l)))) * D) * -0.125); else tmp = w0; end return tmp end
w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
function tmp_2 = code(w0, M, D, h, l, d)
tmp = 0.0;
if (((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)) <= -2e+246)
tmp = (((D * (h * w0)) * (M * (M / ((d * d) * l)))) * D) * -0.125;
else
tmp = w0;
end
tmp_2 = tmp;
end
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -2e+246], N[(N[(N[(N[(D * N[(h * w0), $MachinePrecision]), $MachinePrecision] * N[(M * N[(M / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * D), $MachinePrecision] * -0.125), $MachinePrecision], w0]
\begin{array}{l}
[w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{+246}:\\
\;\;\;\;\left(\left(\left(D \cdot \left(h \cdot w0\right)\right) \cdot \left(M \cdot \frac{M}{\left(d \cdot d\right) \cdot \ell}\right)\right) \cdot D\right) \cdot -0.125\\
\mathbf{else}:\\
\;\;\;\;w0\\
\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.00000000000000014e246Initial program 57.0%
Taylor expanded in M around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites42.5%
Taylor expanded in M around inf
Applied rewrites42.2%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
Applied rewrites46.0%
Applied rewrites48.9%
if -2.00000000000000014e246 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 89.2%
Taylor expanded in M around 0
Applied rewrites88.8%
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M D h l d) :precision binary64 w0)
assert(w0 < M && M < D && D < h && h < l && l < d);
double code(double w0, double M, double D, double h, double l, double d) {
return w0;
}
NOTE: w0, 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, 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
end function
assert w0 < M && M < D && D < h && h < l && l < d;
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0;
}
[w0, M, D, h, l, d] = sort([w0, M, D, h, l, d]) def code(w0, M, D, h, l, d): return w0
w0, M, D, h, l, d = sort([w0, M, D, h, l, d]) function code(w0, M, D, h, l, d) return w0 end
w0, M, D, h, l, d = num2cell(sort([w0, M, D, h, l, d])){:}
function tmp = code(w0, M, D, h, l, d)
tmp = w0;
end
NOTE: w0, M, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M_, D_, h_, l_, d_] := w0
\begin{array}{l}
[w0, M, D, h, l, d] = \mathsf{sort}([w0, M, D, h, l, d])\\
\\
w0
\end{array}
Initial program 81.1%
Taylor expanded in M around 0
Applied rewrites67.7%
herbie shell --seed 2025106
(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))))))