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

learn more… | top users | synonyms

1
vote
1answer
37 views

Algorithm to find the fewest number of values (from a set of values) where the sum equals a value (+ one more condition)

The simplest way to explain this is with an example. You're given then number 19 and you have a set of numbers to choose from: 1, 2, 3, 4, 6 When choosing values from the list (which can be ...
0
votes
0answers
49 views

Excel-like column numbering [migrated]

I have a working code (below) to convert a number to Excel-like (A...Z AA...AZ BA...BZ ...ZA-ZZ) column codes (headers). For simplicity I limited it to 1 or 2 character codes. My question is: ...
0
votes
0answers
26 views

Specific weight randomness based on a curve [duplicate]

I had a problem where I had a list of objects and I wanted the ones near the front of the list to "appear more" then the others when chosen randomly. There wasn't any specific weighting involved for ...
1
vote
1answer
55 views

Program to find Orthogonal Matrices

I have been trying to find orthogonal matrix of order n where first row will be given as 1/√n, 1/√n, .... n times. The second row will be a vector such that dot product of it with the row above and ...
0
votes
5answers
301 views

Given a number which is power of 2, check if it is even power or odd power

I am given a number n , which is always a power of 2. I want to check whether n is odd power of 2 or even power of 2. For example: n=4 , ans= even n=8, ans=odd (because 8 is 2^3) n=1024 , ans=even. ...
4
votes
2answers
163 views

When should a trig function, with a degree argument, return -0.0?

In creating trig functions my_sind(d), my_cosd(d), my_tand(d), that used a degree argument rather than a radian one and provided exact answers at multiples of 90, I noticed that the result was ...
17
votes
7answers
2k views

What can one do to improve readability of math-oriented code in C#, Java, and similar? [closed]

As both a C programmer and a C# programmer, one of the things I don't like about C# is how verbose math functions are. Every time you would have to use a Sin, cosine, or power function for example, ...
4
votes
2answers
181 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
44 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
99 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
215 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
31 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
134 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
243 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
91 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
40 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
331 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
92 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
39 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
93 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
229 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. ...
4
votes
3answers
1k views

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

I'd like to write a simulation of Japanese Multiplication to get benchmarks on large calculations utilizing the shortcut vs traditional CPU multiplication. I'm curious as to whether it makes sense to ...
0
votes
3answers
113 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
184 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
123 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
53 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
388 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
408 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
153 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
516 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
117 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
89 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
275 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
480 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
168 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
235 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
158 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
730 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
237 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
412 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
89 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
217 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
190 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
325 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
637 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
1k 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
335 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
637 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 ...