MAT 142 Day 24

1345 days ago by kcrisman

First, here is the syntax for indefinite integration:

integrate( x^2 * cos(x)^2, x) 
       
1/6*x^3 + 1/8*(2*x^2 - 1)*sin(2*x) + 1/4*x*cos(2*x)
1/6*x^3 + 1/8*(2*x^2 - 1)*sin(2*x) + 1/4*x*cos(2*x)

Just put in the function, and do comma x.

Here's the plot that confirms our two integrations of $\cos^4(x)$ were exactly the same:

P = plot(sin(x)*cos(x)^3/4+.1,(x,0,2*pi),color='red') P += plot(1/8*sin(x)*cos(x)+1/32*sin(4*x),(x,0,2*pi)) show(P) 
       

This worksheet just does a heck of a lot of examples of (mostly) indefinite integrals to see how Sage deals with things as in Chapter 6.5.  

integrate(cos(x)*(sin(x))^4,x) 
       
\frac{{\sin \left( x \right)}^{5} }{5}
\frac{{\sin \left( x \right)}^{5} }{5}
integrate((cos(x))^3*sin(x),x,-pi/2,0) 
       
-\frac{1}{4}
-\frac{1}{4}
integrate((sin(x))^4,x) 
       
\frac{\frac{\frac{\sin \left( {4 x} \right)}{2} + {2 x}}{8} - \frac{\sin \left( {2 x} \right)}{2} + \frac{x}{2}}{2}
\frac{\frac{\frac{\sin \left( {4 x} \right)}{2} + {2 x}}{8} - \frac{\sin \left( {2 x} \right)}{2} + \frac{x}{2}}{2}
_.simplify_full() 
       
\frac{{\left( {2 {\cos \left( x \right)}^{3} } - {5 \cos \left( x \right)} \right) \sin \left( x \right)} + {3 x}}{8}
\frac{{\left( {2 {\cos \left( x \right)}^{3} } - {5 \cos \left( x \right)} \right) \sin \left( x \right)} + {3 x}}{8}
integrate(1/(x^2*sqrt(9-x^2)),x) 
       
\frac{-\left( \sqrt{ 9 - {x}^{2}  } \right)}{{9 x}}
\frac{-\left( \sqrt{ 9 - {x}^{2}  } \right)}{{9 x}}
integrate(sqrt(4-x^2),x,0,2) 
       
\pi
\pi
integrate((x-5)/(x^2-1),x) 
       
{3 \log \left( x + 1 \right)} - {2 \log \left( x - 1 \right)}
{3 \log \left( x + 1 \right)} - {2 \log \left( x - 1 \right)}
integrate((x^2+1)/(x^2-5*x-6),x) 
       
\frac{{-2 \log \left( x + 1 \right)}}{7} + \frac{{37 \log \left( x - 6 \right)}}{7} + x
\frac{{-2 \log \left( x + 1 \right)}}{7} + \frac{{37 \log \left( x - 6 \right)}}{7} + x
integrate(3/(x^4+x),x) 
       
{3 \left( \frac{-\left( \log \left( {x}^{2}  - x + 1 \right) \right)}{3} - \frac{\log \left( x + 1 \right)}{3} + \log \left( x \right) \right)}
{3 \left( \frac{-\left( \log \left( {x}^{2}  - x + 1 \right) \right)}{3} - \frac{\log \left( x + 1 \right)}{3} + \log \left( x \right) \right)}
integrate((cos(x))^2*sin(x)*sqrt(2+3*cos(x)),x) 
       
