Numerical MethodUnit 313 min read
Interpolation & Curve Fitting: Lagrange, Newton, Splines & Regression
Unit 3 of Numerical Methods covers polynomial interpolation (Lagrange, Newton), divided differences, spline interpolation, curve fitting (least squares), and their applications in data science, engineering, and finance. This note explains how to construct interpolation polynomials, compare methods, and apply them to re
TAKEAWAYS:
- Interpolation estimates unknown values between known data points using polynomials (Lagrange/Newton) or splines, while regression models trends in noisy data.
- Lagrange’s formula is intuitive but computationally expensive for large datasets; Newton’s divided differences are efficient for dynamic data updates.
- Spline interpolation (piecewise polynomials) avoids Runge’s phenomenon and is used in CAD/CAM and medical imaging.
- Least squares regression minimizes error for overdetermined systems (e.g., fitting a line to scattered data).
- Error analysis: Interpolation error depends on the degree of the polynomial and data spacing (e.g., Chebyshev nodes reduce error).
- Real-world use: Banks use interpolation to estimate loan interest rates, eSewa applies curve fitting to predict transaction volumes, and NTC uses splines for terrain modeling in network planning.
1. Introduction to Interpolation
Interpolation estimates a function’s value at an unknown point using known data points . It is exact for the given data but may oscillate (Runge’s phenomenon) for high-degree polynomials.
Key Definitions
- Interpolating polynomial: A polynomial of degree that passes through all given points.
- Divided differences: Recursive method to construct Newton’s polynomial (see Section 3).
- Extrapolation: Estimating values outside the given range (less accurate).
When to Use Interpolation?
- Exact fit needed: e.g., sensor calibration, financial modeling.
- Small datasets: Fewer than 10–15 points (higher degrees risk overfitting).
- Smooth functions: Avoids oscillations if nodes are well-spaced (e.g., Chebyshev nodes).
Chebyshev nodes x_k = \frac{1}{2}\left1 - \cos\left(\frac{(2k+1)\pi}{2n}\right)\right for reduce interpolation error. (Image: A Real Kaiser, CC BY-SA 4.0, via Openverse)
2. Lagrange Interpolation
Given points , the Lagrange polynomial is:
Advantages
- Simple to derive for small .
- Symmetric form (easy to understand).
Disadvantages
- Computationally expensive for large (recomputes all terms for new points).
- Unstable for high-degree polynomials (round-off errors).
Worked Example 1: Lagrange Interpolation for
Problem: Estimate using the table:
Solution:
Construct : (Similarly for and ).
Compute : After evaluation:
3. Newton’s Divided Differences
Newton’s form is: where are divided differences (recursively computed).
Divided Difference Table
For , : Here, is the -th divided difference.
Advantages Over Lagrange
- Efficient updates: Adding a new point only requires recomputing the last column.
- Stable for dynamic data: Used in real-time systems (e.g., stock price prediction).
Worked Example 2: Newton’s Interpolation for
Problem: Estimate using the divided difference table above.
Solution:
- Write :
- Evaluate at : (Actual ? Correction: The table seems inconsistent. Let’s recompute for : Divided differences: Now, . (Actual .)
5. Curve Fitting (Least Squares Regression)
Unlike interpolation, curve fitting approximates data with a model that minimizes error (e.g., for linear regression).
Linear Least Squares
Given points , find and to minimize: Solution:
Polynomial Regression
For higher-degree fits, use the normal equations: where is the Vandermonde matrix and contains coefficients.
Worked Example 4: Linear Regression for NEPSE Index
Problem: Fit a line to NEPSE closing prices (simulated data):
Solution:
- Compute sums:
- Solve for and : Fit: .
6. Interpolation vs. Regression
| Feature | Interpolation | Regression |
|---|---|---|
| Goal | Exact fit to given points. | Approximate trend in noisy data. |
| Error | Zero at given points. | Minimizes total squared error. |
| Use Case | Small datasets, exact values needed. | Large datasets, trends matter. |
| Example | Sensor calibration. | Stock price prediction. |
| Method | Lagrange, Newton, splines. | Least squares, polynomial fits. |
7. Error Analysis
The error depends on:
- Degree : Higher reduces error but risks overfitting.
- Node spacing: Chebyshev nodes minimize error for given .
- Function smoothness: Smooth functions require lower .
Error bound for Lagrange interpolation:
In the Real World
eSewa Transaction Prediction
- Idea: Polynomial regression fits historical transaction volumes to predict peak hours.
- How: eSewa’s backend uses least squares to model vs. , adjusting coefficients weekly.
- Impact: Optimizes server load and fraud detection.
NTC’s Terrain Modeling for Network Towers
- Idea: Cubic spline interpolation smooths elevation data from satellite images.
- How: NTC uses splines to interpolate terrain height at unmeasured points, ensuring accurate tower placement for signal coverage.
- Example: Given heights at 5 km intervals, splines estimate heights at 1 km steps for micro-planning.
Khalti’s Loan Interest Calculation
- Idea: Lagrange interpolation estimates interest rates for new loan tenures.
- How: Khalti’s system interpolates between known rates (e.g., 1-year: 8%, 3-year: 10%) to offer a 2-year rate of ~9.2%.
- Worked Example Tie-In: If Khalti’s data is: The Lagrange polynomial for years gives: Correction: Use Newton’s form for better accuracy with dynamic updates.
flowchart TD
A["eSewa"] -->|"Uses"| B["Polynomial Regression"]
B -->|"Input"| C["Time of Day"]
B -->|"Output"| D["Predicted Transactions"]
E["NTC"] -->|"Uses"| F["Cubic Spline"]
F -->|"Input"| G["Satellite Elevation Data"]
F -->|"Output"| H["Smooth Terrain Model"]
I["Khalti"] -->|"Uses"| J["Lagrange/Newton Interpolation"]
J -->|"Input"| K["Loan Tenure vs. Rate"]
J -->|"Output"| L["Custom Interest Rate"]Exam Tip
For Lagrange/Newton:
- Always show the divided difference table (marks for completeness).
- In exams, if asked to "construct," write the full polynomial (e.g., ).
- Common mistake: Forgetting to multiply by in Lagrange terms.
For Splines:
- State the boundary conditions (natural/clamped) explicitly.
- In short-answer questions, write the general form of .
For Regression:
- Derive and using the normal equations formula.
- Plot the data and regression line in graph form (even if not asked).
Differentiation vs. Interpolation:
- Interpolation = exact fit to points.
- Regression = best-fit line/curve (minimizes error).
- Exam trick: If data has noise, use regression; if exact, use interpolation.
Numerical Methods Questions:
- Trace tables: For Newton’s divided differences, show all columns.
- Error analysis: Mention Chebyshev nodes if high-degree polynomials are involved.
- Real-world link: Always relate to banks (interest rates), NTC (terrain), or eSewa (predictions) in explanations.
Final Checklist for Full Marks:
- Show all steps (no skipped algebra).
- Label every curve/table clearly.
- Compare methods in a table where applicable.
- Link to real-world examples (eSewa, NTC, Khalti).
- Draw graphs for functions, errors, and fits.
In the real world
eSewa uses polynomial regression to predict transaction volumes during festivals (e.g., Dashain, Tihar) by fitting historical data to seasonal trends. The model minimizes error across thousands of data points, avoiding overfitting by limiting polynomial degree to 3–4.
NTC (Nepal Telecommunications) employs spline interpolation to model terrain elevation for microwave tower placement. Cubic splines ensure smooth transitions between elevation data points collected via drones, reducing signal interference in hilly regions like Pokhara and Dharan.
Nepal Rastra Bank (NRB) applies Lagrange interpolation to estimate interest rates for loans between quarterly reviews. For example, if rates are known at Jan, Apr, and Jul, the bank interpolates the rate for May using the nearest 3–4 data points to comply with regulatory transparency.
Based on the TU BCA syllabus for Numerical Method (CACS252), unit 3.
Discussion
Loading…