Pieces of mathematics

Posted by Monik, 19 February 2017.
Maths

Pieces of mathematics that are relevant for a developer.

Table of contents

Summations

This is called a summation, more specifically arithmetic progression:

i=1 n i = n(n+1)2

because mathematical induction. Important to remember, as this means that the complexity of an algorithm that takes i steps with every iteration from i=0..n has complexity of Θ(n^2) (big theta). This is the case of selection sort. And the generified rule is:

S(n, p) = i n i p = Θ( n p+1 )

for p>=1.

Geometric series have the index of the loop involved in the exponent:

G(n, a) = i=0 n a i = a n+1 - 1 a - 1 = Θ( a n+1 )

for for a>1.

What may be also relevant is this factorial formula:

i=1 n i * i ! = (n+1)!-1

Logarithms

This is what logarithm is:

bx = y <=> log b y = x

Important formulas
eln x = x
blog b y = y
loga(x*y) = loga(x) + loga(y)
ab = eln(a^b) = eb*ln(a)

The last one can be used for computing an fast. We just make a recursive function that will compute the squares or “squares + 1” of the previous result, and that is just O(lg(n)).

log a b = log c b log c a

Harmonic summation is another important formula:

i=1 n 1 i ln(n)

Quadratic Equation

Square roots of quadratic equation:

Trygonometry

Area of a triangle:

Prime numbers

Every positive integer can be decomposed into a product of primes.

Sieve of Eratosthenes is an algorithm to fins all prime numbers up to a given max value: in a sorted list starting from 2 we take each number and count it as prime, and cross out all following numbers that are divisible by this number.

We can also ask for testing whether a number is prime.

Combinatorics

Probability

What is the probability that out of 3 consecutive tries 2 are successful, if each try has probability p of being successful?

Answer: p*p*(1-p).

Conditional probability

But:

For A and B independent (A happening tells me nothing about B happening):

For A and B mutually exclusive (if A happens B cannot happen:

*Only impossible events are both mutually exclusive and independent.


Comments


Comments: