21 |
21 |
22 lemma has_derivative_of_real[derivative_intros, simp]: |
22 lemma has_derivative_of_real[derivative_intros, simp]: |
23 "(f has_derivative f') F \<Longrightarrow> ((\<lambda>x. of_real (f x)) has_derivative (\<lambda>x. of_real (f' x))) F" |
23 "(f has_derivative f') F \<Longrightarrow> ((\<lambda>x. of_real (f x)) has_derivative (\<lambda>x. of_real (f' x))) F" |
24 using bounded_linear.has_derivative[OF bounded_linear_of_real] . |
24 using bounded_linear.has_derivative[OF bounded_linear_of_real] . |
25 |
25 |
26 lemma has_vector_derivative_real_complex: |
26 lemma has_vector_derivative_real_field: |
27 "DERIV f (of_real a) :> f' \<Longrightarrow> ((\<lambda>x. f (of_real x)) has_vector_derivative f') (at a within s)" |
27 "DERIV f (of_real a) :> f' \<Longrightarrow> ((\<lambda>x. f (of_real x)) has_vector_derivative f') (at a within s)" |
28 using has_derivative_compose[of of_real of_real a _ f "op * f'"] |
28 using has_derivative_compose[of of_real of_real a _ f "op * f'"] |
29 by (simp add: scaleR_conv_of_real ac_simps has_vector_derivative_def has_field_derivative_def) |
29 by (simp add: scaleR_conv_of_real ac_simps has_vector_derivative_def has_field_derivative_def) |
|
30 lemmas has_vector_derivative_real_complex = has_vector_derivative_real_field |
30 |
31 |
31 lemma fact_cancel: |
32 lemma fact_cancel: |
32 fixes c :: "'a::real_field" |
33 fixes c :: "'a::real_field" |
33 shows "of_nat (Suc n) * c / (fact (Suc n)) = c / (fact n)" |
34 shows "of_nat (Suc n) * c / (fact (Suc n)) = c / (fact n)" |
34 by (simp add: of_nat_mult del: of_nat_Suc times_nat.simps) |
35 by (simp add: of_nat_mult del: of_nat_Suc times_nat.simps) |
122 and "\<forall>x\<in>(s - k). DERIV f x :> 0" |
123 and "\<forall>x\<in>(s - k). DERIV f x :> 0" |
123 obtains c where "\<And>x. x \<in> s \<Longrightarrow> f(x) = c" |
124 obtains c where "\<And>x. x \<in> s \<Longrightarrow> f(x) = c" |
124 using has_derivative_zero_connected_constant [OF assms(1-4)] assms |
125 using has_derivative_zero_connected_constant [OF assms(1-4)] assms |
125 by (metis DERIV_const has_derivative_const Diff_iff at_within_open frechet_derivative_at has_field_derivative_def) |
126 by (metis DERIV_const has_derivative_const Diff_iff at_within_open frechet_derivative_at has_field_derivative_def) |
126 |
127 |
127 lemma DERIV_zero_constant: |
128 lemmas DERIV_zero_constant = has_field_derivative_zero_constant |
128 fixes f :: "'a::{real_normed_field, real_inner} \<Rightarrow> 'a" |
|
129 shows "\<lbrakk>convex s; |
|
130 \<And>x. x\<in>s \<Longrightarrow> (f has_field_derivative 0) (at x within s)\<rbrakk> |
|
131 \<Longrightarrow> \<exists>c. \<forall>x \<in> s. f(x) = c" |
|
132 by (auto simp: has_field_derivative_def lambda_zero intro: has_derivative_zero_constant) |
|
133 |
129 |
134 lemma DERIV_zero_unique: |
130 lemma DERIV_zero_unique: |
135 fixes f :: "'a::{real_normed_field, real_inner} \<Rightarrow> 'a" |
|
136 assumes "convex s" |
131 assumes "convex s" |
137 and d0: "\<And>x. x\<in>s \<Longrightarrow> (f has_field_derivative 0) (at x within s)" |
132 and d0: "\<And>x. x\<in>s \<Longrightarrow> (f has_field_derivative 0) (at x within s)" |
138 and "a \<in> s" |
133 and "a \<in> s" |
139 and "x \<in> s" |
134 and "x \<in> s" |
140 shows "f x = f a" |
135 shows "f x = f a" |
141 by (rule has_derivative_zero_unique [OF assms(1) _ assms(4,3)]) |
136 by (rule has_derivative_zero_unique [OF assms(1) _ assms(4,3)]) |
142 (metis d0 has_field_derivative_imp_has_derivative lambda_zero) |
137 (metis d0 has_field_derivative_imp_has_derivative lambda_zero) |
143 |
138 |
144 lemma DERIV_zero_connected_unique: |
139 lemma DERIV_zero_connected_unique: |
145 fixes f :: "'a::{real_normed_field, real_inner} \<Rightarrow> 'a" |
|
146 assumes "connected s" |
140 assumes "connected s" |
147 and "open s" |
141 and "open s" |
148 and d0: "\<And>x. x\<in>s \<Longrightarrow> DERIV f x :> 0" |
142 and d0: "\<And>x. x\<in>s \<Longrightarrow> DERIV f x :> 0" |
149 and "a \<in> s" |
143 and "a \<in> s" |
150 and "x \<in> s" |
144 and "x \<in> s" |
175 shows "DERIV g a :> f'" |
169 shows "DERIV g a :> f'" |
176 by (blast intro: assms DERIV_transform_within) |
170 by (blast intro: assms DERIV_transform_within) |
177 |
171 |
178 (*generalising DERIV_isconst_all, which requires type real (using the ordering)*) |
172 (*generalising DERIV_isconst_all, which requires type real (using the ordering)*) |
179 lemma DERIV_zero_UNIV_unique: |
173 lemma DERIV_zero_UNIV_unique: |
180 fixes f :: "'a::{real_normed_field, real_inner} \<Rightarrow> 'a" |
174 "(\<And>x. DERIV f x :> 0) \<Longrightarrow> f x = f a" |
181 shows "(\<And>x. DERIV f x :> 0) \<Longrightarrow> f x = f a" |
175 by (metis DERIV_zero_unique UNIV_I convex_UNIV) |
182 by (metis DERIV_zero_unique UNIV_I convex_UNIV) |
|
183 |
176 |
184 subsection \<open>Some limit theorems about real part of real series etc.\<close> |
177 subsection \<open>Some limit theorems about real part of real series etc.\<close> |
185 |
178 |
186 (*MOVE? But not to Finite_Cartesian_Product*) |
179 (*MOVE? But not to Finite_Cartesian_Product*) |
187 lemma sums_vec_nth : |
180 lemma sums_vec_nth : |
877 thus "(\<lambda>x. \<Sum>n. f n x) field_differentiable (at x)" unfolding differentiable_def |
870 thus "(\<lambda>x. \<Sum>n. f n x) field_differentiable (at x)" unfolding differentiable_def |
878 by (auto simp: summable_def field_differentiable_def has_field_derivative_def) |
871 by (auto simp: summable_def field_differentiable_def has_field_derivative_def) |
879 qed |
872 qed |
880 |
873 |
881 lemma field_differentiable_series': |
874 lemma field_differentiable_series': |
882 fixes f :: "nat \<Rightarrow> complex \<Rightarrow> complex" |
875 fixes f :: "nat \<Rightarrow> 'a::{real_normed_field,banach} \<Rightarrow> 'a" |
883 assumes "convex s" "open s" |
876 assumes "convex s" "open s" |
884 assumes "\<And>n x. x \<in> s \<Longrightarrow> (f n has_field_derivative f' n x) (at x)" |
877 assumes "\<And>n x. x \<in> s \<Longrightarrow> (f n has_field_derivative f' n x) (at x)" |
885 assumes "uniformly_convergent_on s (\<lambda>n x. \<Sum>i<n. f' i x)" |
878 assumes "uniformly_convergent_on s (\<lambda>n x. \<Sum>i<n. f' i x)" |
886 assumes "x0 \<in> s" "summable (\<lambda>n. f n x0)" |
879 assumes "x0 \<in> s" "summable (\<lambda>n. f n x0)" |
887 shows "(\<lambda>x. \<Sum>n. f n x) field_differentiable (at x0)" |
880 shows "(\<lambda>x. \<Sum>n. f n x) field_differentiable (at x0)" |
888 using field_differentiable_series[OF assms, of x0] \<open>x0 \<in> s\<close> by blast+ |
881 using field_differentiable_series[OF assms, of x0] \<open>x0 \<in> s\<close> by blast+ |
889 |
882 |
890 subsection\<open>Bound theorem\<close> |
883 subsection\<open>Bound theorem\<close> |
891 |
884 |
892 lemma field_differentiable_bound: |
885 lemma field_differentiable_bound: |
893 fixes s :: "complex set" |
886 fixes s :: "'a::real_normed_field set" |
894 assumes cvs: "convex s" |
887 assumes cvs: "convex s" |
895 and df: "\<And>z. z \<in> s \<Longrightarrow> (f has_field_derivative f' z) (at z within s)" |
888 and df: "\<And>z. z \<in> s \<Longrightarrow> (f has_field_derivative f' z) (at z within s)" |
896 and dn: "\<And>z. z \<in> s \<Longrightarrow> norm (f' z) \<le> B" |
889 and dn: "\<And>z. z \<in> s \<Longrightarrow> norm (f' z) \<le> B" |
897 and "x \<in> s" "y \<in> s" |
890 and "x \<in> s" "y \<in> s" |
898 shows "norm(f x - f y) \<le> B * norm(x - y)" |
891 shows "norm(f x - f y) \<le> B * norm(x - y)" |
917 unfolding has_field_derivative_def |
909 unfolding has_field_derivative_def |
918 apply (rule has_derivative_inverse_basic) |
910 apply (rule has_derivative_inverse_basic) |
919 apply (auto simp: bounded_linear_mult_right) |
911 apply (auto simp: bounded_linear_mult_right) |
920 done |
912 done |
921 |
913 |
922 lemma has_complex_derivative_inverse_strong: |
914 lemmas has_complex_derivative_inverse_basic = has_field_derivative_inverse_basic |
923 fixes f :: "complex \<Rightarrow> complex" |
915 |
|
916 lemma has_field_derivative_inverse_strong: |
|
917 fixes f :: "'a::{euclidean_space,real_normed_field} \<Rightarrow> 'a" |
924 shows "DERIV f x :> f' \<Longrightarrow> |
918 shows "DERIV f x :> f' \<Longrightarrow> |
925 f' \<noteq> 0 \<Longrightarrow> |
919 f' \<noteq> 0 \<Longrightarrow> |
926 open s \<Longrightarrow> |
920 open s \<Longrightarrow> |
927 x \<in> s \<Longrightarrow> |
921 x \<in> s \<Longrightarrow> |
928 continuous_on s f \<Longrightarrow> |
922 continuous_on s f \<Longrightarrow> |
929 (\<And>z. z \<in> s \<Longrightarrow> g (f z) = z) |
923 (\<And>z. z \<in> s \<Longrightarrow> g (f z) = z) |
930 \<Longrightarrow> DERIV g (f x) :> inverse (f')" |
924 \<Longrightarrow> DERIV g (f x) :> inverse (f')" |
931 unfolding has_field_derivative_def |
925 unfolding has_field_derivative_def |
932 apply (rule has_derivative_inverse_strong [of s x f g ]) |
926 apply (rule has_derivative_inverse_strong [of s x f g ]) |
933 by auto |
927 by auto |
934 |
928 lemmas has_complex_derivative_inverse_strong = has_field_derivative_inverse_strong |
935 lemma has_complex_derivative_inverse_strong_x: |
929 |
936 fixes f :: "complex \<Rightarrow> complex" |
930 lemma has_field_derivative_inverse_strong_x: |
|
931 fixes f :: "'a::{euclidean_space,real_normed_field} \<Rightarrow> 'a" |
937 shows "DERIV f (g y) :> f' \<Longrightarrow> |
932 shows "DERIV f (g y) :> f' \<Longrightarrow> |
938 f' \<noteq> 0 \<Longrightarrow> |
933 f' \<noteq> 0 \<Longrightarrow> |
939 open s \<Longrightarrow> |
934 open s \<Longrightarrow> |
940 continuous_on s f \<Longrightarrow> |
935 continuous_on s f \<Longrightarrow> |
941 g y \<in> s \<Longrightarrow> f(g y) = y \<Longrightarrow> |
936 g y \<in> s \<Longrightarrow> f(g y) = y \<Longrightarrow> |
942 (\<And>z. z \<in> s \<Longrightarrow> g (f z) = z) |
937 (\<And>z. z \<in> s \<Longrightarrow> g (f z) = z) |
943 \<Longrightarrow> DERIV g y :> inverse (f')" |
938 \<Longrightarrow> DERIV g y :> inverse (f')" |
944 unfolding has_field_derivative_def |
939 unfolding has_field_derivative_def |
945 apply (rule has_derivative_inverse_strong_x [of s g y f]) |
940 apply (rule has_derivative_inverse_strong_x [of s g y f]) |
946 by auto |
941 by auto |
|
942 lemmas has_complex_derivative_inverse_strong_x = has_field_derivative_inverse_strong_x |
947 |
943 |
948 subsection \<open>Taylor on Complex Numbers\<close> |
944 subsection \<open>Taylor on Complex Numbers\<close> |
949 |
945 |
950 lemma sum_Suc_reindex: |
946 lemma sum_Suc_reindex: |
951 fixes f :: "nat \<Rightarrow> 'a::ab_group_add" |
947 fixes f :: "nat \<Rightarrow> 'a::ab_group_add" |
952 shows "sum f {0..n} = f 0 - f (Suc n) + sum (\<lambda>i. f (Suc i)) {0..n}" |
948 shows "sum f {0..n} = f 0 - f (Suc n) + sum (\<lambda>i. f (Suc i)) {0..n}" |
953 by (induct n) auto |
949 by (induct n) auto |
954 |
950 |
955 lemma complex_taylor: |
951 lemma field_taylor: |
956 assumes s: "convex s" |
952 assumes s: "convex s" |
957 and f: "\<And>i x. x \<in> s \<Longrightarrow> i \<le> n \<Longrightarrow> (f i has_field_derivative f (Suc i) x) (at x within s)" |
953 and f: "\<And>i x. x \<in> s \<Longrightarrow> i \<le> n \<Longrightarrow> (f i has_field_derivative f (Suc i) x) (at x within s)" |
958 and B: "\<And>x. x \<in> s \<Longrightarrow> cmod (f (Suc n) x) \<le> B" |
954 and B: "\<And>x. x \<in> s \<Longrightarrow> norm (f (Suc n) x) \<le> B" |
959 and w: "w \<in> s" |
955 and w: "w \<in> s" |
960 and z: "z \<in> s" |
956 and z: "z \<in> s" |
961 shows "cmod(f 0 z - (\<Sum>i\<le>n. f i w * (z-w) ^ i / (fact i))) |
957 shows "norm(f 0 z - (\<Sum>i\<le>n. f i w * (z-w) ^ i / (fact i))) |
962 \<le> B * cmod(z - w)^(Suc n) / fact n" |
958 \<le> B * norm(z - w)^(Suc n) / fact n" |
963 proof - |
959 proof - |
964 have wzs: "closed_segment w z \<subseteq> s" using assms |
960 have wzs: "closed_segment w z \<subseteq> s" using assms |
965 by (metis convex_contains_segment) |
961 by (metis convex_contains_segment) |
966 { fix u |
962 { fix u |
967 assume "u \<in> closed_segment w z" |
963 assume "u \<in> closed_segment w z" |
1016 } note sum_deriv = this |
1012 } note sum_deriv = this |
1017 { fix u |
1013 { fix u |
1018 assume u: "u \<in> closed_segment w z" |
1014 assume u: "u \<in> closed_segment w z" |
1019 then have us: "u \<in> s" |
1015 then have us: "u \<in> s" |
1020 by (metis wzs subsetD) |
1016 by (metis wzs subsetD) |
1021 have "cmod (f (Suc n) u) * cmod (z - u) ^ n \<le> cmod (f (Suc n) u) * cmod (u - z) ^ n" |
1017 have "norm (f (Suc n) u) * norm (z - u) ^ n \<le> norm (f (Suc n) u) * norm (u - z) ^ n" |
1022 by (metis norm_minus_commute order_refl) |
1018 by (metis norm_minus_commute order_refl) |
1023 also have "... \<le> cmod (f (Suc n) u) * cmod (z - w) ^ n" |
1019 also have "... \<le> norm (f (Suc n) u) * norm (z - w) ^ n" |
1024 by (metis mult_left_mono norm_ge_zero power_mono segment_bound [OF u]) |
1020 by (metis mult_left_mono norm_ge_zero power_mono segment_bound [OF u]) |
1025 also have "... \<le> B * cmod (z - w) ^ n" |
1021 also have "... \<le> B * norm (z - w) ^ n" |
1026 by (metis norm_ge_zero zero_le_power mult_right_mono B [OF us]) |
1022 by (metis norm_ge_zero zero_le_power mult_right_mono B [OF us]) |
1027 finally have "cmod (f (Suc n) u) * cmod (z - u) ^ n \<le> B * cmod (z - w) ^ n" . |
1023 finally have "norm (f (Suc n) u) * norm (z - u) ^ n \<le> B * norm (z - w) ^ n" . |
1028 } note cmod_bound = this |
1024 } note cmod_bound = this |
1029 have "(\<Sum>i\<le>n. f i z * (z - z) ^ i / (fact i)) = (\<Sum>i\<le>n. (f i z / (fact i)) * 0 ^ i)" |
1025 have "(\<Sum>i\<le>n. f i z * (z - z) ^ i / (fact i)) = (\<Sum>i\<le>n. (f i z / (fact i)) * 0 ^ i)" |
1030 by simp |
1026 by simp |
1031 also have "\<dots> = f 0 z / (fact 0)" |
1027 also have "\<dots> = f 0 z / (fact 0)" |
1032 by (subst sum_zero_power) simp |
1028 by (subst sum_zero_power) simp |
1033 finally have "cmod (f 0 z - (\<Sum>i\<le>n. f i w * (z - w) ^ i / (fact i))) |
1029 finally have "norm (f 0 z - (\<Sum>i\<le>n. f i w * (z - w) ^ i / (fact i))) |
1034 \<le> cmod ((\<Sum>i\<le>n. f i w * (z - w) ^ i / (fact i)) - |
1030 \<le> norm ((\<Sum>i\<le>n. f i w * (z - w) ^ i / (fact i)) - |
1035 (\<Sum>i\<le>n. f i z * (z - z) ^ i / (fact i)))" |
1031 (\<Sum>i\<le>n. f i z * (z - z) ^ i / (fact i)))" |
1036 by (simp add: norm_minus_commute) |
1032 by (simp add: norm_minus_commute) |
1037 also have "... \<le> B * cmod (z - w) ^ n / (fact n) * cmod (w - z)" |
1033 also have "... \<le> B * norm (z - w) ^ n / (fact n) * norm (w - z)" |
1038 apply (rule field_differentiable_bound |
1034 apply (rule field_differentiable_bound |
1039 [where f' = "\<lambda>w. f (Suc n) w * (z - w)^n / (fact n)" |
1035 [where f' = "\<lambda>w. f (Suc n) w * (z - w)^n / (fact n)" |
1040 and s = "closed_segment w z", OF convex_closed_segment]) |
1036 and s = "closed_segment w z", OF convex_closed_segment]) |
1041 apply (auto simp: ends_in_segment DERIV_subset [OF sum_deriv wzs] |
1037 apply (auto simp: ends_in_segment DERIV_subset [OF sum_deriv wzs] |
1042 norm_divide norm_mult norm_power divide_le_cancel cmod_bound) |
1038 norm_divide norm_mult norm_power divide_le_cancel cmod_bound) |
1043 done |
1039 done |
1044 also have "... \<le> B * cmod (z - w) ^ Suc n / (fact n)" |
1040 also have "... \<le> B * norm (z - w) ^ Suc n / (fact n)" |
1045 by (simp add: algebra_simps norm_minus_commute) |
1041 by (simp add: algebra_simps norm_minus_commute) |
1046 finally show ?thesis . |
1042 finally show ?thesis . |
1047 qed |
1043 qed |
|
1044 |
|
1045 lemma complex_taylor: |
|
1046 assumes s: "convex s" |
|
1047 and f: "\<And>i x. x \<in> s \<Longrightarrow> i \<le> n \<Longrightarrow> (f i has_field_derivative f (Suc i) x) (at x within s)" |
|
1048 and B: "\<And>x. x \<in> s \<Longrightarrow> cmod (f (Suc n) x) \<le> B" |
|
1049 and w: "w \<in> s" |
|
1050 and z: "z \<in> s" |
|
1051 shows "cmod(f 0 z - (\<Sum>i\<le>n. f i w * (z-w) ^ i / (fact i))) |
|
1052 \<le> B * cmod(z - w)^(Suc n) / fact n" |
|
1053 using assms by (rule field_taylor) |
|
1054 |
1048 |
1055 |
1049 text\<open>Something more like the traditional MVT for real components\<close> |
1056 text\<open>Something more like the traditional MVT for real components\<close> |
1050 |
1057 |
1051 lemma complex_mvt_line: |
1058 lemma complex_mvt_line: |
1052 assumes "\<And>u. u \<in> closed_segment w z \<Longrightarrow> (f has_field_derivative f'(u)) (at u)" |
1059 assumes "\<And>u. u \<in> closed_segment w z \<Longrightarrow> (f has_field_derivative f'(u)) (at u)" |