Questions tagged [algorithms]
Mathematical questions about Algorithms, including the analysis of algorithms, combinatorial algorithms, proofs of correctness, invariants, and semantic analyses. See also (computational-mathematics) and (computational-complexity).
11,773 questions
0
votes
0
answers
22
views
Efficient sparse matrix vector multiplication at low 30-90% unstructured sparsity. Relevant use cases?
I have been working on an algorithm for efficient matrix–vector multiplication on GPUs in the regime of moderate sparsity (30%–90%), with no structural assumptions on the sparsity pattern. The ...
-3
votes
0
answers
65
views
Is it valid to compare solving vs checking NP problems using average time per logical step?
I’ve been exploring a measurement approach for NP and NP-complete problems based on average time per logical step.
I define:
...
2
votes
1
answer
42
views
Construct AM–GM Proofs of Muirhead Inequalities (From Majorization to Explicit Weighted AM–GM Chains)
Motivation
I am experimenting with symbolic implementations of algorithms that, given a majorization relation between two exponent vectors, automatically generate Olympiad-style inequality proofs ...
1
vote
1
answer
147
views
Random points in a sphere
I have to randomly put $N$ points in a sphere of radius $R$ in a way that the distance of every point from the other points is greater than or equal to $r_0$. Is there an algorithm to solve this ...
8
votes
3
answers
324
views
Why is there no Euclidean Algorithm for the least common multiple (lcm)?
The greatest common divisor (gcd) of two integers $a$ and $b$ can be computed with the Euclidean Algorithm.
With the gcd known, one can compute the least common multiple (lcm) via the formula $\mathrm{...
0
votes
1
answer
59
views
Find square of format A+n*B [duplicate]
Is there any better way than a brute force scan to find a square (or possible the smallest square) of format $A+n*B$, where $A$ and $B$ are some fixed constant integers? (I know that that is ...
4
votes
1
answer
279
views
Winnability of an urn-ball game with restricted two-urn moves
My question is about a certain combinatorial game. The game works as follows. We have $n$ urns, each of which contains $m$ balls, where $m$ and $n$ are positive and satisfy $m < n$. A move consists ...
0
votes
0
answers
23
views
Max–min assignment on a DAG when nodes have candidate values with compatibility constraints
I have a DAG where every node has a (usually small) set of candidate integers. A candidate a is compatible with b if (a | b) or (b | a). For every root I want to choose one candidate per node to ...
3
votes
2
answers
407
views
Coloring a graph with K-colors
Given a graph, I wish to try and color it with the minimum number of colors (0,1...k).
Each 2 connected vertices must have different colors.
I proposed the following algorithm - Initialize an array of ...
0
votes
0
answers
32
views
Determiniing max roundness of number in an array
I'm trying to solve the following Codeforces question (https://codeforces.com/contest/837/problem/D), and I feel like I have a solution that's very close but is probably still over the time constraint....
2
votes
0
answers
43
views
Minimum number of sign flips for prefix sum positivity
Problem: (from the Indian ZIO exam, $2021$, problem $2$)
We are given a list of integers of length $n$. What is the minimum number of elements whose sign you need to flip such that every prefix sum ...
0
votes
0
answers
10
views
Fast Algorithms for Generating Simplicial $n$-Spheres on $k$ Vertices
As stated in title, I wonder know if there exists any algorithms for generating simplicial $n$-spheres on $k$ vertices.
The motivation for seeking such algorithms comes from my goal to compute the ...
1
vote
0
answers
38
views
Constructive method for expressing arbitrary matrix permutations using cyclic row/column shifts
I am unsure which category this question best fits into, so I apologize in advance if this is not the ideal place to ask.
It is known (see for example:
Do cyclic permutations of rows and column ...
0
votes
0
answers
38
views
Complexit of LSB extraction in Discrete Log Problem w.r.t. a prime number
Consider the discrete Log Problem w.r.t. prime $p$. Given $b, p, r$ find $x$ where: $b^x\bmod p=r$.
Q: What is the complexity of calculating the Least Significant Bit of $x$ in the worst case?
Note: ...
1
vote
1
answer
80
views
Find for two given Similar Matrices $A,B$ a matrix $S$ conjugating them, ie satisfying $A=SBS^{-1}$ constructively
Let $K$ be any field. Two square matrices $A,B \in \text{Mat}_n(K)$ are called similar (denote it my $\sim$) iff there exists a $S \in \text{GL}_n(K)$ such that $A=SBS^{-1}$, so in this form an ...
1
vote
1
answer
73
views
What is a worst case graph for this streaming algorithm?
Consider the following streaming algorithm for maximum matching in a weighted graph.
...
3
votes
0
answers
60
views
Generalized sliding-block puzzle
Finding solution of a Sliding Puzzle of size $N \times N$. asks about solving a sliding-block puzzle with multiple holes. Apparently a 2-hole puzzle is always solvable; as those who've played with the ...
0
votes
1
answer
97
views
Finding solution of a Sliding Puzzle of size $N \times N$.
We are given two matrices $R^{N \times N}$, each containing unique integers from $0$ to $N^2 - 1$ (except $0$, it does not need to be unique). The $0$ in the matrices will be called $blank$. The task ...
1
vote
0
answers
25
views
When do linear constraints form a compact? [closed]
Given a list of constraints
$$
F_i = \{ x\in\mathbb{R}^n\mid L_i(x) \leq c_i \}
$$
where $L_i\in L(\mathbb{R}^n,\mathbb{R})$ and $c_i\in\mathbb{R}$ for every $i\in\{ 0,\dots,m \}$ with $m \geq n$, ...
1
vote
1
answer
111
views
Maximum of a family of linear functions
Consider a finite family $F=\{f_i\}_{i=1}^n$ of nonconstant linear functions $f_i(x)=m_ix+b_i$ (where $m_i$, $b_i$ and $x$ are real numbers).
Is there a simple way to determine the index $I(x)$ such ...
0
votes
1
answer
34
views
Best-case running time [closed]
Definition of a leaf node:
A node that does not have any child node is called a leaf node.
Given an algorithm with a running time:
$$T(n)=2T(n/2)+O(\sqrt{n}).$$
So the number of nodes at root level ...
3
votes
1
answer
236
views
Iranian combinatorics olympiad 2024 problem 3
We say that a sequence $x_1, x_2,\ldots, x_n$ is increasing if $x_i ≤ x_{i+1}$ for all $1 ≤ i < n$. How many ways are there to fill an 8 x 8 table with numbers 1, 2, 3, and 4 such that:
• The ...
15
votes
0
answers
441
views
+100
Determining whether $A\subset X = \left\{0,1,\ldots,n\right\}$ can be written as $A=B+C$
Let $A$ be a nonempty subset of $X=\left\{0,1,\ldots,n\right\}$. We may ask whether $A$ can be written as $A=B+C$, where $B,C$ are also nonempty subsets of $X=\left\{0,1,\ldots,n\right\}$. Here, $B+C$ ...
0
votes
1
answer
75
views
Non-negativity and/or non-positivity constraints
In a Linear Program, introducing non-negativity and/or non-positivity constraints into the Primal turns equality constraints into "regular inequality constraints" (a.k.a., inequality ...
0
votes
0
answers
110
views
Minimum steps to cut a truss
Motivation
While I was looking at the method of sections to find the forces in the members of a truss in engineering mechanics, I had a question about the minimum amount of calculation required to ...
0
votes
0
answers
20
views
Kim & Kim's extension to Greiner-Hormann algorithm
I am currently implementing Kim & Kim's extension of the Greiner-Hormann algorithm seen here. However i have came across an issue that i am unaware if i'm missing something or not.
I have 2 ...
1
vote
2
answers
62
views
Relationship between binary exponentiation and Horner's method evaluation of Robinson polynomials at $x=2$
Binary exponentiation provides an algorithm for calculating a power $a^n$, where you iterate over the binary digits of $a$, and at each step update
$\mathbb{val} \leftarrow \mathbb{val} ^ 2$
$\mathbb{...
1
vote
0
answers
79
views
What is the algorithm for a square root in balanced ternary?
I'm confused by wikipedia's explanation of balanced ternary's algorithm for the square root. They only show a formula I don't know how to generalize to more digits than 2, and the example given doesn'...
2
votes
1
answer
68
views
Efficiently finding out which vectors from some set are linearly independent of the other vectors in the set
I have a set $S = \{v_1, v_2, \cdots, v_N\}$ with $N$ vectors, each of which have $d$ dimensions. I would now like to find a set $S' = \{n | v_n \in \mathrm{span(}S \setminus \{v_n \}) \}$, i.e. the ...
0
votes
0
answers
244
views
Efficient algorithm for solving Diophantine equation $x ^ 2+y ^ 3+z ^ 5=w ^ 7$ with $\gcd (x, y, z)=1$.
My Mathematica Codes:
...
4
votes
2
answers
330
views
Is there any algorithm which can find a common divisor of two polynomials modulo $p^k$?
Let us consider two monic polynomials $f(X), g(X) \in \dfrac{\mathbb{Z}}{p^k\mathbb{Z}}[X]$. Now, we call $h(X)$ is a divisor of $f(X)$, if there exists a $l(X) \in \dfrac{\mathbb{Z}}{p^k\mathbb{Z}}[X]...
-1
votes
1
answer
107
views
Gaussian elimination modulo $4$ [closed]
Does anyone know how to perform Gaussian elimination modulo $4$? Are there any ready-to-use code snippets or relevant websites available? I find that there are almost no existing code implementations ...
3
votes
1
answer
115
views
Is there a simple algorithm for approximating an imperfect offset polyline?
I've got a polyline of straight line segments to which I'd like to calculate an offset polyline (like an offset curve, but described as a sequence of connected non-arcing line segments). This is ...
5
votes
0
answers
54
views
Are there Salem-Spencer sets with bounded absolute second forward difference?
A Salem-Spencer set is a set of numbers no three of which form an arithmetic progression.
Suppose $A$ is a Salem-Spencer set. And let $(a_n)_{n=1}^{\infty}$ be the set $A$ written as a strictly ...
3
votes
2
answers
102
views
Can LP calculate maximum/minimum eigenvalue of a matrix
It's not hard to show that the maximum eigenvalue of a matrix $A\in \mathbb{S}^n$ can be calculated through the following SDP:
\begin{align*}
\max&\ Tr(AX) \\
\text{subject to}& \ Tr(X) = 1\\
...
1
vote
0
answers
37
views
Unorthodox implementation for a recursive identification method
Recently I realized that I've coded a custom-made function for recursive output error method which differs a bit from the traditional algorithm and would like to know the perception of my peers. ...
1
vote
0
answers
45
views
Introducing affine equality constraints into convex programs
In this lecture (43:39 - 44:10) and this lecture (1:11:13 - 1:12:46), Stephen Boyd hints at a method for introducing equality constraints into a convex program. The notation from the lectures is
$$\...
2
votes
1
answer
99
views
Polynomial-Time Algorithms for Canonical Form of Ternary Matrices under Row/Column Permutations and Column Negations
We study equivalence classes of ternary matrices of size $m\times n$, where equivalence is defined via row permutations, column permutations, and negation of entire columns. Our goal is to define and ...
1
vote
0
answers
33
views
Computing Minimum Mean Cycle with Specific Edge
A little context: I am implementing a branch and cut algorithm and I have a separation routine, where I construct a digraph and have to run a minimum mean cycle algorithm to check whether some ...
2
votes
0
answers
105
views
Conjectured fast and simple recursive algorithm for Bernoulli numbers
Let
$B_n$ be the $n$-th Bernoulli number.
$T(n,k)$ be an integer coefficients such that $T(n,k) = \nu_k$ where we start with vector $\nu$ of a fixed length $n$ with elements $\nu_1=1$, $\nu_i=0$ for $...
0
votes
0
answers
75
views
Most Important Asymmetric Computational Problems in Mathematics and Beyond.
I’m interested in computational problems that are asymmetric: problems where finding a solution is hard, but verifying a candidate solution is easy.
For example, in the approximate nearest neighbour ...
1
vote
0
answers
251
views
Compute $100!$ in under 150 steps using only sums and products [closed]
We begin with four numbers written on a board:
$1,0,0,0$
At each step, we may choose two of the four numbers (possibly the same), and replace one of the four with either their sum or their product. ...
1
vote
0
answers
48
views
Algorithm for ideal sum/relative norm in multiquadratic field
I strongly suspect this question has a very straightforward answer.
Let $M = \mathbb{Q}(\sqrt{a_1},\dots,\sqrt{a_k})$ be a large multiquadratic field. In this setup we assume it is infeasible to ...
1
vote
0
answers
70
views
Algorithm for minimizing the degree of a vector of algebraic numbers
Given a vector of algebraic numbers, $\vec{a} = (a_1, a_2, \dots, a_n)$, let the "max algebraic degree" be $$
\operatorname{maxDeg}(a_1, a_2, \dots, a_n) = \max(\deg(a_1), \deg(a_2), \dots, \...
4
votes
0
answers
148
views
playing with water
We have $n$ glasses with capacities $1,2,\dots,n$ liters, respectively. The amount of water in each glass is always an integer and the sum is $n$. In each move, we may pour water from one glass into ...
0
votes
1
answer
69
views
Seeking fast algorithms for a simultaneous diophantine approximation problem
I'm looking for a known or clean algorithm for the following simultaneous Diophantine approximation problem. I have $n$ real numbers $\vec{a} = (a_1, a_2, \ldots, a_n) \in \mathbb{R}^n$ such that $0 \...
0
votes
1
answer
81
views
Prove that for recursive multiplication of two $8 \times 8$ matrices; need $64,$ $2 \times 2$ matrix multiplications.
It is stated in the video on youtube, here, at 16:48; that multiplication of two $8 \times 8$ matrices, using the Divide-and-Conquer (i.e., recursive) approach, needs $64$ multiplications of $2 \times ...
1
vote
1
answer
144
views
Most efficient way to compute ${n+10^{10} \brace 10^{10}}$ for $1 \leqslant n \leqslant 1000$
I'm looking for the most efficient way to compute ${n+10^{10} \brace 10^{10}}$ for $1 \leqslant n \leqslant 1000$.
Obviosly, the standard formula, namely $$ {n \brace k} = \frac{1}{k!} \sum\limits_{j=...
1
vote
1
answer
138
views
A Fibonacci-like phenomenon seems to be happening amongst the primes up to an additive term of $+1, -1,$ or $\pm 1$ in each sequence value.
Fibonacci Algorithms
This question came to me when I learned today that the Fibonacci sequence has a really neat $2\times 2$ matrix power defnition which enables a newbie to compute $n$th Fibonacci ...
2
votes
0
answers
54
views
Algorithm for interlocking 3D blocks
Colloquial framing of the question: I have two solid wood blocks of arbitrary shape. I need to fit them together in some way, sort of like they were two pieces of a jigsaw puzzle. Is there an ...