import sympy
Product Rule
The product rule is a fundamental concept in calculus used to compute the derivative of the product of two functions. If you have two functions, \(f(x)\) and \(g(x)\), the product rule helps you find the derivative of their product \[h(x) = f(x)g(x)\] with respect to \(x\). Mathematically, the product rule states that:
\[ h'(x) = f'(x)g(x) + f(x)g'(x) \]
where \(h'(x)\) is the derivative of \(h(x)\) with respect to \(x\), \(f'(x)\) is the derivative of \(f(x)\) with respect to \(x\), and \(g'(x)\) is the derivative of \(g(x)\) with respect to \(x\).
Example
Find the derivative of the product function \(h(x) = (x^2 + 1)(3x - 4)\) with respect to \(x\)
- Define the functions \(f(x)\) and \(g(x)\):
\[ \begin{aligned} f(x) &= x^2 + 1 \\ g(x) &= 3x - 4 \end{aligned} \]
- Compute the derivatives:
\[ \begin{aligned} f'(x) &= 2x \\ g'(x) &= 3 \end{aligned} \]
- Apply the product rule:
\[ \begin{aligned} h'(x) &= f'(x)g(x) + f(x)g'(x) \\ &= 2x(3x - 4) + (x^2 + 1)(3) \\ &= 9x^2 - 8x + 3 \\ \end{aligned} \]
In Sympy this looks like
= sympy.symbols("x")
x
= x**2 + 1
u_x = 3 * x - 4
v_x
= sympy.diff(u_x, x)
u_prime = sympy.diff(v_x, x)
v_prime
= u_prime * v_x + u_x * v_prime
w_prime
sympy.simplify(w_prime)
\(\displaystyle 9 x^{2} - 8 x + 3\)