# Symbolic Differentiation

We here motivate the basic rules used in symbolic computation of derivatives as the essence of Symbolic Calculus. Using these rules derivates of endless combinations  (algebraic and composite) of functions with known derivatives, can be computed in a veritable eldorado for lovers of symbolic computation.

Let F(t) and G(t) be (real-valued) functions of time t and let D = d/dt denote differentiation with respect to time, so that dF = DF*dt (or dF(t) = DF(t)*dt) with formally dF(t) = F(t+dt) – F(t) up to second order in dt.

#### Derivative of a Polynomial: dt^n/dt = n*t^(n-1)

The basic application of symbolic differentiation concerns the symbolic computation of the derivative D = d/dt of a polynomial

• p(t) = a0 + a1*t + a2*t^2 + a3*t^3 + … + an*t^n

with t^2 = t*t,  t^3 = t*t*t and t^n = t*t*t…*t (n times). The basic case is p(t) = t, with

• dp(t) = p(t+dt) – p(t) = t+dt – t = dt = 1*dt

with thus dp/dt = dt/dt = 1. Next, with p(t) = t*t we have

• dp(t) = (t+dt)*(t+dt) – t*t = t*t + 2*t*dt + dt*dt – t*t = 2*t*dt + dt*dt

with thus dp/dt = d(t*t)/dt = 2*dt up to a term scaling with dt. Next, with p(t)=t^3 with have

• dp(t) = (t+dt)^3 – t^3 = t^3 + 3*t^2*dt + 3*t*dt^2 + dt*3 – t^3 = 3*t^2*dt + 3*t*dt^2 + dt^3

with thus dt^3 = 3*t^2 up to terms scaling with dt or dt^2. More generally, we have

• dt^n = n*t^(n-1) for n = 1, 2, 3,….

Computation of derivatives of polynomials (in several variables) is a basic ingredient of FEM.

Compare with p5.js code polynomials.

Derivative of a Linear Combination

We have with a and b constants

• D(a*F + b*G) = a*DF + b*DG,

because

• d(a*F + b*G)
• = (a*F + b*G)(t+dt) -(a*F + b*G)(t) = a*(F(t+dt)-F(t)) + b*(G(t+dt)-G(t))
• = a*dF + b*dG.

#### Derivative of Product

We have

• D(F*G) = DF*G + F*DG,

because

• d(F*G) – dF*G – F*dG = F(t+dt)*G(t+dt) – F(t)G(t) – dF*G(t) – F(t)*dG
• = F(t+dt)*(G(t+dt)-G(t)) – F(t)*dG + G(t)*(F(t+dt) – F(t)) – G(t)*dF
• = 0

up to send order i dt.

#### Derivative of a Quotient

We have

• D(1/G) = – DG/G^2     (with G^2 = G*G)

because

• d(1/G) = 1/(G(t+dt) – 1/G(t) = – (G(t+dt) – G(t))/(G(t+dt)*G(t))
• = – dG/G(t)^2

up second order in dt. More generally

• D(F/G) = (DF*G-F*DG)/G^2   if G not zero.

#### The Chain Rule

For the composite function $H(t)=F(G(t))$ we have

• DH(t) = DF(G(t))*DG(t)      (with DF(s) = dF(s)/ds and s = G(t))

because

• dH = H(t+dt)-H(t)=F(G(t+dt)-F(G(t)) = DF(G(t))*(G(t+dt) – G(t))
• =DF(G(t))*DG(t)*dt

up to terms of order in dt.