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

learn more… | top users | synonyms

0
votes
1answer
31 views

Speeding up ReplaceRepeated while truncating to desired order

I need to program in an algorithm that recursively makes algebraic replacements which leads to an utterly complicated algebraic function of $x$, but whose final result is only needed at fixed order in ...
5
votes
2answers
332 views

Counting the zeros in a factorial expansion [on hold]

A number, as big as 1000! (! = factorial) is given. I need to find how many zeros are there in the number. I counted the no of terminal zeros by dividing 5, 25, 125, ... (untill fifth power < ...
0
votes
0answers
75 views

Formula for a 15 - Puzzle game (Backwards and forward solution) [closed]

So I currently code a 15-Puzzle Game. Every tile has position starting between 1 and 16. For example has a tile which is at the position where number 3 should be the position 3. Now I need to find ...
13
votes
4answers
633 views

“Indexing” a vector

I need to "index" a vector according to the first occurence of its distinct elements. I have written ...
0
votes
0answers
90 views

Spectral Clustering

I am interested in the following question: How is it possible to check whether an algorithm is working properly? However, this question is too general for the post and I'd like to restrict attention ...
0
votes
0answers
19 views

Get neighbors for N dimensional square [migrated]

I need some algorithm to get neighbours of x vertex of N dimensional square. Thanks in advance.
8
votes
11answers
1k views

Ragged Diamonds

diamond[n_Integer] := Table[1, {#}] & /@ (Range[n]~ Join~Range[n - 1, 1, -1]) diamond[5] // MatrixForm How could a more functional, "tablefree", solution ...
0
votes
0answers
33 views

What Algorithm Does Mathematica use to Calculate Betweenness Centrality for Unweighted Graphs?

Recently asked this question http://math.stackexchange.com/questions/888369/betweenness-centrality-how-long-does-mathematica-take on the Mathematics SE. Does anyone know, as a follow up, what ...
1
vote
0answers
64 views

Creating a simple interactive app with CDF [closed]

I would like to implement an algorithm I have created using a (free) CDF document as interface. The idea is: The user has to give some input values (maybe through a sort of text box, if possible —a ...
8
votes
3answers
340 views

Find intersection points with V10

My question departs from this one: Find intersection of pairs of straight lines but now I want to find the points with the new V10 Region-functions. ...
3
votes
3answers
137 views

Multivariate Polynomial Manipulation

I have a large homogenous multivariate polynomial in, say, 5 variables $a,b,c,d,e$. As an example take the polynomial $$a^4+2abcd+a^2 b^2+e^4+cde^2.$$ Now I would like to replace $k$-th power of any ...
3
votes
2answers
224 views

All possible pairs of two items

I have 4 different items {1, 2, 3, 4}. I want to obtain all possible pairs of two of the items. I have written: ...
0
votes
3answers
181 views

Optimization Algorithm: ideas wanted

EDIT: Lets assume a random matrix: ...
3
votes
4answers
113 views
8
votes
8answers
680 views

Replace interior of matrix with zeros

I have f.e. the following square matrix: ...
1
vote
5answers
229 views

Write a number as the product of its two largest divisors

For even n >= 10 && n <= 98 I want to write n as the product of its two largest divisors (excluding ...
1
vote
0answers
85 views

What's a non-trivial Mathematica program involving conscious choice of stack vs. queue data structure?

In a typical computer science algorithms course, much attention is given to the discussion of queues vs. stacks as a data structure programmers need to consciously choose from to achieve algorithmic ...
15
votes
11answers
1k views

Efficient way to build a certain quadratic matrix

For odd n I'm looking for a short and swift way to construct with (f.e.) n = 3 n = 11 ...
2
votes
1answer
102 views

Implementing Kane's Subset Sum Algorithm

In the following paper, D. Kane describes an algorithm for subset sum that runs in logspace: http://arxiv.org/pdf/1012.1336v2.pdf. I am trying to implement it ...
3
votes
3answers
179 views

Can Mathematica solve $x^{b^2} + ax^b -1 = 0$ for $x$ with $a>0$, $b>1$?

I have a problem that I can't seem to solve neither analytically nor with Mathematica. Namely, I have the expression $$x^{b^2} + ax^b - 1= 0,$$ which I want to solve for $x$ with $a>0$, $b>1$. ...
0
votes
1answer
47 views

How do I find the all valid pairings between two sets?

I have a pretty hard problem to solve here, and I have no idea how to start. I have X kind of fruits and 5 colors (let's say Red, Green, Yellow, Blue and Purple). Each fruit can be available in ...
20
votes
4answers
948 views

Detecting patterns of black and white stones on a 2D board

I'm writing a program to play a game of Pente, and I'm struggling with the following question: What's the best way to detect patterns on a two-dimensional board? For example, in Pente a pair of ...
0
votes
1answer
76 views

How write this Function with many arguments? [duplicate]

F[x1_,x2_,...,x99_]:=expr How to write this Function in mathematica whithout complete write it?
1
vote
0answers
46 views

How to determine three last bindings made to a variable when evaluating an expression?

How can I create a list of bindings made to a certain variable when evaluating an expression? I want to determine three bindings made.
2
votes
1answer
93 views

Generating the set of all strings within a fixed edit distance of a initial string?

Provided a starting string initialString, and a particular alphabet of allowed characters {"A","B","C","D","E",...}, how can I ...
4
votes
1answer
245 views

Bresenham's line algorithm

Bresenham's line algorithm is producing discretized line for given two points for purpose of plotting for example. Like that: I have to stress that I'm interested in positions, not a plot. ...
4
votes
0answers
86 views

Challenge: Speeding up MaxDetect for application in 3D blob detection

In image segmentation it is a common problem that objects appear clustered and are therefore undistinguishable from each other when using simple algorithms. Based on this post I obtained efficient ...
0
votes
0answers
70 views

how to write my own interpolation method

I was comparing results of spline interpolation in Mathematica and C++/gsl-library Results of interpolation are different if I use: ...
0
votes
1answer
60 views

Implementation of a Hanning filter

I'm implementing a package for in-house signal processing. I wrote here a quite trivial function implementing a Hanning windowing of the signal. ...
3
votes
0answers
200 views

A* algorithm for finding shortest path in a graph

FindShortestPath finds the shortest path between two vertices in an edge-weighted graph, allowing a choice between the Dijkstra and Bellman-Ford algorithms. In my (limited) understanding, both of ...
6
votes
2answers
96 views

Algorithm in RandomChoice[{w1,w2,…}->{e1,e2,…},n]?

I wonder if someone happens to know the actual algorithm implemented in the particular overload of RandomChoice that handles explicitly presented discrete ...
0
votes
1answer
131 views

Generate encoding from nested list

Taking reference of Huffman code algorithm, ...
6
votes
2answers
160 views

Generated Numbers under a constraint?

Let's say I have five four dimensional vectors $p_i^\mu=(p_i^1,p_i^2,p_i^3,p_i^4)$ with $i=1,2,3,4,5$. Now, I want to fill the entries of these vectors ($4\cdot5=20$ in total) with some numbers, but ...
0
votes
0answers
43 views

Write nth line to file [duplicate]

I have a code that I am running on a supercomputer. Currently the algorithm must finish before I can export any results from the algorithm. What I would like to do is to have the algorithm write out ...
3
votes
3answers
203 views

Fastest way to check if an expression contains all symbols from a list

I need to execute this function thousands of times, and the faster, the better. I came up with two versions, but wanted to see if you can come up with an even faster way. Is there a better way? I use ...
4
votes
3answers
246 views

Creating a function with integral zeroes of the 0th, 1st, and 2nd derivatives

I would like to be able to randomly generate functions, each of which satisfies $f : [-10, 10] \rightarrow [-10, 10]$ All the zeroes, critical points, and inflection points have an integral ...
3
votes
1answer
270 views

Specific Mathematica algorithms, for example LU Decomposition

Where I can find detailed information on algorithms used by Mathematica, especially for numerical methods. The Manual doesn't seem to iclude specifics in most cases. For example I get a different LU ...
3
votes
2answers
131 views

Checking whether a number can be composed from the cube of its digit

How to check whether or not the sum of the cube of each digit of a number is equal to the number itself? In the following code, I tried to return the number in question whenever it matches the ...
3
votes
0answers
127 views

Using mathematica to discover algorithms?

In Steven Wolfram's blog entries, he discusses using mathematica to discover algorithms. I have tried several different google searches for papers on such topics, and have found none. I suspect this ...
6
votes
4answers
507 views

Check if a matrix is Positive Semidefinite

I have a question concerning the check whether a given matrix is positive semidefinite or not. In mathematica the function PositiveDefiniteMatrixQ[m] tells me ...
5
votes
1answer
209 views

What algorithm and tools should I use to search a data set for the point nearest to a given point?

I have about 1,000,000,000 points, which are the longitudes and latitudes of some places in a city, formatted like this: $(106.1231233,41.43234234)$. I also have about 20,000 points which are the ...
2
votes
2answers
164 views

Write 199319989756262759279209 = 5x + y, where x and y are integers

$\frac{199319989756262759279209}{5} $ = $ 3.9864\times 10^{22}$ according to Mathematica, but I would like to see this number exactly in decimal form (not in scientific notation). I'm attempting to ...
2
votes
2answers
228 views

How does Accumulate work?

Accumulate can be used to compute the partial sums of a list. The partial sums can also be computed using a For loop but this ...
16
votes
3answers
703 views

Generate a Random Polygon

Does some package exist with a function that takes a parameter $n$ and generates a random 2D $n$-sided simple polygon (convex or non-convex), possibly within a certain bounding box? It does not ...
5
votes
2answers
194 views

Parallelizing or optimizing a script for calculating the size of all pairwise intersections between collections of sets

I need to speed up or parallelize an operation that looks essentially like this: ...
6
votes
1answer
180 views

Behavior of Graphics`Mesh`InPolygonQ with self-intersecting polygons

Playing around with some of the answers in the question How to check if a 2D point is in a polygon? I noticed that: Graphics`Mesh`InPolygonQ[poly,pt] Displays ...
1
vote
4answers
214 views

Calculating the median difference between elements with a (particular pair) of consecutive integer indices residing in the same sublist

NOTE: I formally made a serious mistake in the first example provided. pointLists[[1]] had an extra element, and we should have a guarantee that ...
6
votes
5answers
354 views

A fast way to calculate the median difference between pairs of elements

I have a list of coordinate pairs, take for example the following list of three pairs: ...
1
vote
2answers
491 views

Faster way to test if an expression equals zero

I want to test if expressions (mix of variables, functions and numbers) are zero valued, as fast as possible, and PossibleZeroQ is sometimes very slow. One solution ...
2
votes
2answers
225 views

Is there a way to parallelize the convolution component of EdgeDetect?

Provided an image like - test = Import["http://upload.wikimedia.org/wikipedia/commons/d/d5/Sunflowers.jpg"] We can run ...