Online Math Tutor LLC

Discover the Path to Mathematical Mastery 
An Education That Counts

Online Math Tutor LLC

Search
Close this search box.

Although partial fraction decomposition (or simply partial fractions) is an algebraic, not an integration technique, it is useful for integrating rational functions. When decomposing the ration function, remember to echo any repeated factors. A rational functions has the form \(\textstyle f(x)=\frac{P(x)}{Q(x)}\) where \(P(x)\) and \(Q(x)\) are both polynomials

Virtual Lessons

Need some additional help understanding how to apply this integration technique? Click Here to visit the virtual lesson section.

Practice Problems

Evaluate the following questions by using technique of partial Partial Fraction Decomposition. 

  1. \(\displaystyle f(x) = \frac{2}{x^2+6x+8} \)
  2. \(\displaystyle f(x) = \frac{1}{x(x+1)(x+2)^2} \)
  3. \(\displaystyle \int \frac{dx}{x^2-4} \)
  4. \(\displaystyle \int \frac{x+1}{2x^2+7x+3} dx \)
  5. \(\displaystyle \int \frac{3x+1}{x^2+5x+6} dx \)
  1. \(\displaystyle \int \frac{1-2x}{x^3+4x^2+4x} dx \)
  2. \(\displaystyle \int \frac{x-1}{x(x^2+1)} dx \)
  3. \(\displaystyle \int \frac{x}{x^2+2x+10} dx \)
  4. \(\displaystyle \int \frac{\sqrt{x+1}}{x} dx \)
  5. \(\displaystyle \int \frac{\sqrt{x+1}}{\sqrt{x-1}} dx \)
  1. \(\displaystyle \int \frac{d\theta}{1+\texttt{sin}(\theta)}  \)
  2. \(\displaystyle \int \frac{d\theta}{1+\texttt{sin}(\theta)+\texttt{cos}(\theta)}  \)
  3. \(\displaystyle \int \frac{\texttt{sin}(\theta)}{\texttt{cos}(\theta) + \texttt{sin}(\theta)} d\theta \)

Suggestive Solution Guide

This exercise aims to show how the partial fractions decomposition works:

\(
\begin{align*}
\frac{2}{x^2+6x+8}
&= \frac{2}{(x+4)(x+2)} = \frac{A}{x+4}\:+ \frac{B}{x+2}
& \color{gray}{\text{[Factor the denominator and separte the fraction]}} \\[5pt]
& \left( \frac{2}{(x+4)(x+2)} = \frac{A}{x+4}\:+ \frac{B}{x+2} \right)  (x+4)(x+2)
& \color{gray}{\text{[Multiply the equation by the factored denominator]}} \\[5pt]
& 2 = A(x+2)\:+ B(x+4)
& \color{gray}{\text{[Main equation to solve]}} \\[5pt]
& 2 = A(-4+2)\:+ B(-4+4)
& \color{gray}{\text{[If x = -4]}} \\[5pt]
& 2 = -2A \\[5pt]
& \color{blue}{A = -1} \\\\
& 2 = A(x+2)\:+ B(x+4)
& \color{gray}{\text{[Main equation to solve]}} \\[5pt]
& 2 = A(-2+2)\:+ B(-2+4)
& \color{gray}{\text{[If x = -2]}} \\[5pt]
& 2 = 2B \\[5pt]
& \color{blue}{B = 1}
\end{align*}
\)

 

Replace the values of A and B in the partial fractions decomposition:

\(
\begin{align*}
\frac{2}{x^2+6x+8} = \color{green}{-\frac{1}{x+4}\:+ \frac{1}{x+2}}
\end{align*}
\)

This exercise aims to show how the partial fractions decomposition works:

