Why Does FindFit Fail with Non-Real Number Errors in Mathematica?

  • Context: Mathematica 
  • Thread starter Thread starter Hoiya
  • Start date Start date
Click For Summary
SUMMARY

The discussion addresses the error encountered while using the FindFit function in Mathematica with a specific dataset and model function. The user receives a "FindFit::nrlnum" error indicating that the function values are not returning a list of real numbers. The proposed solution involves replacing the exponential function from "e" to "E" in the model definition, which is necessary for proper evaluation in Mathematica. This adjustment ensures that the function is interpreted correctly, allowing FindFit to operate without errors.

PREREQUISITES
  • Understanding of Mathematica syntax and functions
  • Familiarity with the FindFit function in Mathematica
  • Basic knowledge of mathematical modeling using exponential functions
  • Experience with handling numerical data in Mathematica
NEXT STEPS
  • Review the documentation for the FindFit function in Mathematica
  • Learn about the differences between "e" and "E" in Mathematica
  • Explore error handling techniques in Mathematica for debugging
  • Investigate other fitting functions available in Mathematica for different modeling scenarios
USEFUL FOR

Mathematica users, data analysts, and researchers involved in mathematical modeling and curve fitting who encounter issues with function evaluations in their computations.

Hoiya
Messages
2
Reaction score
0
I have these values:

Oscill = {{0, -6.4}, {5, -6.3}, {10, -6.5}, {15, -6.2}, {20, -6.1}, \
{25, -5.9}, {30, -5.8}, {35, -5.5}, {40, -5.1}, {45, -4.8}, {50, \
-4.4}, {55, -3.9}, {60, -3.3}, {65, -2.8}, {70, -2.2}, {75, -1.8}, \
{80, -1}, {85, -0.4}, {90, 0.4}, {95, 1}, {100, 1.8}, {105,
2.3}, {110, 3}, {115, 3.8}, {120, 4.9}, {140, 8}, {160,
11.1}, {180, 13.8}, {200, 16.3}, {220, 18.2}, {240, 19.7}, {260,
20.4}, {280, 20.4}, {300, 19.8}, {320, 18.7}, {340, 17}, {360,
15}, {380, 12.7}, {400, 10.3}, {420, 7.8}, {440, 5.5}, {460,
3.6}, {480, 1.8}, {500, 0.6}, {520, -0.2}, {540, -0.3}, {560,
0}, {580, 0.8}, {600, 1.9}, {620, 3.5}, {640, 5.2}, {660,
7.1}, {680, 8.9}, {700, 10.8}, {720, 12.4}, {740, 13.8}, {760,
14.7}, {780, 15.5}, {800, 15.8}, {820, 15.6}, {840, 15.1}, {860,
14.3}, {880, 13.1}, {900, 11.8}, {920, 10.4}, {940, 8.9}, {960,
7.5}, {980, 6.1}, {1000, 5}, {1020, 4.2}, {1040, 3.6}, {1060,
3.2}, {1080, 3.3}, {1100, 3.6}, {1120, 4.1}, {1140, 4.9}, {1160,
5.8}, {1180, 7}, {1200, 8.1}, {1220, 9.2}, {1240, 10.3}, {1260,
11.2}, {1280, 11.9}, {1300, 12.4}, {1320, 12.8}, {1340,
12.8}, {1360, 12.7}, {1380, 12.3}, {1400, 11.7}, {1420, 11}, {1440,
10.1}, {1460, 9.3}, {1480, 8.4}, {1500, 7.6}, {1520, 6.8}, {1540,
6.3}, {1560, 5.7}, {1580, 5.4}, {1600, 5.3}, {1620, 5.4}, {1640,
5.7}, {1660, 6}, {1680, 6.4}, {1700, 7}, {1720, 7.8}, {1740,
8.4}, {1760, 9}, {1780, 9.6}, {1800, 10.1}, {1820, 10.6}, {1840,
10.8}, {1860, 10.9}, {1880, 10.9}, {1900, 10.8}, {1920,
10.6}, {1940, 10.1}, {1960, 9.7}, {1980, 9.2}, {2000, 8.7}, {2020,
8.1}, {2040, 7.7}, {2060, 7.1}, {2080, 6.9}, {2100, 6.6}, {2120,
6.5}, {2140, 6.5}, {2160, 6.5}, {2180, 6.7}, {2200, 7}, {2220,
7.2}, {2240, 7.7}, {2260, 8.1}, {2280, 8.4}, {2300, 8.9}, {2320,
9.1}, {2340, 9.5}, {2360, 9.7}, {2380, 9.8}, {2400, 9.9}, {2420,
9.8}, {2440, 9.8}, {2460, 9.7}, {2480, 9.3}, {2500, 9.1}, {2520,
8.8}, {2540, 8.6}, {2560, 8.2}, {2580, 8}, {2600, 7.7}, {2620,
7.5}, {2640, 7.4}, {2660, 7.3}, {2680, 7.4}, {2700, 7.4}, {2720,
7.5}, {2740, 7.6}, {2760, 7.8}, {2780, 8}, {2800, 8.2}, {2820,
8.5}, {2840, 8.7}, {2860, 8.9}, {2880, 9}, {2900, 9.1}, {2920,
9.2}, {2940, 9.3}, {2960, 9.3}, {2980, 9.2}, {3000, 9.1}, {3020,
9}, {3040, 8.9}, {3060, 8.7}, {3080, 8.5}, {3100, 8.3}, {3120,
8.1}, {3140, 8}, {3160, 7.9}, {3180, 7.8}, {3200, 7.7}, {3220,
7.7}, {3240, 7.8}, {3260, 7.8}, {3280, 7.9}, {3300, 8.0}, {3320,
8.1}, {3340, 8.3}, {3360, 8.4}, {3380, 8.5}, {3400, 8.6}, {3420,
8.7}, {3440, 8.8}, {3460, 8.8}, {3480, 8.9}, {3500, 8.9}, {3520,
8.8}, {3540, 8.8}, {3560, 8.7}, {3580, 8.6}, {3600, 8.5}}

