[Tutor] Hi there, have a question for a side project in physics.....
Steven D'Aprano
steve at pearwood.info
Mon Dec 25 07:31:46 EST 2017
On Mon, Dec 25, 2017 at 01:08:13PM +0400, Siddharth Sehgal wrote:
> Hi there
>
>
> I am a novice python user and am a physics masters student. I am
> trying to use the Sellmeier Equation to calculate a refractive index.
> The coefficients of this equation are decimals to a large number of
> sig figs ( i.e B1 = 1.03961212, B2 = 0.231792344, C1 = 6.00069867×10−3
That's not really a lot of significant figures. Python floats are C
64-bit doubles, so they can represent about 15 or 16 significant
figures. The numbers you show are only 9 or 10.
> ... and so on) in the sellmeier formula there is a lot of fractions,
> multiplication and squaring of these numbers. I originally state them
> as floats. However such a process apparently cannot be done with
> "floats" like these.
What makes you think that you cannot use floats for this?
Of course floating point maths on computers is not the same as real
arithmetic of the Real numbers in mathematics class, and you may need to
carefully consider the possible error conditions in your equations,
round-off error, and so forth, but in general I would expect that simply
using Python as a calculator will be fine for all but the most precise
calculations.
More information about the Tutor
mailing list