
(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 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(w0, m, d, h, l, d_1)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
code = w0 * sqrt((1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\end{array}
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(let* ((t_0 (* (* 0.5 D_m) (/ M_m d))))
(if (<= (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)) 0.0)
(* w0 (sqrt (- 1.0 (* (* (/ h l) t_0) t_0))))
(*
w0
(sqrt
(fma (* (* (/ -0.25 d) (* D_m (/ M_m d))) (* D_m (/ M_m l))) h 1.0))))))D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double t_0 = (0.5 * D_m) * (M_m / d);
double tmp;
if ((pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= 0.0) {
tmp = w0 * sqrt((1.0 - (((h / l) * t_0) * t_0)));
} else {
tmp = w0 * sqrt(fma((((-0.25 / d) * (D_m * (M_m / d))) * (D_m * (M_m / l))), h, 1.0));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) t_0 = Float64(Float64(0.5 * D_m) * Float64(M_m / d)) tmp = 0.0 if (Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= 0.0) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(h / l) * t_0) * t_0)))); else tmp = Float64(w0 * sqrt(fma(Float64(Float64(Float64(-0.25 / d) * Float64(D_m * Float64(M_m / d))) * Float64(D_m * Float64(M_m / l))), h, 1.0))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := Block[{t$95$0 = N[(N[(0.5 * D$95$m), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], 0.0], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(h / l), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(N[(N[(N[(-0.25 / d), $MachinePrecision] * N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(D$95$m * N[(M$95$m / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * h + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
t_0 := \left(0.5 \cdot D\_m\right) \cdot \frac{M\_m}{d}\\
\mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq 0:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(\frac{h}{\ell} \cdot t\_0\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\left(\frac{-0.25}{d} \cdot \left(D\_m \cdot \frac{M\_m}{d}\right)\right) \cdot \left(D\_m \cdot \frac{M\_m}{\ell}\right), h, 1\right)}\\
\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 86.8%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6488.1
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6486.8
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6487.6
Applied rewrites87.6%
Taylor expanded in D around 0
Applied rewrites87.6%
Taylor expanded in D around 0
Applied rewrites87.6%
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 52.9%
Taylor expanded in d around 0
Applied rewrites44.4%
Applied rewrites56.5%
Taylor expanded in h around inf
Applied rewrites68.3%
Applied rewrites85.8%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(let* ((t_0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l))))
(if (<= t_0 (- INFINITY))
(*
w0
(fma (* (/ -0.125 d) (/ (* (* M_m D_m) (* M_m D_m)) (* d l))) h 1.0))
(if (<= t_0 -2e-9)
(*
w0
(sqrt
(- 1.0 (/ (* (* (* M_m (* 0.25 D_m)) D_m) (* M_m h)) (* (* d d) l)))))
w0))))D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double t_0 = pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = w0 * fma(((-0.125 / d) * (((M_m * D_m) * (M_m * D_m)) / (d * l))), h, 1.0);
} else if (t_0 <= -2e-9) {
tmp = w0 * sqrt((1.0 - ((((M_m * (0.25 * D_m)) * D_m) * (M_m * h)) / ((d * d) * l))));
} else {
tmp = w0;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) t_0 = Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(w0 * fma(Float64(Float64(-0.125 / d) * Float64(Float64(Float64(M_m * D_m) * Float64(M_m * D_m)) / Float64(d * l))), h, 1.0)); elseif (t_0 <= -2e-9) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(M_m * Float64(0.25 * D_m)) * D_m) * Float64(M_m * h)) / Float64(Float64(d * d) * l))))); else tmp = w0; end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := Block[{t$95$0 = N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(w0 * N[(N[(N[(-0.125 / d), $MachinePrecision] * N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * h + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -2e-9], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(M$95$m * N[(0.25 * D$95$m), $MachinePrecision]), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(M$95$m * h), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;w0 \cdot \mathsf{fma}\left(\frac{-0.125}{d} \cdot \frac{\left(M\_m \cdot D\_m\right) \cdot \left(M\_m \cdot D\_m\right)}{d \cdot \ell}, h, 1\right)\\
\mathbf{elif}\;t\_0 \leq -2 \cdot 10^{-9}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(\left(M\_m \cdot \left(0.25 \cdot D\_m\right)\right) \cdot D\_m\right) \cdot \left(M\_m \cdot h\right)}{\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 56.3%
Taylor expanded in M around 0
Applied rewrites39.2%
Applied rewrites46.8%
Taylor expanded in h around inf
Applied rewrites56.2%
if -inf.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -2.00000000000000012e-9Initial program 99.4%
Taylor expanded in d around 0
Applied rewrites16.9%
Applied rewrites33.7%
Applied rewrites48.4%
if -2.00000000000000012e-9 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 90.6%
Taylor expanded in M around 0
Applied rewrites96.5%
Final simplification82.4%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(let* ((t_0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l))))
(if (<= t_0 (- INFINITY))
(*
w0
(fma (* (/ -0.125 d) (/ (* (* M_m D_m) (* M_m D_m)) (* d l))) h 1.0))
(if (<= t_0 -2e-9)
(*
w0
(sqrt
(- 1.0 (/ (* (* 0.25 D_m) (* (* M_m D_m) (* M_m h))) (* (* d d) l)))))
w0))))D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double t_0 = pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = w0 * fma(((-0.125 / d) * (((M_m * D_m) * (M_m * D_m)) / (d * l))), h, 1.0);
} else if (t_0 <= -2e-9) {
tmp = w0 * sqrt((1.0 - (((0.25 * D_m) * ((M_m * D_m) * (M_m * h))) / ((d * d) * l))));
} else {
tmp = w0;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) t_0 = Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(w0 * fma(Float64(Float64(-0.125 / d) * Float64(Float64(Float64(M_m * D_m) * Float64(M_m * D_m)) / Float64(d * l))), h, 1.0)); elseif (t_0 <= -2e-9) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(0.25 * D_m) * Float64(Float64(M_m * D_m) * Float64(M_m * h))) / Float64(Float64(d * d) * l))))); else tmp = w0; end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := Block[{t$95$0 = N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(w0 * N[(N[(N[(-0.125 / d), $MachinePrecision] * N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * h + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -2e-9], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(0.25 * D$95$m), $MachinePrecision] * N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(M$95$m * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;w0 \cdot \mathsf{fma}\left(\frac{-0.125}{d} \cdot \frac{\left(M\_m \cdot D\_m\right) \cdot \left(M\_m \cdot D\_m\right)}{d \cdot \ell}, h, 1\right)\\
\mathbf{elif}\;t\_0 \leq -2 \cdot 10^{-9}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(0.25 \cdot D\_m\right) \cdot \left(\left(M\_m \cdot D\_m\right) \cdot \left(M\_m \cdot h\right)\right)}{\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 56.3%
Taylor expanded in M around 0
Applied rewrites39.2%
Applied rewrites46.8%
Taylor expanded in h around inf
Applied rewrites56.2%
if -inf.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -2.00000000000000012e-9Initial program 99.4%
Taylor expanded in d around 0
Applied rewrites16.9%
Applied rewrites33.7%
Applied rewrites34.1%
Applied rewrites49.3%
if -2.00000000000000012e-9 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 90.6%
Taylor expanded in M around 0
Applied rewrites96.5%
Final simplification82.4%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(let* ((t_0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l))))
(if (<= t_0 (- INFINITY))
(*
w0
(fma (* (/ -0.125 d) (/ (* (* M_m D_m) (* M_m D_m)) (* d l))) h 1.0))
(if (<= t_0 -2e-9)
(*
w0
(sqrt
(fma (* (/ (* (* (* M_m D_m) M_m) D_m) (* (* d d) l)) -0.25) h 1.0)))
w0))))D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double t_0 = pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = w0 * fma(((-0.125 / d) * (((M_m * D_m) * (M_m * D_m)) / (d * l))), h, 1.0);
} else if (t_0 <= -2e-9) {
tmp = w0 * sqrt(fma((((((M_m * D_m) * M_m) * D_m) / ((d * d) * l)) * -0.25), h, 1.0));
} else {
tmp = w0;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) t_0 = Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(w0 * fma(Float64(Float64(-0.125 / d) * Float64(Float64(Float64(M_m * D_m) * Float64(M_m * D_m)) / Float64(d * l))), h, 1.0)); elseif (t_0 <= -2e-9) tmp = Float64(w0 * sqrt(fma(Float64(Float64(Float64(Float64(Float64(M_m * D_m) * M_m) * D_m) / Float64(Float64(d * d) * l)) * -0.25), h, 1.0))); else tmp = w0; end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := Block[{t$95$0 = N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(w0 * N[(N[(N[(-0.125 / d), $MachinePrecision] * N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * h + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -2e-9], N[(w0 * N[Sqrt[N[(N[(N[(N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision] * h + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;w0 \cdot \mathsf{fma}\left(\frac{-0.125}{d} \cdot \frac{\left(M\_m \cdot D\_m\right) \cdot \left(M\_m \cdot D\_m\right)}{d \cdot \ell}, h, 1\right)\\
\mathbf{elif}\;t\_0 \leq -2 \cdot 10^{-9}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\left(\left(M\_m \cdot D\_m\right) \cdot M\_m\right) \cdot D\_m}{\left(d \cdot d\right) \cdot \ell} \cdot -0.25, h, 1\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 56.3%
Taylor expanded in M around 0
Applied rewrites39.2%
Applied rewrites46.8%
Taylor expanded in h around inf
Applied rewrites56.2%
if -inf.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -2.00000000000000012e-9Initial program 99.4%
Taylor expanded in d around 0
Applied rewrites16.9%
Applied rewrites33.7%
Taylor expanded in h around inf
Applied rewrites63.9%
Taylor expanded in M around 0
Applied rewrites58.4%
if -2.00000000000000012e-9 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 90.6%
Taylor expanded in M around 0
Applied rewrites96.5%
Final simplification83.1%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(let* ((t_0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l))))
(if (<= t_0 -2e+284)
(*
w0
(fma (* (/ -0.125 d) (/ (* (* M_m D_m) (* M_m D_m)) (* d l))) h 1.0))
(if (<= t_0 -5e+27)
(*
w0
(sqrt (* -0.25 (* (* D_m D_m) (* (* (/ M_m (* (* d d) l)) h) M_m)))))
w0))))D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double t_0 = pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l);
double tmp;
if (t_0 <= -2e+284) {
tmp = w0 * fma(((-0.125 / d) * (((M_m * D_m) * (M_m * D_m)) / (d * l))), h, 1.0);
} else if (t_0 <= -5e+27) {
tmp = w0 * sqrt((-0.25 * ((D_m * D_m) * (((M_m / ((d * d) * l)) * h) * M_m))));
} else {
tmp = w0;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) t_0 = Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) tmp = 0.0 if (t_0 <= -2e+284) tmp = Float64(w0 * fma(Float64(Float64(-0.125 / d) * Float64(Float64(Float64(M_m * D_m) * Float64(M_m * D_m)) / Float64(d * l))), h, 1.0)); elseif (t_0 <= -5e+27) tmp = Float64(w0 * sqrt(Float64(-0.25 * Float64(Float64(D_m * D_m) * Float64(Float64(Float64(M_m / Float64(Float64(d * d) * l)) * h) * M_m))))); else tmp = w0; end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := Block[{t$95$0 = N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+284], N[(w0 * N[(N[(N[(-0.125 / d), $MachinePrecision] * N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * h + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -5e+27], N[(w0 * N[Sqrt[N[(-0.25 * N[(N[(D$95$m * D$95$m), $MachinePrecision] * N[(N[(N[(M$95$m / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+284}:\\
\;\;\;\;w0 \cdot \mathsf{fma}\left(\frac{-0.125}{d} \cdot \frac{\left(M\_m \cdot D\_m\right) \cdot \left(M\_m \cdot D\_m\right)}{d \cdot \ell}, h, 1\right)\\
\mathbf{elif}\;t\_0 \leq -5 \cdot 10^{+27}:\\
\;\;\;\;w0 \cdot \sqrt{-0.25 \cdot \left(\left(D\_m \cdot D\_m\right) \cdot \left(\left(\frac{M\_m}{\left(d \cdot d\right) \cdot \ell} \cdot h\right) \cdot M\_m\right)\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)) < -2.00000000000000016e284Initial program 57.0%
Taylor expanded in M around 0
Applied rewrites38.7%
Applied rewrites46.2%
Taylor expanded in h around inf
Applied rewrites55.4%
if -2.00000000000000016e284 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -4.99999999999999979e27Initial program 99.6%
Taylor expanded in d around 0
Applied rewrites15.5%
Applied rewrites37.5%
Taylor expanded in h around inf
Applied rewrites65.2%
Taylor expanded in M around inf
Applied rewrites22.8%
if -4.99999999999999979e27 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 90.8%
Taylor expanded in M around 0
Applied rewrites94.9%
Final simplification80.4%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d) :precision binary64 (if (<= (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)) -200000.0) (* w0 (sqrt (/ (* (* (* (* -0.25 (* D_m D_m)) M_m) (/ M_m d)) (/ h l)) d))) w0))
D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if ((pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -200000.0) {
tmp = w0 * sqrt((((((-0.25 * (D_m * D_m)) * M_m) * (M_m / d)) * (h / l)) / d));
} else {
tmp = w0;
}
return tmp;
}
D_m = private
M_m = private
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(w0, m_m, d_m, h, l, d)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
real(8) :: tmp
if (((((m_m * d_m) / (2.0d0 * d)) ** 2.0d0) * (h / l)) <= (-200000.0d0)) then
tmp = w0 * sqrt(((((((-0.25d0) * (d_m * d_m)) * m_m) * (m_m / d)) * (h / l)) / d))
else
tmp = w0
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if ((Math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -200000.0) {
tmp = w0 * Math.sqrt((((((-0.25 * (D_m * D_m)) * M_m) * (M_m / d)) * (h / l)) / d));
} else {
tmp = w0;
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): tmp = 0 if (math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -200000.0: tmp = w0 * math.sqrt((((((-0.25 * (D_m * D_m)) * M_m) * (M_m / d)) * (h / l)) / d)) else: tmp = w0 return tmp
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -200000.0) tmp = Float64(w0 * sqrt(Float64(Float64(Float64(Float64(Float64(-0.25 * Float64(D_m * D_m)) * M_m) * Float64(M_m / d)) * Float64(h / l)) / d))); else tmp = w0; end return tmp end
D_m = abs(D);
M_m = abs(M);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
tmp = 0.0;
if (((((M_m * D_m) / (2.0 * d)) ^ 2.0) * (h / l)) <= -200000.0)
tmp = w0 * sqrt((((((-0.25 * (D_m * D_m)) * M_m) * (M_m / d)) * (h / l)) / d));
else
tmp = w0;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -200000.0], N[(w0 * N[Sqrt[N[(N[(N[(N[(N[(-0.25 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -200000:\\
\;\;\;\;w0 \cdot \sqrt{\frac{\left(\left(\left(-0.25 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot M\_m\right) \cdot \frac{M\_m}{d}\right) \cdot \frac{h}{\ell}}{d}}\\
\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)) < -2e5Initial program 65.4%
Taylor expanded in M around inf
Applied rewrites34.6%
Applied rewrites42.9%
Applied rewrites53.3%
if -2e5 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 90.6%
Taylor expanded in M around 0
Applied rewrites96.3%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(if (<= (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)) -2e-9)
(*
w0
(sqrt (fma (* (/ -0.25 d) (/ (* (* M_m D_m) (* M_m D_m)) (* d l))) h 1.0)))
w0))D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if ((pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -2e-9) {
tmp = w0 * sqrt(fma(((-0.25 / d) * (((M_m * D_m) * (M_m * D_m)) / (d * l))), h, 1.0));
} else {
tmp = w0;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -2e-9) tmp = Float64(w0 * sqrt(fma(Float64(Float64(-0.25 / d) * Float64(Float64(Float64(M_m * D_m) * Float64(M_m * D_m)) / Float64(d * l))), h, 1.0))); else tmp = w0; end return tmp end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -2e-9], N[(w0 * N[Sqrt[N[(N[(N[(-0.25 / d), $MachinePrecision] * N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * h + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{-9}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{-0.25}{d} \cdot \frac{\left(M\_m \cdot D\_m\right) \cdot \left(M\_m \cdot D\_m\right)}{d \cdot \ell}, h, 1\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)) < -2.00000000000000012e-9Initial program 65.8%
Taylor expanded in d around 0
Applied rewrites34.3%
Applied rewrites42.8%
Taylor expanded in h around inf
Applied rewrites59.0%
if -2.00000000000000012e-9 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 90.6%
Taylor expanded in M around 0
Applied rewrites96.5%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d) :precision binary64 (if (<= (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)) -5e+27) (* w0 (sqrt (/ (* (* (* (* -0.25 (* D_m D_m)) M_m) (/ M_m d)) h) (* d l)))) w0))
D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if ((pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -5e+27) {
tmp = w0 * sqrt((((((-0.25 * (D_m * D_m)) * M_m) * (M_m / d)) * h) / (d * l)));
} else {
tmp = w0;
}
return tmp;
}
D_m = private
M_m = private
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(w0, m_m, d_m, h, l, d)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
real(8) :: tmp
if (((((m_m * d_m) / (2.0d0 * d)) ** 2.0d0) * (h / l)) <= (-5d+27)) then
tmp = w0 * sqrt(((((((-0.25d0) * (d_m * d_m)) * m_m) * (m_m / d)) * h) / (d * l)))
else
tmp = w0
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if ((Math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -5e+27) {
tmp = w0 * Math.sqrt((((((-0.25 * (D_m * D_m)) * M_m) * (M_m / d)) * h) / (d * l)));
} else {
tmp = w0;
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): tmp = 0 if (math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -5e+27: tmp = w0 * math.sqrt((((((-0.25 * (D_m * D_m)) * M_m) * (M_m / d)) * h) / (d * l))) else: tmp = w0 return tmp
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -5e+27) tmp = Float64(w0 * sqrt(Float64(Float64(Float64(Float64(Float64(-0.25 * Float64(D_m * D_m)) * M_m) * Float64(M_m / d)) * h) / Float64(d * l)))); else tmp = w0; end return tmp end
D_m = abs(D);
M_m = abs(M);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
tmp = 0.0;
if (((((M_m * D_m) / (2.0 * d)) ^ 2.0) * (h / l)) <= -5e+27)
tmp = w0 * sqrt((((((-0.25 * (D_m * D_m)) * M_m) * (M_m / d)) * h) / (d * l)));
else
tmp = w0;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -5e+27], N[(w0 * N[Sqrt[N[(N[(N[(N[(N[(-0.25 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] / N[(d * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -5 \cdot 10^{+27}:\\
\;\;\;\;w0 \cdot \sqrt{\frac{\left(\left(\left(-0.25 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot M\_m\right) \cdot \frac{M\_m}{d}\right) \cdot h}{d \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)) < -4.99999999999999979e27Initial program 64.2%
Taylor expanded in M around inf
Applied rewrites35.8%
Applied rewrites44.5%
Applied rewrites53.2%
if -4.99999999999999979e27 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 90.8%
Taylor expanded in M around 0
Applied rewrites94.9%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d) :precision binary64 (if (<= (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)) -2e-9) (* w0 (fma (* (/ -0.125 d) (/ (* (* M_m D_m) (* M_m D_m)) (* d l))) h 1.0)) w0))
D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if ((pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -2e-9) {
tmp = w0 * fma(((-0.125 / d) * (((M_m * D_m) * (M_m * D_m)) / (d * l))), h, 1.0);
} else {
tmp = w0;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -2e-9) tmp = Float64(w0 * fma(Float64(Float64(-0.125 / d) * Float64(Float64(Float64(M_m * D_m) * Float64(M_m * D_m)) / Float64(d * l))), h, 1.0)); else tmp = w0; end return tmp end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -2e-9], N[(w0 * N[(N[(N[(-0.125 / d), $MachinePrecision] * N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * h + 1.0), $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{-9}:\\
\;\;\;\;w0 \cdot \mathsf{fma}\left(\frac{-0.125}{d} \cdot \frac{\left(M\_m \cdot D\_m\right) \cdot \left(M\_m \cdot D\_m\right)}{d \cdot \ell}, h, 1\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)) < -2.00000000000000012e-9Initial program 65.8%
Taylor expanded in M around 0
Applied rewrites32.2%
Applied rewrites38.1%
Taylor expanded in h around inf
Applied rewrites47.3%
if -2.00000000000000012e-9 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 90.6%
Taylor expanded in M around 0
Applied rewrites96.5%
Final simplification80.0%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d) :precision binary64 (if (<= (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)) -5e+175) (* w0 (fma (* -0.125 (* D_m D_m)) (* M_m (* h (/ M_m (* (* d l) d)))) 1.0)) w0))
D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if ((pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -5e+175) {
tmp = w0 * fma((-0.125 * (D_m * D_m)), (M_m * (h * (M_m / ((d * l) * d)))), 1.0);
} else {
tmp = w0;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -5e+175) tmp = Float64(w0 * fma(Float64(-0.125 * Float64(D_m * D_m)), Float64(M_m * Float64(h * Float64(M_m / Float64(Float64(d * l) * d)))), 1.0)); else tmp = w0; end return tmp end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -5e+175], N[(w0 * N[(N[(-0.125 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * N[(h * N[(M$95$m / N[(N[(d * l), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -5 \cdot 10^{+175}:\\
\;\;\;\;w0 \cdot \mathsf{fma}\left(-0.125 \cdot \left(D\_m \cdot D\_m\right), M\_m \cdot \left(h \cdot \frac{M\_m}{\left(d \cdot \ell\right) \cdot d}\right), 1\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)) < -5e175Initial program 59.9%
Taylor expanded in M around 0
Applied rewrites36.0%
Applied rewrites40.6%
Applied rewrites42.1%
Applied rewrites44.8%
if -5e175 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 91.2%
Taylor expanded in M around 0
Applied rewrites90.5%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d) :precision binary64 (if (<= (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)) -5e+175) (* w0 (* (* (* -0.125 (* D_m D_m)) M_m) (* (/ M_m (* (* d d) l)) h))) w0))
D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if ((pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -5e+175) {
tmp = w0 * (((-0.125 * (D_m * D_m)) * M_m) * ((M_m / ((d * d) * l)) * h));
} else {
tmp = w0;
}
return tmp;
}
D_m = private
M_m = private
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(w0, m_m, d_m, h, l, d)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
real(8) :: tmp
if (((((m_m * d_m) / (2.0d0 * d)) ** 2.0d0) * (h / l)) <= (-5d+175)) then
tmp = w0 * ((((-0.125d0) * (d_m * d_m)) * m_m) * ((m_m / ((d * d) * l)) * h))
else
tmp = w0
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if ((Math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -5e+175) {
tmp = w0 * (((-0.125 * (D_m * D_m)) * M_m) * ((M_m / ((d * d) * l)) * h));
} else {
tmp = w0;
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): tmp = 0 if (math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)) <= -5e+175: tmp = w0 * (((-0.125 * (D_m * D_m)) * M_m) * ((M_m / ((d * d) * l)) * h)) else: tmp = w0 return tmp
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) <= -5e+175) tmp = Float64(w0 * Float64(Float64(Float64(-0.125 * Float64(D_m * D_m)) * M_m) * Float64(Float64(M_m / Float64(Float64(d * d) * l)) * h))); else tmp = w0; end return tmp end
D_m = abs(D);
M_m = abs(M);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
tmp = 0.0;
if (((((M_m * D_m) / (2.0 * d)) ^ 2.0) * (h / l)) <= -5e+175)
tmp = w0 * (((-0.125 * (D_m * D_m)) * M_m) * ((M_m / ((d * d) * l)) * h));
else
tmp = w0;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -5e+175], N[(w0 * N[(N[(N[(-0.125 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(N[(M$95$m / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -5 \cdot 10^{+175}:\\
\;\;\;\;w0 \cdot \left(\left(\left(-0.125 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot M\_m\right) \cdot \left(\frac{M\_m}{\left(d \cdot d\right) \cdot \ell} \cdot h\right)\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)) < -5e175Initial program 59.9%
Taylor expanded in M around 0
Applied rewrites36.0%
Applied rewrites40.6%
Applied rewrites48.8%
Taylor expanded in M around inf
Applied rewrites43.5%
if -5e175 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 91.2%
Taylor expanded in M around 0
Applied rewrites90.5%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(if (<= (/ (* M_m D_m) (* 2.0 d)) 5e+63)
(*
w0
(sqrt (fma (* (* (/ -0.25 d) (* D_m (/ M_m d))) (* D_m (/ M_m l))) h 1.0)))
(*
w0
(sqrt
(-
1.0
(* (/ (* (* M_m D_m) h) (* (* d 2.0) l)) (* (* 0.5 D_m) (/ M_m d))))))))D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (((M_m * D_m) / (2.0 * d)) <= 5e+63) {
tmp = w0 * sqrt(fma((((-0.25 / d) * (D_m * (M_m / d))) * (D_m * (M_m / l))), h, 1.0));
} else {
tmp = w0 * sqrt((1.0 - ((((M_m * D_m) * h) / ((d * 2.0) * l)) * ((0.5 * D_m) * (M_m / d)))));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) <= 5e+63) tmp = Float64(w0 * sqrt(fma(Float64(Float64(Float64(-0.25 / d) * Float64(D_m * Float64(M_m / d))) * Float64(D_m * Float64(M_m / l))), h, 1.0))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(M_m * D_m) * h) / Float64(Float64(d * 2.0) * l)) * Float64(Float64(0.5 * D_m) * Float64(M_m / d)))))); end return tmp end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 5e+63], N[(w0 * N[Sqrt[N[(N[(N[(N[(-0.25 / d), $MachinePrecision] * N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(D$95$m * N[(M$95$m / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * h + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * h), $MachinePrecision] / N[(N[(d * 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * N[(N[(0.5 * D$95$m), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{M\_m \cdot D\_m}{2 \cdot d} \leq 5 \cdot 10^{+63}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\left(\frac{-0.25}{d} \cdot \left(D\_m \cdot \frac{M\_m}{d}\right)\right) \cdot \left(D\_m \cdot \frac{M\_m}{\ell}\right), h, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(M\_m \cdot D\_m\right) \cdot h}{\left(d \cdot 2\right) \cdot \ell} \cdot \left(\left(0.5 \cdot D\_m\right) \cdot \frac{M\_m}{d}\right)}\\
\end{array}
\end{array}
if (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) < 5.00000000000000011e63Initial program 85.8%
Taylor expanded in d around 0
Applied rewrites53.0%
Applied rewrites60.3%
Taylor expanded in h around inf
Applied rewrites80.8%
Applied rewrites84.7%
if 5.00000000000000011e63 < (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) Initial program 64.6%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6469.1
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6466.9
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6469.2
Applied rewrites69.2%
Taylor expanded in D around 0
Applied rewrites69.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6466.9
Applied rewrites66.9%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d) :precision binary64 (* w0 (sqrt (fma (* (* (/ -0.25 d) (* D_m (/ M_m d))) (* D_m (/ M_m l))) h 1.0))))
D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0 * sqrt(fma((((-0.25 / d) * (D_m * (M_m / d))) * (D_m * (M_m / l))), h, 1.0));
}
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) return Float64(w0 * sqrt(fma(Float64(Float64(Float64(-0.25 / d) * Float64(D_m * Float64(M_m / d))) * Float64(D_m * Float64(M_m / l))), h, 1.0))) end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(N[(N[(N[(-0.25 / d), $MachinePrecision] * N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(D$95$m * N[(M$95$m / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * h + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
w0 \cdot \sqrt{\mathsf{fma}\left(\left(\frac{-0.25}{d} \cdot \left(D\_m \cdot \frac{M\_m}{d}\right)\right) \cdot \left(D\_m \cdot \frac{M\_m}{\ell}\right), h, 1\right)}
\end{array}
Initial program 82.3%
Taylor expanded in d around 0
Applied rewrites52.2%
Applied rewrites59.4%
Taylor expanded in h around inf
Applied rewrites77.7%
Applied rewrites82.1%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d) :precision binary64 w0)
D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0;
}
D_m = private
M_m = private
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(w0, m_m, d_m, h, l, d)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
code = w0
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0;
}
D_m = math.fabs(D) M_m = math.fabs(M) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): return w0
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) return w0 end
D_m = abs(D);
M_m = abs(M);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp = code(w0, M_m, D_m, h, l, d)
tmp = w0;
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := w0
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
w0
\end{array}
Initial program 82.3%
Taylor expanded in M around 0
Applied rewrites66.2%
herbie shell --seed 2025018
(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))))))