Big Page on Vectors

A vector is a quantity with both direction and magnitude

I go by Vector. It's a mathematical term, represented by an arrow with both  direction and magnitude. Vector! That… | Despicable me, Despicable me gif,  Minions funny
Oh yeah!!!
2d vector
3d vector

Vectors can also be denoted (xi + yj + zk) and the vector variable can be called

The way you use a vector depends on if you are treating that vector as a position vector or a direction vector.

A vector is a position vector if the vector is describing a point relative to the origin. For instance, the vector 2i + 3j on it’s own only contains information about a movement of +2 in the x dimension and +3 in the y dimension. If you go onto say this is a position vector, this number now represents an absolute position on the plane, 2 on the x and 3 on the y (and is essentially a coordinate). If it is not specified that a vector is a position vector, it is not right to link it to the corresponding coordinate on a plane.

A position vector can be denoted where O represents the origin and A is a vector.

Essential vector properties / operations

Magnitude of vector

One of the most important things to know about a vector is it’s length. Use Pythagoras.

3D Pythag!

Find unit vector

Equation for unit vector

The unit vector essentially tells you the fundamental information about spatial direction. 2D spatial directions are numerically equivalent to points on the unit circle and spatial directions in 3D are equivalent to a point on the unit sphere.

Parallel vectors

Vectors are parallel if they are scalar multiples of each other.

Parallel vectors

Vector between two vectors

To get the difference in position between two vectors, do the following:

Go back down the A and along the B!
What is the formula for finding the magnitude of vector difference? - Quora
Visual representation of B->A

Scalar Product

The scalar/dot product of two vectors is the sum of the products of their corresponding components.

a \cdot b= \sum \limits_ {i=1}^n a_i b_i
How to calculate dot product

If the dot product of two vectors equal 0, the two vectors are at 90º to each other.

The Line

Line properties

In 2D, lines are parallel or intersect. To check if lines intersect, check if they are not parallel. To check if lines are parallel, look at the direction vector for both lines, if they are linear multiples of one another, they are parallel.

In 3D, lines can be parallel, they can intersect, and can also be skew. Skew lines are when the lines do not intersect and they are not parallel. To check if lines are parallel, see if the direction vectors are linear multiples of each other. To check if lines intersect, set the lines equal to each other, and rearrange to get two equations with two unknowns. Then plug the values of λ and μ into the z row of the original equation, if this equation is true, the lines intersect. If this z equation is false (ie the LHS and RHS are different), the lines are skew.

Vector equation of a line

The straight line r in vector line notation: λ is a variable marking that the b vector is variable in magnitude, and therefore sets the direction of the line.

a is a position vector whose purpose it is to move the line away from the origin.

Straight line r
The vector OD sets the direction and point A sets the position

Cartesian equation of a line

A line in vector equation form as such:

Essentially 3 different equations

Can be rewritten as:

This uses the aspect of the vector equation of the line secretly being 3 separate equations, and rearranges them to make λ the subject.

Angle between two lines / vectors

To get the angle between two lines, use the following formula.

Make sure to only use the direction vectors in the lines, as they are what define the direction of the line, and therefore the angle between the lines.

Angle between two vectors a and b

If the is negative, the result will be the obtuse angle between the two vectors. So if you want the acute angle, do 180 – θ.

c4 vectors angles - The Student Room
Negative dot product means you are getting the blue angle

The Plane

Vector equation of a plane

The vector equation of a plane looks similar to the vector equation of a line, but has another variable and another direction vector.

Plane Π is made of one position vector and two direction vectors

b and c must not be parallel.

This creates a infinite plane of values, achieved by varying lambda and mu.

Cartesian equation of a plane

The cartesian equation of a plane harnesses the normal vector – the vector that is perpendicular to the plane.

Cartesian equation of the plane

Where

Is the normal vector to the plane.

The scalar product equation of a plane

The scalar product equation of a plane is just like the cartesian equation, but folded up a bit.

The vector with the ns is the normal vector to the plane.

Angle between line and plane

