Tuesday, August 4, 2026

Odds Ratio (OR), Logistic Regression Interpretation vs. Prediction, and Ordinal Logistic Regression

An odds ratio (OR) measures the association between an exposure and an outcome. It represents the odds that an outcome will occur given a specific exposure, compared to the odds of the outcome occurring in the absence of that exposure.

Here is a breakdown of odds ratios, interpretive logistic regression, and ordinal logistic regression.


1. Odds Ratio (OR)

An odds ratio compares the likelihood of an event happening between two different groups. It is not the same as risk (probability).

Odds vs. Probability

If a horse wins 2 out of 10 races:

  • Probability of winning = 2 / 10 = 20%
  • Odds of winning = 2 to 8 = 2 / 8 = 0.25
Figure 1.1 Probability versus Odds Probability 2 Wins / 10 Races 20% Odds 2 Wins : 8 Losses 0.25
Probability and odds are related but are not the same quantity.

Calculation

OR = (Odds of Event in Group A) / (Odds of Event in Group B)

Interpretation

Odds Ratio Interpretation
OR = 1 The exposure does not affect the odds of the outcome.
OR > 1 The exposure is associated with higher odds of the outcome.
OR < 1 The exposure is associated with lower odds of the outcome.

2. Logistic Regression for Interpretation vs. Prediction

Logistic regression models the probability of a binary outcome (e.g., Yes/No, Success/Failure) using independent variables.

You can use this tool for two completely different goals:

Figure 2.1 Logistic Regression Goals LOGISTIC REGRESSION GOALS INTERPRETATION • Focus: Understanding • Metric: P-values & Odds Ratios • Goal: Explain "Why" 
PREDICTION • Focus: Forecasting • Metric: AUC, ROC, F1 • Goal: Classify "Who"
Logistic regression can be used either for interpretation or prediction.

Interpretation Focus

Goal: Understand the relationship between variables.

Key Metrics: Coefficients (β), p-values, and confidence intervals.

Action: Convert log-odds coefficients into Odds Ratios by exponentiating them (eβ).

Odds Ratio = eβ
Example

"Holding all other variables constant, every one-year increase in age increases the odds of developing heart disease by 1.15 times (OR = 1.15)."

Prediction Focus

Goal: Accurately classify new, unseen data into a category.

Key Metrics: Accuracy, Precision, Recall, ROC-AUC, and F1-score.

Action: Use the model output to generate a probability score between 0 and 1, then apply a threshold (such as 0.5) to label the data.

Example

"Based on this patient's medical data, there is an 87% chance they have heart disease, so we classify them as High Risk."
Figure 2.2 Prediction Workflow Input Features ->Probability-> Predicted Class
Logistic regression prediction workflow.

3. Ordinal Logistic Regression

Standard logistic regression only works for two categories.

Ordinal logistic regression is used when the dependent variable is categorical and has a natural, ordered ranking, but the distance between the ranks is unknown.

Examples of Ordinal Variables

  • Credit scores (Poor, Fair, Good, Excellent)
  • Survey responses (Strongly Disagree, Disagree, Agree, Strongly Agree)
  • Medical conditions (Mild, Moderate, Severe)
Example Ordered Categories
Credit Score Poor → Fair → Good → Excellent
Survey Response Strongly Disagree → Disagree → Agree → Strongly Agree
Medical Condition Mild → Moderate → Severe

How it Works (Proportional Odds Model)

Instead of predicting a single probability, ordinal logistic regression evaluates cumulative probabilities. It looks at the odds of being in a category or lower versus being in a higher category.

Figure 3.1 Cumulative Probabilities in Ordinal Logistic Regression Mild , Moderate , Severe
Ordinal logistic regression models cumulative probabilities across ordered categories.

The Assumption

It assumes that the effect of an independent variable is the same across all category cutoffs.

For example, if smoking increases the odds of moving from "Mild" to "Moderate" disease by 2.0, it must also increase the odds of moving from "Moderate" to "Severe" disease by 2.0.

Important Note

This assumption is known as the parallel lines assumption or the proportional odds assumption.
Summary

  • An Odds Ratio (OR) compares the odds of an event occurring between two groups.
  • Logistic regression can be used either for interpretation (understanding relationships) or prediction (classifying new observations).
  • Ordinal logistic regression extends binary logistic regression to ordered categorical outcomes by modeling cumulative probabilities under the proportional odds assumption.

