# Questions tagged [mathematical-programming]

Using a computer to implement mathematics. For questions about (mathematical) optimization, (also) use the optimization tag.

149 questions
Filter by
Sorted by
Tagged with
1 vote
1 answer
34 views

### Find the largest possible number not larger than some integer N and is the product of K consecutive primes

Source: Hanoi student competition of unknown year (Kì thi học sinh giỏi thành phố) Additional conditions: N is a positive integer in range [1, 2^64 - 1] K is a positive integer in range [3, 10] ...
0 votes
0 answers
28 views

### Finding Sum(F(i)) where F(i) = min(⌈ Ai / B1 ⌉ * C1, ⌈ Ai / B2 ⌉ * C2, ⌈ Ai / B3 ⌉ * C3, .... ,⌈ Ai / Bm ⌉ * Cm)

Given three arrays A, B, and C of size n, m, and m respectively (1-based indexed). A function F(i) is defined as - F(i) = minimum_of(⌈ Ai / B1 ⌉ * C1 , ⌈ Ai / B2 ⌉ * C2 , ⌈ Ai / B3 ⌉ * C3 , .... , ⌈ ...
2 votes
2 answers
106 views

### Factor a number in the longest possible product of distinct numbers

I got stuck with quite a simple problem: Given a positive number $X$ find the largest number $k$, for which exists the positive distinct integers $Y_1,…,Y_k$ such that $(Y_1+1)(Y_2+1)⋯(Y_k+1)=X$ Any ...
• 121
0 votes
1 answer
85 views

### If greater than or equal to zero then binary variable equals 1: integer linear program

I have a variable $d_{i} \in \mathbb{Z}$ with an upper and lower bound. I also have a binary variable $v_{i}$ which I want to $=1$ if $d_{i} \geq 0$; else $v_{i} = 0$. How do I enforce this as a ...
1 vote
1 answer
28 views

### Beginning Algorithm Design and Proving

I know this is a general question, so you can address this by giving some examples that are specific to your field. I want to start learning algorithm design and consequently prove its convergence. ...
• 243
3 votes
0 answers
26 views

### How to calculate 3D depth reconstruction of an image using a set of 3 similar images?

From a set of 2 similar images taken some small translation distance apart, we can calculate the depth of the a particular point, if we know the distance of a reference object in the frames. This is ...
• 131
0 votes
0 answers
21 views

### When do I use inversions in an array?

In problems like the 15 Tile Problem or Larry's Array problem, we use inversions in the array as a method to solve. But what's the principle behind this method and how do I know when to use inversions?...
1 vote
1 answer
20 views

### Number of operands to take when evaluating postfix notation?

All sources I have seen list taking two operands from the stack once we encounter an operator. Why? What if not all of my operators are binary (taking two arguments)? What if I have custom unary and ...
2 votes
0 answers
25 views

### Is computing subgradients an open research area in Authomatic Differentiation

Large portions of the possible research areas in Automatic Differentiation have broadly defined known solutions; most of which were derived in the 80s and 90s. Compute vector jacobian products: use ...
2 votes
0 answers
96 views

### Algorithm to find largest intersection of sets

This is a cross-posting from here, on the mathematics Stack Exchange. I thought this might be a more appropriate venue. The problem is this: I have a list of sets $$S_1, S_2,... S_N$$ where each set ...
0 votes
1 answer
87 views

### How does Wolfram Alpha solve functional equations?

Wolfram Alpha is able to solve a few basic functional equations. For example, it knows how to solve equations like this. My question is: how does it do this? I am planning on creating a program to ...
1 vote
2 answers
306 views

### Understanding Time Complexity

I am sorry if these are such stupid noob questions. I am just getting into CS. I read a passage in a book that says: Time complexity is written T(n). It gives the number of operations the algorithm ...
• 111
0 votes
2 answers
116 views

### What algorithm is prefered to do a x b mod P with big numbers (256 bits)

I'm trying to implement multiple precision arithmetic operations modulo P, with P < 2^256. More specifically, ...
• 103
3 votes
2 answers
85 views

### Precise algorithm for finding higher order derivatives

I'm trying to make an algorithm that finds the first 10 or so terms of a function's Taylor series, which requires finding the nth derivative of the function for the nth term. It's easy to implement ...
• 55
0 votes
0 answers
126 views

### Count of different ways to express N as the sum of given numbers

I'm working on a case and I need some help :) I need to find number of ways and solutions itself to express N as the sum of given numbers. So, Sum (N) = 600 and the numbers from which I need to get ...
-1 votes
1 answer
198 views

### Proof of Correctness : Arranging the sheep

I've come across a question in Codeforces contest 719(Div - 3). The problem goes like this : I was able to solve the problem by using another approach but had to use 4*n auxiliary space, where n is ...
1 vote
0 answers
28 views

### How to create algebraic structures in code

I've been searching around google and this site and I haven't been able to find the answer to this. How are algebraic structures (like a set and its elements, groups, rings, etc.) defined in code (in ...
• 111
1 vote
1 answer
48 views

• 133
0 votes
1 answer
95 views

### How to get the calculate the binary logarithm of a fixed-point number with 18 decimals?

Suppose that: You're using a programming language that doesn't support fixed-point or floating-point numbers. The said programming language rounds down divisions, e.g. ...
1 vote
1 answer
93 views

### Number of substrings with exactly k distinct characters

Given a string s and an int k, return an int representing the number of substrings (not unique) of s with exactly k distinct characters. If the given string doesn't have k distinct characters, return ...
• 13
1 vote
1 answer
12 views

### Is this adjustment to an rms calculation valid?

I want to calculate the RMS AC value of a signal made up of several thousand readings every second. The processor that I am using doesn't have enough memory to store a whole second of data, so I want ...
• 211
0 votes
0 answers
83 views

### Competitive programming: Good Subsets problem

An array of length K is called good if for each subarray of the array, the sum of the subarray is not divisible by K+1. You are given an array A of length N. Find the number of subsequences of length ...
-1 votes
1 answer
30 views

### Random numbers with condition in matlab

I need ’n’ random numbers that: each one is bigger than ‘a’ their sum is smaller than ‘b’ How can I have that in Matlab?
• 39
0 votes
1 answer
114 views

### Adapt a one-tape turing machine's algorithm that find the center of a string in O(nlog(n)) to find the first third

I have found this answer that finds the center of an input string in nlog(n) complexity. I have tried to use it as a starting point to find an algorithm that finds the character(s) that separate the ...
-1 votes
3 answers
50 views

### Which topics of mathematics should I need to learn to be a good app developer?

I'm 29 years old. I couldn't continue my studies after grade 10 due to some financial issues and I didn't have time to practice mathematics. It's been more than 11 years since I left studies. Now I ...
0 votes
0 answers
40 views

### Optimal partitioning of n-arrays

You're given N integer arrays. Each array can have different size and contains unique values. However same integers can be found in different arrays. The goal is to partition those arrays into K ...
0 votes
1 answer
37 views

### Is there a way to map a multi-variable structure onto a single range?

I want to categorise variants of a structure made up of some number of variable components by mapping it to a unique range. Assume that the individual components all fall within the same base range. I'...
• 3
0 votes
1 answer
93 views

### Is there a way to combine linear equation and inequalities into same equation in order to optimise software calculations?

I’m programming web application which has some tricky calculations and I would need some help with mathematical calculations. What I'm trying to calculate: I have number of items. Lets call items a1, ...
0 votes
0 answers
18 views

0 votes
0 answers
36 views

### Number of multiplications and additions in the given code

$N:=2^p$ Input: $f \in \mathbb C^N$ 1: $n=N/2$ 2: initialize vectors $f^{(1)}, f^{(2)} \in \mathbb C^n$ 3: $w_N^0=1$ 4: for $j=0,\ldots,n-1$ do 5: $\ \ \ \ \ f_j^{(1)}=f_j+f_{j+n}$ 6: \$\ \ \ \ ...
• 101
1 vote
0 answers
48 views

### How can I calculate the exponential integral?

(I'm not sure this is the right forum.) I'm writing a program that uses the prime-counting function. Right now, I'm using x/log(x), but I want to switch to ...
• 121