\(
\begin{align*}
& \frac{1}{x(x+1)(x+2)^2} = \frac{A}{x}\:+ \frac{B}{x+1}\:+ \frac{C}{x+2}\:+ \frac{D}{(x+2)^2}
& \color{gray}{\text{[Denominator already factored]}} \\[5pt]
& \left( \frac{1}{x(x+1)(x+2)^2} = \frac{A}{x}\:+ \frac{B}{x+1}\:+ \frac{C}{x+2}\:+ \frac{D}{(x+2)^2} \right) x(x+1)(x+2)^2
& \color{gray}{\text{[Multiply the equation by the factors]}} \\[5pt]
& 1 = A(x+1)(x+2)^2\:+ Bx(x+2)^2\:+ Cx(x+1)(x+2)\:+ Dx(x+1)
& \color{gray}{\text{[Main equation to solve]}} \\[5pt]
& 1 = 4A\:+ \color{red}{0B}\:+ \color{red}{0C}\:+ \color{red}{0D}
& \color{gray}{\text{[If x=0]}} \\[5pt]
& \color{blue}{A = \frac{1}{4}} \\\\
& 1 = A(x+1)(x+2)^2\:+ Bx(x+2)^2\:+ Cx(x+1)(x+2)\:+ Dx(x+1)
& \color{gray}{\text{[Main equation to solve]}} \\[5pt]
& 1 = \color{red}{0A}\:- B\:+ \color{red}{0C}\:+ \color{red}{0D}
& \color{gray}{\text{[If x=-1]}} \\[5pt]
& \color{blue}{B = -1} \\\\
& 1 = A(x+1)(x+2)^2\:+ Bx(x+2)^2\:+ Cx(x+1)(x+2)\:+ Dx(x+1)
& \color{gray}{\text{[Main equation to solve]}} \\[5pt]
& 1 = \color{red}{0A}\:+ \color{red}{0B}\:+ \color{red}{0D}\:+ 2D
& \color{gray}{\text{[If x=-2]}} \\[5pt]
& \color{blue}{D = \frac{1}{2}} \\\\
& 1 = A(x+1)(x+2)^2\:+ Bx(x+2)^2\:+ Cx(x+1)(x+2)\:+ Dx(x+1)
& \color{gray}{\text{[Main equation to solve]}} \\[5pt]
& 1 = 18A+9B+6C+2D
& \color{gray}{\text{[If x=1]}} \\[5pt]
& 1 = 18\left(\frac{1}{4}\right)\:+ 9(-1)\:+ 6C\:+ 2\left(\frac{1}{2}\right) \\[5pt]
& 1 = \frac{9}{2}-9+6C+1 \\[5pt]
& \color{blue}{C = \frac{3}{4}}
\end{align*}
\)

 

Update the partial fractions with the new found values:

\(
\begin{align*}
\frac{1}{x(x+1)(x+2)^2} = \color{green}{\frac{1}{4x}\:- \frac{1}{x+1}\:+ \frac{3}{4(x+2)}\:+ \frac{1}{2(x+2)^2}}
\end{align*}
\)

Perform a partial fractions decomposition for the integrand:

\(
\begin{align*}
\int \frac{1}{x^2-4} dx
& = \int \frac{1}{(x+2)(x-2)} dx = \int \frac{A}{x+2} dx\:+ \int \frac{B}{x-2} dx
& \color{gray}{\text{[Factor and separate the fraction]}}\\\\
& 1 = A(x-2)+ B(x+2)
& \color{gray}{\text{[Main equation to solve]}} \\[5pt]
& 1 = -4A+ \color{red}{0B}
& \color{gray}{\text{[If x=- 2]}} \\[5pt]
& \color{blue}{A = -\frac{1}{4}}\\\\
& 1 = A(x-2)+ B(x+2)
& \color{gray}{\text{[Main equation to solve]}} \\[5pt]
& 1 = \color{red}{0A}\:+ 4B
& \color{gray}{\text{[If x=2]}} \\[5pt]
& \color{blue}{B = \frac{1}{4}}\\\\
\end{align*}
\)

Update the numerator values for the partial fractions:

\(
\begin{align*}
\int \frac{1}{x^2-4}dx
& = \int \frac{-1}{4(x+2)}dx\:+ \int \frac{1}{4(x-2)}dx
& \color{gray}{\text{[Update the values]}} \\[5pt]
& = \frac{1}{4}\left[ \int \frac{1}{(x-2)}dx\:- \int \frac{1}{(x+2)}dx \right]
& \color{gray}{\text{[Rearrange the expression]}} \\[5pt]
& = \frac{1}{4}\left[ \texttt{ln}|x-2| – \texttt{ln}|x+2| \right]\:+ C
& \color{gray}{\text{[Integrate]}} \\[5pt]
& \color{green}{= \frac{1}{4} \texttt{ln} \left| \frac{x-2}{x+2} \right|\:+ C}
\end{align*}
\)

