How Do You Convert a Discrete Function Into a Continuous One?
At a glance
- 1. Identify the data
List the input-output pairs the continuous function must preserve.
- 2. Choose an interpolation
Use straight segments for linear interpolation, or choose a smoother method if needed.
- 3. Define the function
Specify the formula between data points and check that adjacent pieces agree at their endpoints.
- 4. Check the requirements
Confirm continuity, and also check differentiability if the application requires it.
A discrete function gives values only at separate inputs, such as integers or a finite list of sample points. To make a continuous function that agrees with those values, you need to define what happens between the inputs. There is no single correct conversion: linear interpolation, splines, and other rules can all produce different continuous functions.
The usual practical answer is interpolation: keep the given values and fill in the gaps according to a chosen rule. Linear interpolation is the simplest method.
Linear interpolation between data points
Suppose you know two values, and , where . The straight line through and is
This formula gives and . For a sequence of data points , use this formula separately on each interval . The neighboring formulas agree at each shared endpoint , so the resulting piecewise function is continuous there. For finitely many ordered points, this gives a continuous function on . With infinitely many points, continuity at any accumulation point also requires compatible limiting values.
Worked example: extending the values
Suppose the function is known only at integer inputs, with , and you want a continuous function on the real line that matches those values. For each integer , interpolate linearly from to .
The slope on this interval is
Thus, for , define
For example, between and , this gives . Between and , it gives . At every integer , the interval formulas meet at , so is continuous on and agrees with the original values at all integers.
This extension is not the only possibility. The function is also continuous and matches at every integer. The two extensions differ between integers: at , the linear interpolation gives , while gives . The data alone do not determine which behavior between sample points is intended.
Choosing an interpolation method
Use the method that fits the purpose and the information you have:
| Method | What it does | Typical use |
|---|---|---|
| Linear interpolation | Joins consecutive points with straight lines; for finite ordered data, this gives a continuous interpolant | Simple estimates between measurements |
| Polynomial interpolation | Fits a polynomial through the specified points | Small data sets or theoretical constructions |
| Spline interpolation | Joins polynomial pieces smoothly | Smooth curves through measured data |
| A model function | Uses a chosen formula or physical model | When there is a reason to expect a particular shape |
For finite ordered data, linear interpolation gives a continuous function when the pieces share their endpoint values. For infinitely many points, continuity at accumulation points additionally requires compatible limiting values. Linear interpolation generally does not guarantee differentiability at the joining points: the slopes on the two sides may differ. Splines can provide smoother joins, but they require additional choices, such as endpoint conditions.
A distinction about the word “continuous”
If a function’s domain is exactly the integers, continuity has a technical meaning different from extending it to the real line. With the usual topology inherited from , every integer is isolated: a sufficiently small interval around it contains no other integer. Consequently, every function defined on is continuous as a function from to , regardless of its values.
In most practical questions, “convert a discrete function into a continuous one” means: construct a function on an interval or on that preserves the listed values. Interpolation addresses that goal.
For a finite collection of data points, a piecewise-linear extension is always possible. For an infinite set of inputs with accumulation points, matching values and continuity may not always be possible. If inputs approach a point , the values along every sequence of inputs approaching must converge to the same limit. If is one of the specified inputs, that limit must equal its specified value; if is not specified, the limit determines the value a continuous extension must take there. The data must be compatible with continuity at every such accumulation point.
Common mistakes
- Assuming the data determine one curve. They determine values at the given inputs, not between them. State the interpolation or modeling assumption.
- Confusing interpolation with approximation. Interpolation passes through the supplied points. A fitted curve may instead be chosen to track noisy data without passing through every point.
- Assuming a continuous curve is automatically smooth. A piecewise-linear function is continuous, but it can have sharp corners where its slope changes.
- Using a formula outside its intended intervals. A piecewise definition should specify which formula applies on each interval and should agree at shared endpoints.
To build a basic continuous extension, order the known points, connect each adjacent pair with a line segment, and define the resulting piecewise function. Choose a smoother interpolation or a model when the application calls for more than continuity.
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.