[Tutor] [OT] Re: Floating Point Craziness
Andre' Walker-Loud
walksloud at gmail.com
Tue Jun 14 03:29:18 CEST 2011
On Jun 13, 2011, at 1:44 PM, Emile van Sebille <emile at fenx.com> wrote:
> On 6/12/2011 1:55 PM Andre' Walker-Loud said...
>> Hi Alan,
>>
>>>> * Or you just get used to the fact that some numbers are not exact in
>>>> floating point.
>>>
>>> This got me thinking. How many decimal places do you need to
>>> accurately, say, aim a laser somewhere in a 180 degree arc accurately
>>> enough to hit a dime on the surface of the moon?
>>
>> Here is a quick back of the envelope estimate for you. (While I am still learning the Python, I can answer this one!)
>>
>> The angle subtended by a dime on the earth is (approximately) given by
>>
>> sin( theta ) = d / sqrt( R^2 + d^2 )
>>
>> where
>>
>> d = 1 cm (the diameter of a dime)
>> R = 384,403 km (the average distance from the center of the earth to the center of the moon - the moon traverses an elliptical path about the earth)
>>
>> To make the approximation simple, take advantage of the series expansion for sin (theta) and 1 / sqrt(R^2 + d^2)
>>
>> first
>>
>> d / sqrt( R^2 + d^2 ) = d / R * 1 / sqrt(1 + d^2 / R^2 )
>> ~= d / R * (1 - 1/2 * d^2 / R^2 + ...)
>>
>> now
>>
>> d / R = 1 * e-2 / (384403 * e3)
>> ~= 3 * e-11
>>
>> so the d^2 / R^2 correction will be very small, and won't effect the determination. So we now have
>>
>> sin (theta) ~= d / R
>>
>> This will be a very small angle. The next approximation to make is for small angles
>>
>> sin (theta) ~= theta + ...
>>
>> leaving us with
>>
>> theta ~= d / R
>>
>>
>> To be approximate, assume the precision you need is equal to the size of the dime. This means you need an precision of
>>
>> d theta ~= d/R ~= 3 * e-11 ( = 3 * 10^{-11} if you aren't familiar with the "e" notation)
>>
>> this is the minimum precision you would need in both the "x" and "y" direction to accurately hit the dime on the moon with your laser (at its average distance).
>>
>> Corrections to this estimate will come from the fact that the moon's radius is ~1737 km and the earth's radius is ~6370 km, so you are actually this much closer (R is this much smaller).
>>
>> Of course both the earth is spinning and the moon is moving relative to us, so you would have to account for those extra corrections as well.
>>
>>
>> Hope that wasn't too much info,
>>
>
>
> Of course not. I enjoyed it. However, don't you need to work divergence in, as per wikipedia, "...At the Moon's surface, the beam is only about 6.5 kilometers (four miles) wide[6] and scientists liken the task of aiming the beam to using a rifle to hit a moving dime 3 kilometers (two miles) away."
>
> (http://en.wikipedia.org/wiki/Lunar_Laser_Ranging_experiment)
Of course, I was performing just the 'theoretical' calculation. It is up to others to dtermine if it is actually practical :)
Andre
>
> Emile
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list