Skip to main content

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
4 votes
1 answer
183 views

Slicing Graph by path

I have a Graph (generally not planar and without particular layout), and a simple path that connects two points of its boundary, as in the example shown below. How to ...
Daniel Castro's user avatar
0 votes
1 answer
55 views

Apply an equation based on two sets with different indexes

Apply an equation based on two sets with different indexes Simple example If I have the following elements in the form of two sets with different indexes: $m=\{m_1,m_2,m_3,m_4,m_5\}=\{1,2,2,2,1\}$ $p=\...
Emad kareem's user avatar
  • 1,014
2 votes
1 answer
233 views

Why does FindInstance[x>0,x] give 27? [closed]

Why does FindInstance[x>0,x] give 27? I would think it would give 1… maybe 2 or some small positive decimal.
Just Some Old Man's user avatar
9 votes
8 answers
757 views

Numerical approximation of the integral by using data

I want to use the numerical approximation of the integral of a function given a list of data: $$\int_a^bf(x)dx\approx\sum_{k=1}^N\frac{f(x_{k})+f(x_{k-1})}{2}(x_{k}-x_{k-1}),$$ where $f(x_0)=f(a)$ and ...
Patrick El Pollo's user avatar
7 votes
1 answer
113 views

How is the Mathematica command FindGeometricTransformation related to the Kabsch agorithm?

I searched the internet for a Mathematica version of the Kabsch algorithm, using the search terms "Mathematica and Kabsch" nothing came up in. Looking through Mathematica documentation, I ...
complex's user avatar
  • 333
3 votes
2 answers
677 views

Recycle buying soda problem

there is a question: " If a bottle of soda costs \$1 and you can exchange two empty bottles for one soda, how many sodas can you drink with \$20 " ...
我心永恒's user avatar
  • 1,572
1 vote
1 answer
187 views

Counting the numbers that yield a constant when summed

I was initially trying to code an algo that can rapidly count k numbers that yield s when summed. These numbers must lie in the interval from 0 to d. For instance, taking d=2, k=2 and s=3, the ...
Huldrich's user avatar
1 vote
0 answers
74 views

Sum of disjoint product of sets [closed]

If we have the following sets and we need to apply the Sum of disjoint product property to them, as in the following example: Take: $$P_1=\{x_1 x_4\}$$ $$P_2=\{x_2 x_5\}$$ $$P_3=\{x_1 x_3 x_5\}$$ <...
Emad kareem's user avatar
  • 1,014
0 votes
0 answers
69 views

Missing "StructuredAlgorithms"in the installation

I typed the following array = SymmetrizedArray[{{1, 3} -> a, {2, 2} -> b}, {3, 3}, Symmetric[All]] array["StructuredAlgorithms"] which should ...
Felipe's user avatar
  • 669
1 vote
1 answer
46 views

Performing logical reasoning to find minimum function between two functions

