# Learn Calculus from Scratch in 15 Days

## Intro

Here we learn some single/multivariable calculus, from the perspective of modeling with it. The first iteration is a casual survey of the material, programming some math if you want using R or any language you'd like. The second iteration is working through the free problem book *Advanced Problems in Mathematics: Preparing for University* written to help students prepare for STEP university entrance exams. The idea is to be more economic with out time, and actively learn with a challenging problem per day instead of doing high amounts of repetitive typical textbook end of chapter problems that are all cherry picked nice examples that don't really teach you calculus, and you will end up forgetting what you learned a month later. Instead you will figure it all out yourself and always remember how you did it, no flash cards, no spaced reptition, no other tricks needed.

You could alternatively try learning this with a subject where you will actually use this material, such as machine learning or graphics.

## Materials we will use

Every book you can think of is free from library genesis including the book we are doing but I recommend to buy the books if you can to keep as future reference since technology tends to vanish after a few years while a book remains a book hundreds of years later.

We will do:

## Basic arithmetic

Even if you remember highschool this is worth watching because he writes proofs for all these objects and their arithmetic

### Laws of arithmetic

NJ Wildberger has unique geometric focused lectures

- Arithmetic w/Numbers by Prof Wildberger (10 mins)
- Laws of Arithmetic (9.3 mins)
- Why the associative, commutative and distributive laws are true

- Subtraction & Division (10 mins)
- Write down the laws of division somewhere you will see it repeatedly in later courses

- Hindu-Arabic Number System (8 mins)
- The origins of our encoded number system

- Arithmetic w/the Hindu-Arabic System (10 mins)
- How arithmetic by hand works in our base 10 system

- Division (10 mins)
- How long division works is included

- Fractions (6 mins)
- Arithmetic w/Fractions (9 mins)
- We see what a proof is in this video. The prime or tick ' notation like (b'd') means a different variable from (bd).

- Laws of Arithmetic w/Fractions (6 mins)
- He proves the distributive law for fractions why p(q+r) = pq + pr

- Integers (9 mins)
- A new number object constructed from the naturals

- Rational Numbers (9 mins)
- Visualizing the Rationals (9 mins)
- A new number object constructed from integers. The first part of the second video shows you visually why 6/4 = 9/6 = -3/-2 because they are all on the same line.

### Summation/series notation

Discrete summation notation and arithmetic/geometric series, this is optional you can watch it later when summation comes up. There are slightly different properties for 'infinite convergent series' we'll learn those later too.

- (YouTube) Summation & Sums of Powers

Note use of brackets:

- \(\sum_{i=1}^n\) i + 1 = (1 + 2 + 3..) +1
- \(\sum_{i=1}^n\) (i + 1) = (2 + 3 + 4..)

The summation rules ~@10:30, expand the sum/remove the sigma notation and the rules make sense

- \(\sum_{i=1}^{3}ca_i\) = c1 + c2 + c3
- c\(\sum_{i=1}^{3}a_i\) = c1 + c2 + c3
- c(1 + 2 + 3) = c1 + c2 + c3

Write your own examples for the constant difference rule of an arithmetic sequence:

- Sequence a
_{3}= 10_{1}, 20_{2}, 30_{3} - Example index a
_{1}= 10, a_{2}= 20 .. - d = (20 - 10) = (30 - 20) or d = 10
- To find a
_{4}:- a
_{4}= a_{1}+ d(k - 1) - a
_{4}= 10 + 10(4 - 1) - a
_{4}= 40

- a

Do the same for arithmetic series:

- \(\sum_{k = 1}^n (a_1 + d(k - 1))\)
- n = 4: (a
_{1}+ d(0)) + (a_{1}+ d(1)) + (a_{1}+ d(2)) + (a_{1}+ d(3)) - n = 4: 4a
_{1}+ d(0 + 1 + 2 + 3) - n = 5: 5a
_{1}+ 10d - n = 6: 6a
_{1}+ 15d - n = 7: 7a
_{1}+ 21d - na
_{1}+ d(n^{2}- n)/2- 5a
_{1}+ d(20/2) = 5a_{1}+ 10d

- 5a

### Trigonometry

Try the Brown University trig bootcamp in summary there are 3 triangles who's measurements you should know, you scale them down to the unit circle size, and then use them to figure out points on the unit circle ie: trigonometry. The same page includes a full solution video to the psets. I've already done this here in detail.

**Pi**
There are many tutorials about pi appearing in geometric series here or if you want a interesting pi lecture where Wildberger made his own recursive formula for pi/16 to generate successive digits watch this if you're curious.

