Maths facts

download Maths facts

If you can't read please download the document

description

Some maths facts in Markdown

Transcript of Maths facts

Maths Facts# Groups- Orbit counting lemma: "the number of orbits of `G` on `X` is average number of elmts in `X` fixed by a point in `G`. That is: |X / G| = 1/|G| * Sum(X^g for g in G) where `X^g` denotes the number of elmts in `X` fixed by `g`.- Exactly `n - c(pi)` transpositions (swaps) are needed to transform a permutation `pi` into the id permutation, where `c(pi)` is the number of cycles in `pi`'s disjoint cycle decomposition. This is biinvariant: transforming a permutation `pi` into a permutation sigma requires `n - c(sigma^-1 . pi)` transpositions.- The (unsigned) Stirling numbers of the first kind `s(n, k)` give the number of permutations of `n` elements with `k` exactly disjoint cycles. Recurrence relation: s(0, 0) = 1, s(n, 0) = s(0, n) = 0 s(n + 1, k) = n * s(n, k) + (n, k - 1)# Rings- Eisenstein's criterion: `Q = a_n x^n + ... + a_1 x + a_0` with all as integers divide `Q` through by `gcd(a_n, ..., a_0)` to get `Q'` If there exists a prime `p` s.t.: 1. `p` divides `a_i'` for `i != n` 2. `p` does not divide `a_n'` 3. `p^2` does not divide `a_0'` then `Q` is irreducible in both `Q` and `Z`- For poly Q over a field F, Q deg 1 => Q irred and for Q deg 2 or 3, Q has no roots in F Q irred- `Q / (x - c) = Q(c)`, for any poly `Q` over a field- (x - r) divides Q r is a root of Q- If `Q` is as in EC above, and `c/d` is a rational root of `Q`, then `c` divides `a_0` and `d` divides `a_n`- Cohn's irred criterion: If `p = a_n x^n + ... + a_1 x + a_0` is a poly with each `a_i` and integer and `0 p irred over Z` (becomes digits when `b = 10`) - Binomial coeffs - `(n, r) = n! / (r! * (n - r)!)` - Recurrence on r: `(0, 0) = 1`, `(0, r) = 0` for `r != 0`, `(n, r) = (n - 1, r) + (n - 1, r - 1)` for `r > 0` - `(n, r) = (n, n - r)` - `Sum( (n, k) for k = 0, 1, .., n ) = 2^n` - `Sum( (n, k) for k odd ) = Sum( (n, k) for k even )`# Catalan numbers- Catalan numbers are a set of numbers, generated by the following function: `C(n) = (2n)!/((n+1)!(n!))`. You can generate them quite quickly using this function (and some long doubles).- The nth Catalan number, `C(n)` counts: 1. the number of binary trees with `n` vertices 2. the number of ordered trees with `n+1` vertcies 3. the number of full binary trees with `2n+1` vertices 5. the number of ways `2n` ballots can be counted in order with `n` positive, and `n` negative, so that the running sum is never negative (ie. if you had a ballot of 20 votes, with 10 of them positive and 10 of them negative, the number of orderings of the ballots you could give s.t. the running sum was never negative is `C(10)`, given that a positive vote has the same value as a negative one 7. the number of monotone functions `f:[n] -> [n]` which satisfy `f(i) p | a or p | b` for `p` prime- More general: `if n | ab and n coprime to a, then n | b`- Cayley's formula: the number of trees on `n` labelled vertices is `n^{n-2}`- Partition function p: `p(n)` gives the number of ways of writing `n` as a sum of positive integers. We have `p(n) = Sum( (-1)^k p(n - g_k) for k < 0 or k > 0 )`, where `g_k = k(3k-1)/2` is the kth generalised pentagonal number, and `p(l) = 0` for `l < 0`.- Bell numbers: the number of partitions of a set of `n` elements. Recurrence: B_0 = 1, B_{n+1} = Sum( (n, k) * B_k for k from 0 to n )- Fibonnaci matrix formula: [F_{n+1} F_n; F_n F_{n-1}] = [1 1; 1 0]^n# Quadratic formula- `ax^2 + bx + c = 0` has solution `x = ( -b +- sqrt(b^2 - 4ac) ) / (2a)`# Cubic formula- `ax^3 + bx^2 + cx + d = 0` has solution `x = (q + s)^(1/3) + (q - s)^(1/3) + p` where p = -b / (3a) q = p^3 + (bc - 3ad) / (6a^2) r = c / (3a) s = (q^2 + (r - p^2)^3)^(1/2)# Geometric formulas- For a triangle with angles `A`, `B`, `C` and sides `a`, `b`, `c` opposite the angle of the same letter - Cosine rule: `a^2 = b^2 + c^2 - 2bc cos(A)` - Sine rule: `sin(A) / a = sin(B) / b = sin(C) / c` (which can give two answers!) - Area: `sqrt( s(s-a)(s-b)(s-c) )` where `s = (a + b + c) / 2`- Area of trapezoid with top and bottom side length of `b_1`, `b_2` and height (projected onto `y` axis) of `h`: 1/2 h (b_1 + b_2)- Pyramid / cone volume: `(1/3) b h`, where `b` is area of base and `h` is height (projected onto `z` axis)- Ellipsoid volume: `(4/3) pi r_1 r_2 r_3`- Great circle distance: /*Given the latitude and longitude of two points in degrees, calculates the distance over the sphere between them. Latitude is given in the range [99, 90] degrees, and Longitude is given in the range [180, 180] degrees. */ double greatcircle (double lat1, double long1, double lat2, double long2) { double radius = 1.0; double a = pi*(lat1/180.0); double b = pi*(lat2/180.0); double c = pi*((long2-long1)/180.0); return radius*acos(sin(a)*sin(b) + cos(a)*cos(b)*cos(c)); }- Equation of a circle through 3 points: Given three points `P1 = (x1, y1)`, `P2 = (x2, y2)` and `P3 = (x3, y3)`, we make lines `a` and `b` through `P1` and `P2`, and `P2` and `P3` (resp). Choose the ordering of the points so that no vertical line is generated. The equations of the two lines are ya = ma (x - x1) + y1 and yb = mb(x - x2) + y2 where `ma` and `mb` are the slopes of the lines, given by ma = (y2 - y1) / (x2 - x1) and mb = (y3 - y2) / (x3 - x2) The equations of the lines perpendicular to `a` and `b` passing through the midpoints of `P1P2` and `P2P3` are ya2 = -(1 / ma) (x - (x1 + x2)/2) + (y1 + y2)/2 and yb2 = -(1 / mb) (x - (x2 + x3)/2) + (y2 + y3)/2 These two lines intersect at the centre. Solving for `x` gives x = (ma mb (y1 - y3) + mb (x1 + x2) - ma (x2 + x3)) / (2 (mb - ma)) and `y` can be found by substituting into the equation of one of the perpendicular lines above. Radius is the distance from `P1` to the centre. NOTE: `ma - mb` is only `0` when the lines are parallel, in which case there is no circle that passes through all three points. - Equation of a circle through 2 points, given a radius: Given two points `P1 = (x1, y1)` and `P2 = (x2, y2)` and a radius `R`: double mid_x = (x1 + x2) / 2;double mid_y = (y1 + y2) / 2;double dx = (x1 - x2) / 2;double dy = (y1 - y2) / 2;double dist = sqrt(dx * dx + dy * dy);double p_dist = sqrt(R * R - dist * dist);if(dir) { m_dx = dy * p_dist / dist; m_dy = -dx * p_pist / dist;}else { m_dx = -dy * p_dist / dist; m_dy = dx * p_dist / dist;}// coordinate of centrereturn {mid_x + m_dx, mid_y + m_dy};