Questions tagged [algorithm]

Questions about algorithms used or which might be used to implement a procedure known by name or loosely but not in detail. The subject of the question may be a procedure mentioned in the literature or a Mathematica built-in function

Filter by
Sorted by
Tagged with
0
votes
0answers
17 views

AsymptoticLess function confusion

I have an algorithm which complexity is: ...
2
votes
0answers
105 views

Combinatorics with booleans equations

I have variables $X_i \in \{1,0,-1\}$. Now I add up $m=3$ variables $$S=X_1 + X_2 + X_3 $$ and want to find all combinations that give me, $S=1$. I can do this with (see this solution): ...
3
votes
0answers
59 views

Steiner Tree Approximation

I am wondering about the existence of Mathematica code to find (approximate) Steiner trees in graphs. I know there are a number of algorithms to do so --- just curious if anyone has implemented any ...
3
votes
1answer
73 views

Sorting a list into “all possible ways” - sorting with incomplete information

Familiar example of sorting objects I have a list of $n$ "vectors" $\{x^{(1)},...,x^{(n)}\}$ of form $ x^{(i)}=\sum_{j=1}^m c_j^{(i)}x_j,i=1\dots n$, where $c_j^{(i)}$ are nonnegative ...
6
votes
0answers
73 views

Mathematica's algorithm for FindIndependentEdgeSet? [closed]

Documentation does not mention about algorithm. My guess is Blossom algorithm because I do not know of any better one. Posting it with hope that someone might know it for sure.
2
votes
1answer
35 views

Creating pairs of non-intersecting set from a given set

Let's say I have a set {a,b,c,d} and I want to create a list of pairs {{a,b,c,d},{}},{{a,b,c},{d}},{{a,b,c},{}},... such that there is no intersection between each pair, and they do not need to use ...
1
vote
0answers
42 views

How does Mathematica find the process parameter? [closed]

I want to know what kind of algorithm is used by Mathematica's Estimated Process. For example, we can estimate the parameter as follows: ...
1
vote
1answer
90 views

Given a function $f(t,s)$, compute $\max_{t_2\in [0,1]}\min_{t_1\in [0,1]} |f(t_1,s_1)-f(t_2,s_2)|$

Given a continuous and bounded function $f(t,s)$, $t,s\in[0,1]$, I would like to compute $$\max_{t_2\in [0,1]}\min_{t_1\in [0,1]} |f(t_1,s_1)-f(t_2,s_2)|,$$ for each numeric values of $s_1$ and $s_2$....
2
votes
1answer
57 views

Find critical radius in percolation

I would like to examine the percolation from the left edge to the right edge on random lattice. Suppose I have a rectangle with N random points on it. ...
2
votes
1answer
29 views

What would be the best implementation of the D'Hondt method of highest averages for allocating seats on party-list proportional representation?

The 2019 European Parliament elections are happening shortly and seat allocation will use the D'Hondt method of highest averages. In order to analyse possible scenarios and results I need a Wolfram ...
1
vote
1answer
63 views

Duplicate RowReduce

