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
Click For Summary
SUMMARY

The discussion centers on the errors encountered when using subscripts in Mathematica's NMinimize function. Users reported issues such as "Part::pspec" and "NMinimize::bcons" errors, indicating that subscripts are not treated as first-class citizens in Mathematica. The consensus is that new users must either learn the specific workarounds for subscripts or avoid using them altogether to prevent complications. Understanding the limitations of subscripts in Mathematica is crucial for effective problem-solving.

PREREQUISITES
  • Familiarity with Mathematica syntax and functions
  • Understanding of NMinimize functionality in Mathematica
  • Basic knowledge of mathematical notation and its representation in programming
  • Experience with error handling in Mathematica
NEXT STEPS
  • Research the use of "Subscript" in Mathematica and its limitations
  • Learn about alternative methods for representing variables in Mathematica
  • Explore advanced error handling techniques in Mathematica
  • Study the documentation for NMinimize to understand its constraints and requirements
USEFUL FOR

This discussion is beneficial for Mathematica users, particularly those new to the software, mathematicians, and anyone involved in optimization problems using NMinimize.

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.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
Replies
5
Views
16K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
12
Views
9K
  • · Replies 6 ·
Replies
6
Views
4K
Replies
1
Views
15K