Learning Objectives
By the end of this section, you will be able to:
- Define what it means for a function to be differentiable at a point
- Explain the relationship between continuity and differentiability
- Identify corners, cusps, vertical tangents, and discontinuities as points where derivatives fail to exist
- Compute one-sided (left-hand and right-hand) derivatives
- Analyze piecewise functions for differentiability
- Connect non-differentiable points to challenges in machine learning optimization
The Big Picture: When Derivatives Break Down
"The derivative exists at a point only when the function has a single, well-defined tangent line there — not a corner, not a cusp, not a vertical line."
In the previous sections, we defined the derivative as a limit and computed it for smooth functions like polynomials. But not every function has a derivative at every point. This section explores the boundary conditions of calculus — where and why the derivative fails to exist.
The Central Question
Given a function , at which points does exist, and what can go wrong at points where it doesn't?
Understanding differentiability is crucial because:
- Theoretical foundation: Many calculus theorems (Mean Value Theorem, Taylor series) require differentiability
- Optimization: Gradient-based optimization assumes derivatives exist
- Machine learning: Non-differentiable activation functions (like ReLU) require special handling
- Physics: Sharp boundaries and phase transitions create non-differentiable points
Historical Context: Weierstrass and the Monsters
In the 19th century, mathematicians assumed that any continuous function could be differentiated except perhaps at a few isolated points. Then in 1872, Karl Weierstrass shocked the mathematical world by constructing a function that is continuous everywhere but differentiable nowhere.
The Weierstrass Function
Weierstrass showed that the function (for appropriate and ) is continuous everywhere but has a corner at every single point! This "mathematical monster" forced mathematicians to be much more careful about the distinction between continuity and differentiability.
This discovery revealed that continuity and differentiability are fundamentally different properties. Today, we encounter similar issues in practical applications — neural network activation functions like ReLU are continuous but not differentiable at certain points.
What Does Differentiable Mean?
Let's state precisely what it means for a function to be differentiable:
Definition: Differentiability at a Point
A function is differentiable at if the following limit exists and is finite:
This means the limit must:
- Exist (not oscillate or diverge)
- Be the same whether h approaches 0 from the left or right
- Be a finite real number (not ±∞)
What Can Go Wrong?
The derivative at fails to exist when:
| Problem | Description | Example |
|---|---|---|
| Corner/Cusp | Left and right limits exist but differ | f(x) = |x| at x = 0 |
| Vertical Tangent | Limit is infinite (±∞) | f(x) = ∛x at x = 0 |
| Discontinuity | Function not continuous at the point | Step functions |
| Oscillation | Limit doesn't exist (oscillates) | f(x) = sin(1/x) near x = 0 |
Continuity vs Differentiability: A Crucial Distinction
One of the most important relationships in calculus is between continuity and differentiability:
✓ Differentiable ⟹ Continuous
If is differentiable at , then must be continuous at .
Differentiability is a "stronger" condition.
✗ Continuous ⟹ Differentiable
If is continuous at , it does NOT necessarily mean is differentiable there.
Counter-example: f(x) = |x| at x = 0.
Proof: Differentiability Implies Continuity
Goal: Show that if exists, then .
Proof: Write
Taking the limit as :
Therefore , which means is continuous at . ∎
Key Insight
Continuity is necessary but not sufficient for differentiability. Think of it as: you must first pass the continuity test before you can even attempt the differentiability test.
Interactive Exploration
Use the visualizer below to explore different types of non-differentiable points. Watch how the secant line behaves as h → 0 from the left and right, and see why the derivative fails to exist at problem points.
Watch how the secant line behaves as h → 0 from the left or right. A function is differentiable at a point only if both one-sided limits exist and are equal.
Difference Quotient
Analysis
The absolute value function has a sharp corner at x = 0
Key Insight
At a corner, the left-hand derivative exists (here it's -1) and the right-hand derivative exists (here it's +1), but they are not equal. Since the two-sided limit doesn't exist, the function is not differentiable at x = 0.
Corners and Cusps: Sharp Turns in the Graph
Corners: The Classic Example
A corner occurs where the function changes direction abruptly. The most famous example is the absolute value function:
At , the graph forms a "V" shape. Let's check differentiability:
Approaching from the left (h < 0)
Approaching from the right (h > 0)
Since , the two-sided limit doesn't exist. The derivative is undefined.
Cusps: Even Sharper
A cusp is like an extreme corner where the slopes on both sides approach infinity. Consider :
Near , the derivative approaches depending on the direction.
One-Sided Derivatives
To analyze corners and other problematic points, we introduce one-sided derivatives:
Left-Hand Derivative
The slope as we approach from the left (h is negative)
Right-Hand Derivative
The slope as we approach from the right (h is positive)
Differentiability Criterion
A function is differentiable at if and only if:
- The left-hand derivative exists
- The right-hand derivative exists
- They are equal:
Compare the left-hand and right-hand derivatives of f(x) = |x| at x = 0. Watch both secant lines simultaneously as h approaches 0 from each side.
One-Sided Derivative Comparison
Left-Hand Derivative
Right-Hand Derivative
Vertical Tangents: Infinite Slopes
Some functions are continuous and have no corners, yet still fail to be differentiable. Consider the cube root function:
At , the function is continuous and the graph is smooth-looking. But the tangent line becomes vertical:
As :
The derivative formula gives infinity at x = 0, which means the derivative does not exist as a real number. The tangent line is vertical — it has undefined slope.
Vertical vs. Infinite
We don't say the derivative "equals infinity." Infinity is not a real number. Instead, we say the derivative does not exist because the limit is not finite.
Discontinuities: The Prerequisite Fails
Since differentiability requires continuity, any discontinuity automatically prevents differentiability:
Jump Discontinuity
Function "jumps" from one value to another. Example: step function.
✗ Not continuous → Not differentiable
Removable Discontinuity
Function undefined at a point but has a limit. Example: f(x) = x²/x at x = 0.
✗ Not defined → Not differentiable
Infinite Discontinuity
Function approaches ±∞. Example: f(x) = 1/x at x = 0.
✗ Not continuous → Not differentiable
Gallery of Non-Differentiable Points
Six common ways a function can fail to be differentiable at a point. Each represents a different breakdown of the limit definition.
Corner
f(x) = |x|The function changes direction abruptly. The left slope is -1, the right slope is +1.
Cusp
f(x) = x^(2/3)Like a corner, but more extreme. Both sides curve sharply toward a point with infinite slopes.
Vertical Tangent
f(x) = ∛xThe function is smooth and continuous, but the tangent line becomes vertical.
Jump Discontinuity
f(x) = sgn(x)Differentiability requires continuity. A jump makes the derivative undefined.
Wild Oscillation
f(x) = x·sin(1/x)The function oscillates infinitely fast near 0. The difference quotient never settles.
Removable Discontinuity
f(x) = x²/xThe function equals x everywhere except at 0, where it's undefined (hole in graph).
The Common Thread
In every case, the limit limh→0 [f(x+h) - f(x)] / h fails to exist as a single, finite real number. The reason varies — the limit might not exist at all, might be infinite, or might differ depending on the direction of approach — but the result is the same: no derivative at that point.
Analyzing Piecewise Functions
Piecewise functions are especially important to analyze at their "transition points." Here's a systematic approach:
- Check continuity first: Evaluate the left and right limits and the function value. They must all be equal.
- Check left-hand derivative: Compute the derivative of the left piece at the transition point.
- Check right-hand derivative: Compute the derivative of the right piece at the transition point.
- Compare: If left and right derivatives are equal, the function is differentiable.
Example: Analyzing a Piecewise Function
Consider
Step 1: Check continuity at x = 1
- Left limit:
- Right limit:
- Function value:
✓ All equal, so f is continuous at x = 1.
Step 2: Check derivatives
- Left derivative:
- Right derivative:
✓ Both equal 2, so f is differentiable at x = 1 with f'(1) = 2.
Why This Works
Both pieces share the same tangent line at the transition point. The function "smoothly" transitions from one formula to the other.
Machine Learning Applications
Non-differentiable points appear frequently in machine learning, creating both challenges and opportunities.
The ReLU Challenge
The Rectified Linear Unit (ReLU) activation function is the most widely used in deep learning:
This is essentially shifted — it has a corner at !
The Problem
At x = 0, ReLU has left derivative 0 and right derivative 1. The derivative is undefined at exactly the point where neurons "activate."
The Solution
In practice, we use subgradients: arbitrarily define ReLU'(0) = 0 or 1. The probability of landing exactly at x = 0 is negligible, so this works surprisingly well.
Smooth Alternatives
To avoid differentiability issues, researchers have developed smooth approximations:
| Activation | Formula | Differentiable? |
|---|---|---|
| ReLU | max(0, x) | No (corner at 0) |
| Leaky ReLU | max(αx, x) | No (corner at 0) |
| Softplus | log(1 + eˣ) | Yes (smooth) |
| GELU | x · Φ(x) | Yes (smooth) |
| Swish | x · σ(x) | Yes (smooth) |
Why ReLU Still Wins
Despite being non-differentiable, ReLU often outperforms smooth alternatives in practice because:
- It's computationally cheap (just a max operation)
- It doesn't suffer from vanishing gradients for positive inputs
- The non-differentiable point at 0 is rarely an issue numerically
This is a great example of how practical engineering sometimes trumps mathematical elegance!
Python Implementation
Testing Differentiability Numerically
Let's write code to numerically check if a function is differentiable by comparing left and right derivatives:
Activation Functions in Deep Learning
Here's how non-differentiability appears in neural network activation functions:
Common Mistakes to Avoid
Mistake 1: Assuming continuity implies differentiability
Wrong: "The function is continuous at x = 0, so it must be differentiable there."
Correct: Continuity is necessary but not sufficient. You must also check that left and right derivatives exist and are equal. Example: |x| is continuous at 0 but not differentiable.
Mistake 2: Ignoring the direction of approach
Wrong: Computing only one-sided derivative and concluding the derivative exists.
Correct: Always check both left and right limits. The derivative exists only if they're equal.
Mistake 3: Saying derivative equals infinity
Wrong: "The derivative at x = 0 is infinity."
Correct: The derivative does not exist because the limit is infinite. Infinity is not a real number.
Mistake 4: Only checking the formula
Wrong: Taking the derivative formula and evaluating at a problem point without verifying the limit exists.
Correct: For piecewise functions and functions with potential problems, always verify differentiability using the limit definition.
Test Your Understanding
Question 1 of 6
Which of the following is TRUE about the relationship between continuity and differentiability?
Summary
Differentiability is a stronger condition than continuity. A function can be continuous but still fail to be differentiable at corners, cusps, vertical tangents, or discontinuities.
Key Relationships
But the reverse implications do NOT hold!
Key Concepts
| Concept | Description |
|---|---|
| Differentiable at a | lim_{h→0} [f(a+h) - f(a)] / h exists and is finite |
| One-sided derivatives | f'₋(a) from the left, f'₊(a) from the right |
| Criterion for differentiability | f'₋(a) = f'₊(a) and both are finite |
| Corner/Cusp | Left and right derivatives exist but differ (or are infinite) |
| Vertical tangent | Derivative limit is ±∞ |
| Continuity requirement | Must be continuous to be differentiable |
Key Takeaways
- Differentiability implies continuity — but a continuous function need not be differentiable
- At a corner (like |x| at 0), left and right derivatives differ, so the function is not differentiable
- At a vertical tangent (like ∛x at 0), the derivative is infinite, so it doesn't exist as a real number
- Discontinuities prevent differentiability because continuity is a prerequisite
- For piecewise functions, check both continuity and matching derivatives at transition points
- In machine learning, non-differentiable points (like in ReLU) are handled with subgradients or smooth approximations
Coming Next: In the next section, we'll learn the Power Rule — a shortcut that lets us compute derivatives of polynomial functions without using the limit definition. We'll also see the Sum and Constant rules that make differentiation practical.