HS.6.1a Incorrect: your angles aren't quite right yet!

Hi everyone,

I’m currently working on the exercise where we need to generate the QSP angles for approximating the functions cos(tx) and sin(tx) using truncated Taylor series.
When I run the tests, I get the error:

Incorrect: your angles aren't quite right yet

I’m confident the ordering is correct, so I’m wondering if I’m missing something about normalization, scaling, or the structure of the target polynomial.

Here´s mi code:

def cosine_angles(t):
    """
    Returns an np.array of coefficients of cos(tx) as a function of t
    """
    # cos(tx) ≈ 1 - t^2 x^2 / 2 + t^4 x^4 / 24
    poly_cos = [t**4 / 24, 0, -t**2 / 2, 0, 1]
    angles_cos = qml.poly_to_angles(poly_cos, "QSP")

    return angles_cos

def sine_angles(t):
    """
    Returns an np.array of coefficients of sin(tx) as a function of t
    """
    # sin(tx) ≈ t x - t^3 x^3 / 6 + t^5 x^5 / 120
    poly_sin = [0, t, 0, -t**3 / 6, 0, t**5 / 120]
    angles_sin = qml.poly_to_angles(poly_sin, "QSP")

    return angles_sin

Any help would be greatly appreciated!

Thanks in advance.

Hi!
Recall that the coefficients of the polynomial are ordered from lowest to highest power.
Also, recall that for this Codercise you are using QSVT and not QSP and the argument of qml.poly_to_angles() should be changed accordingly.

I hope this helps.