Use the direction vector of the line and the normal vector of the plane, but note that some extra stuff has to happen once you’ve got the angle:

If you have the yellow angle, do 90 – the angle to get the acute angle between the line and the plane (purple).

If you have the blue angle, do the angle – 90 to get the acute angle between the line and the plane.

Intersect line and plane

This is the super easy one. Simply get the x, y and z formulae from the line equation, and plug those expressions into the Cartesian equation of the plane to get a value of λ.

Then plug this value into the line equation to get the position vector of the point of intersection.

Song of the article

Big Page on Matrices

What is a Matrix??

A matrix is a way of showing information efficiently. It is a rectangular array of numbers.

What is the difference between a row matrix and a row vector? What about a  column matrix and column vector? - Quora

Matrices have two dimensions: the number of rows (usually denoted as as m) and the number of columns (denoted as n). The order of a matrix describes it’s size.

Matrix (mathematics) - Wikipedia
n on the columns, m on the rows

Operations on Matrices

Addition and Subtraction

Adding and subtracting matrices is really easy. Just take each element and do the required operation on the corresponding item. YES this does mean both matrices have to be of the exact same order.

Matrix addition & subtraction (article) | Khan Academy
Adding two matrices 😇

Multiplication by a scalar

Multiplying (and dividing) by a scalar is also pretty easy. Simply apply the operation to all items in the matrix and BOOM you’ve got your answer:

Multiplying matrices by scalars (article) | Khan Academy
Multiplying a matrix by a scalar 😝

Matrix Multiplication

But what if we want to multiply two MATRICES together??! The circumstance where this is possible is if the number of columns (n) in the first matrix is exactly equal to the number of ROWS (m) in the second matrix.

When this condition has been met, this is what you do:

  1. Select the first row of the first matrix
  2. Select the first column of the second matrix
  3. Multiply each number in the first list by the corresponding number in the second list, and add them up
  4. Place the sum in the first row, first column of the output matrix.
  5. Repeat the process for all combinations of rows and columns

NOTE: the position of the number outputted by the above in the output matrix is whatever row the first matrix is on (m) as the y, and whatever column the second matrix is on (n) being the x.

More efficient matrix multiplication (fastai PartII-Lesson08) | by  bigablecat | AI³ | Theory, Practice, Business | Medium
Matrix Multiplication 🤯
Matrices: Multiplication 04 - Numbas at mathcentre.ac.uk
Matrix Multiplication GIF

There is no such thing as matrix division.

Matrix multiplication is non-commutative, meaning AB ≠ BA.

Maths

What can a matrix be used for?

Linear Transformations

Matrices are best used to describe linear transformations. That means the map a point onto another point. This can be visualised by stretching and/or rotating a plane or space.

A two by two matrix represents a linear transformation which works on a 2D plane, three by three represents a transformation on 3D space etc…

NOTE: AS THESE TRANFORMATIONS ARE LINEAR, THE ORIGIN ALWAYS MAPS ONTO ITSELF

Visualizing Matrix Transformations | R-bloggers
GIF showing basis vectors being modified, transforming the plane

A vector can be mapped into the transformed version of itself by applying the matrix multiplication as shown:

Translated vector = Transformation Matrix * Original Vector

The new vector is called the image.

Solving Simultaneous Equations

Due to the way matrices are multiplied together, matrices are perfect at solving systems of equations! 😁

Take this one for example:

3 unknowns, 3 equations!

You can separate the coefficients from the variables like so:

Notice that if you do the matrix multiplication, the exact same equations are formed

Then, pre-multiply the inverse of the matrix of coefficients, to get a formula giving the values of x, y and z:

Pop that in your calculator to get the values of x, y and z. How easy was that!

Modelling

Matrices are great at modelling things in real life, such as populations.

Most questions will give you some information revolving around the total quantity of something, and how it changes from one time to another.

To solve, find 3 equations which represents this system, and solve them as simultaneous equations using the matrix method.


Identity Matrix

Matrices that are square have a value called the Identity Matrix. The Identity Matrix essentially acts as “1” in matrix multiplication.

