Questions on the manipulation of List objects in Mathematica, and the functions used for these manipulations.
5
votes
1answer
279 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:
...
-1
votes
1answer
70 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:
...
2
votes
1answer
157 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 ...
6
votes
1answer
230 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
106 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} ...
1
vote
2answers
89 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 ...
0
votes
1answer
60 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 :
...
-2
votes
1answer
122 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.
...
1
vote
3answers
161 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 ...
3
votes
5answers
236 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
...
2
votes
3answers
141 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 ...
4
votes
5answers
119 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
...
7
votes
3answers
125 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
94 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...
...
2
votes
1answer
95 views
9
votes
1answer
163 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 ...
6
votes
4answers
194 views
1
vote
1answer
105 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 ...
9
votes
2answers
203 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 ...
7
votes
3answers
134 views
Given a list of lists, build a list in which lists with equal first and last elements are grouped together
I have a list of lists, and I'd like to build a new list, in which lists are in the same list if they have the same first and last element. Here's an example. Suppose I have
...
0
votes
1answer
99 views
Where do those nulls come from? [closed]
I have seen discussions of unwanted nulls in the output in the context of building lists with conditions on the elements, but that is not involved here. I would like to know where the nulls come from ...
3
votes
1answer
102 views
How to make a simple tree yourself with defined distances for each generation?
I'm trying to make a function that generates a tree for spin spin analysis in spectroscopy. I though it would be pretty easy, but I'm totally stocked.
The tree should look something like this:
...
4
votes
2answers
130 views
Partition a set into $k$ non-empty subsets
The Stirling number of the second kind is the number of ways to partition a set of $n$ objects into $k$ non-empty subsets. In Mathematica, this is implemented as ...
1
vote
2answers
164 views
Sum of Multinomial Coefficients
Basically I want to write a function to compute the following sum
$f(m,L):=\sum_{0\leq k_1,\cdots, k_n\leq m} \binom{m}{k_1,k_2,\cdots k_n}$ and $supp(k)=L \subseteq \left \{ 1,...,n \right \}$
I ...
8
votes
4answers
272 views
Best way to modify values in a list of rules?
Recently I had to solve a problem similar to this:
Let's say I have a list of list of rules
...
2
votes
1answer
63 views
Strange behaviour of variables in Table
I'm trying to work with some vectors and have run into a strange problem. An obvious way to define a difference of two vectors would be
dif[x_,y_] := x-y
I ...
7
votes
2answers
227 views
Finding all points of period n in an iterated map
I'm trying to implement an algorithm of Jenkinson and Pollicott to calculate the Hausdorff dimension of a Julia set for the map $f_c : z\mapsto z^2 + c$. It's described on page 40 of their paper, ...
8
votes
4answers
291 views
Passing large list by reference
I have the following problem: I would like to control evaluation of a variable that points to a list. For example, frequently in the code I have functions of the form that are supposed to work on ...
0
votes
1answer
134 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 ...
3
votes
2answers
118 views
Listable compiled function using Map
I'm trying to minimize the computation time of problem which is too long to post. I use compilein order to gain some speed. To increase speed I would like to use ...
0
votes
3answers
148 views
Finding an index with certain conditions
EDIT: I need to find out an index i which depends on certain conditions and I'm not able to implement it. I have a list (time points) $t_i$ and two constants $a,c$ ...
8
votes
5answers
336 views
Counting the population of integers
Suppose that myData is a list of sublists. Each sublist has a length of one or greater and contains any number of replicates of the integers 1, 2, 3, and 4. I ...
0
votes
0answers
53 views
get while loop output into a list [duplicate]
I would like to get the output from this while loop and use it as a list so I can count the frequency of the various tuples..
...
0
votes
2answers
75 views
Converting a list of replacement rules into a list of real values [duplicate]
The following command outputs a list of replacement rules.
...
13
votes
3answers
270 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:-
...
1
vote
2answers
140 views
Replacing values of a function
I have recently starting using Mathematica and have recently come to what seems as an impasse in my understanding of the language. If this is too "tell me how to do it" I would certainly understand.
...
8
votes
5answers
181 views
How can I remove matching sublists from my list?
I want to use DeleteCases (or any appropriate function) to remove elements of a list, which in turn are lists of fixed size. The rule I wish to apply is that any ...
5
votes
3answers
226 views
Delete elements from a list really fast
I have this bit of code that works, but it's very slow when there are 600k elements in the list:
...
0
votes
1answer
108 views
Discrete 3D plots of median ratios of two 2D matrices of lists of values
Lets say I have 2 2D arrays where each cell contains a list of values:
Example:
...
4
votes
1answer
274 views
How do I find the Euclidean distance between one point and all the points in a list?
I want to find the Euclidean distance between one point (x1) and a list of points (y1), which contains a lot of coordinates
x1 = killer[[2]]
{6.05102, ...
6
votes
2answers
324 views
Elegant way to handle columns operations
Inspired by this question from @sjdh and by my recurrent use of columns operations in database sets, I was looking for one way to make columns operations more symetric, so I can handle with matrix and ...
1
vote
2answers
130 views
Generating a list of rules [closed]
This is my first time asking a question on this forum.
I would like to generate a list with a range of numbers and use this list for a function to read from. Ok, now for the good part, it would look ...
2
votes
3answers
132 views
Count items in a list that occur before a date
I have a list of dates that happen throughout 2013. I wish to construct a graph showing a cumulative total of elements that happen before that date.
I have a working algorithm, but it seems too slow ...
3
votes
2answers
276 views
How to rebuild original data from a histogram?
I have data in form
list of values ex. {5,7,4}
list of frequecies ex. {1,2,3}
I would like to obtain the original data from which such a histogram was generated
ex. {5,7,7,4,4,4}
8
votes
1answer
239 views
Vlookup function as Excel in Mathematica
How to create a Vlookup function, similar to what we have in Excel. So if we have a table a and another b, we could add columns ...
3
votes
1answer
66 views
Efficiently finding the maximum value of a column in a matrix
Imagine I have a matrix of the following form:
TestArray = $((a_1,b_1,...),(a_2,b_2,...),(a_3,b_3,...),...)$, where a specific example might be:
TestArray = ...
2
votes
1answer
97 views
writing a function using multiple variables
I am fairly new to Mathematica and am trying to write a function for the equation:
xx = [x/(Sqrt[h^2 + d^2 + y^2]))*(Sqrt[h^2 + (d + yy)^2])
where h, d are known ...
0
votes
1answer
131 views
Frequency of elements in a list
I've got a list in the format of list={{a,1},{a,1},{b,1},{c,1},{b,1}}
And I want it to "compress" into a list of pairs ...
4
votes
2answers
133 views
How can I eliminate equivalent equations from a list?
I want to find the numbers $a$, $b$, $c$, $d$ of the plane $ax + by +cz +d = 0$ which make the distance from the point $M(1,2,3)$ to the plane equal to 2. I tried
...
4
votes
3answers
307 views
Summing along rows or columns of a matrix
I have a list of rows in database such as
{{a,b,c}, {d,e,f},{g,h,i}}
I want to be able to add each row across and each column down (like a spreadsheet).
In other ...





