
(FPCore (x c s) :precision binary64 (/ (cos (* 2 x)) (* (pow c 2) (* (* x (pow s 2)) x))))
double code(double x, double c, double s) {
return cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x));
}
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(x, c, s)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))
end function
public static double code(double x, double c, double s) {
return Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x));
}
def code(x, c, s): return math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))
function code(x, c, s) return Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x))) end
function tmp = code(x, c, s) tmp = cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x)); end
code[x_, c_, s_] := N[(N[Cos[N[(2 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2], $MachinePrecision] * N[(N[(x * N[Power[s, 2], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x c s) :precision binary64 (/ (cos (* 2 x)) (* (pow c 2) (* (* x (pow s 2)) x))))
double code(double x, double c, double s) {
return cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x));
}
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(x, c, s)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))
end function
public static double code(double x, double c, double s) {
return Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x));
}
def code(x, c, s): return math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))
function code(x, c, s) return Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x))) end
function tmp = code(x, c, s) tmp = cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x)); end
code[x_, c_, s_] := N[(N[Cos[N[(2 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2], $MachinePrecision] * N[(N[(x * N[Power[s, 2], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
(FPCore (x c s)
:precision binary64
(let* ((t_0 (fmax (fabs c) (fabs s)))
(t_1 (* t_0 (fabs x)))
(t_2 (fmin (fabs c) (fabs s)))
(t_3 (cos (+ (fabs x) (fabs x))))
(t_4 (* t_2 t_1))
(t_5 (* t_2 (fabs x))))
(if (<= (fabs x) 944473296573929/18889465931478580854784)
(/ (* (/ 1 t_4) 1) t_4)
(if (<=
(fabs x)
3799999999999999756058617039041391764068624108275936490937173340954074795328821049994414470557602482673561068656167289341512123668244335230203759534181088908978493199970248798074544917117736881042960550110507673365885163484577344450433556716453888)
(* (/ 1 (* (* (* t_5 (fabs x)) (* t_2 t_0)) t_0)) t_3)
(/ t_3 (* (* (* t_1 t_0) t_2) t_5))))))double code(double x, double c, double s) {
double t_0 = fmax(fabs(c), fabs(s));
double t_1 = t_0 * fabs(x);
double t_2 = fmin(fabs(c), fabs(s));
double t_3 = cos((fabs(x) + fabs(x)));
double t_4 = t_2 * t_1;
double t_5 = t_2 * fabs(x);
double tmp;
if (fabs(x) <= 5e-8) {
tmp = ((1.0 / t_4) * 1.0) / t_4;
} else if (fabs(x) <= 3.8e+246) {
tmp = (1.0 / (((t_5 * fabs(x)) * (t_2 * t_0)) * t_0)) * t_3;
} else {
tmp = t_3 / (((t_1 * t_0) * t_2) * t_5);
}
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(x, c, s)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = fmax(abs(c), abs(s))
t_1 = t_0 * abs(x)
t_2 = fmin(abs(c), abs(s))
t_3 = cos((abs(x) + abs(x)))
t_4 = t_2 * t_1
t_5 = t_2 * abs(x)
if (abs(x) <= 5d-8) then
tmp = ((1.0d0 / t_4) * 1.0d0) / t_4
else if (abs(x) <= 3.8d+246) then
tmp = (1.0d0 / (((t_5 * abs(x)) * (t_2 * t_0)) * t_0)) * t_3
else
tmp = t_3 / (((t_1 * t_0) * t_2) * t_5)
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double t_0 = fmax(Math.abs(c), Math.abs(s));
double t_1 = t_0 * Math.abs(x);
double t_2 = fmin(Math.abs(c), Math.abs(s));
double t_3 = Math.cos((Math.abs(x) + Math.abs(x)));
double t_4 = t_2 * t_1;
double t_5 = t_2 * Math.abs(x);
double tmp;
if (Math.abs(x) <= 5e-8) {
tmp = ((1.0 / t_4) * 1.0) / t_4;
} else if (Math.abs(x) <= 3.8e+246) {
tmp = (1.0 / (((t_5 * Math.abs(x)) * (t_2 * t_0)) * t_0)) * t_3;
} else {
tmp = t_3 / (((t_1 * t_0) * t_2) * t_5);
}
return tmp;
}
def code(x, c, s): t_0 = fmax(math.fabs(c), math.fabs(s)) t_1 = t_0 * math.fabs(x) t_2 = fmin(math.fabs(c), math.fabs(s)) t_3 = math.cos((math.fabs(x) + math.fabs(x))) t_4 = t_2 * t_1 t_5 = t_2 * math.fabs(x) tmp = 0 if math.fabs(x) <= 5e-8: tmp = ((1.0 / t_4) * 1.0) / t_4 elif math.fabs(x) <= 3.8e+246: tmp = (1.0 / (((t_5 * math.fabs(x)) * (t_2 * t_0)) * t_0)) * t_3 else: tmp = t_3 / (((t_1 * t_0) * t_2) * t_5) return tmp
function code(x, c, s) t_0 = fmax(abs(c), abs(s)) t_1 = Float64(t_0 * abs(x)) t_2 = fmin(abs(c), abs(s)) t_3 = cos(Float64(abs(x) + abs(x))) t_4 = Float64(t_2 * t_1) t_5 = Float64(t_2 * abs(x)) tmp = 0.0 if (abs(x) <= 5e-8) tmp = Float64(Float64(Float64(1.0 / t_4) * 1.0) / t_4); elseif (abs(x) <= 3.8e+246) tmp = Float64(Float64(1.0 / Float64(Float64(Float64(t_5 * abs(x)) * Float64(t_2 * t_0)) * t_0)) * t_3); else tmp = Float64(t_3 / Float64(Float64(Float64(t_1 * t_0) * t_2) * t_5)); end return tmp end
function tmp_2 = code(x, c, s) t_0 = max(abs(c), abs(s)); t_1 = t_0 * abs(x); t_2 = min(abs(c), abs(s)); t_3 = cos((abs(x) + abs(x))); t_4 = t_2 * t_1; t_5 = t_2 * abs(x); tmp = 0.0; if (abs(x) <= 5e-8) tmp = ((1.0 / t_4) * 1.0) / t_4; elseif (abs(x) <= 3.8e+246) tmp = (1.0 / (((t_5 * abs(x)) * (t_2 * t_0)) * t_0)) * t_3; else tmp = t_3 / (((t_1 * t_0) * t_2) * t_5); end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[Max[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Min[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Cos[N[(N[Abs[x], $MachinePrecision] + N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$2 * t$95$1), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$2 * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 944473296573929/18889465931478580854784], N[(N[(N[(1 / t$95$4), $MachinePrecision] * 1), $MachinePrecision] / t$95$4), $MachinePrecision], If[LessEqual[N[Abs[x], $MachinePrecision], 3799999999999999756058617039041391764068624108275936490937173340954074795328821049994414470557602482673561068656167289341512123668244335230203759534181088908978493199970248798074544917117736881042960550110507673365885163484577344450433556716453888], N[(N[(1 / N[(N[(N[(t$95$5 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[(t$95$2 * t$95$0), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision], N[(t$95$3 / N[(N[(N[(t$95$1 * t$95$0), $MachinePrecision] * t$95$2), $MachinePrecision] * t$95$5), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\
t_1 := t\_0 \cdot \left|x\right|\\
t_2 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\
t_3 := \cos \left(\left|x\right| + \left|x\right|\right)\\
t_4 := t\_2 \cdot t\_1\\
t_5 := t\_2 \cdot \left|x\right|\\
\mathbf{if}\;\left|x\right| \leq \frac{944473296573929}{18889465931478580854784}:\\
\;\;\;\;\frac{\frac{1}{t\_4} \cdot 1}{t\_4}\\
\mathbf{elif}\;\left|x\right| \leq 3799999999999999756058617039041391764068624108275936490937173340954074795328821049994414470557602482673561068656167289341512123668244335230203759534181088908978493199970248798074544917117736881042960550110507673365885163484577344450433556716453888:\\
\;\;\;\;\frac{1}{\left(\left(t\_5 \cdot \left|x\right|\right) \cdot \left(t\_2 \cdot t\_0\right)\right) \cdot t\_0} \cdot t\_3\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_3}{\left(\left(t\_1 \cdot t\_0\right) \cdot t\_2\right) \cdot t\_5}\\
\end{array}
if x < 4.9999999999999998e-8Initial program 67.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6467.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
Applied rewrites67.2%
Taylor expanded in x around 0
Applied rewrites59.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
Applied rewrites76.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-/r*N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
mult-flipN/A
Applied rewrites79.0%
if 4.9999999999999998e-8 < x < 3.7999999999999998e246Initial program 67.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
lower-/.f64N/A
Applied rewrites78.6%
lift-/.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites73.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6485.7%
Applied rewrites85.7%
if 3.7999999999999998e246 < x Initial program 67.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6467.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
Applied rewrites67.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6479.0%
Applied rewrites79.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6485.7%
Applied rewrites85.7%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (fmax (fabs c) (fabs s)))
(t_1 (cos (+ (fabs x) (fabs x))))
(t_2 (fmin (fabs c) (fabs s)))
(t_3 (* t_2 (* t_0 (fabs x))))
(t_4 (* t_2 (fabs x))))
(if (<= (fabs x) 237684487542793/2475880078570760549798248448)
(/ (* (/ 1 t_3) 1) t_3)
(if (<=
(fabs x)
50000000000000003226559936361919779827105376205144584884917978916367904662510143278135754996687257850822691394447592090096097397546144525317852447661395664561828975608881910401466368)
(* (/ 1 (* (* t_2 (* (* t_4 (fabs x)) t_0)) t_0)) t_1)
(/ t_1 (* (* t_4 t_4) (* t_0 t_0)))))))double code(double x, double c, double s) {
double t_0 = fmax(fabs(c), fabs(s));
double t_1 = cos((fabs(x) + fabs(x)));
double t_2 = fmin(fabs(c), fabs(s));
double t_3 = t_2 * (t_0 * fabs(x));
double t_4 = t_2 * fabs(x);
double tmp;
if (fabs(x) <= 9.6e-14) {
tmp = ((1.0 / t_3) * 1.0) / t_3;
} else if (fabs(x) <= 5e+181) {
tmp = (1.0 / ((t_2 * ((t_4 * fabs(x)) * t_0)) * t_0)) * t_1;
} else {
tmp = t_1 / ((t_4 * t_4) * (t_0 * 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(x, c, s)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
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 = fmax(abs(c), abs(s))
t_1 = cos((abs(x) + abs(x)))
t_2 = fmin(abs(c), abs(s))
t_3 = t_2 * (t_0 * abs(x))
t_4 = t_2 * abs(x)
if (abs(x) <= 9.6d-14) then
tmp = ((1.0d0 / t_3) * 1.0d0) / t_3
else if (abs(x) <= 5d+181) then
tmp = (1.0d0 / ((t_2 * ((t_4 * abs(x)) * t_0)) * t_0)) * t_1
else
tmp = t_1 / ((t_4 * t_4) * (t_0 * t_0))
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double t_0 = fmax(Math.abs(c), Math.abs(s));
double t_1 = Math.cos((Math.abs(x) + Math.abs(x)));
double t_2 = fmin(Math.abs(c), Math.abs(s));
double t_3 = t_2 * (t_0 * Math.abs(x));
double t_4 = t_2 * Math.abs(x);
double tmp;
if (Math.abs(x) <= 9.6e-14) {
tmp = ((1.0 / t_3) * 1.0) / t_3;
} else if (Math.abs(x) <= 5e+181) {
tmp = (1.0 / ((t_2 * ((t_4 * Math.abs(x)) * t_0)) * t_0)) * t_1;
} else {
tmp = t_1 / ((t_4 * t_4) * (t_0 * t_0));
}
return tmp;
}
def code(x, c, s): t_0 = fmax(math.fabs(c), math.fabs(s)) t_1 = math.cos((math.fabs(x) + math.fabs(x))) t_2 = fmin(math.fabs(c), math.fabs(s)) t_3 = t_2 * (t_0 * math.fabs(x)) t_4 = t_2 * math.fabs(x) tmp = 0 if math.fabs(x) <= 9.6e-14: tmp = ((1.0 / t_3) * 1.0) / t_3 elif math.fabs(x) <= 5e+181: tmp = (1.0 / ((t_2 * ((t_4 * math.fabs(x)) * t_0)) * t_0)) * t_1 else: tmp = t_1 / ((t_4 * t_4) * (t_0 * t_0)) return tmp
function code(x, c, s) t_0 = fmax(abs(c), abs(s)) t_1 = cos(Float64(abs(x) + abs(x))) t_2 = fmin(abs(c), abs(s)) t_3 = Float64(t_2 * Float64(t_0 * abs(x))) t_4 = Float64(t_2 * abs(x)) tmp = 0.0 if (abs(x) <= 9.6e-14) tmp = Float64(Float64(Float64(1.0 / t_3) * 1.0) / t_3); elseif (abs(x) <= 5e+181) tmp = Float64(Float64(1.0 / Float64(Float64(t_2 * Float64(Float64(t_4 * abs(x)) * t_0)) * t_0)) * t_1); else tmp = Float64(t_1 / Float64(Float64(t_4 * t_4) * Float64(t_0 * t_0))); end return tmp end
function tmp_2 = code(x, c, s) t_0 = max(abs(c), abs(s)); t_1 = cos((abs(x) + abs(x))); t_2 = min(abs(c), abs(s)); t_3 = t_2 * (t_0 * abs(x)); t_4 = t_2 * abs(x); tmp = 0.0; if (abs(x) <= 9.6e-14) tmp = ((1.0 / t_3) * 1.0) / t_3; elseif (abs(x) <= 5e+181) tmp = (1.0 / ((t_2 * ((t_4 * abs(x)) * t_0)) * t_0)) * t_1; else tmp = t_1 / ((t_4 * t_4) * (t_0 * t_0)); end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[Max[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(N[Abs[x], $MachinePrecision] + N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Min[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$2 * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 237684487542793/2475880078570760549798248448], N[(N[(N[(1 / t$95$3), $MachinePrecision] * 1), $MachinePrecision] / t$95$3), $MachinePrecision], If[LessEqual[N[Abs[x], $MachinePrecision], 50000000000000003226559936361919779827105376205144584884917978916367904662510143278135754996687257850822691394447592090096097397546144525317852447661395664561828975608881910401466368], N[(N[(1 / N[(N[(t$95$2 * N[(N[(t$95$4 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], N[(t$95$1 / N[(N[(t$95$4 * t$95$4), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\
t_1 := \cos \left(\left|x\right| + \left|x\right|\right)\\
t_2 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\
t_3 := t\_2 \cdot \left(t\_0 \cdot \left|x\right|\right)\\
t_4 := t\_2 \cdot \left|x\right|\\
\mathbf{if}\;\left|x\right| \leq \frac{237684487542793}{2475880078570760549798248448}:\\
\;\;\;\;\frac{\frac{1}{t\_3} \cdot 1}{t\_3}\\
\mathbf{elif}\;\left|x\right| \leq 50000000000000003226559936361919779827105376205144584884917978916367904662510143278135754996687257850822691394447592090096097397546144525317852447661395664561828975608881910401466368:\\
\;\;\;\;\frac{1}{\left(t\_2 \cdot \left(\left(t\_4 \cdot \left|x\right|\right) \cdot t\_0\right)\right) \cdot t\_0} \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{\left(t\_4 \cdot t\_4\right) \cdot \left(t\_0 \cdot t\_0\right)}\\
\end{array}
if x < 9.5999999999999995e-14Initial program 67.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6467.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
Applied rewrites67.2%
Taylor expanded in x around 0
Applied rewrites59.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
Applied rewrites76.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-/r*N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
mult-flipN/A
Applied rewrites79.0%
if 9.5999999999999995e-14 < x < 5.0000000000000003e181Initial program 67.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
associate-/r*N/A
*-commutativeN/A
lower-/.f64N/A
Applied rewrites78.6%
lift-/.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites73.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6485.7%
Applied rewrites85.7%
if 5.0000000000000003e181 < x Initial program 67.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6467.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
Applied rewrites67.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6477.6%
Applied rewrites77.6%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (fmax (fabs c) (fabs s)))
(t_1 (* t_0 (fabs x)))
(t_2 (fmin (fabs c) (fabs s)))
(t_3 (* t_2 t_1))
(t_4 (* t_2 (fabs x))))
(if (<= (fabs x) 237684487542793/2475880078570760549798248448)
(/ (* (/ 1 t_3) 1) t_3)
(if (<=
(fabs x)
50000000000000003226559936361919779827105376205144584884917978916367904662510143278135754996687257850822691394447592090096097397546144525317852447661395664561828975608881910401466368)
(/ (cos (* 2 (fabs x))) (* (* t_2 (* t_4 t_1)) t_0))
(/ (cos (+ (fabs x) (fabs x))) (* (* t_4 t_4) (* t_0 t_0)))))))double code(double x, double c, double s) {
double t_0 = fmax(fabs(c), fabs(s));
double t_1 = t_0 * fabs(x);
double t_2 = fmin(fabs(c), fabs(s));
double t_3 = t_2 * t_1;
double t_4 = t_2 * fabs(x);
double tmp;
if (fabs(x) <= 9.6e-14) {
tmp = ((1.0 / t_3) * 1.0) / t_3;
} else if (fabs(x) <= 5e+181) {
tmp = cos((2.0 * fabs(x))) / ((t_2 * (t_4 * t_1)) * t_0);
} else {
tmp = cos((fabs(x) + fabs(x))) / ((t_4 * t_4) * (t_0 * 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(x, c, s)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
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 = fmax(abs(c), abs(s))
t_1 = t_0 * abs(x)
t_2 = fmin(abs(c), abs(s))
t_3 = t_2 * t_1
t_4 = t_2 * abs(x)
if (abs(x) <= 9.6d-14) then
tmp = ((1.0d0 / t_3) * 1.0d0) / t_3
else if (abs(x) <= 5d+181) then
tmp = cos((2.0d0 * abs(x))) / ((t_2 * (t_4 * t_1)) * t_0)
else
tmp = cos((abs(x) + abs(x))) / ((t_4 * t_4) * (t_0 * t_0))
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double t_0 = fmax(Math.abs(c), Math.abs(s));
double t_1 = t_0 * Math.abs(x);
double t_2 = fmin(Math.abs(c), Math.abs(s));
double t_3 = t_2 * t_1;
double t_4 = t_2 * Math.abs(x);
double tmp;
if (Math.abs(x) <= 9.6e-14) {
tmp = ((1.0 / t_3) * 1.0) / t_3;
} else if (Math.abs(x) <= 5e+181) {
tmp = Math.cos((2.0 * Math.abs(x))) / ((t_2 * (t_4 * t_1)) * t_0);
} else {
tmp = Math.cos((Math.abs(x) + Math.abs(x))) / ((t_4 * t_4) * (t_0 * t_0));
}
return tmp;
}
def code(x, c, s): t_0 = fmax(math.fabs(c), math.fabs(s)) t_1 = t_0 * math.fabs(x) t_2 = fmin(math.fabs(c), math.fabs(s)) t_3 = t_2 * t_1 t_4 = t_2 * math.fabs(x) tmp = 0 if math.fabs(x) <= 9.6e-14: tmp = ((1.0 / t_3) * 1.0) / t_3 elif math.fabs(x) <= 5e+181: tmp = math.cos((2.0 * math.fabs(x))) / ((t_2 * (t_4 * t_1)) * t_0) else: tmp = math.cos((math.fabs(x) + math.fabs(x))) / ((t_4 * t_4) * (t_0 * t_0)) return tmp
function code(x, c, s) t_0 = fmax(abs(c), abs(s)) t_1 = Float64(t_0 * abs(x)) t_2 = fmin(abs(c), abs(s)) t_3 = Float64(t_2 * t_1) t_4 = Float64(t_2 * abs(x)) tmp = 0.0 if (abs(x) <= 9.6e-14) tmp = Float64(Float64(Float64(1.0 / t_3) * 1.0) / t_3); elseif (abs(x) <= 5e+181) tmp = Float64(cos(Float64(2.0 * abs(x))) / Float64(Float64(t_2 * Float64(t_4 * t_1)) * t_0)); else tmp = Float64(cos(Float64(abs(x) + abs(x))) / Float64(Float64(t_4 * t_4) * Float64(t_0 * t_0))); end return tmp end
function tmp_2 = code(x, c, s) t_0 = max(abs(c), abs(s)); t_1 = t_0 * abs(x); t_2 = min(abs(c), abs(s)); t_3 = t_2 * t_1; t_4 = t_2 * abs(x); tmp = 0.0; if (abs(x) <= 9.6e-14) tmp = ((1.0 / t_3) * 1.0) / t_3; elseif (abs(x) <= 5e+181) tmp = cos((2.0 * abs(x))) / ((t_2 * (t_4 * t_1)) * t_0); else tmp = cos((abs(x) + abs(x))) / ((t_4 * t_4) * (t_0 * t_0)); end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[Max[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Min[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * t$95$1), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$2 * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 237684487542793/2475880078570760549798248448], N[(N[(N[(1 / t$95$3), $MachinePrecision] * 1), $MachinePrecision] / t$95$3), $MachinePrecision], If[LessEqual[N[Abs[x], $MachinePrecision], 50000000000000003226559936361919779827105376205144584884917978916367904662510143278135754996687257850822691394447592090096097397546144525317852447661395664561828975608881910401466368], N[(N[Cos[N[(2 * N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[(t$95$2 * N[(t$95$4 * t$95$1), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(N[Abs[x], $MachinePrecision] + N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[(t$95$4 * t$95$4), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\
t_1 := t\_0 \cdot \left|x\right|\\
t_2 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\
t_3 := t\_2 \cdot t\_1\\
t_4 := t\_2 \cdot \left|x\right|\\
\mathbf{if}\;\left|x\right| \leq \frac{237684487542793}{2475880078570760549798248448}:\\
\;\;\;\;\frac{\frac{1}{t\_3} \cdot 1}{t\_3}\\
\mathbf{elif}\;\left|x\right| \leq 50000000000000003226559936361919779827105376205144584884917978916367904662510143278135754996687257850822691394447592090096097397546144525317852447661395664561828975608881910401466368:\\
\;\;\;\;\frac{\cos \left(2 \cdot \left|x\right|\right)}{\left(t\_2 \cdot \left(t\_4 \cdot t\_1\right)\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(\left|x\right| + \left|x\right|\right)}{\left(t\_4 \cdot t\_4\right) \cdot \left(t\_0 \cdot t\_0\right)}\\
\end{array}
if x < 9.5999999999999995e-14Initial program 67.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6467.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
Applied rewrites67.2%
Taylor expanded in x around 0
Applied rewrites59.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
Applied rewrites76.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-/r*N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
mult-flipN/A
Applied rewrites79.0%
if 9.5999999999999995e-14 < x < 5.0000000000000003e181Initial program 67.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6477.7%
Applied rewrites77.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6490.0%
Applied rewrites90.0%
if 5.0000000000000003e181 < x Initial program 67.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6467.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
Applied rewrites67.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6477.6%
Applied rewrites77.6%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (fmax (fabs c) (fabs s)))
(t_1 (cos (+ (fabs x) (fabs x))))
(t_2 (fmin (fabs c) (fabs s)))
(t_3 (* t_2 (fabs x)))
(t_4 (* t_2 (* t_0 (fabs x)))))
(if (<= (fabs x) 237684487542793/2475880078570760549798248448)
(/ (* (/ 1 t_4) 1) t_4)
(if (<=
(fabs x)
500000000000000034478783768422291468839913049176218549546891415298328160321104377283093399808452642713299991464708729440150191950239130597851790859288683698879916192875675648)
(/ t_1 (* (* (* t_4 (fabs x)) t_2) t_0))
(/ t_1 (* (* t_3 t_3) (* t_0 t_0)))))))double code(double x, double c, double s) {
double t_0 = fmax(fabs(c), fabs(s));
double t_1 = cos((fabs(x) + fabs(x)));
double t_2 = fmin(fabs(c), fabs(s));
double t_3 = t_2 * fabs(x);
double t_4 = t_2 * (t_0 * fabs(x));
double tmp;
if (fabs(x) <= 9.6e-14) {
tmp = ((1.0 / t_4) * 1.0) / t_4;
} else if (fabs(x) <= 5e+173) {
tmp = t_1 / (((t_4 * fabs(x)) * t_2) * t_0);
} else {
tmp = t_1 / ((t_3 * t_3) * (t_0 * 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(x, c, s)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
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 = fmax(abs(c), abs(s))
t_1 = cos((abs(x) + abs(x)))
t_2 = fmin(abs(c), abs(s))
t_3 = t_2 * abs(x)
t_4 = t_2 * (t_0 * abs(x))
if (abs(x) <= 9.6d-14) then
tmp = ((1.0d0 / t_4) * 1.0d0) / t_4
else if (abs(x) <= 5d+173) then
tmp = t_1 / (((t_4 * abs(x)) * t_2) * t_0)
else
tmp = t_1 / ((t_3 * t_3) * (t_0 * t_0))
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double t_0 = fmax(Math.abs(c), Math.abs(s));
double t_1 = Math.cos((Math.abs(x) + Math.abs(x)));
double t_2 = fmin(Math.abs(c), Math.abs(s));
double t_3 = t_2 * Math.abs(x);
double t_4 = t_2 * (t_0 * Math.abs(x));
double tmp;
if (Math.abs(x) <= 9.6e-14) {
tmp = ((1.0 / t_4) * 1.0) / t_4;
} else if (Math.abs(x) <= 5e+173) {
tmp = t_1 / (((t_4 * Math.abs(x)) * t_2) * t_0);
} else {
tmp = t_1 / ((t_3 * t_3) * (t_0 * t_0));
}
return tmp;
}
def code(x, c, s): t_0 = fmax(math.fabs(c), math.fabs(s)) t_1 = math.cos((math.fabs(x) + math.fabs(x))) t_2 = fmin(math.fabs(c), math.fabs(s)) t_3 = t_2 * math.fabs(x) t_4 = t_2 * (t_0 * math.fabs(x)) tmp = 0 if math.fabs(x) <= 9.6e-14: tmp = ((1.0 / t_4) * 1.0) / t_4 elif math.fabs(x) <= 5e+173: tmp = t_1 / (((t_4 * math.fabs(x)) * t_2) * t_0) else: tmp = t_1 / ((t_3 * t_3) * (t_0 * t_0)) return tmp
function code(x, c, s) t_0 = fmax(abs(c), abs(s)) t_1 = cos(Float64(abs(x) + abs(x))) t_2 = fmin(abs(c), abs(s)) t_3 = Float64(t_2 * abs(x)) t_4 = Float64(t_2 * Float64(t_0 * abs(x))) tmp = 0.0 if (abs(x) <= 9.6e-14) tmp = Float64(Float64(Float64(1.0 / t_4) * 1.0) / t_4); elseif (abs(x) <= 5e+173) tmp = Float64(t_1 / Float64(Float64(Float64(t_4 * abs(x)) * t_2) * t_0)); else tmp = Float64(t_1 / Float64(Float64(t_3 * t_3) * Float64(t_0 * t_0))); end return tmp end
function tmp_2 = code(x, c, s) t_0 = max(abs(c), abs(s)); t_1 = cos((abs(x) + abs(x))); t_2 = min(abs(c), abs(s)); t_3 = t_2 * abs(x); t_4 = t_2 * (t_0 * abs(x)); tmp = 0.0; if (abs(x) <= 9.6e-14) tmp = ((1.0 / t_4) * 1.0) / t_4; elseif (abs(x) <= 5e+173) tmp = t_1 / (((t_4 * abs(x)) * t_2) * t_0); else tmp = t_1 / ((t_3 * t_3) * (t_0 * t_0)); end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[Max[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(N[Abs[x], $MachinePrecision] + N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Min[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$2 * N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 237684487542793/2475880078570760549798248448], N[(N[(N[(1 / t$95$4), $MachinePrecision] * 1), $MachinePrecision] / t$95$4), $MachinePrecision], If[LessEqual[N[Abs[x], $MachinePrecision], 500000000000000034478783768422291468839913049176218549546891415298328160321104377283093399808452642713299991464708729440150191950239130597851790859288683698879916192875675648], N[(t$95$1 / N[(N[(N[(t$95$4 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / N[(N[(t$95$3 * t$95$3), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\
t_1 := \cos \left(\left|x\right| + \left|x\right|\right)\\
t_2 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\
t_3 := t\_2 \cdot \left|x\right|\\
t_4 := t\_2 \cdot \left(t\_0 \cdot \left|x\right|\right)\\
\mathbf{if}\;\left|x\right| \leq \frac{237684487542793}{2475880078570760549798248448}:\\
\;\;\;\;\frac{\frac{1}{t\_4} \cdot 1}{t\_4}\\
\mathbf{elif}\;\left|x\right| \leq 500000000000000034478783768422291468839913049176218549546891415298328160321104377283093399808452642713299991464708729440150191950239130597851790859288683698879916192875675648:\\
\;\;\;\;\frac{t\_1}{\left(\left(t\_4 \cdot \left|x\right|\right) \cdot t\_2\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{\left(t\_3 \cdot t\_3\right) \cdot \left(t\_0 \cdot t\_0\right)}\\
\end{array}
if x < 9.5999999999999995e-14Initial program 67.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6467.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
Applied rewrites67.2%
Taylor expanded in x around 0
Applied rewrites59.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
Applied rewrites76.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-/r*N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
mult-flipN/A
Applied rewrites79.0%
if 9.5999999999999995e-14 < x < 5.0000000000000003e173Initial program 67.2%
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6478.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.3%
lift-pow.f64N/A
unpow2N/A
lower-*.f6478.3%
Applied rewrites78.3%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6491.8%
Applied rewrites91.8%
lift-/.f64N/A
mult-flipN/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
mult-flip-revN/A
lower-/.f6491.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6491.6%
Applied rewrites91.6%
Applied rewrites90.0%
if 5.0000000000000003e173 < x Initial program 67.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6467.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
Applied rewrites67.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6477.6%
Applied rewrites77.6%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (fmax (fabs c) (fabs s)))
(t_1 (* t_0 (fabs x)))
(t_2 (fmin (fabs c) (fabs s)))
(t_3 (* t_2 t_1)))
(if (<= (fabs x) 237684487542793/2475880078570760549798248448)
(/ (* (/ 1 t_3) 1) t_3)
(/
(cos (* 2 (fabs x)))
(* (* (* t_1 t_2) (* t_2 (fabs x))) t_0)))))double code(double x, double c, double s) {
double t_0 = fmax(fabs(c), fabs(s));
double t_1 = t_0 * fabs(x);
double t_2 = fmin(fabs(c), fabs(s));
double t_3 = t_2 * t_1;
double tmp;
if (fabs(x) <= 9.6e-14) {
tmp = ((1.0 / t_3) * 1.0) / t_3;
} else {
tmp = cos((2.0 * fabs(x))) / (((t_1 * t_2) * (t_2 * fabs(x))) * 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(x, c, s)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = fmax(abs(c), abs(s))
t_1 = t_0 * abs(x)
t_2 = fmin(abs(c), abs(s))
t_3 = t_2 * t_1
if (abs(x) <= 9.6d-14) then
tmp = ((1.0d0 / t_3) * 1.0d0) / t_3
else
tmp = cos((2.0d0 * abs(x))) / (((t_1 * t_2) * (t_2 * abs(x))) * t_0)
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double t_0 = fmax(Math.abs(c), Math.abs(s));
double t_1 = t_0 * Math.abs(x);
double t_2 = fmin(Math.abs(c), Math.abs(s));
double t_3 = t_2 * t_1;
double tmp;
if (Math.abs(x) <= 9.6e-14) {
tmp = ((1.0 / t_3) * 1.0) / t_3;
} else {
tmp = Math.cos((2.0 * Math.abs(x))) / (((t_1 * t_2) * (t_2 * Math.abs(x))) * t_0);
}
return tmp;
}
def code(x, c, s): t_0 = fmax(math.fabs(c), math.fabs(s)) t_1 = t_0 * math.fabs(x) t_2 = fmin(math.fabs(c), math.fabs(s)) t_3 = t_2 * t_1 tmp = 0 if math.fabs(x) <= 9.6e-14: tmp = ((1.0 / t_3) * 1.0) / t_3 else: tmp = math.cos((2.0 * math.fabs(x))) / (((t_1 * t_2) * (t_2 * math.fabs(x))) * t_0) return tmp
function code(x, c, s) t_0 = fmax(abs(c), abs(s)) t_1 = Float64(t_0 * abs(x)) t_2 = fmin(abs(c), abs(s)) t_3 = Float64(t_2 * t_1) tmp = 0.0 if (abs(x) <= 9.6e-14) tmp = Float64(Float64(Float64(1.0 / t_3) * 1.0) / t_3); else tmp = Float64(cos(Float64(2.0 * abs(x))) / Float64(Float64(Float64(t_1 * t_2) * Float64(t_2 * abs(x))) * t_0)); end return tmp end
function tmp_2 = code(x, c, s) t_0 = max(abs(c), abs(s)); t_1 = t_0 * abs(x); t_2 = min(abs(c), abs(s)); t_3 = t_2 * t_1; tmp = 0.0; if (abs(x) <= 9.6e-14) tmp = ((1.0 / t_3) * 1.0) / t_3; else tmp = cos((2.0 * abs(x))) / (((t_1 * t_2) * (t_2 * abs(x))) * t_0); end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[Max[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Min[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * t$95$1), $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 237684487542793/2475880078570760549798248448], N[(N[(N[(1 / t$95$3), $MachinePrecision] * 1), $MachinePrecision] / t$95$3), $MachinePrecision], N[(N[Cos[N[(2 * N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[(N[(t$95$1 * t$95$2), $MachinePrecision] * N[(t$95$2 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\
t_1 := t\_0 \cdot \left|x\right|\\
t_2 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\
t_3 := t\_2 \cdot t\_1\\
\mathbf{if}\;\left|x\right| \leq \frac{237684487542793}{2475880078570760549798248448}:\\
\;\;\;\;\frac{\frac{1}{t\_3} \cdot 1}{t\_3}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(2 \cdot \left|x\right|\right)}{\left(\left(t\_1 \cdot t\_2\right) \cdot \left(t\_2 \cdot \left|x\right|\right)\right) \cdot t\_0}\\
\end{array}
if x < 9.5999999999999995e-14Initial program 67.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6467.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
Applied rewrites67.2%
Taylor expanded in x around 0
Applied rewrites59.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
Applied rewrites76.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-/r*N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
mult-flipN/A
Applied rewrites79.0%
if 9.5999999999999995e-14 < x Initial program 67.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6477.7%
Applied rewrites77.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6491.3%
Applied rewrites91.3%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (fmax (fabs c) (fabs s)))
(t_1 (fmin (fabs c) (fabs s)))
(t_2 (* t_1 (fabs x)))
(t_3 (* t_1 (* t_0 (fabs x)))))
(if (<= (fabs x) 15999999999999999731564544)
(/ (* (/ 1 t_3) 1) t_3)
(/ (cos (+ (fabs x) (fabs x))) (* (* t_2 t_2) (* t_0 t_0))))))double code(double x, double c, double s) {
double t_0 = fmax(fabs(c), fabs(s));
double t_1 = fmin(fabs(c), fabs(s));
double t_2 = t_1 * fabs(x);
double t_3 = t_1 * (t_0 * fabs(x));
double tmp;
if (fabs(x) <= 1.6e+25) {
tmp = ((1.0 / t_3) * 1.0) / t_3;
} else {
tmp = cos((fabs(x) + fabs(x))) / ((t_2 * t_2) * (t_0 * 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(x, c, s)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = fmax(abs(c), abs(s))
t_1 = fmin(abs(c), abs(s))
t_2 = t_1 * abs(x)
t_3 = t_1 * (t_0 * abs(x))
if (abs(x) <= 1.6d+25) then
tmp = ((1.0d0 / t_3) * 1.0d0) / t_3
else
tmp = cos((abs(x) + abs(x))) / ((t_2 * t_2) * (t_0 * t_0))
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double t_0 = fmax(Math.abs(c), Math.abs(s));
double t_1 = fmin(Math.abs(c), Math.abs(s));
double t_2 = t_1 * Math.abs(x);
double t_3 = t_1 * (t_0 * Math.abs(x));
double tmp;
if (Math.abs(x) <= 1.6e+25) {
tmp = ((1.0 / t_3) * 1.0) / t_3;
} else {
tmp = Math.cos((Math.abs(x) + Math.abs(x))) / ((t_2 * t_2) * (t_0 * t_0));
}
return tmp;
}
def code(x, c, s): t_0 = fmax(math.fabs(c), math.fabs(s)) t_1 = fmin(math.fabs(c), math.fabs(s)) t_2 = t_1 * math.fabs(x) t_3 = t_1 * (t_0 * math.fabs(x)) tmp = 0 if math.fabs(x) <= 1.6e+25: tmp = ((1.0 / t_3) * 1.0) / t_3 else: tmp = math.cos((math.fabs(x) + math.fabs(x))) / ((t_2 * t_2) * (t_0 * t_0)) return tmp
function code(x, c, s) t_0 = fmax(abs(c), abs(s)) t_1 = fmin(abs(c), abs(s)) t_2 = Float64(t_1 * abs(x)) t_3 = Float64(t_1 * Float64(t_0 * abs(x))) tmp = 0.0 if (abs(x) <= 1.6e+25) tmp = Float64(Float64(Float64(1.0 / t_3) * 1.0) / t_3); else tmp = Float64(cos(Float64(abs(x) + abs(x))) / Float64(Float64(t_2 * t_2) * Float64(t_0 * t_0))); end return tmp end
function tmp_2 = code(x, c, s) t_0 = max(abs(c), abs(s)); t_1 = min(abs(c), abs(s)); t_2 = t_1 * abs(x); t_3 = t_1 * (t_0 * abs(x)); tmp = 0.0; if (abs(x) <= 1.6e+25) tmp = ((1.0 / t_3) * 1.0) / t_3; else tmp = cos((abs(x) + abs(x))) / ((t_2 * t_2) * (t_0 * t_0)); end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[Max[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Min[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 * N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 15999999999999999731564544], N[(N[(N[(1 / t$95$3), $MachinePrecision] * 1), $MachinePrecision] / t$95$3), $MachinePrecision], N[(N[Cos[N[(N[Abs[x], $MachinePrecision] + N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[(t$95$2 * t$95$2), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\
t_1 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\
t_2 := t\_1 \cdot \left|x\right|\\
t_3 := t\_1 \cdot \left(t\_0 \cdot \left|x\right|\right)\\
\mathbf{if}\;\left|x\right| \leq 15999999999999999731564544:\\
\;\;\;\;\frac{\frac{1}{t\_3} \cdot 1}{t\_3}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(\left|x\right| + \left|x\right|\right)}{\left(t\_2 \cdot t\_2\right) \cdot \left(t\_0 \cdot t\_0\right)}\\
\end{array}
if x < 1.6e25Initial program 67.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6467.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
Applied rewrites67.2%
Taylor expanded in x around 0
Applied rewrites59.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
Applied rewrites76.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-/r*N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
mult-flipN/A
Applied rewrites79.0%
if 1.6e25 < x Initial program 67.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6467.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
Applied rewrites67.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6477.6%
Applied rewrites77.6%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (fmax (fabs c) (fabs s)))
(t_1 (fmin (fabs c) (fabs s)))
(t_2 (* t_1 (* t_0 (fabs x)))))
(if (<= (fabs x) 15999999999999999731564544)
(/ (* (/ 1 t_2) 1) t_2)
(/
(cos (+ (fabs x) (fabs x)))
(* (* t_1 (* (* t_1 (fabs x)) (fabs x))) (* t_0 t_0))))))double code(double x, double c, double s) {
double t_0 = fmax(fabs(c), fabs(s));
double t_1 = fmin(fabs(c), fabs(s));
double t_2 = t_1 * (t_0 * fabs(x));
double tmp;
if (fabs(x) <= 1.6e+25) {
tmp = ((1.0 / t_2) * 1.0) / t_2;
} else {
tmp = cos((fabs(x) + fabs(x))) / ((t_1 * ((t_1 * fabs(x)) * fabs(x))) * (t_0 * 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(x, c, s)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = fmax(abs(c), abs(s))
t_1 = fmin(abs(c), abs(s))
t_2 = t_1 * (t_0 * abs(x))
if (abs(x) <= 1.6d+25) then
tmp = ((1.0d0 / t_2) * 1.0d0) / t_2
else
tmp = cos((abs(x) + abs(x))) / ((t_1 * ((t_1 * abs(x)) * abs(x))) * (t_0 * t_0))
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double t_0 = fmax(Math.abs(c), Math.abs(s));
double t_1 = fmin(Math.abs(c), Math.abs(s));
double t_2 = t_1 * (t_0 * Math.abs(x));
double tmp;
if (Math.abs(x) <= 1.6e+25) {
tmp = ((1.0 / t_2) * 1.0) / t_2;
} else {
tmp = Math.cos((Math.abs(x) + Math.abs(x))) / ((t_1 * ((t_1 * Math.abs(x)) * Math.abs(x))) * (t_0 * t_0));
}
return tmp;
}
def code(x, c, s): t_0 = fmax(math.fabs(c), math.fabs(s)) t_1 = fmin(math.fabs(c), math.fabs(s)) t_2 = t_1 * (t_0 * math.fabs(x)) tmp = 0 if math.fabs(x) <= 1.6e+25: tmp = ((1.0 / t_2) * 1.0) / t_2 else: tmp = math.cos((math.fabs(x) + math.fabs(x))) / ((t_1 * ((t_1 * math.fabs(x)) * math.fabs(x))) * (t_0 * t_0)) return tmp
function code(x, c, s) t_0 = fmax(abs(c), abs(s)) t_1 = fmin(abs(c), abs(s)) t_2 = Float64(t_1 * Float64(t_0 * abs(x))) tmp = 0.0 if (abs(x) <= 1.6e+25) tmp = Float64(Float64(Float64(1.0 / t_2) * 1.0) / t_2); else tmp = Float64(cos(Float64(abs(x) + abs(x))) / Float64(Float64(t_1 * Float64(Float64(t_1 * abs(x)) * abs(x))) * Float64(t_0 * t_0))); end return tmp end
function tmp_2 = code(x, c, s) t_0 = max(abs(c), abs(s)); t_1 = min(abs(c), abs(s)); t_2 = t_1 * (t_0 * abs(x)); tmp = 0.0; if (abs(x) <= 1.6e+25) tmp = ((1.0 / t_2) * 1.0) / t_2; else tmp = cos((abs(x) + abs(x))) / ((t_1 * ((t_1 * abs(x)) * abs(x))) * (t_0 * t_0)); end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[Max[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Min[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 15999999999999999731564544], N[(N[(N[(1 / t$95$2), $MachinePrecision] * 1), $MachinePrecision] / t$95$2), $MachinePrecision], N[(N[Cos[N[(N[Abs[x], $MachinePrecision] + N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[(t$95$1 * N[(N[(t$95$1 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\
t_1 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\
t_2 := t\_1 \cdot \left(t\_0 \cdot \left|x\right|\right)\\
\mathbf{if}\;\left|x\right| \leq 15999999999999999731564544:\\
\;\;\;\;\frac{\frac{1}{t\_2} \cdot 1}{t\_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(\left|x\right| + \left|x\right|\right)}{\left(t\_1 \cdot \left(\left(t\_1 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) \cdot \left(t\_0 \cdot t\_0\right)}\\
\end{array}
if x < 1.6e25Initial program 67.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6467.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
Applied rewrites67.2%
Taylor expanded in x around 0
Applied rewrites59.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
Applied rewrites76.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-/r*N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
mult-flipN/A
Applied rewrites79.0%
if 1.6e25 < x Initial program 67.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6467.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
Applied rewrites67.2%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6475.3%
Applied rewrites75.3%
(FPCore (x c s)
:precision binary64
(let* ((t_0
(* (fmin (fabs c) (fabs s)) (* (fmax (fabs c) (fabs s)) x))))
(/ (* (/ 1 t_0) 1) t_0)))double code(double x, double c, double s) {
double t_0 = fmin(fabs(c), fabs(s)) * (fmax(fabs(c), fabs(s)) * x);
return ((1.0 / t_0) * 1.0) / t_0;
}
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(x, c, s)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
t_0 = fmin(abs(c), abs(s)) * (fmax(abs(c), abs(s)) * x)
code = ((1.0d0 / t_0) * 1.0d0) / t_0
end function
public static double code(double x, double c, double s) {
double t_0 = fmin(Math.abs(c), Math.abs(s)) * (fmax(Math.abs(c), Math.abs(s)) * x);
return ((1.0 / t_0) * 1.0) / t_0;
}
def code(x, c, s): t_0 = fmin(math.fabs(c), math.fabs(s)) * (fmax(math.fabs(c), math.fabs(s)) * x) return ((1.0 / t_0) * 1.0) / t_0
function code(x, c, s) t_0 = Float64(fmin(abs(c), abs(s)) * Float64(fmax(abs(c), abs(s)) * x)) return Float64(Float64(Float64(1.0 / t_0) * 1.0) / t_0) end
function tmp = code(x, c, s) t_0 = min(abs(c), abs(s)) * (max(abs(c), abs(s)) * x); tmp = ((1.0 / t_0) * 1.0) / t_0; end
code[x_, c_, s_] := Block[{t$95$0 = N[(N[Min[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision] * N[(N[Max[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(1 / t$95$0), $MachinePrecision] * 1), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
t_0 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right) \cdot \left(\mathsf{max}\left(\left|c\right|, \left|s\right|\right) \cdot x\right)\\
\frac{\frac{1}{t\_0} \cdot 1}{t\_0}
\end{array}
Initial program 67.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6467.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
Applied rewrites67.2%
Taylor expanded in x around 0
Applied rewrites59.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
Applied rewrites76.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-/r*N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
mult-flipN/A
Applied rewrites79.0%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (* (* (- (fabs c)) x) s)) (t_1 (* (fabs c) s)))
(if (<=
(fabs c)
1162941958872971/11629419588729710248789180926208072549658261770997088964503843186890228609814366773219056811420217048972200345700258846936553626057834496)
(/ 1 (* t_1 (* (* t_1 x) x)))
(/ 1 (* t_0 t_0)))))double code(double x, double c, double s) {
double t_0 = (-fabs(c) * x) * s;
double t_1 = fabs(c) * s;
double tmp;
if (fabs(c) <= 1e-121) {
tmp = 1.0 / (t_1 * ((t_1 * x) * x));
} else {
tmp = 1.0 / (t_0 * 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(x, c, s)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (-abs(c) * x) * s
t_1 = abs(c) * s
if (abs(c) <= 1d-121) then
tmp = 1.0d0 / (t_1 * ((t_1 * x) * x))
else
tmp = 1.0d0 / (t_0 * t_0)
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double t_0 = (-Math.abs(c) * x) * s;
double t_1 = Math.abs(c) * s;
double tmp;
if (Math.abs(c) <= 1e-121) {
tmp = 1.0 / (t_1 * ((t_1 * x) * x));
} else {
tmp = 1.0 / (t_0 * t_0);
}
return tmp;
}
def code(x, c, s): t_0 = (-math.fabs(c) * x) * s t_1 = math.fabs(c) * s tmp = 0 if math.fabs(c) <= 1e-121: tmp = 1.0 / (t_1 * ((t_1 * x) * x)) else: tmp = 1.0 / (t_0 * t_0) return tmp
function code(x, c, s) t_0 = Float64(Float64(Float64(-abs(c)) * x) * s) t_1 = Float64(abs(c) * s) tmp = 0.0 if (abs(c) <= 1e-121) tmp = Float64(1.0 / Float64(t_1 * Float64(Float64(t_1 * x) * x))); else tmp = Float64(1.0 / Float64(t_0 * t_0)); end return tmp end
function tmp_2 = code(x, c, s) t_0 = (-abs(c) * x) * s; t_1 = abs(c) * s; tmp = 0.0; if (abs(c) <= 1e-121) tmp = 1.0 / (t_1 * ((t_1 * x) * x)); else tmp = 1.0 / (t_0 * t_0); end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[(N[((-N[Abs[c], $MachinePrecision]) * x), $MachinePrecision] * s), $MachinePrecision]}, Block[{t$95$1 = N[(N[Abs[c], $MachinePrecision] * s), $MachinePrecision]}, If[LessEqual[N[Abs[c], $MachinePrecision], 1162941958872971/11629419588729710248789180926208072549658261770997088964503843186890228609814366773219056811420217048972200345700258846936553626057834496], N[(1 / N[(t$95$1 * N[(N[(t$95$1 * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \left(\left(-\left|c\right|\right) \cdot x\right) \cdot s\\
t_1 := \left|c\right| \cdot s\\
\mathbf{if}\;\left|c\right| \leq \frac{1162941958872971}{11629419588729710248789180926208072549658261770997088964503843186890228609814366773219056811420217048972200345700258846936553626057834496}:\\
\;\;\;\;\frac{1}{t\_1 \cdot \left(\left(t\_1 \cdot x\right) \cdot x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t\_0 \cdot t\_0}\\
\end{array}
if c < 9.9999999999999998e-122Initial program 67.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6467.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
Applied rewrites67.2%
Taylor expanded in x around 0
Applied rewrites59.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
Applied rewrites76.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6476.8%
Applied rewrites76.8%
if 9.9999999999999998e-122 < c Initial program 67.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6467.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
Applied rewrites67.2%
Taylor expanded in x around 0
Applied rewrites59.6%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
sqr-neg-revN/A
unswap-sqrN/A
lift-*.f64N/A
unswap-sqrN/A
lower-*.f64N/A
Applied rewrites78.9%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (fmax (fabs c) (fabs s)))
(t_1 (* t_0 x))
(t_2 (fmin (fabs c) (fabs s))))
(if (<= t_2 4253529586511731/42535295865117307932921825928971026432)
(/ 1 (* (* (* t_1 (* t_2 t_0)) t_2) x))
(/ 1 (* (* (* (* t_2 t_2) x) t_0) t_1)))))double code(double x, double c, double s) {
double t_0 = fmax(fabs(c), fabs(s));
double t_1 = t_0 * x;
double t_2 = fmin(fabs(c), fabs(s));
double tmp;
if (t_2 <= 1e-22) {
tmp = 1.0 / (((t_1 * (t_2 * t_0)) * t_2) * x);
} else {
tmp = 1.0 / ((((t_2 * t_2) * x) * 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(x, c, s)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = fmax(abs(c), abs(s))
t_1 = t_0 * x
t_2 = fmin(abs(c), abs(s))
if (t_2 <= 1d-22) then
tmp = 1.0d0 / (((t_1 * (t_2 * t_0)) * t_2) * x)
else
tmp = 1.0d0 / ((((t_2 * t_2) * x) * t_0) * t_1)
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double t_0 = fmax(Math.abs(c), Math.abs(s));
double t_1 = t_0 * x;
double t_2 = fmin(Math.abs(c), Math.abs(s));
double tmp;
if (t_2 <= 1e-22) {
tmp = 1.0 / (((t_1 * (t_2 * t_0)) * t_2) * x);
} else {
tmp = 1.0 / ((((t_2 * t_2) * x) * t_0) * t_1);
}
return tmp;
}
def code(x, c, s): t_0 = fmax(math.fabs(c), math.fabs(s)) t_1 = t_0 * x t_2 = fmin(math.fabs(c), math.fabs(s)) tmp = 0 if t_2 <= 1e-22: tmp = 1.0 / (((t_1 * (t_2 * t_0)) * t_2) * x) else: tmp = 1.0 / ((((t_2 * t_2) * x) * t_0) * t_1) return tmp
function code(x, c, s) t_0 = fmax(abs(c), abs(s)) t_1 = Float64(t_0 * x) t_2 = fmin(abs(c), abs(s)) tmp = 0.0 if (t_2 <= 1e-22) tmp = Float64(1.0 / Float64(Float64(Float64(t_1 * Float64(t_2 * t_0)) * t_2) * x)); else tmp = Float64(1.0 / Float64(Float64(Float64(Float64(t_2 * t_2) * x) * t_0) * t_1)); end return tmp end
function tmp_2 = code(x, c, s) t_0 = max(abs(c), abs(s)); t_1 = t_0 * x; t_2 = min(abs(c), abs(s)); tmp = 0.0; if (t_2 <= 1e-22) tmp = 1.0 / (((t_1 * (t_2 * t_0)) * t_2) * x); else tmp = 1.0 / ((((t_2 * t_2) * x) * t_0) * t_1); end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[Max[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * x), $MachinePrecision]}, Block[{t$95$2 = N[Min[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$2, 4253529586511731/42535295865117307932921825928971026432], N[(1 / N[(N[(N[(t$95$1 * N[(t$95$2 * t$95$0), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(1 / N[(N[(N[(N[(t$95$2 * t$95$2), $MachinePrecision] * x), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\
t_1 := t\_0 \cdot x\\
t_2 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\
\mathbf{if}\;t\_2 \leq \frac{4253529586511731}{42535295865117307932921825928971026432}:\\
\;\;\;\;\frac{1}{\left(\left(t\_1 \cdot \left(t\_2 \cdot t\_0\right)\right) \cdot t\_2\right) \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(\left(t\_2 \cdot t\_2\right) \cdot x\right) \cdot t\_0\right) \cdot t\_1}\\
\end{array}
if c < 1e-22Initial program 67.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6467.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
Applied rewrites67.2%
Taylor expanded in x around 0
Applied rewrites59.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites75.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lower-*.f6475.4%
Applied rewrites75.4%
if 1e-22 < c Initial program 67.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6467.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
Applied rewrites67.2%
Taylor expanded in x around 0
Applied rewrites59.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6467.4%
Applied rewrites67.4%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (fmin (fabs c) (fabs s)))
(t_1 (fmax (fabs c) (fabs s)))
(t_2 (* t_0 t_1)))
(if (<=
t_0
3794275180128377/948568795032094272909893509191171341133987714380927500611236528192824358010355712)
(/ 1 (* t_2 (* (* t_2 x) x)))
(/ 1 (* (* (* (* t_0 t_0) x) t_1) (* t_1 x))))))double code(double x, double c, double s) {
double t_0 = fmin(fabs(c), fabs(s));
double t_1 = fmax(fabs(c), fabs(s));
double t_2 = t_0 * t_1;
double tmp;
if (t_0 <= 4e-66) {
tmp = 1.0 / (t_2 * ((t_2 * x) * x));
} else {
tmp = 1.0 / ((((t_0 * t_0) * x) * t_1) * (t_1 * x));
}
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(x, c, s)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = fmin(abs(c), abs(s))
t_1 = fmax(abs(c), abs(s))
t_2 = t_0 * t_1
if (t_0 <= 4d-66) then
tmp = 1.0d0 / (t_2 * ((t_2 * x) * x))
else
tmp = 1.0d0 / ((((t_0 * t_0) * x) * t_1) * (t_1 * x))
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double t_0 = fmin(Math.abs(c), Math.abs(s));
double t_1 = fmax(Math.abs(c), Math.abs(s));
double t_2 = t_0 * t_1;
double tmp;
if (t_0 <= 4e-66) {
tmp = 1.0 / (t_2 * ((t_2 * x) * x));
} else {
tmp = 1.0 / ((((t_0 * t_0) * x) * t_1) * (t_1 * x));
}
return tmp;
}
def code(x, c, s): t_0 = fmin(math.fabs(c), math.fabs(s)) t_1 = fmax(math.fabs(c), math.fabs(s)) t_2 = t_0 * t_1 tmp = 0 if t_0 <= 4e-66: tmp = 1.0 / (t_2 * ((t_2 * x) * x)) else: tmp = 1.0 / ((((t_0 * t_0) * x) * t_1) * (t_1 * x)) return tmp
function code(x, c, s) t_0 = fmin(abs(c), abs(s)) t_1 = fmax(abs(c), abs(s)) t_2 = Float64(t_0 * t_1) tmp = 0.0 if (t_0 <= 4e-66) tmp = Float64(1.0 / Float64(t_2 * Float64(Float64(t_2 * x) * x))); else tmp = Float64(1.0 / Float64(Float64(Float64(Float64(t_0 * t_0) * x) * t_1) * Float64(t_1 * x))); end return tmp end
function tmp_2 = code(x, c, s) t_0 = min(abs(c), abs(s)); t_1 = max(abs(c), abs(s)); t_2 = t_0 * t_1; tmp = 0.0; if (t_0 <= 4e-66) tmp = 1.0 / (t_2 * ((t_2 * x) * x)); else tmp = 1.0 / ((((t_0 * t_0) * x) * t_1) * (t_1 * x)); end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[Min[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * t$95$1), $MachinePrecision]}, If[LessEqual[t$95$0, 3794275180128377/948568795032094272909893509191171341133987714380927500611236528192824358010355712], N[(1 / N[(t$95$2 * N[(N[(t$95$2 * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1 / N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * x), $MachinePrecision] * t$95$1), $MachinePrecision] * N[(t$95$1 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\
t_1 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\
t_2 := t\_0 \cdot t\_1\\
\mathbf{if}\;t\_0 \leq \frac{3794275180128377}{948568795032094272909893509191171341133987714380927500611236528192824358010355712}:\\
\;\;\;\;\frac{1}{t\_2 \cdot \left(\left(t\_2 \cdot x\right) \cdot x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(\left(t\_0 \cdot t\_0\right) \cdot x\right) \cdot t\_1\right) \cdot \left(t\_1 \cdot x\right)}\\
\end{array}
if c < 3.9999999999999999e-66Initial program 67.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6467.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
Applied rewrites67.2%
Taylor expanded in x around 0
Applied rewrites59.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
Applied rewrites76.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6476.8%
Applied rewrites76.8%
if 3.9999999999999999e-66 < c Initial program 67.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6467.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
Applied rewrites67.2%
Taylor expanded in x around 0
Applied rewrites59.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6467.4%
Applied rewrites67.4%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (fmin (fabs c) (fabs s)))
(t_1 (fmax (fabs c) (fabs s)))
(t_2 (* t_0 t_1)))
(if (<=
t_0
1162941958872971/11629419588729710248789180926208072549658261770997088964503843186890228609814366773219056811420217048972200345700258846936553626057834496)
(/ 1 (* t_2 (* (* t_2 x) x)))
(/ 1 (* (* t_2 (* t_0 x)) (* t_1 x))))))double code(double x, double c, double s) {
double t_0 = fmin(fabs(c), fabs(s));
double t_1 = fmax(fabs(c), fabs(s));
double t_2 = t_0 * t_1;
double tmp;
if (t_0 <= 1e-121) {
tmp = 1.0 / (t_2 * ((t_2 * x) * x));
} else {
tmp = 1.0 / ((t_2 * (t_0 * x)) * (t_1 * x));
}
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(x, c, s)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = fmin(abs(c), abs(s))
t_1 = fmax(abs(c), abs(s))
t_2 = t_0 * t_1
if (t_0 <= 1d-121) then
tmp = 1.0d0 / (t_2 * ((t_2 * x) * x))
else
tmp = 1.0d0 / ((t_2 * (t_0 * x)) * (t_1 * x))
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double t_0 = fmin(Math.abs(c), Math.abs(s));
double t_1 = fmax(Math.abs(c), Math.abs(s));
double t_2 = t_0 * t_1;
double tmp;
if (t_0 <= 1e-121) {
tmp = 1.0 / (t_2 * ((t_2 * x) * x));
} else {
tmp = 1.0 / ((t_2 * (t_0 * x)) * (t_1 * x));
}
return tmp;
}
def code(x, c, s): t_0 = fmin(math.fabs(c), math.fabs(s)) t_1 = fmax(math.fabs(c), math.fabs(s)) t_2 = t_0 * t_1 tmp = 0 if t_0 <= 1e-121: tmp = 1.0 / (t_2 * ((t_2 * x) * x)) else: tmp = 1.0 / ((t_2 * (t_0 * x)) * (t_1 * x)) return tmp
function code(x, c, s) t_0 = fmin(abs(c), abs(s)) t_1 = fmax(abs(c), abs(s)) t_2 = Float64(t_0 * t_1) tmp = 0.0 if (t_0 <= 1e-121) tmp = Float64(1.0 / Float64(t_2 * Float64(Float64(t_2 * x) * x))); else tmp = Float64(1.0 / Float64(Float64(t_2 * Float64(t_0 * x)) * Float64(t_1 * x))); end return tmp end
function tmp_2 = code(x, c, s) t_0 = min(abs(c), abs(s)); t_1 = max(abs(c), abs(s)); t_2 = t_0 * t_1; tmp = 0.0; if (t_0 <= 1e-121) tmp = 1.0 / (t_2 * ((t_2 * x) * x)); else tmp = 1.0 / ((t_2 * (t_0 * x)) * (t_1 * x)); end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[Min[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * t$95$1), $MachinePrecision]}, If[LessEqual[t$95$0, 1162941958872971/11629419588729710248789180926208072549658261770997088964503843186890228609814366773219056811420217048972200345700258846936553626057834496], N[(1 / N[(t$95$2 * N[(N[(t$95$2 * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1 / N[(N[(t$95$2 * N[(t$95$0 * x), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\
t_1 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\
t_2 := t\_0 \cdot t\_1\\
\mathbf{if}\;t\_0 \leq \frac{1162941958872971}{11629419588729710248789180926208072549658261770997088964503843186890228609814366773219056811420217048972200345700258846936553626057834496}:\\
\;\;\;\;\frac{1}{t\_2 \cdot \left(\left(t\_2 \cdot x\right) \cdot x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(t\_2 \cdot \left(t\_0 \cdot x\right)\right) \cdot \left(t\_1 \cdot x\right)}\\
\end{array}
if c < 9.9999999999999998e-122Initial program 67.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6467.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
Applied rewrites67.2%
Taylor expanded in x around 0
Applied rewrites59.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
Applied rewrites76.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6476.8%
Applied rewrites76.8%
if 9.9999999999999998e-122 < c Initial program 67.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6467.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
Applied rewrites67.2%
Taylor expanded in x around 0
Applied rewrites59.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
Applied rewrites76.1%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6475.4%
Applied rewrites75.4%
(FPCore (x c s) :precision binary64 (let* ((t_0 (fmin (fabs c) (fabs s))) (t_1 (fmax (fabs c) (fabs s)))) (/ 1 (* (* (* (* (* t_1 x) t_0) t_1) x) t_0))))
double code(double x, double c, double s) {
double t_0 = fmin(fabs(c), fabs(s));
double t_1 = fmax(fabs(c), fabs(s));
return 1.0 / (((((t_1 * x) * t_0) * t_1) * x) * t_0);
}
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(x, c, s)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: t_1
t_0 = fmin(abs(c), abs(s))
t_1 = fmax(abs(c), abs(s))
code = 1.0d0 / (((((t_1 * x) * t_0) * t_1) * x) * t_0)
end function
public static double code(double x, double c, double s) {
double t_0 = fmin(Math.abs(c), Math.abs(s));
double t_1 = fmax(Math.abs(c), Math.abs(s));
return 1.0 / (((((t_1 * x) * t_0) * t_1) * x) * t_0);
}
def code(x, c, s): t_0 = fmin(math.fabs(c), math.fabs(s)) t_1 = fmax(math.fabs(c), math.fabs(s)) return 1.0 / (((((t_1 * x) * t_0) * t_1) * x) * t_0)
function code(x, c, s) t_0 = fmin(abs(c), abs(s)) t_1 = fmax(abs(c), abs(s)) return Float64(1.0 / Float64(Float64(Float64(Float64(Float64(t_1 * x) * t_0) * t_1) * x) * t_0)) end
function tmp = code(x, c, s) t_0 = min(abs(c), abs(s)); t_1 = max(abs(c), abs(s)); tmp = 1.0 / (((((t_1 * x) * t_0) * t_1) * x) * t_0); end
code[x_, c_, s_] := Block[{t$95$0 = N[Min[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, N[(1 / N[(N[(N[(N[(N[(t$95$1 * x), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision] * x), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\
t_1 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\
\frac{1}{\left(\left(\left(\left(t\_1 \cdot x\right) \cdot t\_0\right) \cdot t\_1\right) \cdot x\right) \cdot t\_0}
\end{array}
Initial program 67.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6467.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
Applied rewrites67.2%
Taylor expanded in x around 0
Applied rewrites59.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
Applied rewrites76.3%
(FPCore (x c s) :precision binary64 (/ 1 (* (* c s) (* (* (* c s) x) x))))
double code(double x, double c, double s) {
return 1.0 / ((c * s) * (((c * s) * x) * x));
}
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(x, c, s)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = 1.0d0 / ((c * s) * (((c * s) * x) * x))
end function
public static double code(double x, double c, double s) {
return 1.0 / ((c * s) * (((c * s) * x) * x));
}
def code(x, c, s): return 1.0 / ((c * s) * (((c * s) * x) * x))
function code(x, c, s) return Float64(1.0 / Float64(Float64(c * s) * Float64(Float64(Float64(c * s) * x) * x))) end
function tmp = code(x, c, s) tmp = 1.0 / ((c * s) * (((c * s) * x) * x)); end
code[x_, c_, s_] := N[(1 / N[(N[(c * s), $MachinePrecision] * N[(N[(N[(c * s), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{1}{\left(c \cdot s\right) \cdot \left(\left(\left(c \cdot s\right) \cdot x\right) \cdot x\right)}
Initial program 67.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6467.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6467.2%
Applied rewrites67.2%
Taylor expanded in x around 0
Applied rewrites59.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
Applied rewrites76.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6476.8%
Applied rewrites76.8%
herbie shell --seed 2025271 -o generate:evaluate
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2 x)) (* (pow c 2) (* (* x (pow s 2)) x))))