Mathematica:input subscript value

  • Context: Mathematica 
  • Thread starter Thread starter shafieza_garl
  • Start date Start date
  • Tags Tags
    Value
Click For Summary

Discussion Overview

The discussion revolves around how to efficiently assign values to subscripted variables in Mathematica. Participants explore methods for inputting multiple values into subscripted variables and simplifying equations involving subscripts.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant asks how to quickly assign values to subscripted variables using a list, proposing a syntax like Subscript[d,i],{i,4}={3,7,0.6,5}.
  • Another participant provides several code snippets demonstrating how to achieve this using Table and Map functions, showing that Subscript[d,1] returns 3, Subscript[d,2] returns 7, and Subscript[d,3] returns 0.6.
  • Further, a participant inquires about simplifying equations involving divisions of subscripted variables, suggesting a similar approach to the previous assignment method.
  • Another response shows a method to assign values based on divisions of other subscripted variables, but emphasizes that the syntax may lead to confusion and issues due to the nature of subscripts in Mathematica.
  • A cautionary note is raised about the common pitfalls when using subscripts, indicating that they do not behave like ordinary variables and can lead to unexpected results.

Areas of Agreement / Disagreement

Participants present various methods and approaches to the problem, but there is no consensus on a single best method. The discussion highlights the complexities and potential issues with using subscripted variables in Mathematica.

Contextual Notes

Participants note that subscripts in Mathematica can lead to problems and inconsistencies, suggesting that users should be cautious and aware of these limitations when working with them.

shafieza_garl
Messages
20
Reaction score
0
Hi all,
i want to ask a very simple question.
the data i have is:
Code:
Subscript[d, 1]=3;
Subscript[d, 2]=7;
Subscript[d, 3]=0.6;
Subscript[d, 4]=5;
is there any way i can put the value faster like subscript[d,i],{i,4}={3,7,0.6,5}.

Thanks advance,
 
Physics news on Phys.org
In[1]:= Table[(Subscript[d,i]={3,7,0.6,5}[]),{i,4}];Subscript[d,1]
Out[2]= 3

OR

In[3]:= i=1;Map[(Subscript[d,i++]=#)&,{3,7,0.6,5}];Subscript[d,2]
Out[5]= 7

OR

In[6]:= i=1;(Subscript[d,i++]=#)&/@{3,7,0.6,5};Subscript[d,3]
Out[8]= 0.6
 
Last edited:
Thanks Bill.:smile:
 
Bill Simpson said:
In[1]:= Table[(Subscript[d,i]={3,7,0.6,5}[]),{i,4}];Subscript[d,1]
Out[2]= 3

OR

In[3]:= i=1;Map[(Subscript[d,i++]=#)&,{3,7,0.6,5}];Subscript[d,2]
Out[5]= 7

OR

In[6]:= i=1;(Subscript[d,i++]=#)&/@{3,7,0.6,5};Subscript[d,3]
Out[8]= 0.6


one more thing.if my eq.is like
Code:
Subscript[d,1]=Subscript[e,1]/Subscript[f,1];
Subscript[d,2]=Subscript[e,2]/Subscript[f,2];
Subscript[d,3]=Subscript[e,3]/Subscript[f,3];
how is it possible to simplify like previous one.

Thanks advance
 
shafieza_garl said:
one more thing.if my eq.is like
Code:
Subscript[d,1]=Subscript[e,1]/Subscript[f,1];
Subscript[d,2]=Subscript[e,2]/Subscript[f,2];
Subscript[d,3]=Subscript[e,3]/Subscript[f,3];
how is it possible to simplify like previous one.

In[1]:= (Subscript[d,#]=Subscript[e,#]/Subscript[f,#])&/@{1,2,3};Subscript[d,1]

Out[1]= Subscript[e,1]/Subscript[f,1]

Just one caution. One of the top handful of reasons people post "this doesn't work, what do I do?" is because they think the just MUST use subscripts and cannot figure out why it isn't working. Search here or in the Wolfram Student forum for Subscript and count the number of posts that match this description.

Subscripts are not "ordinary variables with first class citizenship in Mathematica, despite how they look or how you think they might work." Without admitting that this has been a problem for decades, one of the Wolfram tech support people actually created a notebook to try to explain just a couple of the problems with this and how to try to get around them. Read the SubscriptedVariables101.nb here
http://forums.wolfram.com/student-support/topics/28271

In Mathematica subscripts are a tar pit of problems and inconsistencies. Now and then I find. or see that someone else has found, a wildly new way that subscripts do not work for a completely different reason.

Is it possible to make subscripts work? Sometimes. You have been warned. I hope it works out for you.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 10 ·
Replies
10
Views
4K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 8 ·
Replies
8
Views
2K