### How to get peer help

Write a question to math stack exchange. Often you will end up figuring it out yourself because the process of posting requires you to precisely write down your problem or they will delete it for being too vague. This style of learning has a name: inquiry-based learning.

## Begin here: Calculus overview

The essence of calculus is a 17m overview with visualizations to intuitively explain how calculus works like the area of a circle is determined by an approximation of summing up tiny values. You may only need this video for the entire book it's highly recommended.

The language of calculus is a an optional extra 30m overview of calculus with Mandarin subtitles written for foreign students in the Australian university system. Wildberger goes through the physics interpretation like velocity, acceleration, etc. He shows how one function can tell you how another is changing by taking it's derivative or by integration, how they are inverse operations.

## Day 1 Functions

Reading Chapter 1.1 of *Mathematical Modeling and Applied Calculus*. Skim this chapter it probably contains things you don't remember. You can always jump to the end of chapter exercises and try enough of them to justify skipping this chapter but this is a different book than most math texts and often has important things to point out that we will come across in later chapters.

In case you forgot highschool and the Cartesian plane, the inputs are the horizontal line and outputs are the points on the veritcal axis. All this does is conveniently represent an input/output relationship with a visualization of displacements.

We are also introduced to our first math data structure, a tuple or an ordered pair of values enclosed in brackets like (1, 2). This is similar to the idea of a list in programming, somebody needed a way to represent values in math in which the order matters and duplicates could be possible like (3, 3), so invented a tuple structure.

Page 8: Question 2: obviously (c) and (b) have numerous y outputs for a single x input. The definition on the same page claims 'every function in this book is contained in the real numbers' which you can read about in the math workshop if you're interested. Rationals, integers and natural numbers are all contained in the real numbers but complex numbers or whatever other number object abstractions aren't.

Example 4(c), they throw in set theory notation (union) without defining it. If you're interested watch a lecture on sets and functions. They also use interval notation without defining it which you can search for on YouTube yourself.

Question 4: Identify the domain of each function. (a) clearly can be anything, (b) can be any negative number, since 4 - (-4) is 8, and 0, 1, 2, 3 to avoid being a negative square root, so (-inf, 4) if we are using interval bracket notation to exclude 4. (c) every single input maps to the same output, so it's domain is the entire 'real numbers'.

Example 5 is much easier if you include brackets f(x) = \((3)\sqrt{x} - 5\) now you know exactly what to do, take the square root of x and multiply it by 3 and subtract 5. Anytime you see math notation jumbled together like this it means multiplication but brackets are never included for some reason.

### RStudio

Reminder we are just using RStudio as a glorified calculator, you don't need to know how to program and can easily figure this out yourself. The *working in R studio* aside you can do this online instead of having to install anything locally if all you have is a phone, meaning work in your browser if you want. The instructions are in the appendix, make a throwaway gmail account, open new project on r studio, first thing you type:

install.packages(c("MMAC", "mosaic", "mosaicCalc", "manipulate"))

The 'c()' is a "vector" meaning multiple inputs to the install.packages() command. This command is actually install.packages(c) where c is filled with entries. Then you have to include all these libraries as written in require statements in the aside on page 12:

require(MMAC) require(mosaic) require(mosaicCalc) require(manipulate)

Which means if you're using the console, where you type in something and it evaluates each line, then you have to paste in those require() statements to let the program know where to look to use those built-in functions like 'mosaic'. These libraries 'MMAC, mosaic' etc are mainly data sets the book uses in later chapters we will import and then model.

I rewrote *Example 7(d)* to make it more clear:

abs( (2^3 / 4^5) - (9^8 / 6^7) )

I'm not sure why they use (2^{3})/(4^{5}) style brackets but whatever, either works. This command is actually abs(thing) where thing = ((2^{3} / 4^{5}) - (9^{8} / 6^{7})) and now you are getting the gist of programming. I also rewrote the aside on page 13 from f=makeFun(8*x+4~x) to the following to make it more clear, translated this means make f a function, where the body is 8*x+4 and the parameter for f is x.

> f = makeFun( ((8 * x) + 4) ~x) > f(3) [1] 28

And I rewrote the plotFun example, translated this means plot function ((-4 * x) + 8) where the input is x, and limit the visual range to (-5,5)

plotFun( ((-4 * x) +8)~x,xlim=range(-5,5) )

**Question 9** Graph a line with a specific domain in RStudio:

