Skip to content

kox13/interpolation-approximation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elevation Profile Approximation

A Python project implementing and comparing two numerical interpolation methods on elevation profile data: Lagrange interpolation and cubic spline interpolation.

Overview

The program visualizes both methods across three datasets with distinct characteristics:

File Description
genoa_rapallo.txt Large, frequent elevation oscillations
Obiadek.csv Two sharp spikes with small fluctuations
chelm.txt Smooth, gradual changes

Each dataset contains 512 (distance, elevation) point pairs.

Interpolation Methods

Lagrange Interpolation

A global method — constructs a single polynomial passing through all selected nodes. Simple to implement, but susceptible to the Runge effect at higher node counts. Tested configurations:

  • Evenly spaced nodes: 6, 9, 12, 15, 18, 21
  • Chebyshev nodes (improved stability): 60, 100

Cubic Spline Interpolation

A local method — connects neighboring nodes with third-degree polynomials while enforcing continuity of the first and second derivatives. Immune to the Runge effect and highly scalable. Tested node counts: 6, 10, 20, 30, 50, 100

Plot Order

  1. Lagrange with 100 nodes for genoa_rapallo — Runge effect demonstration
  2. Lagrange (6–21 nodes) for each of the three profiles
  3. Lagrange with Chebyshev nodes (60 and 100 nodes) for each profile
  4. Cubic spline (6–100 nodes) for each profile

Requirements

  • Python 3.x
  • numpy
  • pandas
  • matplotlib

Setup & Usage

1. Create a virtual environment

python3 -m venv venv

2. Activate the environment and install dependencies

Linux / macOS:

source venv/bin/activate
pip3 install -r requirements.txt

Windows:

.\venv\Scripts\activate
pip install -r requirements.txt

3. Run the program

Linux / macOS:

python3 main.py

Windows:

py main.py

Conclusions

Lagrange interpolation works well for smooth, simple functions — especially when combined with Chebyshev nodes. For highly oscillatory data, cubic spline interpolation is the clear winner: it produces no Runge effect and maintains accuracy regardless of the number of nodes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages