
(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 8 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
(let* ((t_0 (sqrt (- 1.0 (* (pow (/ (* M_m D) (* 2.0 d)) 2.0) (/ h l))))))
(if (<= t_0 2e+132)
(* w0 t_0)
(* w0 (sqrt (- 1.0 (/ (* (pow (* (/ M_m 2.0) (/ D d)) 2.0) h) 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) {
double t_0 = sqrt((1.0 - (pow(((M_m * D) / (2.0 * d)), 2.0) * (h / l))));
double tmp;
if (t_0 <= 2e+132) {
tmp = w0 * t_0;
} else {
tmp = w0 * sqrt((1.0 - ((pow(((M_m / 2.0) * (D / d)), 2.0) * h) / l)));
}
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) :: t_0
real(8) :: tmp
t_0 = sqrt((1.0d0 - ((((m_m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
if (t_0 <= 2d+132) then
tmp = w0 * t_0
else
tmp = w0 * sqrt((1.0d0 - (((((m_m / 2.0d0) * (d / d_1)) ** 2.0d0) * h) / l)))
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 t_0 = Math.sqrt((1.0 - (Math.pow(((M_m * D) / (2.0 * d)), 2.0) * (h / l))));
double tmp;
if (t_0 <= 2e+132) {
tmp = w0 * t_0;
} else {
tmp = w0 * Math.sqrt((1.0 - ((Math.pow(((M_m / 2.0) * (D / d)), 2.0) * h) / l)));
}
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): t_0 = math.sqrt((1.0 - (math.pow(((M_m * D) / (2.0 * d)), 2.0) * (h / l)))) tmp = 0 if t_0 <= 2e+132: tmp = w0 * t_0 else: tmp = w0 * math.sqrt((1.0 - ((math.pow(((M_m / 2.0) * (D / d)), 2.0) * h) / l))) 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) t_0 = sqrt(Float64(1.0 - Float64((Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)))) tmp = 0.0 if (t_0 <= 2e+132) tmp = Float64(w0 * t_0); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64((Float64(Float64(M_m / 2.0) * Float64(D / d)) ^ 2.0) * h) / l)))); 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)
t_0 = sqrt((1.0 - ((((M_m * D) / (2.0 * d)) ^ 2.0) * (h / l))));
tmp = 0.0;
if (t_0 <= 2e+132)
tmp = w0 * t_0;
else
tmp = w0 * sqrt((1.0 - (((((M_m / 2.0) * (D / d)) ^ 2.0) * h) / l)));
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_] := Block[{t$95$0 = 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]}, If[LessEqual[t$95$0, 2e+132], N[(w0 * t$95$0), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[Power[N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * h), $MachinePrecision] / l), $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])\\
\\
\begin{array}{l}
t_0 := \sqrt{1 - {\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\\
\mathbf{if}\;t\_0 \leq 2 \cdot 10^{+132}:\\
\;\;\;\;w0 \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(\frac{M\_m}{2} \cdot \frac{D}{d}\right)}^{2} \cdot h}{\ell}}\\
\end{array}
\end{array}
if (sqrt.f64 (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)))) < 1.99999999999999998e132Initial program 99.9%
if 1.99999999999999998e132 < (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 40.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
lower-*.f64N/A
lower-pow.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6460.2
Applied rewrites60.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
(let* ((t_0 (sqrt (- 1.0 (* (pow (/ (* M_m D) (* 2.0 d)) 2.0) (/ h l))))))
(if (<= t_0 2e+132)
(* w0 t_0)
(*
w0
(sqrt (/ (- l (* (* (/ (pow (* D M_m) 2.0) d) (/ h d)) 0.25)) 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) {
double t_0 = sqrt((1.0 - (pow(((M_m * D) / (2.0 * d)), 2.0) * (h / l))));
double tmp;
if (t_0 <= 2e+132) {
tmp = w0 * t_0;
} else {
tmp = w0 * sqrt(((l - (((pow((D * M_m), 2.0) / d) * (h / d)) * 0.25)) / l));
}
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) :: t_0
real(8) :: tmp
t_0 = sqrt((1.0d0 - ((((m_m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
if (t_0 <= 2d+132) then
tmp = w0 * t_0
else
tmp = w0 * sqrt(((l - (((((d * m_m) ** 2.0d0) / d_1) * (h / d_1)) * 0.25d0)) / l))
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 t_0 = Math.sqrt((1.0 - (Math.pow(((M_m * D) / (2.0 * d)), 2.0) * (h / l))));
double tmp;
if (t_0 <= 2e+132) {
tmp = w0 * t_0;
} else {
tmp = w0 * Math.sqrt(((l - (((Math.pow((D * M_m), 2.0) / d) * (h / d)) * 0.25)) / l));
}
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): t_0 = math.sqrt((1.0 - (math.pow(((M_m * D) / (2.0 * d)), 2.0) * (h / l)))) tmp = 0 if t_0 <= 2e+132: tmp = w0 * t_0 else: tmp = w0 * math.sqrt(((l - (((math.pow((D * M_m), 2.0) / d) * (h / d)) * 0.25)) / l)) 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) t_0 = sqrt(Float64(1.0 - Float64((Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)))) tmp = 0.0 if (t_0 <= 2e+132) tmp = Float64(w0 * t_0); else tmp = Float64(w0 * sqrt(Float64(Float64(l - Float64(Float64(Float64((Float64(D * M_m) ^ 2.0) / d) * Float64(h / d)) * 0.25)) / l))); 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)
t_0 = sqrt((1.0 - ((((M_m * D) / (2.0 * d)) ^ 2.0) * (h / l))));
tmp = 0.0;
if (t_0 <= 2e+132)
tmp = w0 * t_0;
else
tmp = w0 * sqrt(((l - (((((D * M_m) ^ 2.0) / d) * (h / d)) * 0.25)) / l));
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_] := Block[{t$95$0 = 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]}, If[LessEqual[t$95$0, 2e+132], N[(w0 * t$95$0), $MachinePrecision], N[(w0 * N[Sqrt[N[(N[(l - N[(N[(N[(N[Power[N[(D * M$95$m), $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision] * N[(h / d), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision] / l), $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}
t_0 := \sqrt{1 - {\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\\
\mathbf{if}\;t\_0 \leq 2 \cdot 10^{+132}:\\
\;\;\;\;w0 \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{\frac{\ell - \left(\frac{{\left(D \cdot M\_m\right)}^{2}}{d} \cdot \frac{h}{d}\right) \cdot 0.25}{\ell}}\\
\end{array}
\end{array}
if (sqrt.f64 (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)))) < 1.99999999999999998e132Initial program 99.9%
if 1.99999999999999998e132 < (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 40.9%
Taylor expanded in l around 0
lower-/.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6451.9
Applied rewrites51.9%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow-prod-downN/A
lift-pow.f64N/A
lift-*.f64N/A
lower-/.f6459.8
Applied rewrites59.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 (<= (* (pow (/ (* M_m D) (* 2.0 d)) 2.0) (/ h l)) -2e-6) (* w0 (sqrt (/ (- l (* (* (/ (pow (* D M_m) 2.0) d) (/ h d)) 0.25)) l))) (* w0 (sqrt 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)) <= -2e-6) {
tmp = w0 * sqrt(((l - (((pow((D * M_m), 2.0) / d) * (h / d)) * 0.25)) / l));
} else {
tmp = w0 * sqrt(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)) <= (-2d-6)) then
tmp = w0 * sqrt(((l - (((((d * m_m) ** 2.0d0) / d_1) * (h / d_1)) * 0.25d0)) / l))
else
tmp = w0 * sqrt(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)) <= -2e-6) {
tmp = w0 * Math.sqrt(((l - (((Math.pow((D * M_m), 2.0) / d) * (h / d)) * 0.25)) / l));
} else {
tmp = w0 * Math.sqrt(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)) <= -2e-6: tmp = w0 * math.sqrt(((l - (((math.pow((D * M_m), 2.0) / d) * (h / d)) * 0.25)) / l)) else: tmp = w0 * math.sqrt(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)) <= -2e-6) tmp = Float64(w0 * sqrt(Float64(Float64(l - Float64(Float64(Float64((Float64(D * M_m) ^ 2.0) / d) * Float64(h / d)) * 0.25)) / l))); else tmp = Float64(w0 * sqrt(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)) <= -2e-6)
tmp = w0 * sqrt(((l - (((((D * M_m) ^ 2.0) / d) * (h / d)) * 0.25)) / l));
else
tmp = w0 * sqrt(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], -2e-6], N[(w0 * N[Sqrt[N[(N[(l - N[(N[(N[(N[Power[N[(D * M$95$m), $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision] * N[(h / d), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[1.0], $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}\;{\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{-6}:\\
\;\;\;\;w0 \cdot \sqrt{\frac{\ell - \left(\frac{{\left(D \cdot M\_m\right)}^{2}}{d} \cdot \frac{h}{d}\right) \cdot 0.25}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{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)) < -1.99999999999999991e-6Initial program 63.7%
Taylor expanded in l around 0
lower-/.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6451.0
Applied rewrites51.0%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow-prod-downN/A
lift-pow.f64N/A
lift-*.f64N/A
lower-/.f6458.2
Applied rewrites58.2%
if -1.99999999999999991e-6 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 87.0%
Taylor expanded in M around 0
Applied rewrites95.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)) -2e-6)
(*
w0
(sqrt
(*
(- (pow D -2.0) (/ (* (* (* M_m M_m) (/ 0.25 d)) (/ h d)) l))
(* D D))))
(* w0 (sqrt 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)) <= -2e-6) {
tmp = w0 * sqrt(((pow(D, -2.0) - ((((M_m * M_m) * (0.25 / d)) * (h / d)) / l)) * (D * D)));
} else {
tmp = w0 * sqrt(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)) <= (-2d-6)) then
tmp = w0 * sqrt((((d ** (-2.0d0)) - ((((m_m * m_m) * (0.25d0 / d_1)) * (h / d_1)) / l)) * (d * d)))
else
tmp = w0 * sqrt(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)) <= -2e-6) {
tmp = w0 * Math.sqrt(((Math.pow(D, -2.0) - ((((M_m * M_m) * (0.25 / d)) * (h / d)) / l)) * (D * D)));
} else {
tmp = w0 * Math.sqrt(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)) <= -2e-6: tmp = w0 * math.sqrt(((math.pow(D, -2.0) - ((((M_m * M_m) * (0.25 / d)) * (h / d)) / l)) * (D * D))) else: tmp = w0 * math.sqrt(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)) <= -2e-6) tmp = Float64(w0 * sqrt(Float64(Float64((D ^ -2.0) - Float64(Float64(Float64(Float64(M_m * M_m) * Float64(0.25 / d)) * Float64(h / d)) / l)) * Float64(D * D)))); else tmp = Float64(w0 * sqrt(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)) <= -2e-6)
tmp = w0 * sqrt((((D ^ -2.0) - ((((M_m * M_m) * (0.25 / d)) * (h / d)) / l)) * (D * D)));
else
tmp = w0 * sqrt(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], -2e-6], N[(w0 * N[Sqrt[N[(N[(N[Power[D, -2.0], $MachinePrecision] - N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * N[(0.25 / d), $MachinePrecision]), $MachinePrecision] * N[(h / d), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[1.0], $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}\;{\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{-6}:\\
\;\;\;\;w0 \cdot \sqrt{\left({D}^{-2} - \frac{\left(\left(M\_m \cdot M\_m\right) \cdot \frac{0.25}{d}\right) \cdot \frac{h}{d}}{\ell}\right) \cdot \left(D \cdot D\right)}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{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)) < -1.99999999999999991e-6Initial program 63.7%
Taylor expanded in D around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
pow-flipN/A
lower-pow.f64N/A
metadata-evalN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
Applied rewrites36.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6439.3
Applied rewrites39.3%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-/r*N/A
associate-*r*N/A
pow2N/A
associate-*r*N/A
pow2N/A
pow2N/A
lower-/.f64N/A
Applied rewrites45.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-/l*N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lower-/.f6445.7
Applied rewrites45.7%
if -1.99999999999999991e-6 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 87.0%
Taylor expanded in M around 0
Applied rewrites95.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)) -2e-6)
(*
w0
(sqrt
(*
(- (pow D -2.0) (/ (* 0.25 (* M_m (* M_m h))) (* (* d d) l)))
(* D D))))
(* w0 (sqrt 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)) <= -2e-6) {
tmp = w0 * sqrt(((pow(D, -2.0) - ((0.25 * (M_m * (M_m * h))) / ((d * d) * l))) * (D * D)));
} else {
tmp = w0 * sqrt(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)) <= (-2d-6)) then
tmp = w0 * sqrt((((d ** (-2.0d0)) - ((0.25d0 * (m_m * (m_m * h))) / ((d_1 * d_1) * l))) * (d * d)))
else
tmp = w0 * sqrt(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)) <= -2e-6) {
tmp = w0 * Math.sqrt(((Math.pow(D, -2.0) - ((0.25 * (M_m * (M_m * h))) / ((d * d) * l))) * (D * D)));
} else {
tmp = w0 * Math.sqrt(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)) <= -2e-6: tmp = w0 * math.sqrt(((math.pow(D, -2.0) - ((0.25 * (M_m * (M_m * h))) / ((d * d) * l))) * (D * D))) else: tmp = w0 * math.sqrt(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)) <= -2e-6) tmp = Float64(w0 * sqrt(Float64(Float64((D ^ -2.0) - Float64(Float64(0.25 * Float64(M_m * Float64(M_m * h))) / Float64(Float64(d * d) * l))) * Float64(D * D)))); else tmp = Float64(w0 * sqrt(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)) <= -2e-6)
tmp = w0 * sqrt((((D ^ -2.0) - ((0.25 * (M_m * (M_m * h))) / ((d * d) * l))) * (D * D)));
else
tmp = w0 * sqrt(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], -2e-6], N[(w0 * N[Sqrt[N[(N[(N[Power[D, -2.0], $MachinePrecision] - N[(N[(0.25 * N[(M$95$m * N[(M$95$m * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[1.0], $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}\;{\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{-6}:\\
\;\;\;\;w0 \cdot \sqrt{\left({D}^{-2} - \frac{0.25 \cdot \left(M\_m \cdot \left(M\_m \cdot h\right)\right)}{\left(d \cdot d\right) \cdot \ell}\right) \cdot \left(D \cdot D\right)}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{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)) < -1.99999999999999991e-6Initial program 63.7%
Taylor expanded in D around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
pow-flipN/A
lower-pow.f64N/A
metadata-evalN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
Applied rewrites36.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6439.3
Applied rewrites39.3%
if -1.99999999999999991e-6 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 87.0%
Taylor expanded in M around 0
Applied rewrites95.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)) -2e-6)
(*
w0
(sqrt
(* (* (fma (* (* M_m M_m) (/ h (* (* d d) l))) -0.25 (pow D -2.0)) D) D)))
(* w0 (sqrt 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)) <= -2e-6) {
tmp = w0 * sqrt(((fma(((M_m * M_m) * (h / ((d * d) * l))), -0.25, pow(D, -2.0)) * D) * D));
} else {
tmp = w0 * sqrt(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)) <= -2e-6) tmp = Float64(w0 * sqrt(Float64(Float64(fma(Float64(Float64(M_m * M_m) * Float64(h / Float64(Float64(d * d) * l))), -0.25, (D ^ -2.0)) * D) * D))); else tmp = Float64(w0 * sqrt(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], -2e-6], N[(w0 * N[Sqrt[N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * N[(h / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25 + N[Power[D, -2.0], $MachinePrecision]), $MachinePrecision] * D), $MachinePrecision] * D), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[1.0], $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}\;{\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{-6}:\\
\;\;\;\;w0 \cdot \sqrt{\left(\mathsf{fma}\left(\left(M\_m \cdot M\_m\right) \cdot \frac{h}{\left(d \cdot d\right) \cdot \ell}, -0.25, {D}^{-2}\right) \cdot D\right) \cdot D}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{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)) < -1.99999999999999991e-6Initial program 63.7%
Taylor expanded in D around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
pow-flipN/A
lower-pow.f64N/A
metadata-evalN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
Applied rewrites36.6%
Applied rewrites47.4%
if -1.99999999999999991e-6 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 87.0%
Taylor expanded in M around 0
Applied rewrites95.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)) -2e-6)
(*
w0
(sqrt
(*
(/ (- (/ l (* D D)) (/ (* (* 0.25 (* M_m M_m)) h) (* d d))) l)
(* D D))))
(* w0 (sqrt 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)) <= -2e-6) {
tmp = w0 * sqrt(((((l / (D * D)) - (((0.25 * (M_m * M_m)) * h) / (d * d))) / l) * (D * D)));
} else {
tmp = w0 * sqrt(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)) <= (-2d-6)) then
tmp = w0 * sqrt(((((l / (d * d)) - (((0.25d0 * (m_m * m_m)) * h) / (d_1 * d_1))) / l) * (d * d)))
else
tmp = w0 * sqrt(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)) <= -2e-6) {
tmp = w0 * Math.sqrt(((((l / (D * D)) - (((0.25 * (M_m * M_m)) * h) / (d * d))) / l) * (D * D)));
} else {
tmp = w0 * Math.sqrt(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)) <= -2e-6: tmp = w0 * math.sqrt(((((l / (D * D)) - (((0.25 * (M_m * M_m)) * h) / (d * d))) / l) * (D * D))) else: tmp = w0 * math.sqrt(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)) <= -2e-6) tmp = Float64(w0 * sqrt(Float64(Float64(Float64(Float64(l / Float64(D * D)) - Float64(Float64(Float64(0.25 * Float64(M_m * M_m)) * h) / Float64(d * d))) / l) * Float64(D * D)))); else tmp = Float64(w0 * sqrt(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)) <= -2e-6)
tmp = w0 * sqrt(((((l / (D * D)) - (((0.25 * (M_m * M_m)) * h) / (d * d))) / l) * (D * D)));
else
tmp = w0 * sqrt(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], -2e-6], N[(w0 * N[Sqrt[N[(N[(N[(N[(l / N[(D * D), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(0.25 * N[(M$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[1.0], $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}\;{\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{-6}:\\
\;\;\;\;w0 \cdot \sqrt{\frac{\frac{\ell}{D \cdot D} - \frac{\left(0.25 \cdot \left(M\_m \cdot M\_m\right)\right) \cdot h}{d \cdot d}}{\ell} \cdot \left(D \cdot D\right)}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{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)) < -1.99999999999999991e-6Initial program 63.7%
Taylor expanded in D around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
pow-flipN/A
lower-pow.f64N/A
metadata-evalN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
Applied rewrites36.6%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites36.7%
if -1.99999999999999991e-6 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 87.0%
Taylor expanded in M around 0
Applied rewrites95.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 (* w0 (sqrt 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(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 * sqrt(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 * Math.sqrt(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 * math.sqrt(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(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 * sqrt(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[1.0], $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}
\end{array}
Initial program 80.6%
Taylor expanded in M around 0
Applied rewrites70.2%
herbie shell --seed 2025057
(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))))))