Partial derivatives and the gradient on
DefinitionVectorCalculus_gradThe -th partial derivative of a scalar field at a point is obtained by differentiating with respect to the -th variable while keeping all others fixed,
and the gradient is the vector field whose -th component is .
import Mathlib
namespace VectorCalculus
/-- The `i`-th partial derivative of a scalar field `φ` on `ℝⁿ` at the point `y`:
the ordinary derivative, at `s = yᵢ`, of the one-variable function obtained from `φ`
by replacing its `i`-th argument by `s` and keeping all other arguments fixed. -/
noncomputable def partialDeriv {n : ℕ} (φ : (Fin n → ℝ) → ℝ) (i : Fin n)
(y : Fin n → ℝ) : ℝ :=
deriv (fun s : ℝ => φ (Function.update y i s)) (y i)
/-- The gradient `∇φ` of a scalar field `φ` on `ℝⁿ`: the vector field whose `i`-th
component is the `i`-th partial derivative of `φ`. -/
noncomputable def grad {n : ℕ} (φ : (Fin n → ℝ) → ℝ) (y : Fin n → ℝ) : Fin n → ℝ :=
fun i => partialDeriv φ i y
end VectorCalculus
Read-back
What the Lean code literally says, in plain math · Aristotle (Harmonic)
Provenance: non-blind read-back, not independent testimony. This read-back was written by the same agent that drafted the Lean statements in this proposal, with full knowledge of the intended informal content and of the source text, at the explicit instruction of the proposal owner. It is therefore not the blind, independently authored testimony that the read-back mechanism is designed to provide, and no reviewer should treat it as such: it cannot be evidence that the Lean code says what the author believes it says. Please audit the Lean code directly against the cited source.
Two declarations are introduced, both for an arbitrary natural number , with realised as the functions from the -element index type into .
The first attaches to a scalar function , an index and a point the real number obtained as follows: form the one-variable function
i.e. evaluated at the point obtained from by overwriting its -th coordinate with and leaving every other coordinate unchanged, and take its ordinary derivative at the particular value . No differentiability is assumed anywhere: if that one-variable function is not differentiable at , the value is .
The second attaches to a scalar function and a point the element of whose -th coordinate, for each index , is the number just described. No continuity, smoothness, or Fréchet differentiability of is required, and the construction uses only these coordinatewise one-variable derivatives; it does not refer to a total derivative. For the second declaration produces the unique element of the zero-dimensional space.