Skip to main content

Questions tagged [index]

Questions about functions with intrinsic part index such as SparseArray, Part and Indexed or iteration variable indexes such as MapIndexed, Sum and Product.

Filter by
Sorted by
Tagged with
0 votes
1 answer
70 views

Finding Minimum Hamming Distance

Given a set of vectors, $\{v_1, \dots, v_n \}$, I'd like to find their minimum Hamming Distance, $\min_{1 \leq i < j \leq n}|v_i - v_j|$. My main issue is, I don't know how to do this in ...
0 votes
1 answer
85 views

A problem with indices in tensor

I want to create a tensor similar to the one shown in the first picture, but I'm encountering some issues with indices. Could anybody assist me? Here's my code: ...
0 votes
2 answers
103 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. ...
1 vote
1 answer
73 views

Retrieving only first function in matrix ODE using NDSolve

I have a very stupid question, but I don't use Mathematica very often, so here it goes: I'm trying to solve some "matrix" ODE using NDSolve. The matrix in ...
4 votes
4 answers
422 views

How to replace the element in list of list by its ordering index

I have a list of list: res={{9, 1, 5}, {3, 6, 12}} I want to change it to res={{5, 1, 3}, {2, 4, 6}} by following their ordering ...
34 votes
12 answers
1k views

Sequentially numbering a nested list

I've got a nested list {a, b, {c, d}, e, {f, {g, h}}} which I want to magically transmogrify to ...
3 votes
4 answers
231 views

How to include index for the coefficients in series or sequence

I am trying to use the "Summation" command for the exponent and for the corresponding subscript of the coefficient, but it fails. See the example below: ...
5 votes
2 answers
242 views

Map a function that uses the lists indices as arguments

