Message Boards Message Boards

Find fit parameters which will fit experimental data using a Hamiltonian?

Hello! I am currently working on a theoretical model for a Hamiltonian which describes the Strongly deformed nuclei. I've obtained the analytical form of the energies, and now I want to find two parameters which will fit the experimental data in the best way possible. I know there are two ways (at least): One of to use the Fit function or to use Minimize function in Mathematica. I am working with the Minimize function, which basically tries to find the best parameters such that Chi^2 function will me minimum. \sum(Eth-Eexp)^2=minimum. I have introduced my data, as a simple array, I wrote my formulae carefully, and then I just called the Minimize function. Unfortunately this is not working :( I have denoted my parameters with "a" and "b". I also now that my parameters should be in some ranges (that's why I put some extra conditions in the Minimize call). I only tried the first data set. I don't know why it's not working. And before you ask, I checked whether to see if the functions under the square root are positive or not, and for values "a" and "b" greater than 10 and 20 respectively, the positivity is OK.

If you can help me, it would be great! Thank you in advance! Cheers, RP.

Attachments:
POSTED BY: Robert Poenaru
4 Replies

Also, don't start variable or function names with capital letters

POSTED BY: Frank Kampas

I would recommend avoiding using subscript variable in evaluations. Just use simple notation like g3. Also avoid Greek and special notation when you can. All this makes code huge and unstable and hard to read.

POSTED BY: Sam Carrettie
Posted 7 years ago

There are some typos in the notebook:

(1) $\gamma_1 \gamma_2$ has no space between them in the following: Typo 1

(2) There's an extra "something" after $\gamma_1$:

Typo 2

POSTED BY: Jim Baldwin

As an experiment, I tried minimizing just the first term of your expression and got a useful error message

In[51]:= NMinimize[{(E1[6.5] - tsd1[[1]])^2, a > 10 && b > 20}, {a, b}]

During evaluation of In[51]:= NMinimize::nnum: The function value (96.4742 +Sqrt[86916. -Sqrt[7.55438*10^9+Times[<<2>>]]]/(2 Sqrt[2])+Sqrt[86916. +Sqrt[7.55438*10^9-3.97633*10^6 Plus[<<2>>]]]/(2 Sqrt[2]))^2 is not a number at {a,b} = {11.9186,21.6635}.

During evaluation of In[51]:= NMinimize::nnum: The function value (96.4742 +Sqrt[86916. -Sqrt[7.55438*10^9+Times[<<2>>]]]/(2 Sqrt[2])+Sqrt[86916. +Sqrt[7.55438*10^9-3.97633*10^6 Plus[<<2>>]]]/(2 Sqrt[2]))^2 is not a number at {a,b} = {11.9186,21.6635}.

During evaluation of In[51]:= NMinimize::nnum: The function value (96.4742 +Sqrt[86916. -Sqrt[7.55438*10^9+Times[<<2>>]]]/(2 Sqrt[2])+Sqrt[86916. +Sqrt[7.55438*10^9-3.97633*10^6 Plus[<<2>>]]]/(2 Sqrt[2]))^2 is not a number at {a,b} = {11.9186,21.6635}.

During evaluation of In[51]:= General::stop: Further output of NMinimize::nnum will be suppressed during this calculation.

Out[51]= NMinimize[{(-1739.3 + 
    a (179.376 - 8/5 b Cos[(43 \[Pi])/180]) + 
    1/(2 Sqrt[
      2]) (\[Sqrt](a^2 (222.029 + (7.51018 + 
               32/65 Sqrt[3] b Sin[(17 \[Pi])/180]) (12.1941 + 
               16/65 Sqrt[3]
                 b (Sqrt[3] Cos[(17 \[Pi])/180] + 
                  Sin[(17 \[Pi])/
                   180]))) - \[Sqrt](a^4 (222.029 + (7.51018 + 
                  32/65 Sqrt[3] b Sin[(17 \[Pi])/180]) (12.1941 + 
                  16/65 Sqrt[3]
                    b (Sqrt[3] Cos[(17 \[Pi])/180] + 
                    Sin[(17 \[Pi])/180])))^2 - 
            4 a^4 (-47.7013 + 
               7.51018 (7.51018 + 
                  32/65 Sqrt[3]
                    b Sin[(17 \[Pi])/180])) (-89.1844 + (12.1941 + 
                  16/65 Sqrt[3]
                    b (Sqrt[3] Cos[(17 \[Pi])/180] + 
                    Sin[(17 \[Pi])/180])) (6.00082 + 13/(2 
\!\(\*SubscriptBox[\(17\), \(\[AliasDelimiter]\)]\))))))) + 
    1/(2 Sqrt[
      2]) (\[Sqrt](a^2 (222.029 + (7.51018 + 
               32/65 Sqrt[3] b Sin[(17 \[Pi])/180]) (12.1941 + 
               16/65 Sqrt[3]
                 b (Sqrt[3] Cos[(17 \[Pi])/180] + 
                  Sin[(17 \[Pi])/
                   180]))) + \[Sqrt](a^4 (222.029 + (7.51018 + 
                  32/65 Sqrt[3] b Sin[(17 \[Pi])/180]) (12.1941 + 
                  16/65 Sqrt[3]

                    b (Sqrt[3] Cos[(17 \[Pi])/180] + 
                    Sin[(17 \[Pi])/180])))^2 - 
            4 a^4 (-47.7013 + 
               7.51018 (7.51018 + 
                  32/65 Sqrt[3]
                    b Sin[(17 \[Pi])/180])) (-89.1844 + (12.1941 + 
                  16/65 Sqrt[3]
                    b (Sqrt[3] Cos[(17 \[Pi])/180] + 
                    Sin[(17 \[Pi])/180])) (6.00082 + 13/(2 
\!\(\*SubscriptBox[\(17\), \(\[AliasDelimiter]\)]\))))))))^2, 
  a > 10 && b > 20}, {a, b}]
POSTED BY: Frank Kampas
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract