
(FPCore (c0 A V l) :precision binary64 (* c0 (sqrt (/ A (* V l)))))
double code(double c0, double A, double V, double l) {
return c0 * sqrt((A / (V * 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(c0, a, v, l)
use fmin_fmax_functions
real(8), intent (in) :: c0
real(8), intent (in) :: a
real(8), intent (in) :: v
real(8), intent (in) :: l
code = c0 * sqrt((a / (v * l)))
end function
public static double code(double c0, double A, double V, double l) {
return c0 * Math.sqrt((A / (V * l)));
}
def code(c0, A, V, l): return c0 * math.sqrt((A / (V * l)))
function code(c0, A, V, l) return Float64(c0 * sqrt(Float64(A / Float64(V * l)))) end
function tmp = code(c0, A, V, l) tmp = c0 * sqrt((A / (V * l))); end
code[c0_, A_, V_, l_] := N[(c0 * N[Sqrt[N[(A / N[(V * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
\end{array}
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (c0 A V l) :precision binary64 (* c0 (sqrt (/ A (* V l)))))
double code(double c0, double A, double V, double l) {
return c0 * sqrt((A / (V * 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(c0, a, v, l)
use fmin_fmax_functions
real(8), intent (in) :: c0
real(8), intent (in) :: a
real(8), intent (in) :: v
real(8), intent (in) :: l
code = c0 * sqrt((a / (v * l)))
end function
public static double code(double c0, double A, double V, double l) {
return c0 * Math.sqrt((A / (V * l)));
}
def code(c0, A, V, l): return c0 * math.sqrt((A / (V * l)))
function code(c0, A, V, l) return Float64(c0 * sqrt(Float64(A / Float64(V * l)))) end
function tmp = code(c0, A, V, l) tmp = c0 * sqrt((A / (V * l))); end
code[c0_, A_, V_, l_] := N[(c0 * N[Sqrt[N[(A / N[(V * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
\end{array}
A_m = (fabs.f64 A)
V_m = (fabs.f64 V)
l_m = (fabs.f64 l)
NOTE: c0, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
(FPCore (c0 A_m V_m l_m)
:precision binary64
(let* ((t_0 (sqrt (/ A_m (* V_m l_m))))
(t_1 (/ (/ (* (sqrt A_m) c0) (sqrt l_m)) (sqrt V_m))))
(if (<= t_0 5e-161) t_1 (if (<= t_0 1e+136) (* c0 t_0) t_1))))A_m = fabs(A);
V_m = fabs(V);
l_m = fabs(l);
assert(c0 < A_m && A_m < V_m && V_m < l_m);
double code(double c0, double A_m, double V_m, double l_m) {
double t_0 = sqrt((A_m / (V_m * l_m)));
double t_1 = ((sqrt(A_m) * c0) / sqrt(l_m)) / sqrt(V_m);
double tmp;
if (t_0 <= 5e-161) {
tmp = t_1;
} else if (t_0 <= 1e+136) {
tmp = c0 * t_0;
} else {
tmp = t_1;
}
return tmp;
}
A_m = private
V_m = private
l_m = private
NOTE: c0, A_m, V_m, and l_m 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(c0, a_m, v_m, l_m)
use fmin_fmax_functions
real(8), intent (in) :: c0
real(8), intent (in) :: a_m
real(8), intent (in) :: v_m
real(8), intent (in) :: l_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sqrt((a_m / (v_m * l_m)))
t_1 = ((sqrt(a_m) * c0) / sqrt(l_m)) / sqrt(v_m)
if (t_0 <= 5d-161) then
tmp = t_1
else if (t_0 <= 1d+136) then
tmp = c0 * t_0
else
tmp = t_1
end if
code = tmp
end function
A_m = Math.abs(A);
V_m = Math.abs(V);
l_m = Math.abs(l);
assert c0 < A_m && A_m < V_m && V_m < l_m;
public static double code(double c0, double A_m, double V_m, double l_m) {
double t_0 = Math.sqrt((A_m / (V_m * l_m)));
double t_1 = ((Math.sqrt(A_m) * c0) / Math.sqrt(l_m)) / Math.sqrt(V_m);
double tmp;
if (t_0 <= 5e-161) {
tmp = t_1;
} else if (t_0 <= 1e+136) {
tmp = c0 * t_0;
} else {
tmp = t_1;
}
return tmp;
}
A_m = math.fabs(A) V_m = math.fabs(V) l_m = math.fabs(l) [c0, A_m, V_m, l_m] = sort([c0, A_m, V_m, l_m]) def code(c0, A_m, V_m, l_m): t_0 = math.sqrt((A_m / (V_m * l_m))) t_1 = ((math.sqrt(A_m) * c0) / math.sqrt(l_m)) / math.sqrt(V_m) tmp = 0 if t_0 <= 5e-161: tmp = t_1 elif t_0 <= 1e+136: tmp = c0 * t_0 else: tmp = t_1 return tmp
A_m = abs(A) V_m = abs(V) l_m = abs(l) c0, A_m, V_m, l_m = sort([c0, A_m, V_m, l_m]) function code(c0, A_m, V_m, l_m) t_0 = sqrt(Float64(A_m / Float64(V_m * l_m))) t_1 = Float64(Float64(Float64(sqrt(A_m) * c0) / sqrt(l_m)) / sqrt(V_m)) tmp = 0.0 if (t_0 <= 5e-161) tmp = t_1; elseif (t_0 <= 1e+136) tmp = Float64(c0 * t_0); else tmp = t_1; end return tmp end
A_m = abs(A);
V_m = abs(V);
l_m = abs(l);
c0, A_m, V_m, l_m = num2cell(sort([c0, A_m, V_m, l_m])){:}
function tmp_2 = code(c0, A_m, V_m, l_m)
t_0 = sqrt((A_m / (V_m * l_m)));
t_1 = ((sqrt(A_m) * c0) / sqrt(l_m)) / sqrt(V_m);
tmp = 0.0;
if (t_0 <= 5e-161)
tmp = t_1;
elseif (t_0 <= 1e+136)
tmp = c0 * t_0;
else
tmp = t_1;
end
tmp_2 = tmp;
end
A_m = N[Abs[A], $MachinePrecision]
V_m = N[Abs[V], $MachinePrecision]
l_m = N[Abs[l], $MachinePrecision]
NOTE: c0, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
code[c0_, A$95$m_, V$95$m_, l$95$m_] := Block[{t$95$0 = N[Sqrt[N[(A$95$m / N[(V$95$m * l$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[Sqrt[A$95$m], $MachinePrecision] * c0), $MachinePrecision] / N[Sqrt[l$95$m], $MachinePrecision]), $MachinePrecision] / N[Sqrt[V$95$m], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e-161], t$95$1, If[LessEqual[t$95$0, 1e+136], N[(c0 * t$95$0), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
A_m = \left|A\right|
\\
V_m = \left|V\right|
\\
l_m = \left|\ell\right|
\\
[c0, A_m, V_m, l_m] = \mathsf{sort}([c0, A_m, V_m, l_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{A\_m}{V\_m \cdot l\_m}}\\
t_1 := \frac{\frac{\sqrt{A\_m} \cdot c0}{\sqrt{l\_m}}}{\sqrt{V\_m}}\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{-161}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 10^{+136}:\\
\;\;\;\;c0 \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (sqrt.f64 (/.f64 A (*.f64 V l))) < 4.9999999999999999e-161 or 1.00000000000000006e136 < (sqrt.f64 (/.f64 A (*.f64 V l))) Initial program 74.0%
lift-*.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
associate-*l/N/A
lift-*.f64N/A
*-commutativeN/A
sqrt-prodN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6493.2
Applied rewrites93.2%
if 4.9999999999999999e-161 < (sqrt.f64 (/.f64 A (*.f64 V l))) < 1.00000000000000006e136Initial program 74.0%
A_m = (fabs.f64 A)
V_m = (fabs.f64 V)
l_m = (fabs.f64 l)
NOTE: c0, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
(FPCore (c0 A_m V_m l_m)
:precision binary64
(let* ((t_0 (* c0 (/ (sqrt (/ A_m V_m)) (sqrt l_m)))))
(if (<= (* V_m l_m) 0.0)
t_0
(if (<= (* V_m l_m) 4e+233)
(* c0 (/ (sqrt A_m) (sqrt (* V_m l_m))))
t_0))))A_m = fabs(A);
V_m = fabs(V);
l_m = fabs(l);
assert(c0 < A_m && A_m < V_m && V_m < l_m);
double code(double c0, double A_m, double V_m, double l_m) {
double t_0 = c0 * (sqrt((A_m / V_m)) / sqrt(l_m));
double tmp;
if ((V_m * l_m) <= 0.0) {
tmp = t_0;
} else if ((V_m * l_m) <= 4e+233) {
tmp = c0 * (sqrt(A_m) / sqrt((V_m * l_m)));
} else {
tmp = t_0;
}
return tmp;
}
A_m = private
V_m = private
l_m = private
NOTE: c0, A_m, V_m, and l_m 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(c0, a_m, v_m, l_m)
use fmin_fmax_functions
real(8), intent (in) :: c0
real(8), intent (in) :: a_m
real(8), intent (in) :: v_m
real(8), intent (in) :: l_m
real(8) :: t_0
real(8) :: tmp
t_0 = c0 * (sqrt((a_m / v_m)) / sqrt(l_m))
if ((v_m * l_m) <= 0.0d0) then
tmp = t_0
else if ((v_m * l_m) <= 4d+233) then
tmp = c0 * (sqrt(a_m) / sqrt((v_m * l_m)))
else
tmp = t_0
end if
code = tmp
end function
A_m = Math.abs(A);
V_m = Math.abs(V);
l_m = Math.abs(l);
assert c0 < A_m && A_m < V_m && V_m < l_m;
public static double code(double c0, double A_m, double V_m, double l_m) {
double t_0 = c0 * (Math.sqrt((A_m / V_m)) / Math.sqrt(l_m));
double tmp;
if ((V_m * l_m) <= 0.0) {
tmp = t_0;
} else if ((V_m * l_m) <= 4e+233) {
tmp = c0 * (Math.sqrt(A_m) / Math.sqrt((V_m * l_m)));
} else {
tmp = t_0;
}
return tmp;
}
A_m = math.fabs(A) V_m = math.fabs(V) l_m = math.fabs(l) [c0, A_m, V_m, l_m] = sort([c0, A_m, V_m, l_m]) def code(c0, A_m, V_m, l_m): t_0 = c0 * (math.sqrt((A_m / V_m)) / math.sqrt(l_m)) tmp = 0 if (V_m * l_m) <= 0.0: tmp = t_0 elif (V_m * l_m) <= 4e+233: tmp = c0 * (math.sqrt(A_m) / math.sqrt((V_m * l_m))) else: tmp = t_0 return tmp
A_m = abs(A) V_m = abs(V) l_m = abs(l) c0, A_m, V_m, l_m = sort([c0, A_m, V_m, l_m]) function code(c0, A_m, V_m, l_m) t_0 = Float64(c0 * Float64(sqrt(Float64(A_m / V_m)) / sqrt(l_m))) tmp = 0.0 if (Float64(V_m * l_m) <= 0.0) tmp = t_0; elseif (Float64(V_m * l_m) <= 4e+233) tmp = Float64(c0 * Float64(sqrt(A_m) / sqrt(Float64(V_m * l_m)))); else tmp = t_0; end return tmp end
A_m = abs(A);
V_m = abs(V);
l_m = abs(l);
c0, A_m, V_m, l_m = num2cell(sort([c0, A_m, V_m, l_m])){:}
function tmp_2 = code(c0, A_m, V_m, l_m)
t_0 = c0 * (sqrt((A_m / V_m)) / sqrt(l_m));
tmp = 0.0;
if ((V_m * l_m) <= 0.0)
tmp = t_0;
elseif ((V_m * l_m) <= 4e+233)
tmp = c0 * (sqrt(A_m) / sqrt((V_m * l_m)));
else
tmp = t_0;
end
tmp_2 = tmp;
end
A_m = N[Abs[A], $MachinePrecision]
V_m = N[Abs[V], $MachinePrecision]
l_m = N[Abs[l], $MachinePrecision]
NOTE: c0, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
code[c0_, A$95$m_, V$95$m_, l$95$m_] := Block[{t$95$0 = N[(c0 * N[(N[Sqrt[N[(A$95$m / V$95$m), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(V$95$m * l$95$m), $MachinePrecision], 0.0], t$95$0, If[LessEqual[N[(V$95$m * l$95$m), $MachinePrecision], 4e+233], N[(c0 * N[(N[Sqrt[A$95$m], $MachinePrecision] / N[Sqrt[N[(V$95$m * l$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
A_m = \left|A\right|
\\
V_m = \left|V\right|
\\
l_m = \left|\ell\right|
\\
[c0, A_m, V_m, l_m] = \mathsf{sort}([c0, A_m, V_m, l_m])\\
\\
\begin{array}{l}
t_0 := c0 \cdot \frac{\sqrt{\frac{A\_m}{V\_m}}}{\sqrt{l\_m}}\\
\mathbf{if}\;V\_m \cdot l\_m \leq 0:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;V\_m \cdot l\_m \leq 4 \cdot 10^{+233}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{A\_m}}{\sqrt{V\_m \cdot l\_m}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (*.f64 V l) < 0.0 or 3.99999999999999989e233 < (*.f64 V l) Initial program 74.0%
lift-sqrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6484.3
Applied rewrites84.3%
if 0.0 < (*.f64 V l) < 3.99999999999999989e233Initial program 74.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6474.1
Applied rewrites74.1%
lift-sqrt.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
lift-*.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6483.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6483.8
Applied rewrites83.8%
A_m = (fabs.f64 A) V_m = (fabs.f64 V) l_m = (fabs.f64 l) NOTE: c0, A_m, V_m, and l_m should be sorted in increasing order before calling this function. (FPCore (c0 A_m V_m l_m) :precision binary64 (if (<= A_m 8.5e-51) (/ (* (sqrt (/ A_m V_m)) c0) (sqrt l_m)) (/ c0 (* (sqrt (/ l_m A_m)) (sqrt V_m)))))
A_m = fabs(A);
V_m = fabs(V);
l_m = fabs(l);
assert(c0 < A_m && A_m < V_m && V_m < l_m);
double code(double c0, double A_m, double V_m, double l_m) {
double tmp;
if (A_m <= 8.5e-51) {
tmp = (sqrt((A_m / V_m)) * c0) / sqrt(l_m);
} else {
tmp = c0 / (sqrt((l_m / A_m)) * sqrt(V_m));
}
return tmp;
}
A_m = private
V_m = private
l_m = private
NOTE: c0, A_m, V_m, and l_m 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(c0, a_m, v_m, l_m)
use fmin_fmax_functions
real(8), intent (in) :: c0
real(8), intent (in) :: a_m
real(8), intent (in) :: v_m
real(8), intent (in) :: l_m
real(8) :: tmp
if (a_m <= 8.5d-51) then
tmp = (sqrt((a_m / v_m)) * c0) / sqrt(l_m)
else
tmp = c0 / (sqrt((l_m / a_m)) * sqrt(v_m))
end if
code = tmp
end function
A_m = Math.abs(A);
V_m = Math.abs(V);
l_m = Math.abs(l);
assert c0 < A_m && A_m < V_m && V_m < l_m;
public static double code(double c0, double A_m, double V_m, double l_m) {
double tmp;
if (A_m <= 8.5e-51) {
tmp = (Math.sqrt((A_m / V_m)) * c0) / Math.sqrt(l_m);
} else {
tmp = c0 / (Math.sqrt((l_m / A_m)) * Math.sqrt(V_m));
}
return tmp;
}
A_m = math.fabs(A) V_m = math.fabs(V) l_m = math.fabs(l) [c0, A_m, V_m, l_m] = sort([c0, A_m, V_m, l_m]) def code(c0, A_m, V_m, l_m): tmp = 0 if A_m <= 8.5e-51: tmp = (math.sqrt((A_m / V_m)) * c0) / math.sqrt(l_m) else: tmp = c0 / (math.sqrt((l_m / A_m)) * math.sqrt(V_m)) return tmp
A_m = abs(A) V_m = abs(V) l_m = abs(l) c0, A_m, V_m, l_m = sort([c0, A_m, V_m, l_m]) function code(c0, A_m, V_m, l_m) tmp = 0.0 if (A_m <= 8.5e-51) tmp = Float64(Float64(sqrt(Float64(A_m / V_m)) * c0) / sqrt(l_m)); else tmp = Float64(c0 / Float64(sqrt(Float64(l_m / A_m)) * sqrt(V_m))); end return tmp end
A_m = abs(A);
V_m = abs(V);
l_m = abs(l);
c0, A_m, V_m, l_m = num2cell(sort([c0, A_m, V_m, l_m])){:}
function tmp_2 = code(c0, A_m, V_m, l_m)
tmp = 0.0;
if (A_m <= 8.5e-51)
tmp = (sqrt((A_m / V_m)) * c0) / sqrt(l_m);
else
tmp = c0 / (sqrt((l_m / A_m)) * sqrt(V_m));
end
tmp_2 = tmp;
end
A_m = N[Abs[A], $MachinePrecision] V_m = N[Abs[V], $MachinePrecision] l_m = N[Abs[l], $MachinePrecision] NOTE: c0, A_m, V_m, and l_m should be sorted in increasing order before calling this function. code[c0_, A$95$m_, V$95$m_, l$95$m_] := If[LessEqual[A$95$m, 8.5e-51], N[(N[(N[Sqrt[N[(A$95$m / V$95$m), $MachinePrecision]], $MachinePrecision] * c0), $MachinePrecision] / N[Sqrt[l$95$m], $MachinePrecision]), $MachinePrecision], N[(c0 / N[(N[Sqrt[N[(l$95$m / A$95$m), $MachinePrecision]], $MachinePrecision] * N[Sqrt[V$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
A_m = \left|A\right|
\\
V_m = \left|V\right|
\\
l_m = \left|\ell\right|
\\
[c0, A_m, V_m, l_m] = \mathsf{sort}([c0, A_m, V_m, l_m])\\
\\
\begin{array}{l}
\mathbf{if}\;A\_m \leq 8.5 \cdot 10^{-51}:\\
\;\;\;\;\frac{\sqrt{\frac{A\_m}{V\_m}} \cdot c0}{\sqrt{l\_m}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c0}{\sqrt{\frac{l\_m}{A\_m}} \cdot \sqrt{V\_m}}\\
\end{array}
\end{array}
if A < 8.50000000000000036e-51Initial program 74.0%
lift-*.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
sqrt-divN/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6481.7
Applied rewrites81.7%
if 8.50000000000000036e-51 < A Initial program 74.0%
lift-*.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
associate-*l/N/A
lift-*.f64N/A
*-commutativeN/A
sqrt-prodN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6493.2
Applied rewrites93.2%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*l/N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-divN/A
lift-/.f64N/A
lift-sqrt.f64N/A
*-commutativeN/A
associate-/r/N/A
lower-/.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-undivN/A
lift-/.f64N/A
associate-/r/N/A
associate-*l/N/A
lift-*.f64N/A
frac-2neg-revN/A
Applied rewrites74.4%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lift-/.f64N/A
sqrt-prodN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
*-commutativeN/A
lower-*.f6483.3
Applied rewrites83.3%
A_m = (fabs.f64 A) V_m = (fabs.f64 V) l_m = (fabs.f64 l) NOTE: c0, A_m, V_m, and l_m should be sorted in increasing order before calling this function. (FPCore (c0 A_m V_m l_m) :precision binary64 (if (<= A_m 9e-32) (* c0 (/ (sqrt (/ A_m V_m)) (sqrt l_m))) (/ c0 (* (sqrt (/ l_m A_m)) (sqrt V_m)))))
A_m = fabs(A);
V_m = fabs(V);
l_m = fabs(l);
assert(c0 < A_m && A_m < V_m && V_m < l_m);
double code(double c0, double A_m, double V_m, double l_m) {
double tmp;
if (A_m <= 9e-32) {
tmp = c0 * (sqrt((A_m / V_m)) / sqrt(l_m));
} else {
tmp = c0 / (sqrt((l_m / A_m)) * sqrt(V_m));
}
return tmp;
}
A_m = private
V_m = private
l_m = private
NOTE: c0, A_m, V_m, and l_m 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(c0, a_m, v_m, l_m)
use fmin_fmax_functions
real(8), intent (in) :: c0
real(8), intent (in) :: a_m
real(8), intent (in) :: v_m
real(8), intent (in) :: l_m
real(8) :: tmp
if (a_m <= 9d-32) then
tmp = c0 * (sqrt((a_m / v_m)) / sqrt(l_m))
else
tmp = c0 / (sqrt((l_m / a_m)) * sqrt(v_m))
end if
code = tmp
end function
A_m = Math.abs(A);
V_m = Math.abs(V);
l_m = Math.abs(l);
assert c0 < A_m && A_m < V_m && V_m < l_m;
public static double code(double c0, double A_m, double V_m, double l_m) {
double tmp;
if (A_m <= 9e-32) {
tmp = c0 * (Math.sqrt((A_m / V_m)) / Math.sqrt(l_m));
} else {
tmp = c0 / (Math.sqrt((l_m / A_m)) * Math.sqrt(V_m));
}
return tmp;
}
A_m = math.fabs(A) V_m = math.fabs(V) l_m = math.fabs(l) [c0, A_m, V_m, l_m] = sort([c0, A_m, V_m, l_m]) def code(c0, A_m, V_m, l_m): tmp = 0 if A_m <= 9e-32: tmp = c0 * (math.sqrt((A_m / V_m)) / math.sqrt(l_m)) else: tmp = c0 / (math.sqrt((l_m / A_m)) * math.sqrt(V_m)) return tmp
A_m = abs(A) V_m = abs(V) l_m = abs(l) c0, A_m, V_m, l_m = sort([c0, A_m, V_m, l_m]) function code(c0, A_m, V_m, l_m) tmp = 0.0 if (A_m <= 9e-32) tmp = Float64(c0 * Float64(sqrt(Float64(A_m / V_m)) / sqrt(l_m))); else tmp = Float64(c0 / Float64(sqrt(Float64(l_m / A_m)) * sqrt(V_m))); end return tmp end
A_m = abs(A);
V_m = abs(V);
l_m = abs(l);
c0, A_m, V_m, l_m = num2cell(sort([c0, A_m, V_m, l_m])){:}
function tmp_2 = code(c0, A_m, V_m, l_m)
tmp = 0.0;
if (A_m <= 9e-32)
tmp = c0 * (sqrt((A_m / V_m)) / sqrt(l_m));
else
tmp = c0 / (sqrt((l_m / A_m)) * sqrt(V_m));
end
tmp_2 = tmp;
end
A_m = N[Abs[A], $MachinePrecision] V_m = N[Abs[V], $MachinePrecision] l_m = N[Abs[l], $MachinePrecision] NOTE: c0, A_m, V_m, and l_m should be sorted in increasing order before calling this function. code[c0_, A$95$m_, V$95$m_, l$95$m_] := If[LessEqual[A$95$m, 9e-32], N[(c0 * N[(N[Sqrt[N[(A$95$m / V$95$m), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 / N[(N[Sqrt[N[(l$95$m / A$95$m), $MachinePrecision]], $MachinePrecision] * N[Sqrt[V$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
A_m = \left|A\right|
\\
V_m = \left|V\right|
\\
l_m = \left|\ell\right|
\\
[c0, A_m, V_m, l_m] = \mathsf{sort}([c0, A_m, V_m, l_m])\\
\\
\begin{array}{l}
\mathbf{if}\;A\_m \leq 9 \cdot 10^{-32}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\frac{A\_m}{V\_m}}}{\sqrt{l\_m}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c0}{\sqrt{\frac{l\_m}{A\_m}} \cdot \sqrt{V\_m}}\\
\end{array}
\end{array}
if A < 9.00000000000000009e-32Initial program 74.0%
lift-sqrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6484.3
Applied rewrites84.3%
if 9.00000000000000009e-32 < A Initial program 74.0%
lift-*.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
associate-*l/N/A
lift-*.f64N/A
*-commutativeN/A
sqrt-prodN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6493.2
Applied rewrites93.2%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*l/N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-divN/A
lift-/.f64N/A
lift-sqrt.f64N/A
*-commutativeN/A
associate-/r/N/A
lower-/.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-undivN/A
lift-/.f64N/A
associate-/r/N/A
associate-*l/N/A
lift-*.f64N/A
frac-2neg-revN/A
Applied rewrites74.4%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lift-/.f64N/A
sqrt-prodN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
*-commutativeN/A
lower-*.f6483.3
Applied rewrites83.3%
A_m = (fabs.f64 A) V_m = (fabs.f64 V) l_m = (fabs.f64 l) NOTE: c0, A_m, V_m, and l_m should be sorted in increasing order before calling this function. (FPCore (c0 A_m V_m l_m) :precision binary64 (if (<= (sqrt (/ A_m (* V_m l_m))) 10.0) (* c0 (/ (sqrt (/ A_m V_m)) (sqrt l_m))) (* c0 (/ (sqrt (/ A_m l_m)) (sqrt V_m)))))
A_m = fabs(A);
V_m = fabs(V);
l_m = fabs(l);
assert(c0 < A_m && A_m < V_m && V_m < l_m);
double code(double c0, double A_m, double V_m, double l_m) {
double tmp;
if (sqrt((A_m / (V_m * l_m))) <= 10.0) {
tmp = c0 * (sqrt((A_m / V_m)) / sqrt(l_m));
} else {
tmp = c0 * (sqrt((A_m / l_m)) / sqrt(V_m));
}
return tmp;
}
A_m = private
V_m = private
l_m = private
NOTE: c0, A_m, V_m, and l_m 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(c0, a_m, v_m, l_m)
use fmin_fmax_functions
real(8), intent (in) :: c0
real(8), intent (in) :: a_m
real(8), intent (in) :: v_m
real(8), intent (in) :: l_m
real(8) :: tmp
if (sqrt((a_m / (v_m * l_m))) <= 10.0d0) then
tmp = c0 * (sqrt((a_m / v_m)) / sqrt(l_m))
else
tmp = c0 * (sqrt((a_m / l_m)) / sqrt(v_m))
end if
code = tmp
end function
A_m = Math.abs(A);
V_m = Math.abs(V);
l_m = Math.abs(l);
assert c0 < A_m && A_m < V_m && V_m < l_m;
public static double code(double c0, double A_m, double V_m, double l_m) {
double tmp;
if (Math.sqrt((A_m / (V_m * l_m))) <= 10.0) {
tmp = c0 * (Math.sqrt((A_m / V_m)) / Math.sqrt(l_m));
} else {
tmp = c0 * (Math.sqrt((A_m / l_m)) / Math.sqrt(V_m));
}
return tmp;
}
A_m = math.fabs(A) V_m = math.fabs(V) l_m = math.fabs(l) [c0, A_m, V_m, l_m] = sort([c0, A_m, V_m, l_m]) def code(c0, A_m, V_m, l_m): tmp = 0 if math.sqrt((A_m / (V_m * l_m))) <= 10.0: tmp = c0 * (math.sqrt((A_m / V_m)) / math.sqrt(l_m)) else: tmp = c0 * (math.sqrt((A_m / l_m)) / math.sqrt(V_m)) return tmp
A_m = abs(A) V_m = abs(V) l_m = abs(l) c0, A_m, V_m, l_m = sort([c0, A_m, V_m, l_m]) function code(c0, A_m, V_m, l_m) tmp = 0.0 if (sqrt(Float64(A_m / Float64(V_m * l_m))) <= 10.0) tmp = Float64(c0 * Float64(sqrt(Float64(A_m / V_m)) / sqrt(l_m))); else tmp = Float64(c0 * Float64(sqrt(Float64(A_m / l_m)) / sqrt(V_m))); end return tmp end
A_m = abs(A);
V_m = abs(V);
l_m = abs(l);
c0, A_m, V_m, l_m = num2cell(sort([c0, A_m, V_m, l_m])){:}
function tmp_2 = code(c0, A_m, V_m, l_m)
tmp = 0.0;
if (sqrt((A_m / (V_m * l_m))) <= 10.0)
tmp = c0 * (sqrt((A_m / V_m)) / sqrt(l_m));
else
tmp = c0 * (sqrt((A_m / l_m)) / sqrt(V_m));
end
tmp_2 = tmp;
end
A_m = N[Abs[A], $MachinePrecision] V_m = N[Abs[V], $MachinePrecision] l_m = N[Abs[l], $MachinePrecision] NOTE: c0, A_m, V_m, and l_m should be sorted in increasing order before calling this function. code[c0_, A$95$m_, V$95$m_, l$95$m_] := If[LessEqual[N[Sqrt[N[(A$95$m / N[(V$95$m * l$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 10.0], N[(c0 * N[(N[Sqrt[N[(A$95$m / V$95$m), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[Sqrt[N[(A$95$m / l$95$m), $MachinePrecision]], $MachinePrecision] / N[Sqrt[V$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
A_m = \left|A\right|
\\
V_m = \left|V\right|
\\
l_m = \left|\ell\right|
\\
[c0, A_m, V_m, l_m] = \mathsf{sort}([c0, A_m, V_m, l_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\sqrt{\frac{A\_m}{V\_m \cdot l\_m}} \leq 10:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\frac{A\_m}{V\_m}}}{\sqrt{l\_m}}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\frac{A\_m}{l\_m}}}{\sqrt{V\_m}}\\
\end{array}
\end{array}
if (sqrt.f64 (/.f64 A (*.f64 V l))) < 10Initial program 74.0%
lift-sqrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6484.3
Applied rewrites84.3%
if 10 < (sqrt.f64 (/.f64 A (*.f64 V l))) Initial program 74.0%
lift-sqrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6483.8
Applied rewrites83.8%
A_m = (fabs.f64 A)
V_m = (fabs.f64 V)
l_m = (fabs.f64 l)
NOTE: c0, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
(FPCore (c0 A_m V_m l_m)
:precision binary64
(if (<= (* V_m l_m) 2e-297)
(/ c0 (sqrt (* (/ V_m A_m) l_m)))
(if (<= (* V_m l_m) 2e+297)
(* c0 (/ (sqrt A_m) (sqrt (* V_m l_m))))
(/ c0 (sqrt (/ l_m (/ A_m V_m)))))))A_m = fabs(A);
V_m = fabs(V);
l_m = fabs(l);
assert(c0 < A_m && A_m < V_m && V_m < l_m);
double code(double c0, double A_m, double V_m, double l_m) {
double tmp;
if ((V_m * l_m) <= 2e-297) {
tmp = c0 / sqrt(((V_m / A_m) * l_m));
} else if ((V_m * l_m) <= 2e+297) {
tmp = c0 * (sqrt(A_m) / sqrt((V_m * l_m)));
} else {
tmp = c0 / sqrt((l_m / (A_m / V_m)));
}
return tmp;
}
A_m = private
V_m = private
l_m = private
NOTE: c0, A_m, V_m, and l_m 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(c0, a_m, v_m, l_m)
use fmin_fmax_functions
real(8), intent (in) :: c0
real(8), intent (in) :: a_m
real(8), intent (in) :: v_m
real(8), intent (in) :: l_m
real(8) :: tmp
if ((v_m * l_m) <= 2d-297) then
tmp = c0 / sqrt(((v_m / a_m) * l_m))
else if ((v_m * l_m) <= 2d+297) then
tmp = c0 * (sqrt(a_m) / sqrt((v_m * l_m)))
else
tmp = c0 / sqrt((l_m / (a_m / v_m)))
end if
code = tmp
end function
A_m = Math.abs(A);
V_m = Math.abs(V);
l_m = Math.abs(l);
assert c0 < A_m && A_m < V_m && V_m < l_m;
public static double code(double c0, double A_m, double V_m, double l_m) {
double tmp;
if ((V_m * l_m) <= 2e-297) {
tmp = c0 / Math.sqrt(((V_m / A_m) * l_m));
} else if ((V_m * l_m) <= 2e+297) {
tmp = c0 * (Math.sqrt(A_m) / Math.sqrt((V_m * l_m)));
} else {
tmp = c0 / Math.sqrt((l_m / (A_m / V_m)));
}
return tmp;
}
A_m = math.fabs(A) V_m = math.fabs(V) l_m = math.fabs(l) [c0, A_m, V_m, l_m] = sort([c0, A_m, V_m, l_m]) def code(c0, A_m, V_m, l_m): tmp = 0 if (V_m * l_m) <= 2e-297: tmp = c0 / math.sqrt(((V_m / A_m) * l_m)) elif (V_m * l_m) <= 2e+297: tmp = c0 * (math.sqrt(A_m) / math.sqrt((V_m * l_m))) else: tmp = c0 / math.sqrt((l_m / (A_m / V_m))) return tmp
A_m = abs(A) V_m = abs(V) l_m = abs(l) c0, A_m, V_m, l_m = sort([c0, A_m, V_m, l_m]) function code(c0, A_m, V_m, l_m) tmp = 0.0 if (Float64(V_m * l_m) <= 2e-297) tmp = Float64(c0 / sqrt(Float64(Float64(V_m / A_m) * l_m))); elseif (Float64(V_m * l_m) <= 2e+297) tmp = Float64(c0 * Float64(sqrt(A_m) / sqrt(Float64(V_m * l_m)))); else tmp = Float64(c0 / sqrt(Float64(l_m / Float64(A_m / V_m)))); end return tmp end
A_m = abs(A);
V_m = abs(V);
l_m = abs(l);
c0, A_m, V_m, l_m = num2cell(sort([c0, A_m, V_m, l_m])){:}
function tmp_2 = code(c0, A_m, V_m, l_m)
tmp = 0.0;
if ((V_m * l_m) <= 2e-297)
tmp = c0 / sqrt(((V_m / A_m) * l_m));
elseif ((V_m * l_m) <= 2e+297)
tmp = c0 * (sqrt(A_m) / sqrt((V_m * l_m)));
else
tmp = c0 / sqrt((l_m / (A_m / V_m)));
end
tmp_2 = tmp;
end
A_m = N[Abs[A], $MachinePrecision] V_m = N[Abs[V], $MachinePrecision] l_m = N[Abs[l], $MachinePrecision] NOTE: c0, A_m, V_m, and l_m should be sorted in increasing order before calling this function. code[c0_, A$95$m_, V$95$m_, l$95$m_] := If[LessEqual[N[(V$95$m * l$95$m), $MachinePrecision], 2e-297], N[(c0 / N[Sqrt[N[(N[(V$95$m / A$95$m), $MachinePrecision] * l$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(V$95$m * l$95$m), $MachinePrecision], 2e+297], N[(c0 * N[(N[Sqrt[A$95$m], $MachinePrecision] / N[Sqrt[N[(V$95$m * l$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 / N[Sqrt[N[(l$95$m / N[(A$95$m / V$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
A_m = \left|A\right|
\\
V_m = \left|V\right|
\\
l_m = \left|\ell\right|
\\
[c0, A_m, V_m, l_m] = \mathsf{sort}([c0, A_m, V_m, l_m])\\
\\
\begin{array}{l}
\mathbf{if}\;V\_m \cdot l\_m \leq 2 \cdot 10^{-297}:\\
\;\;\;\;\frac{c0}{\sqrt{\frac{V\_m}{A\_m} \cdot l\_m}}\\
\mathbf{elif}\;V\_m \cdot l\_m \leq 2 \cdot 10^{+297}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{A\_m}}{\sqrt{V\_m \cdot l\_m}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c0}{\sqrt{\frac{l\_m}{\frac{A\_m}{V\_m}}}}\\
\end{array}
\end{array}
if (*.f64 V l) < 2.00000000000000008e-297Initial program 74.0%
lift-*.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
associate-*l/N/A
lift-*.f64N/A
*-commutativeN/A
sqrt-prodN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6493.2
Applied rewrites93.2%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*l/N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-divN/A
lift-/.f64N/A
lift-sqrt.f64N/A
*-commutativeN/A
associate-/r/N/A
lower-/.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-undivN/A
lift-/.f64N/A
associate-/r/N/A
associate-*l/N/A
lift-*.f64N/A
frac-2neg-revN/A
Applied rewrites74.4%
if 2.00000000000000008e-297 < (*.f64 V l) < 2e297Initial program 74.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6474.1
Applied rewrites74.1%
lift-sqrt.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
lift-*.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6483.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6483.8
Applied rewrites83.8%
if 2e297 < (*.f64 V l) Initial program 74.0%
lift-*.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
associate-*l/N/A
lift-*.f64N/A
*-commutativeN/A
sqrt-prodN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6493.2
Applied rewrites93.2%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*l/N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-divN/A
lift-/.f64N/A
lift-sqrt.f64N/A
*-commutativeN/A
associate-/r/N/A
lower-/.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-undivN/A
lift-/.f64N/A
associate-/r/N/A
associate-*l/N/A
lift-*.f64N/A
frac-2neg-revN/A
Applied rewrites74.4%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
div-flipN/A
mult-flip-revN/A
lower-/.f64N/A
lower-/.f6473.8
Applied rewrites73.8%
A_m = (fabs.f64 A) V_m = (fabs.f64 V) l_m = (fabs.f64 l) NOTE: c0, A_m, V_m, and l_m should be sorted in increasing order before calling this function. (FPCore (c0 A_m V_m l_m) :precision binary64 (if (<= A_m 3.2e-32) (* c0 (sqrt (/ (/ A_m V_m) l_m))) (/ c0 (sqrt (/ V_m (/ A_m l_m))))))
A_m = fabs(A);
V_m = fabs(V);
l_m = fabs(l);
assert(c0 < A_m && A_m < V_m && V_m < l_m);
double code(double c0, double A_m, double V_m, double l_m) {
double tmp;
if (A_m <= 3.2e-32) {
tmp = c0 * sqrt(((A_m / V_m) / l_m));
} else {
tmp = c0 / sqrt((V_m / (A_m / l_m)));
}
return tmp;
}
A_m = private
V_m = private
l_m = private
NOTE: c0, A_m, V_m, and l_m 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(c0, a_m, v_m, l_m)
use fmin_fmax_functions
real(8), intent (in) :: c0
real(8), intent (in) :: a_m
real(8), intent (in) :: v_m
real(8), intent (in) :: l_m
real(8) :: tmp
if (a_m <= 3.2d-32) then
tmp = c0 * sqrt(((a_m / v_m) / l_m))
else
tmp = c0 / sqrt((v_m / (a_m / l_m)))
end if
code = tmp
end function
A_m = Math.abs(A);
V_m = Math.abs(V);
l_m = Math.abs(l);
assert c0 < A_m && A_m < V_m && V_m < l_m;
public static double code(double c0, double A_m, double V_m, double l_m) {
double tmp;
if (A_m <= 3.2e-32) {
tmp = c0 * Math.sqrt(((A_m / V_m) / l_m));
} else {
tmp = c0 / Math.sqrt((V_m / (A_m / l_m)));
}
return tmp;
}
A_m = math.fabs(A) V_m = math.fabs(V) l_m = math.fabs(l) [c0, A_m, V_m, l_m] = sort([c0, A_m, V_m, l_m]) def code(c0, A_m, V_m, l_m): tmp = 0 if A_m <= 3.2e-32: tmp = c0 * math.sqrt(((A_m / V_m) / l_m)) else: tmp = c0 / math.sqrt((V_m / (A_m / l_m))) return tmp
A_m = abs(A) V_m = abs(V) l_m = abs(l) c0, A_m, V_m, l_m = sort([c0, A_m, V_m, l_m]) function code(c0, A_m, V_m, l_m) tmp = 0.0 if (A_m <= 3.2e-32) tmp = Float64(c0 * sqrt(Float64(Float64(A_m / V_m) / l_m))); else tmp = Float64(c0 / sqrt(Float64(V_m / Float64(A_m / l_m)))); end return tmp end
A_m = abs(A);
V_m = abs(V);
l_m = abs(l);
c0, A_m, V_m, l_m = num2cell(sort([c0, A_m, V_m, l_m])){:}
function tmp_2 = code(c0, A_m, V_m, l_m)
tmp = 0.0;
if (A_m <= 3.2e-32)
tmp = c0 * sqrt(((A_m / V_m) / l_m));
else
tmp = c0 / sqrt((V_m / (A_m / l_m)));
end
tmp_2 = tmp;
end
A_m = N[Abs[A], $MachinePrecision] V_m = N[Abs[V], $MachinePrecision] l_m = N[Abs[l], $MachinePrecision] NOTE: c0, A_m, V_m, and l_m should be sorted in increasing order before calling this function. code[c0_, A$95$m_, V$95$m_, l$95$m_] := If[LessEqual[A$95$m, 3.2e-32], N[(c0 * N[Sqrt[N[(N[(A$95$m / V$95$m), $MachinePrecision] / l$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(c0 / N[Sqrt[N[(V$95$m / N[(A$95$m / l$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
A_m = \left|A\right|
\\
V_m = \left|V\right|
\\
l_m = \left|\ell\right|
\\
[c0, A_m, V_m, l_m] = \mathsf{sort}([c0, A_m, V_m, l_m])\\
\\
\begin{array}{l}
\mathbf{if}\;A\_m \leq 3.2 \cdot 10^{-32}:\\
\;\;\;\;c0 \cdot \sqrt{\frac{\frac{A\_m}{V\_m}}{l\_m}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c0}{\sqrt{\frac{V\_m}{\frac{A\_m}{l\_m}}}}\\
\end{array}
\end{array}
if A < 3.2000000000000002e-32Initial program 74.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6474.1
Applied rewrites74.1%
if 3.2000000000000002e-32 < A Initial program 74.0%
lift-*.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
associate-*l/N/A
lift-*.f64N/A
*-commutativeN/A
sqrt-prodN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6493.2
Applied rewrites93.2%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*l/N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-divN/A
lift-/.f64N/A
lift-sqrt.f64N/A
*-commutativeN/A
associate-/r/N/A
lower-/.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-undivN/A
lift-/.f64N/A
associate-/r/N/A
associate-*l/N/A
lift-*.f64N/A
frac-2neg-revN/A
Applied rewrites74.4%
lift-*.f64N/A
lift-/.f64N/A
mult-flipN/A
associate-*l*N/A
associate-/r/N/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6474.1
Applied rewrites74.1%
A_m = (fabs.f64 A)
V_m = (fabs.f64 V)
l_m = (fabs.f64 l)
NOTE: c0, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
(FPCore (c0 A_m V_m l_m)
:precision binary64
(let* ((t_0 (/ c0 (sqrt (* (/ V_m A_m) l_m)))))
(if (<= (* V_m l_m) 5e-260)
t_0
(if (<= (* V_m l_m) 4e+233) (* c0 (sqrt (/ A_m (* V_m l_m)))) t_0))))A_m = fabs(A);
V_m = fabs(V);
l_m = fabs(l);
assert(c0 < A_m && A_m < V_m && V_m < l_m);
double code(double c0, double A_m, double V_m, double l_m) {
double t_0 = c0 / sqrt(((V_m / A_m) * l_m));
double tmp;
if ((V_m * l_m) <= 5e-260) {
tmp = t_0;
} else if ((V_m * l_m) <= 4e+233) {
tmp = c0 * sqrt((A_m / (V_m * l_m)));
} else {
tmp = t_0;
}
return tmp;
}
A_m = private
V_m = private
l_m = private
NOTE: c0, A_m, V_m, and l_m 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(c0, a_m, v_m, l_m)
use fmin_fmax_functions
real(8), intent (in) :: c0
real(8), intent (in) :: a_m
real(8), intent (in) :: v_m
real(8), intent (in) :: l_m
real(8) :: t_0
real(8) :: tmp
t_0 = c0 / sqrt(((v_m / a_m) * l_m))
if ((v_m * l_m) <= 5d-260) then
tmp = t_0
else if ((v_m * l_m) <= 4d+233) then
tmp = c0 * sqrt((a_m / (v_m * l_m)))
else
tmp = t_0
end if
code = tmp
end function
A_m = Math.abs(A);
V_m = Math.abs(V);
l_m = Math.abs(l);
assert c0 < A_m && A_m < V_m && V_m < l_m;
public static double code(double c0, double A_m, double V_m, double l_m) {
double t_0 = c0 / Math.sqrt(((V_m / A_m) * l_m));
double tmp;
if ((V_m * l_m) <= 5e-260) {
tmp = t_0;
} else if ((V_m * l_m) <= 4e+233) {
tmp = c0 * Math.sqrt((A_m / (V_m * l_m)));
} else {
tmp = t_0;
}
return tmp;
}
A_m = math.fabs(A) V_m = math.fabs(V) l_m = math.fabs(l) [c0, A_m, V_m, l_m] = sort([c0, A_m, V_m, l_m]) def code(c0, A_m, V_m, l_m): t_0 = c0 / math.sqrt(((V_m / A_m) * l_m)) tmp = 0 if (V_m * l_m) <= 5e-260: tmp = t_0 elif (V_m * l_m) <= 4e+233: tmp = c0 * math.sqrt((A_m / (V_m * l_m))) else: tmp = t_0 return tmp
A_m = abs(A) V_m = abs(V) l_m = abs(l) c0, A_m, V_m, l_m = sort([c0, A_m, V_m, l_m]) function code(c0, A_m, V_m, l_m) t_0 = Float64(c0 / sqrt(Float64(Float64(V_m / A_m) * l_m))) tmp = 0.0 if (Float64(V_m * l_m) <= 5e-260) tmp = t_0; elseif (Float64(V_m * l_m) <= 4e+233) tmp = Float64(c0 * sqrt(Float64(A_m / Float64(V_m * l_m)))); else tmp = t_0; end return tmp end
A_m = abs(A);
V_m = abs(V);
l_m = abs(l);
c0, A_m, V_m, l_m = num2cell(sort([c0, A_m, V_m, l_m])){:}
function tmp_2 = code(c0, A_m, V_m, l_m)
t_0 = c0 / sqrt(((V_m / A_m) * l_m));
tmp = 0.0;
if ((V_m * l_m) <= 5e-260)
tmp = t_0;
elseif ((V_m * l_m) <= 4e+233)
tmp = c0 * sqrt((A_m / (V_m * l_m)));
else
tmp = t_0;
end
tmp_2 = tmp;
end
A_m = N[Abs[A], $MachinePrecision]
V_m = N[Abs[V], $MachinePrecision]
l_m = N[Abs[l], $MachinePrecision]
NOTE: c0, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
code[c0_, A$95$m_, V$95$m_, l$95$m_] := Block[{t$95$0 = N[(c0 / N[Sqrt[N[(N[(V$95$m / A$95$m), $MachinePrecision] * l$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(V$95$m * l$95$m), $MachinePrecision], 5e-260], t$95$0, If[LessEqual[N[(V$95$m * l$95$m), $MachinePrecision], 4e+233], N[(c0 * N[Sqrt[N[(A$95$m / N[(V$95$m * l$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
A_m = \left|A\right|
\\
V_m = \left|V\right|
\\
l_m = \left|\ell\right|
\\
[c0, A_m, V_m, l_m] = \mathsf{sort}([c0, A_m, V_m, l_m])\\
\\
\begin{array}{l}
t_0 := \frac{c0}{\sqrt{\frac{V\_m}{A\_m} \cdot l\_m}}\\
\mathbf{if}\;V\_m \cdot l\_m \leq 5 \cdot 10^{-260}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;V\_m \cdot l\_m \leq 4 \cdot 10^{+233}:\\
\;\;\;\;c0 \cdot \sqrt{\frac{A\_m}{V\_m \cdot l\_m}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (*.f64 V l) < 5.0000000000000003e-260 or 3.99999999999999989e233 < (*.f64 V l) Initial program 74.0%
lift-*.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
associate-*l/N/A
lift-*.f64N/A
*-commutativeN/A
sqrt-prodN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6493.2
Applied rewrites93.2%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*l/N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-divN/A
lift-/.f64N/A
lift-sqrt.f64N/A
*-commutativeN/A
associate-/r/N/A
lower-/.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-undivN/A
lift-/.f64N/A
associate-/r/N/A
associate-*l/N/A
lift-*.f64N/A
frac-2neg-revN/A
Applied rewrites74.4%
if 5.0000000000000003e-260 < (*.f64 V l) < 3.99999999999999989e233Initial program 74.0%
A_m = (fabs.f64 A)
V_m = (fabs.f64 V)
l_m = (fabs.f64 l)
NOTE: c0, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
(FPCore (c0 A_m V_m l_m)
:precision binary64
(let* ((t_0 (* c0 (sqrt (/ (/ A_m V_m) l_m)))))
(if (<= (* V_m l_m) 0.0)
t_0
(if (<= (* V_m l_m) 2e+250) (* c0 (sqrt (/ A_m (* V_m l_m)))) t_0))))A_m = fabs(A);
V_m = fabs(V);
l_m = fabs(l);
assert(c0 < A_m && A_m < V_m && V_m < l_m);
double code(double c0, double A_m, double V_m, double l_m) {
double t_0 = c0 * sqrt(((A_m / V_m) / l_m));
double tmp;
if ((V_m * l_m) <= 0.0) {
tmp = t_0;
} else if ((V_m * l_m) <= 2e+250) {
tmp = c0 * sqrt((A_m / (V_m * l_m)));
} else {
tmp = t_0;
}
return tmp;
}
A_m = private
V_m = private
l_m = private
NOTE: c0, A_m, V_m, and l_m 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(c0, a_m, v_m, l_m)
use fmin_fmax_functions
real(8), intent (in) :: c0
real(8), intent (in) :: a_m
real(8), intent (in) :: v_m
real(8), intent (in) :: l_m
real(8) :: t_0
real(8) :: tmp
t_0 = c0 * sqrt(((a_m / v_m) / l_m))
if ((v_m * l_m) <= 0.0d0) then
tmp = t_0
else if ((v_m * l_m) <= 2d+250) then
tmp = c0 * sqrt((a_m / (v_m * l_m)))
else
tmp = t_0
end if
code = tmp
end function
A_m = Math.abs(A);
V_m = Math.abs(V);
l_m = Math.abs(l);
assert c0 < A_m && A_m < V_m && V_m < l_m;
public static double code(double c0, double A_m, double V_m, double l_m) {
double t_0 = c0 * Math.sqrt(((A_m / V_m) / l_m));
double tmp;
if ((V_m * l_m) <= 0.0) {
tmp = t_0;
} else if ((V_m * l_m) <= 2e+250) {
tmp = c0 * Math.sqrt((A_m / (V_m * l_m)));
} else {
tmp = t_0;
}
return tmp;
}
A_m = math.fabs(A) V_m = math.fabs(V) l_m = math.fabs(l) [c0, A_m, V_m, l_m] = sort([c0, A_m, V_m, l_m]) def code(c0, A_m, V_m, l_m): t_0 = c0 * math.sqrt(((A_m / V_m) / l_m)) tmp = 0 if (V_m * l_m) <= 0.0: tmp = t_0 elif (V_m * l_m) <= 2e+250: tmp = c0 * math.sqrt((A_m / (V_m * l_m))) else: tmp = t_0 return tmp
A_m = abs(A) V_m = abs(V) l_m = abs(l) c0, A_m, V_m, l_m = sort([c0, A_m, V_m, l_m]) function code(c0, A_m, V_m, l_m) t_0 = Float64(c0 * sqrt(Float64(Float64(A_m / V_m) / l_m))) tmp = 0.0 if (Float64(V_m * l_m) <= 0.0) tmp = t_0; elseif (Float64(V_m * l_m) <= 2e+250) tmp = Float64(c0 * sqrt(Float64(A_m / Float64(V_m * l_m)))); else tmp = t_0; end return tmp end
A_m = abs(A);
V_m = abs(V);
l_m = abs(l);
c0, A_m, V_m, l_m = num2cell(sort([c0, A_m, V_m, l_m])){:}
function tmp_2 = code(c0, A_m, V_m, l_m)
t_0 = c0 * sqrt(((A_m / V_m) / l_m));
tmp = 0.0;
if ((V_m * l_m) <= 0.0)
tmp = t_0;
elseif ((V_m * l_m) <= 2e+250)
tmp = c0 * sqrt((A_m / (V_m * l_m)));
else
tmp = t_0;
end
tmp_2 = tmp;
end
A_m = N[Abs[A], $MachinePrecision]
V_m = N[Abs[V], $MachinePrecision]
l_m = N[Abs[l], $MachinePrecision]
NOTE: c0, A_m, V_m, and l_m should be sorted in increasing order before calling this function.
code[c0_, A$95$m_, V$95$m_, l$95$m_] := Block[{t$95$0 = N[(c0 * N[Sqrt[N[(N[(A$95$m / V$95$m), $MachinePrecision] / l$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(V$95$m * l$95$m), $MachinePrecision], 0.0], t$95$0, If[LessEqual[N[(V$95$m * l$95$m), $MachinePrecision], 2e+250], N[(c0 * N[Sqrt[N[(A$95$m / N[(V$95$m * l$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
A_m = \left|A\right|
\\
V_m = \left|V\right|
\\
l_m = \left|\ell\right|
\\
[c0, A_m, V_m, l_m] = \mathsf{sort}([c0, A_m, V_m, l_m])\\
\\
\begin{array}{l}
t_0 := c0 \cdot \sqrt{\frac{\frac{A\_m}{V\_m}}{l\_m}}\\
\mathbf{if}\;V\_m \cdot l\_m \leq 0:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;V\_m \cdot l\_m \leq 2 \cdot 10^{+250}:\\
\;\;\;\;c0 \cdot \sqrt{\frac{A\_m}{V\_m \cdot l\_m}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (*.f64 V l) < 0.0 or 1.9999999999999998e250 < (*.f64 V l) Initial program 74.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6474.1
Applied rewrites74.1%
if 0.0 < (*.f64 V l) < 1.9999999999999998e250Initial program 74.0%
A_m = (fabs.f64 A) V_m = (fabs.f64 V) l_m = (fabs.f64 l) NOTE: c0, A_m, V_m, and l_m should be sorted in increasing order before calling this function. (FPCore (c0 A_m V_m l_m) :precision binary64 (if (<= A_m 5e-49) (* c0 (sqrt (/ (/ A_m V_m) l_m))) (/ c0 (sqrt (/ (* l_m V_m) A_m)))))
A_m = fabs(A);
V_m = fabs(V);
l_m = fabs(l);
assert(c0 < A_m && A_m < V_m && V_m < l_m);
double code(double c0, double A_m, double V_m, double l_m) {
double tmp;
if (A_m <= 5e-49) {
tmp = c0 * sqrt(((A_m / V_m) / l_m));
} else {
tmp = c0 / sqrt(((l_m * V_m) / A_m));
}
return tmp;
}
A_m = private
V_m = private
l_m = private
NOTE: c0, A_m, V_m, and l_m 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(c0, a_m, v_m, l_m)
use fmin_fmax_functions
real(8), intent (in) :: c0
real(8), intent (in) :: a_m
real(8), intent (in) :: v_m
real(8), intent (in) :: l_m
real(8) :: tmp
if (a_m <= 5d-49) then
tmp = c0 * sqrt(((a_m / v_m) / l_m))
else
tmp = c0 / sqrt(((l_m * v_m) / a_m))
end if
code = tmp
end function
A_m = Math.abs(A);
V_m = Math.abs(V);
l_m = Math.abs(l);
assert c0 < A_m && A_m < V_m && V_m < l_m;
public static double code(double c0, double A_m, double V_m, double l_m) {
double tmp;
if (A_m <= 5e-49) {
tmp = c0 * Math.sqrt(((A_m / V_m) / l_m));
} else {
tmp = c0 / Math.sqrt(((l_m * V_m) / A_m));
}
return tmp;
}
A_m = math.fabs(A) V_m = math.fabs(V) l_m = math.fabs(l) [c0, A_m, V_m, l_m] = sort([c0, A_m, V_m, l_m]) def code(c0, A_m, V_m, l_m): tmp = 0 if A_m <= 5e-49: tmp = c0 * math.sqrt(((A_m / V_m) / l_m)) else: tmp = c0 / math.sqrt(((l_m * V_m) / A_m)) return tmp
A_m = abs(A) V_m = abs(V) l_m = abs(l) c0, A_m, V_m, l_m = sort([c0, A_m, V_m, l_m]) function code(c0, A_m, V_m, l_m) tmp = 0.0 if (A_m <= 5e-49) tmp = Float64(c0 * sqrt(Float64(Float64(A_m / V_m) / l_m))); else tmp = Float64(c0 / sqrt(Float64(Float64(l_m * V_m) / A_m))); end return tmp end
A_m = abs(A);
V_m = abs(V);
l_m = abs(l);
c0, A_m, V_m, l_m = num2cell(sort([c0, A_m, V_m, l_m])){:}
function tmp_2 = code(c0, A_m, V_m, l_m)
tmp = 0.0;
if (A_m <= 5e-49)
tmp = c0 * sqrt(((A_m / V_m) / l_m));
else
tmp = c0 / sqrt(((l_m * V_m) / A_m));
end
tmp_2 = tmp;
end
A_m = N[Abs[A], $MachinePrecision] V_m = N[Abs[V], $MachinePrecision] l_m = N[Abs[l], $MachinePrecision] NOTE: c0, A_m, V_m, and l_m should be sorted in increasing order before calling this function. code[c0_, A$95$m_, V$95$m_, l$95$m_] := If[LessEqual[A$95$m, 5e-49], N[(c0 * N[Sqrt[N[(N[(A$95$m / V$95$m), $MachinePrecision] / l$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(c0 / N[Sqrt[N[(N[(l$95$m * V$95$m), $MachinePrecision] / A$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
A_m = \left|A\right|
\\
V_m = \left|V\right|
\\
l_m = \left|\ell\right|
\\
[c0, A_m, V_m, l_m] = \mathsf{sort}([c0, A_m, V_m, l_m])\\
\\
\begin{array}{l}
\mathbf{if}\;A\_m \leq 5 \cdot 10^{-49}:\\
\;\;\;\;c0 \cdot \sqrt{\frac{\frac{A\_m}{V\_m}}{l\_m}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c0}{\sqrt{\frac{l\_m \cdot V\_m}{A\_m}}}\\
\end{array}
\end{array}
if A < 4.9999999999999999e-49Initial program 74.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6474.1
Applied rewrites74.1%
if 4.9999999999999999e-49 < A Initial program 74.0%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
div-flipN/A
sqrt-divN/A
metadata-evalN/A
mult-flip-revN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f6473.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6473.9
Applied rewrites73.9%
A_m = (fabs.f64 A) V_m = (fabs.f64 V) l_m = (fabs.f64 l) NOTE: c0, A_m, V_m, and l_m should be sorted in increasing order before calling this function. (FPCore (c0 A_m V_m l_m) :precision binary64 (* c0 (sqrt (/ A_m (* V_m l_m)))))
A_m = fabs(A);
V_m = fabs(V);
l_m = fabs(l);
assert(c0 < A_m && A_m < V_m && V_m < l_m);
double code(double c0, double A_m, double V_m, double l_m) {
return c0 * sqrt((A_m / (V_m * l_m)));
}
A_m = private
V_m = private
l_m = private
NOTE: c0, A_m, V_m, and l_m 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(c0, a_m, v_m, l_m)
use fmin_fmax_functions
real(8), intent (in) :: c0
real(8), intent (in) :: a_m
real(8), intent (in) :: v_m
real(8), intent (in) :: l_m
code = c0 * sqrt((a_m / (v_m * l_m)))
end function
A_m = Math.abs(A);
V_m = Math.abs(V);
l_m = Math.abs(l);
assert c0 < A_m && A_m < V_m && V_m < l_m;
public static double code(double c0, double A_m, double V_m, double l_m) {
return c0 * Math.sqrt((A_m / (V_m * l_m)));
}
A_m = math.fabs(A) V_m = math.fabs(V) l_m = math.fabs(l) [c0, A_m, V_m, l_m] = sort([c0, A_m, V_m, l_m]) def code(c0, A_m, V_m, l_m): return c0 * math.sqrt((A_m / (V_m * l_m)))
A_m = abs(A) V_m = abs(V) l_m = abs(l) c0, A_m, V_m, l_m = sort([c0, A_m, V_m, l_m]) function code(c0, A_m, V_m, l_m) return Float64(c0 * sqrt(Float64(A_m / Float64(V_m * l_m)))) end
A_m = abs(A);
V_m = abs(V);
l_m = abs(l);
c0, A_m, V_m, l_m = num2cell(sort([c0, A_m, V_m, l_m])){:}
function tmp = code(c0, A_m, V_m, l_m)
tmp = c0 * sqrt((A_m / (V_m * l_m)));
end
A_m = N[Abs[A], $MachinePrecision] V_m = N[Abs[V], $MachinePrecision] l_m = N[Abs[l], $MachinePrecision] NOTE: c0, A_m, V_m, and l_m should be sorted in increasing order before calling this function. code[c0_, A$95$m_, V$95$m_, l$95$m_] := N[(c0 * N[Sqrt[N[(A$95$m / N[(V$95$m * l$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
A_m = \left|A\right|
\\
V_m = \left|V\right|
\\
l_m = \left|\ell\right|
\\
[c0, A_m, V_m, l_m] = \mathsf{sort}([c0, A_m, V_m, l_m])\\
\\
c0 \cdot \sqrt{\frac{A\_m}{V\_m \cdot l\_m}}
\end{array}
Initial program 74.0%
herbie shell --seed 2025151
(FPCore (c0 A V l)
:name "Henrywood and Agarwal, Equation (3)"
:precision binary64
(* c0 (sqrt (/ A (* V l)))))