\frac{{-2 {\left( {3 \cos \left( x \right)} + 2 \right)}^{\frac{7}{2}} }}{189} + \frac{{8 {\left( {3 \cos \left( x \right)} + 2 \right)}^{\frac{5}{2}} }}{135} - \frac{{8 {\left( {3 \cos \left( x \right)} + 2 \right)}^{\frac{3}{2}} }}{81}
\frac{{-2 {\left( {3 \cos \left( x \right)} + 2 \right)}^{\frac{7}{2}} }}{189} + \frac{{8 {\left( {3 \cos \left( x \right)} + 2 \right)}^{\frac{5}{2}} }}{135} - \frac{{8 {\left( {3 \cos \left( x \right)} + 2 \right)}^{\frac{3}{2}} }}{81}
integrate(x^5*sqrt(2+3*x^2)) 
       
\frac{{{x}^{4}  {\left( {3 {x}^{2} } + 2 \right)}^{\frac{3}{2}} }}{21} - \frac{{{8 {x}^{2} } {\left( {3 {x}^{2} } + 2 \right)}^{\frac{3}{2}} }}{315} + \frac{{32 {\left( {3 {x}^{2} } + 2 \right)}^{\frac{3}{2}} }}{2835}
\frac{{{x}^{4}  {\left( {3 {x}^{2} } + 2 \right)}^{\frac{3}{2}} }}{21} - \frac{{{8 {x}^{2} } {\left( {3 {x}^{2} } + 2 \right)}^{\frac{3}{2}} }}{315} + \frac{{32 {\left( {3 {x}^{2} } + 2 \right)}^{\frac{3}{2}} }}{2835}
integrate(e^(-3*x)*sqrt(2+3*e^-x)) 
       
\frac{{-2 {\left( {3 {e}^{-x} } + 2 \right)}^{\frac{7}{2}} }}{189} + \frac{{8 {\left( {3 {e}^{-x} } + 2 \right)}^{\frac{5}{2}} }}{135} - \frac{{8 {\left( {3 {e}^{-x} } + 2 \right)}^{\frac{3}{2}} }}{81}
\frac{{-2 {\left( {3 {e}^{-x} } + 2 \right)}^{\frac{7}{2}} }}{189} + \frac{{8 {\left( {3 {e}^{-x} } + 2 \right)}^{\frac{5}{2}} }}{135} - \frac{{8 {\left( {3 {e}^{-x} } + 2 \right)}^{\frac{3}{2}} }}{81}
integrate((sin(x))^6,x) 
       
\frac{\frac{{3 \left( \frac{\sin \left( {4 x} \right)}{2} + {2 x} \right)}}{16} - \frac{\sin \left( {2 x} \right) - \frac{{\left( \sin \left( {2 x} \right) \right)}^{3} }{3}}{8} - \frac{{3 \sin \left( {2 x} \right)}}{8} + \frac{x}{4}}{2}
\frac{\frac{{3 \left( \frac{\sin \left( {4 x} \right)}{2} + {2 x} \right)}}{16} - \frac{\sin \left( {2 x} \right) - \frac{{\left( \sin \left( {2 x} \right) \right)}^{3} }{3}}{8} - \frac{{3 \sin \left( {2 x} \right)}}{8} + \frac{x}{4}}{2}
f(x)=-(1/6)*(sin(x))^5*cos(x)-(5/24)*(sin(x))^3*cos(x)-(5/16)*sin(x)*cos(x)+(5/16)*x f 
       
x \ {\mapsto}\ \frac{{-\cos \left( x \right) {\sin \left( x \right)}^{5} }}{6} - \frac{{{5 \cos \left( x \right)} {\sin \left( x \right)}^{3} }}{24} - \frac{{{5 \cos \left( x \right)} \sin \left( x \right)}}{16} + \frac{{5 x}}{16}
x \ {\mapsto}\ \frac{{-\cos \left( x \right) {\sin \left( x \right)}^{5} }}{6} - \frac{{{5 \cos \left( x \right)} {\sin \left( x \right)}^{3} }}{24} - \frac{{{5 \cos \left( x \right)} \sin \left( x \right)}}{16} + \frac{{5 x}}{16}
(f(x)-integrate(sin(x)^6)).simplify_trig() 
       
