How to Calculate Distributional Derivatives: Step-by-Step Examples of Piecewise Functions and the Dirac Delta Function
- Get link
- X
- Other Apps
Distributional Derivatives: Examples for the Case of a Single Variable
In our previous discussion, we established that if a function ๐(๐ฅ) is continuous and its classical derivative \(f'^\ast(x)\) is piecewise continuous, then the distributional derivative \(f'\) coincides with \(f'^\ast(x)\) in the sense of distributions. Even when \(f'^\ast(x)\) fails to exist at a finite number of points, the distributional framework remains robust.
Recall the Integration by Pasts: The Key Identity form Generalized Functions: Extending Differentiation & Integration
\[ (f', \varphi) = - (f, \varphi') \] for all test functions \( \phi \in C_c^\infty(\mathbb{R})\) , the space of smooth functions with compact support.
A more general sufficient condition is that ๐(๐ฅ) is absolutely continuous. In this case,\(f'^\ast(x)\) exists almost everywhere, is locally integrable, and the integration by parts formula still applies.
Let's explore a few illustrative examples:
Example 1: Smooth Function
Let \( f(x) = x^2 \) . Clearly,\( \quad f \in C^\infty \) , and the classical derivative is:\[ \quad f'^\ast(x) = 2x \] To compute the distributional derivative ๐′, let’s test it against a smooth compactly supported function ๐:\[ \langle f', \phi \rangle =-\langle f, \phi' \rangle= - \int_{-\infty}^{\infty} x^2 \phi'(x) \,dx \] Using integration by parts: \[ = \int_{-\infty}^{\infty} 2x \phi(x) \,dx = \langle 2x, \phi \rangle \] Thus, \( f'(x) = 2x \) in the distributional sense, matching the classical derivative.
SageMath Verification
from sage.all import var, function, integrate, diff
x = var('x')
phi = function('phi')(x)
# Define smooth function
f = x^2
f_prime = diff(f, x) # Classical derivative
# Verify distributional identity
lhs = integrate(f_prime * phi, x, -oo, oo)
rhs = -integrate(f * diff(phi, x), x, -oo, oo)
print(lhs, rhs)
Copy the code snippet from this post and paste it into the live SageMath cell here:
๐ Run SageMath Code Here
The outputs match, confirming that the classical derivative \( f'(x) = 2x \) is also the distributional derivative.
from sage.all import plot
# Plot
plot_f_x = plot(f, (x, -3, 3), color='blue', legend_label="f(x) = x^2")
plot_f_x_prime = plot(f_prime, (x, -3, 3), color='red', legend_label="f'(x) = 2x")
(plot_f_x + plot_f_x_prime).show()
Example 2: Absolute Value Function
Let \( f(x) = |x| \) This function is continuous everywhere and differentiable everywhere except at ๐ฅ=0. The classical derivative is: \[ \quad f'_\ast (x) = \begin{cases} 1, & \text{if } x > 0 \\ -1, & \text{if } x < 0 \end{cases} \quad \text{undefined at } x = 0 \]
Let’s check the distributional derivative. For any test function \( \phi \in C_c^\infty(\mathbb{R})\) :\[\langle f', \phi \rangle = -\langle f, \phi' \rangle \] \[\langle f', \phi \rangle = - \int_{-\infty}^{\infty} |x| \phi'(x) \,dx \] Split the integral: \[= -\left( \int_{-\infty}^{0} (-x) \phi'(x) \,dx + \int_{0}^{\infty} x \phi'(x) \,dx \right) \] Integrating by parts in each region:\[= \int_{-\infty}^{0} \phi(x) \,dx - \int_{0}^{\infty} \phi(x) \,dx \] which simplifies to: \[= \int_{-\infty}^{\infty} \operatorname{sgn}(x) \phi(x) \,dx \] Thus, in the sense of distributions:\[f'(x) = \operatorname{sgn}(x) \] Note: This corresponds to the classical derivative wherever it is defined. The absolute value function is not differentiable at ๐ฅ=0, but we can compute the distributional derivative:\[f'(x) = \operatorname{sgn}(x)+2\delta(x) \]
SageMath Verification
from sage.all import var, function, piecewise, integrate, Integer
x = var('x')
phi = function('phi')(x)
# Define absolute value function
abs_x = piecewise([((x < 0), -x), ((x >= 0), x)])
# Define classical derivative (sgn function)
abs_x_prime = piecewise([((x < 0), -1), ((x > 0), 1)])
# Integrate and add delta contribution
integral_abs_x_phi_prime = integrate(abs_x_prime * phi, x, -oo, oo)
jump_term = Integer(2) * phi(x=0) # Corrected substitution
result = integral_abs_x_phi_prime + jump_term
print(result)
Copy the code snippet from this post and paste it into the live SageMath cell here:
๐ Run SageMath Code Here
The result confirms the distributional derivative includes a delta function at ๐ฅ=0
from sage.all import plot
plot_abs_x = plot(abs_x, (x, -3, 3), color='blue', legend_label="|x|")
plot_abs_x_prime = plot(abs_x_prime, (x, -3, 3), color='red', legend_label="sgn(x)")
(plot_abs_x + plot_abs_x_prime).show()
Example 3: Heaviside Function
Let \( H(x) \)be the Heaviside step function: \[ H(x) = \begin{cases} 0, & x < 0 \\ 1, & x \geq 0 \end{cases} \]
This function is not differentiable in the classical sense, but in the sense of distributions: \[ \langle H', \phi \rangle = -\langle H, \phi' \rangle \]
\[ \langle H', \phi \rangle = -\int_{0}^{\infty} \phi'(x) \,dx= \phi(0) \] Therefore,\( H'(x) = \delta(x) \) , the Dirac delta function.
Classically not differentiable, but distributionally: \( H'(x) = \delta(x) \)
SageMath Verification
from sage.all import var, function, piecewise, integrate
x = var('x')
phi = function('phi')(x)
phi_prime = diff(phi, x)
# Define the Heaviside function
theta = piecewise([((x < 0), 0), ((x >= 0), 1)])
# Compute distributional pairing
integral_theta_phi_prime = -integrate(theta * phi_prime, x, -oo, oo)
print(integral_theta_phi_prime)
Copy the code snippet from this post and paste it into the live SageMath cell here:
๐ Run SageMath Code Here
This returns \( \phi(0) \) , verifying:\[ \langle \theta', \phi \rangle = \phi(0) \Rightarrow \theta'(x) =\delta(x) \]
from sage.all import plot
plot_theta = plot(theta, (x, -3, 3), color='blue', legend_label="ฮธ(x)")
plot_theta.show()
Example 4: Piecewise Smooth Function with Jump
Consider a function: \[ f(x) = \begin{cases} 0, & x < 0 \\ x, & x \geq 0 \end{cases} \]
This is continuous and differentiable on each side of ๐ฅ=0, but the derivative jumps from 0 to 1 at the origin. We compute the distributional derivative: \[ f'(x) = 1.H(x) + \delta(x) \] This derivative consists of the Heaviside function representing the linear part, and a delta function capturing the jump discontinuity in the derivative.
SageMath Verification
from sage.all import var, function, piecewise, integrate
x = var('x')
phi = function('phi')(x)
# Define the piecewise function f(x)
f = piecewise([((x < 0), 0), ((x >= 0), x)])
# Define classical derivative ignoring the delta term
f_prime_classical = piecewise([((x < 0), 0), ((x > 0), 1)])
# Compute integral and delta contribution
integral_f_phi_prime = integrate(f_prime_classical * phi, x, -oo, oo)
# Corrected substitution using named arguments
jump_term = phi(x=0)
result = integral_f_phi_prime + jump_term
print(result)
Copy the code snippet from this post and paste it into the live SageMath cell here:
๐ Run SageMath Code Here
This confirms the distributional derivative: \[ f'(x) = H(x) + \delta(x) \]
from sage.all import plot
plot_f = plot(f, (x, -3, 3), color='blue', legend_label="f(x)")
plot_f_prime = plot(f_prime_classical, (x, -3, 3), color='red', legend_label="f'(x)")
(plot_f + plot_f_prime).show()
These examples demonstrate how SageMath can verify and visualize distributional derivatives for various functions—smooth, discontinuous, and piecewise-defined.
Conclusion
These examples show how distributional derivatives extend the concept of differentiation to functions that may be non-differentiable, piecewise smooth, or even discontinuous. This flexibility is crucial in many areas of mathematics and physics, particularly when dealing with generalized functions or weak solutions to differential equations.
In future posts, we’ll explore how this extends to multiple variables and how distributions interact with differential operators in higher dimensions and how mollifiers help in smoothing and regularization, and how distributions behave in higher dimensions.
- Get link
- X
- Other Apps
Comments
Post a Comment
If you have any queries, do not hesitate to reach out.
Unsure about something? Ask away—I’m here for you!