Suppose I have a function f[x_] that I want to Map over somelist (assumed to be one ...
3 votes
6 answers
2k views

How do I find the position of the maximum value in each column of a table?

Given a table of values, I know how to find find maximum values, but how do I find the position of the maximum value in each column. For example, given ...
1 vote
2 answers
80 views

Can't use iterative variable as part specification [closed]

I've got the following mathematica code: ...
10 votes
3 answers
290 views

Function over a list that depends on the index

Suppose I have a list {a, b, c, d} I want to operate on this list with a function which depends on the index of the element, e.g. I want to add the index ...
2 votes
1 answer
81 views

Problem with integration with indexed variable

I wonder why I can not have a correct integration form on Mathematica with some indexed variables. Indeed, when I write : ...
4 votes
2 answers
123 views

RSolve solves only one of two equivalent recurrences

I am having an issue with the RSolveValue/RSolve function. Specifically, Mathematica is able to correctly evaluate ...
29 votes
8 answers
1k views

Faster position list construction from a "take instructions" list

Take some list, e.g., {1,2,3,4,5}, and a "take instructions" list, say {1,1,2,1,1}. The latter is read as "take the first ...
3 votes
2 answers
182 views

How to use Position to select based on absence of a pattern?

I need to use Position to obtain positions of entries in list of lists that do not contain a certain pattern. The problem is that ...
5 votes
3 answers
152 views

Substituting the element of a list into a list that contains the index position

I see similar questions for lists and indexes and manipulating with Thread, MapIndexed,etc., but I do not see how to do a substitution. I have a list of coordinates for a geometric object and a list ...
1 vote
1 answer
139 views

Is there a builtin command or a workaround to generate a nested sum (of apropriate level) from an expanded expression?

I have the following output from some Mathematica manipulation of nested sums. Does Mathematica have a command or combination of commands that recovers nested sums from the expanded form? $$\begin{...
0 votes
0 answers
39 views

One as Subscript and Supersripts

I am trying writing code with a lots of symbols and their products. There is an issue with the appearance of "1" as an index. e.g. Subscript[[Delta], 1 n] Why "1" does not appear ...
6 votes
4 answers
678 views

Find min and max indices of highest and lowest elements in sorted list

I have a list of integers of the form ...
0 votes
1 answer
38 views

index as an attribute for a function containing data frame

Two questions. I have created a sample problem, and would be glad to have your help. I have 2 functions, fun1 and fun2, and one ...
3 votes
0 answers
157 views

Efficiently get positions of Query results

I have some very large Datasets. Is there any efficient method of getting the positions of results found in a Query? That is, without using ...
2 votes
0 answers
403 views

Part::partd: Part specification is longer than depth of object (Simple list) [closed]

I know that this question has already been asked (I searched for answers), but in every thread I saw the code was much more complicated than what I'm trying to do, and I can't understand why this ...
3 votes
2 answers
95 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 ...
3 votes
1 answer
105 views

Summing list elements for given index tuple

Is there a more compact way of summing certain elements of lists together when given a tuple of which elements to sum. For example if I am given the list of size 8: ...
0 votes
2 answers
185 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 ...
0 votes
0 answers
28 views

How to define an index list of local variables for arbitrarily long

Suppose initially I have a list that looks like list1 = {A, B, C} where the elements A, B, C are all matrices. I want to substitute all the three elements by list1 ...
9 votes
3 answers
3k views

How to parse JSON

please forgive me if this is obvious, but I have some JSON: ...
3 votes
2 answers
128 views

Re-defining the built-in `CharacterRange` for a range of 1500 or more

I have the following function (developed by @kglr), and now I need to use the same function with a list of 1043 characters rather than a limited number from A to <...
2 votes
1 answer
393 views

how to add labels of points next to it based on index in ListPlot

I have a list of some points. I plotted each point and its closest surrounding points. ...
1 vote
1 answer
131 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 ...
6 votes
1 answer
292 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 ...
1 vote
1 answer
113 views

How does Indexed work in terms of sparse array

I want to use indexed given that s is an element [0,500] but I am unsure how to write that without getting a format error or a tensor error. ...
4 votes
2 answers
89 views

Index of item inside StructuredArray

How do I extract position of item in StructuredArray without converting using Normal? The following code finds the position of ...
2 votes
3 answers
192 views

Split matrix expression into multiple lines

Given a matrix expression testm = {a + b, c + d, e}; {# , testm[[ # ]] // Simplify} & /@ Range[ Length[testm] ] // MatrixForm \begin{equation}\begin{pmatrix} ...
2 votes
1 answer
84 views

Fancy Indexing of a 4D array (tensor)

I'm trying to mimic the CoefficientArrays function, which I can't get to work for my symbolic equations. The CoefficientList ...
5 votes
1 answer
372 views

How to get the class of neighbors in a 2D periodic matrix?

I'm trying to analyze the spatial structure of some rectangular arrays by counting the number and class/type of neighboring points around every point in the arrays, with periodic boundaries. For ...
3 votes
2 answers
301 views

Labeling elements of a table

I have a table of the form(the table is very long, i put an example): tab1={{{1,10,30},{1,20,54},{1,30,65}},{{2,10,35},{2,20,65},{2,30,70}}} How can I give ...
1 vote
1 answer
823 views

How do I evaluate my functions over a range of values? [closed]

I want to use the list of data which will come from MapData1 (in code); the first element is θ and second is Action(I). I want to use this Action(I) and Angle(θ) in ...
0 votes
2 answers
56 views

Arrange exceptions in a list by some criteria

I have some dataset, which is supposed to have $30000$ in the last column, and I want to find the elements that break this, and arrange them numerically while mantaining the index. What I'm currently ...
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{...
7 votes
1 answer
120 views

How would you explain Nothing[] weirdness? [duplicate]

I would like to use Nothing[] to make some elements of a list invisible. (The intended use is to remove a few unwanted points from a ...
0 votes
1 answer
128 views

Integer functions indices in a sum

I have some troubles with plotted A versus p, especially for the function F(s,l,p), I don´t know how deal with the integer functions indices of the sum. How can I input such a sum to Mathematica?. ...
14 votes
2 answers
1k views

Map vs. Table for index-specific operations on 2D arrays

Many experienced users on this site tend to use Map (and its variants, MapAt, MapIndexed, etc.) rather than Table. When applying the same operation to every element of an array, Map does seem more ...
3 votes
3 answers
999 views

Is there an easy way to index by a binary vector / mask?

I would like to be able to extract elements from a list where indices are specified by a binary mask. To provide an example, I would like to have a function ...
1 vote
2 answers
253 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 ...
2 votes
0 answers
117 views

Typography of Mixed Tensor Index Notation

How can one properly and quickly write a mixed "tensor" such as $\Gamma{}_{1}{}^{2}{}_{3}$? Shortcuts such as esc Gamma esc, Ctrl+^, Ctrl+_ are prefered. I intendd to use this in an inline equation ...
9 votes
2 answers
302 views

Unable to use indexed variables with NDEigensystem

I am trying to solve a system of differential equations with NDEigensystem, but there need to be arbitrarily many of them. I want to use indexed variables like a[i], which works fine with NDSolve, but ...
3 votes
2 answers
246 views

How to convert span to flat list of indices?

Let sp be a Span object, and n a non-negative integer. I'm looking for an efficient way to ...
1 vote
1 answer
256 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. ...
2 votes
0 answers
763 views

Sum over multiindex

I would like to calculate a sum over some multi-indices, that follow a specific pattern. $$\sum\limits_{1\le i_1<i_2<...<i_k\le N} A(k,i_1, i_2, ..., i_k).$$ $A$ is a fix expression of the ...