Author Topic: Neville Interpolation  (Read 2755 times)

0 Members and 1 Guest are viewing this topic.

Offline jack

  • Seasoned Forum Regular
  • Posts: 408
    • View Profile
Neville Interpolation
« on: September 26, 2021, 04:11:13 am »
the recent talk about recursive functions reminded me of the Neville's method for polynomial interpolation which can easily be defined as a recursive function
Code: QB64: [Select]
  1. Dim As Double x(0 To 6), y(0 To 6)
  2. x(0) = 100: x(1) = 200: x(2) = 300: x(3) = 400: x(4) = 500: x(5) = 600: x(6) = 700
  3. y(0) = 232: y(1) = 231: y(2) = 313: y(3) = 404: y(4) = 357: y(5) = 361: y(6) = 218
  4.  
  5. Print Neville(0, 6, x(), y(), 50)
  6.  
  7. Function Neville# (i As Long, j As Long, x() As Double, y() As Double, z As Double)
  8.     If i = j Then
  9.         Neville = y(i)
  10.     Else
  11.         Neville = ((x(j) - z) * Neville(i, j - 1, x(), y(), z) + (z - x(i)) * Neville(i + 1, j, x(), y(), z)) / (x(j) - x(i))
  12.     End If
  13.