from __future__ import division

from sympy import *

x,y,z = symbols('xyz')

def hyperplot( a2 = 5.10125066033543, b2 = 1.844025414703168, c2 =
2.303750131640994, d2 = 0, e2 = 3):
    """e2 is the distance between foci and a2,b2,c2,d2 are the times
of arrival the foci, c2 is at the center"""

    a = ((a2 - c2)/2)**2
    b = ((b2 - c2)/2)**2
    c = ((d2 - c2)/2)**2
    e = e2/2

    eq1 = y**2/(e**2 - a) - (x + e)**2/a + 1
    eq2 = x**2/(e**2 - b) - (y - e)**2/b + 1
    eq3 = y**2/(e**2 - c) - (x - e)**2/c + 1

    # returns the correct 4 solutions
    # return solve([eq1, eq3], [x, y])

    # sympy seems to have issues with eq2,
    # these should have 4 real solutions each, but the returned
solutions have small imaginary components
    #return solve([eq2, eq3], [x, y])
    #return solve([eq1, eq2], [x, y])

    # this did not return in a reasonable time frame
    #return solve([eq1, eq2, eq3], [x, y])

    # This is the best I have come up with, is there a better way?
    s = solve([eq1, eq3], [x, y])

    bestError = 1
    best = None

    for each in s:
        error = eq2.evalf(subs={x:each[0], y:each[1]})

        if error < bestError:
            bestError = error
            best = each

    return best

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to