human
Bessel 's Interpolation | calculating u mentioned in the formula.
calculating factorial of given number n.
Number of values given.
y [ ] [ ] is used for difference table with y [ ] [ 0 ] used for input.
Calculating the central difference table.
Displaying the central difference table.
value to interpolate at.
Initializing u and sum.
k is origin thats is f ( 0 ).
if ( ( n % 2 ) > 0 ) : origin for odd.
k = int ( n / 2 - 1 ).
origin for even.
Solving using bessel 's formula"
How can the above be solved in Python?
assistant
#Here is code to bessel 's Interpolation and the other steps required.
 def ucal ( u , n ) :
	if ( n == 0 ) :
		return 1 ;
	temp = u ;
	for i in range ( 1 , int ( n / 2 + 1 ) ) :
		temp = temp * ( u - i ) ;
	for i in range ( 1 , int ( n / 2 ) ) :
		temp = temp * ( u + i ) ;
	return temp ;
def fact ( n ) :
	f = 1 ;
	for i in range ( 2 , n + 1 ) :
		f *= i ;
	return f ;
n = 6 ;
x = [ 25 , 26 , 27 , 28 , 29 , 30 ] ;
y = [ [ 0 for i in range ( n ) ] for j in range ( n ) ] ;
y [ 0 ] [ 0 ] = 4.000 ;
y [ 1 ] [ 0 ] = 3.846 ;
y [ 2 ] [ 0 ] = 3.704 ;
y [ 3 ] [ 0 ] = 3.571 ;
y [ 4 ] [ 0 ] = 3.448 ;
y [ 5 ] [ 0 ] = 3.333 ;
for i in range ( 1 , n ) :
	for j in range ( n - i ) :
		y [ j ] [ i ] = y [ j + 1 ] [ i - 1 ] - y [ j ] [ i - 1 ] ;
for i in range ( n ) :
	for j in range ( n - i ) :
		print ( y [ i ] [ j ] , " 	 " , end = " ▁ " ) ;
	print ( " " ) ;
value = 27.4 ;
sum = ( y [ 2 ] [ 0 ] + y [ 3 ] [ 0 ] ) / 2 ;
k = 0 ;
	k = int ( n / 2 ) ;
else :
u = ( value - x [ k ] ) / ( x [ 1 ] - x [ 0 ] ) ;
for i in range ( 1 , n ) :
	if ( i % 2 ) :
		sum = sum + ( ( u - 0.5 ) * ucal ( u , i - 1 ) * y [ k ] [ i ] ) / fact ( i ) ;
	else :
		sum = sum + ( ucal ( u , i ) * ( y [ k ] [ i ] + y [ k - 1 ] [ i ] ) / ( fact ( i ) * 2 ) ) ;
		k -= 1 ;
print ( " Value ▁ at " , value , " is " , round ( sum , 5 ) ) ;