Programming questions that are significantly affected or best defined by the underlying mathematics of the problem.

learn more… | top users | synonyms

1
vote
1answer
132 views

Is Haskell appropriate for Signal Processing, Communication Systems and Information Theory?

I have been working on Software-Defined Radio projects for almost a year. This is an area which requires lots of signal processing (digital filters and FFTs), communication theory (modulation, ...
0
votes
1answer
31 views

Is hadoop designed only for “simple” data processing jobs, where communications between the distributed nodes are sparse?

I am not a professional coder, but rather an engineer/mathematician that uses computer to solve numerical problems. So far most of my problems are math-related, such as solving large scale linear ...
0
votes
0answers
39 views

Generating all the words accepted by a deterministic finite automaton [duplicate]

Imagine you've got a finite deterministic automaton A defining some finite regular language L, consisting of N words. The first question is: how would you determine the number of words N? Then, I ...
1
vote
1answer
111 views

Why did Shannon's outguessing machine beat Hagelbarger's?

I'm reading "Rock Breaks Scissors", which describes two "outguessing machines" built at Bell Labs that try to exploit human non-randomness in the game of matching pennies. There was an outguessing ...
-1
votes
2answers
67 views

Fiscal quarter vs calendar quarter

I'm building a Date/Time class with a "configurable quarter" system as follows. User specifies which month the quarter starts at (config) Set of functions to deal with quarters (next quarter, prev ...
1
vote
0answers
32 views

Time passage arithmetic explanation

I ported this from http://www.effectgames.com/effect/article.psp.html/joe/Old_School_Color_Cycling_with_HTML5 some time ago. However i'm now wanting to modify it for the purpose of changing it from ...
1
vote
1answer
84 views

Is there an easy way to type in common math symbols?

Disclaimer: I'm sure someone is going to moan about easy-of-use, for the purpose of this question consider readability to be the only factor that matters So I found this site that converts to easting ...
0
votes
1answer
207 views

If a library doesn't provide all my needs, how should I proceed? [closed]

I'm developing an application involving math and physics models, and I'd like to use a Math library for things like Matrices. I'm using C#, and so I was looking for some libraries and found Math.NET. ...
6
votes
3answers
828 views

Japanese Multiplication simulation - is a program actually capable of improving calculation speed?

On SuperUser, I asked a (possibly silly) question about processors using mathematical shortcuts and would like to have a look at the possibility at the software application of that concept. I'd like ...
0
votes
3answers
104 views

Unique ID algorithm

I've got a route that contains objects. Each one has value 0 or 1. I need unique route ID which will identify any objects order. Currently I'm doing it using binary number that is converted to decimal ...
0
votes
2answers
122 views

Randomized Hash function with no collisions

Related to the question Which hashing algorithm is best for uniqueness and speed? Is there a way to create a hash function, or find one, whose hash length depends completely on the input length, has ...
0
votes
1answer
117 views

Why Num&sizeMinusOne faster than num&(size-1)

I've been told that when I have a hash table of size m and m=2^k, I can use the & operator as num & (size-1) instead of num % size, to fit the hashCode to my table size. I've also been told ...
0
votes
0answers
50 views

Using JavaScript to find the correct offset in bundled files

I am currently making multiple parsers using PEGjs and have implemented my own partial preprocessor which using a RegExp finds and replaces '#include' directives with the desired files, resulting in a ...
5
votes
1answer
254 views

How to modify ELO algorithm when number of games is low to reduce outliers

I've developed the standard ELO implementation that can be found here, but the problem I'm running into is that my players will only have between 10 and 40 games in a "season". Since my first season ...
0
votes
3answers
289 views

What to expect as a programmer in a bank? [closed]

After three phone interviews, I got this offer in a large bank as a Java programmer. I have no prior experience in financial institutions (only two years as a regular Java dev), so I'm a little bit ...
0
votes
1answer
129 views

Euclidean Space Fully Connected Nondirectional Graph: Shortest Path to all nodes

So this may be a question that is born of my inability to properly express my intentions to Google. In a fully connected non-directional graph such that any three points can be properly represented ...
2
votes
2answers
231 views

Representing a deck of cards in C (not C++)

So far my best ideas have been as fallows A) Represent a "card" in one structure and have a "deck" in another a deck being an array of 52 cards and a card being 2 chars one for and rank one for suit. ...
1
vote
2answers
84 views

Progress bar for unknown number of items

I am working on a survey-based feature in our application and the survey has branching points at any given question depending on the answer given. Each path that a branch can take may not have the ...
0
votes
1answer
65 views

Capture portions of a number using mathematical operations [closed]

Is there a mathematical way to get the following: For the the number 777,888,999 so 777 million and etc etc getMillions(777888999) should return 777 only getThousands(777888999) should return 888 ...
0
votes
1answer
179 views

Find possible variations of one item out of multiple baskets.

I have three baskets of balls and each of them has 10 balls which have the following numbers: Basket 1: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 Basket 2: 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ...
3
votes
1answer
295 views

What are the essential mathematics topics that a programmer should know in order to learn algorithms? [closed]

Being a electronics engineer, I was never exposed to any algorithms. Now I am a experienced programmer and want to learn Algorithms. I started with CLRS. But I was overwhelmed by the maths in the ...
21
votes
11answers
3k views

Why do we still use floats? [duplicate]

I understand why floats served a purpose in the past. And I think I can see why they're useful in some simulation examples today. But I think those example are more exceptional than common. So I ...
2
votes
1answer
132 views

Draw graph of a function whose characteristics are unknown [closed]

Suppose I have a function. I have code that, given an x value, produces a y value. I can assume that the function is somewhat mathematically sane, not something crazy like an ...
2
votes
2answers
212 views

How do you program a way to create mathematics formulas?

For one of my project ideas, I want to create a dice rolling app. It would allow people to setup somewhat complex combinations of dice roll cascades in a visual way. I have a pretty good idea on how ...
0
votes
0answers
134 views

Algorithm for pinning joints for use with inverse kinematics

I'm part of the development team for a 2D animation program. One of the key features of the program is the ability to pose figures using Inverse Kinematics. Although we have that part down, we need to ...
3
votes
2answers
542 views

How to represent a geometric line programmatically?

I have been trying to design a library to do some simple geometric computations in an Euclidean space regardless of its dimension. While it is easy to represent points, vectors, hyperspheres and ...
1
vote
5answers
167 views

shall a vector2 extends a vector3 or is it the opposite?

Perhaps the question might be tied to a theoritical or mathematical forum, but since it is for programming purpose, i ask here first: In a computer vision context, i write a couple of interfaces ...
7
votes
1answer
196 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 ...
7
votes
4answers
317 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
78 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
183 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
2answers
144 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
232 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
506 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
417 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
288 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
503 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
290 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
59 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
231 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
1k 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?
2
votes
3answers
341 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
214 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
641 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? ...
12
votes
4answers
729 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
6answers
2k 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 ...
5
votes
1answer
191 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
468 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
344 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
309 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 ...