0
0
integrate(sin(2*x)/sqrt(4*cos(x)-1)) 
       
{2 \left( \frac{-\left( {\left( {4 \cos \left( x \right)} - 1 \right)}^{\frac{3}{2}}  \right)}{24} - \frac{\sqrt{ {4 \cos \left( x \right)} - 1 }}{8} \right)}
{2 \left( \frac{-\left( {\left( {4 \cos \left( x \right)} - 1 \right)}^{\frac{3}{2}}  \right)}{24} - \frac{\sqrt{ {4 \cos \left( x \right)} - 1 }}{8} \right)}
integrate(sin(2*x)/sqrt(4*cos(x)-1)).simplify_full() 
       
\frac{{-\left( {2 \cos \left( x \right)} + 1 \right) \sqrt{ {4 \cos \left( x \right)} - 1 }}}{6}
\frac{{-\left( {2 \cos \left( x \right)} + 1 \right) \sqrt{ {4 \cos \left( x \right)} - 1 }}}{6}
integrate(1/x) 
       
\log \left( x \right)
\log \left( x \right)
integrate(cos(x)/(sin(x)-2)) 
       
\log \left( \sin \left( x \right) - 2 \right)
\log \left( \sin \left( x \right) - 2 \right)
integrate(4x) 
       
Syntax Error:
    integrate(4x)
Syntax Error:
    integrate(4x)
integrate(4*x 8*x) 
       
line 4
    integrate(_sage_const_4 *x _sage_const_8 *x)
                                           ^
SyntaxError: invalid syntax
line 4
    integrate(_sage_const_4 *x _sage_const_8 *x)
                                           ^
SyntaxError: invalid syntax
integrate(4*x*8*x) 
       
\frac{{32 {x}^{3} }}{3}
\frac{{32 {x}^{3} }}{3}
integrate(x*(x^2+3)^5) 
       
\frac{{\left( {x}^{2}  + 3 \right)}^{6} }{12}
\frac{{\left( {x}^{2}  + 3 \right)}^{6} }{12}
integrate(1/sqrt(9+x^2)) 
       
\sinh^{-1} \left( \frac{x}{3} \right)
\sinh^{-1} \left( \frac{x}{3} \right)
integrate(x^10*sin(2*x)) 
       
\frac{{\left( {5120 {x}^{9} } - {92160 {x}^{7} } + {967680 {x}^{5} } - {4838400 {x}^{3} } + {7257600 x} \right) \sin \left( {2 x} \right)} + {\left( {-1024 {x}^{10} } + {23040 {x}^{8} } - {322560 {x}^{6} } + {2419200 {x}^{4} } - {7257600 {x}^{2} } + 3628800 \right) \cos \left( {2 x} \right)}}{2048}
\frac{{\left( {5120 {x}^{9} } - {92160 {x}^{7} } + {967680 {x}^{5} } - {4838400 {x}^{3} } + {7257600 x} \right) \sin \left( {2 x} \right)} + {\left( {-1024 {x}^{10} } + {23040 {x}^{8} } - {322560 {x}^{6} } + {2419200 {x}^{4} } - {7257600 {x}^{2} } + 3628800 \right) \cos \left( {2 x} \right)}}{2048}

The following is related to some exploratory exercises. What is $\int \frac{1}{1+x^n}dx$ for different $n$? Is there a formula?

integrate(1/(1+x)) 
       
\log \left( x + 1 \right)
\log \left( x + 1 \right)
integrate(1/(1+x^2)).simplify_full() 
       
\tan^{-1} \left( x \right)
\tan^{-1} \left( x \right)
integrate(1/(1+x^3)).simplify_full() 
       
