Linear Interpolation Calculator

Estimate unknown values between two known data points using the linear interpolation formula. Essential for engineering, data analysis, and scientific applications.

Results

Calculated
Interpolated Y Value
0
Y = Y1 + (X - X1) * (Y2 - Y1) / (X2 - X1)
Slope (m)
0
Rate of change
Interpolation Range
-
X1 to X2

Calculation Steps

Enter values and click Calculate to see the step-by-step solution.

Key Takeaways

  • Linear interpolation estimates values between two known data points assuming a straight-line relationship
  • The formula is Y = Y1 + (X - X1) * (Y2 - Y1) / (X2 - X1)
  • Also known as "lerp" in programming and computer graphics applications
  • Works best when data changes linearly; use polynomial or spline interpolation for curved data
  • Extrapolation (values outside the range) is possible but less accurate than interpolation
  • Essential technique in engineering, finance, data science, and game development

What Is Linear Interpolation? A Complete Explanation

Linear interpolation is a mathematical technique used to estimate an unknown value that lies between two known data points. The method assumes that the relationship between these points is linear, meaning the data changes at a constant rate and can be represented by a straight line connecting the two points.

Imagine you have two temperature readings: 20 degrees Celsius at 8:00 AM and 30 degrees Celsius at noon. If someone asks what the temperature was at 10:00 AM, linear interpolation assumes the temperature increased steadily and estimates it was 25 degrees Celsius - exactly halfway between the two readings because 10:00 AM is halfway between 8:00 AM and noon.

The term "interpolation" comes from the Latin word "interpolare," meaning to refurbish or alter. In mathematics, it specifically refers to constructing new data points within the range of a discrete set of known data points. Linear interpolation is the simplest form of interpolation, using a first-degree polynomial (a straight line) to estimate values.

Why Linear Interpolation Matters

Linear interpolation is everywhere in modern technology. Your GPS uses it to smooth your position between satellite readings. Video games use it constantly for smooth animations. Engineers use it to read values from tables. Financial analysts use it for yield curve calculations. Understanding this concept opens doors to countless applications across science and technology.

The Linear Interpolation Formula Explained

The standard linear interpolation formula calculates the Y value for a given X that lies between two known points (X1, Y1) and (X2, Y2):

Y = Y1 + (X - X1) * (Y2 - Y1) / (X2 - X1)
Y = Interpolated result (unknown value)
X = The point where you want to find Y
(X1, Y1) = First known data point
(X2, Y2) = Second known data point

Alternative Forms of the Formula

The linear interpolation formula can be expressed in several equivalent ways depending on the context:

Slope-Point Form: Y = Y1 + m(X - X1), where m = (Y2 - Y1)/(X2 - X1) is the slope

Parametric Form (LERP): Y = Y1 + t(Y2 - Y1), where t = (X - X1)/(X2 - X1) ranges from 0 to 1

Weighted Average Form: Y = (1-t) * Y1 + t * Y2, commonly used in computer graphics

Pro Tip: Understanding the Parameter t

The parameter t represents the "position" between your two points. When t = 0, you get Y1. When t = 1, you get Y2. When t = 0.5, you get the exact midpoint. This parametric understanding is crucial for animation, graphics programming, and understanding interpolation intuitively.

How to Calculate Linear Interpolation (Step-by-Step)

Step-by-Step Linear Interpolation Guide

1

Identify Your Known Points

Gather the coordinates of your two known data points: (X1, Y1) and (X2, Y2). For example: Point 1 is (2, 10) and Point 2 is (8, 40). Also identify the X value where you want to find Y, such as X = 5.

2

Calculate the Slope

Find the slope (rate of change) using m = (Y2 - Y1) / (X2 - X1). In our example: m = (40 - 10) / (8 - 2) = 30 / 6 = 5. This means Y increases by 5 for every 1 unit increase in X.

3

Calculate the X Difference

Subtract X1 from your target X value: (X - X1) = (5 - 2) = 3. This tells you how far your target point is from the first known point.

4

Apply the Formula

Calculate Y = Y1 + slope * (X - X1). In our example: Y = 10 + 5 * 3 = 10 + 15 = 25. The interpolated Y value at X = 5 is 25.

5

Verify Your Result

Check that your result makes sense: Y should be between Y1 and Y2 (if X is between X1 and X2). Our result of 25 is indeed between 10 and 40, so it's reasonable.

Practical Examples of Linear Interpolation

Example 1: Temperature Estimation