What is an identity matrix? - Quora
Identity matrix for 2×2 and 3×3 matrices

You can recognise the identity matrix by the leading diagonal being 1’s and all other items being 0. This matrix does nothing.

Zero Matrix
Intro to zero matrices (article) | Matrices | Khan Academy
0

Figuring out a matrices’ transformation

To figure out what exactly a matrix is doing to the plane, simply imagine the first column and the second column of the matrix as the new position of the (1,0) and (0,1) basis vectors respectively.

How to figure out what a matrix is doing

Matrix rotation

There is a faster way to check if a matrix is rotating: if you see a matrix with signs in the pattern following (they could be the opposite sign):

It is rotating the plane (this might not be the only thing it’s doing). In the case of the matrix above, it applies a rotation counter clockwise to (x, y) by θ degrees.


The Determinant

The determinant is a property of a transformation vector which represents the ratio of the area (or volume) between the original plane (or space) and the transformed plane (or space). So its how much bigger the area/space gets.

For instance the matrix is an enlargement sf 2 around (0, 0), meaning both basis vectors double. This of course increases the area by 4x as the distances are doubling in two directions.

2 by 2 Determinant

You can calculate the determinant of a 2 by 2 matrix with this formula:

The determinant can also be denoted as |A|, like the modulus function
3 by 3 Determinant

To find the determinant of a 3 by 3 matrix:

  1. Multiply one of the three numbers along the first row of the matrix by the 2 by 2 matrix left when taking out the rows and columns corresponding to that number.
  2. Apply the magic signs!
Magic signs!

3. Add them up.

Determinant of 3x3 Matrix - ChiliMath
Formula to get the determinant of a 3 by 3 matrix

Determinants (article) | Khan Academy
Watch as the determinant changes as the area of the translated plane changes

The determinant of a matrix will go negative when the plane has been “flipped” (watch the gif to visualise what this means)

If a matrices’ determinant is 0, it means all of space has been squashed into a lower dimension

If det(A) = 0 the matrix is SINGULAR (no inverse)

If det(A) c 0 the matrix is NON-SINGULAR

You can’t have an inverse of a singular matrix because there is no way to extract area back out from a line with a linear transformation.

The Inverse of a Matrix

The inverse matrix applies the opposite transformation on the plane, undoing the first transformation:

AKA

A matrix times it’s inverse equals the identity matrix

This reads: apply the transformation of matrix A, then apply the transformation of inverse matrix A equals the matrix that represents no change. In this case, A and A^-1 can be swapped as they just do the opposite of on another.

Inverse of 2 by 2 matrix

Use this formula to get the inverse of a 2 by 2 matrix:

Remember to swap the numbers in the matrix in this magical way! 🧙‍♂️
Inverse of 3 by 3 matrix 🥶

First off, the transpose of a matrix is found by flipping the matrix on it’s diagonal:

Getting the transpose of a matrix

Here’s how to get the inverse of matrix A (any non singular 3 by 3 matrix) by hand

  • Find det(A)
  • Construct a matrix of minors of A, to make a 3 by 3 matrix of 2 by 2 matrices
Matrix of minors, pretty large!
  • Get the determinant of every minor matrix to get a new 3 by 3 matrix!
  • Apply the magic signs!
Magic signs!
It’s getting kinda crazy!
  • Transpose the matrix of cofactors!
  • Multiply by 1/det(A)
The final step!
  • DONE

Consistent or Inconsistent?

  • A matrix is consistent when the corresponding system of equations has at least one solution
  • A matrix is inconsistent when the system of equations has zero solutions

This is the most common case, where there is a single set of x, y and z which satisfies all equations. The determinant here is not 0.

How to figure it out:

A flow chart on how to figure out the configuration of a system of three equations

Invariant points and lines

An invariant point is a point unaffected by a transformation.

An invariant line is when each point on a line is transformed to another point on the same line.

