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.Fri, 11 Jan 2013 13:18:15 +0100solve stuck in infinite loop?https://ask.sagemath.org/question/9700/solve-stuck-in-infinite-loop/I enter the following into a freshly built version of sage 5.5...
var('x0 x1 y0 y1 r0 r1 x2 y2')
eq1 = (x2 - x0)^2 + (y2 - y0)^2 == r0^2
eq2 = (x2 - x1)^2 + (y2 - y1)^2 == r1^2
solve([eq1,eq2], x2, y2)
There is no response. It seems like it is stuck in an infinite loop.
Anyone know where I have gone wrong?
Fri, 11 Jan 2013 04:55:47 +0100https://ask.sagemath.org/question/9700/solve-stuck-in-infinite-loop/Comment by calc314 for <p>I enter the following into a freshly built version of sage 5.5...</p>
<pre><code>var('x0 x1 y0 y1 r0 r1 x2 y2')
eq1 = (x2 - x0)^2 + (y2 - y0)^2 == r0^2
eq2 = (x2 - x1)^2 + (y2 - y1)^2 == r1^2
solve([eq1,eq2], x2, y2)
</code></pre>
<p>There is no response. It seems like it is stuck in an infinite loop.</p>
<p>Anyone know where I have gone wrong?</p>
https://ask.sagemath.org/question/9700/solve-stuck-in-infinite-loop/?comment=18411#post-id-18411There are many conditions here under which there is no solution. Reformulating this so that you guarantee a solution may resolve the issue.Fri, 11 Jan 2013 08:24:08 +0100https://ask.sagemath.org/question/9700/solve-stuck-in-infinite-loop/?comment=18411#post-id-18411Answer by achrzesz for <p>I enter the following into a freshly built version of sage 5.5...</p>
<pre><code>var('x0 x1 y0 y1 r0 r1 x2 y2')
eq1 = (x2 - x0)^2 + (y2 - y0)^2 == r0^2
eq2 = (x2 - x1)^2 + (y2 - y1)^2 == r1^2
solve([eq1,eq2], x2, y2)
</code></pre>
<p>There is no response. It seems like it is stuck in an infinite loop.</p>
<p>Anyone know where I have gone wrong?</p>
https://ask.sagemath.org/question/9700/solve-stuck-in-infinite-loop/?answer=14445#post-id-14445Perhaps you have too many parameters.
Maybe some more concrete approach can be more successful:
var('x2 y2')
Z=[1,2]
for x0 in Z:
for y0 in Z:
for x1 in Z:
for y1 in Z:
for r0 in Z:
for r1 in Z:
eq1 = (x2 - x0)^2 + (y2 - y0)^2 == r0^2
eq2 = (x2 - x1)^2 + (y2 - y1)^2 == r1^2
print solve([eq1,eq2], [x2, y2])Fri, 11 Jan 2013 11:38:30 +0100https://ask.sagemath.org/question/9700/solve-stuck-in-infinite-loop/?answer=14445#post-id-14445Comment by DSM for <p>Perhaps you have too many parameters.
Maybe some more concrete approach can be more successful:</p>
<pre><code>var('x2 y2')
Z=[1,2]
for x0 in Z:
for y0 in Z:
for x1 in Z:
for y1 in Z:
for r0 in Z:
for r1 in Z:
eq1 = (x2 - x0)^2 + (y2 - y0)^2 == r0^2
eq2 = (x2 - x1)^2 + (y2 - y1)^2 == r1^2
print solve([eq1,eq2], [x2, y2])
</code></pre>
https://ask.sagemath.org/question/9700/solve-stuck-in-infinite-loop/?comment=18406#post-id-18406If this is the approach, I think it's simpler to use `CartesianProduct` (or `itertools.product`)` rather than nesting loops. Fri, 11 Jan 2013 13:18:15 +0100https://ask.sagemath.org/question/9700/solve-stuck-in-infinite-loop/?comment=18406#post-id-18406