An algorithm is a sequence of well-defined steps that defines in abstract the solution to a problem.

learn more… | top users | synonyms

13
votes
6answers
404 views

Partitioning an integer into $k$ equal parts

Say I have an integer $M$. Is there a one-line command to create a partition of $M$ into $k$ integers s.t. the difference between any two integers is as small as possible? For example, with $M = ...
2
votes
1answer
257 views

Finding a fixed vector which minimizes the pairwise distance between noisy elements in two unordered arrays

Let $A$ and $B$ be two sets of $d$-dimensional coordinates of comparible (though not necessarily equal length). For example, here we can set $d = 3$ and have normalized values like: ...
1
vote
1answer
109 views

Finding a mapping between elements in two lists that satisfy some criterion (such as being less than threshold Euclidean distance apart)?

I have two lists of $d$-dimensional coordinates, for example setting $d=3$ we might write: ...
4
votes
2answers
242 views

Efficiently determining the largest minimum cost to travel from a fixed source to an arbitrary sink in a weighted graph

Let $v_i$ be a vertex in a graph $G$ with vertices $(v_1,...,v_N) \in V$ and edges $(e_1,...,e_M) \in E$ with associated weights $(w_1,...,w_M)$. Let $v_s \in V$ be specified vertex in the graph. In ...
0
votes
1answer
128 views

Returning lists of pixels connected through their Moore neighborhoods

I have a binarized image in Mathematica 9, and I would like to generate a list of coordinates for clusters of pixels connected through their Moore neighborhoods, e.g. ...
1
vote
1answer
245 views

Understanding the computation of the geometric median

In the Wolfram Demonstration Fermat Point for Many Points, it appears that the geometric median is being calculated for an arbitrary set of five manipulable points. How might one extend this ...
1
vote
1answer
522 views

How to linearize an expression automatically?

I would like to automatically linearize some long equations in the scope of variational calculus. Here follows an example of what I need to do : Given two variables $a_1 = q_1 + \delta q_1$ and $a_2 ...
13
votes
1answer
235 views

Baffling increase in runtime

Background of my question I discovered Project Euler today, and decided I would work through the problems in Mathematica. I became obsessed with the first problem, which is essentially "sum all the ...
6
votes
2answers
238 views

What is the underlying algorithm for GroupElementToWord?

What algorithm is Mathematica 9 using for GroupElementToWord[group, g]?
1
vote
1answer
127 views

How can I stop DiscreteMarkovProcess[] from relabeling vertices?

I'm attempting to calculate the mean first passage time between two vertices, $v_1$ and $v_2$, provided some undirected graph $G$. However, I noticed that running the following script: ...
0
votes
2answers
101 views

How can I efficiently and uniformly sample the set of vertices a fixed edge-wise distance away from a chosen vertex?

I have a large graph $G$, which may be either directed or undirected. How would I use DepthFirstScan[] or BreadthFirstScan[] to ...
2
votes
0answers
141 views

Fast calculation of commute distances on large graphs (i.e. fast computation of the pseudo-inverse of a large Laplacian / Kirchhoff matrix)

I have a large, locally connected and undirected graph $G$ with $\approx 10^4$ vertices and $\approx 10^5$ to $\approx 10^6$ edges. Moreover I can bound the maximum vertex degree as $Q_{max}$. I ...
4
votes
0answers
227 views

Counting paths of a certain length between a source and sink vertex

I have a graph $G$, which may be directed or not, and I was wondering if there was an efficient way of using, say, BreadthFirstScan[] and FindShortestPath[] to count the number of paths between some ...
0
votes
1answer
104 views

Can I force a function to quit and return some value after a certain amount of time has passed during its evaluation?

Imagine I provide some random input to function like FindInstance[], and I observe that, despite the existence of good solutions, the function will, with some ...
6
votes
1answer
141 views

Why is FindInstance failing when I relax a set of constraints?

I'm attempting to use FindInstance to generate coordinate sets for plausible triangles with edge length distance constraints. E.g.: ...
3
votes
0answers
279 views

Solving recursion relations using Mathematica

