Questions tagged [indexed-variable]

Questions about indexed variables and related alternative methods to allow assigning indexed names to objects.

Filter by
Sorted by
Tagged with
2 votes
2 answers
152 views

Lorentz indices contraction

I have a complex expression involving second-rank tensors and Kronecker Deltas. How can I instruct Mathematica to utilize the Kronecker Deltas and perform proper index replacements? For example, ...
Hawi's user avatar
  • 173
4 votes
1 answer
98 views

Using Indexed variables in Compile?

This follows a: useful post about Compile from about 10 years ago In that post there is a comment: You can not really use indexed variables in Compile, although it may appear that you can. For ...
Craig Carter's user avatar
  • 3,968
2 votes
2 answers
91 views

Symbolic Indexing on Symbolic Arrays

Is there a way to use symbolic indices on symbolic vectors? The most barebones example I can think of is the following: aV = Array[a,3]; aV[[m]] which evaluates to ...
ertl's user avatar
  • 121
1 vote
2 answers
54 views

How to extract manipulated indexed variables from Manipulate

I am struggling with getting values of variables that are manipulated with Manipulate: The code: ...
atapaka's user avatar
  • 3,733
1 vote
0 answers
41 views

Update some elements of a symbolic matrix

I am trying to build, update and manipulate a binary matrix in an optimization problem using NMinimize. The variable to be optimized on is a vector ...
WaterFox's user avatar
  • 185
5 votes
1 answer
59 views

Assumptions about indexed variables

I am interested in the most efficient way to impose assumptions on indexed variables. In the following stylized problem, the following code ...
oyy's user avatar
  • 187
0 votes
1 answer
79 views

How to specify and use indexed variables of undefined quantity?

These are toy examples intended to elicit general knowledge on indexed variables of undefined (symbolic) quantity; please feel free to offer better examples. Suppose I wish to "solve" this: $...
Julian Moore's user avatar
  • 2,560
0 votes
1 answer
71 views

Replace elements of indexed list by list of rules

I have an array bs that contains many indexed elements b[ ]. I want to define the values of bs by a list of replacement rules. ...
granular bastard's user avatar
1 vote
1 answer
74 views

Indexed array cannot be named by the name of its elements

Indexed Arrays or lists can be created by Array[k,3] (*{k[1], k[2], k[3]}*) However I would like to name this list also by k, i....
granular bastard's user avatar
2 votes
2 answers
342 views

Would it be poor advice to assign roman numerals as top variables?

For example like so. x = 10; xi = 11; xv = 15; Is there an automated way to spit these numbers out maybe 1-1000.
William's user avatar
  • 7,575
1 vote
1 answer
221 views

xAct: How to identify and split module dummy indices?

Hi I'm using the package xAct but I'm running into an issue. It seems that before using //ChristoffelToGradMetric the christoffel connection has indices (which can ...
Tim's user avatar
  • 21
1 vote
1 answer
167 views

Counting multiple $-sign string indices in output and replacing them by normal indices

I'm using the package xTensor in xAct. My issue is that inside a module indices are replaced by strings of the form $##### which make the final output unreadable. In a related post Print expressions ...
Tim's user avatar
  • 21
5 votes
5 answers
897 views

List of letters longer than the alphabet

I would like to create a list of the first $n$ letters of the english alphabet. Importantly, I would like that in case $n$ is bigger than the size of the alphabet, the letters will start repeating in ...
Federico Carta's user avatar
2 votes
1 answer
110 views

Handling dummy variables 2

This is a detailed exploration of my previous post, There was some comment by @Nasser and @yarchik, I post my module in detail ...
phy_math's user avatar
  • 803
0 votes
1 answer
106 views

Creating and defining a family of functions with indexed variables?

I am trying to do the following: Create a list as Table[Subscript[\[Beta], i] _, {i, 1, dim}] And then use this list to define a function: ...
Red Banana's user avatar
  • 5,121
5 votes
3 answers
161 views

Listing all Index Possibilities Given a Vector and Indexed Set

Let's say I am given a vector $v=(5,2,-2,-4,3)^T$ and $\alpha \in \{-1,1\} $. I want to find all indices $(\alpha,i)$ such that $\alpha v_i >0$, where $v_i$ is the $i$th entry of the vector $v$ ...
Vegeta the Prince of Saiyans's user avatar
0 votes
1 answer
75 views

Avoiding For loops to perform an assignment to a variable with indices of user-choice [duplicate]

I am looking for an efficient way to perform the following operation without For loops ...
Saurabh Maiti's user avatar
3 votes
2 answers
200 views

