Tell me more ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I need to get a minimum of function F[ang] which is defined as a function of angle:

F[ang_] := -KFe*(Cos[ang])^2 - NSm*kB*T*Log[Zf[ang]];
Zf[ang_] := Sum[Exp[-Enf[ang][[j]]/(kB*T)], {j, 1, 6}]; 

Where Enf[ang] are the eigenvalues of Hamiltonian (vector 6x1) which also depend on angle, all the others are just constants. I have checked all the matrices and other output - analiticaly they look correct.

Trying all the functions like Minimize,FindMin, etc I always get the same mistake - the program gives me the maximum instead of the minimum. Moreover, it gives me actually the wrong value.
So, the minimum given by programm is

Minimize[{F[theta], 0 < theta < Pi/2}, theta]
{-5.43002*10^7, {theta -> 0.}}  

While in fact it is clear from the graph that F[theta=0]=-4.6*10^7

I have some ideas why this could happen. First of all, my function is kind of sum of analytical part and the sum of series(which is Enf). Futhermore, those Enf are not good-looking really, as follows:

{Root[(-7.46805*10^-45 - 
   2.21485*10^-44 Cos[2 theta]) #1^3 + (-3.65541*10^-29 + 
   1.4013*10^-45 Cos[theta] + 2.8026*10^-45 Cos[2 theta]) #1^4 + 
1. #1^6 &, 1], 
 Root[(-7.46805*10^-45 - 
   2.21485*10^-44 Cos[2 theta]) #1^3 + (-3.65541*10^-29 + 
   1.4013*10^-45 Cos[theta] + 2.8026*10^-45 Cos[2 theta]) #1^4 + 
1. #1^6 &, 2], 
 Root[(-7.46805*10^-45 - 
   2.21485*10^-44 Cos[2 theta]) #1^3 + (-3.65541*10^-29 + 
   1.4013*10^-45 Cos[theta] + 2.8026*10^-45 Cos[2 theta]) #1^4 + 
1. #1^6 &, 3], 
Root[(-7.46805*10^-45 - 
   2.21485*10^-44 Cos[2 theta]) #1^3 + (-3.65541*10^-29 + 
   1.4013*10^-45 Cos[theta] + 2.8026*10^-45 Cos[2 theta]) #1^4 + 
1. #1^6 &, 4], 
 Root[(-7.46805*10^-45 - 
   2.21485*10^-44 Cos[2 theta]) #1^3 + (-3.65541*10^-29 + 
   1.4013*10^-45 Cos[theta] + 2.8026*10^-45 Cos[2 theta]) #1^4 + 
1. #1^6 &, 5], 
 Root[(-7.46805*10^-45 - 
   2.21485*10^-44 Cos[2 theta]) #1^3 + (-3.65541*10^-29 + 
   1.4013*10^-45 Cos[theta] + 2.8026*10^-45 Cos[2 theta]) #1^4 + 
1. #1^6 &, 6]} 

Well, this looks terrible but is not wrong. It is just that initial Hamiltonian is not too simple.

Anyway, I can not solve this problem with finding the minimum of F[angle]. Any help would be greatly appreciated!

Thanks, Kathy

share|improve this question
hi; your code does not work as is. please see screen shot !Mathematica graphics in addition, it is not a good idea to start variables and symbols with UpperCase as that can conflict with Mathematica own. Please post complete and small working example. – Nasser Dec 19 '12 at 14:39
2  
as a general rule, you should probably switch to dimensionless units when doing numerics. Using the Boltzmann constant in SI units will lead to extreme floating point numbers. As for the actual question, if I define enf[theta_]= the expression you gave and plot it, I always get the right minimum (comparing to a plot) – acl Dec 19 '12 at 16:00
@acl The problem is not really the small values (because in a floating point representation they merely adjust an exponent). There is a severe precision problem due to the huge disparity of size in the expression -3.65541*10^-29 + 1.4013*10^-45 Cos[theta]...: at machine-level precision, the first term swamps essentially all the precision in the remaining terms. A multiplicative change in units would not fix this. Calculation to about 25+ decimal digits is needed here in order to do anything reasonable. – whuber Dec 19 '12 at 17:49
@whuber thanks. I'm not really claiming that the problem is or isn't the small values, merely pointing out that doing this sort of thing with dimensionful quantities is generally a bad idea (hence "as a general rule"). I haven't the slightest clue what the problem is here or indeed what the source of those numbers of different magnitude is. If I did I'd have written an answer, not a comment. – acl Dec 19 '12 at 17:52

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.