Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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

2
votes
1answer
18 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
59 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
48 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
786 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
75 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
242 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
72 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
93 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
25 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
69 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
63 views

Defining iterative algorithms [closed]

Assume the iterative algorithm of interest to be as follows: ...
4
votes
1answer
52 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
68 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
3answers
98 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
109 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
456 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
240 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
351 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
150 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
107 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
169 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
69 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
187 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
75 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
199 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
79 views

Filter results those are failed to converge

I have this code ...
0
votes
1answer
202 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
73 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
560 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
31 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
313 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 ...
4
votes
1answer
180 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
274 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
414 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
90 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
200 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
185 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 ...
1
vote
1answer
160 views

Creating subsets of lists of lists which have certain properties

PREFACE: This question is about a proper algorithm and its implementation. I will explain the problem as detailed as possible and will give my current algorithm as well as two more possible solutions ...
1
vote
2answers
319 views

How to convert from C to Mathematica?

I am trying to understand what is explained in this webpage, in the section entitled "Generating noise with different power spectra laws". After reading that section, I thought I could do it in ...
2
votes
1answer
101 views

3D binning keeping the values

I have N points in the from of triplets {xi,yi,zi}. I would like to bin them on a grid ...
0
votes
2answers
149 views

Testing that an algorithm has converged

It's frequent that when writing some kind of algorithm (numerical integration, clustering, whathaveyou) I'll want to say "Stop the algorithm and return the result when some error $\epsilon$ is below ...
1
vote
1answer
340 views

Allan Deviation Algorithm

I am trying to write my own Allan Deviation calculator in Mathematica using the definition, $$\sigma(\tau)^{2}=\frac{1}{2M-2}\sum_{i=1}^{N-1}(\bar{y}_{i+1} - \bar{y}_{i})^{2}\text{.}$$ Where the $\bar{...
11
votes
1answer
499 views

3D tree in Mathematica?

Searching the web for information about the affine transformation, I found the one page, which called my attention for the tree that show and is this but unfortunately do not give information about ...
1
vote
0answers
57 views

Finding same output values by varying input values of function

I have written a function in Mathematica that needs five input variables. The function outputs a single real number. The underlying model is a complex model for option pricing. To ease things up, let ...
8
votes
3answers
281 views

From a list of lists of integer, choose a minimal length list of integers that intersects each sublist

I have this list of lists of integers between 1 and 255. ...
4
votes
0answers
247 views

Problem with the accuracy of the real-coded Genetic algorithm

Since there is no Genetic algorithm implemented in the Mathematica i tried to write a very simple genetic algorithm myself. The accuracy of the results depend upon rounding up the obtained parameters. ...