Perform a partial fractions decomposition for the integrand:

\(
\begin{align*}
\int \frac{x+1}{2x^2+7x+3}dx
& = \int \frac{x+1}{(2x+1)(x+3)}dx = \int \frac{A}{2x+1}dx\:+ \int \frac{B}{x+3}dx \\\\
& x+1 = A(x+3) + B(2x+1)
& \color{gray}{\text{[Main equation to solve]}} \\[5pt]
& \frac{1}{2} = \frac{5}{2}A + \color{red}{0B}
& \color{gray}{\text{[If x=0.5]}} \\[5pt]
& \color{blue}{A = \frac{1}{5}}\\\\
& x+1 = A(x+3) + B(2x+1)
& \color{gray}{\text{[Main equation to solve]}} \\[5pt]
& -2 = \color{red}{0A} – 5B
& \color{gray}{\text{[If x=-3]}} \\[5pt]
& \color{blue}{B = \frac{2}{5}}\\\\
\end{align*}
\)

Update the new values in the partial fractions:

\(
\begin{align*}
\int \frac{x+1}{2x^2+7x+3}dx
& \int \frac {1}{5(2x+1)}dx + \int \frac{2}{5(x+3)}dx
& \color{gray}{\text{[Update A and B]}} \\[5pt]
& = \frac{1}{5} \left[ \int \frac{1}{2x+1}dx + 2\int \frac{1}{x+3}dx \right]
& \color{gray}{\text{[Rearrange the expression]}} \\[5pt]
& = \color{green}{\frac{1}{5} \left[ \frac{1}{2}\texttt{Ln}|2x+1| + 2\texttt{Ln}|x+3| \right] + C}
& \color{gray}{\text{[Integrate using quick U-Subs]}} \\[5pt]
\end{align*}
\)

Perform a partial fractions decomposition for the integrand:

\(\normalsize
\begin{align*}
\int \frac{3x+1}{x^2+5x+6}dx
&= \int \frac{3x+1}{(x+3)(x+2)}dx = \int \frac{A}{x+3}dx + \int \frac{B}{x+2}dx\\\\
& 3x+1 = A(x+2)+ B(x+3)
& \color{gray}{\text{[Main equation to solve for]}} \\[5pt]
& -8= -A + \color{red}{0B}
& \color{gray}{\text{[If x=-3]}} \\[5pt]
& \color{blue}{A = 8} \\\\
& 3x+1 = A(x+2)+ B(x+3)
& \color{gray}{\text{[Main equation to solve for]}} \\[5pt]
& -5= \color{red}{0A} + B
& \color{gray}{\text{[If x=-2]}} \\[5pt]
& \color{blue}{B = -5}
\end{align*}
\)

Update the values for the partial fractions:

\(
\begin{align*}
\int \frac{3x+1}{x^2+5x+6}dx
&= \int \frac{8}{x+3}dx\:- \int \frac{5}{x+2}dx
& \color{gray}{\text{[Update the values for A and B]}} \\[5pt]
& \color{green}{= 8\texttt{ln}|x+3|\:- 5\texttt{ln}|x+2|\:+ C}
& \color{gray}{\text{[Integrate using a quick U-Sub]}}
\end{align*}
\)

Perform a partial fractions decomposition for the integrand:

\(\normalsize
\begin{align*}
\int \frac{1-2x}{x^2+4x^2+4x}dx
&= \int \frac{1-2x}{x(x+2)^2}dx = \int \frac{A}{x}dx + \int \frac{B}{x+2}dx + \int \frac{C}{(x+2)^2}dx\\\\
& 1-2x = A(x+2)^2 + Bx(x+2) + Cx
& \color{gray}{\text{[Main equation to solve for]}} \\[5pt]
& 1 = 4A + \color{red}{0B} + \color{red}{0C}
& \color{gray}{\text{[If x = 0]}} \\[5pt]
& \color{blue}{A = \frac{1}{4}}\\\\
& 1-2x = A(x+2)^2 + Bx(x+2) + Cx
& \color{gray}{\text{[Main equation to solve for]}} \\[5pt]
& 5 = \color{red}{0A} + \color{red}{0B} – 2C
& \color{gray}{\text{[If x = -2]}} \\[5pt]
& \color{blue}{C = -\frac{5}{2}}\\\\
& 1-2x = A(x+2)^2 + Bx(x+2) + Cx
& \color{gray}{\text{[Main equation to solve for]}} \\[5pt]
& -1 = 9A + 3B + C \\[5pt]
& -1 = \frac{9}{4} + 3B -\frac{5}{2}
& \color{gray}{\text{[If x = 1]}} \\[5pt]
& \color{blue}{B = -\frac{1}{4}}\\\\
\end{align*}
\)

