Professional Documents
Culture Documents
CSC 512 Assignment
CSC 512 Assignment
Solution:
import numpy as np
def dft_inverse(X):
N = len(X)
n = np.arange(N)
k = n.reshape((N, 1))
e = np.exp(-2j * np.pi * k * n / N)
np.dot(e, X)
x = np.dot(e, X)/N
return x
Question 4:
Write a funcion my_cubic_spline (x, y, X) where x and y
arrays that contain experimental data points,and X is an array
Asume that x and X are ascendong order and have unique element
The output argument Y should be ал array the same size as X, , where
Y[i] is cubic spline interpolation of X[i]. Do not use interp1d or CubSpline.
Solution:
import numpy as np
dx = X[i] - x[j]
Y[i] = a[j] + b[j] * dx + c[j] * dx**2 + d[j] * dx**3
return Y