Differentiating a Sum

Differentiating a Sum#

If we have multiple terms in the form of a sum, for example \(y=x^3+bx+1\), then in order to find \(\frac{dy}{dx}\), we apply the differential operator on each of the terms in term. So in other words, we differentiate each part of the sum one by one.

Consider \(y = x^3 + 8x + 1\). If we want to find \(\frac{dy}{dx}\), then we would apply the \(\frac{d}{dx}\) operator to both sides of the equation giving us:

  • Starting from: \(\frac{dy}{dx} = \frac{d}{dx} (x^3 + 8x + 1)\)

  • Now we apply the \(\frac{d}{dx}\) operator to each term: \(\frac{dy}{dx} = \frac{d}{dx}(x^3) + \frac{d}{dx}(8x) + \frac{d}{dx}(1)\)

  • Now we differentiate each of the terms individually: \(3x^2 + 8 + 0\)

  • Now simplify: \(3x^2 + 8\)


Let’s see that in Python.

from sympy import symbols, diff

x = symbols('x')

diff(x ** 3 + 8 * x + 1)
\[\displaystyle 3 x^{2} + 8\]

Example

Differentiate the following:

  1. \(y = e^x + 4x^6\)

  2. \(y = \ln{(2x)} + \frac{1}{3}\sin{(9x)}\)

Solution:

  1. To differentiate \(y\), we differentiate all of the terms individually. We use the rules for differentiating exponentials and powers to get:

\[ y = e^x + 4x^6 \Rightarrow \frac{dy}{dx} = e^x + 4 \times 6x^5 = e^x + 24x^5 \]
  1. Same as the example before, we differentiate each term.

\[ y = \ln{(2x)} + \frac{1}{3}\sin({9x)} \Rightarrow \frac{dy}{dx} = \frac{1}{x} + \frac{1}{3}\times 9\cos{(9x)} = \frac{1}{x} + 3\cos{(9x)} \]

Example

Differentiate \(z = \cos{(4t)} + 6e^t + t^5 + 2t^2 + 7\) with respect to \(t\).

Solution: This question is different as our equation is not in terms of \(y\) and \(x\), but instead in terms of \(z\) and \(t\). We treat this in the same way as if the terms were \(y\) and \(x\), so we differentiate each term individually.

\[ \frac{dz}{dt} = -4\sin{(4t)} + 6e^t + 5t^4 + 4t \]
from sympy import cos, exp

t = symbols('t')

diff(cos(4 * t) + 6 * exp(t) + t ** 5 + 2 * t ** 2 + 7)
\[\displaystyle 5 t^{4} + 4 t + 6 e^{t} - 4 \sin{\left(4 t \right)}\]

Onsager Equation

The Onsager equation \(\Lambda = \Lambda^\circ - b\sqrt{c}\) describes the relationship between the conductivity \(\Lambda\) of a simple ionic salt in solution and the concentration \(c\) where the limiting conductivity \(\Lambda^\circ\) and \(b\) are constants. Find \(\frac{d\Lambda}{dc}\).

Solution: As with the previous example, we aren’t using \(y\) and \(x\). We can write \(\sqrt{c}\) as the fractional power \(c^{\frac{1}{2}}\). This gives us \(\Lambda = \Lambda^\circ - bc^{\frac{1}{2}}\).

  • We can then differentiate this with respect to \(c\): \(\frac{d\Lambda}{c} = \frac{d}{dc}(\Lambda^\circ) - b\frac{d}{dc}\left(c^{\frac{1}{2}}\right)\)

  • We can now differentiate each of the terms: \(\frac{d\Lambda}{dc} = 0 - b\left(\frac{1}{2}c^{-\frac{1}{2}}\right)\)

  • Then expand and simplify: \(\frac{d\Lambda}{dc} = -\frac{b}{2}c^{-\frac{1}{2}}\)

from sympy import sqrt

b, c, Lambda_o = symbols('b, c, \Lambda^\circ')

diff(Lambda_o - b * sqrt(c), c)
\[\displaystyle - \frac{b}{2 \sqrt{c}}\]