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
5
votes
1answer
46 views

Delete rows by testing multiple columns againts a range of test values

If I have a matrix or table of data, ...
1
vote
0answers
29 views

How to compute the multiplicative order of an element in a finite field

I want to find the multiplicative order of say the element {0,1,0} in GF[8]. I made a list: b = Map[GF[8][#] &, Tuples[{0, 1}, 3]] I tried: NestWhileList[b[[3]]*# &, b[[3]], # != b[[5]] &...
1
vote
1answer
43 views

How to Make Table Headings [duplicate]

In the code below, how can I add (left to right) column headings "n", "pp","aa"? There is also a shift in the alignment across the generated rows. ...
1
vote
2answers
35 views

Apply NestList to Iteratively Calculate Gradient (Gradient Descent)

I'm attempting to calculate the gradient of a function defined by two variables. After following a tutorial I found, I have the following code: ...
1
vote
0answers
46 views

How to assign a nested list indices for later use

In an attempt to calculate a summation dependent upon a nested list it appears that it a simple use of [[{n,k}]] does not yield the desired result. For example with ...
0
votes
2answers
93 views

SmoothHistogram doesn't appear to work

I have a data set with 500,000 elements. I am trying to use SmoothHistogram to plot the distribution, but it doesn't work and the kernel quits. I used R on the same ...
0
votes
1answer
36 views

Search for certain entries in an expression

I have a list with large expressions. I would like to find certain functions and their derivatives by searching the list. The search outcome should be the functions/derivatives found only, not the ...
2
votes
1answer
56 views

Filtering data 'geometrically'

I was looking at a very nice answer here, where the question was applying a confidence region to some data. If we plot some data as a scatter plot: ...
2
votes
1answer
65 views

Fastest way to compute determinants over (lists of) machine precision numbers

The below code is a code snippet of a larger project of mine. The project is mostly optimised but this part is not. I'm struggling to improve it, the code takes a really long time to evaluate for what ...
0
votes
0answers
40 views

What is the meaning of [ ][[ ]]? [duplicate]

I have a question about these two pieces of code Reap[ For[i = 1, i < 10, i++, Sow[i]; Sow[i^2]; Sow[i!]; Sow[N@Log@i]]; ][[2, 1]] ~ Partition ~ 4 and <...
0
votes
3answers
33 views

Making tuples with values produced by `Range[n]` and a constant $m$

I'd like to produce a list of $n-$tuples made from the elements of Range[n] coupled with a constant value $m$. Here's an example, given $n=3$: ...
1
vote
1answer
42 views

Padding behavior

Why does ArrayPad[Range[7], 4, Padding -> {1, 2, 3}] return {2, 3, 1, 2, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 1}? I expect it to ...
0
votes
1answer
64 views

Phase unwrapping

I am facing a problem in unwrapping a phase. I have a data set presented by $a_i$, where $i$ varies from $1$ to $N$. I need it as follows: If $\mathrm{abs}(a_{i+1} - a_i) > 3$, add $6 k \,$ to $a_{...
4
votes
3answers
225 views

Selecting elements from a list under multiple conditions

suppose there is the following list: ...
6
votes
7answers
457 views

Selecting elements of a list based on range

Suppose I have the following list: ...
0
votes
1answer
28 views

How to get a function from a list element? [duplicate]

I have a set of arguments in a list like: uy = {21/2 + y/2, 13.6667 + 0.666667 y, 20 + y} Now, I want to assign a function (call it 'f(y)') to an element of that ...
1
vote
2answers
23 views
0
votes
0answers
15 views

Can I use Postfix with a condition [duplicate]

I have a nested list Data set with mostly numbers, there are a few elements that occur as strings that I want to convert to a number. By postfixing ToExpression I ...
2
votes
1answer
33 views

Calculate and plot mean values of pairs of data points

I have a list of data points where there can be multiple y values for a given x value, e.g., {{0, 4}, {1, 2}, {1, 3}, {2, 3}}. I would like to Take the mean of the y values for each x value. Get a ...
1
vote
0answers
35 views

Order a list of Names by last name [closed]

I have a nested list with the following structure: ...
3
votes
1answer
40 views

Order or function/list arguments in map/select/others

I keep being uncertain of the correct order of [function,expr] arguments to functions such as Select, Pick, Cases, Position, etc., because I'm used to the ...
2
votes
1answer
27 views

Using the value of OptionValue to clear a list

I'm currently using OptionValue inside a function, the Option I passed to the function should be cleared, then populated with ...
1
vote
1answer
26 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: ...
0
votes
1answer
29 views

Picking out elements from a multi-level list

I have the following problem that is giving me headaches: I have a list with the elements in the following form: {x,{{a1,b1},{a2,b2},{a3,b3}}} I would like to ...
1
vote
1answer
56 views

Is there a function or a way of getting a remainder or modulus with equations with “surds”?

So I'm working with "surds", or radicals. I have expressions like $$7 + 5\sqrt{2} + 6\sqrt{3} + 7\sqrt{6}\tag{1}$$ and I want to take the "coefficients", for lack of a better word, and take their ...
1
vote
2answers
54 views

How can I count only the sublists having more than 9 number of '2'?

I made a table giving me 1's and 2's In[23]:= S = Join[Table[1, 1], Table[2, 1]] Out[23]= {1, 2} And then I made it bigger: ...
3
votes
1answer
61 views

How to access all instances of a defined function

This should have a simple solution, but for some reason I cannot find how to do this. Let's say I have a "function" where I have defined values (in my actual example I have many instances of this, ...
0
votes
0answers
27 views

Creating a special product function

I am having trouble working with lists inside functions with Mathematica. Basically, I have a list of numbers and a special way to multiply them. I want to have a function that is able to create a ...
3
votes
1answer
96 views

Why doesn't DeleteDuplicates do what I want

First off. I am not a mathematician I am a linguist, a syntactician who is trying to say something about semantics, which in the case at hand can be largely understood to reduce to set theory. That ...
0
votes
1answer
29 views

I need to extract data from a multi-valued functions and interpolate them into separate single values functions

The graphed data look like this. I need to extract the data for each curve individually and use Interpolation to create a differentiable function for each curve. Can you show how to do this? I will ...
1
vote
1answer
44 views

How to extract and plot pieces of a multi-valued function

I have multi - valued functions that create lists of data like this: ...
0
votes
1answer
49 views

How to generate a list with elements f[i] for a function of several variables f?

I would like to create an array of length n with each element i equal to the function ...
2
votes
1answer
110 views

Extract values of a ListAnimate plot that are moving at a fixed rate

I have this code which animates a layer of fluid moving on the outside of an ellipse with a moving black point on the cylinder surface itself. Is there a way to find the value of the blue outer line ...
0
votes
1answer
55 views

How to flatten a tensor product

Say I have a tensor product of four two dimensional spaces $\Lambda = S\otimes S\otimes S\otimes S$. The basis of $S$ is CB={{1,0},{0,1}} . I generate the ...
0
votes
1answer
35 views

Delete element from list [closed]

I have a list with 1000 elements, and I want to delete all elements from index 400 (including) until the last element.
7
votes
1answer
100 views

Partitioning a list by cumulated sum when the accumulate reaches a fixed value

I have a list dat = {10, 10, 10, 10, 10, 40} . When the cumulative sum of dat reaches >=...
4
votes
1answer
78 views

Select sets from a list which are in ascending order

Given a list of sets I want to choose the sets whose elements are in ascending order. I think I need to use: Select[list, crit] for this problem, but I could not ...
2
votes
1answer
41 views

Use a list with single number for the second input of Table

As you see both inputs below give the same results. Is there any reason to use List[3] instead of just 3 in the first case? <...
3
votes
2answers
95 views

When do functions apply on lists and when they do not

I have read in my lecture notes on Mathematica that functions (in the general sense) can be applied to lists of data and that they can return new lists with data. I have tried this and I have got ...
3
votes
2answers
95 views

Remove a list element based on condition

I have a list with many expressions as elements. I want to remove the list elements which do not contain certain variables. For example, I would like to remove the element which does not contain ...
2
votes
1answer
57 views

Tuples with more criteria

I have seen that there is question here which does almost what I wanted to ask but it's not quite what I wanted. Efficiently generating tuples with Outer What I would like to have is a Tuples of a ...
1
vote
2answers
35 views

Manipulation replacements rules from Solve [closed]

Assume the call to the routine Solve[eqn==0,{x1,x2}] returns: {{x1->a1,x2->a2},{x1->b1,x2->b2}} I would like to ...
2
votes
1answer
30 views

Taking Out Max List from List of Lists

I have a list like this: L1 = {{500, {x->3, y-> 4, z -> 1}}, {110, {x->11, y->41, z -> 9}}, {750, {x-> 1, y->-1, z->0}}} Is there a ...
0
votes
2answers
28 views

How to create seperate empty lists assigned to seperate variables

Instead of doing l1 = {} l2 = {} Is there a way to incorporate a loop to make this process faster?
2
votes
2answers
49 views

How to iterate through a lists of lists and delete a certain element?

Say I have a list of lists such as l1 = {{a, 2}, {a, 5}, {b, 3}, {b, 9}} How would I iterate through the list and delete all the lists with the first element b ...
0
votes
1answer
41 views

How do I split up a list of data points into invervals and assign values to those intervals?

So I have a data set for chess and our goal is to plot the difference between the rating difference versus white's win rate. I want to subdivide the x-axis into intervals like (-10, 0) (10,20) (20,30)...
3
votes
1answer
46 views

How to add ± to each element in the List?

I just want to add ± with Function Thread Output that I want {±1, ±2, ±3, ±5, ±7, ±9} ...
3
votes
2answers
82 views

Replace the diagonal of a list of matrices

I want to replace the diagonal of a square list of matrices with another list of matrices. What is the fastest and most efficient way to do so. (I will need to do this for very large arrays) Small ...
0
votes
1answer
64 views

Finding the maximal number of lists that form certain rules?

I have the following example: data={1, 2, 3, 4, 5, 6, 7, 8, 9}; NN=Length[data]/3; subdata=Subsets[data, {3}]; I want to know all the possibility for the ...
1
vote
1answer
31 views