# How to integrate a function that has no exact integration and cannot be expanded by a Taylor series

Today I posted a question about the integral

$$\int\frac{(\cos{c x})^2}{a+bx}dx$$

for which a Taylor series can be built and the integral solved for the desired approximation.

Another term in the stiffness matrix has the integral:

$$\int\frac{x^2(\cos{c x})^2}{a+bx}dx$$

whose Taylor series cannot be used since it does not converge:

$$x^4 \left(\frac{b^2}{a^3}-\frac{c^2}{a}\right)-\frac{b x^3}{a^2}+x^6 \left(\frac{b^4}{a^5}-\frac{b^2 c^2}{a^3}+\frac{c^4}{3 a}\right)+x^5 \left(\frac{b c^2}{a^2}-\frac{b^3}{a^4}\right)+\frac{x^2}{a}+O[x]^7$$

In this case, which method could be used to calculate the integral?

• Riemann sums, or whatever other corresponding object if you're using an alternative definition of definite integration. – David H Sep 25 '13 at 13:23
• Your use of "stiffness matrix" suggests a numerical application, perhaps FEM. Typically a numerical quadrature scheme such as a trapezoid rule (or midpoint, or Gaussian quadrature) is used to get numerical evaluation of integrals. – hardmath Sep 25 '13 at 13:57
• "has no exact integration" does not make much sense. – leonbloy Sep 25 '13 at 15:30
• @leonbloy I meant "has no closed form solution"... – Saullo G. P. Castro Sep 25 '13 at 15:51

Maple finds a closed form for your antiderivative:

$$1/4\,{\frac {x\sin \left( 2\,cx \right) }{bc}}+1/8\,{\frac {\cos \left( 2\,cx \right) }{{c}^{2}b}}-1/4\,{\frac {a\sin \left( 2\,cx \right) }{c{b}^{2}}}+1/2\,{a}^{2}{\it Si} \left( 2\,cx+2\,{\frac {ac} {b}} \right) \sin \left( 2\,{\frac {ac}{b}} \right) {b}^{-3}\\+1/2\,{a}^ {2}{\it Ci} \left( 2\,cx+2\,{\frac {ac}{b}} \right) \cos \left( 2\,{ \frac {ac}{b}} \right) {b}^{-3}+1/4\,{\frac {{x}^{2}}{b}}-1/2\,{\frac {ax}{{b}^{2}}}+1/2\,{\frac {{a}^{2}\ln \left( bcx+ac \right) }{{b}^{3 }}}$$ where Si and Ci are the Sine-integral and Cosine-integral functions.

Assume $b\neq0$ for the key case.

Let $u=a+bx$ ,

Then $x=\dfrac{u-a}{b}$

$dx=\dfrac{du}{b}$

$\therefore\int\dfrac{\cos^2cx}{a+bx}dx$

$=\int\dfrac{1+\cos2cx}{2(a+bx)}dx$

$=\int\dfrac{1+\cos\dfrac{2c(u-a)}{b}}{2bu}du$

$=\int\dfrac{1}{2bu}du+\int\dfrac{1}{2bu}\cos\dfrac{2ac}{b}\cos\dfrac{2cu}{b}du+\int\dfrac{1}{2bu}\sin\dfrac{2ac}{b}\sin\dfrac{2cu}{b}du$

$=\int\dfrac{1}{2bu}du+\int\dfrac{1}{2bu}\cos\dfrac{2ac}{b}\sum\limits_{n=0}^\infty\dfrac{(-1)^n}{(2n)!}\left(\dfrac{2cu}{b}\right)^{2n}~du+\int\dfrac{1}{2bu}\sin\dfrac{2ac}{b}\sum\limits_{n=0}^\infty\dfrac{(-1)^n}{(2n+1)!}\left(\dfrac{2cu}{b}\right)^{2n+1}~du$

$=\int\dfrac{1}{2bu}du+\int\dfrac{1}{2bu}\cos\dfrac{2ac}{b}du+\int\sum\limits_{n=1}^\infty\dfrac{(-1)^n2^{2n-1}c^{2n}u^{2n-1}}{b^{2n+1}(2n)!}\cos\dfrac{2ac}{b}du+\int\sum\limits_{n=0}^\infty\dfrac{(-1)^n4^nc^{2n+1}u^{2n}}{b^{2n+2}(2n+1)!}\sin\dfrac{2ac}{b}du$

$=\dfrac{\ln u}{2b}+\dfrac{\ln u}{2b}\cos\dfrac{2ac}{b}+\sum\limits_{n=1}^\infty\dfrac{(-1)^n2^{2n-1}c^{2n}u^{2n}}{b^{2n+1}(2n)!(2n)}\cos\dfrac{2ac}{b}+\sum\limits_{n=0}^\infty\dfrac{(-1)^n4^nc^{2n+1}u^{2n+1}}{b^{2n+2}(2n+1)!(2n+1)}\sin\dfrac{2ac}{b}+C$

$=\dfrac{\ln(a+bx)}{2b}+\dfrac{\ln(a+bx)}{2b}\cos\dfrac{2ac}{b}+\sum\limits_{n=1}^\infty\dfrac{(-1)^n4^{n-1}c^{2n}(a+bx)^{2n}}{b^{2n+1}(2n)!n}\cos\dfrac{2ac}{b}+\sum\limits_{n=0}^\infty\dfrac{(-1)^n4^nc^{2n+1}(a+bx)^{2n+1}}{b^{2n+2}(2n+1)!(2n+1)}\sin\dfrac{2ac}{b}+C$

$\therefore\int\dfrac{x^2\cos^2cx}{a+bx}dx$

