1 | initial version |
First, here is a classical way to get solutions of you equation:
sage: a = 5
sage: p = x^2 - 7*a*x + 5
sage: p.solve(x)
[x == -1/2*sqrt(1205) + 35/2, x == 1/2*sqrt(1205) + 35/2]
So, you have a list of solutions. Each solution is of the form x == -1/2*sqrt(1205) + 35/2
which is a symbolic expression. You can get the right hand side with the rhs()
method:
sage: [s.rhs() for s in p.solve(x)] [-1/2sqrt(1205) + 35/2, 1/2sqrt(1205) + 35/2]
Then, you can take the maximal element of this list:
sage: max([s.rhs() for s in p.solve(x)]) 1/2*sqrt(1205) + 35/2
Alternatively, instead of getting solutions , you can get them as Python dictionaries:
sage: p.solve(x, solution_dict=True)
[{x: -1/2*sqrt(1205) + 35/2}, {x: 1/2*sqrt(1205) + 35/2}]
So, you can get each solution by looking at the x
values:
sage: [s[x] for s in p.solve(x, solution_dict=True)]
[-1/2*sqrt(1205) + 35/2, 1/2*sqrt(1205) + 35/2]
Then, as before, you can take the maximal element of this list:
sage: max([s[x] for s in p.solve(x, solution_dict=True)])
1/2*sqrt(1205) + 35/2
2 | No.2 Revision |
First, here is a classical way to get solutions of you equation:
sage: a = 5
sage: p = x^2 - 7*a*x + 5
sage: p.solve(x)
[x == -1/2*sqrt(1205) + 35/2, x == 1/2*sqrt(1205) + 35/2]
So, you have a list of solutions. Each solution is of the form x == -1/2*sqrt(1205) + 35/2
which is a symbolic expression. You can get the right hand side with the rhs()
method:
sage: [s.rhs() for s in p.solve(x)]
Then, you can take the maximal element of this list:
sage: max([s.rhs() for s in p.solve(x)])
1/2*sqrt(1205) + Alternatively, instead of getting solutions , you can get them as Python dictionaries:
sage: p.solve(x, solution_dict=True)
[{x: -1/2*sqrt(1205) + 35/2}, {x: 1/2*sqrt(1205) + 35/2}]
So, you can get each solution by looking at the x
values:
sage: [s[x] for s in p.solve(x, solution_dict=True)]
[-1/2*sqrt(1205) + 35/2, 1/2*sqrt(1205) + 35/2]
Then, as before, you can take the maximal element of this list:
sage: max([s[x] for s in p.solve(x, solution_dict=True)])
1/2*sqrt(1205) + 35/2
3 | No.3 Revision |
First, here is a classical way to get solutions of you equation:
sage: a = 5
sage: p = x^2 - 7*a*x + 5
sage: p.solve(x)
[x == -1/2*sqrt(1205) + 35/2, x == 1/2*sqrt(1205) + 35/2]
So, you have a list of solutions. Each solution is of the form x == -1/2*sqrt(1205) + 35/2
which is a symbolic expression. You can get the right hand side of such an equality with the rhs()
method:
sage: [s.rhs() for s in p.solve(x)]
[-1/2*sqrt(1205) + 35/2, 1/2*sqrt(1205) + 35/2]
Then, you can take the maximal element of this list:
sage: max([s.rhs() for s in p.solve(x)])
1/2*sqrt(1205) + 35/2
Alternatively, instead of getting solutions , you can get them as Python dictionaries:
sage: p.solve(x, solution_dict=True)
[{x: -1/2*sqrt(1205) + 35/2}, {x: 1/2*sqrt(1205) + 35/2}]
So, you can get each solution by looking at the x
values:
sage: [s[x] for s in p.solve(x, solution_dict=True)]
[-1/2*sqrt(1205) + 35/2, 1/2*sqrt(1205) + 35/2]
Then, as before, you can take the maximal element of this list:
sage: max([s[x] for s in p.solve(x, solution_dict=True)])
1/2*sqrt(1205) + 35/2
4 | No.4 Revision |
First, here is a classical way to get solutions of you equation:
sage: a = 5
sage: p = x^2 - 7*a*x + 5
sage: p.solve(x)
[x == -1/2*sqrt(1205) + 35/2, x == 1/2*sqrt(1205) + 35/2]
So, you have a list of solutions. Each solution is of the form x == -1/2*sqrt(1205) + 35/2
which is a symbolic expression. You can get the right hand side of such an equality with the rhs()
method:
sage: [s.rhs() for s in p.solve(x)]
[-1/2*sqrt(1205) + 35/2, 1/2*sqrt(1205) + 35/2]
Then, you can take the maximal element of this list:
sage: max([s.rhs() for s in p.solve(x)])
1/2*sqrt(1205) + 35/2
Alternatively, instead of getting solutions , as symbolic expressions, you can get them as Python dictionaries:
sage: p.solve(x, solution_dict=True)
[{x: -1/2*sqrt(1205) + 35/2}, {x: 1/2*sqrt(1205) + 35/2}]
So, you can get each solution by looking at the x
values:
sage: [s[x] for s in p.solve(x, solution_dict=True)]
[-1/2*sqrt(1205) + 35/2, 1/2*sqrt(1205) + 35/2]
Then, as before, you can take the maximal element of this list:
sage: max([s[x] for s in p.solve(x, solution_dict=True)])
1/2*sqrt(1205) + 35/2