# Avoid problem fitting Complex part of equation with FindFit?

GROUPS:
 Hi, I am Prady and I am new to Mathematica. I have just started using it for my project work. I have to fit Havriliak Negami Equation to my experimental results. When I take the real part and use FindFit, it is fitting correctly. I have included this in the file Real_part.nb. However, when I include the complex part it is giving error . This error can be seen in Real+Imag_part.nb. Kindly advise which function to use instead of FindFit or provide a solution. Thank you. Attachments:
2 months ago
5 Replies
 There may be an issue with symbols and the order of evaluation. You give a numerical value for Subscript[\[Epsilon], s], then you give s the value 1. If you evaluate \[Epsilon][\[Omega], \[Gamma], \[Tau], z, \[Sigma]] you will see that it contains Subscript[\[Epsilon], 1], which has no numerical value. Did you mean Subscript[\[Epsilon], s] to be a single symbol, with s to be kept symbolic and not to be replaced by 1? If so, you should write it differently to avoid the problem. For example \[Epsilon]s.
2 months ago
 Sander Huisman 1 Vote As I have said before http://community.wolfram.com/groups/-/m/t/854634 , Subscript should only be used as a typographical construct. One will sooner or later get in to trouble with variables with subscripts using the Subscript function.
2 months ago
 Thank you for your support. I changed 's=1' to 'g=1' and now FindFit says :"The gradient is not a vector of real numbers at {z,[Gamma],[Tau],\ [Sigma]} = {0.9,0.9,0.9,0.9}".So, I removed the range and it says :The function value {0.00876 -2767.11 I,-0.28364-4261.31 \ I,-0.57724-6562.55 I,-0.87394-10106.4 I,-1.17984-15563.7 \ I,-1.56744-23967.9 I,<<33>>,-20.5624-5.69282*10^10 \ I,-16.4326-8.7671410^10 I,-11.4734-1.3500810^11 \ I,-7.5542-2.079210^11 I,-6.0063-3.2019810^11 \ I,-7.23858-4.93105*10^11 I} is not a list of real numbers with \ dimensions {45} at {z,[Gamma],[Tau],[Sigma]} = {1.,1.,1.,1.}.I learnt Mathematica all by myself, it is hard. I have to admit it took me 3 weeks to reach here and it is dissapointing to not get a result. I really need to fit those curves. Please help me plot this. Thank you.
2 months ago
 Unfortunately you have run into a shortcoming of Mathematica. FindFit seems to have been programmed with the real case in mind. The complex case works in some simple examples such as FindFit[{I, 2, 3}, a*x , {a}, x] FindFit[{1, 2 + I, 3}, a *x, a, x] FindFit[{1, 2, 3}, a x + I , a, x] but it fails with little variations: FindFit[{I, 2, 3}, Cos[a] , {a}, x] FindFit[{1, 2 + I, 3}, {a *x, {0 < Re[a] < 1}}, a, x] FindFit[{1, 2, 3}, {a x + I, {0 < a < 1}} , a, x] 
2 months ago
 Do you not need Complex data if you're attempting to fit a Complex function? I only see the Real data. But in any event you might want to look at the solution provided by Oleksandr R. at Mathematica StackExchange. (And follow Sander Huisman's advice: drop the subscripts!)