## Maths for Apps lecture 1

These notes are for Dr Daniel Richardson’s course “Mathematics for Applications I” at the University of Bath.The required text book is “Linear Algebra with Applications” by G. Williams, published by Jones and Bartlett

### Linear Equations

An equation such as:

x + 3y = 9

is called a linear equation.

The solution is the collection of pairs of real numbers x and y for which that equation is true. The graph of the solution is a straight line on the xy plane.

Consider a system of two equations in x and y, for example:

x + 3y = 9

-2x + y = -4

A pair (x, y) satisfying *both* equations is a solution of the system. Typically, there will be a single solution where the two graphs intersect.

For systems of 2 equations in 2 unknowns there are three possibilities:

- The two lines intersect, giving one solution
- The two lines are parallel, giving no solution
- The two lines are identical, giving many solutions

So, for two equations with two unknowns you can not have any result that is not covered by the above scenarios.

#### 3 dimensional case

The solution of one equation, 3 unknowns:

ax + by + cz = d

a, b, c and d are constants

The solution is a plane in xyz space.

Now try a system of 3 equations in 3 unknowns:

a_{11}x + a_{12}y + a_{13}z = b_{1}

a_{21}x + a_{22}y + a_{23}z = b_{2}

a_{31}x + a_{32}y + a_{33}z = b_{3}

This typically has a single unique solution, as there are 3 intersecting planes in xyz space. This can be imagined by visualising two intersecting planes (which intersect along a line) and then visualising the third plane intersecting that line at a point. Again we can have one solution, no solutions (for parallel planes) or many solutions. The many solutions case has several possibilities, including:

- Two planes intersect to form a line, the other plane is parallel to and intersects that line
- All planes are the same

This one, many or none model works no matter how many equations or unknowns are involved.

In general, we will study systems of n linear equations in m unknowns using the following notation:

a_{11}x_{1} + a_{12}x_{2} + ... + a_{1m}x_{m} = b_{1}

.

.

.

a_{n1}x_{1} + a_{n2}x_{2} + ... + a_{nm}x_{m} = b_{n}

So a_{ij} is the coefficient of x_{j} in equation i.

We will represent such systems using matrices.

### Matrices

A matrix us a rectangular array of numbers. The numbers in the array are caled elements.

#### Example:

(columns) C1 C2 C3 [2 1 5] R1 (rows) A = [3 4 6] R2

A[i, j] = the element in row i, column j e.g A[2, 3] = 6 in the above example.

A submatrix is a matrix obtained by delting some rows and/or columns from a matrix.

#### Terminology:

- Square Matrix
- A matrix with the same number of rows and columns
- Identity Matrix
Square matrix with 1s on the diagonal (top-left to bottom-right) and 0s elsewhere, i.e:

{ 1 if i == j I[i, j] = { 0 if i != j

- Row matrix
- One row, [a
_{1}... a_{m}] - Column matrix:
- One column

We can use matrices to describe systems of equations:

3x + 2y + z = 1 [ 3 2 1 ] x - y + z = 0 has matrix of coefficients [ 1 -1 1 ] 2x + y - z = 3 [ 2 1 -1 ]

This can be extended to create the augmented matrix for the system, which adds an extra column showing the equation results:

[ 3 2 1 1 ] [ 1 -1 1 0 ] [ 2 1 -1 3 ]

Elementary transformations are used to change a system of equations in to another simpler system with the same solution. These correspond to *elementary row operations* on matrices.

The elementary row operations are things you can do to the augmented matrix that will not change the solution. They are:

- Interchange two rows (obviously has no effect)
- Multiply a row by a
*non-zero*constant - Subtract a multiple of one row from another

The third ELO will alter the goemetry of the system (as visualised in xyz space) but it will not change the solution of the system.

#### Notation

A => B means A can be changed to B by one ELO.

A =>* B means A can be changed to B by a sequence of ELOs.

A =>* B is reversible, as each of the ELOs can be easily reversed.

## More recent articles

- Weeknotes: Parquet in Datasette Lite, various talks, more LLM hacking - 4th June 2023
- It's infuriatingly hard to understand how closed models train on their input - 4th June 2023
- ChatGPT should include inline tips - 30th May 2023
- Lawyer cites fake cases invented by ChatGPT, judge is not amused - 27th May 2023
- llm, ttok and strip-tags - CLI tools for working with ChatGPT and other LLMs - 18th May 2023
- Delimiters won't save you from prompt injection - 11th May 2023
- Weeknotes: sqlite-utils 3.31, download-esm, Python in a sandbox - 10th May 2023
- Leaked Google document: "We Have No Moat, And Neither Does OpenAI" - 4th May 2023
- Midjourney 5.1 - 4th May 2023
- Prompt injection explained, with video, slides, and a transcript - 2nd May 2023