I am working on a visual python program that is meant to model the orbit of an electron around the core of a Hydrogen atom. In order to avoid the singularity at r = 0 in the equation for coulomb force, I am modelling this scenario in semi-parabolic coordinates. My question then is how can I change from cartesian coordinates to semi-parabolic coordinates within python?

1 Answer 1


I'd start with a pair of functions that converts from one coordinate system to another:

rho, tau = fromCartesian(x, y)
x, y = fromParabolic(rho, tau)

I hope you have the formulas and won't have trouble implementing the functions.

Then you convert the coordinates where it's convenient. I suppose that you should read input values, convert to parabolic, do your calculations, convert back to Cartesian and output.

  • I would add that to avoid accumulating rounding errors between the two coordinate types, it may make sense to implement a data type that stores one and converts to the other as needed, perhaps with caching.
    – user22815
    May 23, 2015 at 3:39
  • Do you mind elaborating on what you mean by implementing a data type? I'm not sure how I would do what you said although I agree that I need a way to minimize the rounding errors in between the two systems.
    – Lann625
    May 23, 2015 at 3:45
  • @Snowman: Unless you make great many transformations of the same coordinate pair to and fro, and the coordinates themselves being close to the ends of the range of 64-bit floating-point value, I'd suspect that rounding errors of this type can be neglected. I suspect that the actual electron simulation will introduce much more. OTOH it's wise to keep the computation data in one coordinate system and only translate it to the other sparingly (e.g. for output each frame of animation).
    – 9000
    May 23, 2015 at 3:50
  • @BB'18: "Premature optimization is the root of all evil" (q), so hold to the simplest correct algorithm you can produce, identify its problems (if any) and address them. When can easily predict what can be a problem (using an O(n²) algorithm instead of a linear one, getting your values very close to 0, etc), address it outright. When you only suspect that something could be a problem, measure first, optimize later; human intuition is easily fooled in this respect.
    – 9000
    May 23, 2015 at 3:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.