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

learn more… | top users | synonyms

4
votes
2answers
162 views

Decimal vs. Integer; Given a fixed range of values, which is preferable for accurate computation?

After getting into a "heated discussion" with someone, I figured I'd ask this question for the sake of posterity. I'm willing to be corrected if my assumption is incorrect but I'd like to hear a ...
1
vote
1answer
42 views

Create a collection with “average points” of N items from a pool with items of various points

Let's say I have a question pool to generate exams out of it. Each question contains a difficulty from 1 (hard) to 99 (easy). The questions are available in a hash / array (adapt to your favorite ...
1
vote
2answers
88 views

How can I make sense of the word “Functor” from a semantic standpoint? [closed]

When facing new programming jargon words, I first try to reason about them from an semantic and etymological standpoint when possible (that is, when they aren't obscure acronyms). For instance, you ...
9
votes
1answer
208 views

Implied precision of floating-point functions

While reviewing another programmer's implementation of a function to calculate the normal distribution CDF, I made a suggestion to either replace the entire implementation with Python's built-in ...
0
votes
1answer
26 views

Representing the hierarchy of groups of numbers using type inheritance

I've run into an interesting conundrum while coding my own implementations for the basic sets of mathematical numbers (Natural, Integer, Rational, Irrational, Real, Complex). I'm doing this mostly for ...
0
votes
1answer
126 views

Why are floats called “real numbers” in some languages?

Some programing languages, notably Pascal, have a type of numbers called "real". However, mathematically speaking, these types aren't real. For them to be "real", these types have to be able to ...
1
vote
2answers
222 views

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

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
63 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 ...
3
votes
1answer
289 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 ...
0
votes
2answers
84 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
37 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
88 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
219 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. ...
5
votes
3answers
934 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
110 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
156 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
121 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
52 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
320 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
346 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
143 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
329 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
106 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
80 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
239 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
373 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 ...
22
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
152 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
228 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
145 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 ...
4
votes
2answers
645 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
169 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
217 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
335 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
83 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 ...
3
votes
1answer
203 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
171 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
311 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
596 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
844 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
318 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
593 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
385 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 ...
-4
votes
4answers
242 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
369 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
259 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
792 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? ...
14
votes
4answers
813 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 ...