Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Here are two ways to proceed. The first one gives you approximate results from which you can guess the correct solution, the second is an exact resolution. In both cases, I define $s = a^5 + b^5 + c^5$ and I try to obtain the value of $s$.

Using symbolic variables and solve: approximate solution

sage: var('a, b, c, s')
(a, b, c, s)
sage: eq1 = a + b + c == 3
sage: eq2 = a^2 + b^2 + c^2 == 5
sage: eq3 = a^3 + b^3 + c^3 == 7
sage: eq4 = a^5 + b^5 + c^5 == s
sage: sol = solve([eq1, eq2, eq3, eq4], [s, a, b, c])
sage: sol
[[s == (9.666666666666746 + 2.94556046220862e-14*I), a == -0.240011808699075, b == (1.620005904858813 - 0.3914357752931976*I), c == (1.620005904858815 + 0.3914357752931956*I)], [s == (9.666666666666746 - 2.94556046220862e-14*I), a == -0.240011808699075, b == (1.620005904858813 + 0.3914357752931976*I), c == (1.620005904858816 - 0.3914357752931965*I)], [s == (9.666666666666751 + 3.28070903776734e-14*I), a == (1.620005904858813 + 0.3914357752931967*I), b == (1.620005904858812 - 0.3914357752931972*I), c == (-0.2400118097109294 + 2.8091418080578e-13*I)], [s == (9.666666666666785 + 3.01612557994701e-14*I), a == (1.620005904858813 + 0.3914357752931967*I), b == (-0.2400118097176253 + 3.13587902457777e-16*I), c == (1.620005904858814 - 0.3914357752931946*I)], [s == (9.666666666666691 - 2.60902410786912e-15*I), a == (1.620005904858813 - 0.3914357752931967*I), b == (1.620005904858812 + 0.3914357752931972*I), c == (-0.2400118097145694 + 1.53912993461347e-12*I)], [s == (9.666666666666424 - 3.01370197640685e-14*I), a == (1.620005904858813 - 0.3914357752931967*I), b == (-0.2400118097176253 - 2.82969990755139e-16*I), c == (1.620005904858808 + 0.3914357752932017*I)]]

To obtain only the value of s, you can write:

sage: [s[0] for s in sol]
[s == (9.666666666666746 + 2.94556046220862e-14*I),
 s == (9.666666666666746 - 2.94556046220862e-14*I),
 s == (9.666666666666751 + 3.28070903776734e-14*I),
 s == (9.666666666666785 + 3.01612557994701e-14*I),
 s == (9.666666666666691 - 2.60902410786912e-15*I),
 s == (9.666666666666424 - 3.01370197640685e-14*I)]

From there, you can guess that the value of s is in fact $9.6666666... = 29/3$ and try to prove it.

Using polynomials and Gröbner bases : exact solution

sage: R.<a,b,c,s> = QQ[]
sage: f1 = a + b + c - 3
sage: f2 = a^2 + b^2 + c^2 - 5
sage: f3 = a^3 + b^3 + c^3 - 7
sage: f4 = a^5 + b^5 + c^5 - s
sage: I = R.ideal([f1, f2, f3, f4])
sage: G = I.groebner_basis()
sage: G
[c^3 + (-3)*c^2 + 2*c + 2/3, b^2 + b*c + c^2 + (-3)*b + (-3)*c + 2, a + b + c - 3, s - 29/3]

From there you conclude that the only possibility for $s$ is $29/3$.

Here are two ways to proceed. The first one gives you approximate results from which you can guess the correct solution, the second is an exact resolution. In both cases, I define $s = a^5 + b^5 + c^5$ and I try to obtain the value of $s$.

1. Using symbolic variables and solve: approximate solution