$=\int\dfrac{x^2(1+\cos2cx)}{2(a+bx)}dx$

$=\int\dfrac{\left(\dfrac{u-a}{b}\right)^2\left(1+\cos\dfrac{2c(u-a)}{b}\right)}{2bu}du$

$=\int\dfrac{u^2-2au+a^2}{2b^3u}du+\int\dfrac{u^2-2au+a^2}{2b^3u}\cos\dfrac{2ac}{b}\cos\dfrac{2cu}{b}du+\int\dfrac{u^2-2au+a^2}{2b^3u}\sin\dfrac{2ac}{b}\sin\dfrac{2cu}{b}du$

$=\int\left(\dfrac{u}{2b^3}-\dfrac{a}{b^3}+\dfrac{a^2}{2b^3u}\right)du+\int\left(\dfrac{u}{2b^3}-\dfrac{a}{b^3}+\dfrac{a^2}{2b^3u}\right)\cos\dfrac{2ac}{b}\sum\limits_{n=0}^\infty\dfrac{(-1)^n}{(2n)!}\left(\dfrac{2cu}{b}\right)^{2n}~du+\int\left(\dfrac{u}{2b^3}-\dfrac{a}{b^3}+\dfrac{a^2}{2b^3u}\right)\sin\dfrac{2ac}{b}\sum\limits_{n=0}^\infty\dfrac{(-1)^n}{(2n+1)!}\left(\dfrac{2cu}{b}\right)^{2n+1}~du$

$=\int\left(\dfrac{u}{2b^3}-\dfrac{a}{b^3}+\dfrac{a^2}{2b^3u}\right)\left(1+\cos\dfrac{2ac}{b}\right)du+\int\left(\sum\limits_{n=1}^\infty\dfrac{(-1)^n2^{2n-1}c^{2n}u^{2n+1}}{b^{2n+3}(2n)!}-\sum\limits_{n=1}^\infty\dfrac{(-1)^n4^nac^{2n}u^{2n}}{b^{2n+3}(2n)!}+\sum\limits_{n=1}^\infty\dfrac{(-1)^n2^{2n-1}a^2c^{2n}u^{2n-1}}{b^{2n+3}(2n)!}\right)\cos\dfrac{2ac}{b}du+\int\left(\sum\limits_{n=0}^\infty\dfrac{(-1)^n4^nc^{2n+1}u^{2n+2}}{b^{2n+4}(2n+1)!}-\sum\limits_{n=0}^\infty\dfrac{(-1)^n2^{2n+1}ac^{2n+1}u^{2n+1}}{b^{2n+4}(2n+1)!}+\sum\limits_{n=0}^\infty\dfrac{(-1)^n4^na^2c^{2n+1}u^{2n}}{b^{2n+4}(2n+1)!}\right)\sin\dfrac{2ac}{b}du$

$=\left(\dfrac{u^2}{4b^3}-\dfrac{au}{b^3}+\dfrac{a^2\ln u}{2b^3}\right)\left(1+\cos\dfrac{2ac}{b}\right)+\left(\sum\limits_{n=1}^\infty\dfrac{(-1)^n2^{2n-1}c^{2n}u^{2n+2}}{b^{2n+3}(2n)!(2n+2)}-\sum\limits_{n=1}^\infty\dfrac{(-1)^n4^nac^{2n}u^{2n+1}}{b^{2n+3}(2n+1)!}+\sum\limits_{n=1}^\infty\dfrac{(-1)^n2^{2n-1}a^2c^{2n}u^{2n}}{b^{2n+3}(2n)!(2n)}\right)\cos\dfrac{2ac}{b}+\left(\sum\limits_{n=0}^\infty\dfrac{(-1)^n4^nc^{2n+1}u^{2n+3}}{b^{2n+4}(2n+1)!(2n+3)}-\sum\limits_{n=0}^\infty\dfrac{(-1)^n2^{2n+1}ac^{2n+1}u^{2n+2}}{b^{2n+4}(2n+2)!}+\sum\limits_{n=0}^\infty\dfrac{(-1)^n4^na^2c^{2n+1}u^{2n+1}}{b^{2n+4}(2n+1)!(2n+1)}\right)\sin\dfrac{2ac}{b}+C$

$=\left(\dfrac{(a+bx)^2}{4b^3}-\dfrac{a(a+bx)}{b^3}+\dfrac{a^2\ln(a+bx)}{2b^3}\right)\left(1+\cos\dfrac{2ac}{b}\right)+\left(\sum\limits_{n=1}^\infty\dfrac{(-1)^n4^{n-1}c^{2n}(a+bx)^{2n+2}}{b^{2n+3}(2n)!(n+1)}-\sum\limits_{n=1}^\infty\dfrac{(-1)^n4^nac^{2n}(a+bx)^{2n+1}}{b^{2n+3}(2n+1)!}+\sum\limits_{n=1}^\infty\dfrac{(-1)^n2^{2n-1}a^2c^{2n}(a+bx)^{2n}}{b^{2n+3}(2n)!(2n)}\right)\cos\dfrac{2ac}{b}+\left(\sum\limits_{n=0}^\infty\dfrac{(-1)^n4^nc^{2n+1}(a+bx)^{2n+3}}{b^{2n+4}(2n+1)!(2n+3)}-\sum\limits_{n=0}^\infty\dfrac{(-1)^n2^{2n+1}ac^{2n+1}(a+bx)^{2n+2}}{b^{2n+4}(2n+2)!}+\sum\limits_{n=0}^\infty\dfrac{(-1)^n4^na^2c^{2n+1}(a+bx)^{2n+1}}{b^{2n+4}(2n+1)!(2n+1)}\right)\sin\dfrac{2ac}{b}+C$