935 have "norm ((f \<circ> ?p) 1 - (f \<circ> ?p) 0) \<le> B * norm (x - y)" |
935 have "norm ((f \<circ> ?p) 1 - (f \<circ> ?p) 0) \<le> B * norm (x - y)" |
936 by simp |
936 by simp |
937 finally show ?thesis . |
937 finally show ?thesis . |
938 qed |
938 qed |
939 |
939 |
|
940 lemma field_differentiable_bound: |
|
941 fixes S :: "'a::real_normed_field set" |
|
942 assumes cvs: "convex S" |
|
943 and df: "\<And>z. z \<in> S \<Longrightarrow> (f has_field_derivative f' z) (at z within S)" |
|
944 and dn: "\<And>z. z \<in> S \<Longrightarrow> norm (f' z) \<le> B" |
|
945 and "x \<in> S" "y \<in> S" |
|
946 shows "norm(f x - f y) \<le> B * norm(x - y)" |
|
947 apply (rule differentiable_bound [OF cvs]) |
|
948 apply (erule df [unfolded has_field_derivative_def]) |
|
949 apply (rule onorm_le, simp_all add: norm_mult mult_right_mono assms) |
|
950 done |
|
951 |
940 lemma |
952 lemma |
941 differentiable_bound_segment: |
953 differentiable_bound_segment: |
942 fixes f::"'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector" |
954 fixes f::"'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector" |
943 assumes "\<And>t. t \<in> {0..1} \<Longrightarrow> x0 + t *\<^sub>R a \<in> G" |
955 assumes "\<And>t. t \<in> {0..1} \<Longrightarrow> x0 + t *\<^sub>R a \<in> G" |
944 assumes f': "\<And>x. x \<in> G \<Longrightarrow> (f has_derivative f' x) (at x within G)" |
956 assumes f': "\<And>x. x \<in> G \<Longrightarrow> (f has_derivative f' x) (at x within G)" |
1159 finally show "norm (g z - g y - g' (z - y)) \<le> e * norm (z - y)" |
1171 finally show "norm (g z - g y - g' (z - y)) \<le> e * norm (z - y)" |
1160 by simp |
1172 by simp |
1161 qed (use k in auto) |
1173 qed (use k in auto) |
1162 qed |
1174 qed |
1163 qed |
1175 qed |
|
1176 |
|
1177 text\<^marker>\<open>tag unimportant\<close>\<open>Inverse function theorem for complex derivatives\<close> |
|
1178 lemma has_field_derivative_inverse_basic: |
|
1179 shows "DERIV f (g y) :> f' \<Longrightarrow> |
|
1180 f' \<noteq> 0 \<Longrightarrow> |
|
1181 continuous (at y) g \<Longrightarrow> |
|
1182 open t \<Longrightarrow> |
|
1183 y \<in> t \<Longrightarrow> |
|
1184 (\<And>z. z \<in> t \<Longrightarrow> f (g z) = z) |
|
1185 \<Longrightarrow> DERIV g y :> inverse (f')" |
|
1186 unfolding has_field_derivative_def |
|
1187 apply (rule has_derivative_inverse_basic) |
|
1188 apply (auto simp: bounded_linear_mult_right) |
|
1189 done |
1164 |
1190 |
1165 text \<open>Simply rewrite that based on the domain point x.\<close> |
1191 text \<open>Simply rewrite that based on the domain point x.\<close> |
1166 |
1192 |
1167 lemma has_derivative_inverse_basic_x: |
1193 lemma has_derivative_inverse_basic_x: |
1168 fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector" |
1194 fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector" |
2173 |
2199 |
2174 lemma exp_scaleR_has_vector_derivative_left: "((\<lambda>t. exp (t *\<^sub>R A)) has_vector_derivative A * exp (t *\<^sub>R A)) (at t)" |
2200 lemma exp_scaleR_has_vector_derivative_left: "((\<lambda>t. exp (t *\<^sub>R A)) has_vector_derivative A * exp (t *\<^sub>R A)) (at t)" |
2175 using exp_scaleR_has_vector_derivative_right[of A t] |
2201 using exp_scaleR_has_vector_derivative_right[of A t] |
2176 by (simp add: exp_times_scaleR_commute) |
2202 by (simp add: exp_times_scaleR_commute) |
2177 |
2203 |
|
2204 lemma field_differentiable_series: |
|
2205 fixes f :: "nat \<Rightarrow> 'a::{real_normed_field,banach} \<Rightarrow> 'a" |
|
2206 assumes "convex S" "open S" |
|
2207 assumes "\<And>n x. x \<in> S \<Longrightarrow> (f n has_field_derivative f' n x) (at x)" |
|
2208 assumes "uniformly_convergent_on S (\<lambda>n x. \<Sum>i<n. f' i x)" |
|
2209 assumes "x0 \<in> S" "summable (\<lambda>n. f n x0)" and x: "x \<in> S" |
|
2210 shows "(\<lambda>x. \<Sum>n. f n x) field_differentiable (at x)" |
|
2211 proof - |
|
2212 from assms(4) obtain g' where A: "uniform_limit S (\<lambda>n x. \<Sum>i<n. f' i x) g' sequentially" |
|
2213 unfolding uniformly_convergent_on_def by blast |
|
2214 from x and \<open>open S\<close> have S: "at x within S = at x" by (rule at_within_open) |
|
2215 have "\<exists>g. \<forall>x\<in>S. (\<lambda>n. f n x) sums g x \<and> (g has_field_derivative g' x) (at x within S)" |
|
2216 by (intro has_field_derivative_series[of S f f' g' x0] assms A has_field_derivative_at_within) |
|
2217 then obtain g where g: "\<And>x. x \<in> S \<Longrightarrow> (\<lambda>n. f n x) sums g x" |
|
2218 "\<And>x. x \<in> S \<Longrightarrow> (g has_field_derivative g' x) (at x within S)" by blast |
|
2219 from g(2)[OF x] have g': "(g has_derivative (*) (g' x)) (at x)" |
|
2220 by (simp add: has_field_derivative_def S) |
|
2221 have "((\<lambda>x. \<Sum>n. f n x) has_derivative (*) (g' x)) (at x)" |
|
2222 by (rule has_derivative_transform_within_open[OF g' \<open>open S\<close> x]) |
|
2223 (insert g, auto simp: sums_iff) |
|
2224 thus "(\<lambda>x. \<Sum>n. f n x) field_differentiable (at x)" unfolding differentiable_def |
|
2225 by (auto simp: summable_def field_differentiable_def has_field_derivative_def) |
|
2226 qed |
|
2227 |
|
2228 subsubsection\<^marker>\<open>tag unimportant\<close>\<open>Caratheodory characterization\<close> |
|
2229 |
|
2230 lemma field_differentiable_caratheodory_at: |
|
2231 "f field_differentiable (at z) \<longleftrightarrow> |
|
2232 (\<exists>g. (\<forall>w. f(w) - f(z) = g(w) * (w - z)) \<and> continuous (at z) g)" |
|
2233 using CARAT_DERIV [of f] |
|
2234 by (simp add: field_differentiable_def has_field_derivative_def) |
|
2235 |
|
2236 lemma field_differentiable_caratheodory_within: |
|
2237 "f field_differentiable (at z within s) \<longleftrightarrow> |
|
2238 (\<exists>g. (\<forall>w. f(w) - f(z) = g(w) * (w - z)) \<and> continuous (at z within s) g)" |
|
2239 using DERIV_caratheodory_within [of f] |
|
2240 by (simp add: field_differentiable_def has_field_derivative_def) |
|
2241 |
|
2242 |
2178 subsection \<open>Field derivative\<close> |
2243 subsection \<open>Field derivative\<close> |
2179 |
2244 |
2180 definition\<^marker>\<open>tag important\<close> deriv :: "('a \<Rightarrow> 'a::real_normed_field) \<Rightarrow> 'a \<Rightarrow> 'a" where |
2245 definition\<^marker>\<open>tag important\<close> deriv :: "('a \<Rightarrow> 'a::real_normed_field) \<Rightarrow> 'a \<Rightarrow> 'a" where |
2181 "deriv f x \<equiv> SOME D. DERIV f x :> D" |
2246 "deriv f x \<equiv> SOME D. DERIV f x :> D" |
2182 |
2247 |
2233 lemma vector_derivative_chain_at_general: |
2298 lemma vector_derivative_chain_at_general: |
2234 assumes "f differentiable at x" "g field_differentiable at (f x)" |
2299 assumes "f differentiable at x" "g field_differentiable at (f x)" |
2235 shows "vector_derivative (g \<circ> f) (at x) = vector_derivative f (at x) * deriv g (f x)" |
2300 shows "vector_derivative (g \<circ> f) (at x) = vector_derivative f (at x) * deriv g (f x)" |
2236 apply (rule vector_derivative_at [OF field_vector_diff_chain_at]) |
2301 apply (rule vector_derivative_at [OF field_vector_diff_chain_at]) |
2237 using assms vector_derivative_works by (auto simp: field_differentiable_derivI) |
2302 using assms vector_derivative_works by (auto simp: field_differentiable_derivI) |
2238 |
|
2239 |
2303 |
2240 subsection \<open>Relation between convexity and derivative\<close> |
2304 subsection \<open>Relation between convexity and derivative\<close> |
2241 |
2305 |
2242 (* TODO: Generalise to real vector spaces? *) |
2306 (* TODO: Generalise to real vector spaces? *) |
2243 proposition convex_on_imp_above_tangent: |
2307 proposition convex_on_imp_above_tangent: |