Writing: Ab = {{1, 2, 3, 4, 2}, {4, 3, 5, 6, 3}, {1, 6, 7, 8, 4}, {9, 1, 2, 3, 2}}; RowReduce[Ab] I get: {{1, 0, 0, 0, 1/16}, {0, 1, 0,...
0
votes
0answers
50 views

How to exclude some methods?

Can I exclude one or several methods from methods tried by a function? When we use some 'algorithm-intensive' function, we can often specify whether we want to proceed according to the chosen method ...
3
votes
2answers
1k views

The most efficient algorithm to find all possible integer pairs which sum to a given integer

I wrote a module in Mathematica which finds all possible pairs of integers from a specified list of integers (which can be negative, zero, or positive) which sum to a specified integer m. The only ...
12
votes
2answers
806 views

Solving “Resistance between two nodes on a grid” problem in Mathematica

In the context of resistor networks and finding the (equivalent) resistance between two arbitrary nodes, I am trying to learn how to write a generic approach in Mathematica, generic as in an approach ...
0
votes
0answers
64 views

Most efficient way to define evil and odious numbers [duplicate]

A positive integer $n$ is defined to be evil if the number of ones in its binary expansion is even, otherwise it is odious. Now define the function $$ \begin{equation*} t(n)= \begin{cases} 1 \rm{ \...
1
vote
0answers
87 views

How can I improve and accelerate my 2 D algorithm?

I implemented the algorithm descussed here in the 1 D case (when $g$ is one variable function). Using a relaxation parameter the algorithm became very fast and converges in few iterations (n = 5, 6, , ...
5
votes
2answers
280 views

Finding the dangling free part of a cluster connecting two nodes

I am trying to learn how to use Mathematica for analyzing graphs, more specifically in the context of connectivity and percolation. For the sample graph that I have included in this post, we have a ...
3
votes
0answers
84 views

Approximate Nearest Neighbors in Mathematica?

Is there any support for Approximate Nearest Neighbors (ANN) in Mathematica or third-party packages? I'm looking for a good implementation of locality sensitive hashing for applications where ...
3
votes
0answers
104 views

Hopcroft's Algorithm for Minimization of Deterministic Finite State Automaton

Background Given a deterministic finite state automaton, Hopcroft's algorithm is a $O(n \log(n))$ algorithm for finding an automaton that generates the same language with a minimal number of vertices....
2
votes
0answers
28 views

How to iterate over Orbit of PermutationGroup?

Another day, another permutation group question. I'm given a g=PermutationGroup[...], and a list l={1, 3, 3, 2, ...}. I know I ...
1
vote
0answers
90 views

Trying to compute the heat capacity for the 2D-Ising model

I'm trying compute the heat capacity $C_v$ out of my simulation for the 2D-Ising model which is given by $C_v = \frac{\langle E^2 \rangle - \langle E \rangle^2}{T^2N^2}$ ($E$: Energy, $T$: ...
1
vote
1answer
67 views

Defining iterative algorithms [closed]

Assume the iterative algorithm of interest to be as follows: ...
4
votes
1answer
55 views

Mathematica package to calculate the graph crossing number

I have been searching for a mathematica package that can calculate the graph Crossing number of a (small) given arbitrary graph (the graphdata of known graphs doesn't help me). Before I write my own ...
1
vote
0answers
70 views

How can we make an algorithm with the A* method in Mathematica with 5 different flight routes? [duplicate]

I need to find the shortest path with the A* algorithm using Mathematica. I have 5 different flight routes with coordinates. They start and end at the same point. Between every point there is a wind ...
2
votes
4answers
130 views

How can I compute the chromatic number of a graph?

I'm starting in Wolfram Mathematica. I saw that MinimumVertexColoring [g] could be used to calculate the chromatic number of a graph, but ...
3
votes
1answer
117 views

Identify emotions from a drawn face using machine learning?

Can someone tell me how you could modify this code so that it recognizes more facial expressions? ... thanks for the help. ...
6
votes
1answer
470 views

Which algorithm does Mathematica use for “RandomSearch”?

Recently I have used Mathematica for minimization of certain functions and I have realized that even though it lasts much longer, the method "RandomSearch" functions much better than the other methods ...
4
votes
1answer
248 views

Pythagorean quadruples

I am very interested in the problem that deals with the Pythagorean quadrruples, which are listed in rosettacode. Unfortunately, I have not been able to find any way to compute them with Mathematica. ...
7
votes
1answer
362 views

Why is SVM unable to separate linearly separable data?

I have two sets of data, namely blue and yellow. I manually added a point {8, -3} to the blue data. ...
3
votes
0answers
173 views

How to achieve with Mathematica the effect a closure has in other languages?

Motivation I want to write an auxiliary function (brief auxf) for testing the output of another function that evaluates its body repeatedly using ...
3
votes
1answer
108 views

How to improve the simulation speed?

I'm new here. Actually, Mathematica is so cool, I can just write about 5 lines to do the same thing comparing to over 100 lines in Python. But the speed is very slow. I wonder if there is any method ...
7
votes
2answers
191 views

Generating permutations

I have a list of different combinations of letters of the alphabet {{"a"}, {"b"}, {"c"}, {"a", "b"}, {"a", "c"}, {"b", "c"}} There is no pattern to them - that ...
0
votes
2answers
70 views

An Integrate result is not what it should be

Recently, I come across an algorithm called HyperLogLog (https://stackoverflow.com/questions/12327004/how-does-the-hyperloglog-algorithm-work). There's a magic number in it, and when reading the paper,...
10
votes
1answer
195 views

Quick QuickSort implementation

I am playing with julialang and loving it, but at the same time noticed that they have a benchmark comparison with Mathematica. I have already submited a better version of ...
3
votes
1answer
80 views

What algorithm is used by FindGeometricTransform? [closed]

Can anyone tell me how the operation FindGeometricTransform[pts1, pts2] works (I mean inside logic of the transformation function), or where can I find such an ...
5
votes
2answers
134 views

How to mark leaves of polynomial based on its position in tree

I've been struggling with this for a few days, and so I thought I might ask this here. Part of the problem lies in the fact that I do not even know the mathematical solution, which runs the risk of ...
1
vote
1answer
255 views

Find a few eigenvalues of a HUGE sparse Hermitian matrix

I know that methods such as Arnoldi and FEAST can be employed to only find a few eigenvalues. But now I need to add another ...
1
vote
3answers
80 views

Filter results those are failed to converge

I have this code ...
0
votes
1answer
243 views

Using the binary search algorithm in a sorted grid

I want to get a mathematica code for binary search algorithm applied to a sorted grid containing integers. For example, given f[k_,x_]= x^2 + k x + k - 2 where <...
0
votes
0answers
76 views

What method Mathematica uses to solve a quadratic system

I'am writing a paper and I need to know what method Mathematica uses to solve a quadratic system by default. This is my system: ...
6
votes
2answers
564 views

How to calculate the “center” point

I have such points pts = Uncompress[FromCharacterCode[ Flatten[ImageData[Import["http://i.stack.imgur.com/zEP05.png"],"Byte"]]]]; ListPlot[pts] If I use the ...
3
votes
3answers
2k views

Algorithm too slow

Writing: nn = 10; Table[Sum[Length[Select[DeleteDuplicates[Map[Sort, Tuples[ {1, 2, 5, 10}, i]]], Total[#] == n &]], {i, 1, n}], {n, 1, nn}] I get: {...
0
votes
0answers
32 views

Using space to denote multiplication [duplicate]

When I want to impress a Mathematica novice I show him how we can use spaces to denote multiplication (telling him also to be careful not to forget the space as in ...
6
votes
2answers
330 views

Improve my implementation of the Diamond square algorithm

Some time ago, I began to explore the magnificent world of the terrain generation using the computer. Investigating on the Internet know about the existence of the diamond square algorithm. Try to ...
5
votes
1answer
187 views

solid partitions generator

According to Wikipedia, a solid partition of $n$ is a three-dimensional array $n_{i,j,k}$ of non-negative integers (with indices $i,j,k \geq 1$) such that $$\sum_{i,j,k} n_{i,j,k}=n$$ and $$n_{i+1,j,k}...
3
votes
1answer
287 views

Metropolis-Hastings Algorithm Problem

I've been trying to implement the Metropolis-Hastings algorithm for a while but there seems to be something weird going on. This algorithm does not need as much of the statistics to understand, and ...
6
votes
4answers
425 views

How to speed up this high-dimensional definite integral?

Examples ➤ 1. $$I=\iiint\limits_D \dfrac{{\rm d}x\ \!{\rm d}y\ \!{\rm d}z}{(x+y+z)^p}~,$$ where $$D=\{~(x,y,z)~\colon~x>0~,y>0~,z>0~,x+y+z<1~\}~.$$ MMA gives: $~I=-\dfrac1{2(p-3)}~.$ ➤...
2
votes
2answers
95 views

I want to improve my algorithm of knowing eigenvalues of the matrix H(k)

I want to improve my algorithm. I want to know the eigenvalues of below n-dimensional matrix H. When n=10, the matrix H is like below. Now, $To$ and $M$ are constants and $T1$ and $T2$ are functions ...
4
votes
2answers
201 views

Numerical Join of two sets of vectors ignoring repeats

I have two sets of numerical vectors which can be either Real or Complex and I want to combine them together, ignoring repeats. ...
2
votes
1answer
196 views

How to visualize elastic collision among particles confined in a square 2D container?

I've already simulate two particle confined in a square 2D container, but I don't know how to simulate the elastic collision between them. Currently, they just pass through each other without any ...