Update the values for the partial fractions:

\(
\begin{align*}
\int \frac{1-2x}{x^3+4x^2+4x}dx
& = \int \frac{1}{4x}dx\:- \int \frac{1}{4(x+2)}dx\:- \int \frac{5}{2(x+2)^2}dx
& \color{gray}{\text{[Update the values for A and B]}} \\[5pt]
& = \frac{1}{2} \left( \int \frac{1}{2x}dx\:- \frac{1}{2}\int \frac{1}{x+2}dx\:- \int \frac{5}{(x+2)^2}dx \right)
& \color{gray}{\text{[Rearrange the expression]}} \\[5pt]
& = \frac{1}{2} \left( \frac{1}{2}\texttt{ln}|x|\:- \frac{1}{2}\texttt{ln}|x+2|\:- 5\int \frac{1}{u^2}du \right)
& \color{gray}{\text{[Integrate and using quick U-Subs]}} \\[5pt]
& = \frac{1}{2} \left( \frac{1}{2}\texttt{ln}\left| \frac{x}{x+2} \right|\:+ \frac{5}{u} \right) + C
& \color{gray}{\text{[Integrate and rearrange the expressions]}} \\[5pt]
& = \color{green}{\frac{1}{4}\texttt{ln}\left| \frac{x}{x+2} \right|\:+ \frac{5}{2(x+2)} + C}
& \color{gray}{\text{[Simplify and substitute back to x]}} \\[5pt]
\end{align*}
\)

Perform partial fractions decomposition for the integrand:

\(
\begin{align*}
\int \frac{x-1}{x(x^2+1)}dx
&= \int \frac{A}{x}dx\:+ \int \frac{Bx+C}{x^2+1}dx
& \color{gray}{\text{[Irreducible factor accounted for]}}
\end{align*}
\)

Use the equating method in order to solve this equation

\(
\begin{align*}
&x-1 = A(x^2+1) + Bx^2 + Cx \\[5pt]
&x-1 = Ax^2 + A +Bx^2 + Cx \\[5pt]
&x-1 = (A+B)x^2 + Cx + A
& \color{gray}{\text{[Equate each variable to the x variable]}} \\[5pt]
&A+B = 0, so\:  A=-B \\[5pt]
& C = 1 \\[5pt]
&A = -1
\end{align*}
\)

Update the new values in the partial fractions:

\(
\begin{align*}
\int \frac{x-1}{x(x^2+1)}dx
&= \int \frac{-1}{x}dx\:+ \int \frac{x+1}{x^2+1}dx
& \color{gray}{\text{[Update the values for A and B]}} \\[5pt]
&= -\int \frac{1}{x}dx\:+ \int \frac{x}{x^2+1}dx\:+ \int \frac{1}{x^2+1}dx
& \color{gray}{\text{[Separate the integrals]}} \\[5pt]
&= -\texttt{ln}|x|\:+ \texttt{arctan}(x)\:+ \frac{1}{2}\int \frac{1}{u}dx
& \color{gray}{\text{[Integrate and use a quick U-Sub]}} \\[5pt]
&= \color{green}{-\texttt{ln}|x|\:+ \texttt{arctan}(x)\:+ \frac{1}{2}\texttt{ln}(x^2+1) + C}
\end{align*}
\)

Rewrite the integrand and perform a partial fractions decomposition:

\(
\begin{align*}
\int \frac{x}{x^2+2x+10}dx
&= \int \frac{x+1-1}{x^2+2x+10}dx = \int \frac{x+1}{x^2+2x+10}dx\:- \int \frac{1}{x^2+2x+10}dx
& \color{gray}{\text{[Sum 0 by adding 1 – 1 to the numerator]}} \\[5pt]
\end{align*}
\)

Update the new values in the given integrands. Note that the numerator of the first integrand is half of the derivative of the denominator.

