
(FPCore (x c s) :precision binary64 (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) 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.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s, 2.0], $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 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x c s) :precision binary64 (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) 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.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s, 2.0], $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 (* (fabs x) t_0))
(t_2 (fmin (fabs c) (fabs s)))
(t_3 (* (* t_2 (fabs x)) t_0)))
(if (<= (fabs x) 4e-53)
(/ 1.0 (* t_2 (* (* t_2 t_1) t_1)))
(/ (/ (cos (+ (fabs x) (fabs x))) t_3) t_3))))double code(double x, double c, double s) {
double t_0 = fmax(fabs(c), fabs(s));
double t_1 = fabs(x) * t_0;
double t_2 = fmin(fabs(c), fabs(s));
double t_3 = (t_2 * fabs(x)) * t_0;
double tmp;
if (fabs(x) <= 4e-53) {
tmp = 1.0 / (t_2 * ((t_2 * t_1) * t_1));
} else {
tmp = (cos((fabs(x) + fabs(x))) / t_3) / t_3;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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 = abs(x) * t_0
t_2 = fmin(abs(c), abs(s))
t_3 = (t_2 * abs(x)) * t_0
if (abs(x) <= 4d-53) then
tmp = 1.0d0 / (t_2 * ((t_2 * t_1) * t_1))
else
tmp = (cos((abs(x) + abs(x))) / t_3) / t_3
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.abs(x) * t_0;
double t_2 = fmin(Math.abs(c), Math.abs(s));
double t_3 = (t_2 * Math.abs(x)) * t_0;
double tmp;
if (Math.abs(x) <= 4e-53) {
tmp = 1.0 / (t_2 * ((t_2 * t_1) * t_1));
} else {
tmp = (Math.cos((Math.abs(x) + Math.abs(x))) / t_3) / t_3;
}
return tmp;
}
def code(x, c, s): t_0 = fmax(math.fabs(c), math.fabs(s)) t_1 = math.fabs(x) * t_0 t_2 = fmin(math.fabs(c), math.fabs(s)) t_3 = (t_2 * math.fabs(x)) * t_0 tmp = 0 if math.fabs(x) <= 4e-53: tmp = 1.0 / (t_2 * ((t_2 * t_1) * t_1)) else: tmp = (math.cos((math.fabs(x) + math.fabs(x))) / t_3) / t_3 return tmp
function code(x, c, s) t_0 = fmax(abs(c), abs(s)) t_1 = Float64(abs(x) * t_0) t_2 = fmin(abs(c), abs(s)) t_3 = Float64(Float64(t_2 * abs(x)) * t_0) tmp = 0.0 if (abs(x) <= 4e-53) tmp = Float64(1.0 / Float64(t_2 * Float64(Float64(t_2 * t_1) * t_1))); else tmp = Float64(Float64(cos(Float64(abs(x) + abs(x))) / t_3) / t_3); end return tmp end
function tmp_2 = code(x, c, s) t_0 = max(abs(c), abs(s)); t_1 = abs(x) * t_0; t_2 = min(abs(c), abs(s)); t_3 = (t_2 * abs(x)) * t_0; tmp = 0.0; if (abs(x) <= 4e-53) tmp = 1.0 / (t_2 * ((t_2 * t_1) * t_1)); else tmp = (cos((abs(x) + abs(x))) / t_3) / t_3; 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[(N[Abs[x], $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[Min[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(t$95$2 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 4e-53], N[(1.0 / N[(t$95$2 * N[(N[(t$95$2 * t$95$1), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[N[(N[Abs[x], $MachinePrecision] + N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$3), $MachinePrecision] / t$95$3), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\
t_1 := \left|x\right| \cdot t\_0\\
t_2 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\
t_3 := \left(t\_2 \cdot \left|x\right|\right) \cdot t\_0\\
\mathbf{if}\;\left|x\right| \leq 4 \cdot 10^{-53}:\\
\;\;\;\;\frac{1}{t\_2 \cdot \left(\left(t\_2 \cdot t\_1\right) \cdot t\_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos \left(\left|x\right| + \left|x\right|\right)}{t\_3}}{t\_3}\\
\end{array}
if x < 4.0000000000000001e-53Initial program 67.2%
Taylor expanded in x around 0
Applied rewrites59.2%
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6466.7%
Applied rewrites66.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6477.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.4%
Applied rewrites77.4%
if 4.0000000000000001e-53 < x Initial 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.8%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
lift-/.f64N/A
lift-+.f64N/A
count-2-revN/A
lift-*.f64N/A
associate-/l/N/A
frac-timesN/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
lower-/.f64N/A
Applied rewrites92.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6493.7%
Applied rewrites93.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
associate-*l/N/A
lift-/.f64N/A
frac-timesN/A
*-lft-identityN/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f64N/A
lower-/.f6497.2%
Applied rewrites97.2%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (fmax (fabs c) (fabs s)))
(t_1 (* (fabs x) t_0))
(t_2 (fmin (fabs c) (fabs s)))
(t_3 (* t_2 (fabs x))))
(if (<= (fabs x) 2e-13)
(/ 1.0 (* t_2 (* (* t_2 t_1) t_1)))
(/ (cos (+ (fabs x) (fabs x))) (* t_3 (* t_0 (* t_3 t_0)))))))double code(double x, double c, double s) {
double t_0 = fmax(fabs(c), fabs(s));
double t_1 = fabs(x) * t_0;
double t_2 = fmin(fabs(c), fabs(s));
double t_3 = t_2 * fabs(x);
double tmp;
if (fabs(x) <= 2e-13) {
tmp = 1.0 / (t_2 * ((t_2 * t_1) * t_1));
} else {
tmp = cos((fabs(x) + fabs(x))) / (t_3 * (t_0 * (t_3 * 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 = abs(x) * t_0
t_2 = fmin(abs(c), abs(s))
t_3 = t_2 * abs(x)
if (abs(x) <= 2d-13) then
tmp = 1.0d0 / (t_2 * ((t_2 * t_1) * t_1))
else
tmp = cos((abs(x) + abs(x))) / (t_3 * (t_0 * (t_3 * 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.abs(x) * t_0;
double t_2 = fmin(Math.abs(c), Math.abs(s));
double t_3 = t_2 * Math.abs(x);
double tmp;
if (Math.abs(x) <= 2e-13) {
tmp = 1.0 / (t_2 * ((t_2 * t_1) * t_1));
} else {
tmp = Math.cos((Math.abs(x) + Math.abs(x))) / (t_3 * (t_0 * (t_3 * t_0)));
}
return tmp;
}
def code(x, c, s): t_0 = fmax(math.fabs(c), math.fabs(s)) t_1 = math.fabs(x) * t_0 t_2 = fmin(math.fabs(c), math.fabs(s)) t_3 = t_2 * math.fabs(x) tmp = 0 if math.fabs(x) <= 2e-13: tmp = 1.0 / (t_2 * ((t_2 * t_1) * t_1)) else: tmp = math.cos((math.fabs(x) + math.fabs(x))) / (t_3 * (t_0 * (t_3 * t_0))) return tmp
function code(x, c, s) t_0 = fmax(abs(c), abs(s)) t_1 = Float64(abs(x) * t_0) t_2 = fmin(abs(c), abs(s)) t_3 = Float64(t_2 * abs(x)) tmp = 0.0 if (abs(x) <= 2e-13) tmp = Float64(1.0 / Float64(t_2 * Float64(Float64(t_2 * t_1) * t_1))); else tmp = Float64(cos(Float64(abs(x) + abs(x))) / Float64(t_3 * Float64(t_0 * Float64(t_3 * t_0)))); end return tmp end
function tmp_2 = code(x, c, s) t_0 = max(abs(c), abs(s)); t_1 = abs(x) * t_0; t_2 = min(abs(c), abs(s)); t_3 = t_2 * abs(x); tmp = 0.0; if (abs(x) <= 2e-13) tmp = 1.0 / (t_2 * ((t_2 * t_1) * t_1)); else tmp = cos((abs(x) + abs(x))) / (t_3 * (t_0 * (t_3 * 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[(N[Abs[x], $MachinePrecision] * t$95$0), $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]}, If[LessEqual[N[Abs[x], $MachinePrecision], 2e-13], N[(1.0 / N[(t$95$2 * N[(N[(t$95$2 * t$95$1), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(N[Abs[x], $MachinePrecision] + N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$3 * N[(t$95$0 * N[(t$95$3 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\
t_1 := \left|x\right| \cdot t\_0\\
t_2 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\
t_3 := t\_2 \cdot \left|x\right|\\
\mathbf{if}\;\left|x\right| \leq 2 \cdot 10^{-13}:\\
\;\;\;\;\frac{1}{t\_2 \cdot \left(\left(t\_2 \cdot t\_1\right) \cdot t\_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(\left|x\right| + \left|x\right|\right)}{t\_3 \cdot \left(t\_0 \cdot \left(t\_3 \cdot t\_0\right)\right)}\\
\end{array}
if x < 2.0000000000000001e-13Initial program 67.2%
Taylor expanded in x around 0
Applied rewrites59.2%
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6466.7%
Applied rewrites66.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6477.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.4%
Applied rewrites77.4%
if 2.0000000000000001e-13 < x Initial 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.8%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
lift-/.f64N/A
lift-+.f64N/A
count-2-revN/A
lift-*.f64N/A
associate-/l/N/A
frac-timesN/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
lower-/.f64N/A
Applied rewrites92.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6493.7%
Applied rewrites93.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
*-commutativeN/A
lift-/.f64N/A
associate-/l/N/A
frac-timesN/A
*-commutativeN/A
*-lft-identityN/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6493.2%
Applied rewrites93.2%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (fmax (fabs c) (fabs s)))
(t_1 (* (fabs x) t_0))
(t_2 (fmin (fabs c) (fabs s)))
(t_3 (* t_2 t_1)))
(if (<= (fabs x) 2.2e-55)
(/ 1.0 (* t_2 (* t_3 t_1)))
(/ (cos (+ (fabs x) (fabs x))) (* t_0 (* (* t_3 (fabs x)) t_2))))))double code(double x, double c, double s) {
double t_0 = fmax(fabs(c), fabs(s));
double t_1 = fabs(x) * t_0;
double t_2 = fmin(fabs(c), fabs(s));
double t_3 = t_2 * t_1;
double tmp;
if (fabs(x) <= 2.2e-55) {
tmp = 1.0 / (t_2 * (t_3 * t_1));
} else {
tmp = cos((fabs(x) + fabs(x))) / (t_0 * ((t_3 * fabs(x)) * t_2));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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 = abs(x) * t_0
t_2 = fmin(abs(c), abs(s))
t_3 = t_2 * t_1
if (abs(x) <= 2.2d-55) then
tmp = 1.0d0 / (t_2 * (t_3 * t_1))
else
tmp = cos((abs(x) + abs(x))) / (t_0 * ((t_3 * abs(x)) * t_2))
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.abs(x) * t_0;
double t_2 = fmin(Math.abs(c), Math.abs(s));
double t_3 = t_2 * t_1;
double tmp;
if (Math.abs(x) <= 2.2e-55) {
tmp = 1.0 / (t_2 * (t_3 * t_1));
} else {
tmp = Math.cos((Math.abs(x) + Math.abs(x))) / (t_0 * ((t_3 * Math.abs(x)) * t_2));
}
return tmp;
}
def code(x, c, s): t_0 = fmax(math.fabs(c), math.fabs(s)) t_1 = math.fabs(x) * t_0 t_2 = fmin(math.fabs(c), math.fabs(s)) t_3 = t_2 * t_1 tmp = 0 if math.fabs(x) <= 2.2e-55: tmp = 1.0 / (t_2 * (t_3 * t_1)) else: tmp = math.cos((math.fabs(x) + math.fabs(x))) / (t_0 * ((t_3 * math.fabs(x)) * t_2)) return tmp
function code(x, c, s) t_0 = fmax(abs(c), abs(s)) t_1 = Float64(abs(x) * t_0) t_2 = fmin(abs(c), abs(s)) t_3 = Float64(t_2 * t_1) tmp = 0.0 if (abs(x) <= 2.2e-55) tmp = Float64(1.0 / Float64(t_2 * Float64(t_3 * t_1))); else tmp = Float64(cos(Float64(abs(x) + abs(x))) / Float64(t_0 * Float64(Float64(t_3 * abs(x)) * t_2))); end return tmp end
function tmp_2 = code(x, c, s) t_0 = max(abs(c), abs(s)); t_1 = abs(x) * t_0; t_2 = min(abs(c), abs(s)); t_3 = t_2 * t_1; tmp = 0.0; if (abs(x) <= 2.2e-55) tmp = 1.0 / (t_2 * (t_3 * t_1)); else tmp = cos((abs(x) + abs(x))) / (t_0 * ((t_3 * abs(x)) * t_2)); 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[(N[Abs[x], $MachinePrecision] * t$95$0), $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], 2.2e-55], N[(1.0 / N[(t$95$2 * N[(t$95$3 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(N[Abs[x], $MachinePrecision] + N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * N[(N[(t$95$3 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\
t_1 := \left|x\right| \cdot t\_0\\
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 2.2 \cdot 10^{-55}:\\
\;\;\;\;\frac{1}{t\_2 \cdot \left(t\_3 \cdot t\_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(\left|x\right| + \left|x\right|\right)}{t\_0 \cdot \left(\left(t\_3 \cdot \left|x\right|\right) \cdot t\_2\right)}\\
\end{array}
if x < 2.2e-55Initial program 67.2%
Taylor expanded in x around 0
Applied rewrites59.2%
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6466.7%
Applied rewrites66.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6477.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.4%
Applied rewrites77.4%
if 2.2e-55 < x Initial 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.8%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
lift-/.f64N/A
lift-+.f64N/A
count-2-revN/A
lift-*.f64N/A
associate-/l/N/A
frac-timesN/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
lower-/.f64N/A
Applied rewrites92.0%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flip-revN/A
associate-/l/N/A
lower-/.f64N/A
lower-*.f6491.9%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6490.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.6%
Applied rewrites90.6%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (fmax (fabs c) (fabs s)))
(t_1 (* x t_0))
(t_2 (fmin (fabs c) (fabs s)))
(t_3 (* t_2 t_1)))
(if (<=
(/ (cos (* 2.0 x)) (* (pow t_2 2.0) (* (* x (pow t_0 2.0)) x)))
-1e-171)
(/ (+ 1.0 (* -2.0 (pow x 2.0))) (* t_0 (* (* t_3 x) t_2)))
(/ 1.0 (* t_2 (* t_3 t_1))))))double code(double x, double c, double s) {
double t_0 = fmax(fabs(c), fabs(s));
double t_1 = x * t_0;
double t_2 = fmin(fabs(c), fabs(s));
double t_3 = t_2 * t_1;
double tmp;
if ((cos((2.0 * x)) / (pow(t_2, 2.0) * ((x * pow(t_0, 2.0)) * x))) <= -1e-171) {
tmp = (1.0 + (-2.0 * pow(x, 2.0))) / (t_0 * ((t_3 * x) * t_2));
} else {
tmp = 1.0 / (t_2 * (t_3 * 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) :: t_3
real(8) :: tmp
t_0 = fmax(abs(c), abs(s))
t_1 = x * t_0
t_2 = fmin(abs(c), abs(s))
t_3 = t_2 * t_1
if ((cos((2.0d0 * x)) / ((t_2 ** 2.0d0) * ((x * (t_0 ** 2.0d0)) * x))) <= (-1d-171)) then
tmp = (1.0d0 + ((-2.0d0) * (x ** 2.0d0))) / (t_0 * ((t_3 * x) * t_2))
else
tmp = 1.0d0 / (t_2 * (t_3 * 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 = x * t_0;
double t_2 = fmin(Math.abs(c), Math.abs(s));
double t_3 = t_2 * t_1;
double tmp;
if ((Math.cos((2.0 * x)) / (Math.pow(t_2, 2.0) * ((x * Math.pow(t_0, 2.0)) * x))) <= -1e-171) {
tmp = (1.0 + (-2.0 * Math.pow(x, 2.0))) / (t_0 * ((t_3 * x) * t_2));
} else {
tmp = 1.0 / (t_2 * (t_3 * t_1));
}
return tmp;
}
def code(x, c, s): t_0 = fmax(math.fabs(c), math.fabs(s)) t_1 = x * t_0 t_2 = fmin(math.fabs(c), math.fabs(s)) t_3 = t_2 * t_1 tmp = 0 if (math.cos((2.0 * x)) / (math.pow(t_2, 2.0) * ((x * math.pow(t_0, 2.0)) * x))) <= -1e-171: tmp = (1.0 + (-2.0 * math.pow(x, 2.0))) / (t_0 * ((t_3 * x) * t_2)) else: tmp = 1.0 / (t_2 * (t_3 * t_1)) return tmp
function code(x, c, s) t_0 = fmax(abs(c), abs(s)) t_1 = Float64(x * t_0) t_2 = fmin(abs(c), abs(s)) t_3 = Float64(t_2 * t_1) tmp = 0.0 if (Float64(cos(Float64(2.0 * x)) / Float64((t_2 ^ 2.0) * Float64(Float64(x * (t_0 ^ 2.0)) * x))) <= -1e-171) tmp = Float64(Float64(1.0 + Float64(-2.0 * (x ^ 2.0))) / Float64(t_0 * Float64(Float64(t_3 * x) * t_2))); else tmp = Float64(1.0 / Float64(t_2 * Float64(t_3 * t_1))); end return tmp end
function tmp_2 = code(x, c, s) t_0 = max(abs(c), abs(s)); t_1 = x * t_0; t_2 = min(abs(c), abs(s)); t_3 = t_2 * t_1; tmp = 0.0; if ((cos((2.0 * x)) / ((t_2 ^ 2.0) * ((x * (t_0 ^ 2.0)) * x))) <= -1e-171) tmp = (1.0 + (-2.0 * (x ^ 2.0))) / (t_0 * ((t_3 * x) * t_2)); else tmp = 1.0 / (t_2 * (t_3 * 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[(x * t$95$0), $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[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[t$95$2, 2.0], $MachinePrecision] * N[(N[(x * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1e-171], N[(N[(1.0 + N[(-2.0 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * N[(N[(t$95$3 * x), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(t$95$2 * N[(t$95$3 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\
t_1 := x \cdot t\_0\\
t_2 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\
t_3 := t\_2 \cdot t\_1\\
\mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{t\_2}^{2} \cdot \left(\left(x \cdot {t\_0}^{2}\right) \cdot x\right)} \leq -1 \cdot 10^{-171}:\\
\;\;\;\;\frac{1 + -2 \cdot {x}^{2}}{t\_0 \cdot \left(\left(t\_3 \cdot x\right) \cdot t\_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t\_2 \cdot \left(t\_3 \cdot t\_1\right)}\\
\end{array}
if (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < -9.9999999999999998e-172Initial 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.8%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
lift-/.f64N/A
lift-+.f64N/A
count-2-revN/A
lift-*.f64N/A
associate-/l/N/A
frac-timesN/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
lower-/.f64N/A
Applied rewrites92.0%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flip-revN/A
associate-/l/N/A
lower-/.f64N/A
lower-*.f6491.9%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6490.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.6%
Applied rewrites90.6%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6459.2%
Applied rewrites59.2%
if -9.9999999999999998e-172 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) Initial program 67.2%
Taylor expanded in x around 0
Applied rewrites59.2%
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6466.7%
Applied rewrites66.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6477.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.4%
Applied rewrites77.4%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (fmin (fabs c) (fabs s)))
(t_1 (* x (fmax (fabs c) (fabs s)))))
(/ 1.0 (* t_0 (* (* t_0 t_1) t_1)))))double code(double x, double c, double s) {
double t_0 = fmin(fabs(c), fabs(s));
double t_1 = x * fmax(fabs(c), fabs(s));
return 1.0 / (t_0 * ((t_0 * t_1) * t_1));
}
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 = x * fmax(abs(c), abs(s))
code = 1.0d0 / (t_0 * ((t_0 * t_1) * t_1))
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 = x * fmax(Math.abs(c), Math.abs(s));
return 1.0 / (t_0 * ((t_0 * t_1) * t_1));
}
def code(x, c, s): t_0 = fmin(math.fabs(c), math.fabs(s)) t_1 = x * fmax(math.fabs(c), math.fabs(s)) return 1.0 / (t_0 * ((t_0 * t_1) * t_1))
function code(x, c, s) t_0 = fmin(abs(c), abs(s)) t_1 = Float64(x * fmax(abs(c), abs(s))) return Float64(1.0 / Float64(t_0 * Float64(Float64(t_0 * t_1) * t_1))) end
function tmp = code(x, c, s) t_0 = min(abs(c), abs(s)); t_1 = x * max(abs(c), abs(s)); tmp = 1.0 / (t_0 * ((t_0 * t_1) * t_1)); 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[(x * N[Max[N[Abs[c], $MachinePrecision], N[Abs[s], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * N[(N[(t$95$0 * t$95$1), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(\left|c\right|, \left|s\right|\right)\\
t_1 := x \cdot \mathsf{max}\left(\left|c\right|, \left|s\right|\right)\\
\frac{1}{t\_0 \cdot \left(\left(t\_0 \cdot t\_1\right) \cdot t\_1\right)}
\end{array}
Initial program 67.2%
Taylor expanded in x around 0
Applied rewrites59.2%
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6466.7%
Applied rewrites66.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6477.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.4%
Applied rewrites77.4%
(FPCore (x c s) :precision binary64 (let* ((t_0 (fmin (fabs c) (fabs s))) (t_1 (fmax (fabs c) (fabs s)))) (/ 1.0 (* t_0 (* t_1 (* (* (* x 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_0 * (t_1 * (((x * 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_0 * (t_1 * (((x * 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_0 * (t_1 * (((x * 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_0 * (t_1 * (((x * 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(t_0 * Float64(t_1 * Float64(Float64(Float64(x * 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_0 * (t_1 * (((x * 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.0 / N[(t$95$0 * N[(t$95$1 * N[(N[(N[(x * t$95$1), $MachinePrecision] * x), $MachinePrecision] * t$95$0), $MachinePrecision]), $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)\\
\frac{1}{t\_0 \cdot \left(t\_1 \cdot \left(\left(\left(x \cdot t\_1\right) \cdot x\right) \cdot t\_0\right)\right)}
\end{array}
Initial program 67.2%
Taylor expanded in x around 0
Applied rewrites59.2%
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6466.7%
Applied rewrites66.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6475.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.6%
Applied rewrites75.6%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6473.1%
Applied rewrites73.1%
(FPCore (x c s) :precision binary64 (let* ((t_0 (fmin c (fabs s))) (t_1 (fmax c (fabs s)))) (/ 1.0 (* t_0 (* t_1 (* (* x t_1) (* t_0 x)))))))
double code(double x, double c, double s) {
double t_0 = fmin(c, fabs(s));
double t_1 = fmax(c, fabs(s));
return 1.0 / (t_0 * (t_1 * ((x * t_1) * (t_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
real(8) :: t_0
real(8) :: t_1
t_0 = fmin(c, abs(s))
t_1 = fmax(c, abs(s))
code = 1.0d0 / (t_0 * (t_1 * ((x * t_1) * (t_0 * x))))
end function
public static double code(double x, double c, double s) {
double t_0 = fmin(c, Math.abs(s));
double t_1 = fmax(c, Math.abs(s));
return 1.0 / (t_0 * (t_1 * ((x * t_1) * (t_0 * x))));
}
def code(x, c, s): t_0 = fmin(c, math.fabs(s)) t_1 = fmax(c, math.fabs(s)) return 1.0 / (t_0 * (t_1 * ((x * t_1) * (t_0 * x))))
function code(x, c, s) t_0 = fmin(c, abs(s)) t_1 = fmax(c, abs(s)) return Float64(1.0 / Float64(t_0 * Float64(t_1 * Float64(Float64(x * t_1) * Float64(t_0 * x))))) end
function tmp = code(x, c, s) t_0 = min(c, abs(s)); t_1 = max(c, abs(s)); tmp = 1.0 / (t_0 * (t_1 * ((x * t_1) * (t_0 * x)))); end
code[x_, c_, s_] := Block[{t$95$0 = N[Min[c, N[Abs[s], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Max[c, N[Abs[s], $MachinePrecision]], $MachinePrecision]}, N[(1.0 / N[(t$95$0 * N[(t$95$1 * N[(N[(x * t$95$1), $MachinePrecision] * N[(t$95$0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(c, \left|s\right|\right)\\
t_1 := \mathsf{max}\left(c, \left|s\right|\right)\\
\frac{1}{t\_0 \cdot \left(t\_1 \cdot \left(\left(x \cdot t\_1\right) \cdot \left(t\_0 \cdot x\right)\right)\right)}
\end{array}
Initial program 67.2%
Taylor expanded in x around 0
Applied rewrites59.2%
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6466.7%
Applied rewrites66.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6475.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.6%
Applied rewrites75.6%
herbie shell --seed 2025212
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))