Thanks @dlfivefifty !
Just let me use one more example to make sure that I understand…
julia> using ApproxFun
julia> f = Fun((x, y) -> 1 + 1.2cos(2acos(x)) + 1.3cos(acos(y)), Interval(-1,1)^2)
The first coefficient is for
T_0(x) T_0(y) == cos(0.0acos(x))*cos(0.0acos(y)), the second coefficient is for
T_0(x) T_1(y) == cos(0.0acos(x))*cos(1.0acos(y)) and the last coefficient is for
T_2(x) T_0(y) == cos(2.0acos(x))*cos(0.0acos(y)).
So a function that I could use to compute the polynomial from the coefficients is:
function compute_poly(c, x, y)
ret = 0.0
indeces = [[0,0],[0,1],[1,0],[0,2],[1,1],[2,0]]
for (i, coeff) in enumerate(c)
ret += coeff*cos(indeces[i]*acos(x))*cos(indeces[i]*acos(y))
I know that
ApproxFun does things in a much more clever way, but I am just trying to understand the mathematics.
One thing that I noticed on my adventure trying to implement
compute_poly() above is that the ordering of indeces is different from what you get with
julia> using Combinatorics
julia> a = multiset_combinations([0,0,1,1,2,2], 2) |> collect
So apparently people in combinatorics have different conventions from people in numerics?
One last question. Although your explanation makes sense now, it was not excactly intuitive to me… Do you think that this would be worth adding to the documentation?