Consider the following two expressions: f[x_,y_] := (1+x) g[x_,y_] := (1+x*y^2) x,y are bounded in a unit hypercube. (Ignore ...
BabaYaga's user avatar
  • 1,897
0 votes
0 answers
65 views

How can a program be configured for these steps?

Is it possible to create a program that implements sequential mathematical steps... in order to be circulated to more than one selected set? Step 1: For the following sets: $$S_1=\{x_1,x_2,x_3\},S_2=\{...
Emad kareem's user avatar
  • 1,014
10 votes
5 answers
1k views

How can I get samples of f(x) that are roughly evenly spaced?

I am looking for an efficient way of getting 60 to 80 samples of an arbitrary f(x) such that the distance between adjacent samples are approximately equal. My first attempt is based on a first order ...
Ted Ersek's user avatar
  • 7,144
2 votes
3 answers
167 views

Simplifying 'symbol-linear combinations' of nested monomials

I'm working with a custom binary 'operation' $F$ which takes $x, y$ and produces $F[x, y]$, where the possible arguments are already given by some list $\{ \text{one}, a, b, c, d, x, y, e, f\}$ where $...
VertexVexed's user avatar
2 votes
1 answer
116 views

Efficiently Finding Weighted Integer Partitions

Suppose we have some list of natural numbers $\{ 1, 2, \dots, N \}$ and each natural number $i$ has a 'weight' $w_i$. I would like to generate the all the integer partitions which satisfy the ...
MathPhysPlague's user avatar
3 votes
2 answers
162 views

Taylor approximation of integrals

I have BVP as in the picture and I want to solve it numerically by method given as follow. In the original paper, it is motioned that first iteration is computed and other are computed with Taylor ...
Junaid Ahmad's user avatar
5 votes
2 answers
196 views

Minimum/optimal number of tiles to cover all boxes

I have been struggling with the following problem. Given: the coordinates of a bunch of boxes/rectangles (in the form {xmin,ymin,xmax,ymax}) aligned with the x-y ...
Fraccalo's user avatar
  • 6,107
1 vote
3 answers
228 views

How to implement tridiagonal matrix algorithm?

I have created the tridiagonal matrix below: ...
Mule's user avatar
  • 43
0 votes
0 answers
79 views

Which algorithms are implemented in community detection based on AdjacencyGraph[.] and WeightedAdjacencyGraph[.]?

The following code generates two distinct community structures: one uses a simple adjacency matrix (with 1 and 0), another uses a weighted adjacency graph (with positive real numbers). I like to know ...
Tugrul Temel's user avatar
  • 6,263
5 votes
4 answers
411 views

An accumulated moving average

1. Problem statement In accordance with the standard definitions the inbuilt MovingAverage ...
eldo's user avatar
  • 82.4k
4 votes
2 answers
931 views

How to calculate equivalent resistance for a network of same-value resistors?

Let's assume I have n identical resistors. I can connect them either in series or in parallel (let's disregard bridge connections for now). Now, I want to list all ...
emnha's user avatar
  • 2,111
5 votes
2 answers
198 views

Fill a sequence containing missing values

Example data list = {Missing[], Missing[], 100., 200., Missing[], Missing[], 250., 210., Missing[]}; With downloaded data I often have the situation that there are ...
eldo's user avatar
  • 82.4k
6 votes
2 answers
249 views

Split a sequence with conditions

I need a function which splits a sequence of arbitrary length at x random points and which guarantees that each partition (bin) contains a minimum of ...
eldo's user avatar
  • 82.4k
5 votes
5 answers
604 views

Analyzing football games (pairing matrix)

I want to cross-tabulate football games over several years. Setting up example pairings: Please note that there can be up to 20 clubs and a couple of thousand matches! ...
eldo's user avatar
  • 82.4k
8 votes
6 answers
450 views

Accumulate up and down

I want to accumulate positive and negative values separately. dt = RandomSample[Range[-10, 10]] {3, -5, 2, -9, 1, -1, 0, 8, 10, 4, -7, 7, -8, -3, 6, -4, -2, 5, -10,...
eldo's user avatar
  • 82.4k
9 votes
9 answers
675 views

Partition a random sequence composed of three numbers

I want to partition an array composed of 1s, 2s and 3s in such a way that, going from left ...
eldo's user avatar
  • 82.4k
9 votes
4 answers
709 views

Smooth a list of integer values

I want to smooth a list of Integers so that outlying values become less spiky. The result vector must again contain Integer ...
eldo's user avatar
  • 82.4k
7 votes
6 answers
378 views

Replace duplicate list values with unique elements

My request is a follow-up on this question: Replacing duplicates instead of deleting them What if we want to replace duplicated values not with a single value but with newly created values distinct ...
eldo's user avatar
  • 82.4k
3 votes
0 answers
78 views

How to ask Mathematica to give me possible closed forms from a given numerical approximation

Imagine I am solving a some Infinite Series and I cannot directly compute the value using Mathematica. The value of this series approximates $ 0.785398....$ (Actually is $\frac{\pi}{4}$). I want to be ...
No-one Important's user avatar
4 votes
2 answers
156 views

Extract terms containing symbols

I would like to be able to extract terms that contain a symbol expression and leave the special function alone. I have a list: ...
Mariusz Iwaniuk's user avatar
5 votes
3 answers
318 views

Solving the Covering Salesman Problem in Mathematica

Say I have a weighted graph ...
Tomi's user avatar
  • 4,594
1 vote
0 answers
101 views

Solving system of linear equations in specific order

I know how to solve set of linear equations using Solve, or by hand of course. However, my current problem requires me to solve the equations in a specific order, ...
Lelouch's user avatar
  • 545
2 votes
1 answer
242 views

Finding induced subgraphs that are also trees

Given a graph $G$ with $n$ vertices, I need to find a subgraph consisting of $m$ vertices $\{v_1,\ldots,v_m\}$, and the induced subgraph of this subgraph should also be a tree. For example, suppose $G$...
Dotman's user avatar
  • 496
1 vote
1 answer
36 views

Unable to apply Reduce to a variable number of inequalities (obtained by InputFields)

I'm new to Mathematica and I'm stuck on this piece of code. The code is supposed to let the user choose how many inequalities (in a number between 1 and 5) they want to be evaluated. ...
Gbekss's user avatar
  • 11
5 votes
4 answers
302 views

Efficient generation of n-bit base-m Gray code with adjacent bit changes

How can I generate n-bit base-m Gray code in Mathematica, where only 1 bit changes at a time and all possibilities are covered? I have been hitting my head against a metaphorical wall for a few hours ...
More Senne's user avatar
3 votes
1 answer
193 views

On the solution of systems equations with exact coefficients

It all starts with the following system of equations that I can't solve by hand: ...
πρόσεχε's user avatar
0 votes
0 answers
63 views

How to use quasi-Newton methods to solve a non-linear system?

Consider the following function, for $\mathbf{x}=\{x_1,...,x_n\}$ $$ F(\mathbf{x})=\sum_{k=0}^n \frac{e^{A_k\mathbf{x}}-e^{B_k\mathbf{x}}}{C_k\mathbf{x}}-\mathbf{b} $$ where $\{A_k\}$, $\{B_k\}$ and $\...
sam wolfe's user avatar
  • 4,933
5 votes
1 answer
97 views

How to Find a Weighing Matrix of Size n?

Weighting matrices appear in the statistical design of experiments (Weighting Matrices and Statistical Design of Experiments. A weighting matrix is a generalization of Hadamard matrices, e.g., ...
Craig Carter's user avatar
  • 4,675
1 vote
0 answers
113 views

Solving the Unbalanced Assignment Problem with FindMinimumCostFlow?

I want to adapt this code from this answer to work with unbalanced bipartite graphs: ...
WaterFox's user avatar
  • 185
2 votes
2 answers
153 views

How can I calculate complicated infinite sums with FindIntegerNullVector (or related methods)?

I've recently been very interested in the wonderfully complex world of Euler sums, i.e. (convergent) infinite sums that, roughly speaking, consist of some rational polynomial combination of ...
TheOutZ's user avatar
  • 215
0 votes
0 answers
63 views

What strategy would you adopt for this deep search on a function?

Ok, so I have a problem where I have a function that depends on 9 parameters and a bound condition $$f(x,y,z,w,t,u,v,r,s)<K$$ Now all these variables take discrete values such as: $$x \in \{x_1, ...
Granger Obliviate's user avatar
2 votes
3 answers
134 views

Iterative method for fixed point of a mapping with domain and range contained in $\mathbb{R}^{2}$

Let $X$ be a metric space and $T:X\rightarrow X$ be a function. A point $x\in X$ is called a fixed point of $T$ if $x=Tx$. For example, if $X=[0,1]$ and $Tx=\frac{x}{2}$ then $T$ has a unique fixed ...
Junaid Ahmad's user avatar
21 votes
4 answers
1k views

What's wrong with this FFT-based Von Kármán vortex street simulation?

About 9 years ago, I came across this interesting website, and found the following paragraph with a broken Mathematica code sample: When fluid passes an object, it can leave a trail of vortices ...
xzczd's user avatar
  • 67.6k
4 votes
3 answers
345 views

Find all sets whose index is divisible by the elements

Suppose I have such a set $S=\{3,4,5,...n+2\}, n\in \mathbb{Z}_{>\, 0} $, $a_n$ is any permutation of $S$ such that $n|a_n$, I want to know how many such $a_n$. The easy but inefficient way to do ...
expression's user avatar
  • 5,672
2 votes
1 answer
108 views

Do loop not running the If clause [closed]

My full code is a bit more complicated but I hope that this works as a minimal example. ...
user34047's user avatar
  • 335
2 votes
0 answers
53 views

Memorization for Rule + ReplaceRepeated?

Question When build packages of noncummutative algebras I met the choice: Rule + ReplaceRepeated ...
Lacia's user avatar
  • 2,557
0 votes
0 answers
65 views

Algorithm: Permutations & Signature

Theoretical side Simple example: If I have two sets $A_1=\{1,3\} ,A_2=\{2,3\}$ and Permutations[{1, 2, 3}]= $\left( \begin{array}{ccc} 1 & 2 & 3 \\ 1 &...
Emad kareem's user avatar
  • 1,014
0 votes
0 answers
56 views

Algorithm consisting of modules returning multiple errors

I'm trying to write a genetic algorithm that will take a list of lists of reals in interval [0,1], my "starting population", "score" them according to a fitness function, append ...
J0ta's user avatar
  • 115
0 votes
1 answer
115 views

Visualization of an iteration scheme in Mathematica

I have a mapping T as attached (here. Now for $x_{0}\in C$ the Mann iteration process read as $x_{n+1}=(1-\alpha_{n})x_{n}+\alpha_{n}Tx_{n}$ n=0,1,2,3,... Now I want to obtain a visualization of the ...
Junaid's user avatar
  • 161
2 votes
0 answers
135 views

Implement of faster(maybe paralleled) K-Means clustering

I am writing an algorithm that needs to add noise to the centroid of each iteration on top of KMeans. Therefore, I need to implement a custom KMeans function. I checked out the methods in Mathematica ...
Charmbracelet's user avatar
0 votes
1 answer
614 views

Algorithm to convert real numbers decimal to binary

Currently trying to write code that converts decimal floats to binary base form (I know BaseForm exists). Currently I'm working with an example that takes 3.3 and converts it: ...
EconomicsandMathematica's user avatar

1
2 3 4 5
8