We’re rewarding the question askers & reputations are being recalculated! Read more.

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
2
votes
2answers
65 views

Triangular matrices with conditions

I would like to generate a lower triangular matrix that has checkmarks in the non-zero entries. The way that I created this matrix is the following ...
2
votes
1answer
95 views

Implement gradient method in functional programming style

I implemented the gm for quadratic function in Mathematica, but it looks like more in an OOP style, as the pic shows. How to rewrite it in Mathematica style? I tried with following code: ...
3
votes
2answers
68 views

Problem with Inserting in a Nested list

So I have a nested list like this: {{{0}},{{0}},{{0}}} Now i need to Insert in the first sublist like this ...
3
votes
1answer
50 views

Generating And / Or Conditions Automatically from a List

I have the following list: l1 = {x y, s t, a b} From this list, I am trying to essentially generate a new list that looks like this: ...
0
votes
3answers
49 views

How to obtain the minimal index n in a list (A) so that Total[A[[1;;n]]] is bigger than a specific value m?

Imagine the A array is {1,2,3,4,5,1,2} and m = 4. Then in this case, Total[A[[1;;3]]] is 6, ...
0
votes
0answers
29 views

Differentiation of a series with unknown coefficients

I have a function $f(x)$ expressed as $$f(x) = \sum_{k=1}^n {a_k}sin(kx)$$ and its derivative with respect to $x$ is then $$f'(x) = \sum_{k=1}^n k{a_k}cos(kx)$$ I am actually new to Mathematica and ...
5
votes
1answer
261 views

Removing Shorter Subsets in List of Lists

I have in Mathematica a list of lists like this: ...
1
vote
1answer
72 views

How to return the equal points between two lists

I have something like this ...
4
votes
1answer
55 views

Map list of functions over list of inputs

Given a list of functions {f1, f2, f3, ...} and list of inputs {1, 2, 3, ...} I wish to produce the list ...
3
votes
1answer
43 views

How to efficiently select positions of elements in a sublist

Apologies if this is an already answered question, I was unable to find anything until now. I believe the answer will be quite simple, I have just been stuck on it for a few days now. I have a large ...
1
vote
1answer
57 views

Element-wise minimum of two matrices

I am trying to compare two identically-shaped matrices and select the minimum of the two. This is an extension of a past question: Element-wise max of two lists, except I have three nested lists. <...
1
vote
1answer
36 views

Part Assignment of variables with argument

I do not really understand why this: a = {1, 2, 3}; a[[1]] = 3; a {3,2,3} works as desired, but this does not: ...
0
votes
1answer
38 views

Importing a 3 dimensional list

