1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3#
4# Try to set some integer/rational coefficients
5
6import mpsolve
7
8
9def rootsofunity():
10    """Solve the polynomial x^n - 1 using rational
11    input for MPSolve"""
12    ctx = mpsolve.Context()
13    poly = mpsolve.MonomialPoly(ctx, 8)
14
15    poly.set_coefficient (0, "-1")
16    poly.set_coefficient (8, "1")
17
18    print( "Roots of x^8 - 1 = %s" % ( "  ".join (map (str, ctx.solve (poly)))))
19
20if __name__ == "__main__":
21    rootsofunity()
22
23
24
25