What is causing the NMinimize error in my Mathematica calculation?

In summary, the conversation was about a problem with a calculation, specifically the function XDDO154 that was resulting in an error message. The code being used involved tables, specifically DDO154vobs, DDO154pc, and DDO154err, which were described as tables with one column of numbers. Eventually, it was discovered that the issue was with a table and the conversation ended with thanks.
  • #1
gaby287
14
0
What wrong with my calculation.the problem is from the attachment.
It keeps saying:
NMinimize::nnum: "The function value {10721.1} is not a number at {rs,x} = {1.91862,1.66351}. "

My code:

XDDO154[x_, rs_] :=
Sum[(DDO154vobs[] -
Sqrt[(4 Pi*(43.040600502)*x*
rs^(3)/(DDO154pc[]))*(-DDO154pc[]/(DDO154pc[] +
rs) + Log[((DDO154pc[] + rs)/rs)])])^2/
DDO154err[], {i, 1, 61}]

NMinimize[{XDDO154[x, rs], 0 < x && 0 < rs}, {x, rs}, Method -> "DifferentialEvolution"]

(DDO1254pc, DDO154err are tables)
 
Physics news on Phys.org
  • #2
What do DDO154vobs, DDO154pc, and DDO154err look like?
 
  • #3
They are tables of one column with numbers, like velocity, distance and errors.
 
  • #4
Forget it¡ Something was wrong with my table. Thanks¡
 

1. How does NMinimize work in Mathematica?

NMinimize is a built-in function in Mathematica that is used to minimize a multivariable function by finding the values of the variables that minimize the function. It is based on the Nelder-Mead method, which is a derivative-free optimization algorithm.

2. What is the syntax for using NMinimize in Mathematica?

The basic syntax for using NMinimize in Mathematica is:

NMinimize[fun, vars, init] where "fun" is the function to be minimized, "vars" is a list of variables, and "init" is a list of initial values for the variables.

3. How can I specify constraints when using NMinimize in Mathematica?

Constraints can be specified in NMinimize by using the "Method" option and setting it to "NMinimizeConstraints". This allows you to specify constraints on the variables using the "RegionFunction" option.

4. Can NMinimize be used for non-linear optimization problems?

Yes, NMinimize can be used for both linear and non-linear optimization problems. However, it is more efficient for non-linear problems as it does not require the calculation of derivatives.

5. Are there any limitations to using NMinimize in Mathematica?

While NMinimize is a powerful optimization tool, it does have some limitations. It may not always find the global minimum of a function, and it may struggle with functions that have many local minima. Additionally, it may take longer to converge for highly non-linear functions.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
144
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
4K
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Back
Top