Scenario: A weather station recorded 20C at 8:00 AM (X1=8, Y1=20) and 32C at 2:00 PM (X2=14, Y2=32). What was the temperature at 11:00 AM (X=11)?

Step 1: Known points: (8, 20) and (14, 32)
Step 2: Slope = (32 - 20) / (14 - 8) = 12 / 6 = 2C per hour
Step 3: X difference = 11 - 8 = 3 hours
Step 4: Y = 20 + 2 * 3 = 20 + 6 = 26C

Answer: The estimated temperature at 11:00 AM was 26C

The temperature rose by 2 degrees each hour, so 3 hours after 8 AM (at 11 AM), it would be 6 degrees warmer than 20C.

Example 2: Engineering Lookup Table

Scenario: A pressure table shows 150 PSI at 200F and 225 PSI at 250F. Find the pressure at 220F.

Step 1: Known points: (200, 150) and (250, 225)
Step 2: Slope = (225 - 150) / (250 - 200) = 75 / 50 = 1.5 PSI per degree
Step 3: X difference = 220 - 200 = 20 degrees
Step 4: Y = 150 + 1.5 * 20 = 150 + 30 = 180 PSI

Answer: The pressure at 220F is approximately 180 PSI

Engineers frequently use linear interpolation to find values between entries in reference tables.

Example 3: Game Development Animation

Scenario: A character moves from position X=100 to X=500 over 2 seconds. Where is the character at t=0.7 seconds?

Step 1: Known points: (0, 100) and (2, 500)
Step 2: Slope = (500 - 100) / (2 - 0) = 400 / 2 = 200 units per second
Step 3: Time difference = 0.7 - 0 = 0.7 seconds
Step 4: Position = 100 + 200 * 0.7 = 100 + 140 = 240

Answer: At t=0.7 seconds, the character is at position 240

Game engines use linear interpolation (lerp) extensively for smooth movement and transitions.

Real-World Applications of Linear Interpolation

Linear interpolation is one of the most widely used mathematical techniques across virtually every technical field. Here are the major application areas:

Engineering

Reading values from lookup tables, thermal analysis, stress calculations, and material property estimation

Computer Graphics

Smooth animations, color blending, texture mapping, camera movements, and character motion

Data Science

Filling missing data points, resampling time series, and feature engineering

Finance

Yield curve interpolation, option pricing, interest rate estimation, and risk modeling

GPS & Navigation

Position estimation between satellite readings, route smoothing, and timing calculations

Scientific Research

Experimental data analysis, calibration curves, and measurement interpolation

Interpolation vs. Extrapolation: Understanding the Difference

While this calculator focuses on interpolation, it's crucial to understand the difference between interpolation and extrapolation:

Aspect Interpolation Extrapolation
Definition Estimating values within the known data range Estimating values outside the known data range
X Value Position X is between X1 and X2 X is less than X1 or greater than X2
Accuracy Generally reliable and accurate Increasingly unreliable as distance increases
Risk Level Low risk of large errors High risk of significant errors
Recommendation Use confidently for estimation Use with extreme caution; validate if possible

Warning About Extrapolation

Extrapolation assumes that trends continue beyond your known data range, which is often incorrect. For example:

  • Temperature might rise steadily until noon, then stabilize or drop - extrapolating beyond noon using morning data would be inaccurate
  • Stock prices don't continue in straight lines indefinitely
  • Material properties may change dramatically outside tested conditions

Common Mistakes to Avoid

Even experienced professionals make these common linear interpolation errors. Being aware of them helps you achieve more accurate results:

1. Using Linear Interpolation for Non-Linear Data

Linear interpolation assumes a straight-line relationship. If your data follows a curve (exponential growth, logarithmic patterns, oscillations), linear interpolation can produce significant errors. Consider using polynomial or spline interpolation for curved data.

2. Mixing Up X1/X2 and Y1/Y2

Always ensure your coordinates are properly paired. The point (X1, Y1) should represent one actual data point, and (X2, Y2) should represent another. Mixing coordinates leads to incorrect results.

3. Dividing by Zero

If X1 = X2, the formula divides by zero, which is undefined. This occurs when your two "different" points actually have the same X value. Check your data before calculating.

4. Extrapolating Without Recognition

Some people apply the formula without checking if their target X is within the interpolation range. Always verify that X1 < X < X2 (or X2 < X < X1 if X2 is smaller).

Pro Tip: Validate Your Results

After calculating, do a quick sanity check: Is your result between Y1 and Y2? If X is exactly halfway between X1 and X2, is Y exactly halfway between Y1 and Y2? These quick checks catch most errors immediately.

