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
0 votes
1 answer
60 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 ...
user avatar
8 votes
7 answers
4k 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 ...
user avatar
0 votes
1 answer
72 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 ...
user avatar
  • 337
2 votes
2 answers
126 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, ...
user avatar
  • 337
4 votes
3 answers
236 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 ...
user avatar
  • 3,319
2 votes
6 answers
598 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 ...
user avatar
  • 3,319
2 votes
2 answers
237 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 ...
user avatar
-2 votes
5 answers
567 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 ...
user avatar
  • 151
7 votes
2 answers
611 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 ...
user avatar
  • 183
1 vote
0 answers
93 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 ...
user avatar
-2 votes
1 answer
290 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 ...
user avatar
0 votes
5 answers
670 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-...
user avatar
  • 151
4 votes
3 answers
638 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 ...
user avatar
  • 167
1 vote
4 answers
640 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 ...
user avatar
  • 1,930
3 votes
1 answer
168 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 ...
user avatar
4 votes
2 answers
264 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 ...
user avatar
-3 votes
1 answer
59 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 ...
user avatar
-5 votes
1 answer
72 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 ...
user avatar
  • 2,412
0 votes
2 answers
134 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 ...
user avatar
  • 2,412
1 vote
2 answers
52 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 ...
user avatar
-1 votes
1 answer
49 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 ...
user avatar
  • 3
2 votes
3 answers
128 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, ...
user avatar
1 vote
1 answer
643 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 ...
user avatar
25 votes
4 answers
5k 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,...
user avatar
7 votes
1 answer
419 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 ...
user avatar
  • 89
4 votes
3 answers
207 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 ...
user avatar
  • 1,953
-4 votes
2 answers
782 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 ...
user avatar
-3 votes
2 answers
106 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 "...
user avatar
  • 213
2 votes
1 answer
231 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 ...
user avatar
  • 129
2 votes
1 answer
199 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 ...
user avatar
  • 1,693
2 votes
3 answers
345 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 ...
user avatar
  • 1,124
0 votes
1 answer
529 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 ...
user avatar
  • 1,953
0 votes
1 answer
69 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 ...
user avatar
0 votes
1 answer
245 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 ...
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....
user avatar
3 votes
4 answers
161 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 ...
user avatar
  • 4,003
-2 votes
1 answer
95 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 ...
user avatar
  • 101
1 vote
1 answer
765 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 ...
user avatar
-1 votes
1 answer
738 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 ...
user avatar
0 votes
1 answer
132 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 ...
user avatar
  • 2,412
-3 votes
1 answer
80 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 ...
user avatar
  • 1
0 votes
1 answer
53 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, ...
user avatar
74 votes
10 answers
23k 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 >= ...
user avatar
  • 5,572
-3 votes
2 answers
268 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 =...
user avatar
  • 121
0 votes
3 answers
170 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 ...
user avatar
  • 111
2 votes
2 answers
228 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
719 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 ...
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 ...
user avatar
  • 57
-3 votes
1 answer
380 views

I loved developing a 2D game(C++ SDL), but i am not good at maths/physics [closed]

I developed 2 games in C++ using SDL. Without using any wrappers. I literally loved and enjoyed every part of the journey. Complex algorithms, how 2D works, rendering, audio, input etc. But i am not ...
user avatar
-6 votes
1 answer
84 views

Set of items closest to the mean? [closed]

Given a set of N objects with assigned weights, how would we find the set of K objects that is closest to the average? The average being sum(weights) / N. Also, how could we compute the next set ...
user avatar
  • 89

1
2 3 4 5 6