Quotient Rule#
A quotient looks like a fraction with one function being divided by another function, for example:
When we have a function in the form of a quotient, we differentiate it using the quotient rule:
If the function \(f(x)\) is written as a quotient, so
So returning to \(y=\frac{x^3}{e^{3x}}\), we have \(u=x^3\) and \(v=e^{3x}\).
Hence \(\frac{du}{dx} = 3x^2\), \(\frac{dv}{dx} = 3e^{3x}\), and \(v^2 = e^{6x}\). Then substitute into the quotient rule,
The quotient rule is, naturally, present in sympy
.
from sympy import symbols, diff, exp, simplify
x = symbols('x')
simplify(diff((x ** 3) / (exp(3 * x))))
Example
Differentiate \(y = \frac{\sin(x)}{3\ln(x)}\).
Solution: Just like in the previous example, we have \(u\) to be the numerator and \(v\) to be the denominator of the fraction, so \(u = \sin(x)\) and \(v=3\ln(x)\). We can now differentiate these to get \(\frac{du}{dx} = \cos(x)\) and \(\frac{dv}{dx} = \frac{3}{x}\).
Using the quotient rule, we get that:
Substitute in what we have:
We can simplify:
A factor of 3 can be taken out:
In Python,
from sympy import sin, log
simplify(diff(sin(x) / (3 * log(x))))
Example
Differentiate \(y = \frac{x}{e^{2x}}\)
Solution: We have a function \(x\) divided by a function \(e^{2x}\), so to find the derivative the quotiet rule needs to be used. So \(u=x\) and \(v=e^{2x}\), and, therefore, \(\frac{du}{dx} = 1\) and \(\frac{dv}{dx} = 2e^{2x}\).
We can now employ the quotient rule to get:
Substitute what we know in:
Simplifying this by taking a factor of \(e^{2x}\) out:
The \(e^{2x}\) on top cancels with one on the bottom:
And again, in Python.
simplify(diff(x / (exp(2 * x))))
Partial Pressures
During the reaction N2O4 ⇄ 2NO2, the partial pressure of N2O4 is given by the expression,
Find \(\frac{dp}{d\zeta}\).
Solution: We notice that \(p\) is the quotient of two functions involving \(\zeta\), this means that we should use the quotient rule when differentiating. So we have \(u=1-\zeta\) and \(v=1+\zeta\). Differentiating gives us \(\frac{du}{d\zeta} = -1\) and \frac{dv}{d\zeta} = 1$.
We than utilise the quotient rule to find that:
So we first substitute:
Expand the brackets:
Simplifying the numerator:
Of course, Python can achieve this with the ζ symbol.
zeta = symbols('zeta')
simplify(diff((1 - zeta) / (1 + zeta)))