discrete-mathematics

Is there an online archive for various math formulas?

What I'm looking for are archives of math formulas organized by topic or purpose etc. Basically an online library of math functions. For instance, I'm currently working on a project where I have a range from 0 to 2^32 and I need a formula to divide this range consecutively from 1 to n so that for each step, every 1 to n accounts for a c...

Combinitorics Counting Puzzle: Roll 20, 8-sided dice, what is the probability of getting at least 5 dice of the same value

Assume a game in which one rolls 20, 8-sided die, for a total number of 8^20 possible outcomes. To calculate the probability of a particular event occurring, we divide the number of ways that event can occur by 8^20. One can calculate the number of ways to get exactly 5 dice of the value 3. (20 choose 5) gives us the number of orders o...

Find the "largest" dense sub matrix in a large sparse matrix

Given a large sparse matrix (say 10k+ by 1M+) I need to find a subset, not necessarily continuous, of the rows and columns that form a dense matrix (all non-zero elements). I want this sub matrix to be as large as possible (not the largest sum, but the largest number of elements) within some aspect ratio constraints. Are there any known...

Code-golf: generate pascal's triangle

Generate a list of lists (or print, I don't mind) a Pascal's Triangle of size N with the least lines of code possible! Here goes my attempt (118 characters in python 2.6 using a trick): c,z,k=locals,[0],'_[1]' p=lambda n:[len(c()[k])and map(sum,zip(z+c()[k][-1],c()[k][-1]+z))or[1]for _ in range(n)] Explanation: the first element of...

Paths in complete graph

I have a friend that needs to compute the following: In the complete graph Kn (k<=13), there are k*(k-1)/2 edges. Each edge can be directed in 2 ways, hence 2^[(k*(k-1))/2] different cases. She needs to compute P[A !-> B && C !-> D] - P[A !-> B]*P[C !-> D] X !-> Y means "there is no path from X to Y", and P[ ] is the probability. So ...

Why is squaring a number faster than multiplying two random numbers?

Multiplying two binary numbers takes n^2 time, yet squaring a number can be done more efficiently somehow. (with n being the number of bits) How could that be? Or is it not possible? This is insanity! ...

Uses of Ackermann function ?

In our discrete mathematics course in my university, the teacher shows his students the Ackermann function and assign the student to develop the function on paper. Beside being a benchmark for recursion optimisation, does the Ackermann function has any real uses ? ...

Graph Theory Question

This is a two part question. In a reunion of 20 people, there are 48 pairs of people that know each other. a) Justify why there is, at least, one person who knows, at most, other 4 persons. b) Suppose there is a single person who knows at most other 4 persons. How many people does that person knows exactly? I'm unsure about my answe...

Fastest modular exponentiation in JavaScript

My problem is to compute (g^x) mod p quickly in JavaScript, where ^ is exponentiation, mod is the modulo operation. All inputs are nonnegative integers, x has about 256 bits, and p is a prime number of 2048 bits, and g may have up to 2048 bits. Most of the software I've found that can do this in JavaScript seems to use the JavaScript Bi...

"Concrete Mathematics" companion text? (Knuth light IOW)

I'm interested in learning more of the math behind computer science, partly so I can dip into Knuth's TAOCP without my head spinning too much. I've tried going through Concrete Mathematics but it's a little too much for me unfortunately. Are there books out there below this one but well above Math for Dummies? I own discrete math book...

How can I learn higher-level programming-related math without much formal training?

I haven't taken any math classes above basic college calculus. However, in the course of my programming work, I've picked up a lot of math and comp sci from blogs and reading, and I genuinely believe I have a decent mathematical mind. I enjoy and have success doing Project Euler, for example. I want to dive in and really start learning ...

What number in binary can only be represented as an approximation?

In decimal (base 10), 1/3 can only be approximated to 0.33333 repeating. What number is the equivalent in binary that can only be represented as an approximation? ...

multiplicative inverse?!?!?

Hi, I know that an affine cipher substitutes BD with SG. I need to find the encryption formula, in the form y = a x + b, where a and b are coefficients. From the information above I end up having to equations: a+b=18 and 3a+b=6 So I am working like this: a+b=18 and 3a + b = 6-> 3a+18-a=6->  2a= 6-18 -> 2a=14 (cuz it is mod 26) b=18-a ...

Looking for examples where knowledge of discrete mathematics is helpful

Inspired after watching Michael Feather's SCNA talk "Self-Education and the Craftsman", I am interested to hear about practical examples in software development where discrete mathematics have proved helpful. ...

RSA cryptosystem

Hi i am trying to set up an RSA cryptosystem i have all the values except d selected prime numbers: p=1889, q=2003 n=3783667 phi=3779776 e= 61 i got stuck finding d could anyone help me to figure it out? Setting up an RSA cryptosystem • Two large distinct prime numbers p and q are selected, and n = pq and Φ(n) = (p − 1)(q − 1) are cal...

Project Euler: please help me understand #106

I have solved #103 and #105, but I have a hard time understanding #106, specifically where does the number 25 come from? If we are talking about two disjoint subsets with equal number of elements, then 1-elem vs. 1-elem: there are 4 x 3 = 12 comparisons 2 vs. 2: C(4, 2) = 6 comparisons If we include disjoint subsets with non-equal nu...

Which topic in Discrete Mathematics is considered as a prerequisite for data structures course?

Hello, I want to read a book on Data Structures and Algorithms, but i would like to know if there is any specific topic in Discrete Mathematics considered very important as a prerequisite in order to understand the materials presented in Data Structure Book. Thank you in advance for your help P.S i am self-thought programmer, i didn't...

Exhaustive website verifier

I have this grand idea to basically employ some brute force attack to test/verify that my web application doesn't crash. Don't get me started on unit testing, and IoC stuff, this is something else entirely. What I'm doing, and what I'm asking for help with is to create an intelligent exhaustive search, that explore parts of the program...

Using Maxima's linsolve( ) -- problem passing arrays to linsolve( )

Hello, I'm trying to use linsolve( ) from within a subroutine in order to code up a solution algorithm that is independent of the dimension of the problem. The desire is to dynamically allocate the equation and variable arrays within the subroutine itself, pass these to linsolve( ) and hopefully get back the results. /* SUBROUTINE IDE...

count of distinct acyclic paths from A[a,b] to A[c,d]?

I'm writing a sokoban solver for fun and practice, it uses a simple algorithm (something like BFS with a bit of difference). now i want to estimate its running time ( O and omega). but need to know how to calculate count of acyclic paths from a vertex to another in a network. actually I want an expression that calculates count of valid ...