How to resolve the algorithm Thiele's interpolation formula step by step in the 11l programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Thiele's interpolation formula step by step in the 11l programming language

Table of Contents

Problem Statement

Thiele's interpolation formula is an interpolation formula for a function f(•) of a single variable.   It is expressed as a continued fraction:

ρ

{\displaystyle \rho }

represents the   reciprocal difference,   demonstrated here for reference: Demonstrate Thiele's interpolation function by:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Thiele's interpolation formula step by step in the 11l programming language

Source code in the 11l programming language

F thieleInterpolator(x, y)
   V ρ = enumerate(y).map((i, yi) -> [yi] * (@y.len - i))
   L(i) 0 .< ρ.len - 1
      ρ[i][1] = (x[i] - x[i + 1]) / (ρ[i][0] - ρ[i + 1][0])
   L(i) 2 .< ρ.len
      L(j) 0 .< ρ.len - i
         ρ[j][i] = (x[j] - x[j + i]) / (ρ[j][i - 1] - ρ[j + 1][i - 1]) + ρ[j + 1][i - 2]
   V ρ0 = ρ[0]
   F t(xin)
      V a = 0.0
      L(i) (@=ρ0.len - 1 .< 1).step(-1)
         a = (xin - @=x[i - 1]) / (@=ρ0[i] - @=ρ0[i - 2] + a)
      R @=y[0] + (xin - @=x[0]) / (@=ρ0[1] + a)
   R t

V xVal = (0.<32).map(i -> i * 0.05)
V tSin = xVal.map(x -> sin(x))
V tCos = xVal.map(x -> cos(x))
V tTan = xVal.map(x -> tan(x))
V iSin = thieleInterpolator(tSin, xVal)
V iCos = thieleInterpolator(tCos, xVal)
V iTan = thieleInterpolator(tTan, xVal)
print(‘#.14’.format(6 * iSin(0.5)))
print(‘#.14’.format(3 * iCos(0.5)))
print(‘#.14’.format(4 * iTan(1)))

  

You may also check:How to resolve the algorithm Speech synthesis step by step in the Raku programming language
You may also check:How to resolve the algorithm Greyscale bars/Display step by step in the Mathematica / Wolfram Language programming language
You may also check:How to resolve the algorithm Perlin noise step by step in the V (Vlang) programming language
You may also check:How to resolve the algorithm Run-length encoding step by step in the Wren programming language
You may also check:How to resolve the algorithm Man or boy test step by step in the ALGOL 68 programming language