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).

740 questions
48
votes
3 answers

Under the Curry-Howard correspondence or loosely "proofs-as-programs", do we also have "programs-as-proofs" and what would some arb. program prove?

Curry-Howard Correspondence Now, pick any 5-30 line algorithm in some programming language of choice. What is the program proving? Or, do we not also have "programs-as-proofs"? Take the GCD algorithm written in pseudo-code: function gcd(a, b) …
30
votes
6 answers

Is (a/b)/c equal to a/(b*c) for integer division?

Let $\div$ denote a binary operator that returns the integer quotient of two integers, i.e. (assuming that both integers are positive) $a \div b = \left\lfloor \frac ab \right\rfloor$. This corresponds to the integer division operator in many…
18
votes
7 answers

Is there any way to find the number of real roots of a polynomial computationally?

I'm creating a program to find the real roots of any given polynomial. It takes a user given polynomial as input and tries to find its roots. As an aid, mainly to check if I've missed any after the process, I'd like to know how many roots the…
18
votes
1 answer

How to compute the sine of huge numbers

For several days, I've been wondering how it would be possible to compute the sine of huge numbers like 100000! (radians). I obviously don't use double but cpp_rational from the boost multiprecision library. But I can't simply do 100000! mod 2pi and…
12
votes
6 answers

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 analysis. Despite searching, I have not found good…
12
votes
1 answer

What's special about the number $1.000000015047466$E+$30$?

I'm a programmer by trade by I've run into a weirdly special number and need some help deciphering its significance. I was writing some machine learning code that compiles into GPU kernel code and the compiler output the number 1.000000015047466E+30…
11
votes
1 answer

What is the longest possible Cats & Boxes game?

I have enjoyed playing a puzzle game called "Cats & Boxes" published by Smart Games. Briefly, the way the game is played is: Place $5$ cat pieces and $4$ box pieces (one of which has $2$ boxes) onto a $5\times5$ grid. The game comes with $60$…
DreiCleaner
  • 2,230
9
votes
11 answers

Can exact square roots not be found?

I'm brushing up on some higher level maths for a programming project. I was going along and then I realized that I have absolutely no idea how square roots can be computed. I mean sure, I've memorized a lot of perfect squares. But I wouldn't be able…
9
votes
2 answers

Can these kolams/rangoli be drawn mathematically in any programming language?

I would like to know how to draw these kolams/rangoli programmatically. in any language, what kind of math is required? They are fascinating works of symmetry, thus I feel it should be possible, but don't know where to start.
Suraj
  • 91
8
votes
4 answers

When the product of a multi-digit integer and its mirror is a palindrome, can the original number have digits greater than $2$?

I am reposting a question I posted on r/mathematics. It was suggested I ask it here. My son was jotting down some multiplications for school and asked me if there were many numbers that, when multiplied by their mirror image, resulted in a…
7
votes
4 answers

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, which would be fine if I didn't intend for this to be…
7
votes
2 answers

Sum of the first $n$ palindromes

We put together a problem to be solved programmatically, and we know at lower numbers there is a solution to this problem. How would we go about proving whether the below problem has an answer, as our standard computational approaches do not yield a…
6
votes
1 answer

Taxi distance count to all lattice points at specified distance from the lattice origin and of a specified dimensionality?

Setup of the problem Description of the lattice The problem is stated on a non-negative integer ($ℤ_{\ge 0}$) lattice. The specification of distance is also a non-negative integer ($ℤ_{\ge 0}$). The specification of dimensionality is positive…
user1193068
6
votes
1 answer

How to draw a planar-embedded graph in a visually pleasing way

I have a graph with two types of vertices: "boundary" vertices have degree 1, and "interior" vertices have degree 4. I've computed a planar embedding of the graph, i.e. around each vertex, I have the list of outgoing edges in (say) clockwise order,…
6
votes
2 answers

Number of $n \to p \bmod n$ before getting to 0

There isn't much background context, but is there any estimations on how many iterations of $n \to p\% n$ are needed before $n$ becomes 0? Percentage sign is modulo. ($p$ is fixed, prime in my context but not sure if it matters). For example, when…
1
2 3
49 50