Ask Your Question

# 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?

edit retag close merge delete

## Comments

There are many conditions here under which there is no solution. Reformulating this so that you guarantee a solution may resolve the issue.

( 2013-01-11 08:24:08 +0100 )edit

## 1 Answer

Sort by ยป oldest newest most voted

Perhaps 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])

more

## Comments

If this is the approach, I think it's simpler to use CartesianProduct (or itertools.product)` rather than nesting loops.

( 2013-01-11 13:18:15 +0100 )edit

## Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

## Stats

Asked: 2013-01-11 04:55:47 +0100

Seen: 356 times

Last updated: Jan 11 '13