Why Am I Getting Errors with Subscripts in Mathematica's NMinimize?

  • Context: Mathematica 
  • Thread starter Thread starter parzio
  • Start date Start date
  • Tags Tags
    Method
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 3K views
parzio
Messages
4
Reaction score
0
Hi guys!

I am trying to acquire some experience in Mathematica and goal programming.
In the example shown in the attached image I am trying to minimize the deviations in order to obtain the first row matrix value nearest to 10.



In this case I should obtain x11=5 , n1=5 and p1 =0 instead of i receive these errors:

Part::pspec: Part specification Subscript[x, 1,1] is neither an integer nor a list of integers. >>
Part::pspec: Part specification 0.6524678079740285` is neither an integer nor a list of integers. >>
NMinimize::bcons: The following constraints are not valid. >>

Does someone explain me why I obtain these errors??
 

Attachments

Last edited:
Physics news on Phys.org
parzio said:
Does someone explain me why I obtain these errors??

Partly because you are trying to use subscripts.

Again and again and again people come here or to other forums and say "I'm using subscripts in this Mathematica problem and it doesn't work, what do I do?"

Again and again and again the answer is either become sufficiently skilled that you understand how to use the tricks and work-arounds needed to get subscripts to work in Mathematica OR just quit trying to use subscripts and make your life much easier.

Much of published mathematical notation is inconsistent at one or more levels and depends on the reader being mathematically mature enough to know what the author intended. Mathematica is not mature enough to know what you intend. Mathematica depends on you being sufficiently Mathematica mature to know how to write in a way that Mathematica will understand.

Subscripts are not "first class citizens" in Mathematica notation and cannot be used anywhere any other symbol can be used if you expect to get the same results. But new Mathematica users see that subscripts are available and have no idea of the difficulties that these can deliver.