Mathematica Mathematica:input subscript value

  • Thread starter Thread starter shafieza_garl
  • Start date Start date
  • Tags Tags
    Value
AI Thread Summary
The discussion centers around efficiently assigning values to subscripted variables in Mathematica. Users explore different methods to quickly set values for Subscript[d, i] using lists, with examples including the use of Table, Map, and the shorthand notation for applying functions to lists. The conversation also touches on how to simplify expressions involving division of other subscripted variables, demonstrating a method using the Apply function. A cautionary note is provided regarding the complexities and limitations of using subscripts in Mathematica, highlighting that they do not behave like ordinary variables and can lead to confusion. Users are advised to be aware of these issues when working with subscripts to avoid common pitfalls.
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
Views
3K
Replies
2
Views
2K
Replies
6
Views
2K
Replies
3
Views
3K
Replies
3
Views
4K
Replies
2
Views
3K
Replies
10
Views
4K
Replies
2
Views
4K
Replies
8
Views
2K
Back
Top