From 4f9b3df35a351b292c20145d5aa18da6a4159c0b Mon Sep 17 00:00:00 2001 From: Aron T Date: Fri, 24 Jul 2026 15:15:43 +0300 Subject: [PATCH 1/6] Slope section: intuition rewrite, first figure, LaTeX notation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Work in progress on "The Slope of a Function" — the intuitive build-up before any calculation. - Slope stated as a *ratio* rather than a distance. It was "how far do we move up ... that distance is called the slope", which names a quantity that changes with step size and so cannot describe the line. Now "how far up for each single step forward", with a sentence on why the comparison, not either measurement alone, is what matters. - Graph and function reframed as siblings — two representations of the same motion — rather than the function representing the graph. Credits Descartes and, independently, Fermat for the curves/equations correspondence, noting the modern function concept came later with Leibniz and Euler. - Rate-of-change examples corrected: they were all unintentionally second-order (speed and growth are already rates). Now position → speed → acceleration gives first and second derivative in one breath, plus the "prices still rising, but more slowly" example that needs both at once. - First figure in these docs: an @setup/@example block drawing one line with three differently-sized steps and identical ratios, carrying the ratio-not-a-distance point visually. Plotting code hidden; Documenter embeds it as SVG. - x and y as $x$ and $y$ throughout; typos fixed; broken analytic-geometry link repaired (it used parentheses instead of square brackets, so it rendered as literal text). Co-Authored-By: Claude Opus 4.8 --- .../01 Derivatives and Rules.md | 50 ++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/docs/src/Differential_Calculus/01 Derivatives and Rules.md b/docs/src/Differential_Calculus/01 Derivatives and Rules.md index 8b25b46..afe9d7e 100644 --- a/docs/src/Differential_Calculus/01 Derivatives and Rules.md +++ b/docs/src/Differential_Calculus/01 Derivatives and Rules.md @@ -1,10 +1,54 @@ # Derivatives and Derivative Rules -The [derivative](https://mathworld.wolfram.com/Derivative.html) is the central tool of differential calculus. It measures how steeply the graph of a function rises or falls — the _slope_ of the function — at each point of its domain. This page follows Walz, _Foundations of Mathematics_, Section 6.1: it builds the derivative from the intuitive notion of slope, gives its precise definition as a limit of difference quotients, and then develops the rules that let us differentiate large classes of functions without returning to that limit each time. +## Introduction + +The [derivative](https://mathworld.wolfram.com/Derivative.html) is the central tool of differential calculus. Following Walz, _Foundations of Mathematics_, Section 6.1: this section builds the derivative from the intuitive notion of _slope_, gives its precise definition as a limit of difference quotients, and then develops the rules that let us differentiate large classes of functions without returning to that limit each time. ## The Slope of a Function -Imagine a hike through mountainous terrain, modelled as a function $f : \lbrack a, b \rbrack \to \mathbb{R}$ that assigns to each location $x$ a height $f(x)$. The steepness we must overcome depends on _where_ we are: the slope is generally not constant but varies with $x$. These varying slope values are themselves described by a new function, the _first derivative_ of $f$, written $f'$ (read "f dash"). +_Slope_ is a core concept in working with functions, so it pays to spend a bit of time trying to understand it. Slope is the graphical stand in for the even more fundamental concept of _rate of change_. What makes differential calculus and its tool, the derivative, so useful is precisely that it allows us to calculate the rate of change of functions (and even the rate of the rate of change and so on!). But let's start with the simpler idea of slope. + +On a two dimensional graph there are essentially two directions: horizontal and vertical. If we were physically moving in space we could conceptualize the graph as a visual representation of moving forward (or backward) along the horizontal or $x$-axis, and up (or down) along the vertical $y$-axis. You notice I put _backward_ and _down_ in parentheses because which direction we choose to call the positive one does not matter yet — we will see what a _negative_ slope means shortly. Wherever I use up I can use down, and the same for forward and backwards. So let's stick to forward and up in our preliminary discussion. + +If we imagine we are moving in space, the way we draw a graph of this motion in space is as follows: For every point $x$ we touch as we move forward, we draw or map a point at the corresponding height $y$ we are moving up to. The graph is one way to represent that motion; a _function_ is another, algebraic and far more convenient. I plug in the current $x$ (horizontal location) into the function and it spits out the $y$ — my current height. Neither one is more fundamental than the other, and that is precisely the great insight behind [analytic geometry](https://study.fourm.info/linear_algebra/dev/Basics/04%20Analytic%20Geometry/), which should already be familiar to us: Descartes — and, independently, Fermat — saw that geometric curves and algebraic equations are two languages for the same objects. (The modern notion of a _function_ arrived later, with Leibniz and Euler, but it slots straight into their frame.) Graph and function are siblings, each describing our motion in its own dialect. + +But now I want the answer to a very fundamental question: how far do we move up for each single step we take forward? _That_ ratio — up per forward — is called the _slope_. Note that it is a ratio and not a distance: if I take a step twice as long I rise twice as far, so it is the _comparison_ of the two, and not either one on its own, that tells us anything about the graph. Essentially then, the slope is a graphical representation of rate of change: how much the height $y$ of the graph changes per unit I move horizontally along $x$. + +We can see this directly. Below is a single straight line along which we take three steps of quite different sizes. The rises differ, the runs differ — but every ratio comes out to the same number, and _that_ number is the slope of the line. + +```@setup slope +using Calculus + +f(x) = 2x + 1 +xs = range(0, 8, length = 200) + +plt = plot(xs, f.(xs); + line = (:black, 2), legend = false, + xlabel = "x", ylabel = "y", + xlims = (0, 8.6), ylims = (0, 18), + title = "Same line, three different steps, one slope") + +num(v) = isinteger(v) ? string(Int(v)) : string(v) # 2.0 -> "2", 1.5 -> "1.5" + +for (x0, h) in ((1.0, 1.0), (3.0, 2.0), (6.0, 1.5)) + y0, y1 = f(x0), f(x0 + h) + plot!(plt, [x0, x0 + h], [y0, y0]; line = (:gray40, 1.5, :dash)) # the run + plot!(plt, [x0 + h, x0 + h], [y0, y1]; line = (:gray40, 1.5, :dash)) # the rise + scatter!(plt, [x0, x0 + h], [y0, y1]; color = :black, markersize = 4) + annotate!(plt, x0 + h / 2, y0 - 1.3, + text("rise $(num(2h)) ÷ run $(num(h)) = 2", 8, :center)) +end +``` + +```@example slope +plt # hide +``` + +The _first derivative_ is a function derived from the base function that allows us to compute the slope of the function, in this context the graph's rate of change, for any point $x$ on the graph. The _second derivative_ is the rate of the rate of change in the graph's height. And so we can continue. Of course, as I mentioned earlier slope is the graphical representation of rate of change, so we can just as well talk about rates of change nowhere near a graph. The rate of change of a car's _position_ is its _speed_; the rate of change of its _speed_ is its _acceleration_ — there is a first derivative and a second derivative, in units we all already know. Or think of the news reporting that prices are still rising, but more slowly: that one sentence makes a claim about a first derivative (prices rising) and a second derivative (the rising easing off) at the same time. We could equally talk about the growth of a plant, or the interest accumulating in my bank account, or any rate of change for that matter. The graph is just the representation of these! So if you consider the concept of rate of change more broadly, it should be clear why differential calculus is so useful! + +From now on, everything we talk about in differential calculus is exactly how we compute the derivatives for any given function. Working with graphs is just the way to concretize these calculations and concepts and make them easier to understand. So we will continue to talk about how to compute the slope. + +## Computing Derivatives Before giving the general definition, we compute the derivatives of a few simple functions directly. @@ -24,6 +68,8 @@ In particular the _identity_ $f(x) = x$ (with $c = 1$, $d = 0$) has $f'(x) = 1$. ### The Quadratic Power Function +Imagine a hike through mountainous terrain, modelled as a function $f : \lbrack a, b \rbrack \to \mathbb{R}$ that assigns to each location $x$ a height $f(x)$. The steepness we must overcome depends on _where_ we are: the slope is generally not constant but varies with $x$. These varying slope values are themselves described by a new function, the _first derivative_ of $f$, written $f'$ (read "f dash"). + For $f(x) = x^2$ the slope is _not_ constant. Using the binomial formula, the ratio of the change in value to the change in position between $x$ and $x + h$ is $$\frac{f(x+h) - f(x)}{(x+h) - x} = \frac{(x+h)^2 - x^2}{h} = \frac{2hx + h^2}{h} = 2x + h.$$ This ratio still depends on $h$: it is the slope of the [secant line](https://mathworld.wolfram.com/SecantLine.html) through the two points $(x \mid x^2)$ and $(x+h \mid (x+h)^2)$. To obtain the _actual_ slope at $x$ we let $h$ shrink towards $0$ (written $h \to 0$), which sends the secant into the [tangent line](https://mathworld.wolfram.com/TangentLine.html). Taking this [limit](https://mathworld.wolfram.com/Limit.html) gives $$\lim_{h \to 0} (2x + h) = 2x.$$ From 85ffffaa0b783ea6a024cdce3a5302d0a89dd79f Mon Sep 17 00:00:00 2001 From: Aron T Date: Wed, 29 Jul 2026 13:08:39 +0300 Subject: [PATCH 2/6] Fix stale study.fourm.info link in analytic geometry cross-reference Introduced in this branch's own Slope section commit, written before the domain migration landed on main (PR #4). URL only, no prose change. --- docs/src/Differential_Calculus/01 Derivatives and Rules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/Differential_Calculus/01 Derivatives and Rules.md b/docs/src/Differential_Calculus/01 Derivatives and Rules.md index afe9d7e..a35056b 100644 --- a/docs/src/Differential_Calculus/01 Derivatives and Rules.md +++ b/docs/src/Differential_Calculus/01 Derivatives and Rules.md @@ -10,7 +10,7 @@ _Slope_ is a core concept in working with functions, so it pays to spend a bit o On a two dimensional graph there are essentially two directions: horizontal and vertical. If we were physically moving in space we could conceptualize the graph as a visual representation of moving forward (or backward) along the horizontal or $x$-axis, and up (or down) along the vertical $y$-axis. You notice I put _backward_ and _down_ in parentheses because which direction we choose to call the positive one does not matter yet — we will see what a _negative_ slope means shortly. Wherever I use up I can use down, and the same for forward and backwards. So let's stick to forward and up in our preliminary discussion. -If we imagine we are moving in space, the way we draw a graph of this motion in space is as follows: For every point $x$ we touch as we move forward, we draw or map a point at the corresponding height $y$ we are moving up to. The graph is one way to represent that motion; a _function_ is another, algebraic and far more convenient. I plug in the current $x$ (horizontal location) into the function and it spits out the $y$ — my current height. Neither one is more fundamental than the other, and that is precisely the great insight behind [analytic geometry](https://study.fourm.info/linear_algebra/dev/Basics/04%20Analytic%20Geometry/), which should already be familiar to us: Descartes — and, independently, Fermat — saw that geometric curves and algebraic equations are two languages for the same objects. (The modern notion of a _function_ arrived later, with Leibniz and Euler, but it slots straight into their frame.) Graph and function are siblings, each describing our motion in its own dialect. +If we imagine we are moving in space, the way we draw a graph of this motion in space is as follows: For every point $x$ we touch as we move forward, we draw or map a point at the corresponding height $y$ we are moving up to. The graph is one way to represent that motion; a _function_ is another, algebraic and far more convenient. I plug in the current $x$ (horizontal location) into the function and it spits out the $y$ — my current height. Neither one is more fundamental than the other, and that is precisely the great insight behind [analytic geometry](https://fourm.info/linear_algebra/dev/Basics/04%20Analytic%20Geometry/), which should already be familiar to us: Descartes — and, independently, Fermat — saw that geometric curves and algebraic equations are two languages for the same objects. (The modern notion of a _function_ arrived later, with Leibniz and Euler, but it slots straight into their frame.) Graph and function are siblings, each describing our motion in its own dialect. But now I want the answer to a very fundamental question: how far do we move up for each single step we take forward? _That_ ratio — up per forward — is called the _slope_. Note that it is a ratio and not a distance: if I take a step twice as long I rise twice as far, so it is the _comparison_ of the two, and not either one on its own, that tells us anything about the graph. Essentially then, the slope is a graphical representation of rate of change: how much the height $y$ of the graph changes per unit I move horizontally along $x$. From 4c1a6210d201a7e3c03da82c55eb844131ff8495 Mon Sep 17 00:00:00 2001 From: Aron T Date: Mon, 10 Aug 2026 17:04:31 +0300 Subject: [PATCH 3/6] Derivatives: second figure (rising but easing off) + constant-function difference quotient MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Continues "The Slope of a Function" and starts "Computing Derivatives". - Second figure in the chapter: a saturating curve $5(1 - e^{-x/3})$ with three tangent segments (slopes ≈ 1.01, 0.52, 0.19) getting visibly shallower. Makes the first-vs-second-derivative point concrete — the rate of change stays positive (still rising) while shrinking (rising more slowly), i.e. the "prices still rising, but easing off" sentence drawn. Tangents distinguished by position and numeric slope labels, never by colour. New @setup/@example `slope2` namespace so it can't clobber figure 1's plot. - Lead-in prose keeps the description in graph language ("positive", "declining") rather than the technical positive/negative of a derivative, which isn't defined until later. - Constant function: its slope is now shown as the difference quotient $\frac{f(x+h)-f(x)}{(x+h)-x} = \frac{c-c}{h} = \frac{0}{h} = 0$, replacing an ambiguous $y/x$ (which reads as a ratio of coordinates, not of changes). This mirrors the Linear and Quadratic subsections immediately below — same machine, simplest input — and the numerator $c - c = 0$ is literally the "rise is always 0" stated in words. - Minor: mismatched quote mark and a couple of typos fixed; "rate of the rate of change" for terminology consistency. Co-Authored-By: Claude Opus 4.8 --- .../01 Derivatives and Rules.md | 37 +++++++++++++++++-- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/docs/src/Differential_Calculus/01 Derivatives and Rules.md b/docs/src/Differential_Calculus/01 Derivatives and Rules.md index a35056b..4998f44 100644 --- a/docs/src/Differential_Calculus/01 Derivatives and Rules.md +++ b/docs/src/Differential_Calculus/01 Derivatives and Rules.md @@ -10,9 +10,9 @@ _Slope_ is a core concept in working with functions, so it pays to spend a bit o On a two dimensional graph there are essentially two directions: horizontal and vertical. If we were physically moving in space we could conceptualize the graph as a visual representation of moving forward (or backward) along the horizontal or $x$-axis, and up (or down) along the vertical $y$-axis. You notice I put _backward_ and _down_ in parentheses because which direction we choose to call the positive one does not matter yet — we will see what a _negative_ slope means shortly. Wherever I use up I can use down, and the same for forward and backwards. So let's stick to forward and up in our preliminary discussion. -If we imagine we are moving in space, the way we draw a graph of this motion in space is as follows: For every point $x$ we touch as we move forward, we draw or map a point at the corresponding height $y$ we are moving up to. The graph is one way to represent that motion; a _function_ is another, algebraic and far more convenient. I plug in the current $x$ (horizontal location) into the function and it spits out the $y$ — my current height. Neither one is more fundamental than the other, and that is precisely the great insight behind [analytic geometry](https://fourm.info/linear_algebra/dev/Basics/04%20Analytic%20Geometry/), which should already be familiar to us: Descartes — and, independently, Fermat — saw that geometric curves and algebraic equations are two languages for the same objects. (The modern notion of a _function_ arrived later, with Leibniz and Euler, but it slots straight into their frame.) Graph and function are siblings, each describing our motion in its own dialect. +If we imagine we are moving in space, the way we draw a graph of this motion is as follows: For every point $x$ we touch as we move forward (_run_), we draw or map a point at the corresponding height $y$ we are moving up to (_rise_). The graph is one way to represent that motion; a _function_ is another—algebraic and far more convenient. I plug in the current $x$ (horizontal location) into the function and it spits out the $y$—my current height. Neither one is more fundamental than the other, and that is precisely the great insight behind [analytic geometry](https://fourm.info/linear_algebra/dev/Basics/04%20Analytic%20Geometry/), which should already be familiar to us: Descartes—and, independently, Fermat—saw that geometric curves and algebraic equations are two languages for the same objects. The modern notion of a _function_ arrived later, with Leibniz and Euler, but it fits straight into their frame. Graph and function are siblings, each describing our motion in its own dialect. -But now I want the answer to a very fundamental question: how far do we move up for each single step we take forward? _That_ ratio — up per forward — is called the _slope_. Note that it is a ratio and not a distance: if I take a step twice as long I rise twice as far, so it is the _comparison_ of the two, and not either one on its own, that tells us anything about the graph. Essentially then, the slope is a graphical representation of rate of change: how much the height $y$ of the graph changes per unit I move horizontally along $x$. +But now I want the answer to a very fundamental question: how far do we move up for each single step we take forward? _That_ ratio—up (rise) per forward (run)—is called the _slope_. Note that it is a ratio and not a distance: if I take a step twice as long I rise twice as far, so it is the _comparison_ of the two, and not either one on its own, that tells us anything about the graph. Essentially then, the slope is a graphical representation of rate of change: how much the height $y$ of the graph changes per unit I move horizontally along $x$. We can see this directly. Below is a single straight line along which we take three steps of quite different sizes. The rises differ, the runs differ — but every ratio comes out to the same number, and _that_ number is the slope of the line. @@ -44,7 +44,36 @@ end plt # hide ``` -The _first derivative_ is a function derived from the base function that allows us to compute the slope of the function, in this context the graph's rate of change, for any point $x$ on the graph. The _second derivative_ is the rate of the rate of change in the graph's height. And so we can continue. Of course, as I mentioned earlier slope is the graphical representation of rate of change, so we can just as well talk about rates of change nowhere near a graph. The rate of change of a car's _position_ is its _speed_; the rate of change of its _speed_ is its _acceleration_ — there is a first derivative and a second derivative, in units we all already know. Or think of the news reporting that prices are still rising, but more slowly: that one sentence makes a claim about a first derivative (prices rising) and a second derivative (the rising easing off) at the same time. We could equally talk about the growth of a plant, or the interest accumulating in my bank account, or any rate of change for that matter. The graph is just the representation of these! So if you consider the concept of rate of change more broadly, it should be clear why differential calculus is so useful! +The _first derivative_ is a function derived from the base function that allows us to compute the slope of the function, in this context the graph's rate of change, for any point $x$ on the graph. The _second derivative_ is the rate of the rate of change in the graph's height. And so we can continue on. Of course, as I mentioned earlier slope is the graphical representation of rate of change, so we can just as well talk about rates of change without using a graph. The rate of change of a car's _position_ is its _speed_; the rate of change of its _speed_ is its _acceleration_ — there is a first derivative and a second derivative, in units we all already know. Or think of the news reporting that prices are still rising, but more slowly: that one sentence makes a claim about a first derivative (prices rising) and a second derivative (the rising easing off) at the same time. We could equally talk about the growth of a plant, or the interest accumulating in my bank account, or any rate of change for that matter. The graph is just the representation of these! So if you consider the concept of rate of change more broadly, it should be clear why differential calculus is so useful! + +While we can use functions and descriptive language to talk about rate of change and rate of the rate of change, graphs are also great at helping us visualize these and making this concept more intuitive. For example, the curve below keeps rising—its slope stays positive everywhere—yet the tangent lines drawn along it grow steadily shallower, so the curve rises by less and less. The curve always rising indicates the rate of change is always positive. The gradual decline indicates that the rate of this change is declining. This illustrates what we mean when we say "prices are rising, but easing off." + +```@setup slope2 +using Calculus + +g(x) = 5 * (1 - exp(-x / 3)) # rises toward 5, but ever more slowly +gp(x) = (5 / 3) * exp(-x / 3) # its slope: positive, but shrinking +xs = range(0, 9, length = 200) + +plt = plot(xs, g.(xs); + line = (:black, 2), legend = false, + xlabel = "x", ylabel = "y", + xlims = (0, 9.4), ylims = (0, 5.3), + title = "Still rising, but ever more slowly") + +for x0 in (1.5, 3.5, 6.5) + y0, m = g(x0), gp(x0) + hw = 1.2 # half-width of the drawn tangent segment + plot!(plt, [x0 - hw, x0 + hw], [y0 - hw * m, y0 + hw * m]; line = (:royalblue, 2)) + scatter!(plt, [x0], [y0]; color = :black, markersize = 4) + annotate!(plt, x0, y0 + 0.45, + text("slope ≈ $(round(m, digits = 2))", 8, :center, :royalblue)) +end +``` + +```@example slope2 +plt # hide +``` From now on, everything we talk about in differential calculus is exactly how we compute the derivatives for any given function. Working with graphs is just the way to concretize these calculations and concepts and make them easier to understand. So we will continue to talk about how to compute the slope. @@ -54,7 +83,7 @@ Before giving the general definition, we compute the derivatives of a few simple ### Constant Functions -A constant function $f(x) = c$ has a horizontal graph, so its slope is $0$ everywhere. +A constant function $f(x) = c$ has a horizontal graph, so its slope is $0$ everywhere. To confirm this, note the rise is always 0, so the ratio is $$\frac{f(x+h) - f(x)}{(x+h) - x} = \frac{c - c}{h} = \frac{0}{h} = 0.$$ **First derivative of a constant function.** For $f(x) = c$ the first derivative vanishes for all $x$: $$f'(x) = 0.$$ From 8725108200c596abad2072a5b6c8e605ebc970da Mon Sep 17 00:00:00 2001 From: Aron T Date: Tue, 11 Aug 2026 18:42:12 +0300 Subject: [PATCH 4/6] =?UTF-8?q?Derivatives:=20rework=20the=20Quadratic=20P?= =?UTF-8?q?ower=20Function=20section=20=E2=80=94=20intuition-first,=20two?= =?UTF-8?q?=20figures,=20explicit=20limit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rebuilds "The Quadratic Power Function" around building intuition before formalism, and adds the two figures that carry the approximation→limit idea. - Drops "secant" jargon from this first pass: the slope of x² is built as the line through two nearby points, x and x+h. (The term returns, properly named, in the later "The Derivative as a Limit" section — intuition first, terminology when precise.) - Makes the move from approximation to limit explicit: worked instances (x = 1 → 2 + h, x = 2 → 4 + h) show the slope genuinely varies with x, then a numeric table (h = 1/10, 1/100, 1/1000 → 2.1, 2.01, 2.001) makes h → 0 something you can watch. - Two figures: - The parabola with tangents at x = 0.5, 1.5, 2.5 (slopes 1, 3, 5) — the slope plainly grows with x, cashing "the slope is not constant". - The line through (x, x²) and (x+h, (x+h)²) drawn for h = 1, 0.5, 0.25, its slope (3, 2.5, 2.25) closing in on the tangent's slope 2 as h → 0. Labels distinguished by position and value, never colour. - The general "…turn into the general definition of the derivative" sentence moved to "The General Power Function"; a concrete lead-in now introduces the specific f'(x) = 2x. - LaTeX / mechanical corrections along the way: the "x = h" → "x + h" point error; U+2215 division slash → "/"; a sentence fragment and a garbled limit sentence rewritten; "tangents"-as-a-verb → the tangent line; the dangling "Fig. 6.4" (a leftover Walz reference) removed; assorted typos and $x$/$0$ notation consistency. Co-Authored-By: Claude Opus 4.8 --- .../01 Derivatives and Rules.md | 88 ++++++++++++++++++- 1 file changed, 84 insertions(+), 4 deletions(-) diff --git a/docs/src/Differential_Calculus/01 Derivatives and Rules.md b/docs/src/Differential_Calculus/01 Derivatives and Rules.md index 4998f44..9c2fe4a 100644 --- a/docs/src/Differential_Calculus/01 Derivatives and Rules.md +++ b/docs/src/Differential_Calculus/01 Derivatives and Rules.md @@ -97,17 +97,97 @@ In particular the _identity_ $f(x) = x$ (with $c = 1$, $d = 0$) has $f'(x) = 1$. ### The Quadratic Power Function -Imagine a hike through mountainous terrain, modelled as a function $f : \lbrack a, b \rbrack \to \mathbb{R}$ that assigns to each location $x$ a height $f(x)$. The steepness we must overcome depends on _where_ we are: the slope is generally not constant but varies with $x$. These varying slope values are themselves described by a new function, the _first derivative_ of $f$, written $f'$ (read "f dash"). +The previous two function types are exceptional since their slope is constant. Let's look at how most functions work, where the slope changes for each location of $x$. -For $f(x) = x^2$ the slope is _not_ constant. Using the binomial formula, the ratio of the change in value to the change in position between $x$ and $x + h$ is $$\frac{f(x+h) - f(x)}{(x+h) - x} = \frac{(x+h)^2 - x^2}{h} = \frac{2hx + h^2}{h} = 2x + h.$$ +We can see this with the quadratic function $f(x) = x^2$. Its graph is a parabola, and a single glance shows the slope is _not_ constant: near the bottom the curve is almost flat, while further out it climbs ever more steeply. Drawing the tangent line at a few points makes this concrete — shallow where the parabola is nearly flat, steep where it rises sharply. The slope plainly depends on _where_ we are, that is, on the value of $x$. -This ratio still depends on $h$: it is the slope of the [secant line](https://mathworld.wolfram.com/SecantLine.html) through the two points $(x \mid x^2)$ and $(x+h \mid (x+h)^2)$. To obtain the _actual_ slope at $x$ we let $h$ shrink towards $0$ (written $h \to 0$), which sends the secant into the [tangent line](https://mathworld.wolfram.com/TangentLine.html). Taking this [limit](https://mathworld.wolfram.com/Limit.html) gives $$\lim_{h \to 0} (2x + h) = 2x.$$ +```@setup qslope +using Calculus + +q(x) = x^2 +xs = range(-1, 2.7, length = 220) + +plt = plot(xs, q.(xs); + line = (:black, 2), legend = false, + xlabel = "x", ylabel = "y", + xlims = (-1.1, 3.1), ylims = (-0.6, 8.6), + title = "The slope of x² grows with x") + +for x0 in (0.5, 1.5, 2.5) + m = 2x0 # the slope of x^2 at x0 is 2x0 + hw = 0.4 # half-width of the drawn tangent + plot!(plt, [x0 - hw, x0 + hw], [q(x0) - m*hw, q(x0) + m*hw]; line = (:royalblue, 2)) + scatter!(plt, [x0], [q(x0)]; color = :black, markersize = 4) + annotate!(plt, x0 - 0.06, q(x0) + 0.25, text("slope = $(Int(m))", 8, :right, :royalblue)) +end +``` + +```@example qslope +plt # hide +``` + +How do we calculate the slope of the parabola at point $x$? Let's take an approximation and imagine two points, $x$ and $x+h$, and using the function $f$ calculate the values on the parabola. If we draw a line between those two calculated points on the parabola, we can use the binomial formula to calculate the slope of the line: the ratio of the change in value to the change in position between $x$ and $x + h$ is $$\frac{f(x+h) - f(x)}{(x+h) - x} = \frac{(x+h)^2 - x^2}{h} = \frac{2hx + h^2}{h} = 2x + h.$$ + +Of course, the slope of this line is just an approximation. But we have learned the slope is not constant but completely dependent on $x$. So if $x = 1$ the slope will be $2x + h = 2 \times 1 + h = 2 + h$. If $x = 2$ the slope will be $2x + h = 2 \times 2 + h = 4 + h$. And so on. In other words the slope is different for every value of $x$. + +The remaining question is how do we get rid of the pesky $h$ and get the _actual_ slope at $x$? Intuitively we can imagine that the smaller $h$ is, the closer the line we create is to the actual slope at point $x$. If we let $h$ get closer and closer to $0$ without ever becoming $0$ we say that $h$ _tends towards_ $0$ (written $h \to 0$). For example, if in the formula $2x + h$ we set $x = 1$ and we set $h$ to consecutively take the values $1/10, 1/100, 1/1000, \dots$ we in turn get the resulting approximations for the slope: $2.1, 2.01, 2.001, \dots$ + +Following this thought to the end, we say the term $2 + h$ _converges_ to the limit $2$ as $h \to 0$. The mathematical notation for this is: + +$$\lim_{h \to 0} (2 + h) = 2,$$ + +which means the term $2 + h$ is arbitrarily close to the _limit_ (from the Latin _limes_) $2$ whenever $h$ is close enough to $0$. So the actual slope of $f(x) = x^2$ at $x = 1$ is exactly $2$. + +The same reasoning works at _any_ point $x$, not just $x = 1$ — we only used $1$ to put numbers on the page. Taking the limit of the general approximation $2x + h$ gives + +$$\lim_{h \to 0} (2x + h) = 2x,$$ +so the slope of $f(x) = x^2$ at any point is $2x$ — a slope that, just as the graph showed, grows with $x$. + +Geometrically, this limiting slope belongs to the straight line that just _touches_ the parabola at $x$ — its _tangent_ line (from the Latin _tangere_, "to touch"). As $h \to 0$, the line drawn through our two points swings around and settles onto that tangent: + +```@setup qlimit +using Calculus + +q(x) = x^2 +num(v) = isinteger(v) ? string(Int(v)) : string(v) +xs = range(0.35, 2.35, length = 220) + +plt = plot(xs, q.(xs); + line = (:black, 2), legend = false, + xlabel = "x", ylabel = "y", + xlims = (0.25, 3.35), ylims = (-0.4, 5.9), + title = "As h → 0 the line settles onto the tangent") + +x0, y0 = 1.0, 1.0 + +# connecting lines through (x0,y0) and (x0+h, f(x0+h)); slopes 3, 2.5, 2.25 close in on 2 +for h in (1.0, 0.5, 0.25) + x1, y1 = x0 + h, q(x0 + h) + plot!(plt, [x0, x1], [y0, y1]; line = (:gray45, 1.5, :dash)) + scatter!(plt, [x1], [y1]; color = :gray25, markersize = 3.5) + annotate!(plt, x1 - 0.1, y1 + 0.05, text("slope = $(num(2 + h))", 7, :right, :gray25)) +end + +tangent(x) = y0 + 2 * (x - x0) # the limiting line: slope 2 at x = 1 +plot!(plt, [0.4, 2.2], [tangent(0.4), tangent(2.2)]; line = (:royalblue, 2.5)) +annotate!(plt, 2.25, tangent(2.2) + 0.05, text("tangent, slope = 2", 8, :left, :royalblue)) + +scatter!(plt, [x0], [y0]; color = :black, markersize = 4.5) +annotate!(plt, x0, y0 - 0.33, text("x = 1", 8, :center, :black)) +``` + +```@example qlimit +plt # hide +``` + +Using this idea we can define the first derivative for this specific function as follows: **First derivative of the quadratic power function.** For $f(x) = x^2$: $$f'(x) = 2x.$$ + ### The General Power Function -The same pattern holds for every power $p_i(x) = x^i$ with $i \in \mathbb{N}$: bring the exponent down as a factor and reduce it by one. +This idea of approximating the slope with a line through two nearby points, then letting those points merge at the limit, is exactly the idea we now turn into the general definition of the derivative. Before explaining the general derivation, let's define the general derivative. The same pattern holds for every power $p_i(x) = x^i$ with $i \in \mathbb{N}$: bring the exponent down as a factor and reduce it by one. **First derivative of the power function.** For $p_i(x) = x^i$: $$p_i'(x) = i\,x^{i-1}.$$ From a00d19ea77b3679df6bf1c1ea666731af50b7030 Mon Sep 17 00:00:00 2001 From: Aron T Date: Thu, 13 Aug 2026 17:54:10 +0300 Subject: [PATCH 5/6] Derivatives: tangent-line derivation + worked example; settle difference-quotient terminology MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fills in "The Derivative as a Limit" and cleans up its vocabulary. - Adds the derivation of the tangent line from the point-slope form, and a worked example that separates the two things Walz runs together: the *general* tangent formula t(x̄) = 2x·x̄ − x² (valid at any point of tangency x), and the *specific* tangent at a fixed point — x = 1 gives t(x̄) = 2x̄ − 1, the very line the secants close in on in the qlimit figure. Makes explicit that x is the fixed point of tangency while x̄ is the tangent's own running input (the bar keeps the two roles of "x" apart) — the exact distinction Walz's own derivation obscures. - Terminology: keep "difference quotient" (the standard English term for the finite ratio) and drop "differential quotient" (the dated Germanic name for the limit — in English it's just the derivative); the definition heading is now "First derivative". 202 / 204 / 206 now speak consistently. - Cross-references the point-slope form to the [slope-intercept form] in the Math Foundations notes (absolute link, matching the existing analytic-geometry reference). - Fixes $y-axis$ (the hyphen had landed inside the math, rendering as "y minus axis") → $y$-axis. Co-Authored-By: Claude Opus 4.8 --- .../01 Derivatives and Rules.md | 40 ++++++++++++++----- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/docs/src/Differential_Calculus/01 Derivatives and Rules.md b/docs/src/Differential_Calculus/01 Derivatives and Rules.md index 9c2fe4a..e33cfe0 100644 --- a/docs/src/Differential_Calculus/01 Derivatives and Rules.md +++ b/docs/src/Differential_Calculus/01 Derivatives and Rules.md @@ -184,27 +184,49 @@ plt # hide Using this idea we can define the first derivative for this specific function as follows: **First derivative of the quadratic power function.** For $f(x) = x^2$: $$f'(x) = 2x.$$ - ### The General Power Function -This idea of approximating the slope with a line through two nearby points, then letting those points merge at the limit, is exactly the idea we now turn into the general definition of the derivative. Before explaining the general derivation, let's define the general derivative. The same pattern holds for every power $p_i(x) = x^i$ with $i \in \mathbb{N}$: bring the exponent down as a factor and reduce it by one. +Let's now define the derivative for any power function. The same pattern holds for every power $p_i(x) = x^i$ with $i \in \mathbb{N}$: bring the exponent down as a factor and reduce it by one. **First derivative of the power function.** For $p_i(x) = x^i$: $$p_i'(x) = i\,x^{i-1}.$$ -For example $(x^{128})' = 128\,x^{127}$ and $(x^7)' = 7 x^6$. As we will see below, this "rough rule" also extends to negative and fractional exponents. +For example $(x^{3})' = 3\,x^{2}$ and $(x^7)' = 7 x^6$. As we will see below, this "rough rule" also extends to negative and fractional exponents. ## The Derivative as a Limit -We now make the procedure above precise for a general function $f$. Fix a point $x$ and a small $h \neq 0$ such that both $x$ and $x + h$ lie in the domain of $f$. +The idea we used above of approximating the slope with a line through two nearby points, then letting those points merge at the limit, involved quite a bit of hand waving. Ee will now make this idea a bit more precise, although we still will not precisely define the idea of limit. As an aside, if you look at the history of the Calculus, this is exactly how it developed. Both Newton and Leibniz, the founders of modern Calculus, had the intuitive insights and developed the procedures for calculating the derivatives of different types of functions (as we will do below). Making their ideas more precise is what many great mathemeticians did in the eighteenth and Noneteenth centuries. But that is beyond the scope of this basic introduction. + +So let's start by more precisely defining what we mean by a line between two nearby points and the slope of that line in relation to the function $f$. Start by choosing $x$ and a small $h \neq 0$ such that both $x$ and $x + h$ lie in the domain of $f$ (and so are points on the $x$-axis). + +- The [secant line](https://mathworld.wolfram.com/SecantLine.html) of $f$ through $x$ and $x + h$ is defined as the straight line through the two points $(x, f(x))$ and $(x+h, f(x+h))$. +- Its slope is the _difference quotient_ which is the ratio of the difference between the two $y$-axis co-ordinates per the difference of the $x$-axis co-ordinates (which difference is, of course, just $h$). This gives us: $$\frac{f(x+h) - f(x)}{h}.$$ + +The difference quotient is only an _approximation_ to the actual slope at $x$. Passing to the limit $h \to 0$ gives the exact value: + +**First derivative.** If this limit of the difference quotients $$f'(x) = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}$$ exists, then $f'(x)$ is the value of the slope of $f$ at $x$, called the _first derivative_ of $f$ at $x$. In that case $f$ is said to be _differentiable_ at $x$. + +**Tangent of $f$ at $x$.** The linear function $t$ through $(x, f(x))$ with slope $f'(x)$ is the [tangent line](https://mathworld.wolfram.com/TangentLine.html) of $f$ at $x$. + +We can derive the function $t$ as follows. The tangent is just a straight line, with two key facts that pin it down: + +1. its slope is $f'(x)$, the derivative at the _point of tangency_, and +2. it passes through the point $(x, f(x))$, i.e. it touches the curve there. + +Using the point-slope form of a line — closely related to the [slope-intercept form](https://fourm.info/math_foundations/dev/Algebra/03%20Solving%20Equations/#Standard-Forms) — $y = m \cdot (\bar{x} - x_0) + y_0$, we plug in $m = f'(x)$ and $(x_0, y_0) = (x, f(x))$ to derive $t$: + +$$t(\bar{x}) = f'(x)\,(\bar{x} - x) + f(x) = f'(x)\,\bar{x} - f'(x)\,x + f(x).$$ + +Here $x$ is the _fixed_ point of tangency (a specific number), while $\bar{x}$ is the running input of the tangent line; the bar keeps these two roles of "$x$" apart. + +**Example.** Take $f(x) = x^2$, so $f'(x) = 2x$. Substituting into the formula and simplifying: -- The [secant line](https://mathworld.wolfram.com/SecantLine.html) of $f$ through $x$ and $x + h$ is the straight line through $(x \mid f(x))$ and $(x+h \mid f(x+h))$. -- Its slope is the _difference quotient_ $$\frac{f(x+h) - f(x)}{h}.$$ +$$t(\bar{x}) = 2x \cdot \bar{x} - 2x \cdot x + x^2 = 2x\,\bar{x} - 2x^2 + x^2 = 2x\,\bar{x} - x^2.$$ -The difference quotient is only an _approximation_ to the actual slope at $x$. Passing to the limit $h \to 0$ gives the exact value. +This is still general — $x$ is any point of tangency. To read off a concrete tangent, fix a point, say $x = 1$, where $f(1) = 1$ and $f'(1) = 2$: -**Differential quotient and first derivative.** If the limit of the difference quotients $$f'(x) = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}$$ exists, then $f'(x)$ is the value of the slope of $f$ at $x$, called the _first derivative_ of $f$ at $x$. In that case $f$ is said to be _differentiable_ at $x$. +$$t(\bar{x}) = 2 \cdot 1 \cdot \bar{x} - 1^2 = 2\bar{x} - 1,$$ -**Tangent of $f$ at $x$.** The linear function through $(x \mid f(x))$ with slope $f'(x)$ is the [tangent line](https://mathworld.wolfram.com/TangentLine.html) of $f$ at $x$: $$t(\bar{x}) = f'(x)\,\bar{x} - f'(x)\,x + f(x).$$ +the straight line of slope $2$ through $(1, 1)$. If $f$ is differentiable at _every_ point of its domain, the assignment $x \mapsto f'(x)$ defines a new function, the _derivative function_ (or simply the _derivative_) of $f$. From 5bb6c55322c7c4131f6ead9bc5554da022f0cd95 Mon Sep 17 00:00:00 2001 From: Aron T Date: Fri, 14 Aug 2026 16:57:57 +0300 Subject: [PATCH 6/6] Derivatives: fix two typos; point the notebook env at Latexify MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 01 Derivatives and Rules.md: mathemeticians → mathematicians and Noneteenth → nineteenth, in the Newton–Leibniz aside. - notebooks/Project.toml: drop LAlatex + BlockArrays (Linear-Algebra / vector-calculus machinery, carried over when the file was copied from that repo) and add Latexify. The forthcoming derivatives notebook needs symbolic-expression → LaTeX rendering, not block-matrix display; Latexify is already in the resolved graph via Calculus → CalculusWithJuliaSquared → Symbolics, so this just promotes it to a direct dependency so the notebook can `using Latexify`. Co-Authored-By: Claude Opus 4.8 --- docs/src/Differential_Calculus/01 Derivatives and Rules.md | 2 +- notebooks/Project.toml | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/src/Differential_Calculus/01 Derivatives and Rules.md b/docs/src/Differential_Calculus/01 Derivatives and Rules.md index e33cfe0..4dc6eb4 100644 --- a/docs/src/Differential_Calculus/01 Derivatives and Rules.md +++ b/docs/src/Differential_Calculus/01 Derivatives and Rules.md @@ -194,7 +194,7 @@ For example $(x^{3})' = 3\,x^{2}$ and $(x^7)' = 7 x^6$. As we will see below, th ## The Derivative as a Limit -The idea we used above of approximating the slope with a line through two nearby points, then letting those points merge at the limit, involved quite a bit of hand waving. Ee will now make this idea a bit more precise, although we still will not precisely define the idea of limit. As an aside, if you look at the history of the Calculus, this is exactly how it developed. Both Newton and Leibniz, the founders of modern Calculus, had the intuitive insights and developed the procedures for calculating the derivatives of different types of functions (as we will do below). Making their ideas more precise is what many great mathemeticians did in the eighteenth and Noneteenth centuries. But that is beyond the scope of this basic introduction. +The idea we used above of approximating the slope with a line through two nearby points, then letting those points merge at the limit, involved quite a bit of hand waving. We will now make this idea a bit more precise, although we still will not precisely define the idea of limit. As an aside, if you look at the history of the Calculus, this is exactly how it developed. Both Newton and Leibniz, the founders of modern Calculus, had the intuitive insights and developed the procedures for calculating the derivatives of different types of functions (as we will do below). Making their ideas more precise is what many great mathematicians did in the eighteenth and nineteenth centuries. But that is beyond the scope of this basic introduction. So let's start by more precisely defining what we mean by a line between two nearby points and the slope of that line in relation to the function $f$. Start by choosing $x$ and a small $h \neq 0$ such that both $x$ and $x + h$ lie in the domain of $f$ (and so are points on the $x$-axis). diff --git a/notebooks/Project.toml b/notebooks/Project.toml index fc06e67..daa999a 100644 --- a/notebooks/Project.toml +++ b/notebooks/Project.toml @@ -1,9 +1,8 @@ [deps] -BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e" +Calculus = "dfd5a24e-f5d9-431d-8566-d266db9d2854" IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" -LAlatex = "2feda2f4-7604-459e-bd73-51e960cd9dcb" +Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316" Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" -Calculus = "dfd5a24e-f5d9-431d-8566-d266db9d2854" [compat] julia = "1.10"