
(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 7 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 (<= (sqrt (/ (fabs A) (* t_1 t_0))) 1000.0)
(* 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 (sqrt((fabs(A) / (t_1 * t_0))) <= 1000.0) {
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 (sqrt((abs(a) / (t_1 * t_0))) <= 1000.0d0) 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.sqrt((Math.abs(A) / (t_1 * t_0))) <= 1000.0) {
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.sqrt((math.fabs(A) / (t_1 * t_0))) <= 1000.0: 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 (sqrt(Float64(abs(A) / Float64(t_1 * t_0))) <= 1000.0) 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 (sqrt((abs(A) / (t_1 * t_0))) <= 1000.0) 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[Sqrt[N[(N[Abs[A], $MachinePrecision] / N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1000.0], 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}\;\sqrt{\frac{\left|A\right|}{t\_1 \cdot t\_0}} \leq 1000:\\
\;\;\;\;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 (sqrt.f64 (/.f64 A (*.f64 V l))) < 1e3Initial program 73.5%
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.f6441.4%
Applied rewrites41.4%
if 1e3 < (sqrt.f64 (/.f64 A (*.f64 V l))) Initial program 73.5%
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.f6441.8%
Applied rewrites41.8%
(FPCore (c0 A V l)
:precision binary64
(let* ((t_0 (fmin (fabs V) (fabs l)))
(t_1 (fmax (fabs V) (fabs l)))
(t_2 (sqrt t_1))
(t_3 (* t_0 t_1))
(t_4 (sqrt (/ (fabs A) t_0))))
(if (<= t_3 5e-320)
(* t_4 (/ c0 t_2))
(if (<= t_3 1e+257)
(* c0 (/ (sqrt (fabs A)) (sqrt (* t_1 t_0))))
(* c0 (/ t_4 t_2))))))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 = sqrt(t_1);
double t_3 = t_0 * t_1;
double t_4 = sqrt((fabs(A) / t_0));
double tmp;
if (t_3 <= 5e-320) {
tmp = t_4 * (c0 / t_2);
} else if (t_3 <= 1e+257) {
tmp = c0 * (sqrt(fabs(A)) / sqrt((t_1 * t_0)));
} else {
tmp = c0 * (t_4 / t_2);
}
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) :: t_4
real(8) :: tmp
t_0 = fmin(abs(v), abs(l))
t_1 = fmax(abs(v), abs(l))
t_2 = sqrt(t_1)
t_3 = t_0 * t_1
t_4 = sqrt((abs(a) / t_0))
if (t_3 <= 5d-320) then
tmp = t_4 * (c0 / t_2)
else if (t_3 <= 1d+257) then
tmp = c0 * (sqrt(abs(a)) / sqrt((t_1 * t_0)))
else
tmp = c0 * (t_4 / t_2)
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 = Math.sqrt(t_1);
double t_3 = t_0 * t_1;
double t_4 = Math.sqrt((Math.abs(A) / t_0));
double tmp;
if (t_3 <= 5e-320) {
tmp = t_4 * (c0 / t_2);
} else if (t_3 <= 1e+257) {
tmp = c0 * (Math.sqrt(Math.abs(A)) / Math.sqrt((t_1 * t_0)));
} else {
tmp = c0 * (t_4 / t_2);
}
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 = math.sqrt(t_1) t_3 = t_0 * t_1 t_4 = math.sqrt((math.fabs(A) / t_0)) tmp = 0 if t_3 <= 5e-320: tmp = t_4 * (c0 / t_2) elif t_3 <= 1e+257: tmp = c0 * (math.sqrt(math.fabs(A)) / math.sqrt((t_1 * t_0))) else: tmp = c0 * (t_4 / t_2) return tmp
function code(c0, A, V, l) t_0 = fmin(abs(V), abs(l)) t_1 = fmax(abs(V), abs(l)) t_2 = sqrt(t_1) t_3 = Float64(t_0 * t_1) t_4 = sqrt(Float64(abs(A) / t_0)) tmp = 0.0 if (t_3 <= 5e-320) tmp = Float64(t_4 * Float64(c0 / t_2)); elseif (t_3 <= 1e+257) tmp = Float64(c0 * Float64(sqrt(abs(A)) / sqrt(Float64(t_1 * t_0)))); else tmp = Float64(c0 * Float64(t_4 / t_2)); 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 = sqrt(t_1); t_3 = t_0 * t_1; t_4 = sqrt((abs(A) / t_0)); tmp = 0.0; if (t_3 <= 5e-320) tmp = t_4 * (c0 / t_2); elseif (t_3 <= 1e+257) tmp = c0 * (sqrt(abs(A)) / sqrt((t_1 * t_0))); else tmp = c0 * (t_4 / t_2); 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[Sqrt[t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 * t$95$1), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(N[Abs[A], $MachinePrecision] / t$95$0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$3, 5e-320], N[(t$95$4 * N[(c0 / t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 1e+257], N[(c0 * N[(N[Sqrt[N[Abs[A], $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(t$95$4 / t$95$2), $MachinePrecision]), $MachinePrecision]]]]]]]]
\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 := \sqrt{t\_1}\\
t_3 := t\_0 \cdot t\_1\\
t_4 := \sqrt{\frac{\left|A\right|}{t\_0}}\\
\mathbf{if}\;t\_3 \leq 5 \cdot 10^{-320}:\\
\;\;\;\;t\_4 \cdot \frac{c0}{t\_2}\\
\mathbf{elif}\;t\_3 \leq 10^{+257}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\left|A\right|}}{\sqrt{t\_1 \cdot t\_0}}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{t\_4}{t\_2}\\
\end{array}
if (*.f64 V l) < 4.999944335913415e-320Initial program 73.5%
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.f6441.4%
Applied rewrites41.4%
lift-*.f64N/A
*-commutativeN/A
lower-unsound-/.f64N/A
lower-unsound-sqrt.f64N/A
lower-unsound-sqrt.f64N/A
sqrt-divN/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-sqrt.f64N/A
Applied rewrites40.3%
if 4.999944335913415e-320 < (*.f64 V l) < 1e257Initial program 73.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6473.2%
Applied rewrites73.2%
lift-sqrt.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
sqrt-divN/A
lower-unsound-/.f64N/A
lower-unsound-sqrt.f64N/A
lower-unsound-sqrt.f64N/A
*-commutativeN/A
lower-*.f6441.3%
Applied rewrites41.3%
if 1e257 < (*.f64 V l) Initial program 73.5%
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.f6441.4%
Applied rewrites41.4%
(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 (* (sqrt (/ (fabs A) t_0)) (/ c0 (sqrt t_1)))))
(if (<= t_2 5e-320)
t_3
(if (<= t_2 1e+257) (* c0 (/ (sqrt (fabs A)) (sqrt (* t_1 t_0)))) 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 = sqrt((fabs(A) / t_0)) * (c0 / sqrt(t_1));
double tmp;
if (t_2 <= 5e-320) {
tmp = t_3;
} else if (t_2 <= 1e+257) {
tmp = c0 * (sqrt(fabs(A)) / sqrt((t_1 * t_0)));
} 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 = sqrt((abs(a) / t_0)) * (c0 / sqrt(t_1))
if (t_2 <= 5d-320) then
tmp = t_3
else if (t_2 <= 1d+257) then
tmp = c0 * (sqrt(abs(a)) / sqrt((t_1 * t_0)))
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 = Math.sqrt((Math.abs(A) / t_0)) * (c0 / Math.sqrt(t_1));
double tmp;
if (t_2 <= 5e-320) {
tmp = t_3;
} else if (t_2 <= 1e+257) {
tmp = c0 * (Math.sqrt(Math.abs(A)) / Math.sqrt((t_1 * t_0)));
} 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 = math.sqrt((math.fabs(A) / t_0)) * (c0 / math.sqrt(t_1)) tmp = 0 if t_2 <= 5e-320: tmp = t_3 elif t_2 <= 1e+257: tmp = c0 * (math.sqrt(math.fabs(A)) / math.sqrt((t_1 * t_0))) 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(sqrt(Float64(abs(A) / t_0)) * Float64(c0 / sqrt(t_1))) tmp = 0.0 if (t_2 <= 5e-320) tmp = t_3; elseif (t_2 <= 1e+257) tmp = Float64(c0 * Float64(sqrt(abs(A)) / sqrt(Float64(t_1 * t_0)))); 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 = sqrt((abs(A) / t_0)) * (c0 / sqrt(t_1)); tmp = 0.0; if (t_2 <= 5e-320) tmp = t_3; elseif (t_2 <= 1e+257) tmp = c0 * (sqrt(abs(A)) / sqrt((t_1 * t_0))); 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[(N[Sqrt[N[(N[Abs[A], $MachinePrecision] / t$95$0), $MachinePrecision]], $MachinePrecision] * N[(c0 / N[Sqrt[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, 5e-320], t$95$3, If[LessEqual[t$95$2, 1e+257], N[(c0 * N[(N[Sqrt[N[Abs[A], $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 * t$95$0), $MachinePrecision]], $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 := \sqrt{\frac{\left|A\right|}{t\_0}} \cdot \frac{c0}{\sqrt{t\_1}}\\
\mathbf{if}\;t\_2 \leq 5 \cdot 10^{-320}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 10^{+257}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\left|A\right|}}{\sqrt{t\_1 \cdot t\_0}}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
if (*.f64 V l) < 4.999944335913415e-320 or 1e257 < (*.f64 V l) Initial program 73.5%
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.f6441.4%
Applied rewrites41.4%
lift-*.f64N/A
*-commutativeN/A
lower-unsound-/.f64N/A
lower-unsound-sqrt.f64N/A
lower-unsound-sqrt.f64N/A
sqrt-divN/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-sqrt.f64N/A
Applied rewrites40.3%
if 4.999944335913415e-320 < (*.f64 V l) < 1e257Initial program 73.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6473.2%
Applied rewrites73.2%
lift-sqrt.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
sqrt-divN/A
lower-unsound-/.f64N/A
lower-unsound-sqrt.f64N/A
lower-unsound-sqrt.f64N/A
*-commutativeN/A
lower-*.f6441.3%
Applied rewrites41.3%
(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 5e-320)
t_3
(if (<= t_2 5e+306) (* c0 (/ (sqrt (fabs A)) (sqrt (* t_1 t_0)))) 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 <= 5e-320) {
tmp = t_3;
} else if (t_2 <= 5e+306) {
tmp = c0 * (sqrt(fabs(A)) / sqrt((t_1 * t_0)));
} 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 <= 5d-320) then
tmp = t_3
else if (t_2 <= 5d+306) then
tmp = c0 * (sqrt(abs(a)) / sqrt((t_1 * t_0)))
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 <= 5e-320) {
tmp = t_3;
} else if (t_2 <= 5e+306) {
tmp = c0 * (Math.sqrt(Math.abs(A)) / Math.sqrt((t_1 * t_0)));
} 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 <= 5e-320: tmp = t_3 elif t_2 <= 5e+306: tmp = c0 * (math.sqrt(math.fabs(A)) / math.sqrt((t_1 * t_0))) 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 <= 5e-320) tmp = t_3; elseif (t_2 <= 5e+306) tmp = Float64(c0 * Float64(sqrt(abs(A)) / sqrt(Float64(t_1 * t_0)))); 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 <= 5e-320) tmp = t_3; elseif (t_2 <= 5e+306) tmp = c0 * (sqrt(abs(A)) / sqrt((t_1 * t_0))); 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, 5e-320], t$95$3, If[LessEqual[t$95$2, 5e+306], N[(c0 * N[(N[Sqrt[N[Abs[A], $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 * t$95$0), $MachinePrecision]], $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 5 \cdot 10^{-320}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+306}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\left|A\right|}}{\sqrt{t\_1 \cdot t\_0}}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
if (*.f64 V l) < 4.999944335913415e-320 or 4.9999999999999999e306 < (*.f64 V l) Initial program 73.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6473.4%
Applied rewrites73.4%
if 4.999944335913415e-320 < (*.f64 V l) < 4.9999999999999999e306Initial program 73.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6473.2%
Applied rewrites73.2%
lift-sqrt.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
sqrt-divN/A
lower-unsound-/.f64N/A
lower-unsound-sqrt.f64N/A
lower-unsound-sqrt.f64N/A
*-commutativeN/A
lower-*.f6441.3%
Applied rewrites41.3%
(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))) 6e+16)
(* 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))) <= 6e+16) {
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))) <= 6d+16) 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))) <= 6e+16) {
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))) <= 6e+16: 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))) <= 6e+16) 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))) <= 6e+16) 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], 6e+16], 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 6 \cdot 10^{+16}:\\
\;\;\;\;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))) < 6e16Initial program 73.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6473.4%
Applied rewrites73.4%
if 6e16 < (sqrt.f64 (/.f64 A (*.f64 V l))) Initial program 73.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6473.2%
Applied rewrites73.2%
(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 1e-316)
t_3
(if (<= t_2 4e+275) (* 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 <= 1e-316) {
tmp = t_3;
} else if (t_2 <= 4e+275) {
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 <= 1d-316) then
tmp = t_3
else if (t_2 <= 4d+275) 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 <= 1e-316) {
tmp = t_3;
} else if (t_2 <= 4e+275) {
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 <= 1e-316: tmp = t_3 elif t_2 <= 4e+275: 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 <= 1e-316) tmp = t_3; elseif (t_2 <= 4e+275) 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 <= 1e-316) tmp = t_3; elseif (t_2 <= 4e+275) 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, 1e-316], t$95$3, If[LessEqual[t$95$2, 4e+275], 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 10^{-316}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+275}:\\
\;\;\;\;c0 \cdot \sqrt{\frac{\left|A\right|}{t\_2}}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
if (*.f64 V l) < 9.9999998365971443e-317 or 3.9999999999999998e275 < (*.f64 V l) Initial program 73.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6473.4%
Applied rewrites73.4%
if 9.9999998365971443e-317 < (*.f64 V l) < 3.9999999999999998e275Initial program 73.5%
(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.5%
herbie shell --seed 2025209
(FPCore (c0 A V l)
:name "Henrywood and Agarwal, Equation (3)"
:precision binary64
(* c0 (sqrt (/ A (* V l)))))