sympyzerocrossing

Get multiplicity of zeros in sympy?


I would like to get the multiplicity of zeros as a return value from sympy.solveset. For the example below I get zeroes = {0}. I would like to receive something like zeroes = {0, 0, 0, 0, 0, 0}. Thanks!

import sympy

z = sympy.symbols('z')
zeroes = sympy.solveset(sympy.Eq(z**6, 0), z)

Solution

  • Use roots instead:

    import sympy
    
    z = sympy.symbols('z')
    zeroes = sympy.roots(sympy.Eq(z**6, 0), z)
    
    print(zeroes)
    

    This prints:

    {0: 6}