(** This file is part of the Coquelicot formalization of real analysis in Coq: http://coquelicot.saclay.inria.fr/  Copyright (C) 2011-2015 Sylvie Boldo #<br /># Copyright (C) 2011-2015 Catherine Lelay #<br /># Copyright (C) 2011-2015 Guillaume Melquiond  This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the COPYING file for more details. *)
(** This file describes results about differentiability in [R x R]. This includes the [Schwarz] theorem and the 2D Taylor-Lagrange inequality. *)
(** * Differentiability *)
Definition differentiable_pt_lim (f : R -> R -> R) (x y : R) (lx ly : R) :=
forall eps : posreal, locally_2d (fun u v =>
Rabs (f u v - f x y - (lx * (u - x) + ly * (v - y))) <= eps * Rmax (Rabs (u - x)) (Rabs (v - y))) x y.
Definition differentiable_pt (f : R -> R -> R) (x y : R) :=
exists lx, exists ly, differentiable_pt_lim f x y lx ly.
(** * Operations *)
(** * Partial derivatives *)
Definition partial_derive (m k : nat) (f : R -> R -> R) : R -> R -> R :=
fun x y => Derive_n (fun t => Derive_n (fun z => f t z) k y) m x.
Definition differential (p : nat) (f : R -> R -> R) (x y dx dy : R) : R :=
sum_f_R0
(fun m =>
C p m *
partial_derive m (p - m)%nat f x y *
dx ^ m * dy ^ (p - m)%nat)
p.
Definition DL_pol (n : nat) (f : R -> R -> R) (x y dx dy : R) : R :=
sum_f_R0
(fun p =>
differential p f x y dx dy / INR (fact p))
n.
(** * Schwarz theorem *)

Lemma Schwarz :
forall (f : R -> R -> R) x y,
locally_2d (fun u v =>
ex_derive (fun z : R => f z v) u /\
ex_derive (fun z : R => f u z) v /\
ex_derive (fun z : R => Derive (fun t => f z t) v) u /\
ex_derive (fun z : R => Derive (fun t => f t z) u) v) x y ->
continuity_2d_pt (fun u v => Derive (fun z => Derive (fun t => f z t) v) u) x y ->
continuity_2d_pt (fun u v => Derive (fun z => Derive (fun t => f t z) u) v) x y ->
Derive (fun z => Derive (fun t => f z t) y) x = Derive (fun z => Derive (fun t => f t z) x) y.