Backpropagation vs. Gradient Descent in Linear and Logistic Regression


Note that the term "backpropagation" is technically not used for standard linear or logistic regression. Instead, we simply call the optimization process Gradient Descent.


Backpropagation is also related to vanishing gradient.  Vanishing gradient can occur only across multiple layers. Thus both backpropagation and vanishing gradient are related to multiple layers only, then are never used for single layer models.

Important Note

The word propagation implies a sequence of layers. Because linear regression and logistic regression contain only a single layer of weights, there is no sequence of layers through which errors can propagate backward.

What is Backpropagation?

Backpropagation is short for "backward propagation of errors." It is an algorithm specifically designed for multi-layer neural networks.

The Sequence

It uses the mathematical Chain Rule to calculate gradients. It starts at the final output layer, computes the error, and then passes (propagates) that error backward, layer by layer, to update the weights at the very beginning of the network.

During backpropagation, the error is propagated backward through multiple layers using the Chain Rule.

Why the Confusion in Linear and Logistic Regression?

You might hear people use the term loosely in linear or logistic regression for two main reasons:

1. Neural Network Equivalent

A logistic regression model is mathematically identical to a single-neuron neural network with a sigmoid activation function.

2. The "One-Step" Chain Rule

Even in logistic regression, you use a small version of the Chain Rule. To find how the loss changes with respect to the weights,

∂Loss / ∂W = (∂Loss / ∂Prediction) × (∂Prediction / ∂Score) × (∂Score / ∂W)

Because this calculation proceeds backward from the Loss to the Weights, some instructors casually refer to it as "backpropagation", even though it only spans a single layer.

Logistic regression applies the Chain Rule over a single layer rather than propagating errors through multiple layers.

Summary of Terms

Term Definition Used In
Gradient Descent The overall optimization algorithm used to update weights to minimize error. Linear regression, logistic regression, and neural networks.
Backpropagation The specific method used inside gradient descent to calculate gradients across multiple sequential layers. Multi-layer neural networks.
Key Takeaway

Gradient Descent is the optimization algorithm that updates model parameters to minimize the loss function. Backpropagation is the gradient-computation algorithm used within gradient descent for multi-layer neural networks. In standard linear regression and logistic regression, we typically refer only to Gradient Descent, since there are no multiple layers through which errors must propagate.

Monday, August 3, 2026

Mathematical Transformations

A mathematical transformation is a function T that maps elements from an initial set (domain) to another set (codomain), modifying inputs into outputs according to a strict mathematical rule.

In geometry and linear algebra, it maps vectors or points from one vector space to another, written as:

T : VW
Here V is the domain, W is the Codomain and T is the function that maps V to W.

2. Linear vs. Non-Linear Transformations

The fundamental division between transformations relies on two algebraic rules:

  • Additivity
    T(u + v) = T(u) + T(v)
  • Homogeneity
    T(cu) = cT(u)

Linear Transformations

Linear transformations satisfy both conditions.

  • They always map the origin to itself.
  • T(0) = 0
  • They map straight lines to straight lines.
  • They keep grid lines straight and parallel.
  • They can always be expressed as a matrix multiplication:
    T(x) = Ax

Non-Linear Transformations

Non-linear transformations fail at least one condition.

  • They curve the underlying space.
  • They warp grid lines.
  • They move the origin.
  • Examples include squaring coordinates:
    T(x, y) = (x2, y)
  • Or adding constants:
    T(x) = x + b
    (which is an affine transformation, not strictly linear).
Property Linear Transformation Non-Linear Transformation
Additivity ✔ Satisfied ✘ Violated
Homogeneity ✔ Satisfied ✘ Violated
Origin Preserved May Move
Grid Lines Remain Straight May Warp
Matrix Representation Always Possible Generally Not Possible

3. Standard 2D Linear Geometric Transformations

In a two-dimensional Cartesian plane, standard linear transformations alter the spatial properties of shapes and can be written using a 2 × 2 matrix:

[ x′ ]  =  [ a  b ] [ x ]
[ y′ ]      [ c  d ] [ y ]
Note

Use arrow keys to adjust value.

0:00 / 1:01

Audio made with Google AI. Image licensed by Google.

Scaling

Stretches or shrinks coordinates along axes.

sx 0
0 sy

Rotation

Rotates points counterclockwise around the origin by an angle θ.

cos θ − sin θ
sin θ cos θ

Shearing

Slants one coordinate axis parallel to another based on a factor k.

