No idea if this book does it, but this seems like a perfect fit for automatic differentiation. You can get a simple implementation of automatic differentiation for one dimension in a small amount of surprisingly clear code, without needing to pull in any dependencies or extraneous concepts.