\(
\begin{align*}
\int \frac{x}{x^2+2x+10}dx
&= \frac{1}{2} \int \frac{2x+2}{x^2+2x+10}dx\:- \int \frac{1}{x^2+2x+10}dx
& \color{gray}{\text{[Apply the values for A and B]}} \\[5pt]
& = \frac{1}{2} \int \frac{1}{u}du\:- \int \frac{1}{(x+1)^2+9}dx
& \color{gray}{\text{[Use a quick U-Sub and complete the square]}} \\[5pt]
& = \frac{1}{2} \texttt{ln}|x^2+2x+10|\:- \int \frac{1}{u^2+9}du
& \color{gray}{\text{[Integrate and use a quick U-Sub]}} \\[5pt]
\end{align*}
\)

Apply a trigonometric substitution. Let \(u=3\texttt{tan}(\theta)\), so \(du=3\texttt{sec}^2(\theta)d\theta\). Updating the integrand with this substitution yields:

\(
\begin{align*}
\int \frac{1}{u^2+9}du
&= \int \frac{1}{(\color{red}{3\texttt{tan}(\theta)})^2+9}\left( \color{red}{3\texttt{sec}^2(\theta)d\theta} \right)
& \color{gray}{\text{[Apply the substitution]}} \\[5pt]
&= 3\int \frac{\texttt{sec}^2(\theta)}{9(\texttt{tan}^2(\theta)+1)}d\theta = \frac{1}{3}\int \frac{\texttt{sec}^2(\theta)}{\texttt{sec}^2(\theta)}d\theta
& \color{gray}{\text{[Rearrange the expression]}} \\[5pt]
&= \frac{1}{3} \int \theta d\theta = \frac{1}{3}\theta
& \color{gray}{\text{[Simplify and integrate]}} \\[5pt]
&= \frac{1}{3} \texttt{arctan} \left( \frac{u}{3} \right) + C
& \color{gray}{\text{[Substitute back to u]}} \\[5pt]
&= \frac{1}{3} \texttt{arctan} \left( \frac{x+1}{3} \right) + C
& \color{gray}{\text{[Substitute back to x]}} \\[5pt]
\end{align*}
\)

Use the previous result in the final answer

\(
\begin{align*}
\int \frac{x}{x^2+2x+10}dx \color{green}{= \frac{1}{2}\texttt{ln}|x^2+2x+10|\:- \frac{1}{3}\texttt{arctan}\left( \frac{x+1}{3} \right) + C}
\end{align*}
\)

Reexpress the intergand by performing a U-Sub. Let \(u=\sqrt{x+1}\), so \(du=\frac{1}{2\sqrt{x+1}}dx\). Expanding this strategy:

\(\normalsize
\begin{align*}
u = \sqrt{x+1} \Rightarrow u^2 = x+1 \Rightarrow x = u^2-1 \\[5pt]
du = \frac{1}{2\sqrt{x+1}}dx = \frac{1}{2u}dx \Rightarrow dx = 2udu
\end{align*}
\)

Apply this substitutions in the integrand:

