Differentiating Trigonometric Functions#
Below, we have the rules for differentiating trigonometric functions:
When we have constants multiplying the trigonometric functions and coefficients multiplying our \(x\), we can use the following rules:
Example
Differentiate:
\(y = \sin(9x)\)
\(y = 4 \cos\left(\frac{x}{2}\right)\)
\(y = -2\cos(7x)\)
Solution:
Using the rule:
Now that we have \(y=\sin(9x)\), so \(a=1\) and \(b=9\). So \(\frac{dy}{dx} = 9\cos(9x)\).
Using the rule:
Not that we have \(y=4\cos\left(\frac{x}{2}\right)\), so \(a=4\) and \(b=\frac{1}{2}\)
Using the rule:
Note that we have \(y=-2\cos(7x)\), so \(a=-2\) and \(b=7\)
The sympy
symbolic differentiation can be used for trigonometric functions.
However, we must use the sympy
versions of sin
and cos
.
from sympy import symbols, diff, sin, cos
x = symbols('x')
diff(sin(9 * x))
diff(4 * cos(x / 2))
diff(-2 * cos(7 * x))
Bragg Equation
In X-ray crystallography, the Bragg equation relates the distance \(d\) between successive layers in a crystal, the wavelength of the X-rays, \(\lambda\), an integer \(n\), and the angle through which the X-rays are scattered, \(\theta\), in the equation:
What is the rate of change of \(\lambda\) with \(\theta\)?
Solution: The question is asking us to find \(\frac{d\lambda}{d\theta}\). So as \(n\) and \(d\) are constants, we can use the rule:
So we have \(a=\left(\frac{2d}{n}\right)\) and \(b=1\), with \(\lambda\) as \(y\) and \(\theta\) as \(x\), therefore:
n, d, theta = symbols(r'n d \theta')
diff(2 * d / n * sin(theta), theta)