
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(w0, m, d, h, l, d_1)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
code = w0 * sqrt((1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\end{array}
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(w0, m, d, h, l, d_1)
use fmin_fmax_functions
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
code = w0 * sqrt((1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\end{array}
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
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)) 0.0)
(*
w0
(sqrt
(fma (* (/ h l) (* (/ -0.5 d) (* D_m M_m))) (* (/ M_m (+ d d)) D_m) 1.0)))
(*
w0
(sqrt
(-
1.0
(/ (* (/ (* (* D_m M_m) h) (* (+ d d) l)) (* D_m M_m)) (+ d d)))))))M_m = fabs(M);
D_m = fabs(D);
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)) <= 0.0) {
tmp = w0 * sqrt(fma(((h / l) * ((-0.5 / d) * (D_m * M_m))), ((M_m / (d + d)) * D_m), 1.0));
} else {
tmp = w0 * sqrt((1.0 - (((((D_m * M_m) * h) / ((d + d) * l)) * (D_m * M_m)) / (d + d))));
}
return tmp;
}
M_m = abs(M) D_m = abs(D) 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)) <= 0.0) tmp = Float64(w0 * sqrt(fma(Float64(Float64(h / l) * Float64(Float64(-0.5 / d) * Float64(D_m * M_m))), Float64(Float64(M_m / Float64(d + d)) * D_m), 1.0))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(Float64(D_m * M_m) * h) / Float64(Float64(d + d) * l)) * Float64(D_m * M_m)) / Float64(d + d))))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $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], 0.0], N[(w0 * N[Sqrt[N[(N[(N[(h / l), $MachinePrecision] * N[(N[(-0.5 / d), $MachinePrecision] * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(M$95$m / N[(d + d), $MachinePrecision]), $MachinePrecision] * D$95$m), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] / N[(N[(d + d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] / N[(d + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\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 0:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\frac{h}{\ell} \cdot \left(\frac{-0.5}{d} \cdot \left(D\_m \cdot M\_m\right)\right), \frac{M\_m}{d + d} \cdot D\_m, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\frac{\left(D\_m \cdot M\_m\right) \cdot h}{\left(d + d\right) \cdot \ell} \cdot \left(D\_m \cdot M\_m\right)}{d + d}}\\
\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 81.3%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
distribute-lft-neg-inN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites83.2%
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 81.3%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites84.3%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
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 (/ (* M_m D_m) d)))
(if (<=
(* w0 (sqrt (- 1.0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)))))
5e+260)
(* w0 (sqrt (- 1.0 (* (/ (* t_0 t_0) 4.0) (/ h l)))))
(*
(sqrt
(fma
(* (/ (* (* h (* M_m D_m)) -0.5) (* (* l (+ d d)) d)) M_m)
D_m
1.0))
w0))))M_m = fabs(M);
D_m = fabs(D);
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 = (M_m * D_m) / d;
double tmp;
if ((w0 * sqrt((1.0 - (pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l))))) <= 5e+260) {
tmp = w0 * sqrt((1.0 - (((t_0 * t_0) / 4.0) * (h / l))));
} else {
tmp = sqrt(fma(((((h * (M_m * D_m)) * -0.5) / ((l * (d + d)) * d)) * M_m), D_m, 1.0)) * w0;
}
return tmp;
}
M_m = abs(M) D_m = abs(D) 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(M_m * D_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))))) <= 5e+260) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(t_0 * t_0) / 4.0) * Float64(h / l))))); else tmp = Float64(sqrt(fma(Float64(Float64(Float64(Float64(h * Float64(M_m * D_m)) * -0.5) / Float64(Float64(l * Float64(d + d)) * d)) * M_m), D_m, 1.0)) * w0); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $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[(M$95$m * D$95$m), $MachinePrecision] / d), $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], 5e+260], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] / 4.0), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(N[(N[(N[(N[(h * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision] / N[(N[(l * N[(d + d), $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision] * D$95$m + 1.0), $MachinePrecision]], $MachinePrecision] * w0), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\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{M\_m \cdot D\_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 5 \cdot 10^{+260}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{t\_0 \cdot t\_0}{4} \cdot \frac{h}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(\frac{\left(h \cdot \left(M\_m \cdot D\_m\right)\right) \cdot -0.5}{\left(\ell \cdot \left(d + d\right)\right) \cdot d} \cdot M\_m, D\_m, 1\right)} \cdot w0\\
\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))))) < 4.9999999999999996e260Initial program 81.3%
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
frac-timesN/A
metadata-evalN/A
cosh-0-revN/A
lower-/.f64N/A
Applied rewrites81.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lower-/.f6480.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6480.0
Applied rewrites80.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lower-/.f6481.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6481.3
Applied rewrites81.3%
if 4.9999999999999996e260 < (*.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 81.3%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
distribute-rgt-neg-inN/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites84.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6484.6
Applied rewrites79.2%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
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 (/ (* M_m D_m) d)))
(if (<=
(* w0 (sqrt (- 1.0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)))))
2e+302)
(* w0 (sqrt (- 1.0 (* (/ (* t_0 t_0) 4.0) (/ h l)))))
(*
w0
(sqrt
(-
1.0
(/ (* (* (* D_m M_m) (* 0.25 M_m)) (* h D_m)) (* d (* l d)))))))))M_m = fabs(M);
D_m = fabs(D);
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 = (M_m * D_m) / d;
double tmp;
if ((w0 * sqrt((1.0 - (pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l))))) <= 2e+302) {
tmp = w0 * sqrt((1.0 - (((t_0 * t_0) / 4.0) * (h / l))));
} else {
tmp = w0 * sqrt((1.0 - ((((D_m * M_m) * (0.25 * M_m)) * (h * D_m)) / (d * (l * d)))));
}
return tmp;
}
M_m = private
D_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) :: t_0
real(8) :: tmp
t_0 = (m_m * d_m) / d
if ((w0 * sqrt((1.0d0 - ((((m_m * d_m) / (2.0d0 * d)) ** 2.0d0) * (h / l))))) <= 2d+302) then
tmp = w0 * sqrt((1.0d0 - (((t_0 * t_0) / 4.0d0) * (h / l))))
else
tmp = w0 * sqrt((1.0d0 - ((((d_m * m_m) * (0.25d0 * m_m)) * (h * d_m)) / (d * (l * d)))))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
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 t_0 = (M_m * D_m) / d;
double tmp;
if ((w0 * Math.sqrt((1.0 - (Math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l))))) <= 2e+302) {
tmp = w0 * Math.sqrt((1.0 - (((t_0 * t_0) / 4.0) * (h / l))));
} else {
tmp = w0 * Math.sqrt((1.0 - ((((D_m * M_m) * (0.25 * M_m)) * (h * D_m)) / (d * (l * d)))));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [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): t_0 = (M_m * D_m) / d tmp = 0 if (w0 * math.sqrt((1.0 - (math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l))))) <= 2e+302: tmp = w0 * math.sqrt((1.0 - (((t_0 * t_0) / 4.0) * (h / l)))) else: tmp = w0 * math.sqrt((1.0 - ((((D_m * M_m) * (0.25 * M_m)) * (h * D_m)) / (d * (l * d))))) return tmp
M_m = abs(M) D_m = abs(D) 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(M_m * D_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))))) <= 2e+302) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(t_0 * t_0) / 4.0) * Float64(h / l))))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(D_m * M_m) * Float64(0.25 * M_m)) * Float64(h * D_m)) / Float64(d * Float64(l * d)))))); end return tmp end
M_m = abs(M);
D_m = abs(D);
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)
t_0 = (M_m * D_m) / d;
tmp = 0.0;
if ((w0 * sqrt((1.0 - ((((M_m * D_m) / (2.0 * d)) ^ 2.0) * (h / l))))) <= 2e+302)
tmp = w0 * sqrt((1.0 - (((t_0 * t_0) / 4.0) * (h / l))));
else
tmp = w0 * sqrt((1.0 - ((((D_m * M_m) * (0.25 * M_m)) * (h * D_m)) / (d * (l * d)))));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $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[(M$95$m * D$95$m), $MachinePrecision] / d), $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], 2e+302], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] / 4.0), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(0.25 * M$95$m), $MachinePrecision]), $MachinePrecision] * N[(h * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(d * N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\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{M\_m \cdot D\_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 2 \cdot 10^{+302}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{t\_0 \cdot t\_0}{4} \cdot \frac{h}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(\left(D\_m \cdot M\_m\right) \cdot \left(0.25 \cdot M\_m\right)\right) \cdot \left(h \cdot D\_m\right)}{d \cdot \left(\ell \cdot d\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))))) < 2.0000000000000002e302Initial program 81.3%
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
frac-timesN/A
metadata-evalN/A
cosh-0-revN/A
lower-/.f64N/A
Applied rewrites81.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lower-/.f6480.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6480.0
Applied rewrites80.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lower-/.f6481.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6481.3
Applied rewrites81.3%
if 2.0000000000000002e302 < (*.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 81.3%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites77.9%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6469.6
Applied rewrites69.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6471.6
Applied rewrites71.6%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
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 d) M_m)))
(if (<=
(* w0 (sqrt (- 1.0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)))))
2e+302)
(* w0 (sqrt (- 1.0 (* (/ (* t_0 t_0) 4.0) (/ h l)))))
(*
w0
(sqrt
(-
1.0
(/ (* (* (* D_m M_m) (* 0.25 M_m)) (* h D_m)) (* d (* l d)))))))))M_m = fabs(M);
D_m = fabs(D);
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 / d) * M_m;
double tmp;
if ((w0 * sqrt((1.0 - (pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l))))) <= 2e+302) {
tmp = w0 * sqrt((1.0 - (((t_0 * t_0) / 4.0) * (h / l))));
} else {
tmp = w0 * sqrt((1.0 - ((((D_m * M_m) * (0.25 * M_m)) * (h * D_m)) / (d * (l * d)))));
}
return tmp;
}
M_m = private
D_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) :: t_0
real(8) :: tmp
t_0 = (d_m / d) * m_m
if ((w0 * sqrt((1.0d0 - ((((m_m * d_m) / (2.0d0 * d)) ** 2.0d0) * (h / l))))) <= 2d+302) then
tmp = w0 * sqrt((1.0d0 - (((t_0 * t_0) / 4.0d0) * (h / l))))
else
tmp = w0 * sqrt((1.0d0 - ((((d_m * m_m) * (0.25d0 * m_m)) * (h * d_m)) / (d * (l * d)))))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
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 t_0 = (D_m / d) * M_m;
double tmp;
if ((w0 * Math.sqrt((1.0 - (Math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l))))) <= 2e+302) {
tmp = w0 * Math.sqrt((1.0 - (((t_0 * t_0) / 4.0) * (h / l))));
} else {
tmp = w0 * Math.sqrt((1.0 - ((((D_m * M_m) * (0.25 * M_m)) * (h * D_m)) / (d * (l * d)))));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [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): t_0 = (D_m / d) * M_m tmp = 0 if (w0 * math.sqrt((1.0 - (math.pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l))))) <= 2e+302: tmp = w0 * math.sqrt((1.0 - (((t_0 * t_0) / 4.0) * (h / l)))) else: tmp = w0 * math.sqrt((1.0 - ((((D_m * M_m) * (0.25 * M_m)) * (h * D_m)) / (d * (l * d))))) return tmp
M_m = abs(M) D_m = abs(D) 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 / d) * M_m) 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))))) <= 2e+302) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(t_0 * t_0) / 4.0) * Float64(h / l))))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(D_m * M_m) * Float64(0.25 * M_m)) * Float64(h * D_m)) / Float64(d * Float64(l * d)))))); end return tmp end
M_m = abs(M);
D_m = abs(D);
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)
t_0 = (D_m / d) * M_m;
tmp = 0.0;
if ((w0 * sqrt((1.0 - ((((M_m * D_m) / (2.0 * d)) ^ 2.0) * (h / l))))) <= 2e+302)
tmp = w0 * sqrt((1.0 - (((t_0 * t_0) / 4.0) * (h / l))));
else
tmp = w0 * sqrt((1.0 - ((((D_m * M_m) * (0.25 * M_m)) * (h * D_m)) / (d * (l * d)))));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $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 / d), $MachinePrecision] * M$95$m), $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], 2e+302], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] / 4.0), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(0.25 * M$95$m), $MachinePrecision]), $MachinePrecision] * N[(h * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(d * N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\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}{d} \cdot M\_m\\
\mathbf{if}\;w0 \cdot \sqrt{1 - {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq 2 \cdot 10^{+302}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{t\_0 \cdot t\_0}{4} \cdot \frac{h}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(\left(D\_m \cdot M\_m\right) \cdot \left(0.25 \cdot M\_m\right)\right) \cdot \left(h \cdot D\_m\right)}{d \cdot \left(\ell \cdot d\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))))) < 2.0000000000000002e302Initial program 81.3%
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
frac-timesN/A
metadata-evalN/A
cosh-0-revN/A
lower-/.f64N/A
Applied rewrites81.1%
if 2.0000000000000002e302 < (*.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 81.3%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites77.9%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6469.6
Applied rewrites69.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6471.6
Applied rewrites71.6%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
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 (<=
(* w0 (sqrt (- 1.0 (* (pow (/ (* M_m D_m) (* 2.0 d)) 2.0) (/ h l)))))
2e+302)
(*
w0
(sqrt (fma (* (* (* (* (/ D_m d) M_m) M_m) -0.25) (/ h l)) (/ D_m d) 1.0)))
(*
w0
(sqrt
(- 1.0 (/ (* (* (* D_m M_m) (* 0.25 M_m)) (* h D_m)) (* d (* l d))))))))M_m = fabs(M);
D_m = fabs(D);
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 ((w0 * sqrt((1.0 - (pow(((M_m * D_m) / (2.0 * d)), 2.0) * (h / l))))) <= 2e+302) {
tmp = w0 * sqrt(fma((((((D_m / d) * M_m) * M_m) * -0.25) * (h / l)), (D_m / d), 1.0));
} else {
tmp = w0 * sqrt((1.0 - ((((D_m * M_m) * (0.25 * M_m)) * (h * D_m)) / (d * (l * d)))));
}
return tmp;
}
M_m = abs(M) D_m = abs(D) 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(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))))) <= 2e+302) tmp = Float64(w0 * sqrt(fma(Float64(Float64(Float64(Float64(Float64(D_m / d) * M_m) * M_m) * -0.25) * Float64(h / l)), Float64(D_m / d), 1.0))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(D_m * M_m) * Float64(0.25 * M_m)) * Float64(h * D_m)) / Float64(d * Float64(l * d)))))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $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[(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], 2e+302], N[(w0 * N[Sqrt[N[(N[(N[(N[(N[(N[(D$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] * -0.25), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(0.25 * M$95$m), $MachinePrecision]), $MachinePrecision] * N[(h * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(d * N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;w0 \cdot \sqrt{1 - {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq 2 \cdot 10^{+302}:\\
\;\;\;\;w0 \cdot \sqrt{\mathsf{fma}\left(\left(\left(\left(\frac{D\_m}{d} \cdot M\_m\right) \cdot M\_m\right) \cdot -0.25\right) \cdot \frac{h}{\ell}, \frac{D\_m}{d}, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(\left(D\_m \cdot M\_m\right) \cdot \left(0.25 \cdot M\_m\right)\right) \cdot \left(h \cdot D\_m\right)}{d \cdot \left(\ell \cdot d\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))))) < 2.0000000000000002e302Initial program 81.3%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites77.9%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites82.0%
if 2.0000000000000002e302 < (*.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 81.3%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites77.9%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6469.6
Applied rewrites69.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6471.6
Applied rewrites71.6%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
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 1.0)
(* w0 1.0)
(if (<= t_0 2e+51)
(*
(sqrt
(fma (* (* (* (/ D_m d) M_m) M_m) -0.25) (* D_m (/ h (* l d))) 1.0))
w0)
(*
w0
(sqrt
(-
1.0
(/ (* (* (* D_m M_m) (* 0.25 M_m)) (* h D_m)) (* d (* l d))))))))))M_m = fabs(M);
D_m = fabs(D);
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 <= 1.0) {
tmp = w0 * 1.0;
} else if (t_0 <= 2e+51) {
tmp = sqrt(fma(((((D_m / d) * M_m) * M_m) * -0.25), (D_m * (h / (l * d))), 1.0)) * w0;
} else {
tmp = w0 * sqrt((1.0 - ((((D_m * M_m) * (0.25 * M_m)) * (h * D_m)) / (d * (l * d)))));
}
return tmp;
}
M_m = abs(M) D_m = abs(D) 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 <= 1.0) tmp = Float64(w0 * 1.0); elseif (t_0 <= 2e+51) tmp = Float64(sqrt(fma(Float64(Float64(Float64(Float64(D_m / d) * M_m) * M_m) * -0.25), Float64(D_m * Float64(h / Float64(l * d))), 1.0)) * w0); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(Float64(D_m * M_m) * Float64(0.25 * M_m)) * Float64(h * D_m)) / Float64(d * Float64(l * d)))))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $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, 1.0], N[(w0 * 1.0), $MachinePrecision], If[LessEqual[t$95$0, 2e+51], N[(N[Sqrt[N[(N[(N[(N[(N[(D$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] * -0.25), $MachinePrecision] * N[(D$95$m * N[(h / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] * w0), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(0.25 * M$95$m), $MachinePrecision]), $MachinePrecision] * N[(h * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(d * N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\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 1:\\
\;\;\;\;w0 \cdot 1\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+51}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(\left(\left(\frac{D\_m}{d} \cdot M\_m\right) \cdot M\_m\right) \cdot -0.25, D\_m \cdot \frac{h}{\ell \cdot d}, 1\right)} \cdot w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{\left(\left(D\_m \cdot M\_m\right) \cdot \left(0.25 \cdot M\_m\right)\right) \cdot \left(h \cdot D\_m\right)}{d \cdot \left(\ell \cdot d\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)))) < 1Initial program 81.3%
Taylor expanded in M around 0
Applied rewrites67.9%
if 1 < (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)))) < 2e51Initial program 81.3%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites77.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.9
Applied rewrites79.9%
if 2e51 < (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 81.3%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites77.9%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6469.6
Applied rewrites69.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6471.6
Applied rewrites71.6%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
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) 4e-237)
(* w0 1.0)
(*
(sqrt (fma (* (* (* (/ D_m d) M_m) M_m) -0.25) (* D_m (/ h (* l d))) 1.0))
w0)))M_m = fabs(M);
D_m = fabs(D);
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) <= 4e-237) {
tmp = w0 * 1.0;
} else {
tmp = sqrt(fma(((((D_m / d) * M_m) * M_m) * -0.25), (D_m * (h / (l * d))), 1.0)) * w0;
}
return tmp;
}
M_m = abs(M) D_m = abs(D) 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) <= 4e-237) tmp = Float64(w0 * 1.0); else tmp = Float64(sqrt(fma(Float64(Float64(Float64(Float64(D_m / d) * M_m) * M_m) * -0.25), Float64(D_m * Float64(h / Float64(l * d))), 1.0)) * w0); end return tmp end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $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], 4e-237], N[(w0 * 1.0), $MachinePrecision], N[(N[Sqrt[N[(N[(N[(N[(N[(D$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] * -0.25), $MachinePrecision] * N[(D$95$m * N[(h / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] * w0), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\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 4 \cdot 10^{-237}:\\
\;\;\;\;w0 \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(\left(\left(\frac{D\_m}{d} \cdot M\_m\right) \cdot M\_m\right) \cdot -0.25, D\_m \cdot \frac{h}{\ell \cdot d}, 1\right)} \cdot w0\\
\end{array}
\end{array}
if (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) < 4e-237Initial program 81.3%
Taylor expanded in M around 0
Applied rewrites67.9%
if 4e-237 < (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) Initial program 81.3%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites77.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.9
Applied rewrites79.9%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
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
(sqrt
(fma (/ M_m (* d d)) (* (* (* (/ h l) D_m) (* D_m M_m)) -0.25) 1.0)))
(if (<= t_0 -2e-13)
(*
(sqrt
(fma (* (/ (* (* D_m M_m) (* D_m M_m)) (* d d)) -0.25) (/ h l) 1.0))
w0)
(* w0 1.0)))))M_m = fabs(M);
D_m = fabs(D);
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 * sqrt(fma((M_m / (d * d)), ((((h / l) * D_m) * (D_m * M_m)) * -0.25), 1.0));
} else if (t_0 <= -2e-13) {
tmp = sqrt(fma(((((D_m * M_m) * (D_m * M_m)) / (d * d)) * -0.25), (h / l), 1.0)) * w0;
} else {
tmp = w0 * 1.0;
}
return tmp;
}
M_m = abs(M) D_m = abs(D) 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 * sqrt(fma(Float64(M_m / Float64(d * d)), Float64(Float64(Float64(Float64(h / l) * D_m) * Float64(D_m * M_m)) * -0.25), 1.0))); elseif (t_0 <= -2e-13) tmp = Float64(sqrt(fma(Float64(Float64(Float64(Float64(D_m * M_m) * Float64(D_m * M_m)) / Float64(d * d)) * -0.25), Float64(h / l), 1.0)) * w0); else tmp = Float64(w0 * 1.0); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $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[Sqrt[N[(N[(M$95$m / N[(d * d), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(h / l), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -2e-13], N[(N[Sqrt[N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] * w0), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\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 \sqrt{\mathsf{fma}\left(\frac{M\_m}{d \cdot d}, \left(\left(\frac{h}{\ell} \cdot D\_m\right) \cdot \left(D\_m \cdot M\_m\right)\right) \cdot -0.25, 1\right)}\\
\mathbf{elif}\;t\_0 \leq -2 \cdot 10^{-13}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(\frac{\left(D\_m \cdot M\_m\right) \cdot \left(D\_m \cdot M\_m\right)}{d \cdot d} \cdot -0.25, \frac{h}{\ell}, 1\right)} \cdot w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot 1\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -inf.0Initial program 81.3%
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
swap-sqrN/A
metadata-evalN/A
cosh-0-revN/A
lower-*.f64N/A
cosh-0-revN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f6464.8
Applied rewrites64.8%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mult-flipN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
lower-/.f6463.3
Applied rewrites63.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6470.2
Applied rewrites70.2%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites67.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.0000000000000001e-13Initial program 81.3%
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
swap-sqrN/A
metadata-evalN/A
cosh-0-revN/A
lower-*.f64N/A
cosh-0-revN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f6464.8
Applied rewrites64.8%
Applied rewrites64.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6467.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.9
Applied rewrites67.9%
if -2.0000000000000001e-13 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 81.3%
Taylor expanded in M around 0
Applied rewrites67.9%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
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-13)
(*
(sqrt (fma (* (/ (* (* D_m M_m) (* D_m M_m)) (* d d)) -0.25) (/ h l) 1.0))
w0)
(* w0 1.0)))M_m = fabs(M);
D_m = fabs(D);
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-13) {
tmp = sqrt(fma(((((D_m * M_m) * (D_m * M_m)) / (d * d)) * -0.25), (h / l), 1.0)) * w0;
} else {
tmp = w0 * 1.0;
}
return tmp;
}
M_m = abs(M) D_m = abs(D) 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-13) tmp = Float64(sqrt(fma(Float64(Float64(Float64(Float64(D_m * M_m) * Float64(D_m * M_m)) / Float64(d * d)) * -0.25), Float64(h / l), 1.0)) * w0); else tmp = Float64(w0 * 1.0); end return tmp end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $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-13], N[(N[Sqrt[N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] * w0), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\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^{-13}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(\frac{\left(D\_m \cdot M\_m\right) \cdot \left(D\_m \cdot M\_m\right)}{d \cdot d} \cdot -0.25, \frac{h}{\ell}, 1\right)} \cdot w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot 1\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -2.0000000000000001e-13Initial program 81.3%
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
swap-sqrN/A
metadata-evalN/A
cosh-0-revN/A
lower-*.f64N/A
cosh-0-revN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f6464.8
Applied rewrites64.8%
Applied rewrites64.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6467.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.9
Applied rewrites67.9%
if -2.0000000000000001e-13 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 81.3%
Taylor expanded in M around 0
Applied rewrites67.9%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
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-13)
(*
(sqrt (/ (fma (* (* (/ M_m (* d d)) (* (* D_m M_m) D_m)) -0.25) h l) l))
w0)
(* w0 1.0)))M_m = fabs(M);
D_m = fabs(D);
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-13) {
tmp = sqrt((fma((((M_m / (d * d)) * ((D_m * M_m) * D_m)) * -0.25), h, l) / l)) * w0;
} else {
tmp = w0 * 1.0;
}
return tmp;
}
M_m = abs(M) D_m = abs(D) 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-13) tmp = Float64(sqrt(Float64(fma(Float64(Float64(Float64(M_m / Float64(d * d)) * Float64(Float64(D_m * M_m) * D_m)) * -0.25), h, l) / l)) * w0); else tmp = Float64(w0 * 1.0); end return tmp end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $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-13], N[(N[Sqrt[N[(N[(N[(N[(N[(M$95$m / N[(d * d), $MachinePrecision]), $MachinePrecision] * N[(N[(D$95$m * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision] * h + l), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision] * w0), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\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^{-13}:\\
\;\;\;\;\sqrt{\frac{\mathsf{fma}\left(\left(\frac{M\_m}{d \cdot d} \cdot \left(\left(D\_m \cdot M\_m\right) \cdot D\_m\right)\right) \cdot -0.25, h, \ell\right)}{\ell}} \cdot w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot 1\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < -2.0000000000000001e-13Initial program 81.3%
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
swap-sqrN/A
metadata-evalN/A
cosh-0-revN/A
lower-*.f64N/A
cosh-0-revN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f6464.8
Applied rewrites64.8%
Applied rewrites64.8%
Applied rewrites69.9%
if -2.0000000000000001e-13 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 81.3%
Taylor expanded in M around 0
Applied rewrites67.9%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) 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 1.0))
M_m = fabs(M);
D_m = fabs(D);
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 * 1.0;
}
M_m = private
D_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 * 1.0d0
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
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 * 1.0;
}
M_m = math.fabs(M) D_m = math.fabs(D) [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 * 1.0
M_m = abs(M) D_m = abs(D) 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 * 1.0) end
M_m = abs(M);
D_m = abs(D);
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 * 1.0;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $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 * 1.0), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
w0 \cdot 1
\end{array}
Initial program 81.3%
Taylor expanded in M around 0
Applied rewrites67.9%
herbie shell --seed 2025159
(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))))))