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
1answer
38 views

All positive integer points up to a certain distance from a hyperplane

I have the hyperplane $\sum_{i=1}^{d} x_i c_i = z$ for $x \in \mathbb{R}^d$, defined by the vector of postivive numerical coefficients $c_i \in \mathbb{R}, c_i > 0$, and the value $z > 0$. I ...
1
vote
0answers
63 views

How to write Horner's Algorithm in Mathematica? [closed]

The pseudocode we were given is: Right now I have: ...
0
votes
0answers
62 views

How does Mathematica implement PrimePi?

I'm attempting to implement a "PrimePi" function from scratch. I have a highly optimized Sieve implemented, and I've read a handful of papers to get a rough idea how to implement the Meissel & ...
1
vote
1answer
50 views

Writing code to produce continued fractions

I have been trying to create a continuing fraction to help prove the theory about any rational number: a/b being able to be written as a continued fraction where the remainders found in the Euclidean ...
2
votes
1answer
57 views

Extended Euclidean Algorithm

I am trying to program the Extended Euclidean Algorithm. Earlier I made some progress past simply generating garbage data. I am supposed to yield two constants s & t that would help compute the ...
3
votes
1answer
66 views

How to access all instances of a defined function

This should have a simple solution, but for some reason I cannot find how to do this. Let's say I have a "function" where I have defined values (in my actual example I have many instances of this, ...
3
votes
1answer
86 views

Efficiently computing current flow betweenness centrality for graphs

Definitions: Given a graph $G=(V,E),$ the current flow betweenness is a node-wise measure that captures the fraction of current through a given node with a unit source (s) sink (t) supply $b_{st}$ (1 ...
4
votes
1answer
94 views

Langton's ant algorithm using AnglePath

I would like to implement Langton's ant algorithm using AnglePath. I know there are some MMA implementation on the internet but I would like to implement it myself. Here is definition of algorithm: ...
1
vote
2answers
55 views

Mistake in recursive algorithm

I am new to Wolfram, and I am trying to make a recursive Archimedes algorithm in Wolfram. I read documentation and I tried to run this code ...
0
votes
0answers
18 views

AsymptoticLess function confusion

I have an algorithm which complexity is: ...
2
votes
0answers
111 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
63 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
80 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
86 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
51 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
46 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
101 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
61 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
120 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
66 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
51 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 ...
14
votes
2answers
994 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
89 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, , ...
6
votes
3answers
365 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
107 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
141 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
29 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 ...
5
votes
1answer
213 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
75 views

Defining iterative algorithms [closed]

Assume the iterative algorithm of interest to be as follows: ...
4
votes
1answer
66 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 ...
3
votes
4answers
200 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
144 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
492 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
262 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
403 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
205 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
110 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
221 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
74 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,...
14
votes
1answer
278 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
85 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
138 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
319 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
82 views

Filter results those are failed to converge

I have this code ...
0
votes
1answer
316 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 <...

1 2 3 4 5 6