An algorithm is a sequence of well-defined steps that defines in abstract the solution to a problem.
35
votes
2answers
2k 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 ...
35
votes
3answers
11k 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 ...
33
votes
1answer
881 views
Adaptive sampling for slow to compute functions in 2D
EDIT: Although I have posted an answer based on my current progress, this in incomplete. Please see the "open issues" section in the answer.
Most plotting functions in Mathematica adjust the ...
32
votes
0answers
737 views
How to construct a treemap using non-rectangles?
I've written the standard version of a tree map (a graphic that shows nested data) and I'm looking to improve on this layout by switching to different types of polygons or perhaps circles. Can anyone ...
27
votes
4answers
941 views
Finding a percolation path
I would like to examine percolation on a random lattice. To be exact, I wish to find the minimum length of a 'bond' needed such that the leftmost site can be connected to the rightmost site.
Here is ...
22
votes
7answers
779 views
Splitting words into specific fragments
I am looking into splitting words into a succession of chemical elements symbols, where possible. For example:
Titanic = Ti Ta Ni C (titanium, tantalum, nickel, carbon)
A word may or may not be ...
21
votes
3answers
372 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}
...
19
votes
3answers
456 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 ...
19
votes
2answers
563 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
642 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 ...
17
votes
3answers
1k views
Plotting a set of trajectories (not a vector field) in 3D
Consider a set of trajectories in 3D space, that possibly converge. By visualizing trajectories as arrows the result will look crowded as each arrowhead will be placed where the attractor is. In 2D, ...
15
votes
5answers
332 views
Alternative ways to implement a triangular recursion
Triangular recursions are a class of algorithms that frequently turn up in computational mathematics. These recursions are expressible in the general form
...
15
votes
2answers
441 views
How can I pack circles of different sizes into a spiral?
Given a list of circles of different areas, I need to arrange them tangentially in order of increasing area and spiraling outward. An example of the type of packing I'm attempting is shown by the ...
14
votes
2answers
694 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)?
14
votes
3answers
663 views
Effective matrix power like algorithm
First example
Suppose you want to calculate the 6th power of some matrix $A$. The brute force attempt of doing this is considering
$$(((AA)A)A)A)A$$
which requires a total of 5 matrix ...
14
votes
2answers
378 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 ...
13
votes
5answers
962 views
Finding all elements within a certain range in a sorted list
Suppose we have a sorted list of values. Let's use list = Sort@RandomReal[1, 1000000]; for this example.
I need a fast function ...
12
votes
2answers
657 views
How to get actual triangles from DelaunayTriangulation[]?
The ComputationalGeometry package has a DelaunayTriangulation[] function. It returns a list of points connected to each point, ...
12
votes
1answer
343 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 ...
12
votes
2answers
772 views
Simple algorithm to find cycles in edge list
I have the edge list of an undirected graph which consists of disjoint "cycles" only. Example:
{{1, 2}, {2, 3}, {3, 4}, {4, 1}, {5, 6}, {6, 7}, {7, 5}}
Each ...
11
votes
2answers
334 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:
...
10
votes
4answers
606 views
Mathematica Implementations of the Random Forest algorithm
Is anyone aware of Mathematica use/implementation of Random Forest algorithm?
9
votes
2answers
155 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 ...
8
votes
3answers
236 views
Faster Alternatives to DateDifference
I need a faster implementation of FractionOfYear and FractionOfMonth, which do the following:
Input: A time/date specified by ...
7
votes
2answers
271 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:
...
7
votes
2answers
228 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, ...
7
votes
1answer
163 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 ...
6
votes
2answers
367 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, ...
6
votes
1answer
229 views
How can I extend BinCounts to work on Times and Dates?
I want to extend BinCounts to work on a list of times or dates, binning them by Day, Week, Hour of the Month, Day of the Year, etc... So given a list of times and a time bin spec, I need to calculate ...
6
votes
1answer
342 views
Higher order SVD
Does anyone know how to do a higher order SVD in Mathematica ? A good reference seems to be here http://csmr.ca.sandia.gov/~tgkolda/pubs/bibtgkfiles/TensorReview.pdf but I don't understand their ...
5
votes
3answers
281 views
How do we solve Eight Queens variation using primes?
Using a $p_n $x $p_n$ matrix, how can we solve the Eight queens puzzle to find a prime in every row and column?
...
5
votes
2answers
203 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$ ...
5
votes
1answer
87 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.:
...
5
votes
1answer
128 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 ...
5
votes
1answer
549 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 ...
4
votes
1answer
121 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 ...
4
votes
1answer
568 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 ...
4
votes
1answer
384 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
354 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 ...
4
votes
0answers
83 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 ...
3
votes
1answer
102 views
3
votes
1answer
224 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:
...
3
votes
0answers
115 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 ...
2
votes
1answer
74 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 ...
2
votes
1answer
84 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 ...
2
votes
1answer
64 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
68 views
What is the underlying algorithm for GroupElementToWord?
What algorithm is Mathematica 9 using for GroupElementToWord[group, g]?
2
votes
0answers
54 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 ...
2
votes
0answers
120 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 ...
1
vote
2answers
72 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:
...




