Ask Your Question
0

Solving system of equations using approximation

asked 2014-08-29 18:58:46 +0200

CCorio gravatar image

Hello - I'm an experienced software developer but new to Sage. I'm trying to solve a system of equations in various ways using Sage online.

Here's the system of equations

var('x y h k r t d')

eq1 = x^2 + y^2 == d^2

eq2 = y == tan(t) * x

eq3 = (x-h)^2 + (y-k)^2 == r^2

eq4 = -1 * r < h < r

eq5 = -1 * r < k < r

I'm trying to solve this in two ways:

  1. I'm trying to solve for h and k for a given r using a set of t and d values. This will obviously be an approximation.

  2. I'm trying to get all values of d given h, k, r, and t. I think there should be two values. I was trying to get the equations for d but that might not be possible...

If you could provide any insight into the functions to use to get these results or any sample code, I'd appreciate it.

Thanks, Chris

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2014-08-29 19:18:27 +0200

FrédéricC gravatar image

Well, as this is a purely polynomial problem (by replacing $\tan(t$) by $t$) of intersection between two circles, you can use polynomial tools.

sage: x,y,d,t,h,k,r = polygen(QQ,'x,y,d,t,h,k,r')
sage: eq = [x*x+y*y-d*d,y-t*x,(x-h)**2+(y-k)**2-r**2,h-1,k-1,r-6,t-2]
sage: ring = x.parent()
sage: ideal = ring.ideal(eq)
sage: ideal.dimension()
0
sage: ideal.variety()   # no solutions with rational coordinates
[]
sage: ideal.variety?   # help of the variety method
sage: ideal.variety(ring=CC)     # working over the complex numbers
[{y: 6.55163526410386, r: 6.00000000000000, t: 2.00000000000000, d: -7.32495090716051, k: 1.00000000000000, h: 1.00000000000000, x: 3.27581763205193}, {y: -4.15163526410386, r: 6.00000000000000, t: 2.00000000000000, d: -4.64166933416076, k: 1.00000000000000, h: 1.00000000000000, x: -2.07581763205193}, {y: -4.15163526410386, r: 6.00000000000000, t: 2.00000000000000, d: 4.64166933416076, k: 1.00000000000000, h: 1.00000000000000, x: -2.07581763205193}, {y: 6.55163526410386, r: 6.00000000000000, t: 2.00000000000000, d: 7.32495090716051, k: 1.00000000000000, h: 1.00000000000000, x: 3.27581763205193}]
sage: ideal.variety(ring=RR)     # working over the real numbers
[{y: 6.55163526410386, r: 6.00000000000000, t: 2.00000000000000, d: -7.32495090716051, k: 1.00000000000000, h: 1.00000000000000, x: 3.27581763205193}, {y: -4.15163526410386, r: 6.00000000000000, t: 2.00000000000000, d: -4.64166933416076, k: 1.00000000000000, h: 1.00000000000000, x: -2.07581763205193}, {y: -4.15163526410386, r: 6.00000000000000, t: 2.00000000000000, d: 4.64166933416076, k: 1.00000000000000, h: 1.00000000000000, x: -2.07581763205193}, {y: 6.55163526410386, r: 6.00000000000000, t: 2.00000000000000, d: 7.32495090716051, k: 1.00000000000000, h: 1.00000000000000, x: 3.27581763205193}]
edit flag offensive delete link more

Comments

can you help me understand this equation set a bit more? eq = [x*x+y*y-d*d,y-t*x,(x-h)**2+(y-k)**2-r**2,h-1,k-1,r-6,t-2] What does the "h-1,k-1,r-6,t-2" signify? Why is it -1 or -6, etc.?

CCorio gravatar imageCCorio ( 2014-08-29 19:31:49 +0200 )edit

The last 4 equations in eq are there to set the values of h,k,r and t. I have chosen arbitrary values.

FrédéricC gravatar imageFrédéricC ( 2014-08-29 19:53:15 +0200 )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

Stats

Asked: 2014-08-29 18:58:46 +0200

Seen: 149 times

Last updated: Aug 29 '14