ReflectionsRotationsEnlargement
Invariant
Lines
Mirror line and all lines perpendicular.None, unless the angle = 180°, In which case all
lines through (0, 0).
All lines through (0, 0).
Invariant
Points
All points on mirror line.(0, 0)(0, 0)

To find invariant points:

Set the point (x, y) that has the transformation applied equal to the point (x, y). (So the point is the same after the transformation).

Find the invariant points!

Then, expand to get some equations:

This will either give you the equation of a line – in which case there is an entire line of invariant points – or a single value for x and y, if there is only one invariant point.

To find invariant lines:

First, suppose y = mx + c is an invariant line.

Set the matrix up like this:

y is set in terms of x, therefore the relationship between x and y is a line.

After this expansion, keep in mind that x’ and y’ must be on the line y = mx + c.

Get these two equations
Rearrange to this

Now plug these equations into the y = mx + c formula!

Song of the article

Decision Maths 1 Revision

Sorting Algorithms

Bubble Sort

Numbers are sorted into ascending order by comparing pairs of numbers. If the number on the left is larger than the number on the right, the two numbers are swapped. If the number on the right is larger, everything is kept the same.

C# Sharp exercises: Bubble sort - w3resource

This process is repeated until the list is completely sorted. In the worst case – where the list is in descending order – there must be n (n being the number of items in the list) – 1 passes.

For the number of comparisons each pass: if the algorithm is straight forward, it will be n-1, but the algorithm could be designed to appreciate that after the first pass, the largest number must be in the correct place, so it can automatically skip this out.

Formula for number of comparisons with n being number of items in list

Either way, this means Bubble sort is in Quadratic time: O(n2)

Quick Sort

Quick sort picks a number to be a pivot. It is usually the middle number (the rightmost if there are an even number of items) but it could be any number in the list and there should theoretically be no loss in efficiency. It then iterates through the other numbers, and puts them on the left of the pivot if smaller, right if bigger (order must persist!). Once one iteration is done, a new pivots are picked out of the two sets of numbers either side of the original pivot. The same process is then repeated until all numbers have been the pivot.

The order of quciksort is O(log n) but it seems I don’t need to be able to show it or know it at all.

Graph Theory

A Graph consists of vertices (nodes) and edges (arcs).

A vertex has an order (degree, valency). This is equal to the number of edges that are connected to it.

Network

How to normalize edges weight between 0 and 1 - Mathematics Stack Exchange

A network is a graph where every edge has a weight (numbered)

Connected

A connected graph means every vertex has a path to every other vertex

3. The graph shown is an example of disconnected graph with three... |  Download Scientific Diagram
Disconnected Graph

Simple Graph

A simple graph has no loops and no multiple edges

Simple Graph -- from Wolfram MathWorld

Directed Graph

Directed graph - Wikipedia
Directed graph

A directed graph gives a direction to every edge

Complete Graph (kn)

A graph that contains n vertices where each vertex has an edge between every other vertex. There will be

edges.

Song of the article

IoT Cat Feeder

Planning stages
Buying some bits from BnQ
Chopping time
The basic parts of the box
Did some experiments to see how wide the hole had to be in order to stop the cat food forming a plug and not falling through
Begun gluing
Cutting the angled pieces to direct the food (I didn’t use these in the end)
Assembling the tube with screw and motor using zip ties
Testing the Archimedes screw mechanism for the first time!
Installed a simplified back slope made of a rectangle instead of a triangle using grab adhesive
Installed some legs using extra wood and modified the tube with an open top and two wooden pieces either side to stop bits of food getting jammed.
Installed side slants to direct the food into the hole. Unfortunately the long slant is not at a great enough angle for the food to slide down it. I’ll try to fix this later on.
Setting up the Arduino Nano with L298N Motor Driver inside the empty space in the back
The cats trying it out for the first time!! They were pretty baffled.
Upgrading the electronics to allow the feeder to be phone activatable and to go off automatically every user defined amount of time.
Pretty much done now
A quick demo of how to use the app to control the feeder.

TODO: Decorate the box!

TODO: Coat inside with something glossy to decrease friction between food and wood.

Song of the article