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
43 views

Interpolate the discrete list into continuous function

I have a data whose list plot shows up following graph I would like to interpolate the missing data and make the function continuous but for particular x-coordinate there is multiple values of $y$ ...
0
votes
0answers
31 views

Algorithm to solve monetary obligation [migrated]

i Need some help to find an algorithm for the following Problem. A Group of n persons lend each other some Money. A -> B, B -> C, C -> A, and so on. Now i want to find out how much Money each Person ...
1
vote
2answers
283 views

How to optimize this code?

I am implementing a code that works correctly but it takes too much time. I did not see how to optimize it to be run quickly. Here is my code: ...
1
vote
2answers
61 views

How to replace the selected value in matrix with a specific digit?

I want to replace the selected values through "RandomChoice" by 1 and all other values in matrix with 0. I want output in binary form matirx. ...
4
votes
1answer
102 views

Find random $n$ combinations of values with a given sum

This problem is described in the related StackOverflow question: Find all combinations of coins when given some dollar value. I would like generate a list of $n$ combinations of values that sum up to ...
5
votes
2answers
143 views

Extending a list

I have a range of n integers (always starting at 1) which are 1 apart, f.e. Range[10], Range[17] or ...
2
votes
0answers
64 views

How to solve lowest eigenvalue with Lanczos or Arnoldi algorithm? [closed]

By setting Method->Arnoldi in Eigensystem I was able to solve lowest eigenvalue and eigenstate of a large sparse matrix. ...
1
vote
2answers
133 views

Refining subset relations

People who do combinatorics (like me) are often faced with the following problem: For a list of combinatorial objects (vectors, permutations graphs,etc.), we know what multi-set of values it ...
0
votes
1answer
54 views

Creating algorithm with several conditions

I'm pretty new to mathematica and was wondering if you guys could help me out. Example: We have the following coordinates: {1, 1}, {2, 1}, {3, 1}, {5, 1}, {1, 2}, {2, 2}, {3, 2}, where {x,y} And ...
4
votes
1answer
171 views

Random Partitions

I want to write a function RandomPartition to partition a vector of length n into p partitions of varying (random) lengths. For example with ...
8
votes
1answer
68 views

Smallest connected subgraph containing all given vertices

Given a connected graph $G$ and a subset of its vertices, $S$, I need to find the smallest connected subgraph of $G$ containing all of $S$. How would you approach this in Mathematica? I am asking ...
5
votes
1answer
110 views

Finding a complete subgraph efficiently

I'm working on some experimental algorithms which would benefit from methods to find an instance of complete subgraphs with N vertices in an undirected graph. This far I've tried these methods: ...
1
vote
0answers
36 views

Depth limited search in mathematica

I often use FindPath[G, 1, 2, {L}, All] where $G$ is some graph. This finds all paths of length exactly $L$ edges which run between nodes $1$ and $2$. In large ...
3
votes
2answers
152 views

Pollard's Rho algorithm