Horizontal Shear

1 k
0 1

Vertical Shear

1 0
k 1

Reflection

Flips the space across a line passing through the origin.

Across the x-axis:

1 0
0 −1
Note

Translation—sliding an object—is geometric but requires a 3 × 3 matrix with homogeneous coordinates to be handled linearly because it moves the origin.
Figure 3.1 — Examples of scaling, rotation, shearing, and reflection in two-dimensional space.

4. Non-Geometric Transformations

Non-geometric transformations modify the properties or data structures of elements rather than their spatial positions, shapes, or orientations.

Transformation Type Description Examples
Data Transformations Converting variable distributions in statistics. Logarithmic transformation (log(x)) or Z-score normalization.
Color Space Transformations Converting digital imagery pixels from one color representation to another. RGB → CMYK or YCbCr color spaces.
Domain Transformations Changing the functional domain of an equation. Fourier Transform or Laplace Transform for mapping time-domain signals to the frequency domain.
Cryptographic Transformations Permuting and substituting data bytes to encrypt plain text into ciphertext. Algorithms such as AES.
Important Note

Unlike geometric transformations, non-geometric transformations change the underlying data, representation, or mathematical domain without necessarily altering the physical position or shape of objects.

Prompt Engineering

Prompt Engineering Frameworks Comparison
Category Framework Components / Meaning Best Use Case
1. General & Professional Tasks
General & Professional Tasks RACE Role, Action, Context, Expectation 80% of daily professional tasks
General & Professional Tasks RTF Role, Task, Format Most minimalist and fastest framework to use
General & Professional Tasks TAG Task, Action, Goal Quick, objective-driven assignments
2. Marketing, Creative, & Communication
Marketing, Creative, & Communication CO-STAR Context, Objective, Style, Tone, Audience, Response Gold standard for high-stakes copywriting and content creation
Marketing, Creative, & Communication CRISPE Capacity/Role, Response, Insight, Scope, Personality, Experiment Developed internally by OpenAI circles for detailed outputs
Marketing, Creative, & Communication CREATE Context, Role, Explicit instructions, Attributes, Target audience, Execute Audience-centric copy and tailored messaging
3. Technical, Analytical, & Deep Research
Technical, Analytical, & Deep Research RISEN Role, Instructions, Steps, End goal, Narrowing constraints Project roadmaps or complex execution plans
Technical, Analytical, & Deep Research RTCROS Role, Task, Context, Resources, Output, Success criteria Production-grade AI features (matches with constraints, commands, resources, rules and performance evaluation) 
Technical, Analytical, & Deep Research CLEAR Context, Limits, Emphasis, Alignment, Review Strategic research and highly regulated topics
4. Advanced "Reasoning" Frameworks
Advanced "Reasoning" Frameworks Chain-of-Thought (CoT) Architectural behavioral method Forces the AI to show its step-by-step reasoning before outputting a final answer.
Advanced "Reasoning" Frameworks Tree-of-Thought (ToT) Architectural behavioral method Guides the AI to evaluate multiple different solution paths simultaneously, self-correcting as it goes.
Advanced "Reasoning" Frameworks ReAct Reasoning + Acting Prompts the AI to alternate between "thinking" about a problem and "acting" (e.g., searching the web, running code).

Prompt Components: Constraints, Commands, Resources, Rules, and Performance Evaluation

A prompt can consist of constraints, commands, resources, rules, and performance evaluation. While a basic prompt might only be a simple question, advanced prompt engineering frameworks frequently use these exact five components to obtain high-quality, predictable outputs from AI models.

Key Idea

Advanced prompt engineering frameworks extend beyond a simple instruction by defining what the AI should do, what limitations it must follow, what information it can use, what rules it must obey, and how the final output will be evaluated.

Component Breakdown

Component Description Example
Commands The core instruction telling the AI what to do. "Write," "Analyze," "Summarize"
Constraints The boundaries or limits placed on the output. "Under 500 words," "Do not use jargon," "Format as markdown"
Resources The background data, context, or examples provided to help the AI understand the task. "Based on the attached CSV file," "Use the following style guide"
Rules The logical guidelines or conditional policies the AI must follow while processing the request. "If the sentiment is negative, escalate to human tone," "Always verify facts before listing them"
Performance Evaluation The criteria or rubric used to tell the AI how its output will be judged, often used in iterative prompts. "Your output will be scored on clarity, accuracy, and conciseness from 1 to 5"
  • Commands:What to do 
  • Constraints: Limits 
  • Resources: Context 
  • Rules: Policies 
  • Performance Evaluation: Quality Criteria
Important Note

Although a simple prompt may contain only a question or instruction, advanced prompt engineering frameworks typically combine these five components to produce more accurate, consistent, and predictable AI responses.

Sunday, August 2, 2026

The Sigmoid Function: Definition, Properties, Applications, and Evolution

1. The Sigmoid Function: Definition, Properties, and Universality

Mathematical Definition

The standard logistic sigmoid function maps any real-valued number into a strict probability-like range between 0 and 1.

σ(x) = 1 1 + e-x

The Derivative

Using the quotient rule and the chain rule, the derivative simplifies into a remarkably elegant, self-referential expression where the slope is computed directly from the value of the sigmoid itself.

σ′(x) = σ(x) (1 − σ(x))

Why Euler's Number (e) is Used

While any exponential base (such as 2-x or 10-x) could theoretically be used, Euler's number (e ≈ 2.71828) is universally chosen for deep mathematical reasons.

The Natural Derivative

The derivative of ex is exactly ex. This unique property eliminates unwanted scaling constants such as ln(2) or ln(10), making the derivative beautifully simple and computationally efficient during backpropagation.

Information Theory & Physics

The base e naturally appears in the Boltzmann distribution in statistical physics and in log-odds (logits) in statistics. It represents the natural rate of continuous growth and maximum entropy, making it the mathematically preferred choice for probabilistic modeling.

Universal Significance of the Sigmoid Function

Why the Sigmoid Function Is So Widely Used

The sigmoid function is much more than just another mathematical equation. It possesses several unique properties that make it one of the most important functions in statistics, probability, machine learning, and deep learning.

  • Smooth Thresholding
    It acts as a continuous, differentiable alternative to a hard step function. Instead of abruptly switching from 0 to 1, it transitions smoothly, making gradient-based optimization possible.
  • Probability Mapping
    It transforms unconstrained real numbers ranging from
    −∞   to   +∞
    into valid probabilities between
    0   and   1
    making it ideal for probabilistic prediction.

2. Why the Derivative Is Not a True Parabola

The derivative of the sigmoid function is written as

σ′(x) = σ(x) (1 − σ(x))

At first glance, this expression resembles the quadratic form

σ − σ2

Since this resembles the familiar equation x − x2, many beginners assume the derivative must be a parabola. Although the algebraic form appears similar, the geometric behavior is completely different.

The Input Variable Matters

A true parabola is defined directly as a polynomial in the horizontal variable.

f(x) = x − x2

Here, the independent variable x appears directly as a polynomial. Consequently, the graph follows the familiar parabolic shape.

In contrast, the sigmoid derivative is ultimately a function of x through the exponential term e−x. Therefore, the horizontal axis is not related polynomially to the output.

The Exponential Constraint

Inside the sigmoid function, the input variable appears inside an exponential:

σ(x) = 1 1 + e−x

Because of this exponential dependence, the rate of change grows and decays exponentially rather than polynomially.

As a result, the derivative cannot produce the infinitely expanding shape associated with a geometric parabola.

The Geometric Result

Instead of expanding outward forever, the exponential terms continuously bend the curve inward.

The curve gradually flattens on both sides, producing a smooth, symmetric, bell-shaped distribution.

Mathematically, this curve is a hyperbolic secant squared function rather than a parabola.

Visual Comparison: Parabola vs. Sigmoid Derivative

True Parabola Sigmoid Derivative
Key Observation

Although the derivative contains an algebraic expression that resembles a quadratic function, its dependence on the exponential term e−x causes the graph to become a bounded bell-shaped curve rather than an unbounded parabola.

3. Core Applications: Logistic Regression and Neural Networks

Why the Sigmoid Function Became So Important

The sigmoid function became one of the most influential mathematical functions in Machine Learning because it naturally converts unrestricted real-valued numbers into probabilities.

This single property makes it extremely useful in both statistical machine learning and artificial neural networks.

Logistic Regression (Statistical Machine Learning)

In binary classification problems, an algorithm must predict a probability between 0 and 1.

Examples include determining whether:

  • Email → Spam or Not Spam
  • Patient → Disease Present or Healthy
  • Transaction → Fraudulent or Genuine
  • Student → Pass or Fail

Step 1 — Linear Model Produces a Raw Score

A linear model first computes a raw numerical score known as the logit.

