The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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.

69 questions
Filter by
Sorted by
Tagged with
71 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?. ...
366 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 ...
136 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 ...
112 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 ...
70 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 ...
38 views

Creating lists of values referring to the same index

I would like to code lists of the form: Ai = {x0, x1, x2, x3, ...} Bi = {y0, y1, y2, y3, ...} where the index i refers to the elements 0,1,2,3, etc., across all lists that I make. The values in the ...
46 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 ...
57 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. ...
165 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 ...
20 views

Why do I have to index my covariance matrix as if it has 3 dimensions [duplicate]

The language reference for getting parts of a matrix seems to make sense. I'm wondering why my covariance matrix behaves differently. ...
62 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 ...
43 views

Defining list of data

I need to define a list of parameters A[i] where i runs from 1 to some integerN. The ...
88 views

Algorithm for Swapping indices and simplifying the summand in a double sum [closed]

Say we have something like $$\sum_{p}^N\sum_{q}^N \cos(p) \sin(q) - \cos(q)\sin(p)$$ usually, in the case like this, the indices p and q can be swapped, and the sum simplifies to 0. I have an ...
322 views

Indexing nested list with another list

So I'm wanting to index the sublists within a list using another list. So I have x = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}} And I want the 2nd term of the first ...
447 views

Finding the x-value corresponding to a y-value found using Nearest [closed]

I have a large 2d array of infinite precision named "data" of x values and y values. I am using Nearest to find the y-value closest to a specified number, say 0....
113 views

subscript index notation select certain value [closed]

I have an indexed variable Subscript[p, s, m, t] established using the Notation method. There are various expressions where s, <...
38 views

Part[] for multi-index array [duplicate]

If I want to set element (i,j) of two-dimensional array X to 0, I can write X[[i,j]] = 0. My question is how can I achieve this if I have the indices i and j in a ...
317 views

Add Index to All Elements of a List

My goal is to add an index to all elements of a list in the form {"a", "b", "c", ... }, so it becomes ...
558 views

How to use the value returned from Position as index for another list? [duplicate]

say, I want to find an index of a specific element in a list using Position[{a, b, c, d, e, f}, c] and it returns {{3}} How ...
320 views

Getting error messages during double summation [closed]

I have two lists xi and ai of equal length, n. I would like to perform a sum over the ...
56 views

Condition on the index of an element $a_{i,j}$

This question may seem to be easy. But I did not find the right way after several attempts I need to put a condition in general for $a_{i,j}$ ,If the i is bigger ...
118 views

Using sparse matrices when value depends on position

I am working with solving a linear system that becomes a tridiagonal matrix. In order to speed up the process for large matrices, I want to use sparse matrices. My problem is that the values are not ...
124 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 ...
1k views

How to parse JSON

please forgive me if this is obvious, but I have some JSON: ...
220 views

contraction of indexes takes long time

I have got an expression which has more than a hundred terms being added up together, each of terms are similar in mathematical form....
178 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 ...
45 views

How can I retrieve an element of an array created with Range? [duplicate]

I have the following Mathematica code where I create a linearly spaced array of numbers and try to retrieve the third element: ...
145 views

How to map functions twice?

I would like to plot multiple lists. The table looks like a={{1,2,3,0,0,0,0,0,0},{1,2,3,0,0,1,0,0,0},{1,2,3,0,0,0,2,0,0},...,{1,2,3,0,0,0,0,3,0}} I want to plot ...
715 views

How to set variable from imported data

I have an excel file i would like to import as data in mathematica with 3 columns like below: Column 1: the nodal numbers Column 2: the values of mx Column 3: the value of mxy Once ive imported the ...
215 views

Using a set of indices to select a subset of an array

Let's say I have a 1D array a, I can use a list of indices b to select a subset of that array: ...
208 views

Slicing an Association with named key span without normalizing?

Is there way to slice an Association with named key span? Span currently doesn't accept named keys: ...
51 views

How to use Table function with two parameters executed when they are not equal? [duplicate]

I have a list, param2 = { {-qlim, -qlim}, {-qlim, qlim}, {qlim, -qlim}, {qlim, qlim} }; and want to get combination of them with, ...
663 views

define variable index

im in the medal of coding and i reached the point where i have something like this, the problem is i have up to 35 terms and all should be index in order to preform summation to count all ...
40 views

Fast list update using list of indices with repetitions

I want to update a vector like this: list = {0, 0, 0, 0}; updval = {1, 1, 1}; updind = {2, 2, 3}; list[[updind]] += updval; list The result is ...
220 views

What's wrong with the Sum function?

Here are the codes: ...
156 views

Assigning Values of Indexed Variables to Arrays

New to mma. I have assigned the results of using Solve to solve 5 variables to 5 indices of a new variable: ...
260 views

Basic Search Functionality

Let say I have three blocks of text like the following. {"first block of text with random content","different block of text","1 2 3 4"} Now let's say I want to ...
220 views

An alternative to subscripts?

Are there any good alternatives to using subscripts to keep track of and uniquely identify many variables? I know that subscripted variables behave badly. Thanks!