> line = makeFun(((-3.546 * x) - 9.128)~x) > plotFun(line(x)~x, xlim=range(-15,15)) Try experimenting with syntax This works too because we already declared line a function with (x) input Translated: plotFun(function, display-options) > plotFun(line, xlim=range(-15,15))

### Other languages

You can do this entire book in Pyret as well if you've already done the software workshop, or read a few chapters from this, using https://code.pyret.org/ web page to write and run code. You can use built-in libraries like num-abs() or rewrite everything yourself. Here's rewriting some of the book's R examples and you can plot function graphs in Pyret too or use Desmos.

## Day 2 Exercises

Trying some of the chapter 1.1 exercises. The only non-functions I see in Ex 7-14 are 10, 13 and 14 because the same input has different outputs (3.14 is not the same object that pi is). All of these you can answer in your head in a couple of seconds.

Ex 34 can be rewritten \(\sqrt{x}\) + \((1 + x)^{\frac{1}{4}}\) search for rational exponent rules. We can't have a negative square root so you have take into account \(\sqrt{x}\) meaning the domain is the entire positive real numbers and zero.

Try changing all these exercises to an equivalent form from the Wildberger basic arithmetic lectures in the beginning of this workshop. For example Ex 37 can be rewritten \(\frac{\pi}{x^2 - 9} \cdot \frac{x}{x}\) and now it's obvious what to cancel to simplify this problem to a domain that avoids x^{2} - 9 being 0.

Ex 35 we only care that the denominator is not 0, since a/b + c/d = ad/bd + cb/bd then the denominator is 4x^{2} + 20x or 4x(x + 5) and x can't be -5, or else we get 4x(0) which is 0 or -20(-5 + 5) which is 100 - 100 or 0.

I like exercises 91 to 100 where you have to in your own words explain all the topics the chapter presented. This is known as the Feynman method where you attempt to explain concepts to an invisible audience in the most simplest terms anybody can understand, and if you find yourself stumbling then you go back and reread those concepts, or practice some exercises until you can effortlessly explain 91 through 100. When you explain to yourself, remove any words like conjecture or even data. Imagine somebody is sitting in front of you asking you to define every word you use, and wants to know exactly what data means (tip: they often will do this in those annoying software developer interviews). It took me about an hour to do a random sampling of the 100 exercises for Chapter 1 so congrats, you're done for today.

## Day 3 Multivariable functions

There are visualizations for chapter 1.2:

- Multivariable functions (6m)
- Points in 3D (6:30) this introduces vectors
- 3D graphs (7m)
- Interpreting graphs w/slices (5:30) uses basic trig we already know
- Contour plots (5:30) this is in the book

Easy chapter you can skim assuming you watched the above YouTube videos, here f(x,y) returns a z-axis point. Example 9, where they 'simplify using properties of exponents' they also break that fraction up to an equivalent form, just like \(\frac{5}{7d}\) is equivalent to 5/7 \(\cdot\) 1/d.

- L = \((\frac{C}{1.01})^{4/3} \cdot (\frac{1}{K^{1/4}})^{4/3}\)
- L = \((\frac{\sqrt[3]{c^4}}{\sqrt[3]{1.01^4}}) \cdot (\frac{1}{k^{1/3}})\)
- if C = 5: \((\sqrt[3]{(5 \div 1.01)^4})\) or ~8.44

### 1.2 Exercises

Nothing here that wasn't already covered in the contour plot video, like Ex 57-62 matching 3D graphs to their contour plots. I did another sampling of exercises again not all 90+.

### 1.3 Linear functions

This chapter is a review of linear functions you probably already know from highschool, *Parameters of Linear Functions* is interesting showing shifts and the section on Monotonicity which will come up again. Their definition of monotonicity has no concrete examples, but if (a, b) is an interval, then c and d are two numbers within that interval, and if c < d then f(c) < f(d) means the function is increasing. ie interval (1, 10) for f(x) = x + 1 and f(5) < f(6) ergo this is an increasing function.

Summary: the parameters m and b in y = mx + b

- b is a shift on the y axis up or down
- m is the slope of the line either positive or negative

## Day 4 Exponential functions

Before you read this chapter watch this tutorial about the constant e why it's often used to model something who's growth is itself, especially the end of the video where he shows how since all a^{k} functions behave the same as e, we just end up modeling with e and some parameter(s). We haven't learned the chain rule or derivatives really yet except the beginning crash course vids so you can skip those if you want and still be able to understand most of the tutorial.

