ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 09 May 2022 19:02:02 +0200Strange problem with Solve functionhttps://ask.sagemath.org/question/62372/strange-problem-with-solve-function/I am running into a strange issue when trying to solve an equation, which seems pretty simple to solve. When I ask SAGE preform
x=var('x')
solve(1630*x^3 + 2991*x^2 + 1628*x + 1==0, x)
Everything goes fine, and it gives me the roots of the equation. However, when I ask it to do the same for a larger equation, I get this:
x=var('x')
solve(1953125*x^5 + 6793750*x^4 + 5942255*x^3 + 8749866*x^2 + 5857878*x + 1==0, x)
and the result is:
[0 == 1953125*x^5 + 6793750*x^4 + 5942255*x^3 + 8749866*x^2 + 5857878*x + 1]
And I do not understand why. I even checked using WolframAlpha, and the issue is not that this equation has no roots. Indeed, WolframAlpha was able to solve this equation with no issues.
What is the issue here? What am I missing?RuneMon, 09 May 2022 19:02:02 +0200https://ask.sagemath.org/question/62372/How to pick out the largest root of an equation?https://ask.sagemath.org/question/25568/how-to-pick-out-the-largest-root-of-an-equation/ I tried the following but it didn't work,
p = x^2 - 7*a*x + 5;
a=5;
m = max((p == 0).solve([x]))
PhoenixTue, 20 Jan 2015 05:22:48 +0100https://ask.sagemath.org/question/25568/Trigonometric Equation Solving: Not Terminatinghttps://ask.sagemath.org/question/9898/trigonometric-equation-solving-not-terminating/## The Background
I want to write a script which is able to do the following:
- **INPUT:** **`x`** - A list of triangle items. These items are considered as given.
- **INPUT:** **`y`** - A list of triangle items. We want to know the abstract formulas of these items.
- **OUTPUT:** **`z`** - A list of formulas to calculate the items from `y`
For example:
- **INPUT:** **`x`** - `[alpha, beta]` (considered as given)
- **INPUT:** **`y`** - `[gamma]` (we want to know the formula of `gamma`)
- **OUTPUT:** **`z`** - `[gamma == pi - alpha - beta]`
I want to do that using `sage`'s `solve()`.
## My Problem:
This is a simplified script. It is just able to output formulas for `alpha`, `beta` and `gamma` when `a`, `b` and `c` are considered as given:
rings = RR[('a', 'b', 'c')].gens()[:3] # considered as given
x = dict([(str(rings_), rings_) for rings_ in rings])
varbs = SR.var(['alpha', 'beta', 'gamma']) # looking for `alpha`, `beta` and `gamma`
x.update([(str(varbs_), varbs_) for varbs_ in varbs])
print solve([
#x['a']**2 == x['b']**2 + x['c']**2 - 2*x['b']*x['c']*cos(x['alpha']),
#x['b']**2 == x['a']**2 + x['c']**2 - 2*x['a']*x['c']*cos(x['beta']),
#x['c']**2 == x['a']**2 + x['b']**2 - 2*x['a']*x['b']*cos(x['gamma']),
x['alpha'] == arccos((x['a']**2 - x['b']**2 - x['c']**2) / 2*x['b']*x['c']),
x['beta'] == arccos((x['b']**2 - x['a']**2 - x['c']**2) / 2*x['a']*x['c']),
x['gamma'] == arccos((x['c']**2 - x['a']**2 - x['b']**2) / 2*x['a']*x['b']),
#pi == x['alpha'] + x['beta'] + x['gamma'],
], [
x['alpha'],
x['beta'],
x['gamma'],
])
This script is working correctly and outputs:
[
[alpha == pi - arccos(-0.5*a^2*b*c + 0.5*b^3*c + 0.5*b*c^3), beta == pi - arccos(0.5*a^3*c - 0.5*a*b^2*c + 0.5*a*c^3), gamma == arccos(-0.5*a^3*b - 0.5*a*b^3 + 0.5*a*b*c^2)]
]
I wanted to extend `solve()`'s knowledge base in order to be able to solve more complicated problems later on. But when I tried to uncomment the `#` lines and ran the script again, `solve()` didn't terminate any more.
## My Question:
* Why doesn't `solve()` terminate when I uncomment the `#` lines?
* How can I get `sage` to terminate? Or: How can I work around this problem?
Thanks - if anything's unclear, please leave a comment concerning that.fdj815Sun, 10 Mar 2013 09:56:09 +0100https://ask.sagemath.org/question/9898/