I'm working in Mathematica and I'm trying to implement the [Pollard's Rho Algorithm for the Discrete Logartihm Problem][1].
19
votes
2answers
443 views

Upper bound “Vicious nearest neighbour” algorithm suggestions

I am asking a question based on this question from the sister site MSE. In an effort to make this a self-contained question, I include the fiorst documented posing of the problem by Robert Abilock in ...
0
votes
0answers
45 views

Find the maximum hyperrectangle contained in a set of points

I have a question similar to this one ( Find the largest rectangular block satisfying some condition without iterating explicitly). but in my case I have a multidimensional (up to 6 dimensions) binary ...
2
votes
0answers
37 views

Algorithm to determine if two colored graphs are isomorphic? [duplicate]

I have two (vertex-)colored graphs. I want to determine if they are isomorphic, with the condition that the isomorphism respects the colors of the vertices. Moreover, I want the algorithm to output ...
0
votes
0answers
49 views

Get Domain resp. implicit piecewise definition of numeric Function

Given the following quintic polynomial ...
18
votes
3answers
460 views

How to implement the sample-point process like the built-ins of Mathematica?

Consider this: pts = {{0, 0}, {1, 1}, {2, -1}, {3, 0}, {4, -2}, {5, 1}}; f = BSplineFunction[pts] I can use ParametricPlot to ...
2
votes
3answers
150 views

Given a list of triangle vertices, how to find the neighbors for each vertex?

A triangle is represented by {a,b,c}, indicting that its vertex IDs are a, b, and ...
0
votes
1answer
51 views

A question about the syntax [closed]

I have $3$ elementary questions to ask and I thank you in advance. Question N°1. What is the right syntax for $$y\equiv0\pmod {2}$$ in the code below? ...
7
votes
1answer
115 views

Challenging matrix sorting request?

I have an application in mind, and I need to do the following analysis, but am having a high degree of difficulty conceptualizing it in terms of syntax. I understand what I want, but cannot seem to ...
1
vote
1answer
226 views

Efficient algorithm to generate a basis for exact diagonalization

The problem is described as follows: I need to generate a basis(matrix) in lexicographic order. For two different basis vector $\{n_1,n_2,\cdots,n_M\}$ and $\{t_1,t_2,\cdots,t_M\}$, there must exist ...
6
votes
1answer
164 views

How to do automatic differentiation?

Does Mathematica have any AD functionality or does it only support symbolic differentiation? If not, are there any packages or other third party implementations available? Edit (J. M.) Here is an ...
0
votes
0answers
66 views

3-adic FFT algorithm

I am trying to implement the FFT algorithm when $n=3^k$, but maybe my code is wrong. Are there any suggestions for improving my code? ...
0
votes
0answers
46 views

Recursive method for the SR1 correction

I am looking to program a recursive formula for implementing the Symmetric rank-one correction. I am not sure exactly where my program fails. Every value is correct except the value for ...
1
vote
0answers
191 views

Integration of graphs with datasets

Mathematica has a rich family of graph algorithms. I would like to leverage some of these for a very large tree structure. Because of the size of the structure, I would like to store it in a Dataset ...
6
votes
1answer
266 views

Efficiently find all connected subgraphs

Is there a way to generate all the connected subgraphs of a graph in mathematica without going through all the subsets of the nodes and checking if the subgraph is connected (which will be ...
2
votes
1answer
109 views

i need a swap mutation code (genetic algorithm) in Mathematica?

I'm working on GA coding to optimize the locators position in fixturing system to minimize the error in precision manufacturing.I need a code for mutation (genetic algorithm) in Mathematica. Here, I ...
2
votes
0answers
84 views

AVL binary search tree implementation

Is there any text-book implementation of self-balancing binary search trees such as AVL or red-black in Mathematica?
-1
votes
1answer
44 views

Algorithm in Module behaves different [closed]

In my Notebook i wrote this algorithm: ...
2
votes
1answer
161 views

Using the Baby-Step Giant-Step algorithm

Here is a concept I am working through: As part of an attack on an El-Gamal cipher, solving the discrete logarithm problem $$10^x = 532107 \;\, {\rm mod} \;\, 1313839.$$ Using the ...
5
votes
4answers
566 views

Efficient way to sum all the primes below $N$ million in Mathematica

Today, I saw a problem described as below: Sum all primes below $N$ million At the beginning, I feel it is rather simple to calculate it in Mathematica ...
5
votes
4answers
719 views

A too complicated lookup

I have the following keys: nm = {"bay", "ica", "rat", "tat", "dax", "dow", "sp5", "nas", "mean", "total"}; which I want to use to find a corresponding entry in ...
4
votes
3answers
145 views

Unragging a matrix

Today I ran into matrices like this one: ...
2
votes
2answers
51 views

Count elements between matching opening and closing parentheses?

Suppose I have a List of the form: lst={"(", "x1", "x2", "(", "(", "x3", ")", "x5", "(", "x6", ")", ")", ")"} For each pair ...
3
votes
2answers
140 views

Replace missing data

I have vectors of equal lengths where I want to replace the zeroes (missing data) with their preceding values. So far I have written: ...
9
votes
5answers
641 views

Match opening and closing parentheses?

Suppose I have a List of the form: lst={"(", "(", "(", ")", "(", ")", ")", ")"} By running ...
25
votes
7answers
746 views

Faster position list construction from a “take instructions” list

Take some list, e.g., {1,2,3,4,5}, and a "take instructions" list, say {1,1,2,1,1}. The latter is read as "take the first ...
3
votes
1answer
144 views

Stochastic Predator-Prey model using Gillespie's SSA

I'm trying to model the predator-prey situation using SSA. I am very new to Mathematica so my handling of matrices is probably terrible, and that's probably adding to my confusion: ...
2
votes
2answers
66 views

Efficiently or Elegantly construct linear graph list from vertex pairs

I am processing MRP data, with BOM relations as pairs of part number strings. I want to construct lists that represent the linear graphs defined by these pairs. Here is some code to generate random ...
1
vote
0answers
91 views

Implementation of Lubaehevsky-Stillinger Algorithm to pack hard spheres

To generate a model of a polycrystalline material with specified grain size distribution (e.g coming from a Monte Carlo Grain Growth simulation) the Paper "Effects of grain size distribution and ...
1
vote
1answer
395 views

Code efficiency improvement needed solving problem 499 in Project Euler

I am trying to solve https://projecteuler.net/problem=499 by constructing a transition matrix and finding its steady state. Here is my code: ...
2
votes
1answer
124 views

Maximizing the number of zero entries in a matrix

I have a matrix with a bunch of parameters in its entries, they all come in different combinations in different places of the matrix. I can post the matrix itself if requested, but I think what I mean ...
1
vote
0answers
146 views

How can I detect certain letters by shape in an image?

I have a website where people can post Flipbook animations, called Flipnotes. Unfortunately, most of the Popular flipnotes are in the following categories: MV (Music Video) AV (Audio Video) AMV ...
2
votes
0answers
71 views

How to compute the longest non-contiguous common sequence?

LongestCommonSequence[] works well, but what about finding the longest common sub-sequence (not necessarily contiguous)? Is this function built in to the genome ...
15
votes
3answers
247 views

Partitioning with constraints on subsets

Given the following data: constraints = {{11, 2}, {11, 3}, {11, 4}, {11, 6}, {11, 9}, {1, 6}, {5, 6}, {2, 5}}; weights = {3, 7, 3, 2, 4, 2, 2, 2, 3, 2, 1}; I ...
7
votes
1answer
184 views

Is there a way to characterize a winding object in an image?

I have produced this image by applying a Gaussian image substraction, Binarize, Colornegate, and ...
4
votes
1answer
251 views

A problem about Steffensen method

Two days ago,I asked a question about bisection algorithm. Thanks for Michael E2 giving me a good solution My algorithm 1, I use the bisection algorithm to generate a initial value that contain a ...
7
votes
3answers
766 views

Implement the Bisection algorithm elegantly and easily

Description: Rencently, I have finished my course Numerical Analysis, so I'd like to implement many algorithm that I have learned from that course.By this practice, I hope that I can improve my ...