Le vendredi 16 novembre 2018 21:52:18 UTC+1, Michael Beeson a écrit : > > Thank you, that was very instructive to see the "right way" to start by > using an appropriate ring. > I guess you can go on to divide out by the other linear factor and get the > quadratic equation, > and solve it, but I got that far myself, and then could not work with the > solutions of the quadratic equation. > But you may be able to do that because then they will belong to some > algebraic number field which > will come equipped with useful algorithms. >
Oops, the last command should have been print("h = .... in enumerate(h.list()))) instead of print("h = .... in enumerate(g.list()))) and, really, writing a last pretty_print function for the whole polynomial, and applying it to h, would have been a better way to go. So here is the full thing with a last pretty_print function, and applying it to `h`, not to `g`. sage: R.<N, M> = QQbar[] sage: S.<x> = R[] sage: a = QQbar(3).sqrt() / 2 sage: i = QQbar(I) sage: b = (x - ~x) / (2 * i) sage: c = (a * (x + ~x) + b) / 2 sage: X = (M / 3) * (a + b + c) sage: f = 24 * (X^2 - N * b * c) * x^2 sage: f = S(f) sage: t = QQbar(exp(-pi*I/3)) sage: # pretty_print functions sage: def pretty_qqbar(z): ....: a, b = z.real().radical_expression(), z.imag().radical_expression() ....: return "{} + {}*i".format(a, b) ....: sage: def pretty_x_coeff(xc): ....: return " + ".join("({})*{}".format(pretty_qqbar(xc[m]), m) ....: for m in xc.monomials()) ....: sage: def pretty_poly_x_MN(p, name='p'): ....: print("\n{} = ".format(name) +"\n + " ....: .join("({})*x^{}".format(pretty_x_coeff(xc), k) ....: for k, xc in enumerate(h.list())) + "\n") ....: sage: g = f // (x + 1) sage: h = g // (x - t) sage: pretty_poly_x_MN(h, name='h') h = ((2 + 0*i)*M^2 + (-6 + 0*i)*N)*x^0 + ((1 + -sqrt(3)*i)*M^2 + (3 + -3*sqrt(3)*i)*N)*x^1 + ((-1 + -sqrt(3)*i)*M^2 + (3 + 3*sqrt(3)*i)*N)*x^2 sage: -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.