Lanczos interpolation explained

This is a rendered version of the notebook. Head over to the Mathematica file for a version you can actually play with (although you will have to buy Mathematica itself).

The problem, and some solutions

The wobbly example function:

lanczos_1.gif

lanczos_2.gif

Evenly spaced samples, symmetric about the y axis.

lanczos_3.gif

lanczos_4.gif

Generate evenly spaced samples for a given expression.

lanczos_5.gif

The first example sampled function.

lanczos_6.gif

lanczos_7.gif

A wrapper to render interpolations nicely (signal in blue, interpolation in gold).

lanczos_8.gif

Linear interpolation examples.

lanczos_9.gif

lanczos_10.gif

lanczos_11.gif

lanczos_12.gif

Cubic interpolation example.

lanczos_13.gif

lanczos_14.gif

Interpolation and convolution

Display fractions on a single line (for higher legibility in legends).

lanczos_15.gif

lanczos_16.gif

Our sample function, again.

lanczos_17.gif

lanczos_18.gif

The triangle interpolation function.

lanczos_19.gif

lanczos_20.gif

Given an interpolation function, a frequency, and a point, stretches it to the frequency, and centers it around the point.

lanczos_21.gif

Evaluates and plots a single point using convolution.

lanczos_22.gif

Convolve was already taken by Mathematica, and mine is slightly different.

lanczos_23.gif

Plots the whole convolution.

lanczos_24.gif

The samples do not change after convolutions (for well behaved interpolation functions).

lanczos_25.gif

lanczos_26.gif

Visual aid for triangle = linear interpolation.

lanczos_27.gif

lanczos_28.gif

lanczos_29.gif

lanczos_30.gif

Full linear interpolation through convolution.

lanczos_31.gif

lanczos_32.gif

sinc, master interpolator

sinc in all its glory.

lanczos_33.gif

lanczos_34.gif

Again, the samples stay put.

lanczos_35.gif

lanczos_36.gif

But in between, all other samples contribute to the interpolation.

lanczos_37.gif

lanczos_38.gif

lanczos_39.gif

lanczos_40.gif

lanczos_41.gif

lanczos_42.gif

Fourier transform, and inverse.

lanczos_43.gif

lanczos_44.gif

sinc and triangle and their Fourier transforms, compared.

lanczos_45.gif

lanczos_46.gif

lanczos_47.gif

lanczos_48.gif

Different width sincs  compared.

lanczos_49.gif

lanczos_50.gif

lanczos_51.gif

lanczos_52.gif

Interpolating with sinc — an example

Our original function and its components.

lanczos_53.gif

lanczos_54.gif

lanczos_55.gif

lanczos_56.gif

Its Fourier transform, made up of Dirac deltas.

lanczos_57.gif

lanczos_58.gif

We can’t really plot the Dirac deltas, so let’s do it manually.

lanczos_59.gif

lanczos_60.gif

Show how we need to get past the highest-frequency Dirac delta to perfectly reconstruct the signal.

lanczos_61.gif

lanczos_62.gif

Graphics:ξ = 1 Graphics:ξ = 1.5
Graphics:ξ = 2 Graphics:ξ = 2.01

The problem with sinc

Simple example of a jump discontinuity.

lanczos_67.gif

lanczos_68.gif lanczos_69.gif

Gibbs oscillations.

lanczos_70.gif

Graphics:ξ = 1 Graphics:ξ = 1.5
Graphics:ξ = 2 Graphics:ξ = 4

sinc -- chopped and screwed

Utility to truncate a function.

lanczos_75.gif

And our truncated lanczos_76.gif.

lanczos_77.gif

lanczos_78.gif

...which doesn’t interpolate so well.

lanczos_79.gif

lanczos_80.gif

Gibbs oscillations redux -- this time in the spectrum of lanczos_81.gif.

lanczos_82.gif

lanczos_83.gif lanczos_84.gif lanczos_85.gif

Error together with carrier wave.

lanczos_86.gif

lanczos_87.gif

Smoothed spectrum using Lanczos’ method.

lanczos_88.gif

lanczos_89.gif lanczos_90.gif lanczos_91.gif

lanczos_92.gif

lanczos_93.gif lanczos_94.gif lanczos_95.gif

sinc, lanczos_96.gif, and smoothed lanczos_97.gif compared.

lanczos_98.gif

lanczos_99.gif lanczos_100.gif

lanczos_101.gif

Graphics:sinc(t) Graphics:<sinc(t) >_3 Graphics:<sinc(π t) >_3 sinc(π t/3)

lanczos_105.gif

Created with the Wolfram Language