×
Login Register an account
Top Submissions Explore Upgoat Search Random Subverse Random Post Colorize! Site Rules Donate
4

Lagrange Interpolation

submitted by happytoes to mathematics 6 daysJan 9, 2025 15:37:41 ago (+4/-0)     (www.youtube.com)

https://www.youtube.com/watch?v=bzp_q7NDdd4

This video has beautiful graphics underpinning an especially clear explanation. At just seven minutes it doesn't get on to Runge Spikes. I'm hoping to create original content about Runge Spikes and this will be the video I link to, to explain Lagrange Interpolation


3 comments block


[ - ] WyattDonnelly 1 point 6 daysJan 9, 2025 17:30:44 ago (+1/-0)

Elliot Nicholson's is well worth watching also:
https://www.youtube.com/watch?v=wbSzthGR7OU&t=1s

[ - ] happytoes [op] 0 points 5 daysJan 10, 2025 18:23:03 ago (+0/-0)

I liked the way he built up the formula, first one point, then two, then three, then the general case. I coded along at home, writing some Common Lisp, structured the same way

https://pastebin.com/GY1YZUGz

In the last five minutes Elliot Nicholson warns that Lagrange Interpolation sometimes wiggles weirdly in between the given points. That is the Runge Spikes thing that I'm interested in.

I thought that I could generate a simple example by running my code. Let the points be (0,0), (1,0), (2,1), (3,0), (4,0). I'm expecting wiggles at the half-integer points.

CL-USER> (funcall (make-poly '((0 . 0)(1 . 0)(2 . 1)(3 . 0)(4 . 0))) 2.5) => 0.703125

That is reasonable

CL-USER> (funcall (make-poly '((0 . 0)(1 . 0)(2 . 1)(3 . 0)(4 . 0))) 3.5) => -0.546875

That little dip is odd, but not too weird.

But if I try interpolating 0 0 0 0 0 1 0 0 0 0 0

CL-USER> (funcall (make-poly '((0 . 0)(1 . 0)(2 . 0)(3 . 0)(4 . 0)
(5 . 1)
(6 . 0)(7 . 0)(8 . 0)(9 . 0)(10 . 0)
)) 0.5)

=> 4.9335175

I get a weird answer at one half. Yah! My first Runge Spike!

[ - ] FreeinTX 0 points 6 daysJan 9, 2025 17:17:49 ago (+0/-0)

Noice.