\frac{-\left( {\sqrt{ 3 } \log \left( {x}^{2}  - x + 1 \right)} - {6 \tan^{-1} \left( \frac{{2 x} - 1}{\sqrt{ 3 }} \right)} - {{2 \sqrt{ 3 }} \log \left( x + 1 \right)} \right)}{{6 \sqrt{ 3 }}}
\frac{-\left( {\sqrt{ 3 } \log \left( {x}^{2}  - x + 1 \right)} - {6 \tan^{-1} \left( \frac{{2 x} - 1}{\sqrt{ 3 }} \right)} - {{2 \sqrt{ 3 }} \log \left( x + 1 \right)} \right)}{{6 \sqrt{ 3 }}}
integrate(1/(1+x^4)).simplify_full() 
       
\frac{{\sqrt{ 2 } \log \left( {x}^{2}  + {\sqrt{ 2 } x} + 1 \right)} - {\sqrt{ 2 } \log \left( {x}^{2}  - {\sqrt{ 2 } x} + 1 \right)} + {{2 \sqrt{ 2 }} \tan^{-1} \left( \frac{{2 x} + \sqrt{ 2 }}{\sqrt{ 2 }} \right)} + {{2 \sqrt{ 2 }} \tan^{-1} \left( \frac{{2 x} - \sqrt{ 2 }}{\sqrt{ 2 }} \right)}}{8}
\frac{{\sqrt{ 2 } \log \left( {x}^{2}  + {\sqrt{ 2 } x} + 1 \right)} - {\sqrt{ 2 } \log \left( {x}^{2}  - {\sqrt{ 2 } x} + 1 \right)} + {{2 \sqrt{ 2 }} \tan^{-1} \left( \frac{{2 x} + \sqrt{ 2 }}{\sqrt{ 2 }} \right)} + {{2 \sqrt{ 2 }} \tan^{-1} \left( \frac{{2 x} - \sqrt{ 2 }}{\sqrt{ 2 }} \right)}}{8}
integrate(1/(1+x^5)).simplify_full() 
       
\frac{{\sqrt{ \sqrt{ 5 } + 5 } \left( {\sqrt{ \sqrt{ 5 } - 5 } \left( {\left( {\sqrt{ 2 } \sqrt{ 5 }} - \sqrt{ 2 } \right) \log \left( {2 {x}^{2} } + {\left( \sqrt{ 5 } - 1 \right) x} + 2 \right)} + {\left( {-\sqrt{ 2 } \sqrt{ 5 }} - \sqrt{ 2 } \right) \log \left( {2 {x}^{2} } + {\left( -\sqrt{ 5 } - 1 \right) x} + 2 \right)} + {{4 \sqrt{ 2 }} \log \left( x + 1 \right)} \right)} + {\left( {4 \sqrt{ 5 }} - 20 \right) \tanh^{-1} \left( \frac{{4 x} - \sqrt{ 5 } - 1}{{\sqrt{ 2 } \sqrt{ \sqrt{ 5 } - 5 }}} \right)} \right)} + {{\sqrt{ \sqrt{ 5 } - 5 } \left( {4 \sqrt{ 5 }} + 20 \right)} \tan^{-1} \left( \frac{{4 x} + \sqrt{ 5 } - 1}{{\sqrt{ 2 } \sqrt{ \sqrt{ 5 } + 5 }}} \right)}}{{{{20 \sqrt{ 2 }} \sqrt{ \sqrt{ 5 } - 5 }} \sqrt{ \sqrt{ 5 } + 5 }}}
\frac{{\sqrt{ \sqrt{ 5 } + 5 } \left( {\sqrt{ \sqrt{ 5 } - 5 } \left( {\left( {\sqrt{ 2 } \sqrt{ 5 }} - \sqrt{ 2 } \right) \log \left( {2 {x}^{2} } + {\left( \sqrt{ 5 } - 1 \right) x} + 2 \right)} + {\left( {-\sqrt{ 2 } \sqrt{ 5 }} - \sqrt{ 2 } \right) \log \left( {2 {x}^{2} } + {\left( -\sqrt{ 5 } - 1 \right) x} + 2 \right)} + {{4 \sqrt{ 2 }} \log \left( x + 1 \right)} \right)} + {\left( {4 \sqrt{ 5 }} - 20 \right) \tanh^{-1} \left( \frac{{4 x} - \sqrt{ 5 } - 1}{{\sqrt{ 2 } \sqrt{ \sqrt{ 5 } - 5 }}} \right)} \right)} + {{\sqrt{ \sqrt{ 5 } - 5 } \left( {4 \sqrt{ 5 }} + 20 \right)} \tan^{-1} \left( \frac{{4 x} + \sqrt{ 5 } - 1}{{\sqrt{ 2 } \sqrt{ \sqrt{ 5 } + 5 }}} \right)}}{{{{20 \sqrt{ 2 }} \sqrt{ \sqrt{ 5 } - 5 }} \sqrt{ \sqrt{ 5 } + 5 }}}
integrate(1/(1+x^6)).simplify_full() 
       
\frac{{\sqrt{ 3 } \log \left( {x}^{2}  + {\sqrt{ 3 } x} + 1 \right)} - {\sqrt{ 3 } \log \left( {x}^{2}  - {\sqrt{ 3 } x} + 1 \right)} + {2 \tan^{-1} \left( {2 x} + \sqrt{ 3 } \right)} + {2 \tan^{-1} \left( {2 x} - \sqrt{ 3 } \right)} + {4 \tan^{-1} \left( x \right)}}{12}
\frac{{\sqrt{ 3 } \log \left( {x}^{2}  + {\sqrt{ 3 } x} + 1 \right)} - {\sqrt{ 3 } \log \left( {x}^{2}  - {\sqrt{ 3 } x} + 1 \right)} + {2 \tan^{-1} \left( {2 x} + \sqrt{ 3 } \right)} + {2 \tan^{-1} \left( {2 x} - \sqrt{ 3 } \right)} + {4 \tan^{-1} \left( x \right)}}{12}
integrate(1/(1+x^7)).simplify_full() 
       
\frac{-\left( \int {{{x^5-2\,x^4+3\,x^3-4\,x^2+5\,x-6}\over{x^6-x^5+x^4-x^3+x^2-x  +1}}}{\;dx} - \log \left( x + 1 \right) \right)}{7}
\frac{-\left( \int {{{x^5-2\,x^4+3\,x^3-4\,x^2+5\,x-6}\over{x^6-x^5+x^4-x^3+x^2-x  +1}}}{\;dx} - \log \left( x + 1 \right) \right)}{7}
integrate(1/(1+x^8)).simplify_full() 
       
\int {{{1}\over{x^8+1}}}{\;dx}
\int {{{1}\over{x^8+1}}}{\;dx}
mypoly(x)=(x^2-2*cos(pi/8)*x+1)*(x^2-2*cos(3*pi/8)*x+1)*(x^2-2*cos(5*pi/8)*x+1)*(x^2-2*cos(7*pi/8)*x+1) 
       
mypoly;expand(mypoly).simplify_full() 
       
