I need to write two functions to calculate the speed and the $fine for over speeding. The formula I need to use is: V = c * (W0 – W1) / W0

I wrote the function to calculate the speed, but the results are incorrect, using the formulas below.

V = speed
C = speed of light (669,600,000 miles per hour)
W0 = wavelength of red light (.533 microns)
W1 = wavelength of green light (.674 microns)

V = 669600000 * (.674 - .533 ) / .674


The formula is correct, except that the values of microns are incorrect. The assigned value (.533 & .674) needs to be converted into miles, but even when I did the conversion, the results are still not correct.

.533 microns converted to miles per hour = 3.311908
.674 microns converted to miles per hour = 4.188042

I would appreciate if someone can tell me what type of conversion I need for the microns, I would greatly appreciate it.

Thanks.

Recommended Answers

All 3 Replies

if 1 micron is 1/1000000000 of a km, that means 1 micron pero hour is 1/60000000000 km/hour... in miles, that is 1.6/60000000000 mi/hour, so your conversion should be .533*1.6/60000000000 for red light, and .674 * 1.6/60000000000 for green light...

>.533 microns converted to miles per hour = 3.311908
>.674 microns converted to miles per hour = 4.188042
Well, first, you need to remove the "per hour" part of that. The conversion is strictly distance, not distance over time. Second, you're neglecting to include the exponent in the miles value. The conversion is actually:

.533 microns converted to miles per hour = 3.311908e-10
.674 microns converted to miles per hour = 4.188042e-10

That's quite a significant difference in value.

commented: I cannot allow you to surpass my reputation points. Sorry. -2

Thanks you guys.
I finally got my codes to work, and have submitted my lab.

You are correct, including the exponent in the miles value made a SIGNIFICANT difference.


Thanks again. :cool:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.