# Exponential fit precision lost

I have a data:

data = {{1504., 0.38623}, {1698.56, 1.70795}, {1855.34, 4.77922}, {1998.22,
9.76965}, {1957.13, 7.34756}, {1924.72, 5.8017}, {1793.82,
2.84449}, {1679.68, 1.14792}, {1604.06, 0.765434}, {1422.63,
0.183902}, {1350.57, 0.078183}}


And I wanted to fit function

nlm = NonlinearModelFit[data, $$\frac{c1}{Exp \left[\frac{c2 \left(\frac{3*10^8}{583.92*10^{-9}}\right)}{x+273.15}\right]-1}$$, {c1, c2}, x]

I get warning: ...is too small to represent as a normalized machine number; precision may be lost.

How to fit this function?

• Please include the actual code for NonlinearModelFit rather than the display format currently showing and decide if the data set is data or data8.
– JimB
Commented Feb 4, 2022 at 22:01
• Given that 1/Exp[750.] underflows, I'm not surprised, given the argument in your model. You might consider giving starting values, esp. for c2. Commented Feb 5, 2022 at 3:58
• @MichaelE2 The idea of starting values works. Commented Feb 6, 2022 at 20:44
• Using anything between 10^-20 to 10^-10 as a starting value for c2 works. But it is simpler if you use c1/(Exp[c0 /(x + 273.15)] - 1) as the model and then solve for the appropriate multiple of c0 to get c2 because the default starting values work fine in that case.
– JimB
Commented Feb 6, 2022 at 22:51

I guess, there is simpliy a typo with 583.92 10^-9  Get good result with positive exponent

model[x_] = c1/(Exp[(c2 ((3 10^8)/(583.92 10^9)))/(x + 273.15)] - 1)

nlm = NonlinearModelFit[data, model[x], {c1, c2}, x]

Normal[nlm]

(*   1.50253*10^6/(-1 + E^(27202./(273.15+ x)))   *)

Plot[Normal[nlm], {x, 1300, 2000}, Epilog -> Point@data]

• The value 583.92 10^-9 is a wavelength in nanometers ($10^{-9}$ m) Commented Feb 5, 2022 at 14:46