import OAI.AlgebraicGeometry.ComplexMultiplication.HodgeComparison.InverseCoefficientCancellation import Mathlib.Analysis.Calculus.FDeriv.Analytic /-! # Determinant Derivative -/ namespace OAI.AlgebraicGeometry.ComplexMultiplication.HodgeComparison.DeterminantDerivative.CM.Construction noncomputable section /-! Jacobi's determinant formula for differentiable matrix coefficients. -/ variable {ฮน ๐•œ E : Type*} [Fintype ฮน] [DecidableEq ฮน] [RCLike ๐•œ] [NormedAddCommGroup E] [NormedSpace โ„ E] def determinantMultilinear : ContinuousMultilinearMap ๐•œ (fun _ : ฮน => ฮน โ†’ ๐•œ) ๐•œ where toMultilinearMap := Matrix.detRowAlternating.toMultilinearMap cont := by change Continuous (fun M : ฮน โ†’ ฮน โ†’ ๐•œ => Matrix.det (Matrix.of M)) simp only [Matrix.det_apply', Matrix.of_apply] fun_prop theorem determinant_derivative_rows (M : E โ†’ Matrix ฮน ฮน ๐•œ) {x : E} (hM : โˆ€ i, DifferentiableAt โ„ (fun y => M y i) x) (u : E) : fderiv โ„ (fun y => (M y).det) x u = โˆ‘ i, ((M x).updateRow i (fderiv โ„ (fun y => M y i) x u)).det := by have hd := HasFDerivAt.multilinear_comp ((determinantMultilinear (ฮน := ฮน) (๐•œ := ๐•œ)).restrictScalars โ„) (fun i => (hM i).hasFDerivAt) have hv := congrArg (fun L : E โ†’L[โ„] ๐•œ => L u) hd.fderiv change fderiv โ„ (fun y => (M y).det) x u = _ at hv simp only [sum_apply, ContinuousLinearMap.comp_apply, ContinuousMultilinearMap.toContinuousLinearMap_apply] at hv exact hv theorem determinant_updateRow_inverse (M H : Matrix ฮน ฮน ๐•œ) (hM : IsUnit M.det) (i : ฮน) : (M.updateRow i (H i)).det = (H * Mโปยน) i i * M.det := by have hr : H i = โˆ‘ j, (H * Mโปยน) i j โ€ข M j := by funext k simp only [Finset.sum_apply, Pi.smul_apply, smul_eq_mul] change H i k = ((H * Mโปยน) * M) i k rw [Matrix.mul_assoc, Matrix.nonsing_inv_mul M hM, Matrix.mul_one] rw [hr, Matrix.det_updateRow_sum, smul_eq_mul] theorem determinant_derivative_trace (M : E โ†’ Matrix ฮน ฮน ๐•œ) {x : E} (hM : โˆ€ i, DifferentiableAt โ„ (fun y => M y i) x) (hdet : IsUnit (M x).det) (u : E) : fderiv โ„ (fun y => (M y).det) x u = (M x).det * ((M x)โปยน * Matrix.of (fun i => fderiv โ„ (fun y => M y i) x u)).trace := by rw [determinant_derivative_rows M hM] calc _ = โˆ‘ i, (Matrix.of (fun j => fderiv โ„ (fun y => M y j) x u) * (M x)โปยน) i i * (M x).det := by apply Finset.sum_congr rfl intro i _ exact determinant_updateRow_inverse (M x) (Matrix.of (fun j => fderiv โ„ (fun y => M y j) x u)) hdet i _ = _ := by rw [โ† Finset.sum_mul] change (Matrix.trace (Matrix.of (fun i => fderiv โ„ (fun y => M y i) x u) * (M x)โปยน)) * (M x).det = _ rw [Matrix.trace_mul_comm, mul_comm] end end OAI.AlgebraicGeometry.ComplexMultiplication.HodgeComparison.DeterminantDerivative.CM.Construction