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

Lemma derivable_pt_lim_comp_2d : forall f1 f2 f3 x l1x l1y l2 l3,
differentiable_pt_lim f1 (f2 x) (f3 x) l1x l1y ->
derivable_pt_lim f2 x l2 -> derivable_pt_lim f3 x l3 ->
derivable_pt_lim (fun t => f1 (f2 t) (f3 t)) x (l1x * l2 + l1y * l3).