x \ {\mapsto}\ {{{\left( {x}^{2}  - {{2 \cos \left( \frac{\pi}{8} \right)} x} + 1 \right) \left( {x}^{2}  - {{2 \cos \left( \frac{{3 \pi}}{8} \right)} x} + 1 \right)} \left( {x}^{2}  - {{2 \cos \left( \frac{{5 \pi}}{8} \right)} x} + 1 \right)} \left( {x}^{2}  - {{2 \cos \left( \frac{{7 \pi}}{8} \right)} x} + 1 \right)}
x \ {\mapsto}\ {x}^{8}  + {\left( {-2 \cos \left( \frac{{7 \pi}}{8} \right)} - {2 \cos \left( \frac{{5 \pi}}{8} \right)} - {2 \cos \left( \frac{{3 \pi}}{8} \right)} - {2 \cos \left( \frac{\pi}{8} \right)} \right) {x}^{7} } + {\left( {\left( {4 \cos \left( \frac{{5 \pi}}{8} \right)} + {4 \cos \left( \frac{{3 \pi}}{8} \right)} + {4 \cos \left( \frac{\pi}{8} \right)} \right) \cos \left( \frac{{7 \pi}}{8} \right)} + {\left( {4 \cos \left( \frac{{3 \pi}}{8} \right)} + {4 \cos \left( \frac{\pi}{8} \right)} \right) \cos \left( \frac{{5 \pi}}{8} \right)} + {{4 \cos \left( \frac{\pi}{8} \right)} \cos \left( \frac{{3 \pi}}{8} \right)} + 4 \right) {x}^{6} } + {\left( {\left( {\left( {-8 \cos \left( \frac{{3 \pi}}{8} \right)} - {8 \cos \left( \frac{\pi}{8} \right)} \right) \cos \left( \frac{{5 \pi}}{8} \right)} - {{8 \cos \left( \frac{\pi}{8} \right)} \cos \left( \frac{{3 \pi}}{8} \right)} - 6 \right) \cos \left( \frac{{7 \pi}}{8} \right)} + {\left( {{-8 \cos \left( \frac{\pi}{8} \right)} \cos \left( \frac{{3 \pi}}{8} \right)} - 6 \right) \cos \left( \frac{{5 \pi}}{8} \right)} - {6 \cos \left( \frac{{3 \pi}}{8} \right)} - {6 \cos \left( \frac{\pi}{8} \right)} \right) {x}^{5} } + {\left( {\left( {\left( {{16 \cos \left( \frac{\pi}{8} \right)} \cos \left( \frac{{3 \pi}}{8} \right)} + 8 \right) \cos \left( \frac{{5 \pi}}{8} \right)} + {8 \cos \left( \frac{{3 \pi}}{8} \right)} + {8 \cos \left( \frac{\pi}{8} \right)} \right) \cos \left( \frac{{7 \pi}}{8} \right)} + {\left( {8 \cos \left( \frac{{3 \pi}}{8} \right)} + {8 \cos \left( \frac{\pi}{8} \right)} \right) \cos \left( \frac{{5 \pi}}{8} \right)} + {{8 \cos \left( \frac{\pi}{8} \right)} \cos \left( \frac{{3 \pi}}{8} \right)} + 6 \right) {x}^{4} } + {\left( {\left( {\left( {-8 \cos \left( \frac{{3 \pi}}{8} \right)} - {8 \cos \left( \frac{\pi}{8} \right)} \right) \cos \left( \frac{{5 \pi}}{8} \right)} - {{8 \cos \left( \frac{\pi}{8} \right)} \cos \left( \frac{{3 \pi}}{8} \right)} - 6 \right) \cos \left( \frac{{7 \pi}}{8} \right)} + {\left( {{-8 \cos \left( \frac{\pi}{8} \right)} \cos \left( \frac{{3 \pi}}{8} \right)} - 6 \right) \cos \left( \frac{{5 \pi}}{8} \right)} - {6 \cos \left( \frac{{3 \pi}}{8} \right)} - {6 \cos \left( \frac{\pi}{8} \right)} \right) {x}^{3} } + {\left( {\left( {4 \cos \left( \frac{{5 \pi}}{8} \right)} + {4 \cos \left( \frac{{3 \pi}}{8} \right)} + {4 \cos \left( \frac{\pi}{8} \right)} \right) \cos \left( \frac{{7 \pi}}{8} \right)} + {\left( {4 \cos \left( \frac{{3 \pi}}{8} \right)} + {4 \cos \left( \frac{\pi}{8} \right)} \right) \cos \left( \frac{{5 \pi}}{8} \right)} + {{4 \cos \left( \frac{\pi}{8} \right)} \cos \left( \frac{{3 \pi}}{8} \right)} + 4 \right) {x}^{2} } + {\left( {-2 \cos \left( \frac{{7 \pi}}{8} \right)} - {2 \cos \left( \frac{{5 \pi}}{8} \right)} - {2 \cos \left( \frac{{3 \pi}}{8} \right)} - {2 \cos \left( \frac{\pi}{8} \right)} \right) x} + 1
x \ {\mapsto}\ {{{\left( {x}^{2}  - {{2 \cos \left( \frac{\pi}{8} \right)} x} + 1 \right) \left( {x}^{2}  - {{2 \cos \left( \frac{{3 \pi}}{8} \right)} x} + 1 \right)} \left( {x}^{2}  - {{2 \cos \left( \frac{{5 \pi}}{8} \right)} x} + 1 \right)} \left( {x}^{2}  - {{2 \cos \left( \frac{{7 \pi}}{8} \right)} x} + 1 \right)}
x \ {\mapsto}\ {x}^{8}  + {\left( {-2 \cos \left( \frac{{7 \pi}}{8} \right)} - {2 \cos \left( \frac{{5 \pi}}{8} \right)} - {2 \cos \left( \frac{{3 \pi}}{8} \right)} - {2 \cos \left( \frac{\pi}{8} \right)} \right) {x}^{7} } + {\left( {\left( {4 \cos \left( \frac{{5 \pi}}{8} \right)} + {4 \cos \left( \frac{{3 \pi}}{8} \right)} + {4 \cos \left( \frac{\pi}{8} \right)} \right) \cos \left( \frac{{7 \pi}}{8} \right)} + {\left( {4 \cos \left( \frac{{3 \pi}}{8} \right)} + {4 \cos \left( \frac{\pi}{8} \right)} \right) \cos \left( \frac{{5 \pi}}{8} \right)} + {{4 \cos \left( \frac{\pi}{8} \right)} \cos \left( \frac{{3 \pi}}{8} \right)} + 4 \right) {x}^{6} } + {\left( {\left( {\left( {-8 \cos \left( \frac{{3 \pi}}{8} \right)} - {8 \cos \left( \frac{\pi}{8} \right)} \right) \cos \left( \frac{{5 \pi}}{8} \right)} - {{8 \cos \left( \frac{\pi}{8} \right)} \cos \left( \frac{{3 \pi}}{8} \right)} - 6 \right) \cos \left( \frac{{7 \pi}}{8} \right)} + {\left( {{-8 \cos \left( \frac{\pi}{8} \right)} \cos \left( \frac{{3 \pi}}{8} \right)} - 6 \right) \cos \left( \frac{{5 \pi}}{8} \right)} - {6 \cos \left( \frac{{3 \pi}}{8} \right)} - {6 \cos \left( \frac{\pi}{8} \right)} \right) {x}^{5} } + {\left( {\left( {\left( {{16 \cos \left( \frac{\pi}{8} \right)} \cos \left( \frac{{3 \pi}}{8} \right)} + 8 \right) \cos \left( \frac{{5 \pi}}{8} \right)} + {8 \cos \left( \frac{{3 \pi}}{8} \right)} + {8 \cos \left( \frac{\pi}{8} \right)} \right) \cos \left( \frac{{7 \pi}}{8} \right)} + {\left( {8 \cos \left( \frac{{3 \pi}}{8} \right)} + {8 \cos \left( \frac{\pi}{8} \right)} \right) \cos \left( \frac{{5 \pi}}{8} \right)} + {{8 \cos \left( \frac{\pi}{8} \right)} \cos \left( \frac{{3 \pi}}{8} \right)} + 6 \right) {x}^{4} } + {\left( {\left( {\left( {-8 \cos \left( \frac{{3 \pi}}{8} \right)} - {8 \cos \left( \frac{\pi}{8} \right)} \right) \cos \left( \frac{{5 \pi}}{8} \right)} - {{8 \cos \left( \frac{\pi}{8} \right)} \cos \left( \frac{{3 \pi}}{8} \right)} - 6 \right) \cos \left( \frac{{7 \pi}}{8} \right)} + {\left( {{-8 \cos \left( \frac{\pi}{8} \right)} \cos \left( \frac{{3 \pi}}{8} \right)} - 6 \right) \cos \left( \frac{{5 \pi}}{8} \right)} - {6 \cos \left( \frac{{3 \pi}}{8} \right)} - {6 \cos \left( \frac{\pi}{8} \right)} \right) {x}^{3} } + {\left( {\left( {4 \cos \left( \frac{{5 \pi}}{8} \right)} + {4 \cos \left( \frac{{3 \pi}}{8} \right)} + {4 \cos \left( \frac{\pi}{8} \right)} \right) \cos \left( \frac{{7 \pi}}{8} \right)} + {\left( {4 \cos \left( \frac{{3 \pi}}{8} \right)} + {4 \cos \left( \frac{\pi}{8} \right)} \right) \cos \left( \frac{{5 \pi}}{8} \right)} + {{4 \cos \left( \frac{\pi}{8} \right)} \cos \left( \frac{{3 \pi}}{8} \right)} + 4 \right) {x}^{2} } + {\left( {-2 \cos \left( \frac{{7 \pi}}{8} \right)} - {2 \cos \left( \frac{{5 \pi}}{8} \right)} - {2 \cos \left( \frac{{3 \pi}}{8} \right)} - {2 \cos \left( \frac{\pi}{8} \right)} \right) x} + 1
expand((x^2-2*sqrt((1+cos(pi/4))/2)*x+1)*(x^2-2*sqrt((1+cos(3*pi/4))/2)*x+1)*(x^2-2*(-sqrt((1+cos(5*pi/4))/2))*x+1)*(x^2-2*(-sqrt((1+cos(7*pi/4))/2))*x+1));(x^2-2*sqrt((1+cos(pi/4))/2)*x+1)*(x^2-2*sqrt((1+cos(3*pi/4))/2)*x+1)*(x^2-2*(-sqrt((1+cos(5*pi/4))/2))*x+1)*(x^2-2*(-sqrt((1+cos(7*pi/4))/2))*x+1) 
       
