Ask Your Question

Sympy geometry: can't compute tangent lines

asked 2013-02-10 17:36:34 -0500

Alasdair gravatar image

Here's the problem:

from sympy import symbols, Plot
from sympy.geometry import * 
c1 = Circle(Point(0,0),2)
a = Point(3,0)
at = c1.tangent_lines(a)

DomainError: can't compute a Groebner basis over RR

A little web search indicates that this was a problem with older versions of sympy, but Sage includes a newer version for which this issue is not supposed to be a problem. Any ideas on how to get round this?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-02-11 04:57:09 -0500

DSM gravatar image

This seems to work for me in Sage 5.6:

sage: from sympy.geometry import Circle, Point
sage: c1 = Circle(Point(0,0),2)
sage: a = Point(3,0)
sage: at = c1.tangent_lines(a)
sage: at
[Line(Point(3, 0), Point(4/3, -2*5**(1/2)/3)), Line(Point(3, 0), Point(4/3, 2*5**(1/2)/3))]

as well as on sagenb's 5.4.

BTW, star imports -- from somewhere import * -- are generally disfavoured in Python, and that's even more true in Sage, because it's very easy to accidentally rebind a name -- sin, say -- which originally referred to Sage's function with one which refers to the sin function of sympy, or mpmath, or numpy, or something, which will raise puzzling errors and be the source of mysterious bugs.

[My favourite example:

sage: all(i < 10 for i in [0..100])  
sage: from numpy import *
sage: all(i < 10 for i in [0..100])

This once caused a bug in my code it took forever to track down.]

edit flag offensive delete link more


I discovered that my mistake (not shown in the original example) was describing circles using real numbers: Circle(Point(-0.25,0),1) instead of rationals: Circle(Point([-1/4,0]),1) And thank you for the heads-up about not importing using *. That's just me being lazy!

Alasdair gravatar imageAlasdair ( 2013-02-12 10:43:27 -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-02-10 17:36:34 -0500

Seen: 267 times

Last updated: Feb 11 '13