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

A question about the syntax [on hold]

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
105 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 ...
2
votes
0answers
29 views

Functionality of FindMaximumFlow

I know that the superseeded function NetworkFlow (needs Combinatorica) uses Goldberg-Trajan's Push-Relabel-Algorithm but i cant find any information on Mathematica's build-in-function ...
1
vote
1answer
127 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 ...
5
votes
1answer
122 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
54 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
42 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
59 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 ...
5
votes
1answer
98 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 ...
1
vote
1answer
55 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
38 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
39 views

Algorithm in Module behaves different [closed]

In my Notebook i wrote this algorithm: ...
2
votes
1answer
125 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
315 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 ...
0
votes
0answers
45 views

Substitution Permutation Network (SPN) - Decryption In Mathematica

I am working with a Substitution Permutation Function, SPN, in Mathematica. I have an encryption function for an SPN. By changing the parameters that go into the spn function, and not the function ...
5
votes
4answers
711 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 ...
0
votes
1answer
79 views

Books of algorithms for programming [closed]

I'm studying Computer Science and would like to know, if there are special books on algorithms for programmers, or if you can suggest some books talking on algorithms in general
4
votes
3answers
138 views

Unragging a matrix

Today I ran into matrices like this one: ...
2
votes
2answers
37 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
112 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
491 views

Match opening and closing parentheses?

Suppose I have a List of the form: lst={"(", "(", "(", ")", "(", ")", ")", ")"} By running ...
24
votes
7answers
694 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 ...
2
votes
1answer
99 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
59 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
65 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 ...
4
votes
1answer
75 views

Default algorithm in NonlinearModelFit

Does anyone know the default algorithm used in NonlinearModelFit? The documentation gives several possible algorithms, but I can't figure out what it uses if you do not specify the algorithm. Thanks. ...
1
vote
1answer
303 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
115 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
93 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
49 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
195 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 ...
4
votes
1answer
223 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
441 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 ...
4
votes
1answer
132 views

How to execute a notebook in background

I am developing an algorithm that take time to return results. I thought if I could run this notebook in background and continue to develop the rest of my work. It is possible to do that?
4
votes
0answers
101 views

Implement a piecewise function elegantly and efficiently

Given that $$ g(x)= \begin{cases} max(x_{min},x-m) & 0.5x \leq max(x_{min},x-m) \\ 0.5x & max(x_{min},x-m)<0.5x<min(1,x+m) \\ min(1,x+m) & min(1,x+m)\leq 0.5x \end{cases}$$ ...
-1
votes
1answer
58 views

timing series algorithm [closed]

If we have a timing series t1,t2,t3.... and every timing point means an event. A time interval T is given. Once T is given, how to calculate the maximum event number happening in T? case A ...
3
votes
3answers
83 views

Generating increasingly longer lists from a single list

I start with an array such as {{1,1},{0,1},{-1,1}}. (1) I want to create an array from this which replaces each array inside the array with 3 new arrays, one ...
6
votes
3answers
325 views

Calculating integral by Romberg Algorithm

In my "Numeric Anasyis" course, I learned the Romberg Alogrithm to calculate the numerical integral. The Romberg Alogrithm as shown below: $$ ...
16
votes
7answers
606 views

Enumerating tuples from a larger space such that all pairs of values are present at least once

I am trying to write a function that will accept a list of N lists and returns a list of N-tuples that represent all pairs of values from the original N lists at least once. To illustrate with an ...
4
votes
1answer
226 views

How to create a Poincare disk type kaleidoscope in Mathematica?

Creating a Kaleidoscope in Mathematica is not a new topic at all, examples can be found from the links like: Wolfram reference and Wolfram demonstrations. My question is how to create Poincare disk ...
2
votes
1answer
137 views

Neighbourhood - Calculations

SeedRandom[0]; n = 5; (m = N @ RandomInteger[{1, 3}, {n, n}]) // MatrixForm result1 = MeanFilter[m, 1] // MatrixForm ...
9
votes
5answers
391 views

Repeating Digits

I have written ...
2
votes
3answers
64 views

Reconstructing an expression [duplicate]

I have a nested expression like this one expr = Tan[Sin[Cos[x]]]; I can deconstruct it with ...
4
votes
3answers
586 views

Computing Gaussian curvature

Can Gaussian curvature $K$ be computed from WolframAlpha or any other available Mathematica program? Please indicate the program or its reference. If input ...
10
votes
5answers
785 views

How to deal with recursion formula in Mathematica?

In engineering problems, I am always seeing many recursion formula. For instance, In the book "The NURBS book", I discovered many recursion formula Fibonacci ...
3
votes
2answers
224 views

A problem about recursion formula of deCasteljau algorithm

I use mathematica to realize the deCasteljaul algorithm $$\vec{P}_{k,i}(u_0)=(1-u_0)\vec{P}_{k-1,i}(u_0)+u_0\vec{P}_{k-1,i+1}(u_0)$$ The graphics that deCasteljaul algorithm generated as below: ...
11
votes
2answers
225 views

Temporal database reconstruction in mathematica

<EDIT> after some internet research I found the database domain that deals with this kind of thing: Temporal Databases. I think my question therefore becomes how to reconstruct a temporal ...
8
votes
3answers
305 views

Random Integer Sequences

I want to construct a random square matrix in the following manner: a) Three states [0 | 1 | 2] are repeated ...
14
votes
2answers
451 views

Better way to test that a matrix is upper-triangular?

Today, I got to thinking about how to test that a matrix was upper-triangular. So I had a try at it. Algorithm $\quad \quad a_{ij}=0 $ Or $i \leq j$ $\Rightarrow$ $True$ My solution is ...
5
votes
2answers
176 views

Graph expansion on Mathematica

Is there a way by which Mathematica can be given a graph as an input and be asked to find its expansion? Note: By "expansion" I mean the quantity called "isoperimetric number" or "Cheeger constant", ...