Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The problem is that you are mixing up symbolic values, like 3 ** (1 / 2), cos(pi / 5), etc., that do not exist in L.

A possible solution is to extend the base ring from QQ to AA to include radicals like sqrt(3), sqrt(5). However, explicit conversion of those expression into AA is needed:

def Omega(m, z) :
    if m == 0: return z**0
    if m == 1: return exp(z)
    if m == 2: return cosh(z)
    if m == 3: return (exp(z) + 2 * exp(-z / 2) * cos(z * sqrt(AA(3)) / 2)) / 3
    if m == 4: return (cosh(z) + cos(z)) / 2
    if m == 5: return (exp(z)
            + 2 * exp(-AA(cos(pi / 5)) * z) * cos(AA(sin(pi / 5)) * z)
            + 2 * exp(AA(cos((2 * pi) / 5)) * z) * cos(AA(sin((2 * pi) / 5)) * z) ) / 5
    if m == 6: return (cosh(z) + 2 * cos(z * sqrt(AA(3)) / 2) * cosh(z / 2)) / 3
    return 0

L = LazyLaurentSeriesRing(AA, 'z')
for m in (0..6):
    f = Omega(m, L.gen())
    print(f"m={m}: {[factorial(n)*f.coefficient(n).radical_expression() for n in range(24)]}")

The problem is that you are mixing up symbolic values, like 3 ** (1 / 2), cos(pi / 5), etc., that do not exist in QQ and L.

A possible solution is to extend the base ring from QQ to AA to include radicals like sqrt(3), sqrt(5). However, explicit conversion of those expression into AA is needed:

def Omega(m, z) :
    if m == 0: return z**0
    if m == 1: return exp(z)
    if m == 2: return cosh(z)
    if m == 3: return (exp(z) + 2 * exp(-z / 2) * cos(z * sqrt(AA(3)) / 2)) / 3
    if m == 4: return (cosh(z) + cos(z)) / 2
    if m == 5: return (exp(z)
            + 2 * exp(-AA(cos(pi / 5)) * z) * cos(AA(sin(pi / 5)) * z)
            + 2 * exp(AA(cos((2 * pi) / 5)) * z) * cos(AA(sin((2 * pi) / 5)) * z) ) / 5
    if m == 6: return (cosh(z) + 2 * cos(z * sqrt(AA(3)) / 2) * cosh(z / 2)) / 3
    return 0

L = LazyLaurentSeriesRing(AA, 'z')
for m in (0..6):
    f = Omega(m, L.gen())
    print(f"m={m}: {[factorial(n)*f.coefficient(n).radical_expression() for n in range(24)]}")