Skip to main content

Questions tagged [math]

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

Filter by
Sorted by
Tagged with
6 votes
4 answers
491 views

Why is there (practically) no 6-byte integer in common usage?

In Postgres, it used to be quite common to use a 4-byte integer auto field for primary keys, until it started becomming somewhat common to run into the 2147483647 limit of 4-byte integers. Now, it's ...
orokusaki's user avatar
  • 1,093
17 votes
11 answers
17k views

Is it possible to build a system to generate UUIDs where every UUID is guaranteed unique?

Is it possible to design a distributed system to generate unique ids where there is a requirement that every generated id is guaranteed to be unique with no possibility of collision? I didn't think ...
Daniel's user avatar
  • 517
1 vote
1 answer
144 views

Ranking results from a Question and Answer game

I have a question and answer trivia game app which randomly picks questions from a database and prompts the user to answer the question correctly. The total number of correct answers, the total number ...
user1527613's user avatar
8 votes
7 answers
9k views

What is the size of the number 65535 in bytes? [closed]

As I got to know there are 256 possible combinations to get for 1 byte. If I understand it correctly, it should mean that you can display any number out of numbers 0-255 and this very number would use ...
treesarecool's user avatar
0 votes
1 answer
138 views

Understand implementation of exponential moving average (in case of unix load average)

The UNIX load average gives 3 numbers over 1/5/15 minute time intervals. It's supposed to be an indicator of how busy a UNIX machine is. The global load average is an exponentially decaying average of ...
BMBM's user avatar
  • 337
2 votes
2 answers
131 views

Design a function that indicates significant deviations in response times

I'd need some feedback on how to approach the design of a function that highlights parts of a time series chart. The chart shows the response time of an application, in particular the 90th percentile, ...
BMBM's user avatar
  • 337
4 votes
3 answers
256 views

Is it possible to store N bits of unique combinations, in N-1 bits? If not; why does MD5 get reprimanded for collissions?

Regarding cryptography and the issue of collisions, I posed a question as to whether it was ever possible to store every single possible combination of a bit array of a particular size, in a bit array ...
Anon's user avatar
  • 3,623
2 votes
6 answers
610 views

What is the viability of engineering an integral type with values ranging from -1 to 254? Do types like this even exist?

In software engineering, often developers will utilize three different states of a signed integer, as a trilean: This tends to be quite typical: -1 - Represents something akin to a null pointer, as in ...
Anon's user avatar
  • 3,623
2 votes
2 answers
879 views

How to use chebyshev polynomials to calculate exponents (antilogs)?

I am trying to write an algorithm to accurately calculate exponents (antilogs) for a variable precision floating point library I am working on. The base is not relevant since I can convert between ...
user264480's user avatar
0 votes
5 answers
2k views

Why is What Every Computer Scientist Should Know About Floating-point Arithmetic considered mandatory reading? [closed]

What Every Computer Scientist Should Know About Floating-point Arithmetic is widely considered absolutely mandatory reading for every programmer. Why is this the case? What aspects of the article make ...
J. Mini's user avatar
  • 1,037
7 votes
2 answers
630 views

some misunderstanding in concept of Huffman algorithm

What is difference between Average length of codes and Average length of codewords in Huffman Algorithm? is both the same meaning? I get stuck in some facts: I see a fact that marked as False: for a ...
Emma Nic.'s user avatar
  • 183
2 votes
0 answers
218 views

What algorithm can I use to spread a workload between two processor with fixed resources?

I need to write an algorithm to allocate x number of tasks to 2 processors per day. I know the following: Exact amount of time it will take to complete each task The exact amount of time available ...
Pythonner12's user avatar
-1 votes
1 answer
615 views

Is there a term for "shift towards zero"?

In pseudo code: given numbers x and y, if x is greater than zero, subtract the magnitude of y from x, otherwise add the magnitude of y to x. It's ok if x goes from being positive to negative or vice ...
baqyoteto's user avatar
  • 133
-1 votes
5 answers
2k views

Why is converting 0-indexed code to 1-indexed code non-trivial?

The disadvantages of 1-indexing are well-known. However, our hand is sometimes forced by our choice of language and we have to convert algorithms that were intended for a 0-indexed language to being 1-...
J. Mini's user avatar
  • 1,037
4 votes
3 answers
688 views

Why do computer scientists seem to avoid closed-form solutions to mathematical problems?

There are many instances of software developmet where we seem to solve problems differently than from a mathematical perspective. For instance, consider the classical example of calculating Fibonacci ...
coderhk's user avatar
  • 167
1 vote
4 answers
1k views

Is using multiple UUIDs decrease chance of collisions exponentially?

For example if you have a single UUID with a collision probability of x, if you concatenate 2 UUIDs, does the collision probability become x^2? val0 = generate_uuid() val1 = generate_uuid() final_val ...
Joan Venge's user avatar
  • 1,970