\(
\begin{align*}
\int \frac{\color{red}{\sqrt{x+1}}}{\color{red}{x}} \color{red}{dx}
&= \int \frac{\color{red}{u}}{\color{red}{u^2-1}} (\color{red}{2udu})
& \color{gray}{\text{[Apply the substitution]}} \\[5pt]
&= 2\int \frac{u^2}{u^2-1}du = 2\int \frac{u^2-1+1}{u^2-1}du
& \color{gray}{\text{[Sum 0 by adding -1+1]}} \\[5pt]
&= 2\left[ \int \frac{u^2-1}{u^2-1}du\:+ \int \frac{1}{u^2-1}du \right]
& \color{gray}{\text{[Separate the integrand]}} \\[5pt]
&= 2\left[ \int du\:+ \int \frac{1}{u^2-1}du \right]
& \color{gray}{\text{[Simplify]}} \\[5pt]
&= 2u\:+ 2\int \frac{1}{(u+1)(u-1)}du
& \color{gray}{\text{[Apply partial fractions decomposition]}} \\[5pt]
&= 2u\:+ 2\left( \int \frac{A}{u+1}du\:+ \int \frac{B}{u-1}du \right)\\\\\\
& 1 = A(u-1)+B(u+1)
& \color{gray}{\text{[Main equation]}} \\[5pt]
& 1 = -2A+\color{red}{0B}
& \color{gray}{\text{[If u=-1]}} \\[5pt]
& \color{blue}{A=-\frac{1}{2}}\\\\
& 1 = A(u-1)+B(u+1)
& \color{gray}{\text{[Main equation]}} \\[5pt]
& 1 = \color{red}{0A} + 2B
& \color{gray}{\text{[If u=1]}} \\[5pt]
& \color{blue}{B=\frac{1}{2}}\\\\
& =2u + 2\left( -\frac{1}{2}\int \frac{1}{u+1}du +\frac{1}{2}\int \frac{1}{u-1}du \right)
& \color{gray}{\text{[Update the values of A and B]}} \\[5pt]
& = 2u +\int \frac{1}{u-1}du\:- \int \frac{1}{u+1}du
& \color{gray}{\text{[Simplify]}} \\[5pt]
& = 2u + \texttt{ln}|u-1|\:- \texttt{ln}|u+1| + C
& \color{gray}{\text{[Integrate]}} \\[5pt]
& \color{green}{ =2\sqrt{x+1}\:+ \texttt{ln}\left| \frac{\sqrt{x+1}-1}{\sqrt{x+1}+1} \right| + C}
\end{align*}
\)

To rearrange the integrand use a U-Sub. Let \(u=\sqrt{x+1}\), so \(du = \frac{1}{2\sqrt{x+1}}dx; \Rightarrow dx = 2\sqrt{x+1}du = 2udu\). Find the equivalent to x in terms of u:

\(
\begin{align*}
& u = \sqrt{x+1} \\[5pt]
& u^2 = x \:+ 1 \\[5pt]
& x = u^2 \:- 1
\end{align*}
\)

Applying this substitutions in the integrand yields:

\(
\begin{align*}
\int \frac{\sqrt{x+1}}{\sqrt{x-1}} dx
& = \int \frac{\color{red}{u}}{\sqrt{\color{red}{(u^2-1)}-1}} \color{red}{(2udu)} = 2 \int \frac{u^2}{\sqrt{u^2-2}}du
\end{align*}
\)

 

[IN PROGRESS]

 

 

 

Apply Weierstrass substitution. Let \(\texttt{sin}(\theta)= \frac{2x}{1+x^2}\), \(x=\texttt{tan}(\frac{\theta}{2})\), and \(d\theta=\frac{2dx}{1+x^2}\). Applying the substitution to the integrand yields:

\(
\begin{align*}
\int \frac{1}{1+\color{red}{\texttt{sin}(\theta)}}\color{red}{d\theta}
&= \int \frac{1}{1+\color{red}{\frac{2x}{1+x^2}}} \left( \color{red}{\frac{2dx}{1+x^2}} \right)
& \color{gray}{\text{[Apply the substitution]}} \\[5pt]
&= 2\int \left( \frac{1}{\frac{x^2+2x+1}{1+x^2}} \right) \left( \frac{1}{1+x^2} \right) dx
& \color{gray}{\text{[Combine the denominator]}} \\[5pt]
&= 2\int \left( \frac{1+x^2}{(x+1)^2} \right) \left( \frac{1}{1+x^2} \right) dx
& \color{gray}{\text{[Reverse the first fraction]}} \\[5pt]
&= 2 \int \frac{1}{(x+1)^2} dx
& \color{gray}{\text{[Simplify]}} \\[5pt]
&= 2 \int \frac{1}{u^2} du = -\frac{2}{u} + C
& \color{gray}{\text{[Integrate using a U-Sub]}} \\[5pt]
&= -\frac{2}{x+1} + C
& \color{gray}{\text{[Substitute back to x]}} \\[5pt]
& \color{green}{= -\frac{2}{\texttt{tan}(\frac{\theta}{2})+1} + C}
& \color{gray}{\text{[Substitute back]}} \\[5pt]
\end{align*}
\)

Apply Weierstrass substitution. Let \(\texttt{sin}(\theta)=\frac{2x}{1+x^2}\), \(\texttt{cos}(\theta)=\frac{1-x^2}{1+x^2}\), \(x=\texttt{tan}(\frac{\theta}{2})\), and \(d\theta = \frac{2dx}{1+x^2}\). Applying this substitution in the integrand leads to:

