# Integrating $\frac{1}{\sin(3x)}$ when sovling an ODE

I struggle solving the following.

$$f''+9f=\cot(3x)$$

Homogeneous:

With the Ansatz $$f=e^{\lambda x}$$ we find

$$P(\lambda)=\lambda^2+9=0 \quad \Rightarrow \quad \lambda_{1,2}=\pm3i$$

so we get

$$y_h(x)=A\cos(3x)+B\sin(3x)$$

Particular:

We use variation of constants and we consider $$A,B$$ as two functions of x: $$A(x), B(x)$$. With the Basis $$\{\cos(3x), \sin(3x)\}$$ we find:

$$\begin{pmatrix}\cos(3x)& \sin(3x) \\ -3\sin(3x) & 3\cos(3x)\end{pmatrix}\cdot\begin{pmatrix}A'(x)\\B'(x)\end{pmatrix}=\begin{pmatrix}0\\ \frac{\cos(3x)}{\sin(3x)}\end{pmatrix}$$

We solve it and get

$$A'(x)=-\frac{1}{3}\cos(3x), \quad B'(X)=\frac{\cos^2(x)}{\sin(3x)}$$

We integrate it:

$$A(x)=\int A'(x) dx = \frac{1}{3}\sin(3x)$$

$$B(x)=\int B'(x) dx = \frac{1}{3}\int\frac{\cos^2(3x)}{\sin(3x)}dx=\frac{1}{3}\int\frac{1-\sin^2(3x)}{\sin(3x)}=\frac{1}{3}\int\frac{1}{\sin(3x)}dx-\frac{1}{3}\int \sin(3x)dx$$

Now I have problems solving $$\int\frac{1}{\sin(3x)}dx$$

Any hints? :)

• Start by letting $3x=t$ , then to integrate $\int \frac{dt}{\sin t}$ multiply it by $\frac{\sin t}{\sin t}$. You have to think though how to rewrite $\sin^2 t$ from the denominator in order to solve the integral :) – カカロット Jan 9 at 17:36
• Answer is $\frac{1}{3}ln|\arctan(\frac{3x}{2})|+c$. The step by step solution is here: symbolab.com/solver/integral-calculator/… – ersh Jan 9 at 17:43
• Thanks, gonna try it. – xotix Jan 9 at 17:46
• This is similar to the secant integral. There are many forms of the solution, a common one is $\frac13 \ln|\csc 3x + \cot 3x|$ – Dylan Jan 9 at 18:08
• @Dylan watch your signs, it's $\frac{1}{3}\ln|\csc 3x\color{red}{-}\cot 3x|+C$. – Oscar Lanzi Jan 10 at 1:22

$$$$I = \int \frac{1}{\sin\left(3x\right)}\:dx$$$$
Let $$u = 3x$$ to yield:
$$$$I = \int \frac{1}{\sin\left(3x\right)}dx = \int \frac{1}{\sin\left(u\right)}\cdot\frac{1}{3}\:du = \frac{1}{3}\int \operatorname{cosec}(u) \:du$$$$
There are a variety of ways to approach this integral. One method is covered here. You will observe that method requires knowledge of a trigonometric derivative identity. Here I will employ a method that can be used to solve integrals of rational expressions of trigonometric functions. This method is known as the Half Tangent (aka Weierstrass) Substitution. Thus we let $$t = \tan\left(\frac{u}{2} \right)$$ to yield:
\begin{align} I &= \frac{1}{3}\int \operatorname{cosec}(u) \:du = \frac{1}{3}\int \frac{1}{\sin(u)}\:du \\ &= \frac{1}{3}\int \frac{1}{\frac{2t}{1 + t^2}}\frac{2}{1 + t^2}\:dt = \frac{1}{3} \int \frac{1}{t}\:dt = \frac{1}{3}\ln\left|t \right| + C \\ &= \frac{1}{3}\ln\left|\:\tan\left(\frac{u}{2}\right)\: \right| + C = \frac{1}{3}\ln\left|\:\tan\left(\frac{3x}{2}\right) \: \right| + C \end{align}
Where $$C$$ is the constant of integration.