3 votes
1 answer
212 views

Integrating TeX into a Java desktop application

Looking to integrate TeX equations in a TeX-agnostic fashion, suitable for either ConTeXt or LaTeX, into a Java-based desktop Markdown editor. The possibilities are numerous, but I'm not sure what ...
Dave Jarvis's user avatar
4 votes
2 answers
1k views

How to show fluctuating data smoothly and accurately?

I am working on a project in which I have to read data from liquid level sensor installed in tank which measures fluid level and sends output in millivolt. The device has predefined ranges of voltage ...
Kashyap Kansara's user avatar
-3 votes
1 answer
62 views

Should absolute value functions be overloaded to give the norm of vector-like data structures?

The absolute value function is an instance of the norm function in one dimension. I've seen instances of libraries where the absolute value function is overloaded to also take the norm of higher ...
Josie Thompson's user avatar
-5 votes
1 answer
83 views

What is the difference between BigInt and "Computer Algebra System" integers?

Obviously I imagine a CAS does more than BigInt does. But I'm wondering if there is a difference in implementation between BigInt integers and CAS integers (whatever they may be, symbols?). Wondering ...
Lance Pollard's user avatar
0 votes
2 answers
139 views

How to minimize size of data given the need for a null pointer?

So I don't know how to formulate this clearly, as it's quite confusing. Hence the reason for asking this question, to overcome the confusion. I will do my best to make it clear, but part of the ...
Lance Pollard's user avatar
1 vote
2 answers
57 views

Suitable way to round results returned by any function of a class

Assume there is a class Shape. The class has two functions area() and perimeter(). Let's say Circle and Square inherit from Shape and override these methods. Obviously the results are going to be ...
Abhishek Kumar's user avatar
-1 votes
1 answer
56 views

Resolving Dependencies and Incompatibilities Deterministically

Problem Description I'm working in Python and I've been having a problem designing something to handle the following (abstracted) system: I have some objects (lets call them Nodes) that can be in ...
Qudit's user avatar
  • 3
2 votes
3 answers
137 views

Is there a way to specify a two-way relationship between variables?

Let's say we have two variables, eta and phi related by eta = cos(phi). Is there a way to link these variables in any programming language such that there's no need for two different functions, ...
BeeperTeeper's user avatar
1 vote
2 answers
1k views

Loan Amortization Schedule - Precision and rounding

I have been playing around making amortization schedules in PHP. My php.ini currently has the precision set to 14. I understand going into this that there will be rounding errors however I am hoping ...
FamousAv8er's user avatar
25 votes
4 answers
6k views

Why is the norm of a complex number in the C++ complex library actually the square of the norm?

