
(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 (* (/ D_m 2.0) (/ M_m d))))
(if (<=
(* w0 (sqrt (- 1.0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)))))
INFINITY)
(* w0 (sqrt (- 1.0 (* (* (/ h l) t_0) t_0))))
(*
w0
(sqrt
(fma (* h -0.25) (* (/ D_m (* l d)) (* (* (/ M_m d) M_m) D_m)) 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 = (D_m / 2.0) * (M_m / d);
double tmp;
if ((w0 * sqrt((1.0 - (pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l))))) <= ((double) INFINITY)) {
tmp = w0 * sqrt((1.0 - (((h / l) * t_0) * t_0)));
} else {
tmp = w0 * sqrt(fma((h * -0.25), ((D_m / (l * d)) * (((M_m / d) * M_m) * D_m)), 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(D_m / 2.0) * Float64(M_m / d)) tmp = 0.0 if (Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))))) <= Inf) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(h / l) * t_0) * t_0)))); else tmp = Float64(w0 * sqrt(fma(Float64(h * -0.25), Float64(Float64(D_m / Float64(l * d)) * Float64(Float64(Float64(M_m / d) * M_m) * D_m)), 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[(D$95$m / 2.0), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], Infinity], 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[(h * -0.25), $MachinePrecision] * N[(N[(D$95$m / N[(l * d), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
t_0 := \frac{D\_m}{2} \cdot \frac{M\_m}{d}\\
\mathbf{if}\;w0 \cdot \sqrt{1 - {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq \infty:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(\frac{h}{\ell} \cdot t\_0\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(h \cdot -0.25, \frac{D\_m}{\ell \cdot d} \cdot \left(\left(\frac{M\_m}{d} \cdot M\_m\right) \cdot D\_m\right), 1\right)}\\
\end{array}
\end{array}
if (*.f64 w0 (sqrt.f64 (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))))) < +inf.0Initial program 88.1%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6489.8
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/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-/.f6488.9
Applied rewrites88.9%
if +inf.0 < (*.f64 w0 (sqrt.f64 (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l))))) Initial program 0.0%
Taylor expanded in h around inf
Applied rewrites73.3%
Applied rewrites73.3%
Applied rewrites86.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
(let* ((t_0 (sqrt (- 1.0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l))))))
(if (<= t_0 2.0)
w0
(if (<= t_0 4e+78)
(*
w0
(sqrt
(fma (* h -0.25) (* M_m (/ (* (* D_m M_m) D_m) (* (* l d) d))) 1.0)))
(*
w0
(fma
(* (* (/ M_m (* l d)) (/ (* M_m h) d)) D_m)
(* -0.125 D_m)
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 = sqrt((1.0 - (pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l))));
double tmp;
if (t_0 <= 2.0) {
tmp = w0;
} else if (t_0 <= 4e+78) {
tmp = w0 * sqrt(fma((h * -0.25), (M_m * (((D_m * M_m) * D_m) / ((l * d) * d))), 1.0));
} else {
tmp = w0 * fma((((M_m / (l * d)) * ((M_m * h) / d)) * D_m), (-0.125 * D_m), 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 = sqrt(Float64(1.0 - Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)))) tmp = 0.0 if (t_0 <= 2.0) tmp = w0; elseif (t_0 <= 4e+78) tmp = Float64(w0 * sqrt(fma(Float64(h * -0.25), Float64(M_m * Float64(Float64(Float64(D_m * M_m) * D_m) / Float64(Float64(l * d) * d))), 1.0))); else tmp = Float64(w0 * fma(Float64(Float64(Float64(M_m / Float64(l * d)) * Float64(Float64(M_m * h) / d)) * D_m), Float64(-0.125 * D_m), 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[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 2.0], w0, If[LessEqual[t$95$0, 4e+78], N[(w0 * N[Sqrt[N[(N[(h * -0.25), $MachinePrecision] * N[(M$95$m * N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] / N[(N[(l * d), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[(N[(N[(N[(M$95$m / N[(l * d), $MachinePrecision]), $MachinePrecision] * N[(N[(M$95$m * h), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(-0.125 * D$95$m), $MachinePrecision] + 1.0), $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 := \sqrt{1 - {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}\\
\mathbf{if}\;t\_0 \leq 2:\\
\;\;\;\;w0\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+78}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(h \cdot -0.25, M\_m \cdot \frac{\left(D\_m \cdot M\_m\right) \cdot D\_m}{\left(\ell \cdot d\right) \cdot d}, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \mathsf{fma}\left(\left(\frac{M\_m}{\ell \cdot d} \cdot \frac{M\_m \cdot h}{d}\right) \cdot D\_m, -0.125 \cdot D\_m, 1\right)\\
\end{array}
\end{array}
if (sqrt.f64 (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)))) < 2Initial program 100.0%
Taylor expanded in M around 0
Applied rewrites99.6%
if 2 < (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)))) < 4.00000000000000003e78Initial program 99.4%
Taylor expanded in h around inf
Applied rewrites23.2%
Applied rewrites24.0%
Applied rewrites53.6%
Applied rewrites49.8%
if 4.00000000000000003e78 < (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.2%
Taylor expanded in M around 0
Applied rewrites46.5%
Applied rewrites56.7%
Applied rewrites49.2%
Applied rewrites61.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
(if (<=
(sqrt (- 1.0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l))))
50000000.0)
w0
(*
w0
(sqrt
(fma (* (* -0.25 h) (* (* (/ M_m d) (/ D_m d)) M_m)) (/ D_m l) 1.0)))))D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (sqrt((1.0 - (pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)))) <= 50000000.0) {
tmp = w0;
} else {
tmp = w0 * sqrt(fma(((-0.25 * h) * (((M_m / d) * (D_m / d)) * M_m)), (D_m / l), 1.0));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (sqrt(Float64(1.0 - Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)))) <= 50000000.0) tmp = w0; else tmp = Float64(w0 * sqrt(fma(Float64(Float64(-0.25 * h) * Float64(Float64(Float64(M_m / d) * Float64(D_m / d)) * M_m)), Float64(D_m / l), 1.0))); end return tmp end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 50000000.0], w0, N[(w0 * N[Sqrt[N[(N[(N[(-0.25 * h), $MachinePrecision] * N[(N[(N[(M$95$m / d), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] * N[(D$95$m / l), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;\sqrt{1 - {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq 50000000:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\left(-0.25 \cdot h\right) \cdot \left(\left(\frac{M\_m}{d} \cdot \frac{D\_m}{d}\right) \cdot M\_m\right), \frac{D\_m}{\ell}, 1\right)}\\
\end{array}
\end{array}
if (sqrt.f64 (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)))) < 5e7Initial program 100.0%
Taylor expanded in M around 0
Applied rewrites99.1%
if 5e7 < (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 48.2%
Taylor expanded in h around inf
Applied rewrites44.2%
Applied rewrites59.9%
Applied rewrites61.7%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(if (<= (sqrt (- 1.0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)))) 2.0)
w0
(*
w0
(sqrt
(fma (* h -0.25) (* (/ D_m (* l d)) (* (* (/ M_m d) M_m) D_m)) 1.0)))))D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (sqrt((1.0 - (pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l)))) <= 2.0) {
tmp = w0;
} else {
tmp = w0 * sqrt(fma((h * -0.25), ((D_m / (l * d)) * (((M_m / d) * M_m) * D_m)), 1.0));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (sqrt(Float64(1.0 - Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)))) <= 2.0) tmp = w0; else tmp = Float64(w0 * sqrt(fma(Float64(h * -0.25), Float64(Float64(D_m / Float64(l * d)) * Float64(Float64(Float64(M_m / d) * M_m) * D_m)), 1.0))); end return tmp end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], w0, N[(w0 * N[Sqrt[N[(N[(h * -0.25), $MachinePrecision] * N[(N[(D$95$m / N[(l * d), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;\sqrt{1 - {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq 2:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(h \cdot -0.25, \frac{D\_m}{\ell \cdot d} \cdot \left(\left(\frac{M\_m}{d} \cdot M\_m\right) \cdot D\_m\right), 1\right)}\\
\end{array}
\end{array}
if (sqrt.f64 (-.f64 #s(literal 1 binary64) (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)))) < 2Initial program 100.0%
Taylor expanded in M around 0
Applied rewrites99.6%
if 2 < (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 48.7%
Taylor expanded in h around inf
Applied rewrites43.8%
Applied rewrites49.0%
Applied rewrites58.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) 0.0002)
(*
w0
(sqrt (fma (* h -0.25) (/ (* (* (/ D_m d) M_m) (* D_m M_m)) (* l d)) 1.0)))
(*
w0
(sqrt
(fma (* (* -0.25 h) (/ (* (* (/ M_m d) M_m) D_m) d)) (/ D_m l) 1.0)))))D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (pow(((M_m * D_m) / (2.0 * d)), 2.0) <= 0.0002) {
tmp = w0 * sqrt(fma((h * -0.25), ((((D_m / d) * M_m) * (D_m * M_m)) / (l * d)), 1.0));
} else {
tmp = w0 * sqrt(fma(((-0.25 * h) * ((((M_m / d) * M_m) * D_m) / d)), (D_m / l), 1.0));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if ((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) <= 0.0002) tmp = Float64(w0 * sqrt(fma(Float64(h * -0.25), Float64(Float64(Float64(Float64(D_m / d) * M_m) * Float64(D_m * M_m)) / Float64(l * d)), 1.0))); else tmp = Float64(w0 * sqrt(fma(Float64(Float64(-0.25 * h) * Float64(Float64(Float64(Float64(M_m / d) * M_m) * D_m) / d)), Float64(D_m / l), 1.0))); end return tmp end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], 0.0002], N[(w0 * N[Sqrt[N[(N[(h * -0.25), $MachinePrecision] * N[(N[(N[(N[(D$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(N[(N[(-0.25 * h), $MachinePrecision] * N[(N[(N[(N[(M$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(D$95$m / l), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \leq 0.0002:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(h \cdot -0.25, \frac{\left(\frac{D\_m}{d} \cdot M\_m\right) \cdot \left(D\_m \cdot M\_m\right)}{\ell \cdot d}, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\left(-0.25 \cdot h\right) \cdot \frac{\left(\frac{M\_m}{d} \cdot M\_m\right) \cdot D\_m}{d}, \frac{D\_m}{\ell}, 1\right)}\\
\end{array}
\end{array}
if (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) < 2.0000000000000001e-4Initial program 92.7%
Taylor expanded in h around inf
Applied rewrites75.8%
Applied rewrites77.6%
Applied rewrites88.6%
Applied rewrites97.2%
if 2.0000000000000001e-4 < (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) Initial program 59.0%
Taylor expanded in h around inf
Applied rewrites38.2%
Applied rewrites55.9%
Applied rewrites57.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 (if (<= (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)) -5e+156) (* w0 (fma (* (* D_m D_m) -0.125) (* (/ M_m d) (/ (* h M_m) (* 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+156) {
tmp = w0 * fma(((D_m * D_m) * -0.125), ((M_m / d) * ((h * M_m) / (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+156) tmp = Float64(w0 * fma(Float64(Float64(D_m * D_m) * -0.125), Float64(Float64(M_m / d) * Float64(Float64(h * M_m) / Float64(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+156], N[(w0 * N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * -0.125), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * N[(N[(h * M$95$m), $MachinePrecision] / N[(l * d), $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^{+156}:\\
\;\;\;\;w0 \cdot \mathsf{fma}\left(\left(D\_m \cdot D\_m\right) \cdot -0.125, \frac{M\_m}{d} \cdot \frac{h \cdot M\_m}{\ell \cdot d}, 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)) < -4.99999999999999992e156Initial program 55.4%
Taylor expanded in M around 0
Applied rewrites38.3%
Applied rewrites48.8%
Applied rewrites48.9%
if -4.99999999999999992e156 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 88.6%
Taylor expanded in M around 0
Applied rewrites90.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)) -4e+163) (* w0 (fma (* (* D_m D_m) -0.125) (* M_m (/ (* M_m h) (* (* l d) 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)) <= -4e+163) {
tmp = w0 * fma(((D_m * D_m) * -0.125), (M_m * ((M_m * h) / ((l * d) * 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)) <= -4e+163) tmp = Float64(w0 * fma(Float64(Float64(D_m * D_m) * -0.125), Float64(M_m * Float64(Float64(M_m * h) / Float64(Float64(l * d) * 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], -4e+163], N[(w0 * N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * -0.125), $MachinePrecision] * N[(M$95$m * N[(N[(M$95$m * h), $MachinePrecision] / N[(N[(l * d), $MachinePrecision] * d), $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 -4 \cdot 10^{+163}:\\
\;\;\;\;w0 \cdot \mathsf{fma}\left(\left(D\_m \cdot D\_m\right) \cdot -0.125, M\_m \cdot \frac{M\_m \cdot h}{\left(\ell \cdot d\right) \cdot d}, 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)) < -3.9999999999999998e163Initial program 54.7%
Taylor expanded in M around 0
Applied rewrites38.9%
Applied rewrites49.5%
Applied rewrites42.6%
Applied rewrites44.5%
if -3.9999999999999998e163 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 88.7%
Taylor expanded in M around 0
Applied rewrites90.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)) -4e+163) (* w0 (* -0.125 (* (* M_m M_m) (* (* D_m D_m) (/ h (* (* l d) 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)) <= -4e+163) {
tmp = w0 * (-0.125 * ((M_m * M_m) * ((D_m * D_m) * (h / ((l * d) * 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)) <= (-4d+163)) then
tmp = w0 * ((-0.125d0) * ((m_m * m_m) * ((d_m * d_m) * (h / ((l * d) * 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)) <= -4e+163) {
tmp = w0 * (-0.125 * ((M_m * M_m) * ((D_m * D_m) * (h / ((l * d) * 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)) <= -4e+163: tmp = w0 * (-0.125 * ((M_m * M_m) * ((D_m * D_m) * (h / ((l * d) * 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)) <= -4e+163) tmp = Float64(w0 * Float64(-0.125 * Float64(Float64(M_m * M_m) * Float64(Float64(D_m * D_m) * Float64(h / Float64(Float64(l * d) * 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)) <= -4e+163)
tmp = w0 * (-0.125 * ((M_m * M_m) * ((D_m * D_m) * (h / ((l * d) * 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], -4e+163], N[(w0 * N[(-0.125 * N[(N[(M$95$m * M$95$m), $MachinePrecision] * N[(N[(D$95$m * D$95$m), $MachinePrecision] * N[(h / N[(N[(l * d), $MachinePrecision] * d), $MachinePrecision]), $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}
\mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell} \leq -4 \cdot 10^{+163}:\\
\;\;\;\;w0 \cdot \left(-0.125 \cdot \left(\left(M\_m \cdot M\_m\right) \cdot \left(\left(D\_m \cdot D\_m\right) \cdot \frac{h}{\left(\ell \cdot d\right) \cdot d}\right)\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)) < -3.9999999999999998e163Initial program 54.7%
Taylor expanded in M around 0
Applied rewrites38.9%
Taylor expanded in M around inf
Applied rewrites37.8%
Applied rewrites42.8%
if -3.9999999999999998e163 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 88.7%
Taylor expanded in M around 0
Applied rewrites90.4%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(if (<= (* M_m D_m) 1e-120)
(*
w0
(sqrt (/ (- l (/ (* (* (* (* 0.25 (* D_m D_m)) M_m) (/ M_m d)) h) d)) l)))
(if (<= (* M_m D_m) 1.5e+146)
(*
w0
(sqrt
(fma (* h -0.25) (/ (* (* M_m D_m) (* M_m D_m)) (* (* d l) d)) 1.0)))
(*
w0
(sqrt
(fma (* (* -0.25 h) (* (* (/ M_m d) (/ D_m d)) M_m)) (/ D_m l) 1.0))))))D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if ((M_m * D_m) <= 1e-120) {
tmp = w0 * sqrt(((l - (((((0.25 * (D_m * D_m)) * M_m) * (M_m / d)) * h) / d)) / l));
} else if ((M_m * D_m) <= 1.5e+146) {
tmp = w0 * sqrt(fma((h * -0.25), (((M_m * D_m) * (M_m * D_m)) / ((d * l) * d)), 1.0));
} else {
tmp = w0 * sqrt(fma(((-0.25 * h) * (((M_m / d) * (D_m / d)) * M_m)), (D_m / l), 1.0));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (Float64(M_m * D_m) <= 1e-120) tmp = Float64(w0 * sqrt(Float64(Float64(l - Float64(Float64(Float64(Float64(Float64(0.25 * Float64(D_m * D_m)) * M_m) * Float64(M_m / d)) * h) / d)) / l))); elseif (Float64(M_m * D_m) <= 1.5e+146) tmp = Float64(w0 * sqrt(fma(Float64(h * -0.25), Float64(Float64(Float64(M_m * D_m) * Float64(M_m * D_m)) / Float64(Float64(d * l) * d)), 1.0))); else tmp = Float64(w0 * sqrt(fma(Float64(Float64(-0.25 * h) * Float64(Float64(Float64(M_m / d) * Float64(D_m / d)) * M_m)), Float64(D_m / l), 1.0))); end return tmp end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 1e-120], N[(w0 * N[Sqrt[N[(N[(l - 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] / d), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 1.5e+146], N[(w0 * N[Sqrt[N[(N[(h * -0.25), $MachinePrecision] * N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(d * l), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(N[(N[(-0.25 * h), $MachinePrecision] * N[(N[(N[(M$95$m / d), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] * N[(D$95$m / l), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \cdot D\_m \leq 10^{-120}:\\
\;\;\;\;w0 \cdot \sqrt{\frac{\ell - \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}}{\ell}}\\
\mathbf{elif}\;M\_m \cdot D\_m \leq 1.5 \cdot 10^{+146}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(h \cdot -0.25, \frac{\left(M\_m \cdot D\_m\right) \cdot \left(M\_m \cdot D\_m\right)}{\left(d \cdot \ell\right) \cdot d}, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\left(-0.25 \cdot h\right) \cdot \left(\left(\frac{M\_m}{d} \cdot \frac{D\_m}{d}\right) \cdot M\_m\right), \frac{D\_m}{\ell}, 1\right)}\\
\end{array}
\end{array}
if (*.f64 M D) < 9.99999999999999979e-121Initial program 80.8%
Taylor expanded in l around 0
Applied rewrites68.1%
Applied rewrites78.6%
if 9.99999999999999979e-121 < (*.f64 M D) < 1.50000000000000001e146Initial program 87.9%
Taylor expanded in h around inf
Applied rewrites71.4%
Applied rewrites77.5%
Applied rewrites90.0%
if 1.50000000000000001e146 < (*.f64 M D) Initial program 67.1%
Taylor expanded in h around inf
Applied rewrites35.6%
Applied rewrites60.1%
Applied rewrites67.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 (<= (/ h l) -2e-143)
(*
w0
(sqrt (fma (* h -0.25) (/ (* (* (/ D_m d) M_m) (* D_m M_m)) (* l d)) 1.0)))
(*
w0
(sqrt
(fma (* h -0.25) (* (/ D_m (* l d)) (* (* (/ M_m d) M_m) D_m)) 1.0)))))D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if ((h / l) <= -2e-143) {
tmp = w0 * sqrt(fma((h * -0.25), ((((D_m / d) * M_m) * (D_m * M_m)) / (l * d)), 1.0));
} else {
tmp = w0 * sqrt(fma((h * -0.25), ((D_m / (l * d)) * (((M_m / d) * M_m) * D_m)), 1.0));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (Float64(h / l) <= -2e-143) tmp = Float64(w0 * sqrt(fma(Float64(h * -0.25), Float64(Float64(Float64(Float64(D_m / d) * M_m) * Float64(D_m * M_m)) / Float64(l * d)), 1.0))); else tmp = Float64(w0 * sqrt(fma(Float64(h * -0.25), Float64(Float64(D_m / Float64(l * d)) * Float64(Float64(Float64(M_m / d) * M_m) * D_m)), 1.0))); end return tmp end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(h / l), $MachinePrecision], -2e-143], N[(w0 * N[Sqrt[N[(N[(h * -0.25), $MachinePrecision] * N[(N[(N[(N[(D$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(N[(h * -0.25), $MachinePrecision] * N[(N[(D$95$m / N[(l * d), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{h}{\ell} \leq -2 \cdot 10^{-143}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(h \cdot -0.25, \frac{\left(\frac{D\_m}{d} \cdot M\_m\right) \cdot \left(D\_m \cdot M\_m\right)}{\ell \cdot d}, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(h \cdot -0.25, \frac{D\_m}{\ell \cdot d} \cdot \left(\left(\frac{M\_m}{d} \cdot M\_m\right) \cdot D\_m\right), 1\right)}\\
\end{array}
\end{array}
if (/.f64 h l) < -1.9999999999999999e-143Initial program 78.2%
Taylor expanded in h around inf
Applied rewrites59.1%
Applied rewrites61.9%
Applied rewrites68.0%
Applied rewrites75.4%
if -1.9999999999999999e-143 < (/.f64 h l) Initial program 82.5%
Taylor expanded in h around inf
Applied rewrites64.9%
Applied rewrites68.4%
Applied rewrites86.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
(if (<= (* M_m D_m) 1e-120)
w0
(if (<= (* M_m D_m) 2e+148)
(*
w0
(sqrt
(fma (* h -0.25) (/ (* (* M_m D_m) (* M_m D_m)) (* (* d l) d)) 1.0)))
(*
w0
(fma (* (* (/ M_m (* l d)) (/ (* M_m h) d)) D_m) (* -0.125 D_m) 1.0)))))D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if ((M_m * D_m) <= 1e-120) {
tmp = w0;
} else if ((M_m * D_m) <= 2e+148) {
tmp = w0 * sqrt(fma((h * -0.25), (((M_m * D_m) * (M_m * D_m)) / ((d * l) * d)), 1.0));
} else {
tmp = w0 * fma((((M_m / (l * d)) * ((M_m * h) / d)) * D_m), (-0.125 * D_m), 1.0);
}
return tmp;
}
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (Float64(M_m * D_m) <= 1e-120) tmp = w0; elseif (Float64(M_m * D_m) <= 2e+148) tmp = Float64(w0 * sqrt(fma(Float64(h * -0.25), Float64(Float64(Float64(M_m * D_m) * Float64(M_m * D_m)) / Float64(Float64(d * l) * d)), 1.0))); else tmp = Float64(w0 * fma(Float64(Float64(Float64(M_m / Float64(l * d)) * Float64(Float64(M_m * h) / d)) * D_m), Float64(-0.125 * D_m), 1.0)); end return tmp end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 1e-120], w0, If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 2e+148], N[(w0 * N[Sqrt[N[(N[(h * -0.25), $MachinePrecision] * N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(d * l), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[(N[(N[(N[(M$95$m / N[(l * d), $MachinePrecision]), $MachinePrecision] * N[(N[(M$95$m * h), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(-0.125 * D$95$m), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \cdot D\_m \leq 10^{-120}:\\
\;\;\;\;w0\\
\mathbf{elif}\;M\_m \cdot D\_m \leq 2 \cdot 10^{+148}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(h \cdot -0.25, \frac{\left(M\_m \cdot D\_m\right) \cdot \left(M\_m \cdot D\_m\right)}{\left(d \cdot \ell\right) \cdot d}, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \mathsf{fma}\left(\left(\frac{M\_m}{\ell \cdot d} \cdot \frac{M\_m \cdot h}{d}\right) \cdot D\_m, -0.125 \cdot D\_m, 1\right)\\
\end{array}
\end{array}
if (*.f64 M D) < 9.99999999999999979e-121Initial program 80.8%
Taylor expanded in M around 0
Applied rewrites77.4%
if 9.99999999999999979e-121 < (*.f64 M D) < 2.0000000000000001e148Initial program 88.1%
Taylor expanded in h around inf
Applied rewrites71.9%
Applied rewrites77.9%
Applied rewrites90.2%
if 2.0000000000000001e148 < (*.f64 M D) Initial program 65.9%
Taylor expanded in M around 0
Applied rewrites33.3%
Applied rewrites41.4%
Applied rewrites33.6%
Applied rewrites55.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 (<= D_m 1.05e+96)
(*
w0
(sqrt (fma (* h -0.25) (* (* (/ M_m d) M_m) (/ (* D_m D_m) (* d l))) 1.0)))
(*
w0
(fma (* (* (/ M_m (* l d)) (/ (* M_m h) d)) D_m) (* -0.125 D_m) 1.0))))D_m = fabs(D);
M_m = fabs(M);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (D_m <= 1.05e+96) {
tmp = w0 * sqrt(fma((h * -0.25), (((M_m / d) * M_m) * ((D_m * D_m) / (d * l))), 1.0));
} else {
tmp = w0 * fma((((M_m / (l * d)) * ((M_m * h) / d)) * D_m), (-0.125 * D_m), 1.0);
}
return tmp;
}
D_m = abs(D) M_m = abs(M) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (D_m <= 1.05e+96) tmp = Float64(w0 * sqrt(fma(Float64(h * -0.25), Float64(Float64(Float64(M_m / d) * M_m) * Float64(Float64(D_m * D_m) / Float64(d * l))), 1.0))); else tmp = Float64(w0 * fma(Float64(Float64(Float64(M_m / Float64(l * d)) * Float64(Float64(M_m * h) / d)) * D_m), Float64(-0.125 * D_m), 1.0)); end return tmp end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[D$95$m, 1.05e+96], N[(w0 * N[Sqrt[N[(N[(h * -0.25), $MachinePrecision] * N[(N[(N[(M$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(N[(D$95$m * D$95$m), $MachinePrecision] / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[(N[(N[(N[(M$95$m / N[(l * d), $MachinePrecision]), $MachinePrecision] * N[(N[(M$95$m * h), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(-0.125 * D$95$m), $MachinePrecision] + 1.0), $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}\;D\_m \leq 1.05 \cdot 10^{+96}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(h \cdot -0.25, \left(\frac{M\_m}{d} \cdot M\_m\right) \cdot \frac{D\_m \cdot D\_m}{d \cdot \ell}, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \mathsf{fma}\left(\left(\frac{M\_m}{\ell \cdot d} \cdot \frac{M\_m \cdot h}{d}\right) \cdot D\_m, -0.125 \cdot D\_m, 1\right)\\
\end{array}
\end{array}
if D < 1.0500000000000001e96Initial program 81.8%
Taylor expanded in h around inf
Applied rewrites62.8%
Applied rewrites72.8%
if 1.0500000000000001e96 < D Initial program 72.9%
Taylor expanded in M around 0
Applied rewrites31.2%
Applied rewrites37.1%
Applied rewrites31.5%
Applied rewrites73.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 (* w0 (fma (* (* (/ M_m (* l d)) (/ (* M_m h) d)) D_m) (* -0.125 D_m) 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 * fma((((M_m / (l * d)) * ((M_m * h) / d)) * D_m), (-0.125 * D_m), 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 * fma(Float64(Float64(Float64(M_m / Float64(l * d)) * Float64(Float64(M_m * h) / d)) * D_m), Float64(-0.125 * D_m), 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[(N[(N[(N[(M$95$m / N[(l * d), $MachinePrecision]), $MachinePrecision] * N[(N[(M$95$m * h), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(-0.125 * D$95$m), $MachinePrecision] + 1.0), $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 \mathsf{fma}\left(\left(\frac{M\_m}{\ell \cdot d} \cdot \frac{M\_m \cdot h}{d}\right) \cdot D\_m, -0.125 \cdot D\_m, 1\right)
\end{array}
Initial program 80.6%
Taylor expanded in M around 0
Applied rewrites49.4%
Applied rewrites64.2%
Applied rewrites53.5%
Applied rewrites77.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 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 80.6%
Taylor expanded in M around 0
Applied rewrites70.1%
herbie shell --seed 2025019
(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))))))