|
| 1 | +learned the formal names for derivative notations today. |
| 2 | + |
| 3 | +- Newton: $\dot{x}$, $\ddot{x}$, $\dddot{x}$, $\ddddot{x}$ |
| 4 | +- Lagrange: $f'$, $f''$, $f'''$, $f^{(4)}$ |
| 5 | +- Leibniz: $\frac{df}{dx}$, $\frac{d^2f}{dx^2}$, $\frac{d^3f}{dx^3}$, $\frac{d^4f}{dx^4}$ |
| 6 | + |
| 7 | +I hate Leibniz. it is so many tokens. Newton says the same thing with a single dot. why would anyone pick the bulky one? |
| 8 | + |
| 9 | +also stumbled on the [wikipage](https://en.wikipedia.org/wiki/Fourth,_fifth,_and_sixth_derivatives_of_position) for higher-order derivatives of position. soo... |
| 10 | + |
| 11 | +position → velocity → acceleration → jerk → snap → crackle → pop? |
| 12 | + |
| 13 | +these sound so silly :P I can't imagine using them in a real paper, but they are fun to say. |
| 14 | + |
| 15 | +and the latex for Newton dots is delightful. `dot` for one, `ddot` for two d'ots, `dddot` for three d'ots, `ddddot` for four. love it. but the dots in a row get boring for higher orders. why not play with the arrangement? (I mean there's probably a plethera of reasons why we don't, but it's fun to think about it anyway) |
| 16 | + |
| 17 | +$$ |
| 18 | +\dot{x} |
| 19 | +\quad \ddot{x} |
| 20 | +\quad \dddot{x} |
| 21 | +\quad \ddddot{x} |
| 22 | +
|
| 23 | +\quad \text{vs.} |
| 24 | +
|
| 25 | +\quad \dot{x} |
| 26 | +\quad \ddot{x} |
| 27 | +\quad \overset{\begin{smallmatrix} \cdot \\ \cdot \,\, \cdot \end{smallmatrix}}{x} |
| 28 | +\quad \overset{\substack{\cdot \kern{1.4pt} \cdot \\[-0.2ex] \cdot \kern{1.4pt} \cdot}}{x} |
| 29 | +$$ |
| 30 | + |
| 31 | +but then I started thinking about it. |
| 32 | + |
| 33 | +each notation shows up in a different place. the spring mass equation uses Newton: $m\ddot{x} = -kx$. clean with no ambiguity and time being the only variable that matters. Lagrange shows up in textbooks and pure math, $f'(x)$ when there's nothing to disambiguate. I really like the scalability as you can fall back to $f^{(n)}$ when you have more than three derivatives, which is a nice perk. |
| 34 | + |
| 35 | +Leibniz dominates numerical integration and anything with multiple variables. $\frac{dx}{dt} \approx \frac{\Delta x}{\Delta t}$ almost writes the discretization for you. |
| 36 | + |
| 37 | +and then partial derivatives: $\frac{\partial f}{\partial x}$, $\frac{\partial^2 f}{\partial x \partial y}$. Newton and Lagrange can't express this cleanly at all. the moment you have $f(x, y)$, a dot or a prime stops being enough. you need to name the variable you're differentiating against whereas Leibniz was built for it. |
| 38 | + |
| 39 | +but it's super verbose. look at _this_ Jacobi matrix: |
| 40 | + |
| 41 | +$$Df = \begin{bmatrix} |
| 42 | +\frac{\partial f_1}{\partial x} & \frac{\partial f_1}{\partial y} & \frac{\partial f_1}{\partial z} & \frac{\partial f_1}{\partial w} & \frac{\partial f_1}{\partial v} \\ |
| 43 | +\frac{\partial f_2}{\partial x} & \frac{\partial f_2}{\partial y} & \frac{\partial f_2}{\partial z} & \frac{\partial f_2}{\partial w} & \frac{\partial f_2}{\partial v} \\ |
| 44 | +\frac{\partial f_3}{\partial x} & \frac{\partial f_3}{\partial y} & \frac{\partial f_3}{\partial z} & \frac{\partial f_3}{\partial w} & \frac{\partial f_3}{\partial v} \\ |
| 45 | +\frac{\partial f_4}{\partial x} & \frac{\partial f_4}{\partial y} & \frac{\partial f_4}{\partial z} & \frac{\partial f_4}{\partial w} & \frac{\partial f_4}{\partial v} \\ |
| 46 | +\frac{\partial f_5}{\partial x} & \frac{\partial f_5}{\partial y} & \frac{\partial f_5}{\partial z} & \frac{\partial f_5}{\partial w} & \frac{\partial f_5}{\partial v} |
| 47 | +\end{bmatrix}$$ |
| 48 | + |
| 49 | +painful to write on a chalkboard. found out there's [a shorthand](https://en.wikibooks.org/wiki/General_Relativity/Coordinate_systems_and_the_comma_derivative) called the comma derivative where $f_{i,j} \equiv \frac{\partial f_i}{\partial x_j}$, but replacing variable names with numbers loses readability. i don't like numbers that much, they're harder to parse. |
| 50 | + |
| 51 | +so here's a proposal: output component as a superscript, input variable as a subscript. $f^{(1)}_x \equiv \frac{\partial f_1}{\partial x}$. parentheses around the superscript so it doesn't get read as an exponent. it reads "derive this, this much, by that." |
| 52 | + |
| 53 | +$$Df = \begin{bmatrix} |
| 54 | +f^{(1)}_x & f^{(1)}_y & f^{(1)}_z & f^{(1)}_w & f^{(1)}_v \\ |
| 55 | +f^{(2)}_x & f^{(2)}_y & f^{(2)}_z & f^{(2)}_w & f^{(2)}_v \\ |
| 56 | +f^{(3)}_x & f^{(3)}_y & f^{(3)}_z & f^{(3)}_w & f^{(3)}_v \\ |
| 57 | +f^{(4)}_x & f^{(4)}_y & f^{(4)}_z & f^{(4)}_w & f^{(4)}_v \\ |
| 58 | +f^{(5)}_x & f^{(5)}_y & f^{(5)}_z & f^{(5)}_w & f^{(5)}_v |
| 59 | +\end{bmatrix}$$ |
| 60 | + |
| 61 | +row index goes up, column index goes down. names stay and the $\frac{\partial}{\partial}$ shenanigins disappear. it's like an extension of the Lagrange notation. probably already exists somewhere and I just haven't seen it. I think it is super cool :3 |
| 62 | + |
| 63 | +same thing shows up in code: |
| 64 | + |
| 65 | +```ruby |
| 66 | +class Person |
| 67 | + attr_accessor :age, :name, :created_at, :email, :company_id, :start_date, :gender |
| 68 | +end |
| 69 | +``` |
| 70 | + |
| 71 | +```rust |
| 72 | +struct Person<'a> { |
| 73 | + age: u32, |
| 74 | + name: &'a str, |
| 75 | + created_at: DateTime<Utc>, |
| 76 | + email: String, |
| 77 | + company_id: u64, |
| 78 | + start_date: NaiveDate, |
| 79 | + gender: Arc<RwLock<Box<dyn Spectrum + Send + Sync + 'a>>>, |
| 80 | +} |
| 81 | +``` |
| 82 | + |
| 83 | +Ruby assumes you can apply common sense. `age` is years. `name` is a string. `created_at` is a timestamp. you don't need a type annotation to tell you that, the word already did. Rust spells it out anyway. `u32` not `i32`, not `u64`. `&'a str` not `String` _and_ now you need a lifetime too, something Ruby doesn't even have a concept for. feels a bit wasteful on a higher level, until you hit something like `gender`, where the name alone genuinely doesn't tell you the shape, and suddenly you're writing `Arc<RwLock<Box<dyn Spectrum + Send + Sync + 'a>>>`. or when you actually care about memory and don't just rely blindly on an interpreter to do the right thing. |
| 84 | + |
| 85 | +the bulk is the information. Newton's dots assume time. Lagrange's primes assume you already know. Leibniz assumes nothing. |
| 86 | + |
| 87 | +still... |
| 88 | + |
| 89 | +_how many other defaults am i using that look wasteful until i see what they're doing?_ |
0 commit comments