and this function:

Espo = A*(e^(-\[Sigma]*t))*Cos[((2*Pi/T)*t) + \[Theta]] + \[Phi]

When I try to use findfit, I read this error message:

FEO = FindFit[Oscill, Espo, {A, \[Sigma], T, \[Theta], \[Phi]}, t]

FindFit::nrlnum: The function value {7.9403,7.3+0.540302/e^5.,7.5+0.540302/e^10.,7.2+0.540302/e^15.,7.1+<<19>>/e^<<4>>,<<1>>,6.8+<<1>>,6.5+0.540302/e^35.,6.1+0.540302/e^40.,5.8+0.540302/e^45.,<<189>>} is not a list of real numbers with dimensions {199} at {A,\[Sigma],T,\[Theta],\[Phi]} = {1.,1.,1.,1.,1.}. >>

FindFit::nrlnum: The function value {7.9403,7.3+0.540302/e^5.,7.5+0.540302/e^10.,7.2+0.540302/e^15.,7.1+<<19>>/e^<<4>>,<<1>>,6.8+<<1>>,6.5+0.540302/e^35.,6.1+0.540302/e^40.,5.8+0.540302/e^45.,<<189>>} is not a list of real numbers with dimensions {199} at {A,\[Sigma],T,\[Theta],\[Phi]} = {1.,1.,1.,1.,1.}. >>

Can anybody help me?
 
Physics news on Phys.org
Replace this
Espo = A*(e^...
with this
Espo = A*(E^...
 

Similar threads

  • Poll Poll
  • · Replies 5 ·
Replies
5
Views
13K
  • · Replies 41 ·
2
Replies
41
Views
6K
  • Poll Poll
  • · Replies 1 ·
Replies
1
Views
5K
  • Poll Poll
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 6 ·
Replies
6
Views
6K
  • Poll Poll
  • · Replies 1 ·
Replies
1
Views
6K
  • Poll Poll
  • · Replies 3 ·
Replies
3
Views
8K
  • Poll Poll
  • · Replies 6 ·
Replies
6
Views
9K
  • · Replies 11 ·
Replies
11
Views
33K