Programming questions that are significantly affected or best defined by the underlying mathematics of the problem.
5
votes
1answer
41 views
Can relational algebra/calculus proofs be used to test/verify SQL?
Is it feasible or even possible to use relational algebra and/or relational calculus in the form of proofs to test/verify the correctness of SQL statements, functions, and stored procedures?
It seems ...
4
votes
2answers
109 views
Fastest way to check if two square 2D arrays are rotationally and reflectively distinct
The best idea I have so far is to rotate first array by {0, 90, 180, 270} degrees and reflect it horizontally or/and vertically. We basically get 16 variations [1] of first array and compare them with ...
1
vote
1answer
50 views
Matching users based on a series of questions
I'm trying to figure out a way to match users based on specific personality traits. Each trait will have its own category.
I figure in my user table I'll add a column for each category:
id name ...
2
votes
1answer
111 views
Are there any formalized/mathematical theories of software testing? [duplicate]
Googling "software testing theory" only seems to give theories in the soft sense of the word; I have not been able to find anything that would classify as a theory in the mathematical, information ...
-2
votes
0answers
76 views
What is functional programming about, in a few words? [duplicate]
I've heard good things about functional programming, and that it's great if you love maths, which I do. So, what is it about? What can you do with it- in what sort of ways can you apply it?
2
votes
2answers
134 views
Name of the function f(x) = a*(x^b) [closed]
I am working on a C++ library, and I would like to make good decisions on the naming of function. In several places of my library, I need the use of a function which is a multiplication/exponentiation ...
2
votes
2answers
71 views
Effective and simple matching for 2 unequal small-scale point sets
I need to match two sets of 3D points, however the number of points in each set can be different. It seems that most algorithms are designed to align images and trimmed to work with hundreds of ...
1
vote
1answer
70 views
Best way to define 'snap points' between two arbitrary objects in 3D?
I'm working on a simple in-browser 3D model constructor using THREE.js. The user picks a plane body, and adds wings, cockpit, tail etc of their choice, choosing from multiple options. I need to be ...
5
votes
1answer
319 views
Maths needed to understand theory behind Haskell's type system?
Recently, I've become deeply interested in Haskell.
While attempting to learn new concepts (e.g. the forall keyword and ST monad) and Haskell's type system in general, I continually run into ...
2
votes
1answer
105 views
Treating a 1D data structure as 2D grid
Hopefully this is a good question. I am working with a native class that represents a 2D image as a 1D array. If you want to change one pixel, for example, you need to now how to derive the index from ...
0
votes
1answer
129 views
Sort rectangles in a grid based on a comparison of the center point of each
If I have a grid of rectangles and I move one of the rectangles, say above and to the left of another rectangle, how would I resort the rectangles?
Note the rectangles are in an array, so each ...
2
votes
1answer
246 views
Subtractive color mixing algorithm
Here is my problem:
I have a set of 'n' colors including the primary colors and their codes in hexadecimal. Now given another color 'x' I wonder if it's actually possible to come up with a mix ...
-3
votes
3answers
230 views
More Accurate Random in C [closed]
I have 3 IPs and every IP has a weight, I want to return the IP's according to its weights using the random function. For example if we have 3 IP's
X with weight 3
Y with weight 3
and Z with weight ...
0
votes
0answers
53 views
How to process components of a matrix that are obtained by singular value decomposition so as to find weightage?
I am writing an application that needs to find weightage of words in a document.
For this I am using the principles and techniques of Information retrieval. I programmed to find information about ...
-4
votes
4answers
202 views
Which if statement requires less computation?
I have
if (!b && c || a && c)
//do action a
else
//...
Due to some internal relationship between a, b, and c. !b && c || a && c is proved to be equivalent to (! ...
2
votes
3answers
498 views
Why does division and multiplication by 2 use the shift operator rather than division operator?
While looking at the code in C for division/multiplication by 2, it is found that shift operator is used rather than division operator. What is the advantage of using shift over division operator?
1
vote
3answers
266 views
Why is float the default in the majority of languages?
In programming languages, for represent numbers you have (mainly) two types: Int(s) and floats.
The us of Int is very easy. However floats cause a lot of unexpected surprises:
...
1
vote
2answers
149 views
How fast should a Python factoring script be?
Just how efficient is "good enough" for all intents and purposes? I wrote a script to simply list off all numbers that divide into an input, x, as pairs (i, n//i) and was just curious how efficient I ...
4
votes
5answers
427 views
When comparing floats, what do you call the threshold of difference?
I'm comparing floats in Java right now and the simplest formula is:
Math.abs(a - b) < THRESHOLD
When naming your variable for the threshold of difference, should you name it delta or epsilon? ...
11
votes
4answers
404 views
Why is mod (%) a fundamental mathematical operator in many programming languages?
Is there a reason, historical or otherwise, why the modulus operator is part of a small set of standard operators in what seems like many languages? (+, -, *, / and %, for Java and C, with ** in Ruby ...
10
votes
7answers
917 views
Web Developer and Math [duplicate]
I have just learned HTML/CSS and I practice everything I read to make it more understandable to me and I really enjoy it. My goal is to be a Modern Web Developer both front and back-end, so I won't ...
6
votes
1answer
141 views
Bin sorting problem - Please help categorize
I have a problem I am developing a solution for and currently I solve it with a brute force solution that checks all possibilities. It works for small numbers of bins but I'd like to work with a ...
13
votes
2answers
419 views
Trying to understand the 2N lnN compares for quicksort
I was going through the analysis of quicksort in Sedgewick's Algorithms book. He creates the following recurrence relation for number of compares in quicksort while sorting an array of N distinct ...
0
votes
1answer
212 views
Sum of divisors of numbers of the range ~ 10^6
I was trying to find the sum of divisors of numbers upto 106. The test cases are like of the order of 105. I have done some pre processing like
int divisors(int num)
{
int sum=0;
for(int ...
0
votes
3answers
225 views
Using Power of 2 numbers to represent types
Let's say that we have some values, represented by power of 2:
TYPE_1 = 1
TYPE_2 = 2
TYPE_3 = 4
TYPE_4 = 8
...
I need to store some of these types in one value.
Example:
To represent TYPE_1 with ...
0
votes
1answer
172 views
Python — Time complexity of built-in functions versus manually-built functions in finite fields
Generally, I'm wondering about the advantages versus disadvantages of using the built-in arithmetic functions versus rolling your own in Python.
Specifically, I'm taking in GF(2) finite field ...
14
votes
4answers
786 views
Documenting mathematical logic in code
Sometimes, although not often, I have to include math logic in my code. The concepts used are mostly very simple, but the resulting code is not - a lot of variables with unclear purpose, and some ...
4
votes
2answers
208 views
Array Multiplication and Division
I came across a question that (eventually) landed me wondering about array arithmetic. I'm thinking specifically in Ruby, but I think the concepts are language independent.
So, addition and ...
0
votes
0answers
87 views
What kind of maths do I need to become an excellent programmer [duplicate]
I am looking to become a app/video game developer or a website developer. What kind of maths do I need to know and do I have to know it well. Do I need to know calculus, statistics and modeling, what ...
4
votes
2answers
438 views
Does learning to play an instrument improve programming ability? [closed]
I've seen plenty of questions asking if listening to music boosts productivity, etc. but I haven't been able to find one about performing music. Learning to play the piano has been on my to-do list ...
0
votes
0answers
125 views
What kind of math do I need to become a better developer and programmer? [duplicate]
I'm at a community college currently and while our curriculum is pretty good, it lacks math or any real theory. If I ever want to create an algorithm for anything, I'm screwed. I'm essentially a code ...
3
votes
1answer
179 views
Finding maximum number of congruent numbers
Let's say we have a multiset (set with possible duplicates) of integers. We would like to find the size of the largest subset of the multiset such that all numbers in the subset are congruent to each ...
1
vote
0answers
214 views
Optimization algorithm, how to develop this problem
I have a situation where I would like your input and think over / solve algorithm.
The specs
There are inventories with a specified amount of capacity. 'X
(width) and Y (time)' creates ...
5
votes
1answer
188 views
What is the difference between a combinator and function chaining?
So from what I've read about combinators I can't quite tell how they're different from simply chaining function calls. I know I must be missing something but I'm not figuring out what I'm missing. I ...
1
vote
1answer
162 views
Pairwise testing, not possible to say which combinations is faulty?
Let's say I have 4 (A,B,C,D) parameters with 3 possible values, also 81 unique combinations. With e.g. orthogonal array, I will end up with 9 test cases, each combining 3 pairs. But that means that if ...
2
votes
4answers
100 views
Find how the data has been processed
Well this has been a question I have puzzled about for a long time:
Suppose I have a dictionary of input:output like:
This
{2: 6,
5: 15,
20: 60,
26: 78,
...
982: 2946,
997: 2991}
where ...
2
votes
2answers
330 views
Transform math formula into code (line-line intersection)
I'm having hard times transforming a math formula to code. I can solve it on the paper easily, but it's hard for me to bring it into code form. Is it generally possible to bring a math formula ...
1
vote
4answers
435 views
Is there such a thing as truly random? [closed]
I saw a video about random numbers and how the programmer in that video was talking about computers generating pseudo random numbers and that they are not really random. I knew about this.
Then he ...
0
votes
3answers
163 views
algorithm to create all possible column vectors of size N containing only ones and zeroes [closed]
I am a mathematics student and am just starting to learn about programming. I am stuck on a particular program I am trying to write for fun. I want to find an algorithm to create all possible column ...
2
votes
2answers
1k views
Closest Point of Approach (CPA) mathematical formula in ship radar
I was recently searching for the mathematical formula to find closest point of approach (CPA) between one ship and another ship. I need to apply the formula in my radar ship program and I can't find ...
4
votes
3answers
277 views
Customer Requirements Contains Equations that Cancel to Nothing
I have a project where the customer requirement specifies a report and contains mathematical equations for the contents of some of the columns on that report. One of the columns on this report is a ...
2
votes
7answers
776 views
Is (1/(1/x)) always a perfect round trip?
Is the following guaranteed to return true for all numerical and non-zero values of x?
bool IsRoundTrip(double x)
{
double y = 1 / (1 / x);
return x == y;
}
What conditions would cause a ...
0
votes
2answers
144 views
Tracking scientific error when working with floating-point numbers
Background
I hate the way .Net/IEEE-754 handles equality of floating-point numbers (FPNs) (i.e. double, float). It requires the programmer to be prescient with respect to the yet-to-be-determined ...
2
votes
3answers
847 views
what is a efficient way to find repeating decimal
I am trying to find a efficient algorithm in Java to find the repeating decimal part of two integers a and b where a/b.
eg. 5/7 = 0.714258 714258....
I currently only know of the long division ...
3
votes
3answers
245 views
strategies for dealing with machine epsilon
Say you have a situation where you divide and then multiply a float, and you need to guarantee that it survives macheps (ie multiplication output equals division input). What are known strategies for ...
0
votes
1answer
267 views
I'm trying to create a visual representation of something, but I don't know what words to use, so I'll try to describe it
My project team is making a site that will use reddit style voting to track users' opinions on various issues, and use the data to create a "heat map". I say heat map in quotes because I'm not sure ...
3
votes
2answers
131 views
Randomness of wrapped RNG
There are plenty of questions around regarding random number generation, but I couldn't find anything that exactly matched my question. Apologies if I missed one.
Most random number generators in ...
0
votes
1answer
135 views
Algorithm to detect a CLICK within Square range
It might be a simple question but I am looking for optimal solution. I will have numbers printed on a screen and I will be aware of coordinates. Numbers/Symbols will have 4 points(Square) to define ...
10
votes
5answers
689 views
Interview puzzle on traveling on a line segment
Here's an interesting question I came upon:
Let's just say on a number line of length M, where 0 < M <= 1,000,000,000, you given N (1 < N <= 100,000) integer pairs of points. In each ...
2
votes
1answer
111 views
Turning n-dim points into m-dim where m<n and where point-to-point distance deviation is minimized
I want to apply k-means clustering to a (sparse) adjacency graph. For this I need to assign the nodes to a position in an euclidean space. Trivially I can do this by having a space with as many ...