sage: var('a, b, c, s')
(a, b, c, s)
sage: eq1 = a + b + c == 3
sage: eq2 = a^2 + b^2 + c^2 == 5
sage: eq3 = a^3 + b^3 + c^3 == 7
sage: eq4 = a^5 + b^5 + c^5 == s
sage: sol = solve([eq1, eq2, eq3, eq4], [s, a, b, c])
sage: sol
[[s == (9.666666666666746 + 2.94556046220862e-14*I), a == -0.240011808699075, b == (1.620005904858813 - 0.3914357752931976*I), c == (1.620005904858815 + 0.3914357752931956*I)], [s == (9.666666666666746 - 2.94556046220862e-14*I), a == -0.240011808699075, b == (1.620005904858813 + 0.3914357752931976*I), c == (1.620005904858816 - 0.3914357752931965*I)], [s == (9.666666666666751 + 3.28070903776734e-14*I), a == (1.620005904858813 + 0.3914357752931967*I), b == (1.620005904858812 - 0.3914357752931972*I), c == (-0.2400118097109294 + 2.8091418080578e-13*I)], [s == (9.666666666666785 + 3.01612557994701e-14*I), a == (1.620005904858813 + 0.3914357752931967*I), b == (-0.2400118097176253 + 3.13587902457777e-16*I), c == (1.620005904858814 - 0.3914357752931946*I)], [s == (9.666666666666691 - 2.60902410786912e-15*I), a == (1.620005904858813 - 0.3914357752931967*I), b == (1.620005904858812 + 0.3914357752931972*I), c == (-0.2400118097145694 + 1.53912993461347e-12*I)], [s == (9.666666666666424 - 3.01370197640685e-14*I), a == (1.620005904858813 - 0.3914357752931967*I), b == (-0.2400118097176253 - 2.82969990755139e-16*I), c == (1.620005904858808 + 0.3914357752932017*I)]]

To obtain only the value of s, you can write:

sage: [s[0] for s in sol]
[s == (9.666666666666746 + 2.94556046220862e-14*I),
 s == (9.666666666666746 - 2.94556046220862e-14*I),
 s == (9.666666666666751 + 3.28070903776734e-14*I),
 s == (9.666666666666785 + 3.01612557994701e-14*I),
 s == (9.666666666666691 - 2.60902410786912e-15*I),
 s == (9.666666666666424 - 3.01370197640685e-14*I)]

From there, you can guess that the value of s is in fact $9.6666666... = 29/3$ and try to prove it.

2. Using polynomials and Gröbner bases bases: exact solution

sage: R.<a,b,c,s> = QQ[]
sage: f1 = a + b + c - 3
sage: f2 = a^2 + b^2 + c^2 - 5
sage: f3 = a^3 + b^3 + c^3 - 7
sage: f4 = a^5 + b^5 + c^5 - s
sage: I = R.ideal([f1, f2, f3, f4])
sage: G = I.groebner_basis()
sage: G
[c^3 + (-3)*c^2 + 2*c + 2/3, b^2 + b*c + c^2 + (-3)*b + (-3)*c + 2, a + b + c - 3, s - 29/3]

From there you conclude that the only possibility for $s$ is $29/3$.

Here are two ways to proceed. The first one gives you approximate results from which you can guess the correct solution, the second is an exact resolution. In both cases, I define $s = a^5 + b^5 + c^5$ and I try to obtain the value of $s$.

1. Using symbolic variables and solve: approximate solution

sage: var('a, b, c, s')
(a, b, c, s)
sage: eq1 = a + b + c == 3
sage: eq2 = a^2 + b^2 + c^2 == 5
sage: eq3 = a^3 + b^3 + c^3 == 7
sage: eq4 = a^5 + b^5 + c^5 == s
sage: sol = solve([eq1, eq2, eq3, eq4], [s, a, b, c])
sage: sol
[[s == (9.666666666666746 + 2.94556046220862e-14*I), a == -0.240011808699075, b == (1.620005904858813 - 0.3914357752931976*I), c == (1.620005904858815 + 0.3914357752931956*I)], [s == (9.666666666666746 - 2.94556046220862e-14*I), a == -0.240011808699075, b == (1.620005904858813 + 0.3914357752931976*I), c == (1.620005904858816 - 0.3914357752931965*I)], [s == (9.666666666666751 + 3.28070903776734e-14*I), a == (1.620005904858813 + 0.3914357752931967*I), b == (1.620005904858812 - 0.3914357752931972*I), c == (-0.2400118097109294 + 2.8091418080578e-13*I)], [s == (9.666666666666785 + 3.01612557994701e-14*I), a == (1.620005904858813 + 0.3914357752931967*I), b == (-0.2400118097176253 + 3.13587902457777e-16*I), c == (1.620005904858814 - 0.3914357752931946*I)], [s == (9.666666666666691 - 2.60902410786912e-15*I), a == (1.620005904858813 - 0.3914357752931967*I), b == (1.620005904858812 + 0.3914357752931972*I), c == (-0.2400118097145694 + 1.53912993461347e-12*I)], [s == (9.666666666666424 - 3.01370197640685e-14*I), a == (1.620005904858813 - 0.3914357752931967*I), b == (-0.2400118097176253 - 2.82969990755139e-16*I), c == (1.620005904858808 + 0.3914357752932017*I)]]

To obtain only the value of s, you can write:

