Lindgren price dynamics: dot product, partial derivatives, Hamiltonian, optimal velocity
DefinitionLindgrenPriceDynamicsShared definitions for the price-adjustment model of Lindgren (2022). There are commodities; price vectors are .
- Contraction (eq. (1)): .
- Price partial derivative and gradient: at , and .
- Time partial derivative of a function : , the derivative of .
- Aggregate expenditure: .
- Hamiltonian (eq. (8)), as a function of the control , with standing for :
- Optimal price velocity (eq. (9)): .
These are the objects in which the HJB equation, the price-velocity evolution equation and the Lyapunov condition of the paper are stated.
Formalization Note Partial derivatives are Fréchet derivatives applied to standard basis vectors; as usual in Mathlib, they return where the function is not differentiable, and is when .
import Mathlib
/-!
# Lindgren (2022): price-adjustment dynamics — shared definitions
Source: J. Lindgren, *General Equilibrium with Price Adjustments — A Dynamic Programming
Approach*, Analytics 2022, 1, 27–34, https://doi.org/10.3390/analytics1010003.
There are `l` commodities (prices `p : Fin l → ℝ`) and `n` agents.
-/
namespace LindgrenPriceDynamics
/-- The implicit-summation contraction `x^i y_i = ∑_{i=1}^l x_i y_i` of eq. (1). -/
noncomputable def dot {l : ℕ} (x y : Fin l → ℝ) : ℝ := ∑ i, x i * y i
/-- Partial derivative `∂f/∂p_i` of a function of the price vector, i.e. the Fréchet
derivative of `f` at `p` applied to the `i`-th standard basis vector. -/
noncomputable def pricePartial {l : ℕ} (f : (Fin l → ℝ) → ℝ) (p : Fin l → ℝ) (i : Fin l) : ℝ :=
fderiv ℝ f p (Pi.single i 1)
/-- Price gradient `∇f(p) = (∂f/∂p_1, …, ∂f/∂p_l)`. -/
noncomputable def priceGrad {l : ℕ} (f : (Fin l → ℝ) → ℝ) (p : Fin l → ℝ) : Fin l → ℝ :=
fun i => pricePartial f p i
/-- Partial time derivative `∂F/∂t (t, p)` of a function of time and prices. -/
noncomputable def timePartial {l : ℕ} (F : ℝ → (Fin l → ℝ) → ℝ) (t : ℝ) (p : Fin l → ℝ) : ℝ :=
deriv (fun τ => F τ p) t
/-- Aggregate expenditure `λ^j e_j(p) = ∑_{j=1}^n λ_j e_j(p)` (the running cost in eq. (7)). -/
noncomputable def aggregateExpenditure {n l : ℕ} (lam : Fin n → ℝ) (e : Fin n → (Fin l → ℝ) → ℝ)
(p : Fin l → ℝ) : ℝ :=
∑ j, lam j * e j p
/-- The Hamiltonian of eq. (8), `H = ½ m v^i v_i + λ^j e_j + (∂J/∂p_i) v^i`,
written as a function of the control `v`, with `E = λ^j e_j` and `g = ∇J`. -/
noncomputable def hamiltonian {l : ℕ} (m E : ℝ) (g v : Fin l → ℝ) : ℝ :=
(1 / 2) * m * dot v v + E + dot g v
/-- The optimal price velocity (feedback policy) of eq. (9): `v_i = -(1/m) ∂J/∂p_i`. -/
noncomputable def optimalVelocity {l : ℕ} (m : ℝ) (J : ℝ → (Fin l → ℝ) → ℝ) (t : ℝ)
(p : Fin l → ℝ) : Fin l → ℝ :=
fun i => -(1 / m) * pricePartial (J t) p i
end LindgrenPriceDynamics
Read-back
What the Lean code literally says, in plain math · Aristotle (Harmonic) — non-blind, same agent as drafter
Non-blind read-back. This read-back was written by the same agent that drafted the Lean statements (Aristotle, by Harmonic), with full knowledge of the source paper and of the intended meaning. It is not blind, independent testimony and must not be treated as an independent audit; an independent blind read-back is still recommended before submission.
All objects below are indexed by natural numbers (number of commodities) and, where relevant, (number of agents). Vectors are functions from to .
- dot: . For it is .
- pricePartial : for , the Fréchet derivative evaluated on the -th standard basis vector , i.e. . If is not differentiable at this is (not undefined).
- priceGrad : the vector , with the same junk-value convention.
- timePartial : for (curried), the ordinary derivative at of ; equal to if that map is not differentiable at .
- aggregateExpenditure , for arbitrary real weights and arbitrary real functions (no sign or regularity constraints); if .
- hamiltonian , for arbitrary reals (no sign condition on ) and vectors .
- optimalVelocity : the vector with components . When , is interpreted as , so the vector is .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.