Replacing multiple variables according to the index

I'm currently working on the Polya's Enumeration Theorem implementation in Mathematica. As an example, of what I want to do, here's a formula I'm working with: $$P_{C_{12}}(x_1,\ldots,x_{12})=\frac{1}{...
mikemykhaylov's user avatar
3 votes
2 answers
77 views

Solve with a non-numerical-index constant

I have 4 different constants in a given expression. Due to their physical interpretation, it makes sense to label them with non numerical indices, such as $r_+$. The problem is that they prevent even ...
Sergio Jorás's user avatar
0 votes
2 answers
88 views

Extract subscript of variable in product

My input is a product of the variable x with index: x[1]^2 x[5] x[7] How do I extract the indices of the above product to get ...
Camilo's user avatar
  • 13
1 vote
1 answer
397 views

How to assign values of variables with index

I'm trying to plot the following function $V(\{r_j\})=\sum^n_{i<j,j=1} \frac{1}{|r_i-r_j|^2}$ in Mathematica. For the expression of this function, I wrote ...
Victoria's user avatar
3 votes
0 answers
153 views

Summation variables aren't recognised as dummy variables

I'm trying to write this expression in Mathematica, and calculate the following quantity However, when I tried the following ...
Our's user avatar
  • 229
0 votes
2 answers
168 views

Indexed variable - Function that contains summation

I have the following problem: I have a function that looks like $f(c_1 , c_2 ) = c_1 + c_2 + c_3$. The variables are $c_1$ and $c_2$, $c_3$ is a known constant. I would like to define a function in ...
MegAmaNeo1's user avatar
4 votes
1 answer
200 views

Differentiation by indexed variable in equation of Christoffel Symbols

I am very new to Mathematica, and am trying to use it to compute Christoffel symbols for a certain manifold. All this requires is taking some indexed sums of derivatives, but it builds up on several ...
Rough L's user avatar
  • 43
1 vote
2 answers
124 views

how to create a list of machine-made index names

How can I create such lists of variables: list1={sus1[t],sus2[t],sus3[t],...,sus99[t]}; list2={inf1[t],inf2[t],inf3[t],...,inf99[t]}; Consecutive ...
Tugrul Temel's user avatar
  • 5,508
6 votes
1 answer
266 views

Undefined Indexed Variable

I searched already a lot about indexed Variables, and it tends to be the most applicable way to use tensor notation. But I am having a hard time to solve for undefined indexed variables: Here my ...
oyy's user avatar
  • 187
1 vote
1 answer
123 views

Can I overload Part for specific heads (a la overloaded array subscripting)? [closed]

Mathematica/Wolfram Language newbie here. The behavior I am after is to be able to "overload" the subscripting of me-defined objects/Heads and thereby use them as if they were ...
user avatar
2 votes
0 answers
89 views

Referring to matrices with index [closed]

For exampe I have two matrices, with index 1 and 2 Mat[1] = ConstantArray[0, {2, 2}] Mat[2] = ConstantArray[0, {2, 2}] I wanna assign new value with ...
Nigel1's user avatar
  • 741
3 votes
2 answers
281 views

How to use a list of indexes as a variables inside a Module?

This is a trivial function, just to show that Module does not recognize the list generated by Table. ...
pablo's user avatar
  • 31
1 vote
1 answer
89 views

How does Mathematica evaluate sums where the upper limit of the index is not an integer?

I am interested in the way Mathematica evaluates sums where the upper limit of the index is not an integer - i.e., sums that are some sense mathematically meaningless. For example: ...
Richard Burke-Ward's user avatar
3 votes
2 answers
337 views

Define implicit dummy index?

I've been looking for a solution to this question for a while. I was wondering if anyone is aware of a way of defining symbolic dummy indices to implement Einstein's convention. Let me explain with an ...
Einj's user avatar
  • 157
0 votes
1 answer
269 views

Subscripts use to make expression readable [duplicate]

I am trying to write a function in mathematica which depends on different parameters. For example $$f(x_1, x_2, x_3, x_4, x_5)= 2x_1+\sin(x_2)+x_3*x_4-x_5^{-1}$$ (My actual function has 12 such ...
CouchPotato's user avatar
6 votes
2 answers
334 views

How to create a nested list of variable depth with indexed elements

i want to obtain this definition of a nested list t = Table[C[i, j], {i, 3}, {j, 3}] with arbitrary depth, ...
Rainer Glüge's user avatar
3 votes
0 answers
180 views

Parallelize import of many files

I'm trying to speed up the import of a large number of files, using ParallelTable to store them in a indexed variable, eqDump. The files are in the folder "Frames" and are named "Conf_Run.1000", "...
kl0z's user avatar
  • 171
1 vote
1 answer
281 views

Getting a stored variable from its value

Given a numerical value, is it possible to check whether that value is stored in (or defines) some variable in the notebook? Maybe if I could list all of the defined variables, then I could simply ...
sam wolfe's user avatar
  • 4,179
6 votes
2 answers
1k views

Defining a function of arguments with sub- and superscripts

I want to define a function that takes, several, let's say two arguments, both of which have several sub- and suberscripts. For example a function might have the signature $$ f(x_i,q_{j,k}) = \mathrm{...
HerpDerpington's user avatar
1 vote
1 answer
57 views

Manipulating variables indexed by a list

I have a variable g, indexed by a list: g[{1,1}]=11; g[{1,2}]=12; g[{2,1}]=21; g[{2,2}]=22; I would like to move things around as follows: ...
Paul R.'s user avatar
  • 877
6 votes
1 answer
2k views

Best way to write an equation with subscripts and superscripts

This post is not about a specific Mathematica problem but about to develop the best way to enter mathematical equations with subscripts and superscripts. I have a ...
Tugrul Temel's user avatar
  • 5,508
3 votes
1 answer
1k views

xAct, xTensor: How to avoid clash of indices?

Please refer to the picture below. In the first line, I define the angular momentum vector $\vec{L} = \vec{R} \times \vec{P}$ using the Levi-Civita tensor $\epsilon^{i}_{jk}$. The definition relies on ...
Sashwat Tanay's user avatar
1 vote
2 answers
245 views

Collecting terms from expression with indexed functions

Say I have an expansion of terms containing functions y[j,t] and its derivatives, indexed by j with the index beginning at 0 ...
Decebalus's user avatar
  • 115
0 votes
1 answer
47 views

Getting named functions from an sequence of parameter values applied to a parametric function [closed]

The general question is how can I loop on names and indices? An example: I have pfun = ParametricNDSolveValue[{y'[t] == a y[t], y[0] == b}, y, {t, 0, 10}, {a,b}] ...
J.A's user avatar
  • 1,265
0 votes
2 answers
599 views

Summation over an index and a set

I have an index CC and a set of values CM, and c is an element of CM and ...
Tugrul Temel's user avatar
  • 5,508
2 votes
1 answer
125 views

Loop with indexed function not defined for some index values [duplicate]

If anyone cares, this is supposed to be a very simple implementation of a Metropolis algorithm for a uniform distribution. I want to plot the variance of the sampled values as a function of an ...
Ryland Forsythe's user avatar
9 votes
1 answer
990 views

Einstein summation convention for symbolic vector calculus

I am trying to do some vector calculus in Mathematica in index notation form because it gives a clear result that can be compared to pen and paper calculations. Since there is no built in Einstein ...
Takoda's user avatar
  • 765
0 votes
2 answers
269 views

Sum over integer partition with variable function argument

Define $$\hat{X}(Y) = [X,Y] $$ I have known matrices $S_i$ and $V$. I am trying to use Mathematica to define a function which calculates $$ \sum_{\substack{n_1, \ldots, n_k>1\\ n_1+\ldots n_k = ...
Jagerber48's user avatar
1 vote
1 answer
237 views

Create list of values with arbitrary index and the use it in a function

I have the following generating functions: $l_{2i-1}=l_{1}-(i-2)(w+s)$ with $i\geq 2$ and $l_{2i}=l_{2}-(i-1)(w+s)$ with $i\geq 2$, so the first one is for odd index and the second for even index. ...
Felipe Gonzalez's user avatar
4 votes
1 answer
70 views

Taking a Part of a Part of a Variable

Say I have Part of a variable x. Part[x, 1] Then, I'll get an error message, as the ...
LBogaardt's user avatar
  • 1,585
2 votes
2 answers
70 views

Naming indexed output streams

I need to write into multiple files in a Do loop. Hence, I tried to open multiple streams: ...
Karamveer Kaur's user avatar
0 votes
1 answer
57 views

How to truncate equation with multivariables

I am trying to set certain terms zero. How to set terms with greater than 'a3' and 'an3' zero in the following equation: ...
parmeshwar89's user avatar
2 votes
0 answers
115 views

ParallelDo with doubly-indexed iterators

What is the reason that ParallelDo works with singly-indexed iterators, but not doubly- or more-indexed iterators? For example, the code ...
Andrew Patrick Turner's user avatar