
(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));
}
real(8) function code(x, c, s)
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]
\begin{array}{l}
\\
\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 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));
}
real(8) function code(x, c, s)
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]
\begin{array}{l}
\\
\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
\end{array}
(FPCore (x c s) :precision binary64 (/ (/ (/ (cos (* 2.0 x)) (* s c)) x) (* (* s c) x)))
double code(double x, double c, double s) {
return ((cos((2.0 * x)) / (s * c)) / x) / ((s * c) * x);
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = ((cos((2.0d0 * x)) / (s * c)) / x) / ((s * c) * x)
end function
public static double code(double x, double c, double s) {
return ((Math.cos((2.0 * x)) / (s * c)) / x) / ((s * c) * x);
}
def code(x, c, s): return ((math.cos((2.0 * x)) / (s * c)) / x) / ((s * c) * x)
function code(x, c, s) return Float64(Float64(Float64(cos(Float64(2.0 * x)) / Float64(s * c)) / x) / Float64(Float64(s * c) * x)) end
function tmp = code(x, c, s) tmp = ((cos((2.0 * x)) / (s * c)) / x) / ((s * c) * x); end
code[x_, c_, s_] := N[(N[(N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(s * c), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / N[(N[(s * c), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{s \cdot c}}{x}}{\left(s \cdot c\right) \cdot x}
\end{array}
Initial program 70.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.9
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
associate-*l*N/A
pow2N/A
*-commutativeN/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f6499.2
Applied rewrites99.2%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6499.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.6
lift-*.f64N/A
*-commutativeN/A
lift-*.f6499.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.6
lift-*.f64N/A
*-commutativeN/A
lift-*.f6499.6
Applied rewrites99.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6499.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Final simplification99.7%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (* (* s c) x)))
(if (<= (/ (cos (* 2.0 x)) (* (* (* (pow s 2.0) x) x) (pow c 2.0))) 4e+191)
(/ (cos (+ x x)) (* (* (* (* c c) x) (* s x)) s))
(/ 1.0 (* t_0 t_0)))))
double code(double x, double c, double s) {
double t_0 = (s * c) * x;
double tmp;
if ((cos((2.0 * x)) / (((pow(s, 2.0) * x) * x) * pow(c, 2.0))) <= 4e+191) {
tmp = cos((x + x)) / ((((c * c) * x) * (s * x)) * s);
} else {
tmp = 1.0 / (t_0 * t_0);
}
return tmp;
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: tmp
t_0 = (s * c) * x
if ((cos((2.0d0 * x)) / ((((s ** 2.0d0) * x) * x) * (c ** 2.0d0))) <= 4d+191) then
tmp = cos((x + x)) / ((((c * c) * x) * (s * x)) * s)
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 = (s * c) * x;
double tmp;
if ((Math.cos((2.0 * x)) / (((Math.pow(s, 2.0) * x) * x) * Math.pow(c, 2.0))) <= 4e+191) {
tmp = Math.cos((x + x)) / ((((c * c) * x) * (s * x)) * s);
} else {
tmp = 1.0 / (t_0 * t_0);
}
return tmp;
}
def code(x, c, s): t_0 = (s * c) * x tmp = 0 if (math.cos((2.0 * x)) / (((math.pow(s, 2.0) * x) * x) * math.pow(c, 2.0))) <= 4e+191: tmp = math.cos((x + x)) / ((((c * c) * x) * (s * x)) * s) else: tmp = 1.0 / (t_0 * t_0) return tmp
function code(x, c, s) t_0 = Float64(Float64(s * c) * x) tmp = 0.0 if (Float64(cos(Float64(2.0 * x)) / Float64(Float64(Float64((s ^ 2.0) * x) * x) * (c ^ 2.0))) <= 4e+191) tmp = Float64(cos(Float64(x + x)) / Float64(Float64(Float64(Float64(c * c) * x) * Float64(s * x)) * s)); else tmp = Float64(1.0 / Float64(t_0 * t_0)); end return tmp end
function tmp_2 = code(x, c, s) t_0 = (s * c) * x; tmp = 0.0; if ((cos((2.0 * x)) / ((((s ^ 2.0) * x) * x) * (c ^ 2.0))) <= 4e+191) tmp = cos((x + x)) / ((((c * c) * x) * (s * x)) * s); else tmp = 1.0 / (t_0 * t_0); end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[(N[(s * c), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[(N[(N[Power[s, 2.0], $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4e+191], N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / N[(N[(N[(N[(c * c), $MachinePrecision] * x), $MachinePrecision] * N[(s * x), $MachinePrecision]), $MachinePrecision] * s), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(s \cdot c\right) \cdot x\\
\mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{\left(\left({s}^{2} \cdot x\right) \cdot x\right) \cdot {c}^{2}} \leq 4 \cdot 10^{+191}:\\
\;\;\;\;\frac{\cos \left(x + x\right)}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot \left(s \cdot x\right)\right) \cdot s}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t\_0 \cdot t\_0}\\
\end{array}
\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))) < 4.00000000000000029e191Initial program 88.4%
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
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6494.0
Applied rewrites94.0%
lift-*.f64N/A
count-2N/A
lower-+.f6494.0
Applied rewrites94.0%
if 4.00000000000000029e191 < (/.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 53.3%
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
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6462.6
Applied rewrites62.6%
Taylor expanded in x around 0
Applied rewrites61.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
lower-*.f6486.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6486.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6486.8
Applied rewrites86.8%
Final simplification90.4%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (* (* s c) x)))
(if (<= (/ (cos (* 2.0 x)) (* (* (* (pow s 2.0) x) x) (pow c 2.0))) -4e-214)
(/ (/ (/ -2.0 (* s s)) c) c)
(/ 1.0 (* t_0 t_0)))))
double code(double x, double c, double s) {
double t_0 = (s * c) * x;
double tmp;
if ((cos((2.0 * x)) / (((pow(s, 2.0) * x) * x) * pow(c, 2.0))) <= -4e-214) {
tmp = ((-2.0 / (s * s)) / c) / c;
} else {
tmp = 1.0 / (t_0 * t_0);
}
return tmp;
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: tmp
t_0 = (s * c) * x
if ((cos((2.0d0 * x)) / ((((s ** 2.0d0) * x) * x) * (c ** 2.0d0))) <= (-4d-214)) then
tmp = (((-2.0d0) / (s * s)) / c) / c
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 = (s * c) * x;
double tmp;
if ((Math.cos((2.0 * x)) / (((Math.pow(s, 2.0) * x) * x) * Math.pow(c, 2.0))) <= -4e-214) {
tmp = ((-2.0 / (s * s)) / c) / c;
} else {
tmp = 1.0 / (t_0 * t_0);
}
return tmp;
}
def code(x, c, s): t_0 = (s * c) * x tmp = 0 if (math.cos((2.0 * x)) / (((math.pow(s, 2.0) * x) * x) * math.pow(c, 2.0))) <= -4e-214: tmp = ((-2.0 / (s * s)) / c) / c else: tmp = 1.0 / (t_0 * t_0) return tmp
function code(x, c, s) t_0 = Float64(Float64(s * c) * x) tmp = 0.0 if (Float64(cos(Float64(2.0 * x)) / Float64(Float64(Float64((s ^ 2.0) * x) * x) * (c ^ 2.0))) <= -4e-214) tmp = Float64(Float64(Float64(-2.0 / Float64(s * s)) / c) / c); else tmp = Float64(1.0 / Float64(t_0 * t_0)); end return tmp end
function tmp_2 = code(x, c, s) t_0 = (s * c) * x; tmp = 0.0; if ((cos((2.0 * x)) / ((((s ^ 2.0) * x) * x) * (c ^ 2.0))) <= -4e-214) tmp = ((-2.0 / (s * s)) / c) / c; else tmp = 1.0 / (t_0 * t_0); end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[(N[(s * c), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[(N[(N[Power[s, 2.0], $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -4e-214], N[(N[(N[(-2.0 / N[(s * s), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision] / c), $MachinePrecision], N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(s \cdot c\right) \cdot x\\
\mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{\left(\left({s}^{2} \cdot x\right) \cdot x\right) \cdot {c}^{2}} \leq -4 \cdot 10^{-214}:\\
\;\;\;\;\frac{\frac{\frac{-2}{s \cdot s}}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t\_0 \cdot t\_0}\\
\end{array}
\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))) < -3.99999999999999965e-214Initial program 85.0%
Taylor expanded in x around 0
lower-/.f64N/A
Applied rewrites32.3%
Taylor expanded in x around inf
Applied rewrites41.6%
if -3.99999999999999965e-214 < (/.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 70.1%
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
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6477.2
Applied rewrites77.2%
Taylor expanded in x around 0
Applied rewrites73.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
lower-*.f6488.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6488.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6488.5
Applied rewrites88.5%
Final simplification86.1%
(FPCore (x c s)
:precision binary64
(let* ((t_0 (* (* c x) s)))
(if (<= x 5.8e-17)
(/ (/ 1.0 (* (* s x) c)) (* (* s c) x))
(/ (cos (* 2.0 x)) (* t_0 t_0)))))
double code(double x, double c, double s) {
double t_0 = (c * x) * s;
double tmp;
if (x <= 5.8e-17) {
tmp = (1.0 / ((s * x) * c)) / ((s * c) * x);
} else {
tmp = cos((2.0 * x)) / (t_0 * t_0);
}
return tmp;
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
real(8) :: tmp
t_0 = (c * x) * s
if (x <= 5.8d-17) then
tmp = (1.0d0 / ((s * x) * c)) / ((s * c) * x)
else
tmp = cos((2.0d0 * x)) / (t_0 * t_0)
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double t_0 = (c * x) * s;
double tmp;
if (x <= 5.8e-17) {
tmp = (1.0 / ((s * x) * c)) / ((s * c) * x);
} else {
tmp = Math.cos((2.0 * x)) / (t_0 * t_0);
}
return tmp;
}
def code(x, c, s): t_0 = (c * x) * s tmp = 0 if x <= 5.8e-17: tmp = (1.0 / ((s * x) * c)) / ((s * c) * x) else: tmp = math.cos((2.0 * x)) / (t_0 * t_0) return tmp
function code(x, c, s) t_0 = Float64(Float64(c * x) * s) tmp = 0.0 if (x <= 5.8e-17) tmp = Float64(Float64(1.0 / Float64(Float64(s * x) * c)) / Float64(Float64(s * c) * x)); else tmp = Float64(cos(Float64(2.0 * x)) / Float64(t_0 * t_0)); end return tmp end
function tmp_2 = code(x, c, s) t_0 = (c * x) * s; tmp = 0.0; if (x <= 5.8e-17) tmp = (1.0 / ((s * x) * c)) / ((s * c) * x); else tmp = cos((2.0 * x)) / (t_0 * t_0); end tmp_2 = tmp; end
code[x_, c_, s_] := Block[{t$95$0 = N[(N[(c * x), $MachinePrecision] * s), $MachinePrecision]}, If[LessEqual[x, 5.8e-17], N[(N[(1.0 / N[(N[(s * x), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision] / N[(N[(s * c), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(c \cdot x\right) \cdot s\\
\mathbf{if}\;x \leq 5.8 \cdot 10^{-17}:\\
\;\;\;\;\frac{\frac{1}{\left(s \cdot x\right) \cdot c}}{\left(s \cdot c\right) \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(2 \cdot x\right)}{t\_0 \cdot t\_0}\\
\end{array}
\end{array}
if x < 5.8000000000000006e-17Initial program 70.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.6
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
associate-*l*N/A
pow2N/A
*-commutativeN/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f6499.1
Applied rewrites99.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6499.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.6
lift-*.f64N/A
*-commutativeN/A
lift-*.f6499.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.6
lift-*.f64N/A
*-commutativeN/A
lift-*.f6499.6
Applied rewrites99.6%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6486.8
Applied rewrites86.8%
if 5.8000000000000006e-17 < x Initial program 71.6%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
unpow2N/A
unswap-sqrN/A
unpow2N/A
unswap-sqrN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6498.1
Applied rewrites98.1%
Final simplification89.6%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* (* s c) x))) (/ (/ (cos (+ x x)) t_0) t_0)))
double code(double x, double c, double s) {
double t_0 = (s * c) * x;
return (cos((x + x)) / t_0) / t_0;
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
t_0 = (s * c) * x
code = (cos((x + x)) / t_0) / t_0
end function
public static double code(double x, double c, double s) {
double t_0 = (s * c) * x;
return (Math.cos((x + x)) / t_0) / t_0;
}
def code(x, c, s): t_0 = (s * c) * x return (math.cos((x + x)) / t_0) / t_0
function code(x, c, s) t_0 = Float64(Float64(s * c) * x) return Float64(Float64(cos(Float64(x + x)) / t_0) / t_0) end
function tmp = code(x, c, s) t_0 = (s * c) * x; tmp = (cos((x + x)) / t_0) / t_0; end
code[x_, c_, s_] := Block[{t$95$0 = N[(N[(s * c), $MachinePrecision] * x), $MachinePrecision]}, N[(N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(s \cdot c\right) \cdot x\\
\frac{\frac{\cos \left(x + x\right)}{t\_0}}{t\_0}
\end{array}
\end{array}
Initial program 70.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.9
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
associate-*l*N/A
pow2N/A
*-commutativeN/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f6499.2
Applied rewrites99.2%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6499.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.6
lift-*.f64N/A
*-commutativeN/A
lift-*.f6499.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.6
lift-*.f64N/A
*-commutativeN/A
lift-*.f6499.6
Applied rewrites99.6%
lift-*.f64N/A
count-2N/A
lower-+.f6499.6
Applied rewrites99.6%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* (* s c) x))) (/ (cos (* 2.0 x)) (* t_0 t_0))))
double code(double x, double c, double s) {
double t_0 = (s * c) * x;
return cos((2.0 * x)) / (t_0 * t_0);
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
t_0 = (s * c) * x
code = cos((2.0d0 * x)) / (t_0 * t_0)
end function
public static double code(double x, double c, double s) {
double t_0 = (s * c) * x;
return Math.cos((2.0 * x)) / (t_0 * t_0);
}
def code(x, c, s): t_0 = (s * c) * x return math.cos((2.0 * x)) / (t_0 * t_0)
function code(x, c, s) t_0 = Float64(Float64(s * c) * x) return Float64(cos(Float64(2.0 * x)) / Float64(t_0 * t_0)) end
function tmp = code(x, c, s) t_0 = (s * c) * x; tmp = cos((2.0 * x)) / (t_0 * t_0); end
code[x_, c_, s_] := Block[{t$95$0 = N[(N[(s * c), $MachinePrecision] * x), $MachinePrecision]}, N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(s \cdot c\right) \cdot x\\
\frac{\cos \left(2 \cdot x\right)}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 70.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.9
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
associate-*l*N/A
pow2N/A
*-commutativeN/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f6499.2
Applied rewrites99.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6499.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.2
lift-*.f64N/A
*-commutativeN/A
lift-*.f6499.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.2
lift-*.f64N/A
*-commutativeN/A
lift-*.f6499.2
Applied rewrites99.2%
Final simplification99.2%
(FPCore (x c s) :precision binary64 (if (<= x 6.4e-105) (/ 1.0 (* (* (* (* c c) s) x) (* s x))) (/ 1.0 (* (* (* s c) s) (* (* x x) c)))))
double code(double x, double c, double s) {
double tmp;
if (x <= 6.4e-105) {
tmp = 1.0 / ((((c * c) * s) * x) * (s * x));
} else {
tmp = 1.0 / (((s * c) * s) * ((x * x) * c));
}
return tmp;
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: tmp
if (x <= 6.4d-105) then
tmp = 1.0d0 / ((((c * c) * s) * x) * (s * x))
else
tmp = 1.0d0 / (((s * c) * s) * ((x * x) * c))
end if
code = tmp
end function
public static double code(double x, double c, double s) {
double tmp;
if (x <= 6.4e-105) {
tmp = 1.0 / ((((c * c) * s) * x) * (s * x));
} else {
tmp = 1.0 / (((s * c) * s) * ((x * x) * c));
}
return tmp;
}
def code(x, c, s): tmp = 0 if x <= 6.4e-105: tmp = 1.0 / ((((c * c) * s) * x) * (s * x)) else: tmp = 1.0 / (((s * c) * s) * ((x * x) * c)) return tmp
function code(x, c, s) tmp = 0.0 if (x <= 6.4e-105) tmp = Float64(1.0 / Float64(Float64(Float64(Float64(c * c) * s) * x) * Float64(s * x))); else tmp = Float64(1.0 / Float64(Float64(Float64(s * c) * s) * Float64(Float64(x * x) * c))); end return tmp end
function tmp_2 = code(x, c, s) tmp = 0.0; if (x <= 6.4e-105) tmp = 1.0 / ((((c * c) * s) * x) * (s * x)); else tmp = 1.0 / (((s * c) * s) * ((x * x) * c)); end tmp_2 = tmp; end
code[x_, c_, s_] := If[LessEqual[x, 6.4e-105], N[(1.0 / N[(N[(N[(N[(c * c), $MachinePrecision] * s), $MachinePrecision] * x), $MachinePrecision] * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(s * c), $MachinePrecision] * s), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.4 \cdot 10^{-105}:\\
\;\;\;\;\frac{1}{\left(\left(\left(c \cdot c\right) \cdot s\right) \cdot x\right) \cdot \left(s \cdot x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(s \cdot c\right) \cdot s\right) \cdot \left(\left(x \cdot x\right) \cdot c\right)}\\
\end{array}
\end{array}
if x < 6.39999999999999962e-105Initial program 71.9%
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
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6481.4
Applied rewrites81.4%
Taylor expanded in x around 0
Applied rewrites73.0%
Taylor expanded in x around 0
associate-*r*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6477.0
Applied rewrites77.0%
Applied rewrites73.4%
if 6.39999999999999962e-105 < x Initial program 68.8%
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
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6472.0
Applied rewrites72.0%
Taylor expanded in x around 0
Applied rewrites62.3%
Taylor expanded in x around 0
associate-*r*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6471.2
Applied rewrites71.2%
Final simplification72.7%
(FPCore (x c s) :precision binary64 (let* ((t_0 (* (* s c) x))) (/ 1.0 (* t_0 t_0))))
double code(double x, double c, double s) {
double t_0 = (s * c) * x;
return 1.0 / (t_0 * t_0);
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
real(8) :: t_0
t_0 = (s * c) * x
code = 1.0d0 / (t_0 * t_0)
end function
public static double code(double x, double c, double s) {
double t_0 = (s * c) * x;
return 1.0 / (t_0 * t_0);
}
def code(x, c, s): t_0 = (s * c) * x return 1.0 / (t_0 * t_0)
function code(x, c, s) t_0 = Float64(Float64(s * c) * x) return Float64(1.0 / Float64(t_0 * t_0)) end
function tmp = code(x, c, s) t_0 = (s * c) * x; tmp = 1.0 / (t_0 * t_0); end
code[x_, c_, s_] := Block[{t$95$0 = N[(N[(s * c), $MachinePrecision] * x), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(s \cdot c\right) \cdot x\\
\frac{1}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Initial program 70.9%
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
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6478.3
Applied rewrites78.3%
Taylor expanded in x around 0
Applied rewrites69.5%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
lower-*.f6484.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6484.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6484.0
Applied rewrites84.0%
Final simplification84.0%
(FPCore (x c s) :precision binary64 (/ 1.0 (* (* (* (* s c) x) (* s c)) x)))
double code(double x, double c, double s) {
return 1.0 / ((((s * c) * x) * (s * c)) * x);
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = 1.0d0 / ((((s * c) * x) * (s * c)) * x)
end function
public static double code(double x, double c, double s) {
return 1.0 / ((((s * c) * x) * (s * c)) * x);
}
def code(x, c, s): return 1.0 / ((((s * c) * x) * (s * c)) * x)
function code(x, c, s) return Float64(1.0 / Float64(Float64(Float64(Float64(s * c) * x) * Float64(s * c)) * x)) end
function tmp = code(x, c, s) tmp = 1.0 / ((((s * c) * x) * (s * c)) * x); end
code[x_, c_, s_] := N[(1.0 / N[(N[(N[(N[(s * c), $MachinePrecision] * x), $MachinePrecision] * N[(s * c), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\left(\left(\left(s \cdot c\right) \cdot x\right) \cdot \left(s \cdot c\right)\right) \cdot x}
\end{array}
Initial program 70.9%
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
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6478.3
Applied rewrites78.3%
Taylor expanded in x around 0
Applied rewrites69.5%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6482.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6482.5
Applied rewrites82.5%
Final simplification82.5%
(FPCore (x c s) :precision binary64 (/ 1.0 (* (* (* s c) s) (* (* x x) c))))
double code(double x, double c, double s) {
return 1.0 / (((s * c) * s) * ((x * x) * c));
}
real(8) function code(x, c, s)
real(8), intent (in) :: x
real(8), intent (in) :: c
real(8), intent (in) :: s
code = 1.0d0 / (((s * c) * s) * ((x * x) * c))
end function
public static double code(double x, double c, double s) {
return 1.0 / (((s * c) * s) * ((x * x) * c));
}
def code(x, c, s): return 1.0 / (((s * c) * s) * ((x * x) * c))
function code(x, c, s) return Float64(1.0 / Float64(Float64(Float64(s * c) * s) * Float64(Float64(x * x) * c))) end
function tmp = code(x, c, s) tmp = 1.0 / (((s * c) * s) * ((x * x) * c)); end
code[x_, c_, s_] := N[(1.0 / N[(N[(N[(s * c), $MachinePrecision] * s), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\left(\left(s \cdot c\right) \cdot s\right) \cdot \left(\left(x \cdot x\right) \cdot c\right)}
\end{array}
Initial program 70.9%
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
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6478.3
Applied rewrites78.3%
Taylor expanded in x around 0
Applied rewrites69.5%
Taylor expanded in x around 0
associate-*r*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6475.1
Applied rewrites75.1%
Final simplification75.1%
herbie shell --seed 2024272
(FPCore (x c s)
:name "mixedcos"
:precision binary64
(/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))