36 lemma has_derivative_eq_rhs: "(f has_derivative f') F \<Longrightarrow> f' = g' \<Longrightarrow> (f has_derivative g') F" |
36 lemma has_derivative_eq_rhs: "(f has_derivative f') F \<Longrightarrow> f' = g' \<Longrightarrow> (f has_derivative g') F" |
37 by simp |
37 by simp |
38 |
38 |
39 definition has_field_derivative :: "('a::real_normed_field \<Rightarrow> 'a) \<Rightarrow> 'a \<Rightarrow> 'a filter \<Rightarrow> bool" |
39 definition has_field_derivative :: "('a::real_normed_field \<Rightarrow> 'a) \<Rightarrow> 'a \<Rightarrow> 'a filter \<Rightarrow> bool" |
40 (infix "(has'_field'_derivative)" 50) |
40 (infix "(has'_field'_derivative)" 50) |
41 where "(f has_field_derivative D) F \<longleftrightarrow> (f has_derivative ( * ) D) F" |
41 where "(f has_field_derivative D) F \<longleftrightarrow> (f has_derivative (*) D) F" |
42 |
42 |
43 lemma DERIV_cong: "(f has_field_derivative X) F \<Longrightarrow> X = Y \<Longrightarrow> (f has_field_derivative Y) F" |
43 lemma DERIV_cong: "(f has_field_derivative X) F \<Longrightarrow> X = Y \<Longrightarrow> (f has_field_derivative Y) F" |
44 by simp |
44 by simp |
45 |
45 |
46 definition has_vector_derivative :: "(real \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> 'b \<Rightarrow> real filter \<Rightarrow> bool" |
46 definition has_vector_derivative :: "(real \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> 'b \<Rightarrow> real filter \<Rightarrow> bool" |
151 (bounded_linear D \<and> (\<lambda>h. norm (f (x + h) - f x - D h) / norm h) \<midarrow>0\<rightarrow> 0)" |
151 (bounded_linear D \<and> (\<lambda>h. norm (f (x + h) - f x - D h) / norm h) \<midarrow>0\<rightarrow> 0)" |
152 unfolding has_derivative_iff_norm LIM_offset_zero_iff[of _ _ x] by simp |
152 unfolding has_derivative_iff_norm LIM_offset_zero_iff[of _ _ x] by simp |
153 |
153 |
154 lemma field_has_derivative_at: |
154 lemma field_has_derivative_at: |
155 fixes x :: "'a::real_normed_field" |
155 fixes x :: "'a::real_normed_field" |
156 shows "(f has_derivative ( * ) D) (at x) \<longleftrightarrow> (\<lambda>h. (f (x + h) - f x) / h) \<midarrow>0\<rightarrow> D" (is "?lhs = ?rhs") |
156 shows "(f has_derivative (*) D) (at x) \<longleftrightarrow> (\<lambda>h. (f (x + h) - f x) / h) \<midarrow>0\<rightarrow> D" (is "?lhs = ?rhs") |
157 proof - |
157 proof - |
158 have "?lhs = (\<lambda>h. norm (f (x + h) - f x - D * h) / norm h) \<midarrow>0 \<rightarrow> 0" |
158 have "?lhs = (\<lambda>h. norm (f (x + h) - f x - D * h) / norm h) \<midarrow>0 \<rightarrow> 0" |
159 by (simp add: bounded_linear_mult_right has_derivative_at) |
159 by (simp add: bounded_linear_mult_right has_derivative_at) |
160 also have "... = (\<lambda>y. norm ((f (x + y) - f x - D * y) / y)) \<midarrow>0\<rightarrow> 0" |
160 also have "... = (\<lambda>y. norm ((f (x + y) - f x - D * y) / y)) \<midarrow>0\<rightarrow> 0" |
161 by (simp cong: LIM_cong flip: nonzero_norm_divide) |
161 by (simp cong: LIM_cong flip: nonzero_norm_divide) |
646 "(f has_derivative D) F \<Longrightarrow> (\<And>x. x * D' = D x) \<Longrightarrow> (f has_field_derivative D') F" |
646 "(f has_derivative D) F \<Longrightarrow> (\<And>x. x * D' = D x) \<Longrightarrow> (f has_field_derivative D') F" |
647 unfolding has_field_derivative_def |
647 unfolding has_field_derivative_def |
648 by (rule has_derivative_eq_rhs[of f D]) (simp_all add: fun_eq_iff mult.commute) |
648 by (rule has_derivative_eq_rhs[of f D]) (simp_all add: fun_eq_iff mult.commute) |
649 |
649 |
650 lemma has_field_derivative_imp_has_derivative: |
650 lemma has_field_derivative_imp_has_derivative: |
651 "(f has_field_derivative D) F \<Longrightarrow> (f has_derivative ( * ) D) F" |
651 "(f has_field_derivative D) F \<Longrightarrow> (f has_derivative (*) D) F" |
652 by (simp add: has_field_derivative_def) |
652 by (simp add: has_field_derivative_def) |
653 |
653 |
654 lemma DERIV_subset: |
654 lemma DERIV_subset: |
655 "(f has_field_derivative f') (at x within s) \<Longrightarrow> t \<subseteq> s \<Longrightarrow> |
655 "(f has_field_derivative f') (at x within s) \<Longrightarrow> t \<subseteq> s \<Longrightarrow> |
656 (f has_field_derivative f') (at x within t)" |
656 (f has_field_derivative f') (at x within t)" |
673 "f differentiable at x within s \<longleftrightarrow> (\<exists>D. (f has_real_derivative D) (at x within s))" |
673 "f differentiable at x within s \<longleftrightarrow> (\<exists>D. (f has_real_derivative D) (at x within s))" |
674 proof safe |
674 proof safe |
675 assume "f differentiable at x within s" |
675 assume "f differentiable at x within s" |
676 then obtain f' where *: "(f has_derivative f') (at x within s)" |
676 then obtain f' where *: "(f has_derivative f') (at x within s)" |
677 unfolding differentiable_def by auto |
677 unfolding differentiable_def by auto |
678 then obtain c where "f' = (( * ) c)" |
678 then obtain c where "f' = ((*) c)" |
679 by (metis real_bounded_linear has_derivative_bounded_linear mult.commute fun_eq_iff) |
679 by (metis real_bounded_linear has_derivative_bounded_linear mult.commute fun_eq_iff) |
680 with * show "\<exists>D. (f has_real_derivative D) (at x within s)" |
680 with * show "\<exists>D. (f has_real_derivative D) (at x within s)" |
681 unfolding has_field_derivative_def by auto |
681 unfolding has_field_derivative_def by auto |
682 qed (auto simp: differentiable_def has_field_derivative_def) |
682 qed (auto simp: differentiable_def has_field_derivative_def) |
683 |
683 |
700 qed |
700 qed |
701 |
701 |
702 lemma DERIV_def: "DERIV f x :> D \<longleftrightarrow> (\<lambda>h. (f (x + h) - f x) / h) \<midarrow>0\<rightarrow> D" |
702 lemma DERIV_def: "DERIV f x :> D \<longleftrightarrow> (\<lambda>h. (f (x + h) - f x) / h) \<midarrow>0\<rightarrow> D" |
703 unfolding field_has_derivative_at has_field_derivative_def has_field_derivative_iff .. |
703 unfolding field_has_derivative_at has_field_derivative_def has_field_derivative_iff .. |
704 |
704 |
705 lemma mult_commute_abs: "(\<lambda>x. x * c) = ( * ) c" |
705 lemma mult_commute_abs: "(\<lambda>x. x * c) = (*) c" |
706 for c :: "'a::ab_semigroup_mult" |
706 for c :: "'a::ab_semigroup_mult" |
707 by (simp add: fun_eq_iff mult.commute) |
707 by (simp add: fun_eq_iff mult.commute) |
708 |
708 |
709 lemma DERIV_compose_FDERIV: |
709 lemma DERIV_compose_FDERIV: |
710 fixes f::"real\<Rightarrow>real" |
710 fixes f::"real\<Rightarrow>real" |
711 assumes "DERIV f (g x) :> f'" |
711 assumes "DERIV f (g x) :> f'" |
712 assumes "(g has_derivative g') (at x within s)" |
712 assumes "(g has_derivative g') (at x within s)" |
713 shows "((\<lambda>x. f (g x)) has_derivative (\<lambda>x. g' x * f')) (at x within s)" |
713 shows "((\<lambda>x. f (g x)) has_derivative (\<lambda>x. g' x * f')) (at x within s)" |
714 using assms has_derivative_compose[of g g' x s f "( * ) f'"] |
714 using assms has_derivative_compose[of g g' x s f "(*) f'"] |
715 by (auto simp: has_field_derivative_def ac_simps) |
715 by (auto simp: has_field_derivative_def ac_simps) |
716 |
716 |
717 |
717 |
718 subsection \<open>Vector derivative\<close> |
718 subsection \<open>Vector derivative\<close> |
719 |
719 |
894 lemma DERIV_cmult_right: |
894 lemma DERIV_cmult_right: |
895 "(f has_field_derivative D) (at x within s) \<Longrightarrow> |
895 "(f has_field_derivative D) (at x within s) \<Longrightarrow> |
896 ((\<lambda>x. f x * c) has_field_derivative D * c) (at x within s)" |
896 ((\<lambda>x. f x * c) has_field_derivative D * c) (at x within s)" |
897 using DERIV_cmult by (auto simp add: ac_simps) |
897 using DERIV_cmult by (auto simp add: ac_simps) |
898 |
898 |
899 lemma DERIV_cmult_Id [simp]: "(( * ) c has_field_derivative c) (at x within s)" |
899 lemma DERIV_cmult_Id [simp]: "((*) c has_field_derivative c) (at x within s)" |
900 using DERIV_ident [THEN DERIV_cmult, where c = c and x = x] by simp |
900 using DERIV_ident [THEN DERIV_cmult, where c = c and x = x] by simp |
901 |
901 |
902 lemma DERIV_cdivide: |
902 lemma DERIV_cdivide: |
903 "(f has_field_derivative D) (at x within s) \<Longrightarrow> |
903 "(f has_field_derivative D) (at x within s) \<Longrightarrow> |
904 ((\<lambda>x. f x / c) has_field_derivative D / c) (at x within s)" |
904 ((\<lambda>x. f x / c) has_field_derivative D / c) (at x within s)" |
917 assumes "(f has_field_derivative D) (at x within s)" |
917 assumes "(f has_field_derivative D) (at x within s)" |
918 and "f x \<noteq> 0" |
918 and "f x \<noteq> 0" |
919 shows "((\<lambda>x. inverse (f x)) has_field_derivative - (inverse (f x) * D * inverse (f x))) |
919 shows "((\<lambda>x. inverse (f x)) has_field_derivative - (inverse (f x) * D * inverse (f x))) |
920 (at x within s)" |
920 (at x within s)" |
921 proof - |
921 proof - |
922 have "(f has_derivative (\<lambda>x. x * D)) = (f has_derivative ( * ) D)" |
922 have "(f has_derivative (\<lambda>x. x * D)) = (f has_derivative (*) D)" |
923 by (rule arg_cong [of "\<lambda>x. x * D"]) (simp add: fun_eq_iff) |
923 by (rule arg_cong [of "\<lambda>x. x * D"]) (simp add: fun_eq_iff) |
924 with assms have "(f has_derivative (\<lambda>x. x * D)) (at x within s)" |
924 with assms have "(f has_derivative (\<lambda>x. x * D)) (at x within s)" |
925 by (auto dest!: has_field_derivative_imp_has_derivative) |
925 by (auto dest!: has_field_derivative_imp_has_derivative) |
926 then show ?thesis using \<open>f x \<noteq> 0\<close> |
926 then show ?thesis using \<open>f x \<noteq> 0\<close> |
927 by (auto intro: has_derivative_imp_has_field_derivative has_derivative_inverse) |
927 by (auto intro: has_derivative_imp_has_field_derivative has_derivative_inverse) |
970 lemma DERIV_pow: "((\<lambda>x. x ^ n) has_field_derivative real n * (x ^ (n - Suc 0))) (at x within s)" |
970 lemma DERIV_pow: "((\<lambda>x. x ^ n) has_field_derivative real n * (x ^ (n - Suc 0))) (at x within s)" |
971 using DERIV_power [OF DERIV_ident] by simp |
971 using DERIV_power [OF DERIV_ident] by simp |
972 |
972 |
973 lemma DERIV_chain': "(f has_field_derivative D) (at x within s) \<Longrightarrow> DERIV g (f x) :> E \<Longrightarrow> |
973 lemma DERIV_chain': "(f has_field_derivative D) (at x within s) \<Longrightarrow> DERIV g (f x) :> E \<Longrightarrow> |
974 ((\<lambda>x. g (f x)) has_field_derivative E * D) (at x within s)" |
974 ((\<lambda>x. g (f x)) has_field_derivative E * D) (at x within s)" |
975 using has_derivative_compose[of f "( * ) D" x s g "( * ) E"] |
975 using has_derivative_compose[of f "(*) D" x s g "(*) E"] |
976 by (simp only: has_field_derivative_def mult_commute_abs ac_simps) |
976 by (simp only: has_field_derivative_def mult_commute_abs ac_simps) |
977 |
977 |
978 corollary DERIV_chain2: "DERIV f (g x) :> Da \<Longrightarrow> (g has_field_derivative Db) (at x within s) \<Longrightarrow> |
978 corollary DERIV_chain2: "DERIV f (g x) :> Da \<Longrightarrow> (g has_field_derivative Db) (at x within s) \<Longrightarrow> |
979 ((\<lambda>x. f (g x)) has_field_derivative Da * Db) (at x within s)" |
979 ((\<lambda>x. f (g x)) has_field_derivative Da * Db) (at x within s)" |
980 by (rule DERIV_chain') |
980 by (rule DERIV_chain') |
988 |
988 |
989 lemma DERIV_image_chain: |
989 lemma DERIV_image_chain: |
990 "(f has_field_derivative Da) (at (g x) within (g ` s)) \<Longrightarrow> |
990 "(f has_field_derivative Da) (at (g x) within (g ` s)) \<Longrightarrow> |
991 (g has_field_derivative Db) (at x within s) \<Longrightarrow> |
991 (g has_field_derivative Db) (at x within s) \<Longrightarrow> |
992 (f \<circ> g has_field_derivative Da * Db) (at x within s)" |
992 (f \<circ> g has_field_derivative Da * Db) (at x within s)" |
993 using has_derivative_in_compose [of g "( * ) Db" x s f "( * ) Da "] |
993 using has_derivative_in_compose [of g "(*) Db" x s f "(*) Da "] |
994 by (simp add: has_field_derivative_def o_def mult_commute_abs ac_simps) |
994 by (simp add: has_field_derivative_def o_def mult_commute_abs ac_simps) |
995 |
995 |
996 (*These two are from HOL Light: HAS_COMPLEX_DERIVATIVE_CHAIN*) |
996 (*These two are from HOL Light: HAS_COMPLEX_DERIVATIVE_CHAIN*) |
997 lemma DERIV_chain_s: |
997 lemma DERIV_chain_s: |
998 assumes "(\<And>x. x \<in> s \<Longrightarrow> DERIV g x :> g'(x))" |
998 assumes "(\<And>x. x \<in> s \<Longrightarrow> DERIV g x :> g'(x))" |