In the C++ complex library, the method norm() of a complex number actually returns the square of what I have learned is usually called the "Norm". Reference: std::norm For example, std::norm() of (3,...
Mathieu Krisztian's user avatar
7 votes
1 answer
636 views

Smallest Rubik's cube state representation

I'm trying to determine what is the fewest number of bits I need to represent the state of a Rubik's cube. (EDIT: I am assuming the cube is a valid Rubik's cube that has not been altered and only ...
J Price's user avatar
  • 89
4 votes
3 answers
498 views

How to do grid systems with floats given precision causes problems

I've been trying to create a grid system that can use any grid size and start at any given anchor point rather than always at 0,0. The problem however is imprecision makes it impossible, even the ...
WDUK's user avatar
  • 2,092
-3 votes
2 answers
1k views

How can I calculate the radius of an arc given by a series of points

Given a series of points, I need to assert that the plotted points form an arc (with a certain level of confidence), and I need to approximate the radius of the arc. For example, the following points ...
Yanick Rochon's user avatar
-3 votes
2 answers
138 views

Seeking appropriate design pattern(s) to describe most function-based mathematical problems

I have been looking for a good, general design pattern to implement simple mathematical structures where functions have the following properties: know which parameters they contain, parameters are "...
user32882's user avatar
  • 267
2 votes
1 answer
295 views

Big-O Notation and Calculus [closed]

I was wondering if there are any calculus relationships implicit in Big-O notation. For example, an algorithm linear according to Big-O notation reduces the size of the problem by a constant amount ...
user10478's user avatar
  • 129
2 votes
1 answer
341 views

Generic way to describe data synchronization between systems?

Is there a generic way (useful formalisms) to think about data synchronization between two systems, especially in the case of slightly asymmetric roles (eg, one system contain master data, another one ...
Roman Susi's user avatar
  • 1,793
2 votes
3 answers
690 views

What effects does memory space have on bitwise shifts?

It is true that the bitwise left shift operation (shl) doubles the value of the integer being shifted. However, when constrained to a finite space, such as 8 bits for example, left shift will begin to ...
the_endian's user avatar
  • 1,152
0 votes
1 answer
1k views

Gerstner Wave equation from tessendorf paper, mesh penetrates itself

I have been learning to create water waves in a mesh from a paper commonly known as the Tessendorf paper. Which is quite well known. But those who don't know this is the equations it mentions in the ...
WDUK's user avatar
  • 2,092
0 votes
1 answer
76 views

Best way to encode a queryable number to another unique queryable number? (database outsourcing)

So lets say you want to outsource your database to a third party and be able to query on it on their server but you want to "encode" the salary column of the users on their server, aka hide the real ...
OneAndOnly's user avatar
0 votes
1 answer
311 views

Find two horizontal lines to minimize distance to scattered points

I am having trouble with a coding question that I found practicing for a interview: A scatter graph of points on a page, draw two horizontal lines (these lines are parallel) across the page such that ...
Hyperion's user avatar
2 votes
0 answers
1k views

Division by zero Java [closed]

The behavior of Java is explained in this topic. But, is Infinity useful for something? Float: public class DivisionByZeroFloat{ public static void main(String[] args) { System.out....
Juliano Costa's user avatar
4 votes
4 answers
280 views

How to properly decide what is the appropriate rounding off error for a mathematical function?

In the space of 3D geometry, I need to compute the magnitude of the cross product of two Line3D because I want to check whether these two Lines are "parallel" to each other. Line3D is consisted of 4 ...
Graviton's user avatar
  • 3,995
-2 votes
1 answer
98 views

Where are mathematical equations applied in the application stack [closed]

Say I have a program using Java or C, that will interface with a hardware device and either read streaming data or write it to a database before applying a few complex mathematical equations to this ...
arrydavid's user avatar
  • 101
1 vote
1 answer
956 views

How do I create a comparable checksum of a number sequence?

Sorry if the title is confusing, but here's an example to illustrate what I'm trying to accomplish. I would like to create a 'checksum' or ID grouping of similar number sequences, so that when you ...
green sammich's user avatar
-1 votes
1 answer
1k views

Interdependent variables

Let's say there are two variables a & b, both a & b would have a value between a predefined range. a = x1 to y1 (range) b = x2 to y2 (range) Variable a & b are interdependent, if the ...
Gandalf the White's user avatar
0 votes
1 answer
141 views

How a Proof Assistant Proves ∀ or ∃

Wondering how a proof assistant such as Coq proves forall or exists. For example: Three aspects: If you were to give it a huge set of items like a million, wondering if it would actually iterate ...
Lance Pollard's user avatar
-3 votes
1 answer
83 views

Identify sets differing by one

I have a set of objects with different attributes; e.g. a set of cars with colors, brand etc. I choose subsets by virtue of a specific set of attributes. Now I want to identify pairs of such subsets ...
Peder's user avatar
  • 1
0 votes
1 answer
57 views

Algorithm: Identify same Outlets / Supermarkets

We have a database with stores Outlets / Supermarkets (mainly in germany but other countries are also possible). We store some informations of this outlets / supermarkets like name, street, ...
OPunktSchmidt's user avatar
75 votes
10 answers
30k views

Is it good practice to replace division with multiplication when possible?

Whenever I need division, for example, condition checking, I would like to refactor the expression of division into multiplication, for example: Original version: if(newValue / oldValue >= ...
ocomfd's user avatar
  • 5,722
-3 votes
2 answers
271 views

How to model infinite non-linear combination? [closed]

Let L be an ordered set of positive integers (for example, the set of all primes). Here, #L = infinity, and N is a positive number serving as an upper limit. Goal is to list the following set M: M =...
Error's user avatar
  • 121
0 votes
3 answers
234 views

Use case, design, and how to append to an immutable object in functional programming

This is not (supposed to be) an opinion question, but it is a newbie question, so if there is just a resource I haven't found that I need to read, point me there :) I am in the design stages of a ...
Apollo's user avatar
  • 111
2 votes
2 answers
246 views

Handling behavior of non-finite numbers

Without using big int classes in C++, what's a good way to handle arithmetic on large numbers? For instance, writing a Vector class that deals with dot products and cross products using large ...
user avatar
0 votes
1 answer
990 views

Round robin, balanced home/away, multiple locations with multi-team options

This is my first question on this forum, have tried to exhaust every possible research option I could think of or find. Actually this is the first time I've posted for help with this anywhere, so ...
user277561's user avatar
-3 votes
1 answer
2k views

What's the needed math for building algorithms? [closed]

What's the needed math for building algorithms? Because I was reading a book and I can't understand much. It says I need simple math from high school. I don't want to learn all the math that exist ...
Frank's user avatar
  • 57

1
2 3 4 5 6