Advanced Interpolation Concepts

Bilinear Interpolation

When you need to interpolate in two dimensions (like finding a value on a surface), bilinear interpolation extends the concept. You perform linear interpolation twice: first in one direction, then in the perpendicular direction. This is commonly used in image processing for resizing and texture mapping in 3D graphics.

Multilinear Interpolation

For higher dimensions, the concept extends further. Trilinear interpolation works in 3D space (used in medical imaging and 3D rendering). The computational complexity increases with dimensions, but the underlying principle remains the same: approximate values using nearby known points.

Piecewise Linear Interpolation

When you have many data points, you can connect consecutive points with straight lines, creating a "connect-the-dots" approximation. This is more accurate than fitting a single line through all points and is the basis for many practical interpolation schemes.

Comparison with Other Interpolation Methods

Method Complexity Smoothness Best For
Linear Simple Sharp corners at points Quick estimates, small ranges
Polynomial Moderate Smooth curves Curved data, small datasets
Cubic Spline Complex Very smooth Large datasets, smooth requirements
Nearest Neighbor Simplest Stair-step pattern Categorical data, quick lookups

Linear Interpolation in Programming

Linear interpolation is so fundamental that most programming languages include built-in functions or simple implementations. Here's how it looks in various languages:

LERP Function Implementations

// JavaScript / TypeScript
function lerp(a, b, t) {
    return a + t * (b - a);
}

// Python
def lerp(a, b, t):
    return a + t * (b - a)

// C# / Unity
float Lerp(float a, float b, float t) {
    return a + t * (b - a);
}

// The parameter t is typically between 0 and 1
// t=0 returns a, t=1 returns b, t=0.5 returns midpoint

The "lerp" function is standard in game engines (Unity, Unreal), graphics libraries (OpenGL, WebGL), and animation frameworks.

Converting to Parametric Form

To use the standard lerp(a, b, t) function with coordinates, first calculate t = (x - x1) / (x2 - x1), then call lerp(y1, y2, t). This two-step process is common in real-world applications and makes the code more reusable.

Frequently Asked Questions

Linear interpolation finds exact values between two known points by drawing a straight line through them. Linear regression finds the best-fit line through many data points, which may not pass exactly through any of them. Use interpolation when you have two precise points and need values between them. Use regression when you have many points and want to understand the overall trend.

Yes! This is called piecewise linear interpolation. You find which two adjacent points your target X falls between, then apply linear interpolation using just those two points. This creates a "connect-the-dots" line through all your data points. It's more accurate than using only the first and last points when you have intermediate data.

"Lerp" is short for Linear intERPolation. It's the standard function name used in game development, computer graphics, and animation frameworks. The typical signature is lerp(start, end, t) where t ranges from 0 to 1. At t=0 you get the start value, at t=1 you get the end value, and values in between give proportional results.

Avoid linear interpolation when: (1) Your data follows a curved pattern (exponential, logarithmic, sinusoidal), (2) You're extrapolating far beyond your known data range, (3) There are discontinuities or sudden jumps in your data, or (4) High precision is critical and the linear assumption introduces unacceptable error. In these cases, consider polynomial interpolation, spline interpolation, or domain-specific methods.

Accuracy depends on how linear your actual data is. If the true relationship is perfectly linear, interpolation is exact. For slightly curved data, the maximum error occurs at the midpoint between your known points. Generally, the closer your known points are together, the more accurate linear interpolation becomes. For critical applications, calculate the second derivative of your data function - if it's small, linear interpolation will be accurate.

Inverse linear interpolation finds the X value for a given Y, rather than finding Y for a given X. The formula is X = X1 + (Y - Y1) * (X2 - X1) / (Y2 - Y1). It's simply the regular formula with X and Y swapped. This is useful when you know the desired output and need to find the input that produces it.

Finance uses linear interpolation extensively for yield curve construction, interest rate estimation between known maturities, forward rate calculations, and option pricing. For example, if you know 2-year and 5-year Treasury yields, you can interpolate to estimate the 3-year or 4-year yield. However, more sophisticated methods (like cubic spline) are often preferred for yield curves due to their smoothness requirements.

Absolutely! Linear interpolation works with any real numbers - positive, negative, or zero. The formula handles all cases correctly. For example, if you're interpolating temperatures that include values below zero, or financial data that includes losses (negative values), the calculation proceeds exactly the same way. Just ensure your inputs are entered correctly with their signs.

Ready to Try Linear Interpolation?

Use our calculator above to find values between any two known points. Enter your coordinates and get instant results with step-by-step calculations shown.