\( \begin{align*} \int \frac{1}{1+\color{red}{\texttt{sin}(\theta)} + \color{red}{\texttt{cos}(\theta)}} \color{red}{d\theta} &= \int \frac{1}{1+\color{red}{\frac{2x}{1+x^2}} + \color{red}{\frac{1-x^2}{1+x^2}}} \color{red}{\left( \frac{2}{1+x^2}dx \right)} & \color{gray}{\text{[Apply the substitution]}} \\[5pt] &= 2 \int \left( \frac{1}{\frac{1+x^2+2x+1-x^2}{1+x^2}} \right) \left( \frac{1}{1+x^2} \right) dx & \color{gray}{\text{[Merge the denominator]}} \\[5pt] &= 2 \int \left( \frac{1}{\frac{2x+2}{1+x^2}} \right) \left( \frac{1}{1+x^2} \right) dx & \color{gray}{\text{[Simplify]}} \\[5pt] &= 2 \int \left( \frac{1+x^2}{2x+2} \right) \left( \frac{1}{1+x^2} \right) dx = 2 \int \frac{1}{2x+2} dx = \int \frac{1}{x+1}dx \\[5pt] &= \texttt{ln}|x+1| + C & \color{gray}{\text{[Integrate]}} \\[5pt] & \color{green}{= \texttt{ln}\left| \texttt{tan} \left( \frac{\theta}{2} \right) +1 \right| + C} & \color{gray}{\text{[Substitute back]}} \end{align*} \)

Apply Weierstrass substitution. Let \(\texttt{sin}(\theta)=\frac{2x}{1+x^2}\), \(\texttt{cos}(\theta)=\frac{1-x^2}{1+x^2}\), \(x=\texttt{tan}(\frac{\theta}{2})\), and \(d\theta = \frac{2dx}{1+x^2}\). Applying this substitution in the integrand leads to:

\(
\begin{align*}
\int \frac{\color{red}{\texttt{sin}(\theta)}}{\color{red}{\texttt{sin}(\theta)} + \color{red}{\texttt{cos}(\theta)}} \color{red}{d\theta}
&= \int \frac{\color{red}{\frac{2x}{1+x^2}}}{\color{red}{\frac{2x}{1+x^2}} + \color{red}{\frac{1-x^2}{1+x^2}}} \color{red}{\left( \frac{2}{1+x^2}dx \right)}
& \color{gray}{\text{[Apply the substitution]}} \\[5pt]
&= 4 \int \frac{\frac{x}{(1+x^2)^2}}{\frac{-x^2+2x+1}{1+x^2}}dx
& \color{gray}{\text{[Manipulate algebraically]}} \\[5pt]
&= 4 \int \left( \frac{x}{(1+x^2)^2} \right) \left( \frac{1+x^2}{-x^2+2x+1} \right) dx
& \color{gray}{\text{[Reverse the denominator]}} \\[5pt]
&= -4 \int \frac{x}{(1+x^2)(x^2-2x-1)}dx
& \color{gray}{\text{[Simplify]}} \\[5pt]
\end{align*}
\)

In order to apply partial fractions decomposition use the quadratic formula for the second factor in the denominator:

\(
\begin{align*}
& x = \frac{-b \pm \sqrt{b^2-4ac}}{2a} = \frac{-(-2) \pm \sqrt{(-2)^2-4(1)(-1)}}{2(1)} = \frac{2 \pm \sqrt{4+4}}{2} = \frac{2 \pm \sqrt{8}}{2} = \frac{2 \pm 2\sqrt{2}}{2} = 1 \pm \sqrt{2} \\[5pt]
& x_1 = 1 + \sqrt{2} \\[5pt]
& x_2 = 1 – \sqrt{2} \\[5pt]
& x^2-2x-1 = (x – 1 + \sqrt{2})(x – 1 – \sqrt{2})
\end{align*}
\)

Update the factor in the denominator with the new factorization result to apply partial fractions decomposition:

