# Tagged Questions

An algorithm is a sequence of well-defined steps that defines in abstract the solution to a problem.

55 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 ...
172 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: ...
823 views

### Match opening and closing parentheses?

Suppose I have a List of the form: lst={"(", "(", "(", ")", "(", ")", ")", ")"} By running ...
760 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 ...
197 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: ...
69 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 ...
106 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 ...
443 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: ...
131 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 ...
180 views

### How can I detect certain letters by shape in an image? [closed]

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 (...
121 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 ...
283 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 ...
197 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 ...
289 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 ...
1k 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 ...
163 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?
84 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 ...
617 views

249 views

### A problem about recursion formula of de Casteljau algorithm

I use Mathematica to implement the de Casteljau 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 de Casteljau algorithm generated as follows: ...
302 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 ...
321 views

### Random Integer Sequences

I want to construct a random square matrix in the following manner: a) Three states [0 | 1 | 2] are repeated ...
520 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 ...
209 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", ...
937 views

### An inverted pyramid

I want to draw a pyramid approximately like this ...
721 views

### Coalition Games

Suppose an election produces the following result: result = {{"a", 120}, {"b", 80}, {"c", 50}, {"d", 30}}; Letters are parties and numbers seats. To form a ...
706 views

### Splitting strings into letter keys and integers

I have strings of the following form: string = "ABC123DEFG456HI89UZXX1"; Letter keys of variable lengths are followed by (positive) integers. I want to get this ...
370 views

### Replacing matrix values

I want to find the n largest values in a matrix and replace all others with zero. The solution I found uses ReplaceAll and becomes very slow as the size of ...
579 views

### How to generate a blank crossword sheet?

I attempted to generate a blank crossword sheet. My method is by combining the rows and columns as shown on the graph below. However, some of the across and ...
339 views

### Extracting values with multiple keys

I want to extract sorted data from a huge database based upon two (or more) keys in a very timely manner. Here is a reproducible toy example for two keys only: ...
151 views

### How to make a case insensitive sorted list and rename the file names of a given folder?

Suppose I had about 500 .JPG and .jpg files in my folder "c:\images\". How to ask ...
291 views

### How to build a game board [duplicate]

I have - rather lazily - constructed a chessboard like this: ...
66 views

### Speeding up ReplaceRepeated while truncating to desired order

I need to program in an algorithm that recursively makes algebraic replacements which leads to an utterly complicated algebraic function of $x$, but whose final result is only needed at fixed order in ...
805 views

### “Indexing” a vector

I need to "index" a vector according to the first occurence of its distinct elements. I have written ...
296 views

### Spectral Clustering

I am attempting to implement a spectral clustering routine using Mathematica, but I am encountering difficulties. Using the standard Gaussian similarity function found in section 2.2 of this paper ...
1k views

### Ragged Diamonds

diamond[n_Integer] := Table[1, {#}] & /@ (Range[n]~ Join~Range[n - 1, 1, -1]) diamond[5] // MatrixForm How could a more functional, "tablefree", solution ...
579 views

### Find intersection points with V10

My question departs from this one: Find intersection of pairs of straight lines but now I want to find the points with the new V10 Region-functions. ...
217 views

### Multivariate Polynomial Manipulation

I have a large homogenous multivariate polynomial in, say, 5 variables $a,b,c,d,e$. As an example take the polynomial $$a^4+2abcd+a^2 b^2+e^4+cde^2.$$ Now I would like to replace $k$-th power of any ...
293 views

### All possible pairs of two items

I have 4 different items {1, 2, 3, 4}. I want to obtain all possible pairs of two of the items. I have written: ...
208 views

### Optimization Algorithm: ideas wanted

EDIT: Lets assume a random matrix: ...
165 views

...
766 views

### Replace interior of matrix with zeros

I have f.e. the following square matrix: ...
337 views

### Write a number as the product of its two largest divisors

For even n >= 10 && n <= 98 I want to write n as the product of its two largest divisors (excluding ...
156 views

### What's a non-trivial Mathematica program involving conscious choice of stack vs. queue data structure?

In a typical computer science algorithms course, much attention is given to the discussion of queues vs. stacks as a data structure programmers need to consciously choose from to achieve algorithmic ...
1k views

### Efficient way to build a certain square matrix

For odd n I'm looking for a short and swift way to construct with (f.e.) n = 3 n = 11 ...