# Questions tagged [programming]

For mathematical questions related to programming, and questions where a computer-aided solution is strongly suggested. A strong connection with a mathematical topic is needed to make programming questions on-topic. This should not be the only tag. Consider also using the tags (algorithms), (numerical-methods), or (linear-programming).

727 questions
Filter by
Sorted by
Tagged with
1 vote
81 views

### Book Recommendations for Learning Python for Mathematics.

Lately, I've been finding that I often need to compute various things and graph some pretty complicated functions. I've realized that learning to program, especially in Python, could be really helpful ...
29 views

### Select a random number for a certain seed, being sure the previous seed doesn't select the same random number [closed]

Say I have a random number generator which takes a seed and gives an integer between 1 and 10. Say I have a seed '100'. This would generate a random number '4'. Now, how would I be sure that this ...
17 views

### How to solve a paths optimization problem in node-labeled and weighted graphs

I am having trouble finding a way to optimize this problem in Python. Even if it is not exact, I am trying some heuristics. Let $G = (V,\mathbf{L}, E,\mathbf{W})$ be a graph where $V$ is the set of ...
• 1,965
25 views

### Find closet point to C in an intersection of two circle A,B [closed]

Let $C_{A},C_{B},C_{D}$ denote all the points in the circles A,B,C with radius r,d,d respectively. Let $dist(x,y)$ denote the euclidian distance between point x & y. Let denote $m_{i}$ closest ...
26 views

### How to Find Closest Average for a set of variables from Multiple Sets of Numbers

I'm working on a problem where I have several sets of numbers and I need to find the closest average for a set of target values by combining numbers from these sets. For example, let's say I want to ...
• 21
32 views

### How can I make a vector of the products of the elements $(a_0b_0,a_0b_1,a_1b_0,a_1b_1)$ from the vectors $(a_0,a_1)$, $(b_0,b_1)$?

Given the vectors $$\bar{a}=\left(\begin{array}\\a_0\\a_1\end{array}\right), \hspace{5pt} \bar{b}=\left(\begin{array}\\b_0\\b_1\end{array}\right) \in \mathbb{R}^2,$$ is there any way to get the ...
1 vote
139 views

### Is everything an object in Math, just like in Objected-Oriented Programming? (Tao's Analysis I)

I am reading Tao's Analysis I, and there are a number of passages which seem to suggest an object-oriented point of view of mathematics reminiscent of the object-oriented programming with which I, as ...
• 2,533
33 views

### Circular Breakout Game: time or collisions needed to reach nth layer

Shower thoughts... A tiny ball starts inside a unit circle, surrounded by fixed concentric circles of increasing integer radius length. So it starts in is the 0-th "level". The ball moves in ...
• 294
23 views

### Solving systems of linear algebraic equations in singular case

I want to solve this system: $A \in \mathbb{R}^{n \times n}, \quad Ax = b, \quad det(A) = 0$ Hence, there are either no solutions or there are infinitely many of them, then I want to find a pseudo-...
1 vote
37 views

### Rotation invariant representation of strings

I came across the following simple programming question: You need to create a boolean function that will return True if you get String A by shifting the alphabets in String B. Example: ...
• 121
1k views

### Book recommendations for Combinatorics for Computer Science Students

I am a computer science student with an interest in competitive programming. I am currently looking to deepen my understanding of combinatorics, as it is a crucial part of algorithm design and ...
• 343
2k views

### Is it possible to find sum of x^x from a to b without using summation but rather a less computationally heavy method?

I don't know if I have an odd question, or if this has been asked before (research has not provided me with an answer or question about this). But I have a large amount of summation I need to do, ...
26 views

### Determine if point can be projected on any segment in polyline

I am trying to implement a script that determines if a series of points can be projected on any segment of a polyline. The projection must be exactly on the segment, not in the rest of the line ...
17 views

### Why adding functional derivative of entropy doesn't get an uniform distribution?

From https://mbernste.github.io/posts/functionals/, the functional derivative of entropy is $−1−logP_x(x)$. From my understanding, adding this derivative to a distribution, it will get an uniform ...
• 53
1 vote
66 views

### Find the center point of ellipse by only 2 points on it and radiuses

For a project, I am requested to find the center point of an ellipse (not necessarily centered), by just 2 points on it and radiuses. B and E are points on an ellipse (Begin and End of an elliptic arc)...
• 123
13 views

### Are there any theorems about the existence of feasible solutions to the Mixed-Integer Nonlinear Programming (MINLP) problem?

I am just wondering if there are any theorems about the existence of feasible solutions to the Mixed-Integer Nonlinear Programming (MINLP) problem. For example: Theorems about sufficient conditions ...
1 vote
38 views

### How to find both of the degrees and length of the hypotenuse in a circle if were stretched?

I'm trying to calculate the degrees of an angle and the length of the hypotenuse if they were stretched/scaled horizontally or vertically. Here's a picture to demonstrate. a = width b = height c = ...
• 43
10 views

### Latent Change Score Modelling

I am currently undertaking a research project that aims to assess the effectiveness of an intervention program. However, I am encountering difficulties in locating suitable resources for my study. ...
32 views

### Representing a Groebner basis decomposition in sympy

In Sympy package there is Groebner() function, which allows to find a Groebner basis={$g_1, g_2,..., g_k$} for an ideal I, generated by polynomials $\{f_1, f_2,..., f_n\}$. I wonder if there is ...
1 vote
14 views

### Help - How to separate 4th order transfer function (Butterworth Approximation) into 2nd order using Python Control Library?

Previously I had the following coefficients in the program. In this program I want to create a transfer function of butterworth approximation (Figital Filter Fesign - Digital Signal Processing). ...
304 views