{x}^{8}  + 1
{{{\left( {x}^{2}  - \frac{{{2 \sqrt{ 1 - \frac{1}{\sqrt{ 2 }} }} x}}{\sqrt{ 2 }} + 1 \right) \left( {x}^{2}  + \frac{{{2 \sqrt{ 1 - \frac{1}{\sqrt{ 2 }} }} x}}{\sqrt{ 2 }} + 1 \right)} \left( {x}^{2}  - \frac{{{2 \sqrt{ \frac{1}{\sqrt{ 2 }} + 1 }} x}}{\sqrt{ 2 }} + 1 \right)} \left( {x}^{2}  + \frac{{{2 \sqrt{ \frac{1}{\sqrt{ 2 }} + 1 }} x}}{\sqrt{ 2 }} + 1 \right)}
{x}^{8}  + 1
{{{\left( {x}^{2}  - \frac{{{2 \sqrt{ 1 - \frac{1}{\sqrt{ 2 }} }} x}}{\sqrt{ 2 }} + 1 \right) \left( {x}^{2}  + \frac{{{2 \sqrt{ 1 - \frac{1}{\sqrt{ 2 }} }} x}}{\sqrt{ 2 }} + 1 \right)} \left( {x}^{2}  - \frac{{{2 \sqrt{ \frac{1}{\sqrt{ 2 }} + 1 }} x}}{\sqrt{ 2 }} + 1 \right)} \left( {x}^{2}  + \frac{{{2 \sqrt{ \frac{1}{\sqrt{ 2 }} + 1 }} x}}{\sqrt{ 2 }} + 1 \right)}