I've been scouring the internet for a straightforward way to approximate the distance between Earth and Mars at a given time. I hope to achieve an accuracy of about 100km.
Do not underestimate the astronomers! 100 km? That's absurd. Saturn('s center of mass) is located to within one mile's distance from the Sun. Mars is of course even much better located.
Here's a site I googled that seems to give current distance to Mars to within single kilometers. I don't know how that site makes up its numbers, but it is certainly possible to measure it like that. With mutual radio communication, there are really good opportunities for precis distance measuring. 135,834,832 km just now! Pretty close and that's why the ExoMars space probe was launched towards Mars a few days ago. And here is a table with the conunction distances just past and soon coming up.
The python library, pyephem has this function.
import ephem km = 149597871 # 1AU in km m = ephem.Mars() m.compute('2016/3/18') print(m.earth_distance*km) 136729311.6250654