\(
\begin{align*}
&-4\int \frac{x}{(1+x^2)\color{red}{(x^2-2x-1)}}dx = -4\int \frac{x}{(1+x^2)\color{red}{(x-1+\sqrt{2})(x-1-\sqrt{2})}}dx \\[5pt]
&= -4\left( \int \frac{Ax+B}{1+x^2}dx + \int \frac{C}{x-1+\sqrt{2}}dx + \int \frac{D}{x-1-\sqrt{2}}dx \right) \\\\
& \color{gray}{\text{[Use the equating method]}} \\[5pt]
&x = (Ax+B)(x-1+\sqrt{2})(x-1-\sqrt{2}) + \color{blue}{C(x^2+1)(x-1-\sqrt{2})} + \color{red}{D(x^2+1)(x-1+\sqrt{2})} \\[5pt]
& x = Ax^3-2Ax^2-Ax+Bx^2-2Bx-B + \color{blue}{Cx^3-Cx^2-\sqrt{2}Cx^2+Cx-C-\sqrt{2}C} + \color{red}{Dx^3-Dx^2+\sqrt{2}Dx^2+Dx-D+\sqrt{2}D} \\[5pt]
& x = \color{red}{[A+C+D]}x^3 + \color{blue}{[-2A+B-C(1+\sqrt{2})-D(1-\sqrt{2})]}x^2 + \color{green}{[-A-2B+C + D]}x + \color{orange}{[-B-C(1+\sqrt{2})-D(1-\sqrt{2})]} \\\\
& \color{gray}{\text{[Solve the resulting equation system using any method]}} \\[5pt]
&A+C+D=0 \\[5pt]
&-2A+B-C-\sqrt{2}C-D+\sqrt{2}D=0 \\[5pt]
&-A-2B+C+D=1 \\[5pt]
&-B-C-\sqrt{2}C-D+\sqrt{2}D=0 \\[5pt]
& A = -\frac{1}{4}\\[5pt]
& B = -\frac{1}{4} \\[5pt]
& C = \frac{1}{8} \\[5pt]
& D = \frac{1}{8} \\[5pt]
\end{align*}
\)

Update the newfound values into the partial fraction integrals:

\(
\begin{align*}
-4&\int \frac{x}{(1+x^2)(x-1+\sqrt{2})(x-1-\sqrt{2})}dx\\
&= -4\left( \int \frac{-\frac{1}{4}x-\frac{1}{4}}{1+x^2}dx + \int \frac{\frac{1}{8}}{x-1+\sqrt{2}}dx + \int \frac{\frac{1}{8}}{x-1-\sqrt{2}}\right)
& \color{gray}{\text{[Update]}} \\[5pt]
&= \int \frac{x+1}{1+x^2}dx\:- \frac{1}{2}\int \frac{1}{x-1+\sqrt{2}}dx\:- \frac{1}{2}\int \frac{1}{x-1-\sqrt{2}}dx \\[5pt]
&= \int \frac{x}{1+x^2}dx + \int \frac{1}{1+x^2}dx\: – \frac{1}{2} \left( \texttt{ln}|x-1+\sqrt{2}|\:+ \texttt{Ln}|x-1-\sqrt{2}| \right) + C
& \color{gray}{\text{[Integrate]}} \\[5pt]
& = \frac{1}{2}\int \frac{1}{u}du + \int \frac{1}{1+x^2}dx\: – \frac{1}{2} \texttt{ln}|(x-1+\sqrt{2})(x-1-\sqrt{2})| + C \\[5pt]
& = \frac{1}{2} \texttt{ln}|u| + \texttt{arctan}(x)\:- \frac{1}{2} \texttt{ln}|x^2-2x-1| + C \\[5pt]
& = \frac{1}{2} \texttt{ln}(x^2+1)\:- \frac{1}{2} \texttt{ln}|x^2-2x-1| + \texttt{arctan}(x) + C \\[5pt]
&= \frac{1}{2} \texttt{ln} \left| \frac{x^2+1}{x^2-2x-1} \right| +\texttt{arctan}(x) + C
& \color{gray}{\text{[Substitute back]}} \\[5pt]
&= \color{green}{\frac{1}{2} \texttt{ln} \left| \frac{\texttt{tan}^2(\frac{\theta}{2})+1}{\texttt{tan}^2(\theta)-2\texttt{tan}(\frac{\theta}{2})-1} \right| + \texttt{arctan} \left( \texttt{tan} \left( \frac{\theta}{2} \right) \right) + C}
\end{align*}
\)