z = β0 + β1x1 + β2x2 + ··· + βnxn

This value may lie anywhere between −∞ and +∞.

Step 2 — Apply the Sigmoid Function

The raw score is then passed through the sigmoid function.

P = 1 1 + e−z

The output is now guaranteed to lie between 0 and 1, allowing it to be interpreted as a probability.

Step 3 — Make the Final Prediction

A threshold is then applied.

  • If the probability is ≥ 0.5, predict Class 1.
  • If the probability is < 0.5, predict Class 0.

Logistic Regression Pipeline

Input Features Logit (z) Sigmoid Probability Class

Activation Functions in Neural Networks

Early neural networks adopted the sigmoid function because it provides a simple mathematical approximation of how biological neurons behave.

Biological Analogy

  • A biological neuron receives electrical signals from many other neurons.
  • It accumulates these incoming signals.
  • When the accumulated signal exceeds a threshold, the neuron fires.

Mathematical Interpretation

The sigmoid function acts as a smooth mathematical gate that determines how much information should pass from one layer of neurons to the next, depending on the strength of the incoming signal.

Sigmoid as an Activation Function

σ Activation Output

4. The Vanishing Gradient Problem and the Evolution of Activation Functions

The Vanishing Gradient Problem

Although the sigmoid function is mathematically elegant, it introduces a major difficulty when training deep neural networks.

The maximum value of the sigmoid derivative occurs at x = 0, where

σ′(0) = 0.25

As the input moves away from zero in either direction, the sigmoid curve gradually flattens and its derivative rapidly approaches zero.

During backpropagation, gradients from deeper layers are multiplied together while moving toward earlier layers.

Since each sigmoid derivative is at most 0.25, repeatedly multiplying these small values causes the gradient to shrink exponentially.

Result

By the time the gradient reaches the earliest layers of a deep network, it has effectively become zero. Consequently, those layers stop learning because their weights receive almost no updates.

Mathematical Intuition

Suppose a network contains several hidden layers. During backpropagation, the gradient reaching an early layer is roughly the product of all the derivatives encountered along the path.

Gradient = σ′1 × σ′2 × σ′3 × ··· × σ′n

If every derivative is smaller than 0.25, the product decreases exponentially as the number of layers increases.

Example of Gradient Shrinkage

Consider a simplified network in which each layer contributes a gradient of approximately 0.2.

Layer Approximate Gradient
Layer 4 0.20
Layer 3 0.04
Layer 2 0.008
Layer 1 Almost 0 (Vanished)

Gradient Flow Through a Deep Neural Network

Layer 4 Gradient ≈ 0.20 Layer 3 Gradient ≈ 0.04 Layer 2 Gradient ≈ 0.008 Layer 1 Vanished

Why Learning Stops

Neural networks learn by updating their weights using gradients computed during backpropagation.

If the gradient reaching a layer becomes extremely small, the weight updates become almost zero.

As a result, the earliest layers stop learning useful features even though the later layers continue to update.

Key Consequence

This inability to update the early layers severely limits the training of very deep neural networks and was one of the primary motivations for developing newer activation functions.

How Other Activation Functions Solve the Vanishing Gradient Problem

To overcome the vanishing gradient problem, modern deep learning relies on activation functions that preserve stronger gradients during backpropagation.

Instead of rapidly flattening like the sigmoid function, these activations maintain a larger derivative over a wider range of inputs, allowing information to propagate efficiently through very deep neural networks.

ReLU (Rectified Linear Unit)

The Rectified Linear Unit (ReLU) is defined as:

f(x) = max(0, x)

For any positive input, the derivative of ReLU is a constant 1.

Because a gradient of 1 does not shrink during multiplication, it can travel through hundreds of layers without vanishing, making ReLU the default activation function in many deep neural networks.

Tanh (Hyperbolic Tangent)

The hyperbolic tangent function scales inputs into the range:

−1    to    +1

Its maximum derivative is 1.0 (at x = 0), allowing gradients to flow more effectively than with the sigmoid function.

However, tanh still saturates for very large positive and negative inputs, so its gradients also become extremely small in those regions.

Activation Output Range Maximum Derivative Main Characteristic
Sigmoid 0 to 1 0.25 Good for probabilities but suffers from vanishing gradients.
Tanh −1 to 1 1.0 Improves gradient flow but still saturates.
ReLU 0 to ∞ 1.0 Fast training and excellent gradient propagation.

The Dying ReLU Problem