I have a code that is generating some numerical data in the form of a list of trajectories. Each trajectory itself is a list of 2D coordinates. Each coord. is a list of 2 numbers.(see example data ...
2
votes
2answers
79 views

Create a list of the first 100 deficient numbers

For the purposes of the assignment, I need these values in a table. We have so far only used for/while loops to check the deficiency or abundance of certain types of numbers. I initially tried using a ...
1
vote
0answers
34 views

Transpose two lists with rightarrow and commas [closed]

I need to transpose the two following lists: data0 = {99.52267, 93.78726, 99.67644, 99.85036}; error0 = {0.21152, 0.37626, 0.16309, 0.10167}; Into ...
2
votes
1answer
38 views

Interpolating and subtracting two sets of data

I have a data set "data9k" with x varying from 0 to 365, and another data "data0" set with x varying from 0 to 365. But the x values for both data sets are not same but similar. I want to subtract the ...
2
votes
1answer
55 views

How can a set of rules be applied to edit strings within a list of lists while maintaining list structure?

In attempting to read a webpage ("https://www.house.gov/representatives#by-name") I have managed to import a table using ...
2
votes
1answer
43 views

How to Mathematica applied discrete Fourier transform to matrix?

I am new user of Mathematica, sorry if my question odd. I not understanding, how to Mathematica apply the discrete Fourier transform for matrix: ...
0
votes
1answer
84 views

Why is lisa[i_, j_] :> Nothing un-evaluated?

Anyone know how to correct it with minor change? Input...
3
votes
4answers
209 views

How to select pairs in a list of pairs where the second pair element is within a specified range? [closed]

I have a list like the following list of pairs: ...
2
votes
1answer
32 views

Removing all sublists containing any arbitrary string as one or more of its list component

so, basically I have a list of sublists of varying length. For example, ...
0
votes
1answer
31 views

assigning integers to inner lists

Consider a asymmetric list which has been obtained from a NSolve command ...
0
votes
1answer
25 views

Deleting numbers from a list based on another longer list [closed]

I would like to delete all elements of a list that are equalled to any element found in a bigger list. For example, if I had A = {1,2,3,4,5} and B = {2,4,6,8,9,12} I would like to get C = {1,3,5} ...
5
votes
4answers
855 views

Flatten an array

I have obtained an array of results as follows ...
0
votes
1answer
36 views

Sets of k expressions, being k a variable

I need to write something like Table[Subscript[A,i] = i, {i,5}] in order to define a set of expressions. All is OK with this, but if I try to left the number of expressions as a variable k... Table[...
5
votes
7answers
1k views

Make a list of Fibonacci numbers less than 1000, whose index is in the form 3m+1. Verify that all these numbers are odd

I've been working on this for far too long with unsatisfactory results. And after losing all my hours of work around 4am thanks to a glitch in the program itself, I'm at my wit's end. It was ...
3
votes
1answer
45 views

How does the Fourier transform take its input?

I'm using the Fourier command and I'm wondering how does it take its imput. I know that it takes a list of numbers representing a function of time and it gives back a list of numbers representing a ...
4
votes
4answers
104 views

How to transform an UpperDiagonalMatrix into a symmetric matrix in Mathematica 5.2?

I have an UpperDiagonalMatrix as the following, how to transform it into a symmetric matrix in Mathematica 5.2? Note: don't use the command ...
2
votes
1answer
43 views

Remove elements from a list with a mask

Suppose we have a list {a, b, c} and a mask {1, 0, 1} (or {True, False, True}). And we want ...
4
votes
4answers
1k views

I wanna get a result of i/j . Like 1/3, 1/5, 1/7, 3/5, 3, 5/3… Something like that. But none of my code works [closed]

None of this works,can anyone correct this? 1st method j = {1, 3, 5, 7, 9}; i = {1, 3, 5, 7, 9}; jase[i_, j_] := i/j 2nd method ...
0
votes
0answers
29 views

Correctly Evaluating the existence of Large Solutions

I'm trying to correctly evaluate $$D(S\cap[a,b])=\lim_{n\to\infty}\frac{\left|S\cap{F_n\cap[a,b]}\right|}{\left|F_n\cap[a,b]\right|}$$ where $D$ is the density of $S\cap[a,b]$ (in $A\cap[a,b]$), $[...
2
votes
1answer
53 views

Find highest values between two different sets

I have the two following lists: ...
0
votes
3answers
67 views

At how many of these points is f(x,y) (strictly) greater than both g(x,y) and h(x,y)? and

I try too find out the solution but is not work. Please help! This what I wrote:
2
votes
0answers
35 views

Why does accessing the first element of a list yield “List” [closed]

I have a list of expressions listOfStuff = {-(b^(3/2)/Sqrt[7 \[Pi]]), b^(3/2)/Sqrt[7 \[Pi]]} When I try to access the first element of this list like so ...
5
votes
2answers
90 views

Element-wise multiplication of an array and a matrix

How can I express multiplication of an array and a matrix so that {x, y, z}*{{10, 20, 30}, {0, 1, 2}} gives ...
7
votes
6answers
575 views

How do I count the number of elements in a list which are between two determined values?

I have a long list (apprx. 10000 elements) of numbers. I want to count the number of elements between two determined vallues a and ...
7
votes
4answers
679 views

Mapping string into integers

Suppose I have the following list, l = {{"b", "c", "d"}, {"e", "b"}, {"a", "b", "d", "e"}} and further suppose I have the following association, ...
6
votes
5answers
376 views

A replacement for NextPermutation in Combinatorica [duplicate]

Does anyone know of a replacement for NextPermutation in Combinatorica? The problem with loading Combinatorica is that it interferes with new functionality which I ...
1
vote
5answers
167 views

If someone would want to think about the question: mathematical-optimization “Banknote”

I solved the puzzle of IBM Ponder This September 2019 by my code written with mathematica. I would like to share this code after the solution that will come as soon, and discuss it. In the meantime, ...
0
votes
1answer
98 views

Fast way to count distinct pairs of integers

I have a association list, S, whose size is about 5*10^4. I also have a function F which takes in ordered pairs of elements from S, and spits out ordered pairs of integers. There is some amount of ...
2
votes
0answers
43 views

Net layer that replicates last element

I am trying to design a neural network layer that takes in an array of dimensions n x 100, and produces an array of dimensions ...
11
votes
7answers
461 views

How can I add just the second elements in lists of pairs?

Say I have two lists of pairs: a = {{1, 2}, {3, 4}}; b = {{5, 6}, {7, 8}}; And I want to add the second element of every pair in ...
0
votes
1answer
32 views

Retrieve the independent variables from a linear replacement list

Is there a good way to convert a linear replacement list into a list of the independent variables? For example, I would like to take {n1->n3+n4, n2->n3+2n4} and get {n3,n4}, the variables that n1 and ...
5
votes
3answers
172 views

Adding elements to some sublists of unequal length

Complicated title for a simple problem: I have list a = {{1, 3, 5, 2}, {2, 6, 2}, {3, 5, 6, 1, 2}, {4, 2}} In which the first element of each sublist is ...
0
votes
0answers
29 views

Speeding my code to calculate a density which uses Folner Sequences?

I created a code which calculates $$D(S\cap[a,b])=\lim_{n\to\infty}\frac{\left|S\cap{F_n\cap[a,b]}\right|}{\left|F_n\cap[a,b]\right|}$$ where $D$ is the density of $S\cap[a,b]$ (in $A\cap[a,b]$), $[...
0
votes
0answers
27 views

Easiest way to simultaneously keep track of two values in a list

I have a bunch of functions a,b,c,... that all take in a list of images and return a list consisting of a list of transformed images, and a number (let's call it ...
0
votes
0answers
30 views

Why is my code for density using Folner Sequences giving incorrect values? [duplicate]

I am creating a code that calculates or approximates $$D(S\cap[a,b])=\lim_{n\to\infty}\frac{\left|S\cap{F_n\cap[a,b]}\right|}{\left|F_n\cap[a,b]\right|}$$ where $D$ is the density of $S\cap[a,b]$ (...
1
vote
1answer
64 views

How to pass pair of parameters in function

I am writing a function with a pair of values {x,y}, I have issues when I apply this function to list such as...
0
votes
3answers
86 views

Using StringJoin

Is there a way to use StringJoin to go from: {{abc, 0000}, {def, 1111}} To {{abc_0000},{def_1111}} I've been trying to use Map and MapThread with StringJoin but have failed.
0
votes
0answers
22 views

Approximating the density of an arbitrary set using an arbitrary Folner Sequence of its superset [duplicate]

How do we use Programming to approximate this limit where is the density of in , is the Folner Sequence of , is an interval with , and . For more information, click on this link (replace G,X,i,g ...