RJDennis / ChebyshevApprox.jl

A Julia package to approximate multivariate continuous functions using Chebyshev polynomials.
MIT License
29 stars 3 forks source link

basis function matrix and coefficient vector #32

Closed 121180875 closed 5 months ago

121180875 commented 6 months ago

If I want to extract the basis function matrix and coefficient vector after completing interpolation, what steps should I take?

RJDennis commented 6 months ago

Suppose it is a 2d problem, then the weights can be found from the chebyshev_weights() function and will take the form of a matrix. The basis functions can be found using the chebyshev_polynomial() function. For example:

x1 = chebyshev_nodes(21)
x2 = chebyshev_nodes(21)

y = randn(21,21)

w = chebyshev_weights(y,(x1,x2),(5,6))
weights = reshape(w,(5+1)*(6+1),1)

p1 = chebyshev_polynomial(5,x1)
p2 = chebyshev_polynomial(6,x2)
p = kron(p2,p1)

If I understand your question correctly, then weights and p are what you are looking for. The package itself doesn't ever construct p.