I want to solve the recursion relation given in equation 2.7(a/b) on page $6$ of this paper. (..the initial seed is $F_1 = G_1 = 1$ and the functions $\alpha$ and $\beta$ are defined on page $5$ in ...
7
votes
1answer
215 views

Making FindShortestPath a little bit sloppy [duplicate]

I have a dense graph, and I'd like to find multiple "almost shortest" paths from a source vertex, $v_s$, to a sink vertex, $v_s$, on an undirected graph $G$. How can I repeatedly run ...
4
votes
1answer
163 views

Is there a fast way to trilaterate a point?

I have a point in 2D or 3D space at an unknown coordinate, $p_0$, and I'd like to determine its position using distances from known coordinates $(p_1, p_2, p_3)$. Beyond using ...
5
votes
2answers
264 views

Is there something akin to “SubgraphIsomorphismQ” in Mathematica 9?

Provided two unlabeled graphs, $G$ and $H$, I would like to test where $H$ is a subgraph of $G$. In other words, I'd like to test whether we can prune some fixed number of vertices or edges from $G$ ...
2
votes
1answer
116 views

Is it possible for me to explicitly specify a point list for SpatialGraphDistribution?

The function RandomGraph[SpatialGraphDistribution[n, r]] generates a random geometric graph over $[0,1]^2$ where vertices are connected if they are within a ...
2
votes
1answer
123 views

Determining whether two k-chromatic graphs are equivalent (not simply isomorphic) using IsomorphicGraphQ?

In a previous question of mine, I asked whether Mathematica's built-in routines could determine an isomorphism for two $k$-chromatic graphs, Determining whether two $k$-chromatic graphs are isomorphic ...
9
votes
2answers
242 views

Determining whether two $k$-chromatic graphs are isomorphic (respecting vertex coloration)

Consider the case where I have two $k$-chromatic graphs $G_1$ and $G_2$, i.e. two graphs where individual vertices can be colored with one of a set of $k$ total colors, and I would like to determine ...
4
votes
1answer
406 views

Efficient method for inverting a block tridiagonal matrix

Is there a better method to invert a large block tridiagonal Hermitian block matrix, other than treating it as a ordinary matrix? For example: ...
7
votes
2answers
344 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, ...
13
votes
4answers
1k views

Mathematica Implementations of the Random Forest algorithm

Is anyone aware of Mathematica use/implementation of Random Forest algorithm?
1
vote
2answers
153 views

How to incorporate functions within Do Loops

I'm attempting to repeatedly perform a simple algorithm with incremental changes of a parameter. I can easily express my changing parameter: ...
7
votes
2answers
1k views

Easier program for period of Fibonacci sequence modulo p

For a little project I need to calculate the period of a Fibonacci sequence modulo p, for which p is a prime number. For example, the Fibonacci sequence modulo 19 would be: $$0, 1, 1, 2, 3, 5, 8, 13, ...
5
votes
1answer
295 views

Random number generation with specific distribution

I am writing a program for solving the shortest path in travelling salesman problem, with a twist that there are multiple salesmen who partition the cities among themselves, thus creating two part ...
15
votes
1answer
656 views

How to extract metadata from an image of a business card?

I'm trying to digitize some documents, and I came across a very cool app called camscanner app which performs parallax transform and ocr very nicely, now I'm implementing it in mathematica... Given ...
43
votes
3answers
19k views

How to create new “person curve”?

Wolfram|Alpha has a whole collection¹ of parametric curves that create images of famous people. To see them, enter WolframAlpha["person curve"] into a Mathematica ...
16
votes
1answer
409 views

Simulating Theatre puzzle

I have been trying to simulate the process of the theatre puzzle from the Joy of X (Strogatz). The puzzle, and some relevant material are here. My simplistic coding for this process follows: ...
2
votes
1answer
169 views

How do I determine if there's an arithmetic sequence within a list? [duplicate]

Possible Duplicate: find subsequences of constant increase Given an arbitrarily long list of integers (let's say they are sorted), how would one determine if any 3 (or more) of those ...
6
votes
1answer
2k views

Machine learning. SVM algorithm

I want to work with machine learning in Mathematica. Are there any SVM algorithms implemented in Mathematica anywhere? Or any other algorithms for machine learning? With positive and negative database ...
2
votes
0answers
194 views

How can I compute the chromatic index and number of a graph?

I saw a recent question from M.R. and realized there is no function to compute the chromatic index and number of a graph, other than a really slow method in the now deprecated Combinatorica. So, how ...
7
votes
3answers
393 views

How do we solve N-Rooks variation using primes?

Using a $p_n $x $p_n$ matrix, how can we solve the N-Rooks problem to find a prime in every row and column? ...
14
votes
2answers
533 views

How can I speed up the classic GA for graph coloring?

I'm trying to compute the chromatic number of this graph (which is 28): g = Import@"http://www.info.univ-angers.fr/pub/porumbel/graphs/dsjc250.5.col"; My genetic ...
20
votes
2answers
917 views

How to quickly calculate intersections of filled curves?

I am trying to quickly calculate the intersection of polygons with more than 6,000 points. A compiled solution would be preferable. Here is one example of the problem: ...
18
votes
11answers
986 views

Generating an ordered list of pairs of elements from ordered lists

I have a pair of ordered lists. I want to generate a new ordered list (using the same ordering) of length n by applying a binary operator to pairs of elements, one from each list, along with the index ...
1
vote
1answer
144 views

Community structure algorithm [closed]

I'm using CommunityStructureAssginment[] from GraphUtilities but not sure what is the algorithm behind it. May be someone knows what is the algorithm? Or any info on the community structure ...
20
votes
3answers
547 views

Computing polynomial eigenvalues in Mathematica

MATLAB offers a function polyeig for computing polynomial eigenvalues, which appear, for instance in quadratic eigenvalue problems (see here for some applications) such as: \begin{equation} ...
4
votes
1answer
959 views

Efficient implementation of cubic equation of state

...In this case the Peng Robinson Equation of State. Equations of state are empirical equations with parameters derived from experimental data. They are used to predict pure component and mixture ...
7
votes
2answers
324 views

find subsequences of constant increase

A list like l = {0, 1, 2, 3, 4, 5, 7, 9, 12, 13, 18, 19} may have subsequences of constant increase, $a_{n+1} = a_n + k$. For example: ...
17
votes
2answers
1k views

How can I create a glass distortion effect in an image?

I'd like to overlay a glass jar onto an image with realistic light bending. Can anyone think of a way to automate this effect (perhaps this can be done with the raytracing package rayica)?
12
votes
4answers
1k views

Finding elementary cycles of (directed) graphs

I need to enumerate all the simple cycles (i.e. elementary cycles where no vertex is repeated other than the starting) of a graph which has both directed and undirected edges, where we can treat the ...
51
votes
3answers
5k views

Programmatic approach to HDR photography with Mathematica image processing functions

The High dynamic range imaging (HDR or HDRI) direction in photography and image processing became very popular recently. Besides obvious photo art applications (see examples), there are many great ...
11
votes
2answers
379 views

Word Squares and Beyond

A word square is a set of words which, when placed in a grid, read the same horizontally and vertically. For example, the following is an English word square of order 5: ...
19
votes
3answers
731 views

Build a refined grid based on intersecting line

I honestly have no idea where to begin with this problem. In summary, I have a 2D coarse grid with an intersecting line. For an easy example, let's assume it's a 4x4 grid. I wish to pass through ...
3
votes
1answer
115 views

Center of quadrangular

Having 4 points A (ax, ay), B (bx, by), C (cx, cy) and D ...
7
votes
1answer
808 views

Efficient backtracking with Mathematica

Backtracking is a general algorithm for finding all (or some) solutions to some computational problem, that incrementally builds candidates to the solutions, and abandons each partial candidate c ...
4
votes
1answer
532 views

Computing Slater determinants

I need to compute Slater determinants. I'm wondering if I would benefit from assigning each of my functions to a variable prior to computation. I'm working with Slater determinants, but my question ...