
(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]
c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
Herbie found 8 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]
c0 \cdot \sqrt{\frac{A}{V \cdot \ell}}
(FPCore (c0 A V l)
:precision binary64
(let* ((t_0 (fmax (fabs V) (fabs l))) (t_1 (fmin (fabs V) (fabs l))))
(if (<= (fabs A) 1e-19)
(* c0 (/ (sqrt (/ (fabs A) t_1)) (sqrt t_0)))
(* c0 (/ (sqrt (/ (fabs A) t_0)) (sqrt t_1))))))double code(double c0, double A, double V, double l) {
double t_0 = fmax(fabs(V), fabs(l));
double t_1 = fmin(fabs(V), fabs(l));
double tmp;
if (fabs(A) <= 1e-19) {
tmp = c0 * (sqrt((fabs(A) / t_1)) / sqrt(t_0));
} else {
tmp = c0 * (sqrt((fabs(A) / t_0)) / sqrt(t_1));
}
return tmp;
}
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
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = fmax(abs(v), abs(l))
t_1 = fmin(abs(v), abs(l))
if (abs(a) <= 1d-19) then
tmp = c0 * (sqrt((abs(a) / t_1)) / sqrt(t_0))
else
tmp = c0 * (sqrt((abs(a) / t_0)) / sqrt(t_1))
end if
code = tmp
end function
public static double code(double c0, double A, double V, double l) {
double t_0 = fmax(Math.abs(V), Math.abs(l));
double t_1 = fmin(Math.abs(V), Math.abs(l));
double tmp;
if (Math.abs(A) <= 1e-19) {
tmp = c0 * (Math.sqrt((Math.abs(A) / t_1)) / Math.sqrt(t_0));
} else {
tmp = c0 * (Math.sqrt((Math.abs(A) / t_0)) / Math.sqrt(t_1));
}
return tmp;
}
def code(c0, A, V, l): t_0 = fmax(math.fabs(V), math.fabs(l)) t_1 = fmin(math.fabs(V), math.fabs(l)) tmp = 0 if math.fabs(A) <= 1e-19: tmp = c0 * (math.sqrt((math.fabs(A) / t_1)) / math.sqrt(t_0)) else: tmp = c0 * (math.sqrt((math.fabs(A) / t_0)) / math.sqrt(t_1)) return tmp
function code(c0, A, V, l) t_0 = fmax(abs(V), abs(l)) t_1 = fmin(abs(V), abs(l)) tmp = 0.0 if (abs(A) <= 1e-19) tmp = Float64(c0 * Float64(sqrt(Float64(abs(A) / t_1)) / sqrt(t_0))); else tmp = Float64(c0 * Float64(sqrt(Float64(abs(A) / t_0)) / sqrt(t_1))); end return tmp end
function tmp_2 = code(c0, A, V, l) t_0 = max(abs(V), abs(l)); t_1 = min(abs(V), abs(l)); tmp = 0.0; if (abs(A) <= 1e-19) tmp = c0 * (sqrt((abs(A) / t_1)) / sqrt(t_0)); else tmp = c0 * (sqrt((abs(A) / t_0)) / sqrt(t_1)); end tmp_2 = tmp; end
code[c0_, A_, V_, l_] := Block[{t$95$0 = N[Max[N[Abs[V], $MachinePrecision], N[Abs[l], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Min[N[Abs[V], $MachinePrecision], N[Abs[l], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Abs[A], $MachinePrecision], 1e-19], N[(c0 * N[(N[Sqrt[N[(N[Abs[A], $MachinePrecision] / t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[Sqrt[N[(N[Abs[A], $MachinePrecision] / t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|V\right|, \left|\ell\right|\right)\\
t_1 := \mathsf{min}\left(\left|V\right|, \left|\ell\right|\right)\\
\mathbf{if}\;\left|A\right| \leq 10^{-19}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\frac{\left|A\right|}{t\_1}}}{\sqrt{t\_0}}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\frac{\left|A\right|}{t\_0}}}{\sqrt{t\_1}}\\
\end{array}
if A < 9.9999999999999998e-20Initial program 73.2%
lift-sqrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
sqrt-divN/A
lower-unsound-/.f64N/A
lower-unsound-sqrt.f64N/A
lower-/.f64N/A
lower-unsound-sqrt.f6442.2%
Applied rewrites42.2%
if 9.9999999999999998e-20 < A Initial program 73.2%
lift-sqrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
sqrt-divN/A
lower-unsound-/.f64N/A
lower-unsound-sqrt.f64N/A
lower-/.f64N/A
lower-unsound-sqrt.f6442.2%
Applied rewrites42.2%
(FPCore (c0 A V l)
:precision binary64
(let* ((t_0 (fmax (fabs V) (fabs l))) (t_1 (fmin (fabs V) (fabs l))))
(if (<= (fabs A) 5e+26)
(* c0 (/ (sqrt (/ (fabs A) t_1)) (sqrt t_0)))
(* (sqrt (/ (fabs A) t_0)) (/ c0 (sqrt t_1))))))double code(double c0, double A, double V, double l) {
double t_0 = fmax(fabs(V), fabs(l));
double t_1 = fmin(fabs(V), fabs(l));
double tmp;
if (fabs(A) <= 5e+26) {
tmp = c0 * (sqrt((fabs(A) / t_1)) / sqrt(t_0));
} else {
tmp = sqrt((fabs(A) / t_0)) * (c0 / sqrt(t_1));
}
return tmp;
}
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
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = fmax(abs(v), abs(l))
t_1 = fmin(abs(v), abs(l))
if (abs(a) <= 5d+26) then
tmp = c0 * (sqrt((abs(a) / t_1)) / sqrt(t_0))
else
tmp = sqrt((abs(a) / t_0)) * (c0 / sqrt(t_1))
end if
code = tmp
end function
public static double code(double c0, double A, double V, double l) {
double t_0 = fmax(Math.abs(V), Math.abs(l));
double t_1 = fmin(Math.abs(V), Math.abs(l));
double tmp;
if (Math.abs(A) <= 5e+26) {
tmp = c0 * (Math.sqrt((Math.abs(A) / t_1)) / Math.sqrt(t_0));
} else {
tmp = Math.sqrt((Math.abs(A) / t_0)) * (c0 / Math.sqrt(t_1));
}
return tmp;
}
def code(c0, A, V, l): t_0 = fmax(math.fabs(V), math.fabs(l)) t_1 = fmin(math.fabs(V), math.fabs(l)) tmp = 0 if math.fabs(A) <= 5e+26: tmp = c0 * (math.sqrt((math.fabs(A) / t_1)) / math.sqrt(t_0)) else: tmp = math.sqrt((math.fabs(A) / t_0)) * (c0 / math.sqrt(t_1)) return tmp
function code(c0, A, V, l) t_0 = fmax(abs(V), abs(l)) t_1 = fmin(abs(V), abs(l)) tmp = 0.0 if (abs(A) <= 5e+26) tmp = Float64(c0 * Float64(sqrt(Float64(abs(A) / t_1)) / sqrt(t_0))); else tmp = Float64(sqrt(Float64(abs(A) / t_0)) * Float64(c0 / sqrt(t_1))); end return tmp end
function tmp_2 = code(c0, A, V, l) t_0 = max(abs(V), abs(l)); t_1 = min(abs(V), abs(l)); tmp = 0.0; if (abs(A) <= 5e+26) tmp = c0 * (sqrt((abs(A) / t_1)) / sqrt(t_0)); else tmp = sqrt((abs(A) / t_0)) * (c0 / sqrt(t_1)); end tmp_2 = tmp; end
code[c0_, A_, V_, l_] := Block[{t$95$0 = N[Max[N[Abs[V], $MachinePrecision], N[Abs[l], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Min[N[Abs[V], $MachinePrecision], N[Abs[l], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Abs[A], $MachinePrecision], 5e+26], N[(c0 * N[(N[Sqrt[N[(N[Abs[A], $MachinePrecision] / t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(N[Abs[A], $MachinePrecision] / t$95$0), $MachinePrecision]], $MachinePrecision] * N[(c0 / N[Sqrt[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|V\right|, \left|\ell\right|\right)\\
t_1 := \mathsf{min}\left(\left|V\right|, \left|\ell\right|\right)\\
\mathbf{if}\;\left|A\right| \leq 5 \cdot 10^{+26}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\frac{\left|A\right|}{t\_1}}}{\sqrt{t\_0}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{\left|A\right|}{t\_0}} \cdot \frac{c0}{\sqrt{t\_1}}\\
\end{array}
if A < 5.0000000000000001e26Initial program 73.2%
lift-sqrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
sqrt-divN/A
lower-unsound-/.f64N/A
lower-unsound-sqrt.f64N/A
lower-/.f64N/A
lower-unsound-sqrt.f6442.2%
Applied rewrites42.2%
if 5.0000000000000001e26 < A Initial program 73.2%
lift-sqrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
sqrt-divN/A
lower-unsound-/.f64N/A
lower-unsound-sqrt.f64N/A
lower-/.f64N/A
lower-unsound-sqrt.f6442.2%
Applied rewrites42.2%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6441.0%
Applied rewrites41.0%
(FPCore (c0 A V l)
:precision binary64
(let* ((t_0 (fmax (fabs V) (fabs l))) (t_1 (fmin (fabs V) (fabs l))))
(if (<= (fabs A) 1.2e+31)
(* (sqrt (/ (fabs A) t_1)) (/ c0 (sqrt t_0)))
(* (sqrt (/ (fabs A) t_0)) (/ c0 (sqrt t_1))))))double code(double c0, double A, double V, double l) {
double t_0 = fmax(fabs(V), fabs(l));
double t_1 = fmin(fabs(V), fabs(l));
double tmp;
if (fabs(A) <= 1.2e+31) {
tmp = sqrt((fabs(A) / t_1)) * (c0 / sqrt(t_0));
} else {
tmp = sqrt((fabs(A) / t_0)) * (c0 / sqrt(t_1));
}
return tmp;
}
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
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = fmax(abs(v), abs(l))
t_1 = fmin(abs(v), abs(l))
if (abs(a) <= 1.2d+31) then
tmp = sqrt((abs(a) / t_1)) * (c0 / sqrt(t_0))
else
tmp = sqrt((abs(a) / t_0)) * (c0 / sqrt(t_1))
end if
code = tmp
end function
public static double code(double c0, double A, double V, double l) {
double t_0 = fmax(Math.abs(V), Math.abs(l));
double t_1 = fmin(Math.abs(V), Math.abs(l));
double tmp;
if (Math.abs(A) <= 1.2e+31) {
tmp = Math.sqrt((Math.abs(A) / t_1)) * (c0 / Math.sqrt(t_0));
} else {
tmp = Math.sqrt((Math.abs(A) / t_0)) * (c0 / Math.sqrt(t_1));
}
return tmp;
}
def code(c0, A, V, l): t_0 = fmax(math.fabs(V), math.fabs(l)) t_1 = fmin(math.fabs(V), math.fabs(l)) tmp = 0 if math.fabs(A) <= 1.2e+31: tmp = math.sqrt((math.fabs(A) / t_1)) * (c0 / math.sqrt(t_0)) else: tmp = math.sqrt((math.fabs(A) / t_0)) * (c0 / math.sqrt(t_1)) return tmp
function code(c0, A, V, l) t_0 = fmax(abs(V), abs(l)) t_1 = fmin(abs(V), abs(l)) tmp = 0.0 if (abs(A) <= 1.2e+31) tmp = Float64(sqrt(Float64(abs(A) / t_1)) * Float64(c0 / sqrt(t_0))); else tmp = Float64(sqrt(Float64(abs(A) / t_0)) * Float64(c0 / sqrt(t_1))); end return tmp end
function tmp_2 = code(c0, A, V, l) t_0 = max(abs(V), abs(l)); t_1 = min(abs(V), abs(l)); tmp = 0.0; if (abs(A) <= 1.2e+31) tmp = sqrt((abs(A) / t_1)) * (c0 / sqrt(t_0)); else tmp = sqrt((abs(A) / t_0)) * (c0 / sqrt(t_1)); end tmp_2 = tmp; end
code[c0_, A_, V_, l_] := Block[{t$95$0 = N[Max[N[Abs[V], $MachinePrecision], N[Abs[l], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Min[N[Abs[V], $MachinePrecision], N[Abs[l], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Abs[A], $MachinePrecision], 1.2e+31], N[(N[Sqrt[N[(N[Abs[A], $MachinePrecision] / t$95$1), $MachinePrecision]], $MachinePrecision] * N[(c0 / N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(N[Abs[A], $MachinePrecision] / t$95$0), $MachinePrecision]], $MachinePrecision] * N[(c0 / N[Sqrt[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|V\right|, \left|\ell\right|\right)\\
t_1 := \mathsf{min}\left(\left|V\right|, \left|\ell\right|\right)\\
\mathbf{if}\;\left|A\right| \leq 1.2 \cdot 10^{+31}:\\
\;\;\;\;\sqrt{\frac{\left|A\right|}{t\_1}} \cdot \frac{c0}{\sqrt{t\_0}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{\left|A\right|}{t\_0}} \cdot \frac{c0}{\sqrt{t\_1}}\\
\end{array}
if A < 1.1999999999999999e31Initial program 73.2%
lift-sqrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
sqrt-divN/A
lower-unsound-/.f64N/A
lower-unsound-sqrt.f64N/A
lower-/.f64N/A
lower-unsound-sqrt.f6442.2%
Applied rewrites42.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6440.9%
Applied rewrites40.9%
if 1.1999999999999999e31 < A Initial program 73.2%
lift-sqrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
sqrt-divN/A
lower-unsound-/.f64N/A
lower-unsound-sqrt.f64N/A
lower-/.f64N/A
lower-unsound-sqrt.f6442.2%
Applied rewrites42.2%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6441.0%
Applied rewrites41.0%
(FPCore (c0 A V l)
:precision binary64
(let* ((t_0 (* (fabs V) (fabs l)))
(t_1 (* (sqrt (/ (fabs A) (fabs V))) (/ c0 (sqrt (fabs l))))))
(if (<= t_0 1e-303)
t_1
(if (<= t_0 5e+305)
(* c0 (/ (sqrt (fabs A)) (sqrt (* (fabs l) (fabs V)))))
t_1))))double code(double c0, double A, double V, double l) {
double t_0 = fabs(V) * fabs(l);
double t_1 = sqrt((fabs(A) / fabs(V))) * (c0 / sqrt(fabs(l)));
double tmp;
if (t_0 <= 1e-303) {
tmp = t_1;
} else if (t_0 <= 5e+305) {
tmp = c0 * (sqrt(fabs(A)) / sqrt((fabs(l) * fabs(V))));
} else {
tmp = t_1;
}
return tmp;
}
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
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = abs(v) * abs(l)
t_1 = sqrt((abs(a) / abs(v))) * (c0 / sqrt(abs(l)))
if (t_0 <= 1d-303) then
tmp = t_1
else if (t_0 <= 5d+305) then
tmp = c0 * (sqrt(abs(a)) / sqrt((abs(l) * abs(v))))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double c0, double A, double V, double l) {
double t_0 = Math.abs(V) * Math.abs(l);
double t_1 = Math.sqrt((Math.abs(A) / Math.abs(V))) * (c0 / Math.sqrt(Math.abs(l)));
double tmp;
if (t_0 <= 1e-303) {
tmp = t_1;
} else if (t_0 <= 5e+305) {
tmp = c0 * (Math.sqrt(Math.abs(A)) / Math.sqrt((Math.abs(l) * Math.abs(V))));
} else {
tmp = t_1;
}
return tmp;
}
def code(c0, A, V, l): t_0 = math.fabs(V) * math.fabs(l) t_1 = math.sqrt((math.fabs(A) / math.fabs(V))) * (c0 / math.sqrt(math.fabs(l))) tmp = 0 if t_0 <= 1e-303: tmp = t_1 elif t_0 <= 5e+305: tmp = c0 * (math.sqrt(math.fabs(A)) / math.sqrt((math.fabs(l) * math.fabs(V)))) else: tmp = t_1 return tmp
function code(c0, A, V, l) t_0 = Float64(abs(V) * abs(l)) t_1 = Float64(sqrt(Float64(abs(A) / abs(V))) * Float64(c0 / sqrt(abs(l)))) tmp = 0.0 if (t_0 <= 1e-303) tmp = t_1; elseif (t_0 <= 5e+305) tmp = Float64(c0 * Float64(sqrt(abs(A)) / sqrt(Float64(abs(l) * abs(V))))); else tmp = t_1; end return tmp end
function tmp_2 = code(c0, A, V, l) t_0 = abs(V) * abs(l); t_1 = sqrt((abs(A) / abs(V))) * (c0 / sqrt(abs(l))); tmp = 0.0; if (t_0 <= 1e-303) tmp = t_1; elseif (t_0 <= 5e+305) tmp = c0 * (sqrt(abs(A)) / sqrt((abs(l) * abs(V)))); else tmp = t_1; end tmp_2 = tmp; end
code[c0_, A_, V_, l_] := Block[{t$95$0 = N[(N[Abs[V], $MachinePrecision] * N[Abs[l], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(N[Abs[A], $MachinePrecision] / N[Abs[V], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(c0 / N[Sqrt[N[Abs[l], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e-303], t$95$1, If[LessEqual[t$95$0, 5e+305], N[(c0 * N[(N[Sqrt[N[Abs[A], $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Abs[l], $MachinePrecision] * N[Abs[V], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := \left|V\right| \cdot \left|\ell\right|\\
t_1 := \sqrt{\frac{\left|A\right|}{\left|V\right|}} \cdot \frac{c0}{\sqrt{\left|\ell\right|}}\\
\mathbf{if}\;t\_0 \leq 10^{-303}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+305}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\left|A\right|}}{\sqrt{\left|\ell\right| \cdot \left|V\right|}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (*.f64 V l) < 9.9999999999999993e-304 or 5.0000000000000001e305 < (*.f64 V l) Initial program 73.2%
lift-sqrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
sqrt-divN/A
lower-unsound-/.f64N/A
lower-unsound-sqrt.f64N/A
lower-/.f64N/A
lower-unsound-sqrt.f6442.2%
Applied rewrites42.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6440.9%
Applied rewrites40.9%
if 9.9999999999999993e-304 < (*.f64 V l) < 5.0000000000000001e305Initial program 73.2%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-unsound-/.f64N/A
lower-unsound-sqrt.f64N/A
lower-unsound-sqrt.f6441.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.7%
Applied rewrites41.7%
(FPCore (c0 A V l)
:precision binary64
(let* ((t_0 (* (fabs V) (fabs l))))
(if (<= t_0 0.0)
(* c0 (sqrt (/ (/ (fabs A) (fabs V)) (fabs l))))
(if (<= t_0 5e+305)
(* c0 (/ (sqrt (fabs A)) (sqrt (* (fabs l) (fabs V)))))
(* c0 (sqrt (/ (/ (fabs A) (fabs l)) (fabs V))))))))double code(double c0, double A, double V, double l) {
double t_0 = fabs(V) * fabs(l);
double tmp;
if (t_0 <= 0.0) {
tmp = c0 * sqrt(((fabs(A) / fabs(V)) / fabs(l)));
} else if (t_0 <= 5e+305) {
tmp = c0 * (sqrt(fabs(A)) / sqrt((fabs(l) * fabs(V))));
} else {
tmp = c0 * sqrt(((fabs(A) / fabs(l)) / fabs(V)));
}
return tmp;
}
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
real(8) :: t_0
real(8) :: tmp
t_0 = abs(v) * abs(l)
if (t_0 <= 0.0d0) then
tmp = c0 * sqrt(((abs(a) / abs(v)) / abs(l)))
else if (t_0 <= 5d+305) then
tmp = c0 * (sqrt(abs(a)) / sqrt((abs(l) * abs(v))))
else
tmp = c0 * sqrt(((abs(a) / abs(l)) / abs(v)))
end if
code = tmp
end function
public static double code(double c0, double A, double V, double l) {
double t_0 = Math.abs(V) * Math.abs(l);
double tmp;
if (t_0 <= 0.0) {
tmp = c0 * Math.sqrt(((Math.abs(A) / Math.abs(V)) / Math.abs(l)));
} else if (t_0 <= 5e+305) {
tmp = c0 * (Math.sqrt(Math.abs(A)) / Math.sqrt((Math.abs(l) * Math.abs(V))));
} else {
tmp = c0 * Math.sqrt(((Math.abs(A) / Math.abs(l)) / Math.abs(V)));
}
return tmp;
}
def code(c0, A, V, l): t_0 = math.fabs(V) * math.fabs(l) tmp = 0 if t_0 <= 0.0: tmp = c0 * math.sqrt(((math.fabs(A) / math.fabs(V)) / math.fabs(l))) elif t_0 <= 5e+305: tmp = c0 * (math.sqrt(math.fabs(A)) / math.sqrt((math.fabs(l) * math.fabs(V)))) else: tmp = c0 * math.sqrt(((math.fabs(A) / math.fabs(l)) / math.fabs(V))) return tmp
function code(c0, A, V, l) t_0 = Float64(abs(V) * abs(l)) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(c0 * sqrt(Float64(Float64(abs(A) / abs(V)) / abs(l)))); elseif (t_0 <= 5e+305) tmp = Float64(c0 * Float64(sqrt(abs(A)) / sqrt(Float64(abs(l) * abs(V))))); else tmp = Float64(c0 * sqrt(Float64(Float64(abs(A) / abs(l)) / abs(V)))); end return tmp end
function tmp_2 = code(c0, A, V, l) t_0 = abs(V) * abs(l); tmp = 0.0; if (t_0 <= 0.0) tmp = c0 * sqrt(((abs(A) / abs(V)) / abs(l))); elseif (t_0 <= 5e+305) tmp = c0 * (sqrt(abs(A)) / sqrt((abs(l) * abs(V)))); else tmp = c0 * sqrt(((abs(A) / abs(l)) / abs(V))); end tmp_2 = tmp; end
code[c0_, A_, V_, l_] := Block[{t$95$0 = N[(N[Abs[V], $MachinePrecision] * N[Abs[l], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(c0 * N[Sqrt[N[(N[(N[Abs[A], $MachinePrecision] / N[Abs[V], $MachinePrecision]), $MachinePrecision] / N[Abs[l], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+305], N[(c0 * N[(N[Sqrt[N[Abs[A], $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Abs[l], $MachinePrecision] * N[Abs[V], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[Sqrt[N[(N[(N[Abs[A], $MachinePrecision] / N[Abs[l], $MachinePrecision]), $MachinePrecision] / N[Abs[V], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \left|V\right| \cdot \left|\ell\right|\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;c0 \cdot \sqrt{\frac{\frac{\left|A\right|}{\left|V\right|}}{\left|\ell\right|}}\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+305}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\left|A\right|}}{\sqrt{\left|\ell\right| \cdot \left|V\right|}}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \sqrt{\frac{\frac{\left|A\right|}{\left|\ell\right|}}{\left|V\right|}}\\
\end{array}
if (*.f64 V l) < 0.0Initial program 73.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6473.8%
Applied rewrites73.8%
if 0.0 < (*.f64 V l) < 5.0000000000000001e305Initial program 73.2%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-unsound-/.f64N/A
lower-unsound-sqrt.f64N/A
lower-unsound-sqrt.f6441.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.7%
Applied rewrites41.7%
if 5.0000000000000001e305 < (*.f64 V l) Initial program 73.2%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6473.7%
Applied rewrites73.7%
(FPCore (c0 A V l)
:precision binary64
(let* ((t_0 (fmin (fabs V) (fabs l)))
(t_1 (fmax (fabs V) (fabs l)))
(t_2 (* t_0 t_1))
(t_3 (* c0 (sqrt (/ (/ (fabs A) t_0) t_1)))))
(if (<= t_2 4e-261)
t_3
(if (<= t_2 1e+236) (* c0 (sqrt (/ (fabs A) t_2))) t_3))))double code(double c0, double A, double V, double l) {
double t_0 = fmin(fabs(V), fabs(l));
double t_1 = fmax(fabs(V), fabs(l));
double t_2 = t_0 * t_1;
double t_3 = c0 * sqrt(((fabs(A) / t_0) / t_1));
double tmp;
if (t_2 <= 4e-261) {
tmp = t_3;
} else if (t_2 <= 1e+236) {
tmp = c0 * sqrt((fabs(A) / t_2));
} else {
tmp = t_3;
}
return tmp;
}
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
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = fmin(abs(v), abs(l))
t_1 = fmax(abs(v), abs(l))
t_2 = t_0 * t_1
t_3 = c0 * sqrt(((abs(a) / t_0) / t_1))
if (t_2 <= 4d-261) then
tmp = t_3
else if (t_2 <= 1d+236) then
tmp = c0 * sqrt((abs(a) / t_2))
else
tmp = t_3
end if
code = tmp
end function
public static double code(double c0, double A, double V, double l) {
double t_0 = fmin(Math.abs(V), Math.abs(l));
double t_1 = fmax(Math.abs(V), Math.abs(l));
double t_2 = t_0 * t_1;
double t_3 = c0 * Math.sqrt(((Math.abs(A) / t_0) / t_1));
double tmp;
if (t_2 <= 4e-261) {
tmp = t_3;
} else if (t_2 <= 1e+236) {
tmp = c0 * Math.sqrt((Math.abs(A) / t_2));
} else {
tmp = t_3;
}
return tmp;
}
def code(c0, A, V, l): t_0 = fmin(math.fabs(V), math.fabs(l)) t_1 = fmax(math.fabs(V), math.fabs(l)) t_2 = t_0 * t_1 t_3 = c0 * math.sqrt(((math.fabs(A) / t_0) / t_1)) tmp = 0 if t_2 <= 4e-261: tmp = t_3 elif t_2 <= 1e+236: tmp = c0 * math.sqrt((math.fabs(A) / t_2)) else: tmp = t_3 return tmp
function code(c0, A, V, l) t_0 = fmin(abs(V), abs(l)) t_1 = fmax(abs(V), abs(l)) t_2 = Float64(t_0 * t_1) t_3 = Float64(c0 * sqrt(Float64(Float64(abs(A) / t_0) / t_1))) tmp = 0.0 if (t_2 <= 4e-261) tmp = t_3; elseif (t_2 <= 1e+236) tmp = Float64(c0 * sqrt(Float64(abs(A) / t_2))); else tmp = t_3; end return tmp end
function tmp_2 = code(c0, A, V, l) t_0 = min(abs(V), abs(l)); t_1 = max(abs(V), abs(l)); t_2 = t_0 * t_1; t_3 = c0 * sqrt(((abs(A) / t_0) / t_1)); tmp = 0.0; if (t_2 <= 4e-261) tmp = t_3; elseif (t_2 <= 1e+236) tmp = c0 * sqrt((abs(A) / t_2)); else tmp = t_3; end tmp_2 = tmp; end
code[c0_, A_, V_, l_] := Block[{t$95$0 = N[Min[N[Abs[V], $MachinePrecision], N[Abs[l], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Abs[V], $MachinePrecision], N[Abs[l], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(c0 * N[Sqrt[N[(N[(N[Abs[A], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, 4e-261], t$95$3, If[LessEqual[t$95$2, 1e+236], N[(c0 * N[Sqrt[N[(N[Abs[A], $MachinePrecision] / t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(\left|V\right|, \left|\ell\right|\right)\\
t_1 := \mathsf{max}\left(\left|V\right|, \left|\ell\right|\right)\\
t_2 := t\_0 \cdot t\_1\\
t_3 := c0 \cdot \sqrt{\frac{\frac{\left|A\right|}{t\_0}}{t\_1}}\\
\mathbf{if}\;t\_2 \leq 4 \cdot 10^{-261}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 10^{+236}:\\
\;\;\;\;c0 \cdot \sqrt{\frac{\left|A\right|}{t\_2}}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
if (*.f64 V l) < 3.9999999999999999e-261 or 1.0000000000000001e236 < (*.f64 V l) Initial program 73.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6473.8%
Applied rewrites73.8%
if 3.9999999999999999e-261 < (*.f64 V l) < 1.0000000000000001e236Initial program 73.2%
(FPCore (c0 A V l)
:precision binary64
(let* ((t_0 (fmax (fabs V) (fabs l))) (t_1 (fmin (fabs V) (fabs l))))
(if (<= (sqrt (/ (fabs A) (* t_1 t_0))) 4e-47)
(* c0 (sqrt (/ (/ (fabs A) t_1) t_0)))
(* c0 (sqrt (/ (/ (fabs A) t_0) t_1))))))double code(double c0, double A, double V, double l) {
double t_0 = fmax(fabs(V), fabs(l));
double t_1 = fmin(fabs(V), fabs(l));
double tmp;
if (sqrt((fabs(A) / (t_1 * t_0))) <= 4e-47) {
tmp = c0 * sqrt(((fabs(A) / t_1) / t_0));
} else {
tmp = c0 * sqrt(((fabs(A) / t_0) / t_1));
}
return tmp;
}
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
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = fmax(abs(v), abs(l))
t_1 = fmin(abs(v), abs(l))
if (sqrt((abs(a) / (t_1 * t_0))) <= 4d-47) then
tmp = c0 * sqrt(((abs(a) / t_1) / t_0))
else
tmp = c0 * sqrt(((abs(a) / t_0) / t_1))
end if
code = tmp
end function
public static double code(double c0, double A, double V, double l) {
double t_0 = fmax(Math.abs(V), Math.abs(l));
double t_1 = fmin(Math.abs(V), Math.abs(l));
double tmp;
if (Math.sqrt((Math.abs(A) / (t_1 * t_0))) <= 4e-47) {
tmp = c0 * Math.sqrt(((Math.abs(A) / t_1) / t_0));
} else {
tmp = c0 * Math.sqrt(((Math.abs(A) / t_0) / t_1));
}
return tmp;
}
def code(c0, A, V, l): t_0 = fmax(math.fabs(V), math.fabs(l)) t_1 = fmin(math.fabs(V), math.fabs(l)) tmp = 0 if math.sqrt((math.fabs(A) / (t_1 * t_0))) <= 4e-47: tmp = c0 * math.sqrt(((math.fabs(A) / t_1) / t_0)) else: tmp = c0 * math.sqrt(((math.fabs(A) / t_0) / t_1)) return tmp
function code(c0, A, V, l) t_0 = fmax(abs(V), abs(l)) t_1 = fmin(abs(V), abs(l)) tmp = 0.0 if (sqrt(Float64(abs(A) / Float64(t_1 * t_0))) <= 4e-47) tmp = Float64(c0 * sqrt(Float64(Float64(abs(A) / t_1) / t_0))); else tmp = Float64(c0 * sqrt(Float64(Float64(abs(A) / t_0) / t_1))); end return tmp end
function tmp_2 = code(c0, A, V, l) t_0 = max(abs(V), abs(l)); t_1 = min(abs(V), abs(l)); tmp = 0.0; if (sqrt((abs(A) / (t_1 * t_0))) <= 4e-47) tmp = c0 * sqrt(((abs(A) / t_1) / t_0)); else tmp = c0 * sqrt(((abs(A) / t_0) / t_1)); end tmp_2 = tmp; end
code[c0_, A_, V_, l_] := Block[{t$95$0 = N[Max[N[Abs[V], $MachinePrecision], N[Abs[l], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Min[N[Abs[V], $MachinePrecision], N[Abs[l], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Sqrt[N[(N[Abs[A], $MachinePrecision] / N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 4e-47], N[(c0 * N[Sqrt[N[(N[(N[Abs[A], $MachinePrecision] / t$95$1), $MachinePrecision] / t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(c0 * N[Sqrt[N[(N[(N[Abs[A], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|V\right|, \left|\ell\right|\right)\\
t_1 := \mathsf{min}\left(\left|V\right|, \left|\ell\right|\right)\\
\mathbf{if}\;\sqrt{\frac{\left|A\right|}{t\_1 \cdot t\_0}} \leq 4 \cdot 10^{-47}:\\
\;\;\;\;c0 \cdot \sqrt{\frac{\frac{\left|A\right|}{t\_1}}{t\_0}}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \sqrt{\frac{\frac{\left|A\right|}{t\_0}}{t\_1}}\\
\end{array}
if (sqrt.f64 (/.f64 A (*.f64 V l))) < 3.9999999999999999e-47Initial program 73.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6473.8%
Applied rewrites73.8%
if 3.9999999999999999e-47 < (sqrt.f64 (/.f64 A (*.f64 V l))) Initial program 73.2%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6473.7%
Applied rewrites73.7%
(FPCore (c0 A V l) :precision binary64 (* c0 (sqrt (/ (fabs A) (* (fabs V) (fabs l))))))
double code(double c0, double A, double V, double l) {
return c0 * sqrt((fabs(A) / (fabs(V) * fabs(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((abs(a) / (abs(v) * abs(l))))
end function
public static double code(double c0, double A, double V, double l) {
return c0 * Math.sqrt((Math.abs(A) / (Math.abs(V) * Math.abs(l))));
}
def code(c0, A, V, l): return c0 * math.sqrt((math.fabs(A) / (math.fabs(V) * math.fabs(l))))
function code(c0, A, V, l) return Float64(c0 * sqrt(Float64(abs(A) / Float64(abs(V) * abs(l))))) end
function tmp = code(c0, A, V, l) tmp = c0 * sqrt((abs(A) / (abs(V) * abs(l)))); end
code[c0_, A_, V_, l_] := N[(c0 * N[Sqrt[N[(N[Abs[A], $MachinePrecision] / N[(N[Abs[V], $MachinePrecision] * N[Abs[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
c0 \cdot \sqrt{\frac{\left|A\right|}{\left|V\right| \cdot \left|\ell\right|}}
Initial program 73.2%
herbie shell --seed 2025214
(FPCore (c0 A V l)
:name "Henrywood and Agarwal, Equation (3)"
:precision binary64
(* c0 (sqrt (/ A (* V l)))))