Although ReLU effectively prevents vanishing gradients for positive inputs, it introduces another limitation.

Whenever the input is negative, the output becomes 0 and the derivative is also exactly 0.

If a neuron continually receives negative inputs, it always produces zero output. Consequently, its gradient remains zero, its weights stop updating, and the neuron permanently stops contributing to the network.

Result

The neuron becomes permanently inactive, a phenomenon commonly known as the Dying ReLU Problem.

Solutions to the Dying ReLU Problem

Leaky ReLU

Instead of forcing every negative input to zero, Leaky ReLU assigns a small non-zero slope.

f(x) = 0.01x    for    x < 0

This ensures that a small gradient (approximately 0.01) always flows backward, allowing inactive neurons to recover during training.


GELU (Gaussian Error Linear Unit)

GELU combines the behavior of ReLU with a probabilistic weighting based on a Gaussian distribution.

Instead of introducing a sharp transition at zero, GELU provides a smoother activation function that has become the dominant choice in modern Transformer architectures and Large Language Models (LLMs).

Summary

The mathematical elegance of the sigmoid function relies on Euler's number (e) to create clean probabilistic outputs.

Although its derivative has an algebraic expression that resembles a parabola, the exponential nature of the sigmoid function causes the derivative to form a bell-shaped curve rather than a true parabola.

As neural networks became deeper, the sigmoid function's rapidly shrinking derivative led to the vanishing gradient problem, motivating the development of improved activation functions such as ReLU, Leaky ReLU, and GELU that maintain stronger gradients during training.

Friday, July 31, 2026

Understanding Limits, Continuity and Differentiability

Relationship, Hierarchy, and Conditions for Non-Differentiability
Note

The discussion below explains the relationship between limits, continuity and differentiability, together with important examples illustrating when differentiability fails. All mathematical expressions have been formatted using pure HTML so that the article remains fully compatible with Blogger without requiring MathJax, KaTeX or JavaScript.
1. Limits are not the same as derivatives

A derivative is defined using a limit, but the existence of a limit alone does not imply the existence of a derivative.

f(a) = limh→0 f(a+h) − f(a) h

Notice that this is a very specific limit (called the difference quotient).

A function may have an ordinary limit

limx→a f(x)

while the derivative does not exist.

Example
Definition
f(x) = |x|

At x = 0,

limx→0 |x| = 0

exists.

Graph of f(x) = |x|
x y (0,0)
Observation

The graph is continuous, but there is a sharp corner at the origin. This geometric feature prevents the derivative from existing at x=0 even though the limit exists.

But

limh→0 |h| − 0 h

does not exist because

One-Sided Limit Value
Left-hand limit −1
Right-hand limit 1
Important
  • Left-hand derivative = −1
  • Right-hand derivative = 1
  • Since the two one-sided derivatives are different, the derivative does not exist.

Hence

Property Result
Limit exists
Derivative exists
Conclusion

Your first statement is correct. The existence of an ordinary limit does not guarantee the existence of a derivative. A derivative requires the existence of a very specific limit—the difference quotient—which is a much stronger condition than the ordinary limit.


2. Order of Strictness

The proper hierarchy is

Differentiable->   Continuous->   Limit Exists

Every differentiable function is continuous.

Every continuous function has a limit equal to the function value.

The converse of none of these is true.

Key Observation

Differentiability is the strongest property. Continuity is weaker than differentiability. The existence of a limit is weaker than continuity. Therefore,

Limit Exists ->Continuous (Stronger) ->   Differentiable (Strongest)
Therefore

(i) Limit exists

(ii) Function may still not be continuous because

limx→a f(x)

may exist but

f(a) ≠ limx→a f(x)

or f(a) may not even exist.

