Ask Your Question

solve stuck in infinite loop?

asked 2013-01-10 21:55:47 -0500

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 flag offensive close merge delete


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

calc314 gravatar imagecalc314 ( 2013-01-11 01:24:08 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2013-01-11 04:38:30 -0500

achrzesz gravatar image

updated 2013-01-11 04:54:00 -0500

Perhaps you have too many parameters. Maybe some more concrete approach can be more successful:

var('x2 y2')
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])
edit flag offensive delete link more


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

DSM gravatar imageDSM ( 2013-01-11 06:18:15 -0500 )edit

Your Answer

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

Add Answer

Question Tools


Asked: 2013-01-10 21:55:47 -0500

Seen: 186 times

Last updated: Jan 11 '13