HS.5.2 polynomial

The exercise is from the link above. We need to use QSP to estimate the \text{erf} function. I tried to solve that without viewing the hint by estimating the Chebyshev series of erf. I run this externally and copy the coef to the exercise

from numpy.polynomial.chebyshev import chebfit
def integrand(t):
    return 2/np.sqrt(np.pi) * np.exp(-t**2)

y = []
x = np.arange(-1, 1, 0.005)
for i in x:
    I, _ = quad(integrand, 0, i)
    y.append(I)

# do the chebyshev fit
coef = chebfit(x, y, deg=7)

Now I click the hint, and see we use Taylor expansion. That worked, but aren’t we supposed to use Chebysev as HS.5.1 instead of Taylor?

Hi @mchau , it’s great to see you back in the Forum!

It’s possible that more than one solution can give the right answer but we encourage you to use the method described in the Codercise. We will take a deeper look into this just to check that everything is working correctly but in the meantime I encourage you to try it out with the instructions from the exercise.