Example
f(x) =
{ 1,  x = 0
0,  x ≠ 0

Here

limx→0 f(x) = 0

exists,

but

f(0) = 1

Hence not continuous.

Graph of the Piecewise Function
x y (0,1) Limit = 0
Observation

Every point except the origin lies on the horizontal line y = 0. As x approaches 0 from either side, the function approaches 0. However, the actual value of the function at the origin is f(0)=1, shown by the filled red point. Therefore, the limit exists, but the function is not continuous.

(iii) Even if continuous, the derivative may not exist.

Example
f(x) = |x|

Continuous everywhere.

Not differentiable at 0.

Geometric Interpretation
Left slope = −1 Right slope = 1
Conclusion

The function is perfectly continuous, yet its graph contains a sharp corner. The left-hand and right-hand slopes are different, so the derivative does not exist at the origin.


3. When is a Function Not Differentiable?
(i) Not Continuous

Correct.

Differentiability always implies continuity.

Differentiable  ⇒  Continuous

Therefore,

Logical Consequence

If a function is discontinuous, then it cannot be differentiable.

Summary

Discontinuous  ⇒  Not Differentiable


(ii) Sharp Corner (Corner Point)

Correct.

Example

f(x) = |x|

Left slope

= −1

Right slope

= 1

Hence the derivative does not exist.

Corner Geometry
Sharp Corner
Observation

Although the graph is continuous, the slope changes abruptly at the corner. Since the left-hand and right-hand derivatives are unequal, the derivative does not exist.


(iii) Vertical Tangent

Mostly correct.

Example

f(x) = x1/3

The derivative is

f(x) = 1 3x2/3

At

x = 0

the derivative becomes infinite.

Important

Most elementary calculus books simply state that the derivative does not exist at this point. Geometrically, however, the tangent line is vertical.

Graph of f(x) = x1/3
Vertical Tangent (0,0) x y
Geometric Interpretation

Unlike a corner, the graph remains smooth. However, the tangent becomes perfectly vertical at the origin. Since the slope tends to positive infinity, the ordinary finite derivative does not exist.


(iv) Wild Oscillation

Correct.

Example

f(x) = x sin ( 1 x )

At 0, define

f(0)=0

The function is continuous.

But

f(0)= limh→0 f(h)-f(0) h

Substituting f(h)=h sin(1/h) and f(0)=0,

f(0)= limh→0 sin ( 1 h )

does not exist because

Observation

As h approaches zero, the quantity 1/h becomes arbitrarily large. Consequently, the value of sin(1/h) oscillates endlessly between −1 and 1 without approaching any single value. Therefore, the required limit does not exist.

Graph of f(x) = x sin(1/x)
(0,0) Oscillation continues indefinitely
Conclusion

The function itself approaches the origin continuously. However, its slope oscillates infinitely rapidly near the origin. Since the derivative limit fails to converge, the derivative does not exist.


4. Examples

Let's examine each one.

(i) f(x) = |x|

Correct.

Continuous.

Not differentiable at 0.

Reason: corner.

Key Point

The function is perfectly continuous because there is no break in its graph. However, the graph changes direction abruptly at the origin. The left-hand derivative is −1 while the right-hand derivative is 1. Since these one-sided derivatives are unequal, the derivative does not exist.

Visual Interpretation of the Corner
Left slope = −1 Right slope = 1 Corner
(ii) x sin(π/x)

(assuming f(0)=0).

Continuous.

Not differentiable at 0.

Reason: oscillation.

Observation

Although the function itself approaches the origin continuously, its slope oscillates increasingly rapidly near the origin. Therefore, the derivative fails to converge even though the function remains continuous.

Graph of f(x) = x sin(π/x)
Oscillation near the origin

(iii) Weierstrass Function

This is one of the most famous examples.

Properties
  • Continuous everywhere.
  • Differentiable nowhere.
Illustration of a Weierstrass-Type Curve
Continuous but Nowhere Differentiable
Important Observation

The graph never contains any breaks or jumps, so it is continuous everywhere. However, no matter how much the graph is magnified, it never becomes locally straight. Consequently, no unique tangent exists at any point.


(iv) Blancmange Function

Also called the Takagi function.

Properties
  • Continuous everywhere.
  • Differentiable nowhere.
Illustration of the Blancmange (Takagi) Function
Self-Similar Fractal Structure
Observation

The Blancmange function exhibits self-similarity at different scales. Although it is continuous everywhere, it has no well-defined derivative at any point.


(v) Koch Snowflake

This one needs a small correction.

Important Correction

The Koch snowflake is not a function. Instead, it is a fractal curve. Therefore, we do not normally discuss its differentiability as a function of the form y = f(x).

More precisely,

  • The boundary of the Koch snowflake is a continuous curve.
  • It has no well-defined tangent at any point.
  • Consequently, it is regarded as a nowhere-differentiable curve.
Illustration of the Koch Snowflake Boundary
Continuous Fractal Curve
Why it is Different

Unlike the previous examples, the Koch snowflake does not represent a single-valued function. Instead, it is studied as a geometric curve. Its boundary is continuous, but nowhere smooth, making it an important example in fractal geometry.


One More Important Example

There is another classic example.

f(x) = x2/3

At x = 0, the graph has a cusp.

The derivative approaches

  • +∞ from one side,
  • −∞ from the other side.

Therefore, the derivative does not exist.

Key Observation

A cusp is fundamentally different from a corner. The graph remains continuous, but the tangent direction changes infinitely rapidly, producing infinite slopes with opposite signs.


Corner vs Cusp vs Vertical Tangent

Although all three situations result in the derivative not existing, they are geometrically very different. Understanding these differences is essential in elementary calculus.

Summary
  • Corner: Finite one-sided derivatives exist but are unequal.
  • Cusp: One-sided derivatives become infinite with opposite signs.
  • Vertical Tangent: Both one-sided derivatives approach the same infinite value.
Visual Comparison
Corner Cusp Vertical Tangent Left slope ≠ Right slope −∞ and +∞ slopes Same infinite slope
Important Distinction

Although all three graphs are continuous, the derivative fails for different geometric reasons. A corner has two different finite slopes. A cusp has two infinite slopes with opposite signs. A vertical tangent has infinite slopes of the same sign. Recognizing these differences is extremely important when studying differentiability.


Summary Hierarchy

The relationship between limits, continuity and differentiability can now be summarized as follows.

Differentiable Continuous Limit Exists

Differentiable → Continuous → Limit Exists

Key Implication

Every differentiable function is automatically continuous. Likewise, every continuous function automatically has a limit equal to the function value. However, the converse implications are not true.

Important Note

A function may possess a limit without being continuous. Similarly, a function may be continuous without being differentiable. Therefore, each property is stronger than the one below it in the hierarchy.


Converse Implications are False

The hierarchy

Differentiable  ⇒  Continuous  ⇒  Limit Exists

does not work in the reverse direction.

Differentiable Continuous Limit Exists False False
Common Misconception

Many students mistakenly assume that if a function is continuous, it must also be differentiable. The absolute value function, f(x) = |x|, is an immediate counterexample. Likewise, the existence of a limit alone does not guarantee continuity.


Complete Summary

A function may fail to be differentiable because of the following reasons.

  1. Discontinuity ✓
  2. Corner (sharp turn) ✓
  3. Cusp ✓
  4. Vertical tangent ✓
  5. Wild oscillation ✓
  6. Fractal behavior (for example, the Weierstrass or Blancmange function) ✓
Appendix A — Common Misconceptions
Misconception Reality
If the limit exists, the function is continuous. False. The function value must also equal the limit.
If a function is continuous, it is differentiable. False. The graph may contain a corner, cusp or vertical tangent.
Infinite derivative means derivative exists. False. Elementary calculus requires a finite derivative.
Every continuous curve represents a function. False. The Koch snowflake is a continuous curve but not a function y=f(x).
Appendix B — How to Test Differentiability
Does the limit exist? Is f(a)=Limit? Continuous? Compare Left and Right Derivatives If equal → Differentiable Otherwise examine Corner • Cusp • Vertical Tangent • Oscillation
Revision Cheat Sheet
  • Derivative is defined using a limit.
  • Every differentiable function is continuous.
  • Every continuous function has a limit equal to its function value.
  • The converse of both statements is false.
  • Discontinuity always destroys differentiability.
  • Corner → unequal finite slopes.
  • Cusp → opposite infinite slopes.
  • Vertical tangent → same infinite slope.
  • Oscillation → derivative limit fails to converge.
  • Weierstrass and Blancmange functions are continuous everywhere but differentiable nowhere.
  • Koch snowflake is a fractal curve, not a function.
Practice Questions
  1. Give an example of a function whose limit exists but which is not continuous.
  2. Give an example of a function that is continuous but not differentiable.
  3. Why does |x| fail to be differentiable at x = 0?
  4. Differentiate between a corner and a cusp.
  5. What is meant by a vertical tangent?
  6. Explain why x sin(1/x) is continuous but not differentiable at x = 0.
  7. State the hierarchy relating limits, continuity and differentiability.
  8. Why is the Koch snowflake not considered a function?
  9. Name two famous functions that are continuous everywhere but differentiable nowhere.
  10. Give one real-life application where differentiability is important.

Odds Ratio (OR), Logistic Regression Interpretation vs. Prediction, and Ordinal Logistic Regression

An odds ratio (OR) measures the association between an exposure and an outcome. It represents the odds that an outcome will occur given ...