### Find a the Position and Rotation of an Object in 3D Space Given the Pan and Tilt Angle to 3 Other Known Points.

Goal I want to find the rotation and position of an object in the real world given the pan/tilt or azimuth/elevation angles between the object and 3 or more other points in the room. The rotation of ...
76 views

### Help with reformulating linear programming with rounding numbers

I have the following problem, abstracting away a few details from a real-world application, that I want to solve with linear programming (or any other mathematical optimization with constraints, ...
• 157
54 views

### Find X such that X is the largest divisor of Y that is less than or equal to M.

I have this function that finds X such that X is the largest divisor of Y that is less than or equal to M (and X != 1). in other words, Y/X gives least amount of remainders when dividing from 2 to M. ...
21 views

### Minimize the Frobenius norm between two matrices with inequality and equality constraints.

I had previously asked a question in which the problem was incorrectly specified. I am rephrasing it in this new question. The specific model is this one: Let A $\in \mathbb{R}^{n \times m}$ and B and ...
226 views

### Vietnam Mathematical Olympiad 2024 - First Question

Problemset paper (in Vietnamese): https://www.facebook.com/share/p/PpV3EQVE4chTZnZC/?mibextid=TrneLp I am looking at the problem set of the VMO2024, but I can't solve any of them, nor have an idea of ...
674 views

### Chance of generating two zeros in a row, compared to chance of generating a zero and a one in a row when generating random numbers between 0 and 5?? [closed]

I tried to code a simple python program which does the following: it generates random numbers between 0 and 5 until a zero is generated twice in a row. it does this N times and calculates the average ...
• 39
92 views

### Deriving constants that are used to construct an isometric cube [closed]

Problem Overview I'm working on a website that uses CSS/JS to create this isometric, resizable cube. Through some "logical" experimentation, I was able to determine the constants that allow ...
57 views

### Prime partitions of a rectangle

Prime partitions of a rectangle partitions of a rectangle ABCD is a rectangle such that AB ≥ AD. AB, AD, AE and AF are integer lengths. A configuration is called “first” when the 8 surfaces Si (i = 1, ...
1 vote
59 views

### Good textbooks on optimization to read?

I am a user of CPLEX and I routinely came across more or less theoretical issues in my work. So I have to keep improving my optimization skills and knowledge. So far I have finished two well known ...
• 11
31 views

### non-homothetic configurations such that the area of triangle ABC is integer

Let a, b, c, and n be four integers such that b < a ≤ n and c ≤ n. In a triangle ABC (ABC is oriented in the positive counterclockwise direction), let D be a point on side [BC] such that BD = a, DC ...
55 views

### Defining a recursive function (structural induction)

A list of integers can be recursively defined as follows: <IntList> ::= [] | cons(<Int>, <IntList>) Write a recursive function named ...
• 1,237
31 views

### Failing to understand (scaled) partial pivoting

I have a few questions regarding the (scaled) partial pivoting method. In my lecture slides, it says that partial pivoting chooses the biggest pivot in magnitude to prevent round-off errors from ...
• 1
141 views

### The number of triangles in the fractal, which is formed from a square by the additional construction of isosceles right triangles

There is an algorithm for constructing a fractal: Take a square with a side of size 1; An isosceles right triangle is completed on each side; GOTO step 2. There is an example of that shape: How can ...
32 views

### calculating dynamic offset

there are two given functions. One (blue) is detailed but has a certain offset from its actual value. The other (red) doesn't have this offset, but it is less detailed. I'd like to use the first ...
654 views

### Project Euler #864, count $\sum\limits_{i=1}^C \mu^2(i^2+1)$ for large $C$

Link: https://projecteuler.net/problem=864 For short, you are asked to calculate: $\sum\limits_{i=1}^C \mu^2(i^2+1)$, where $\mu$ is the Mobius function and $C=123567101113$ is a large integer ...
• 1,006
78 views

### How to derive the Log and Exp functions of a Geometric Algebra Rotor for Spherical Interpolation (Slerp) in 4D

I am trying to create a Slerp function between two 4D Rotors Rotor Slerp(Rotor a, Rotor b, t) { ... } I have been told you can do an interpolation using Log and ...
• 1
24 views

### What are the steps for the LQ decomposition of a tall matrix

I need to write an R function that decomposes a rectangular $6 \times 4$ matrix into $6\times 4$ lower triangular L matrix and an orthogonal Q matrix, however I can't seem to find any information on ...
• 463
23 views

• 177
186 views

### Combinatorial Proof for the Number of Squares in a Grid

I am exploring combinatorial methods to solve a problem related to counting the number of squares in a grid. Given an 'a x b' grid of evenly spaced points, I want to understand how to determine the ...
• 123
1 vote
65 views

### Using Sage to compute facts about modules

I am new to programming in general but in my project, I am required to work with a finite set $S = \{A_1,...,A_n\}$ of $m \times n$ matrices over a finite ring $R$, and the submodule $M$ they generate....
• 713
1 vote
176 views

### Find combinations of 3 values that add to final value

So I only took math up to high school level and a bit during uni, but I do code a lot and can figure out a lot of algorithms and formulas to get what I want, but this stumped me... I never had to ...
26 views

### Understanding of the Squares World Problem

I am currenlty improving my problem solving skills and i stumble upon this problem, I thought it is quite a simple problem but upon further exploring it is harder than i thought it would be. Here is ...
72 views

### optimal sandwiches in first $n$ positive integers

Consider an ordered permutation of $n$ integers $\lbrace a_1,a_2,\ldots,a_{n} \rbrace$. Define a sandwich to be a pair $(a_i,a_j)$ such that $a_i,a_j > a_{i+1},a_{i+2},\ldots,a_{j-1}$. Find the ...
• 109
1 vote