Parameters for C\(e^{kx}\) or C\(e^{k(x-h)}\)

- C is the y-intercept (shift along y-axis)
- k affects the steepness (slope)
- x is the function input
- h is a horizontal shift on the x-axis
- never crosses the x-axis as y is never equal to zero

There must be errata for Example 6, Figure 12. If f(1) = e^{k1} if k is negative you get y = 0.367 which clearly is graph(b) going down towards x-axis, because e^{-kx} results in y = 1/e^{kx} meaning y gets smaller and smaller. If you input x = -1, with negative k you get graph(b) again. Skim rest of chapter, like the exponent rules if you forgot them. You don't have to memorize the formulas for halving or doubling time since you can always come back here later and look them up.

### Statistics example of e^{x} parameters

Look up 'bell curve' or 'normal distribution'. A picture is here. The formula is:

\(f(x) = \frac{1}{\sigma\sqrt{2\pi}} \exp\left( -\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^{\!2}\,\right)\)

or equivalent e^{x} notation:

\(f(x) = \frac{1}{\sigma\sqrt{2\pi}}e^{-\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^2}\)

C = \(\frac{1}{\sigma\sqrt{2\pi}}\), k = -1/2, and x is being shifted by h = \(\mu\)

Type this into desmos and move the slider around. Notice parameter h, (here it's mu or \(\mu\)), the horizontal shift, determines the middle of the bell curve, in other words the mean. Parameter C, the y-intercept moves up and down the y-axis as you change it. Parameter k, when h is negative, k is positive, since -1/2 * -2 is 1, so all x inputs that are negative are concave up or climbing, and all positive x inputs are negative concaving down to give the bell curve. Everything else like squaring the inputs, dividing by C (here the standard deviation), is finessing of the data to construct that model you can play around with too in desmos to see how it works.

### 1.5 Inverse functions

This is the setup for understanding log(). Can quickly skim this chapter: horizontal line test, montononic functions have inverses, find the inverse by inputting the y output and getting original x input, etc. I don't really get what the chapter refers to as 'book keeping convention of change of variables', example 9 if you want an inverse function to y = 4x - 7 then x = 0.25y + 1.75 is what you want instead of y = 0.25x + 1.75 because then you are solving for x all over again if 2 = 0.25x + 1.75 instead of x = 0.25(2) + 1.75, and the whole point was to reverse y and get the original f(x) inputs. Maybe this is explained in future chapters.

Exercises 81 - 94 you can also type into desmos.com for example Ex 90.

## Day 5 Logarithm fundamentals

To make the reading of chapter 1.6 faster there is a great workshop here that starts ~14m in, as you watch it and he asks questions pause and input your own examples. The workshop isn't the full 1:32:55 you can skip the time waiting for students to answer quizzes or the Q&A. Since this is an hour or so of work you're done for today.

## Day 6 Logarithmic functions

Chapter 1.6 Logarithmic functions.

Parameters of logarithms.

- y = C(ln(x - h)) + v
- v is a vertical shift
- h is the horizontal shift
- C is the magnitude/rate of increase

There's some easy examples substituting log rules for each other, these come up all the time in solving recurrence relations in algorithm/discrete math courses.

Let's try question 5: find the equation of the exponential function passing through points (0,-4) and (3,-24). Stare at the laws of logarithms and reduce/substitute:

- y = Ce
^{kx}- -24 = -4e
^{3k} - 6 = e
^{3k} - ln(6) = ln(e
^{3k}) - ln(6) = 3k
- 6 can't be manipulated into one of the log laws

- k = ln(6)/3
- y = -4e
^{\(\frac{ln(6)}{3}x\)}

- y = -4e

- -24 = -4e

Graph it with desmos here I added a second graph to play around with h parameter. Skim the semi-log and log-log plots material then you can safely skip to the end of chapter summary. The exercises again take a random sampling if you feel like it, you don't have to memorize all the laws of logarithms just be aware they exist, and you can come back to this chapter later to manipulate them as per log laws when you encounter them. As usual Ex 97-102 are the best where you have to explain yourself the chapter material like C is the magnitude parameter, h is the horizontal shift.

## Day 7 Trig fundamentals

Let's watch Trigonometry fundamentals from Lockdown math episode 2, every question he asks refer to chapter 1.7 *Trig Functions* which is a short chapter. All the workshop quizzes are in the text, like cos(pi/3) = 1/2.

There's errata in the book chapter, Example 3 is filled with errors, should be 3pi/4 = 135deg not 5pi/4 which is 225deg. It then mixes up the signs for 5pi/4 with 3pi/4 but looking at Figure 5 you can figure out what the correct example should be.

Algebra reminder:

- \(\frac{1}{\frac{\sqrt2}{2}}\) = \(\frac{1}{1} \cdot \frac{2}{\sqrt 2}\) = \(\frac{\sqrt 2 \cdot \sqrt 2}{\sqrt 2}\) = \(\sqrt 2\)
- 2 is \((\sqrt 2)^2\) or \(\sqrt 2 \cdot \sqrt 2\) since \(\sqrt 4\) = 2

The book provides trig identities that we learned in the Brown bootcamp, and really that's it, the exercises primarily are plug and play or graphing functions on desmos or in R to see how the identities work, which for the most part the lockdown math lecture already provided for us.

There is an interesting visualization at @59:30 that show how cot() and tan() are represented geometrically. This is a two-part video with a promise that studying complex numbers in the next video will better explain trigonometry.

### Land Surveying

Some optional extra trig material for practical use in astronomy or land surveying

#### Ancient Mesopotamia surveying

Wildberger has an ancient trig lecture here (22m) on 4000 year old Babylonian surveying, apparently trig originates from land taxation and ownership disputes even before they wanted to start building pyramids and ziggurats and was an offshoot of ancient people who wanted to map stars and predict eclipses.

#### Spherical trigonometry

Wildberger explains here the spherical trig of astronomy that influenced planar trig. If you are wondering why sine/cosine is a rotation around a unit circle, why we have tan(x) function, this explains it.

## Day 8 Complex numbers (Trig part II)

This workshop is part 2 of trig fundamentals and is optional, we finished the first section of the book which is 105 pages in 7 days and are now on to section 2 *Mathematical Modeling* but this workshop will further explain trig identities. Alternatively, the Wildberger rational trigonometry lectures also contain complex numbers defined as dilations (stretch) and rotations. His later complex number lectures make the concept of i^{2} = -1 trivial, he defines i as a 2x2 matrix that when multiplied by itself produces -1.

If you're confused watching the lockdown math lecture, the Geogebra visualization at around 30:55 emphasizes how everything stretches and rotates. The quiz @45:53 is a trig identity, cos(pi/6 + pi/4) or cos(α + β) = cos(α)cos(β) – sin(α)sin(β) all the inputs are in figure 5 on page 111 and he derives it from complex number multiplication. @1:09:09 the quiz solution is obvious if you again look at figure 5 on page 111.

## Day 9 The exp() function part 1

Since we are going to rapidly do the math modeling section of the book, we have some extra time, so may as well watch the next lockdown math lecture about e^{ix} since it provides a model of sin/cos functions as a weighted sum of the exponential function and teaches the properties of exp() we will have to learn later anyway.

Watching lockdown math workshop 4 *What is Euler's formula actually saying?*. We learn e^{x} is really exp(x) and all the parameters still apply like C(exp(kx)). @16:24 the first quiz, reminder that if f(a+b) = f(a)f(b) then we have the rules of exponents, since 2^{3} \(\cdot\) 2^{4} = 2^{7} and 2^{7} = 2^{3+4}, so every option in the quiz is true though he has a moment of confusion that ends up being 1/e * e or e/e which is 1 and still satisfies exp(-1 + 1) = exp(0) = 1.

Quiz @ 27:30 is a Khan Academy lesson but his geometric explanation you can easily see it is -i.

Try it yourself: i^{-1} = 1/i

- 1/i = i
^{4}/i because if i^{2}= (-1) then i^{2}\(\cdot\) i^{2}= 1 which is 1/i - 1/i = i
^{3}because i^{4}/i is i^{3} - 1/i = i
^{3}= (i^{2}\(\cdot\) i) or ((-1) \(\cdot\) i) which = -i.

Summary: \(\frac{1}{i} = \frac{i^4}{i} = i^3 = (i^2 \cdot i) = (-1 \cdot i) = -i\)

When he shows the visualization of exp(i(theta)): i moves up, i^{2} is -1 so moves left, i^{3} is -i so moves down..the @40m quiz asking what is e^{3i}, we can rewrite this as exp(i(3)) and besides him already showing us roughly what this value is @38:40 where theta = pi, recall figure 5 on page 111 of our book and see that pi on the unit circle is -1, so since e^{3i} is close to e^{3.14..i} it's going to be a slightly positive i and nearly -1 value for x. Of course this is also cos(3) + i(sin(3)).

**Homework 1**: expand exp(x)exp(y) or e^{x}e^{y} or e^{x + y} and show every term has a form of \(\frac{x^{k}y^{m}}{k!m!}\)

The formula for exp() is:

\[exp(x) = \sum_{k=0}^{\infty} \frac{x^k}{k!} = \frac{x^0}{0!} + \frac{x^1}{1!} + \frac{x^2}{2!} + \frac{x^3}{3!} ..\]

Recall the lecture on Summation/series notation. So what is exp(1)exp(2), since this is ee^{2} it should be e^{1+2} we will cut off at 2 though in practice you would never do this as you need numerous entries in the series for precision:

\[exp(1) = \sum_{k=0}^{2} \frac{1^k}{k!} = \frac{1^0}{0!} + \frac{1^1}{1!} + \frac{1^2}{2!}\] \[exp(2) = \sum_{k=0}^{2} \frac{2^k}{k!} = \frac{2^0}{0!} + \frac{2^1}{1!} + \frac{2^2}{2!}\]

Now show every term is actually \(\frac{x^{k}y^{m}}{k!m!}\) for exp(1) \(\cdot\) exp(2):

\[(\frac{1^0}{0!} + \frac{1^1}{1!} + \frac{1^2}{2!})(\frac{2^0}{0!} + \frac{2^1}{1!} + \frac{2^2}{2!})\]

You're done, this shows each term as \(\frac{x^{k}y^{m}}{k!m!}\) after you FOIL everything out and collect them under similar denominators at least, I think that's what he's asking.

Homework 2 requires remembering the binomial theorem or n choose k, and #3 is to compare both results to convince yourself that exp(x + y) is roughly exp(x)exp(y) because exp(x) ~ e^{x} so exp() should act like an exponent with the same laws. Homework 4 req watching his linear algebra playlist, and everywhere exists notes or youtube tutorials on the complex exponental: exp(iy) = 1 + iy + (iy)^{2}/2!… where all the positive terms become cos() and negative terms become i(sin()) since i^{2} = -1 and i^{3} = -i etc. Basically you end up proving the thumbnail in this lecture if you try it.

The exp(x) for matrices is explained in the next lecture @59:08 if you're curious. Matrices don't commute when you multiply them.

## Day 10 The exp() part 2

A last and optional workshop on e^{x} introduces the limit definition of e^{x}. Reminder imaginary i is \(\sqrt{-1}\). I chose this because you get an intuitive definition of limits, change and continuous math, plus a crash course in acceleration. All central topics in calculus. The question @43:50 'x nought' or x_{0}, all this means is an arbitrary distance, so instead of inserting a concrete distance of say 12, you abstract this to say it's x_{0} because the actual value doesn't matter.

I also liked this lecture because he substitutes a lot of equations to make them simpler, such as assigning a complex expression to z, or change in z = -1 * z * change in t. In the other math workshop, the Putnam seminar repeatedly uses this strategy to assist with proofs and simplify them.

## Day 11 Mathematical modeling

Let's read through most of chapter 2. I'm not doing any of the exercises here because I'm already taking machine learning courses where we will program these models on a regular basis, when needed I'll return and try some exercises.

### 2.1 Linear function modeling

How do we know if data fits a linear model? Check the slopes are approximately similar at different points, y/x or rise/run, take the average of the slopes minus the one you couldn't include since you don't know the y4 - y3 value if only given data up to y3. Once you get the slope iterate through all y points to solve for b, reminder b is the shift up and down the y-axis, average these and now you have y = mx + b with m and b known and can plug in all your data.

### 2.2 Exponential function modeling

We verify if exponential models are a reasonable data fit by plotting it (x, ln(y)) which produces a linear straight line if e^{x} is the model that fits the data, otherwise we get a curved (non-linear) line. I interpret 'nonconstant' linear meaning you have a variable in there that changes, and not just a constant like y = 5 or else you get a linear flat line no matter what.

Page 142 there's a good breakdown why this works:

- ln(y) = kx + (-kh + ln(C))
- this is of course y = mx + (b) since k is the slope

Should this test for linearity using ln(x) work, our semi-log model of y = m(x - h) + b gives us the parameters for the exponential model where m = k (slope), and C = e^{b}, so e^{be}^{kx}. There's a remark that if you're dealing with -C parameter, you take the absolute value and see if it's linear since ln(x) it's domain is the positive real numbers, so ln(-C) is undefined. I skimmed the rest of the chapter, good advice here how to shift the data to fit the model using the h parameter. If I need this model I'll return to this chapter later.

### 2.3 Power function modeling

Power functions are y = Cx^{k} where k and C are constants. Example: y = x is a power function: y = 1x^{1} or Cx^{k}.

Many of the examples here reinforce the laws of exponents, showing you how to manipulate power function equations. The test for identifying a power function model fits the data is to take the log-log plot or (ln(x), ln(y)) and the result should be approximately linear. They again show reasoning in steps why this works on page 164, the last line being ln(y) = kln(x) + ln(C) and again this is y = mx + b. This test fails however if the input or output to ln() function are negative values, we can't just take the absolute value like we did with exponential models, and are told we're screwed and the solution is beyond the scope of the book. Chapter ends talking about logarithmic scale plots, where spacing between values on the x/y axis changes logarithmically, so you can show bigger inputs/outputs on smaller graphs.

### 2.4 Sine function modeling

If you watched the 3blue1brown lecture above on trig fundamentals, we already saw him adjusting sin(x)/cos(x) parameters in desmos.

Parameters: \(Asin[\frac{2\pi}{P}(x - h)] + v\)

- A = amplitude
- P = period
- h = horizontal shift on x-axis
- v = vertical shift on y-axis

Try it out in desmos to see what each parameter does.

### 2.5 Sigmoidal function modeling

To understand the parameters use desmos again and adjust them. These kinds of functions come up everywhere, for example a logistic function where the S curve on the y-axis is between 0 and 1, and now any real number you input the output is a probability since a probability space adds up to 1.

### 2.7 Dimensional Analysis

'Dimensionaless' means a scalar, or c^{1} like 1, 2, 3. The number line is 1-dimensional, cartesian (x,y) plane is 2-dimensional, 3-dimensions is (x,y,z) etc.

This whole chapter is about combining dimensions to get a new dimensional result, not the concrete values. Example 3(a): 55mph is the product of either LT^{-1} where T=1 for 1 hour, then L*1*0.5 is the answer or T = 60m then 55/60*30 to get the same answer, which is a distance dimension. Using purely dimensional arithmetic, you get LT^{-1}T which is just L, the distance travelled and same dimension we ended up using concrete values.

Ex 4(a): 4bc where b=T and c=LT^{-1} the 4 being a scalar becomes 1 because we are working at the dimensional level, and the answer is L since LTT^{-1} is LT/T or L*1.

Since we are just working at the level of exponents, they have the same arithmetic as vectors do. This chapter's content on solving three linear equations for three unknown exponents is a simple linear algebra problem we will learn in the next section.

You can skip most of this chapter and come back later as needed, however after reading this chapter and reminding myself on basic dimensional analysis I forgot years ago, I started to notice it is absolutely everywhere even in type theory for dimensional correctness type checking, and statistics theory books to reduce the number of causal factors under consideration and test for scalar dimensionaless quantities.

## Day 12 Method of least squares

This chapter is optional, you can skip to Chapter 4 *Derivatives* if you want to get to calculus. From chapter 3.1 to 3.4 is a linear algebra crash course. All the vector operations examples in the book you can write as small toy programs, for example like I did here in Pyret or you can do in rstudio.

- Vectors - 3Blue1Brown
- Linear combinations - 3Blue1brown
- What a scalar is, what a basis is

- Linear transformations and matrices - 3Blue1Brown
- Explains what the columns of a 2x2 matrix represent

- The determinant - 3Blue1Brown
- ad-bc is the area

The last determinant lecture doesn't really show you how it's actually calculated, though this will:

- Area and volume - WildLinAlg 4 (12m)

We are only watching enough of this lecture to understand the determinant in the book which is kind of given without explanation. Start at the beginning of the lecture.

- Up to 6:20 he shows how you would think about calculating the area of this special case
- @8:40 this is the determinant ad - bc of a 2x2 matrix

You can stop watching at 12:00, though the lecture will go on to define 3D determinants which you can do if you take the linear algebra workshop

### 3.5 Method of Least Squares

If the data is not linear, make a linear approximation y = mx + b. Good chapter if you've never seen this before, page 336 *Understanding the Method of Least Squares* explains what is happening geometrically which is a projection to make it linear like mapping a shadow from 3D to the 2D cartesian plane.

## Day 13 Derivatives

We finally can learn calculus.

- A visualization (17m) to explain average and instantaneous rate of change.

@2:03 s(t) distance function is a sigmoidal function, v(t) velocity function changes based on how s(t) changes, and v(t) looks a lot like a probability normal distribution. Skimming through chapter 4.1 *Rates of Change* from the math modeling book, example 3 to find the instantaneous rate of change, you are shrinking that ds/dt triangle in the 3Blue1Brown videos to almost a point instead of an interval, and approximating the value to 5. Tangents are explained as a limiting of secant lines that are drawn with smaller and smaller intervals.

The RStudio examples, on page 357 I rewrote the syntax they've been using to more generic R syntax:

f <- function(x) { (6 * x^3) - (3 * x^2) } AROC <- function(a, b) { ((f(b) - f(a)) / (b - a)) } AROC(2,3) >> 99

If you are using rstudio cloud, Ctrl-Alt-r runs all your code, and in the bottom console you can enter AROC(2,3).

**Derivatives of Modeling Functions**

- Derivative formulas visualized (19m) the derivatives x
^{n}and sin(x) shown geometrically using area.

The corresponding chapter is 4.3 *Derivatives of Modeling Functions* and differentiation rules on page 404.

- linear differentiation: f(x) = mx + b
- f'(x) = m
- the derivative of a line is it's slope, think of the small triangle 3Blue1Brown drew to represent a 'slight nudge' and a straight linear line is going to have the same 'triangle' or rise/run slope

3blue1brown has tutorials for all these functions.

### The Derivative is a function that consumes other functions and returns a function

If you did the software workshop, I assume you can understand this writeup that explains derivative math notation. Summarized below:

\[{\frac{d}{dx}} x^2 = 2x\]

dy/dx or d/dx consumes functions like p(x) = x^{2} + 3x + 5 and returns a new function p'(x) = 2x + 3 even when we only have a constant returned, such as d(2x) = 2 then what that really means is d(2x) returns p'(x) = 2 a function that returns 2 for all inputs x.

## Day 14 Limits

We skipped the chapter on optimization, all the content on product & chain rule, and some others like quotient rule because we will end up doing them in a problem book anyway, you can skim these chapters then know where to find them later and work through the material as needed, there is no reason to do it all now. 3blue1brown has a good visualization for the product/chain rule you may want to watch it.

Here is another visualization on limits (18m) with L'Hopital's rule. Chapter 4.7 *Limits and the Derivative* starts on page 461 of the math modeling book and is straight forward, to find the limit you subsitute it in or you do this silly dance of approximation if the function is discontinuous. There is much more to know about limits we will do at the end of this workshop.

## Last Day: Integrals

3Blue1Brown's playlist has an integral visualization you should watch, then watch these:

- The integral of x
^{n}(a) - (43m) Wildberger FMP 10a

Wildberger has another interpretation of calculus called the algebraic calculus, here he goes through (starting around 6:45) how you would go about defining your own integration formula. Around 7m in he starts at the beginning integrating a constant x^{0} or 1, a variable x^{1}, a quadratic x^{2}, and points out Archimedes already figured this out over 2200+ years ago in Italy with an extremely simple method.

Around 14m is the standard integration explanation we get in every course. @24:57 we go from Archimedes to the 17th century to see what happens when we integrate x^{3} using the standard x^{n} integration formula. Around 29m in he outlines some problems with integration theory like the nature of the continuum, the problems of using arithmetical series instead of a geometric series, and having no theory of area. This is classic Wildberger hating on analytic modern mathematicians but 34:20 is worth watching, the 'absent theory of areas'.

- The integral of x
^{n}(b) - (39m) Wildberger FMP 10b

Here he goes through all the difference approaches you could try if you were to think up your own integral formula. The most important of this video is the basic integral properties of linearity, additivity, translation invariance, scale invariance and normalization. He walks through all these properties then shows a full proof of the x^{n} integral using just those properties completely in basic algebra.

### You're done

You know enough to work through any AI undergrad statistics or learn how to write proofs and will likely return to this book many times as you work through Wasserman's *All of Statistics* or even a book on algorithm design.

## Advanced problems in Mathematics

Let's work through *Advanced Problems in Mathematics: Preparing for University* by Siklos. It's a free and open text. This is the best way to fill in any blanks, these kinds of problems are designed so you learn multiple concepts at once.

We are also doing this for time efficiency, you can get up in the morning, load up a problem in your head, poke at it over a coffee then hold it in your head for the rest of the day trying to figure it out when you have some downtime like waiting in a line, going for lunch, sitting on the subway. It will annoy you if you can't figure it out and force you to do independent research going through calculus texts trying to find solutions, re-reading all the sections we skipped or you didn't fully understand the first time around.

TODO