I would like to define a function f(n) which outputs another function as follows:
f[n_] := PolynomialRemainder[#,ChebyshevT[n,x],x]&
However, I would like the ChebyshevT[n,x] part of the function to be evaluated when f is called, so that for instance when f(2) is evaluated I get PolynomialRemainder[#,-1+2x^2,x]& instead of PolynomialRemainder[#,ChebyshevT[2,x],x]&.
How do I do that? If I wrap the function body in an Evaluate as follows:
f[n_] := Evaluate[PolynomialRemainder[#,ChebyshevT[n,x],x]]&
then the whole definition gets evaluated, and the input # is assumed to be free of x, resulting in f[2] = #&.
With[{poly = Chebyshev[n, x]}, ...– Kuba Jan 12 '19 at 14:22