Ask Your Question

# Revision history [back]

### Not understanding behavior with solution to simultaneous quadratic equations

Hello,

I should preface this by saying I'm brand-new to sage so am probably missing some basics.

I'm writing because I wanted to use Sage to explore the behavior of a system of quadratic equations.

Here's my code

c = 299792458
eps1 = ( vector([9, 10, 10]).norm() -1 ) / c
eps2 = ( vector([9, -10, 10]).norm() -1 ) / c
eps3 = ( vector([-11, 10, 10]).norm() -1 ) / c
eps4 = ( vector([-11, -10, 10]).norm() -1 ) / c

x,y,z,D = var('x y z D')   # GPS solution
x1,y1,z1 = var('x1 y1 z1') # Coordinates of P1

eq1 =  (x - 10)^2 + (y - 10)^2 + (z - 10)^2 == ( vector([x1, y1 -1, z1]).norm() + c*eps1 - D)^2
eq2 =  (x - 10)^2 + (y + 10)^2 + (z - 10)^2 == ( vector([x1, y1 -1, z1]).norm() + c*eps2 - D)^2
eq3 =  (x + 10)^2 + (y - 10)^2 + (z - 10)^2 == ( vector([x1, y1 -1, z1]).norm() + c*eps3 - D)^2
eq4 =  (x + 10)^2 + (y + 10)^2 + (z - 10)^2 == ( vector([x1, y1 -1, z1]).norm() + c*eps4 - D)^2


If I solve the system with S = solve([eq1, eq2, eq3, eq4,D==0], x, y, z, D)I get symbolic solutions as expected (y is constantly 0 which is unexpected and doesn't seem right, but that's a different matter).

However, if I try to specify values for x1,y1,z1 by using solve([eq1, eq2, eq3, eq4, x1==0, y1==0, z1==0, D==0], x, y, z) it returns an empty list, which I assume means no solution. On the other hand, if I use my solution S from before and explicitly substitute x1==0, y1==0, z1==0, D==0 I get the solutions I'm expecting.

Could anyone explain this behavior? Is it somehow easier for Sage to solve the more general equation than the one with parameters plugged in? Will Sage sometimes fail to find existent solutions to such systems, or have I just done something wrong?

Many thanks, Justin