Skip to main content

Questions tagged [list-manipulation]

Questions on the manipulation of List objects in Mathematica, and the functions used for these manipulations.

Filter by
Sorted by
Tagged with
0 votes
0 answers
5 views

How to make a Do iterator to get a specified value when calling a function?

Dear Mathematica users, I would like to compile my function first to make the calculations faster. My sample code is as: ...
Kazim Ahmet Hasim's user avatar
5 votes
5 answers
133 views

Counting consecutive units in nested lists

I have nested lists which consist of a series of 1s followed by a series of 0s. p = Table[PerfectNumber[n], {n, 5}]; i = IntegerDigits[p, 2] which results in: {{1,...
stevenvh's user avatar
  • 6,946
2 votes
0 answers
78 views

How to push the performance of this compiled function

I have the function optvals solving for two variables. For the given example of variables, I need the program to run atmost in a millisecond. The main part of the ...
Dotman's user avatar
  • 456
1 vote
0 answers
53 views

How can I efficiently gather similar lists?

I want to gather similar lists by the function sameQ below. Gather works well here, but it's too slow for large data. My real <...
internet's user avatar
  • 793
4 votes
1 answer
94 views

Generate a List of Lists from Two Lists for Histogram Input

I have two lists of equal length: ...
anonmous's user avatar
0 votes
1 answer
71 views

How to speed up generating and filtering large lists of numbers?

I have the following code where I brute force search for two variables. list gives a list of 3 dimensional vectors, say {x,y,z}. ...
Dotman's user avatar
  • 456
1 vote
1 answer
57 views

All possible tuples satisfying conditions

Let $\beta = (\beta_1, \beta_2, \ldots)$ be any given sequence of non-negative integers with all but finitely many $\beta_i$ zero. I want to collect all possible tuples $\beta^{\prime}= (\beta_1^{\...
Anantadulal paul's user avatar
2 votes
2 answers
65 views

How to retrieve the index of a subset in Subsets[list,nspec,{s}]?

Subsets[Range[2000], {4}, {n}] would give the $s^{th}$ subset of the Subsets[Range[2000], {4}]. For example, ...
internet's user avatar
  • 793
1 vote
0 answers
102 views

Implicit Runge Kutta for system of ODEs [closed]

I am trying to build a module that solves a system of ODEs using the implicit Runge-Kutta method but it seems that I have an issue with the convergence condition. Where might the problem be? This is ...
Elis's user avatar
  • 11
3 votes
1 answer
125 views

Nested integration of the list of functions returns error

I have a list of expressions which I would like to integrate by nested integration. For any element from the list it works without issues (see end of the post), however, when I apply nested ...
seva011's user avatar
  • 316
1 vote
0 answers
51 views

Random replacement in array

In the spirit of this interesting article of Stephen Wolfram I also decided to study some issues related to mutations. I’m working with simple {0,1} arrays and I’ve ...
lesobrod's user avatar
  • 1,699
2 votes
1 answer
97 views

Outer function for nested list

I have the following routine where I build a pair of function name lists {Flist, Klist} and 1D argument list {a1,a2,a3,a4,a5}: <...
seva011's user avatar
  • 316
1 vote
1 answer
46 views

Define certain argument in functions which depend on several arguments and built in a list

I got confused working with list of functions of two variables. I construct few lists of functions, one is vector of functions List1 and another is 2D list of ...
seva011's user avatar
  • 316
5 votes
1 answer
147 views

Find permutation that satisfies conditions

Suppose you what to find a permutation of integers {1, 2, ..., 13} that satisfy some rules. Rules can be found in variable rules....
azerbajdzan's user avatar
  • 18.6k
1 vote
2 answers
139 views

Strange behavior of a list manipulation

This is a list of data obtained from numerical calculation, in which the 2nd element in all sublists are the same: ...
lxy's user avatar
  • 189
0 votes
1 answer
61 views

Using List in an Optimisation Problem

I have been adding various constraints to an existing optimiser and came across an issue. My latest constraints requires me to determine a conditional cumulative sum per below. There was an error and ...
legendary kaya's user avatar
0 votes
0 answers
34 views

Plotting a different data set

I am trying to plot the following list in which for each value of x point, we have three different values for the y point list={{1,{1,2,3}},{2,{2,3,4}},{3,{5,6,7}}; ...
sined's user avatar
  • 583
0 votes
1 answer
49 views

Specific array filtering - code optimization

I have a nested list where all sublists have a length 2, eg: {{1,2}, {1,1}, {3,4}, {3,5}, ...} I need to filter it for two requirements: Delete all sub-lists ...
lesobrod's user avatar
  • 1,699
0 votes
2 answers
63 views

Table over a region

in Mathematica we can easily use SliceVectorPlot3D to create a vector plot over a given region in 3D. For example for some arbitrary field ...
Nitaa a's user avatar
  • 770
3 votes
4 answers
286 views

What other methods are there to extract from a list the sublists that contain the same elements as a target list while preserving the order ?

How can we extract from the list ...
csn899's user avatar
  • 4,315
5 votes
6 answers
363 views

Using DeleteDuplicates with choosing which item of the pair should be deleted

How to delete duplicates on criteria that an interval is duplicate if it is fully contained in another interval and the smaller interval should be removed. None of the following works on both lists <...
azerbajdzan's user avatar
  • 18.6k
3 votes
2 answers
114 views

Plot of Density of States Using DiracDelta Function [duplicate]

I am trying to plot the density of states $$ N(E)= \frac{1}{N}\Sigma_{k} (\delta{(E - \epsilon_{k}))} $$ where $\epsilon_{k} = -2t*[cos(k_x)+cos(k_y)]$ and $k$ goes from $-\pi$ to $\pi$. For this plot,...
CuriousMind's user avatar
0 votes
1 answer
72 views

How to apply the Manipulate function on a 5D data set and visualize the data using ListContourPlot? [closed]

Say you have a data set with 5 columns and each column is defined by the variables theta, phi, x, y, z such that data(theta, phi, x, y, z). I would like to use the Manipulate function on this list and ...
Quantum Kid's user avatar
3 votes
5 answers
172 views

Importing Specific Data from a Text File

I am quite new to Mathematica. I have a text file that upon importing has a repetitive structure with characters included. I need to extract only the following in numbers only (no letters, dash lines, ...
LollyPop's user avatar
4 votes
4 answers
200 views

How to tally a list of lists only by considering the first element of the sub list

We need to Tally a list of lists only by considering the first element of the sub lists and then sort the resulting list. As a simple example consider ...
SPJ's user avatar
  • 159
2 votes
2 answers
62 views

How to implement this zip function? zip[g,{f[{a,b}],f[{c,d}]}] to f[{g[{a,c}],g[{b,d}]}]

I have a function that returns an expression in the form f[{a,b}], and I use this function twice and assemble the expression ...
Tapiocaweasel's user avatar
5 votes
4 answers
230 views

Select elements from a list based on alphabetical order criteria

I have this code to generate the anagrams for a 6 letters word: ...
Rodrigo's user avatar
  • 1,534
3 votes
1 answer
94 views

How to sum over Slot inside MapThread

I am trying to do simple operations with several lists. In this context, I was wondering if a sum over Slot is possible inside ...
BabaYaga's user avatar
  • 1,888
3 votes
0 answers
42 views

How can I access subsets in manageable chunks?

I have a large subset (as an example). subset = Subsets[Range[8000], {2}] I cannot evaluate this as I don't have enough space. So the question is how can I access ...
internet's user avatar
  • 793
2 votes
1 answer
156 views

How can we arrange data for ListLinePlot? [duplicate]

I have this data ...
MMA13's user avatar
  • 4,732
0 votes
1 answer
46 views

Build 2D lists of functions and variables in different combinations

Can someone give examples on how to build 2D Lists of function and expressions by the given vectors? I have the following: V1={a,b,c}; V2={1,2,3}; V3={x1,x2,x3}; ...
seva011's user avatar
  • 316
2 votes
4 answers
214 views

How to convert the form of a solution from solve {x -> 1, y -> 1, z -> Sqrt[2]} into a list form {1, 1, Sqrt[2]}? [closed]

How to convert the form of a solution from solve as follows: {x -> 1, y -> 1, z -> Sqrt[2]} into a list form ...
csn899's user avatar
  • 4,315
5 votes
2 answers
177 views

How to select right triangles and non right triangles given their coordinates

I have a list of triangle coordinates in 2D-space: ...
Thuy Nguyen's user avatar
  • 1,097
0 votes
0 answers
45 views

How to convert RowBoxes into list of math expressions?

I have following RowBox which represents Step By Step solution of undefined integral ...
nnarek's user avatar
  • 1
4 votes
1 answer
70 views

Flattening nested data generated in a table

The data in the following is structured like this $\{\cdot,\{\cdot,\cdot\}\}$, but I need it like this $\{\cdot,\cdot,\cdot\}$. How do I do this? ...
KZ-Spectra's user avatar
0 votes
1 answer
41 views

Extracting coefficients from a list of expressions

I have a list of the form, ...
Patrick.B's user avatar
  • 1,511
0 votes
0 answers
63 views

JacobianMatrix function flattens input in column order

The JacobianMatrix function appears to flatten its input in column order. Both of the following queries (Wolfram Alpha syntax) give the same result: Q1: "JacobianMatrix of {{a_1+a_2, a_1+ a_2, ...
xformat's user avatar
-1 votes
3 answers
91 views

How to generate an array with specific conditions?

To randomly generate an array of 10 non-negative integers with a mean of 3 and a variance of 2. ...
csn899's user avatar
  • 4,315
0 votes
1 answer
43 views

Syntax regarding Manipulate plot with multiple functions

I am facing the following issue; I have the solution of a ParametricNDSolveValue and would like to plot several solutions with varying parameter in the same Manipulate to see qualitative differences. ...
IronicOwl's user avatar
  • 115
4 votes
2 answers
309 views

Get cumulative sums in a list without using a for loop [closed]

I want a list of the kind list = {a,a+b,a+b+c} for list plotting. The quantities of the list come from a function. Let us say this is ...
QFTheorist's user avatar
2 votes
1 answer
72 views

Find disjoint subsets and their union is {1...9}

I have such a list sets = Select[IntegerDigits /@ (Range[Floor@Sqrt@987654321]^2), DuplicateFreeQ@# && FreeQ[#, 0] &] I want to pick all subsets of ...
vector's user avatar
  • 201
0 votes
0 answers
35 views

Writing list as disjoint union of input lists

Suppose I have two lists, s1={{1,2,3},{3,1,2},{3,1,2},{2,3,1},{3,2,1},{1,3,2}} and ...
Tanatofobico's user avatar
1 vote
0 answers
31 views

Efficient chain rule implementation

(there is a fair amount of context here) I am implementing a generalized chain rule to do some work, say for order 3 in derivatives ($\partial_i = \partial/\partial x_i$): \begin{align} \partial_i \...
Felipe's user avatar
  • 499
5 votes
2 answers
505 views

Fill a matrix with randomly placed elements that are a certain distance apart

Problem statement I want to populate a matrix of points with randomly placed elements, here denoted as x. In all matrix rows there must be an equal number of x-...
eldo's user avatar
  • 74.3k
6 votes
5 answers
368 views

Combining duplicate elements in a list

I have a list of the form, mylist = {{0.1, 1.2},{0.3, 2.1},{0.1, 0.5},{0.4, 0.4},{0.4, 0.1},{0.1, 1.6}} I would like to create a function, ...
Patrick.B's user avatar
  • 1,511
0 votes
2 answers
54 views

How to use FoldList for matrix multiplication?

I'm trying to use FoldList to create successive matrices that depend on a changing parameter n, so the transition matrices are ...
magg13__'s user avatar
5 votes
1 answer
147 views

How could I speed up this tensor product?

I have to take tensor products of lists of tensors and I want to include the possibility of tensors whose components have high working precision. The tensors are all totally symmetric, so the first ...
Felipe's user avatar
  • 499
1 vote
6 answers
260 views

How can I find all the different ways to group integer numbers from 1 to 10 into 3 lists?

(Unfortunately, I couldn't change the bounty message. By n above I meant the number of sublists.) How can I group a list of integers from 1 to 10 into 3 sublists of ...
internet's user avatar
  • 793
1 vote
1 answer
52 views

How to convert a list of polynomials with different degrees into a list of lists?

I asked a question about converting a polynomial into a list. Now I have a list of polynomials. For example, ...
Jianrong Li's user avatar
5 votes
4 answers
283 views

How to convert a polynomial into a list?

I have a list of polynomials. Each polynomial looks like: p[1, 2, 5] p[3, 6, 9] p[4, 7, 8] - 3 p[1, 2, 4] p[3, 6, 9] p[5, 7, 8] How to convert each of these ...
Jianrong Li's user avatar

1
2 3 4 5
192