sage: [s[0] for s in sol]
[s == (9.666666666666746 + 2.94556046220862e-14*I),
 s == (9.666666666666746 - 2.94556046220862e-14*I),
 s == (9.666666666666751 + 3.28070903776734e-14*I),
 s == (9.666666666666785 + 3.01612557994701e-14*I),
 s == (9.666666666666691 - 2.60902410786912e-15*I),
 s == (9.666666666666424 - 3.01370197640685e-14*I)]

From there, you can guess that the value of s is in fact $9.6666666... = 29/3$ and try to prove it.

2. Using polynomials and Gröbner bases: exact solution

sage: R.<a,b,c,s> = QQ[]
sage: f1 = a + b + c - 3
sage: f2 = a^2 + b^2 + c^2 - 5
sage: f3 = a^3 + b^3 + c^3 - 7
sage: f4 = a^5 + b^5 + c^5 - s
sage: I = R.ideal([f1, f2, f3, f4])
sage: G = I.groebner_basis()
sage: G
[c^3 + (-3)*c^2 + 2*c + 2/3, b^2 + b*c + c^2 + (-3)*b + (-3)*c + 2, a + b + c - 3, s - 29/3]

From there you conclude that the only possibility for $s$ is $29/3$.

Of course, you can ask for more to obtain the full list of solutions :

First compute the dimension of I:

sage: I.dimension()
0

Since it is zero, the variety (set of solutions) defined by your ideal is finite, and you can compute the full list:

sage: V = I.variety()
sage: V
[]

This means that there is no solution with all variables set to some rational. But there are solutions in the algebraic closure of the rationals:

sage: V = I.variety(QQbar)
sage: V
[{s: 9.666666666666667?, c: -0.2400118097176259?, b: 1.620005904858813? - 0.3914357752931970?*I, a: 1.620005904858813? + 0.3914357752931970?*I},
 {s: 9.666666666666667?, c: -0.2400118097176259?, b: 1.620005904858813? + 0.3914357752931970?*I, a: 1.620005904858813? - 0.3914357752931970?*I},
 {s: 9.666666666666667?, c: 1.620005904858813? - 0.3914357752931970?*I, b: -0.2400118097176259? + 0.?e-17*I, a: 1.620005904858813? + 0.3914357752931970?*I},
 {s: 9.666666666666667?, c: 1.620005904858813? - 0.3914357752931970?*I, b: 1.620005904858813? + 0.3914357752931970?*I, a: -0.2400118097176259? + 0.?e-35*I},
 {s: 9.666666666666667?, c: 1.620005904858813? + 0.3914357752931970?*I, b: -0.2400118097176259? + 0.?e-17*I, a: 1.620005904858813? - 0.3914357752931970?*I},
 {s: 9.666666666666667?, c: 1.620005904858813? + 0.3914357752931970?*I, b: 1.620005904858813? - 0.3914357752931970?*I, a: -0.2400118097176259? + 0.?e-35*I}]

You find the solutions of the first part of my answer. Note though that the approximate values you see are approximate screen representations of values that Sage knows exactly. For $s$, you can explicitly ask for an exact representation:

sage: s0 = V[0][s] # s in the first solution
sage: s0.exactify()
sage: s0
29/3

Bingo! And as a final note, some kind of magic happened under the hood (compare the values of $s$ before and now):

sage: V
[{s: 29/3, c: -0.2400118097176259?, b: 1.620005904858813? - 0.3914357752931970?*I, a: 1.620005904858813? + 0.3914357752931970?*I},
 {s: 29/3, c: -0.2400118097176259?, b: 1.620005904858813? + 0.3914357752931970?*I, a: 1.620005904858813? - 0.3914357752931970?*I},
 {s: 29/3, c: 1.620005904858813? - 0.3914357752931970?*I, b: -0.2400118097176259? + 0.?e-17*I, a: 1.620005904858813? + 0.3914357752931970?*I},
 {s: 29/3, c: 1.620005904858813? - 0.3914357752931970?*I, b: 1.620005904858813? + 0.3914357752931970?*I, a: -0.2400118097176259? + 0.?e-35*I},
 {s: 29/3, c: 1.620005904858813? + 0.3914357752931970?*I, b: -0.2400118097176259? + 0.?e-17*I, a: 1.620005904858813? - 0.3914357752931970?*I},
 {s: 29/3, c: 1.620005904858813? + 0.3914357752931970?*I, b: 1.620005904858813? - 0.3914357752931970?*I, a: -0.2400118097176259? + 0.?e-35*I}]