
(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 9 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 (* c0 (/ (/ (sqrt (fabs A)) (sqrt (fmax (fabs V) (fabs l)))) (sqrt (fmin (fabs V) (fabs l))))))
double code(double c0, double A, double V, double l) {
return c0 * ((sqrt(fabs(A)) / sqrt(fmax(fabs(V), fabs(l)))) / sqrt(fmin(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)) / sqrt(fmax(abs(v), abs(l)))) / sqrt(fmin(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.sqrt(fmax(Math.abs(V), Math.abs(l)))) / Math.sqrt(fmin(Math.abs(V), Math.abs(l))));
}
def code(c0, A, V, l): return c0 * ((math.sqrt(math.fabs(A)) / math.sqrt(fmax(math.fabs(V), math.fabs(l)))) / math.sqrt(fmin(math.fabs(V), math.fabs(l))))
function code(c0, A, V, l) return Float64(c0 * Float64(Float64(sqrt(abs(A)) / sqrt(fmax(abs(V), abs(l)))) / sqrt(fmin(abs(V), abs(l))))) end
function tmp = code(c0, A, V, l) tmp = c0 * ((sqrt(abs(A)) / sqrt(max(abs(V), abs(l)))) / sqrt(min(abs(V), abs(l)))); end
code[c0_, A_, V_, l_] := N[(c0 * N[(N[(N[Sqrt[N[Abs[A], $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Max[N[Abs[V], $MachinePrecision], N[Abs[l], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[Min[N[Abs[V], $MachinePrecision], N[Abs[l], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
c0 \cdot \frac{\frac{\sqrt{\left|A\right|}}{\sqrt{\mathsf{max}\left(\left|V\right|, \left|\ell\right|\right)}}}{\sqrt{\mathsf{min}\left(\left|V\right|, \left|\ell\right|\right)}}
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.f6442.8%
Applied rewrites42.8%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-unsound-/.f64N/A
lower-unsound-sqrt.f64N/A
lower-unsound-sqrt.f6425.0%
Applied rewrites25.0%
(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)))
(if (<= t_2 1e-265)
(/ (* c0 (sqrt (* (/ t_1 t_0) (fabs A)))) t_1)
(if (<= t_2 4e+265)
(* c0 (/ (sqrt (fabs A)) (sqrt (* t_1 t_0))))
(* c0 (/ (sqrt (* (/ t_0 t_1) (fabs A))) t_0))))))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 tmp;
if (t_2 <= 1e-265) {
tmp = (c0 * sqrt(((t_1 / t_0) * fabs(A)))) / t_1;
} else if (t_2 <= 4e+265) {
tmp = c0 * (sqrt(fabs(A)) / sqrt((t_1 * t_0)));
} else {
tmp = c0 * (sqrt(((t_0 / t_1) * fabs(A))) / t_0);
}
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) :: tmp
t_0 = fmin(abs(v), abs(l))
t_1 = fmax(abs(v), abs(l))
t_2 = t_0 * t_1
if (t_2 <= 1d-265) then
tmp = (c0 * sqrt(((t_1 / t_0) * abs(a)))) / t_1
else if (t_2 <= 4d+265) then
tmp = c0 * (sqrt(abs(a)) / sqrt((t_1 * t_0)))
else
tmp = c0 * (sqrt(((t_0 / t_1) * abs(a))) / t_0)
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 tmp;
if (t_2 <= 1e-265) {
tmp = (c0 * Math.sqrt(((t_1 / t_0) * Math.abs(A)))) / t_1;
} else if (t_2 <= 4e+265) {
tmp = c0 * (Math.sqrt(Math.abs(A)) / Math.sqrt((t_1 * t_0)));
} else {
tmp = c0 * (Math.sqrt(((t_0 / t_1) * Math.abs(A))) / t_0);
}
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 tmp = 0 if t_2 <= 1e-265: tmp = (c0 * math.sqrt(((t_1 / t_0) * math.fabs(A)))) / t_1 elif t_2 <= 4e+265: tmp = c0 * (math.sqrt(math.fabs(A)) / math.sqrt((t_1 * t_0))) else: tmp = c0 * (math.sqrt(((t_0 / t_1) * math.fabs(A))) / t_0) 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) tmp = 0.0 if (t_2 <= 1e-265) tmp = Float64(Float64(c0 * sqrt(Float64(Float64(t_1 / t_0) * abs(A)))) / t_1); elseif (t_2 <= 4e+265) tmp = Float64(c0 * Float64(sqrt(abs(A)) / sqrt(Float64(t_1 * t_0)))); else tmp = Float64(c0 * Float64(sqrt(Float64(Float64(t_0 / t_1) * abs(A))) / t_0)); 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; tmp = 0.0; if (t_2 <= 1e-265) tmp = (c0 * sqrt(((t_1 / t_0) * abs(A)))) / t_1; elseif (t_2 <= 4e+265) tmp = c0 * (sqrt(abs(A)) / sqrt((t_1 * t_0))); else tmp = c0 * (sqrt(((t_0 / t_1) * abs(A))) / t_0); 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]}, If[LessEqual[t$95$2, 1e-265], N[(N[(c0 * N[Sqrt[N[(N[(t$95$1 / t$95$0), $MachinePrecision] * N[Abs[A], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[t$95$2, 4e+265], 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[(N[Sqrt[N[(N[(t$95$0 / t$95$1), $MachinePrecision] * N[Abs[A], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $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 := t\_0 \cdot t\_1\\
\mathbf{if}\;t\_2 \leq 10^{-265}:\\
\;\;\;\;\frac{c0 \cdot \sqrt{\frac{t\_1}{t\_0} \cdot \left|A\right|}}{t\_1}\\
\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+265}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\left|A\right|}}{\sqrt{t\_1 \cdot t\_0}}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\frac{t\_0}{t\_1} \cdot \left|A\right|}}{t\_0}\\
\end{array}
if (*.f64 V l) < 9.99999999999999985e-266Initial program 73.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6473.6%
Applied rewrites73.6%
Taylor expanded in l around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6436.9%
Applied rewrites36.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6437.1%
Applied rewrites37.1%
if 9.99999999999999985e-266 < (*.f64 V l) < 4.00000000000000027e265Initial program 73.5%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-unsound-/.f64N/A
lower-unsound-sqrt.f64N/A
lower-unsound-sqrt.f6442.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.1%
Applied rewrites42.1%
if 4.00000000000000027e265 < (*.f64 V l) Initial program 73.5%
Taylor expanded in V around 0
lower-/.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6438.8%
Applied rewrites38.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6438.8%
Applied rewrites38.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 (* t_0 t_1)))
(if (<= t_2 1e-265)
(/ (* c0 (sqrt (* (/ t_1 t_0) (fabs A)))) t_1)
(if (<= t_2 5e+260)
(* c0 (/ (sqrt (fabs A)) (sqrt (* t_1 t_0))))
(* c0 (/ (sqrt (/ (fabs A) t_0)) (sqrt t_1)))))))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 tmp;
if (t_2 <= 1e-265) {
tmp = (c0 * sqrt(((t_1 / t_0) * fabs(A)))) / t_1;
} else if (t_2 <= 5e+260) {
tmp = c0 * (sqrt(fabs(A)) / sqrt((t_1 * 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) :: t_2
real(8) :: tmp
t_0 = fmin(abs(v), abs(l))
t_1 = fmax(abs(v), abs(l))
t_2 = t_0 * t_1
if (t_2 <= 1d-265) then
tmp = (c0 * sqrt(((t_1 / t_0) * abs(a)))) / t_1
else if (t_2 <= 5d+260) then
tmp = c0 * (sqrt(abs(a)) / sqrt((t_1 * 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 = 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 tmp;
if (t_2 <= 1e-265) {
tmp = (c0 * Math.sqrt(((t_1 / t_0) * Math.abs(A)))) / t_1;
} else if (t_2 <= 5e+260) {
tmp = c0 * (Math.sqrt(Math.abs(A)) / Math.sqrt((t_1 * 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 = fmin(math.fabs(V), math.fabs(l)) t_1 = fmax(math.fabs(V), math.fabs(l)) t_2 = t_0 * t_1 tmp = 0 if t_2 <= 1e-265: tmp = (c0 * math.sqrt(((t_1 / t_0) * math.fabs(A)))) / t_1 elif t_2 <= 5e+260: tmp = c0 * (math.sqrt(math.fabs(A)) / math.sqrt((t_1 * 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 = fmin(abs(V), abs(l)) t_1 = fmax(abs(V), abs(l)) t_2 = Float64(t_0 * t_1) tmp = 0.0 if (t_2 <= 1e-265) tmp = Float64(Float64(c0 * sqrt(Float64(Float64(t_1 / t_0) * abs(A)))) / t_1); elseif (t_2 <= 5e+260) tmp = Float64(c0 * Float64(sqrt(abs(A)) / sqrt(Float64(t_1 * 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 = min(abs(V), abs(l)); t_1 = max(abs(V), abs(l)); t_2 = t_0 * t_1; tmp = 0.0; if (t_2 <= 1e-265) tmp = (c0 * sqrt(((t_1 / t_0) * abs(A)))) / t_1; elseif (t_2 <= 5e+260) tmp = c0 * (sqrt(abs(A)) / sqrt((t_1 * 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[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]}, If[LessEqual[t$95$2, 1e-265], N[(N[(c0 * N[Sqrt[N[(N[(t$95$1 / t$95$0), $MachinePrecision] * N[Abs[A], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[t$95$2, 5e+260], 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[(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{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\\
\mathbf{if}\;t\_2 \leq 10^{-265}:\\
\;\;\;\;\frac{c0 \cdot \sqrt{\frac{t\_1}{t\_0} \cdot \left|A\right|}}{t\_1}\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+260}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\left|A\right|}}{\sqrt{t\_1 \cdot t\_0}}\\
\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{\sqrt{\frac{\left|A\right|}{t\_0}}}{\sqrt{t\_1}}\\
\end{array}
if (*.f64 V l) < 9.99999999999999985e-266Initial program 73.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6473.6%
Applied rewrites73.6%
Taylor expanded in l around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6436.9%
Applied rewrites36.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6437.1%
Applied rewrites37.1%
if 9.99999999999999985e-266 < (*.f64 V l) < 4.9999999999999996e260Initial program 73.5%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-unsound-/.f64N/A
lower-unsound-sqrt.f64N/A
lower-unsound-sqrt.f6442.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.1%
Applied rewrites42.1%
if 4.9999999999999996e260 < (*.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.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 (<= (sqrt (/ (fabs A) (* t_1 t_0))) 5e-6)
(* 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))) <= 5e-6) {
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))) <= 5d-6) 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))) <= 5e-6) {
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))) <= 5e-6: 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))) <= 5e-6) 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))) <= 5e-6) 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], 5e-6], 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 5 \cdot 10^{-6}:\\
\;\;\;\;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))) < 5.00000000000000041e-6Initial 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.f6442.2%
Applied rewrites42.2%
if 5.00000000000000041e-6 < (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.f6442.8%
Applied rewrites42.8%
(FPCore (c0 A V l)
:precision binary64
(let* ((t_0 (* (fabs V) (fabs l)))
(t_1 (* c0 (/ (sqrt (/ (fabs A) (fabs V))) (sqrt (fabs l))))))
(if (<= t_0 1e-265)
t_1
(if (<= t_0 5e+260)
(* 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 = c0 * (sqrt((fabs(A) / fabs(V))) / sqrt(fabs(l)));
double tmp;
if (t_0 <= 1e-265) {
tmp = t_1;
} else if (t_0 <= 5e+260) {
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 = c0 * (sqrt((abs(a) / abs(v))) / sqrt(abs(l)))
if (t_0 <= 1d-265) then
tmp = t_1
else if (t_0 <= 5d+260) 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 = c0 * (Math.sqrt((Math.abs(A) / Math.abs(V))) / Math.sqrt(Math.abs(l)));
double tmp;
if (t_0 <= 1e-265) {
tmp = t_1;
} else if (t_0 <= 5e+260) {
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 = c0 * (math.sqrt((math.fabs(A) / math.fabs(V))) / math.sqrt(math.fabs(l))) tmp = 0 if t_0 <= 1e-265: tmp = t_1 elif t_0 <= 5e+260: 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(c0 * Float64(sqrt(Float64(abs(A) / abs(V))) / sqrt(abs(l)))) tmp = 0.0 if (t_0 <= 1e-265) tmp = t_1; elseif (t_0 <= 5e+260) 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 = c0 * (sqrt((abs(A) / abs(V))) / sqrt(abs(l))); tmp = 0.0; if (t_0 <= 1e-265) tmp = t_1; elseif (t_0 <= 5e+260) 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[(c0 * N[(N[Sqrt[N[(N[Abs[A], $MachinePrecision] / N[Abs[V], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Abs[l], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e-265], t$95$1, If[LessEqual[t$95$0, 5e+260], 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 := c0 \cdot \frac{\sqrt{\frac{\left|A\right|}{\left|V\right|}}}{\sqrt{\left|\ell\right|}}\\
\mathbf{if}\;t\_0 \leq 10^{-265}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+260}:\\
\;\;\;\;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.99999999999999985e-266 or 4.9999999999999996e260 < (*.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.f6442.2%
Applied rewrites42.2%
if 9.99999999999999985e-266 < (*.f64 V l) < 4.9999999999999996e260Initial program 73.5%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-unsound-/.f64N/A
lower-unsound-sqrt.f64N/A
lower-unsound-sqrt.f6442.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.1%
Applied rewrites42.1%
(FPCore (c0 A V l)
:precision binary64
(let* ((t_0 (* (fabs V) (fabs l))))
(if (<= t_0 1e-312)
(* c0 (sqrt (/ (/ (fabs A) (fabs l)) (fabs V))))
(if (<= t_0 5e+297)
(* c0 (/ (sqrt (fabs A)) (sqrt (* (fabs l) (fabs V)))))
(* c0 (sqrt (/ (/ (fabs A) (fabs V)) (fabs l))))))))double code(double c0, double A, double V, double l) {
double t_0 = fabs(V) * fabs(l);
double tmp;
if (t_0 <= 1e-312) {
tmp = c0 * sqrt(((fabs(A) / fabs(l)) / fabs(V)));
} else if (t_0 <= 5e+297) {
tmp = c0 * (sqrt(fabs(A)) / sqrt((fabs(l) * fabs(V))));
} else {
tmp = c0 * sqrt(((fabs(A) / fabs(V)) / fabs(l)));
}
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 <= 1d-312) then
tmp = c0 * sqrt(((abs(a) / abs(l)) / abs(v)))
else if (t_0 <= 5d+297) then
tmp = c0 * (sqrt(abs(a)) / sqrt((abs(l) * abs(v))))
else
tmp = c0 * sqrt(((abs(a) / abs(v)) / abs(l)))
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 <= 1e-312) {
tmp = c0 * Math.sqrt(((Math.abs(A) / Math.abs(l)) / Math.abs(V)));
} else if (t_0 <= 5e+297) {
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(V)) / Math.abs(l)));
}
return tmp;
}
def code(c0, A, V, l): t_0 = math.fabs(V) * math.fabs(l) tmp = 0 if t_0 <= 1e-312: tmp = c0 * math.sqrt(((math.fabs(A) / math.fabs(l)) / math.fabs(V))) elif t_0 <= 5e+297: 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(V)) / math.fabs(l))) return tmp
function code(c0, A, V, l) t_0 = Float64(abs(V) * abs(l)) tmp = 0.0 if (t_0 <= 1e-312) tmp = Float64(c0 * sqrt(Float64(Float64(abs(A) / abs(l)) / abs(V)))); elseif (t_0 <= 5e+297) tmp = Float64(c0 * Float64(sqrt(abs(A)) / sqrt(Float64(abs(l) * abs(V))))); else tmp = Float64(c0 * sqrt(Float64(Float64(abs(A) / abs(V)) / abs(l)))); end return tmp end
function tmp_2 = code(c0, A, V, l) t_0 = abs(V) * abs(l); tmp = 0.0; if (t_0 <= 1e-312) tmp = c0 * sqrt(((abs(A) / abs(l)) / abs(V))); elseif (t_0 <= 5e+297) tmp = c0 * (sqrt(abs(A)) / sqrt((abs(l) * abs(V)))); else tmp = c0 * sqrt(((abs(A) / abs(V)) / abs(l))); 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, 1e-312], N[(c0 * N[Sqrt[N[(N[(N[Abs[A], $MachinePrecision] / N[Abs[l], $MachinePrecision]), $MachinePrecision] / N[Abs[V], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+297], 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[V], $MachinePrecision]), $MachinePrecision] / N[Abs[l], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \left|V\right| \cdot \left|\ell\right|\\
\mathbf{if}\;t\_0 \leq 10^{-312}:\\
\;\;\;\;c0 \cdot \sqrt{\frac{\frac{\left|A\right|}{\left|\ell\right|}}{\left|V\right|}}\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+297}:\\
\;\;\;\;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|V\right|}}{\left|\ell\right|}}\\
\end{array}
if (*.f64 V l) < 9.9999999999847e-313Initial program 73.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6473.6%
Applied rewrites73.6%
if 9.9999999999847e-313 < (*.f64 V l) < 4.9999999999999998e297Initial program 73.5%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-unsound-/.f64N/A
lower-unsound-sqrt.f64N/A
lower-unsound-sqrt.f6442.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.1%
Applied rewrites42.1%
if 4.9999999999999998e297 < (*.f64 V l) Initial program 73.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6473.6%
Applied rewrites73.6%
(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))) 5000.0)
(* 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))) <= 5000.0) {
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))) <= 5000.0d0) 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))) <= 5000.0) {
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))) <= 5000.0: 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))) <= 5000.0) 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))) <= 5000.0) 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], 5000.0], 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 5000:\\
\;\;\;\;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))) < 5e3Initial program 73.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6473.6%
Applied rewrites73.6%
if 5e3 < (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.6%
Applied rewrites73.6%
(FPCore (c0 A V l)
:precision binary64
(let* ((t_0 (fmin (fabs V) (fabs l)))
(t_1 (fmax (fabs V) (fabs l)))
(t_2 (* (fabs c0) (sqrt (/ (/ (fabs A) t_0) t_1))))
(t_3 (* (fabs c0) (sqrt (/ (fabs A) (* t_0 t_1))))))
(*
(copysign 1.0 c0)
(if (<= t_3 4e-273) t_2 (if (<= t_3 5e+256) t_3 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 = fabs(c0) * sqrt(((fabs(A) / t_0) / t_1));
double t_3 = fabs(c0) * sqrt((fabs(A) / (t_0 * t_1)));
double tmp;
if (t_3 <= 4e-273) {
tmp = t_2;
} else if (t_3 <= 5e+256) {
tmp = t_3;
} else {
tmp = t_2;
}
return copysign(1.0, c0) * tmp;
}
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.abs(c0) * Math.sqrt(((Math.abs(A) / t_0) / t_1));
double t_3 = Math.abs(c0) * Math.sqrt((Math.abs(A) / (t_0 * t_1)));
double tmp;
if (t_3 <= 4e-273) {
tmp = t_2;
} else if (t_3 <= 5e+256) {
tmp = t_3;
} else {
tmp = t_2;
}
return Math.copySign(1.0, c0) * 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.fabs(c0) * math.sqrt(((math.fabs(A) / t_0) / t_1)) t_3 = math.fabs(c0) * math.sqrt((math.fabs(A) / (t_0 * t_1))) tmp = 0 if t_3 <= 4e-273: tmp = t_2 elif t_3 <= 5e+256: tmp = t_3 else: tmp = t_2 return math.copysign(1.0, c0) * tmp
function code(c0, A, V, l) t_0 = fmin(abs(V), abs(l)) t_1 = fmax(abs(V), abs(l)) t_2 = Float64(abs(c0) * sqrt(Float64(Float64(abs(A) / t_0) / t_1))) t_3 = Float64(abs(c0) * sqrt(Float64(abs(A) / Float64(t_0 * t_1)))) tmp = 0.0 if (t_3 <= 4e-273) tmp = t_2; elseif (t_3 <= 5e+256) tmp = t_3; else tmp = t_2; end return Float64(copysign(1.0, c0) * 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 = abs(c0) * sqrt(((abs(A) / t_0) / t_1)); t_3 = abs(c0) * sqrt((abs(A) / (t_0 * t_1))); tmp = 0.0; if (t_3 <= 4e-273) tmp = t_2; elseif (t_3 <= 5e+256) tmp = t_3; else tmp = t_2; end tmp_2 = (sign(c0) * abs(1.0)) * 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[(N[Abs[c0], $MachinePrecision] * N[Sqrt[N[(N[(N[Abs[A], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Abs[c0], $MachinePrecision] * N[Sqrt[N[(N[Abs[A], $MachinePrecision] / N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$3, 4e-273], t$95$2, If[LessEqual[t$95$3, 5e+256], t$95$3, t$95$2]]), $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 := \left|c0\right| \cdot \sqrt{\frac{\frac{\left|A\right|}{t\_0}}{t\_1}}\\
t_3 := \left|c0\right| \cdot \sqrt{\frac{\left|A\right|}{t\_0 \cdot t\_1}}\\
\mathsf{copysign}\left(1, c0\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_3 \leq 4 \cdot 10^{-273}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_3 \leq 5 \cdot 10^{+256}:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 c0 (sqrt.f64 (/.f64 A (*.f64 V l)))) < 4e-273 or 5.00000000000000015e256 < (*.f64 c0 (sqrt.f64 (/.f64 A (*.f64 V l)))) Initial program 73.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6473.6%
Applied rewrites73.6%
if 4e-273 < (*.f64 c0 (sqrt.f64 (/.f64 A (*.f64 V l)))) < 5.00000000000000015e256Initial 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 2025185
(FPCore (c0 A V l)
:name "Henrywood and Agarwal, Equation (3)"
:precision binary64
(* c0 (sqrt (/ A (* V l)))))