(** 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.

(* Specifications: *)
Lemma filterdiff_differentiable_pt_lim (f : R -> R -> R) (x y lx ly : R) :
filterdiff (fun u : R * R => f (fst u) (snd u)) (locally (x,y)) (fun u : R * R => fst u * lx + snd u * ly)
<-> differentiable_pt_lim f x y lx ly.
Lemma differentiable_pt_lim_ext : forall f1 f2 x y lx ly,
locally_2d (fun u v => f1 u v = f2 u v) x y ->
differentiable_pt_lim f1 x y lx ly -> differentiable_pt_lim f2 x y lx ly.