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

learn more… | top users | synonyms (3)

7
votes
1answer
78 views

Ordering function with recognition of duplicates

Fairly often I have a need to get the Ordering of an expression but with recognition of duplicates. For example: ...
17
votes
3answers
364 views

How to efficiently find positions of duplicates?

Is there an efficient way to find the positions of the duplicates in a list? I would like the positions grouped according to duplicated elements. For instance, given ...
0
votes
3answers
125 views

How to construct pairs in a list?

I have an expression like this, input = x[1] x[2]^3 x[5]^2; Fist step, we can get a list from the input expression, ...
5
votes
4answers
204 views

Prevent Part[] from trying to extract parts of symbolic expressions

If you have a list, e.g. {1, 2, 3} then you can extract the $k$th part using Part (...
10
votes
3answers
446 views

What is Mathematica's equivalent to MATLAB's filter function?

The MATLAB code filter(0.5,[1, -0.5], [1:10]) is equivalent to Rest@FoldList[(#1 + #2)/2. &, 0, Range[10]] I don't ...
3
votes
4answers
209 views

Extract function arguments

Is there a way to extract the arguments of a function? Consider the following example: I have this sum ...
9
votes
2answers
210 views

Speed up 4D matrix/array generation

I have to fill a 4D array, whose entries are $\mathrm{sinc}\left[j(a-b)^2+j(c-d)^2-\phi\right]$ for a fixed value of $\phi$ (normally -15) and a fixed value of $j$ (normally about 0.00005). The way ...
3
votes
2answers
150 views

For loop with steps other than 1

I would like to do a For loop with a jump 2*Pi instead of 1. For[j = 0, j <= nmax, (incr = 2 Pi), ...] Actually what I want to do is ...
2
votes
1answer
43 views

Replace a specified portion of an array with elements from another smaller array

This may be a trivial question, but I have been at it for a couple of hours and I have not made much progress. I have a 10 x 10 array (T) that I have used to generate an 8 x 8 array (Q). I want to ...
12
votes
9answers
346 views

Dropping n consecutive terms from a list periodically

Suppose I have the following list lis = Range[100]; and I want to remove n consecutive terms periodically from the list. For example suppose I want to drop terms ...
2
votes
3answers
211 views

How make f[{x,y}] evaluate as f[x,y]?

I frequently encounter the situation where I have a function of two real variables defined, e.g.: f[x_, y_] := 9 - x^2 - y^2 But then I need to feed into ...
1
vote
1answer
111 views

Extracting information from list

I have a huge list that looks like this: ...
1
vote
2answers
92 views

Subtract more than one array using DeleteCases

I need to create an array subtracting two arrays from another array. I know how to subtract one: am = DeleteCases[amp, Alternatives @@ af] I can subtract an ...
1
vote
2answers
133 views

Select rows from table by keys

I am looking for a way to iteratively select all sublists with the same ID (my 1st column, residual columns are AbsoluteTime entries). First, I obtained the list of ...
8
votes
1answer
220 views

How to remove some elements in a list based on a rule?

I want to deal with the following list. mylist = Table[cof[i] exp[i], {i, 1, n}]; (*n is very larege *) exp[ ] is a function ...
0
votes
0answers
36 views

Correspondence between eigenvectors and eigenvalues [duplicate]

Let us say I have a matrix h (2x2). Now, I want to get the eigenvectors and eigenvalues of my matrix h: ...
4
votes
3answers
246 views

Separating positive and negative numbers into two arrays

$c$ is a vector with real numbers.I want to separate the positive ones and the negative ones into two vectors: $a$ and $b$. I have the following problem: When I do: ...
2
votes
2answers
262 views

Finding a best fit curve and plotting it [closed]

I have a list as shown below: m01 = {{250, 0.083121}, {200, 0.0888446}, {150, 0.0992422}, {100, 0.121567}, {50, 0.186825}} I'm new to Mathematica, and would like ...
0
votes
0answers
65 views

Keeping the length of vectors fixed

b and d are two arrays that are given. I create aa and ...
0
votes
1answer
62 views

Collecting roots of different equations and create a list

I solve two equations and have two solutions one by each equation. I want to create list of these roots. Could anyone please help me? Appreciate it. m02R150 = FindRoot[P1 == 0, {E1, 0.07, 0.1}] ...
4
votes
2answers
126 views

Extracting data from a table under conditions

I have a very large table with two columns. Let's say the name of first column is E and the name of the second is P. How can I get the E values when P = 0.
3
votes
1answer
92 views

How can I get a single solution to a set of inequality constraints?

I have a set of constraints to which I require integer solutions. However, instead of needing all possible integer solutions (as obtained by using ...
1
vote
1answer
62 views

Calibrating Precision in calculations

As the title says, I encounter an irritating problem which has to do with the accuracy or the precision used in the calculations. To be more specific, I have the following code: ...
1
vote
0answers
105 views

Transferring a list from one notebook to another

I have Mathematica code split into two notebooks. The first part is supposed to run and output a list of numbers into a text file, using Export. The second part ...
6
votes
2answers
202 views

removing elements that are contained in other elements

For example, I have a list of lists: l = {{a,b,c},{a,b,d},{d,e},{d},{a},{a,b},{f}}; And I want to remove all the lists that are contained in other lists: ...
6
votes
3answers
130 views
5
votes
1answer
160 views

Problem with creating a large list of tuples

This is a follow-up question from Sum of Multinomial Coefficients I have thought about the meaning of the formula I mentioned and, with help, I implemented the following code: ...
9
votes
7answers
319 views
6
votes
2answers
167 views

Merging two Lists

I have two tables. One is given by T1 = Table[{x, y, 0.}, {x, 0, V},{y, 0, V}] and from a calculation I have the second, a list of points {x, y, z} ...
2
votes
4answers
243 views

Mapping over the last level of a list, or equivalent operations

I would like to style each element of my list using Style. But when I try ...
6
votes
1answer
325 views

Get the coordinates from ContourPlot and RegionPlot

How do I get the coordinates from a contour plot I've done in Mathematica? For example, I have a two-variable function f[x, y], for which I can make a contour plot: ...
13
votes
3answers
286 views

Quick multiple selections from a list

What is the fastest way to make multiple selections from a list? Compiled methods included. For example, here are two methods for selecting a subset, compared:- ...
2
votes
1answer
203 views

How to solve equations self-consistently

I want to solve the following equation self-consistently. So, H.u = e.u {{1, d}, {d, 1}}.{u1, u2} = e.{u1, u2} I guess an initial value for ...
-1
votes
1answer
74 views

How to separate a vector into two vectors, one having the first half of my original vector and the other having the second half

I have a set of n vectors with an even length. Let us make an easy example with 3 vectors of length=4: ...
1
vote
1answer
106 views

Creating an array eval [closed]

How can I create an one dimensional array (a vector) evaluating a function of two variables? I know how to do it with one variable: Array[f, n, {a, b}] generates a ...
1
vote
3answers
108 views

Separate an array in two arrays, the even and odd terms being separated in these two arrays

How can I separate the odd terms in one array and the even terms in another array,i.e., go from a={1,2,3,4} to aeven={2,4} ...
-2
votes
1answer
132 views

Non-regular grid data

I have issue with non-regulary spaced data. I have set of 3 numbers {x, y, z} in my list. ...
6
votes
1answer
276 views

Remove redundant brackets. Clean up lists

There are numerous examples whose end result is the removal of empty brackets "{}" and empty lists here, I still can't find an example of simply removing redundant brackets though. (It's hard for ...
1
vote
3answers
179 views

Loop through a list and select elements

I am new to Mathematica and I have no idea how to make a basic for loop work. I want to loop through the elements of a list: Range[45, 200]. I want to select the ...
0
votes
1answer
61 views

How to get a number, but not a list, of the dimension of your array?

I need to use the dimension of a certain array, to use it as a bounder in a loop afterwards. The problem is that I get a list, when write : ...
3
votes
5answers
239 views

How to combine some elements of a list?

In order to simplify my expression, I face a list manipulation problem. For example, given the input list ...
9
votes
1answer
169 views

Creating a number based on given conditions

In the grade 7 math curriculum here in Alberta we teach divisibility. I'm trying to write a program to create questions based on the idea of a student being given say, 4 digits, and then choosing ...
0
votes
1answer
150 views

Find Roots in Do loop

Task: Finding roots in loop t = List[1, 2, 3, 4, 5] fx[x_] := a*x^2 - 5 List[Do[Print[FindRoot[fx[k] == 1, {a, 1}]], {k, 0, 5}]] Output: Currently the output is ...
5
votes
3answers
154 views

Elementwise join

I have two tensors of arbitrary but equal rank n (and equal dimensions): A and B, and I want to get a third tensor of rank n + ...
4
votes
5answers
121 views

Convert a list with three arguments {x0,x1, step} into an equidistant table?

How can I convert a list such as: a = {1, 2, 0.1} into sequence so that I can pass them into a function, e.g. I want to be able to do something like this ...
2
votes
3answers
170 views

Selecting subsets of a list containing a specific element

I'm trying to generate all the subsets of a set containing a specific element. For example, for the set {1, 2, 3, 4}, with the specific element I want inside each subset being 4, the required answer ...
7
votes
3answers
137 views

Multiply a list of matrices by a list of vectors

How does one multiply a list of matrices by a list of vectors, elementwise? For example, multiplying ...
3
votes
2answers
96 views

Sequence and boolean And

I'm trying to figure out if a calculation result it's a valid result. As it return a matrix, I need to test that every element it's a number, so I thought this could work... ...

1 3 4 5 6 7 14