text\<open>By John Harrison et al. Ported from HOL Light by L C Paulson (2015)\<close>
theory Complex_Transcendental imports
Complex_Analysis_Basics Summation_Tests "HOL-Library.Periodic_Fun" begin
subsection\<open>Möbius transformations\<close>
(* TODO: Figure out what to do with Möbius transformations *) definition\<^marker>\<open>tag important\<close> "moebius a b c d \<equiv> (\<lambda>z. (a*z+b) / (c*z+d :: 'a :: field))"
theorem moebius_inverse: assumes"a * d \ b * c" "c * z + d \ 0" shows"moebius d (-b) (-c) a (moebius a b c d z) = z" proof - from assms have"(-c) * moebius a b c d z + a \ 0" unfolding moebius_def by (simp add: field_simps) with assms show ?thesis unfolding moebius_def by (simp add: moebius_def divide_simps) (simp add: algebra_simps)? qed
lemma moebius_inverse': assumes"a * d \ b * c" "c * z - a \ 0" shows"moebius a b c d (moebius d (-b) (-c) a z) = z" using assms moebius_inverse[of d a "-b""-c" z] by (auto simp: algebra_simps)
lemma cmod_add_real_less: assumes"Im z \ 0" "r\0" shows"cmod (z + r) < cmod z + \r\" proof (cases z) case (Complex x y) thenhave"0 < y * y" using assms mult_neg_neg by force with assms have"r * x / \r\ < sqrt (x*x + y*y)" by (simp add: real_less_rsqrt power2_eq_square) thenshow ?thesis using assms Complex apply (simp add: cmod_def) apply (rule power2_less_imp_less, auto) apply (simp add: power2_eq_square field_simps) done qed
lemma cmod_diff_real_less: "Im z \ 0 \ x\0 \ cmod (z - x) < cmod z + \x\" using cmod_add_real_less [of z "-x"] by simp
lemma cmod_square_less_1_plus: assumes"Im z = 0 \ \Re z\ < 1" shows"(cmod z)\<^sup>2 < 1 + cmod (1 - z\<^sup>2)" proof (cases "Im z = 0 \ Re z = 0") case True with assms abs_square_less_1 show ?thesis by (force simp add: Re_power2 Im_power2 cmod_def) next case False with cmod_diff_real_less [of "1 - z\<^sup>2" "1"] show ?thesis by (simp add: norm_power Im_power2) qed
lemma norm_exp_imaginary: "norm(exp z) = 1 \ Re z = 0" by simp
lemma field_differentiable_within_exp: "exp field_differentiable (at z within s)" using DERIV_exp field_differentiable_at_within field_differentiable_def by blast
lemma continuous_within_exp: fixes z::"'a::{real_normed_field,banach}" shows"continuous (at z within s) exp" by (simp add: continuous_at_imp_continuous_within)
lemma assumes"\w. w \ A \ exp (f w) = w" assumes"f holomorphic_on A""z \ A" "open A" shows deriv_complex_logarithm: "deriv f z = 1 / z" and has_field_derivative_complex_logarithm: "(f has_field_derivative 1 / z) (at z)" proof - have [simp]: "z \ 0" using assms(1)[of z] assms(3) by auto have deriv [derivative_intros]: "(f has_field_derivative deriv f z) (at z)" using assms holomorphic_derivI by blast have"((\w. w) has_field_derivative 1) (at z)" by (intro derivative_intros) alsohave"?this \ ((\w. exp (f w)) has_field_derivative 1) (at z)" by (smt (verit, best) assms has_field_derivative_transform_within_open) finallyhave"((\w. exp (f w)) has_field_derivative 1) (at z)" . moreoverhave"((\w. exp (f w)) has_field_derivative exp (f z) * deriv f z) (at z)" by (rule derivative_eq_intros refl)+ ultimatelyhave"exp (f z) * deriv f z = 1" using DERIV_unique by blast with assms show"deriv f z = 1 / z" by (simp add: field_simps) with deriv show"(f has_field_derivative 1 / z) (at z)" by simp qed
subsection\<open>Euler and de Moivre formulas\<close>
text\<open>The sine series times \<^term>\<open>i\<close>\<close> lemma sin_i_eq: "(\n. (\ * sin_coeff n) * z^n) sums (\ * sin z)" proof - have"(\n. \ * sin_coeff n *\<^sub>R z^n) sums (\ * sin z)" using sin_converges sums_mult by blast thenshow ?thesis by (simp add: scaleR_conv_of_real field_simps) qed
theorem exp_Euler: "exp(\ * z) = cos(z) + \ * sin(z)" proof - have"(\n. (cos_coeff n + \ * sin_coeff n) * z^n) = (\n. (\ * z) ^ n /\<^sub>R (fact n))" by (force simp: cos_coeff_def sin_coeff_def scaleR_conv_of_real field_simps elim!: evenE oddE) alsohave"\ sums (exp (\ * z))" by (rule exp_converges) finallyhave"(\n. (cos_coeff n + \ * sin_coeff n) * z^n) sums (exp (\ * z))" . moreoverhave"(\n. (cos_coeff n + \ * sin_coeff n) * z^n) sums (cos z + \ * sin z)" using sums_add [OF cos_converges [of z] sin_i_eq [of z]] by (simp add: field_simps scaleR_conv_of_real) ultimatelyshow ?thesis using sums_unique2 by blast qed
corollary\<^marker>\<open>tag unimportant\<close> exp_minus_Euler: "exp(-(\<i> * z)) = cos(z) - \<i> * sin(z)" using exp_Euler [of "-z"] by simp
lemma sin_exp_eq: "sin z = (exp(\ * z) - exp(-(\ * z))) / (2*\)" by (simp add: exp_Euler exp_minus_Euler)
lemma field_differentiable_at_sin: "sin field_differentiable at z" using DERIV_sin field_differentiable_def by blast
lemma field_differentiable_within_sin: "sin field_differentiable (at z within S)" by (simp add: field_differentiable_at_sin field_differentiable_at_within)
lemma field_differentiable_at_cos: "cos field_differentiable at z" using DERIV_cos field_differentiable_def by blast
lemma field_differentiable_within_cos: "cos field_differentiable (at z within S)" by (simp add: field_differentiable_at_cos field_differentiable_at_within)
lemma holomorphic_on_sin: "sin holomorphic_on S" by (simp add: field_differentiable_within_sin holomorphic_on_def)
lemma holomorphic_on_cos: "cos holomorphic_on S" by (simp add: field_differentiable_within_cos holomorphic_on_def)
lemma holomorphic_on_sin' [holomorphic_intros]: assumes"f holomorphic_on A" shows"(\x. sin (f x)) holomorphic_on A" using holomorphic_on_compose[OF assms holomorphic_on_sin] by (simp add: o_def)
lemma holomorphic_on_cos' [holomorphic_intros]: assumes"f holomorphic_on A" shows"(\x. cos (f x)) holomorphic_on A" using holomorphic_on_compose[OF assms holomorphic_on_cos] by (simp add: o_def)
lemma analytic_on_sin [analytic_intros]: "f analytic_on A \ (\w. sin (f w)) analytic_on A" and analytic_on_cos [analytic_intros]: "f analytic_on A \ (\w. cos (f w)) analytic_on A" and analytic_on_sinh [analytic_intros]: "f analytic_on A \ (\w. sinh (f w)) analytic_on A" and analytic_on_cosh [analytic_intros]: "f analytic_on A \ (\w. cosh (f w)) analytic_on A" unfolding sin_exp_eq cos_exp_eq sinh_def cosh_def by (auto intro!: analytic_intros)
lemma analytic_on_tan [analytic_intros]: "f analytic_on A \ (\z. z \ A \ cos (f z) \ 0) \ (\w. tan (f w)) analytic_on A" and analytic_on_cot [analytic_intros]: "f analytic_on A \ (\z. z \ A \ sin (f z) \ 0) \ (\w. cot (f w)) analytic_on A" and analytic_on_tanh [analytic_intros]: "f analytic_on A \ (\z. z \ A \ cosh (f z) \ 0) \ (\w. tanh (f w)) analytic_on A" unfolding tan_def cot_def tanh_def by (auto intro!: analytic_intros)
subsection\<^marker>\<open>tag unimportant\<close>\<open>More on the Polar Representation of Complex Numbers\<close>
lemma exp_Complex: "exp(Complex r t) = of_real(exp r) * Complex (cos t) (sin t)" using Complex_eq Euler complex.sel by presburger
lemma exp_eq_1: "exp z = 1 \ Re(z) = 0 \ (\n::int. Im(z) = of_int (2 * n) * pi)"
(is"?lhs = ?rhs") proof assume"exp z = 1" thenhave"Re z = 0" by (metis exp_eq_one_iff norm_exp_eq_Re norm_one) with\<open>?lhs\<close> show ?rhs by (metis Re_exp cos_one_2pi_int exp_zero mult.commute mult_1 of_int_mult of_int_numeral one_complex.simps(1)) next assume ?rhs thenshow ?lhs using Im_exp Re_exp complex_eq_iff by (simp add: cos_one_2pi_int cos_one_sin_zero mult.commute) qed
lemma exp_eq: "exp w = exp z \ (\n::int. w = z + (of_int (2 * n) * pi) * \)"
(is"?lhs = ?rhs") proof - have"exp w = exp z \ exp (w-z) = 1" by (simp add: exp_diff) alsohave"\ \ (Re w = Re z \ (\n::int. Im w - Im z = of_int (2 * n) * pi))" by (simp add: exp_eq_1) alsohave"\ \ ?rhs" by (auto simp: algebra_simps intro!: complex_eqI) finallyshow ?thesis . qed
lemma exp_complex_eqI: "\Im w - Im z\ < 2*pi \ exp w = exp z \ w = z" by (auto simp: exp_eq abs_mult)
lemma exp_2pi_1_nat [simp]: "exp (\ * (of_nat j * (of_real pi * 2))) = 1" by (metis exp_2pi_1_int of_int_of_nat_eq)
lemma exp_integer_2pi_plus1: assumes"n \ \" shows"exp(((2 * n + 1) * pi) * \) = - 1" using exp_integer_2pi [OF assms] by (metis cis_conv_exp cis_mult cis_pi distrib_left mult.commute mult.right_neutral)
lemma inj_on_exp_pi: fixes z::complex shows"inj_on exp (ball z pi)" proof (clarsimp simp: inj_on_def exp_eq) fix y n assume"dist z (y + 2 * of_int n * of_real pi * \) < pi" "dist z y < pi" thenhave"dist y (y + 2 * of_int n * of_real pi * \) < pi+pi" using dist_commute_lessI dist_triangle_less_add by blast thenhave"norm (2 * of_int n * of_real pi * \) < 2*pi" by (simp add: dist_norm) thenshow"n = 0" by (auto simp: norm_mult) qed
lemma sin_eq_0: fixes z::complex shows"sin z = 0 \ (\n::int. z = of_real(n * pi))" by (simp add: sin_exp_eq exp_eq)
lemma cos_eq_0: fixes z::complex shows"cos z = 0 \ (\n::int. z = complex_of_real(n * pi) + of_real pi/2)" using sin_eq_0 [of "z - of_real pi/2"] by (simp add: sin_diff algebra_simps)
lemma cos_eq_1: fixes z::complex shows"cos z = 1 \ (\n::int. z = complex_of_real(2 * n * pi))" by (metis Re_complex_of_real cos_of_real cos_one_2pi_int cos_one_sin_zero mult.commute of_real_1 sin_eq_0)
lemma csin_eq_1: fixes z::complex shows"sin z = 1 \ (\n::int. z = of_real(2 * n * pi) + of_real pi/2)" using cos_eq_1 [of "z - of_real pi/2"] by (simp add: cos_diff algebra_simps)
lemma csin_eq_minus1: fixes z::complex shows"sin z = -1 \ (\n::int. z = complex_of_real(2 * n * pi) + 3/2*pi)"
(is"_ = ?rhs") proof - have"sin z = -1 \ sin (-z) = 1" by (simp add: equation_minus_iff) alsohave"\ \ (\n::int. z = - of_real(2 * n * pi) - of_real pi/2)" by (metis (mono_tags, lifting) add_uminus_conv_diff csin_eq_1 equation_minus_iff minus_add_distrib) alsohave"\ = ?rhs" apply safe apply (rule_tac [2] x="-(x+1)"in exI) apply (rule_tac x="-(x+1)"in exI) apply (simp_all add: algebra_simps) done finallyshow ?thesis . qed
lemma ccos_eq_minus1: fixes z::complex shows"cos z = -1 \ (\n::int. z = complex_of_real(2 * n * pi) + pi)" using csin_eq_1 [of "z - of_real pi/2"] by (simp add: sin_diff algebra_simps equation_minus_iff)
lemma sin_eq_1: "sin x = 1 \ (\n::int. x = (2 * n + 1 / 2) * pi)"
(is"_ = ?rhs") proof - have"sin x = 1 \ sin (complex_of_real x) = 1" by (metis of_real_1 one_complex.simps(1) real_sin_eq sin_of_real) alsohave"\ \ (\n::int. x = of_real(2 * n * pi) + of_real pi/2)" by (metis csin_eq_1 Re_complex_of_real id_apply of_real_add of_real_divide of_real_eq_id of_real_numeral) alsohave"\ = ?rhs" by (auto simp: algebra_simps) finallyshow ?thesis . qed
lemma sin_eq_minus1: "sin x = -1 \ (\n::int. x = (2*n + 3/2) * pi)" (is "_ = ?rhs") proof - have"sin x = -1 \ sin (complex_of_real x) = -1" by (metis Re_complex_of_real of_real_def scaleR_minus1_left sin_of_real) alsohave"\ \ (\n::int. x = of_real(2 * n * pi) + 3/2*pi)" by (metis Re_complex_of_real csin_eq_minus1 id_apply of_real_add of_real_eq_id) alsohave"\ = ?rhs" by (auto simp: algebra_simps) finallyshow ?thesis . qed
lemma cos_eq_minus1: "cos x = -1 \ (\n::int. x = (2*n + 1) * pi)"
(is"_ = ?rhs") proof - have"cos x = -1 \ cos (complex_of_real x) = -1" by (metis Re_complex_of_real of_real_def scaleR_minus1_left cos_of_real) alsohave"\ \ (\n::int. x = of_real(2 * n * pi) + pi)" by (metis ccos_eq_minus1 id_apply of_real_add of_real_eq_id of_real_eq_iff) alsohave"\ = ?rhs" by (auto simp: algebra_simps) finallyshow ?thesis . qed
lemma cos_gt_neg1: assumes"(t::real) \ {-pi<.. shows"cos t > -1" using assms by simp (metis cos_minus cos_monotone_0_pi cos_monotone_minus_pi_0 cos_pi linorder_le_cases)
lemma dist_exp_i_1: "norm(exp(\ * of_real t) - 1) = 2 * \sin(t / 2)\" proof - have"sqrt (2 - cos t * 2) = 2 * \sin (t / 2)\" using cos_double_sin [of "t/2"] by (simp add: real_sqrt_mult) thenshow ?thesis by (simp add: exp_Euler cmod_def power2_diff sin_of_real cos_of_real algebra_simps) qed
lemma sin_cx_2pi [simp]: "\z = of_int m; even m\ \ sin (z * complex_of_real pi) = 0" by (simp add: sin_eq_0)
lemma cos_cx_2pi [simp]: "\z = of_int m; even m\ \ cos (z * complex_of_real pi) = 1" using cos_eq_1 by auto
lemma complex_sin_eq: fixes w :: complex shows"sin w = sin z \ (\n \ \. w = z + of_real(2*n*pi) \ w = -z + of_real((2*n + 1)*pi))"
(is"?lhs = ?rhs") proof assume ?lhs then consider "sin ((w - z) / 2) = 0" | "cos ((w + z) / 2) = 0" by (metis divide_eq_0_iff nonzero_eq_divide_eq right_minus_eq sin_diff_sin zero_neq_numeral) thenshow ?rhs proof cases case 1 thenshow ?thesis by (simp add: sin_eq_0 algebra_simps) (metis Ints_of_int of_real_of_int_eq) next case 2 thenshow ?thesis by (simp add: cos_eq_0 algebra_simps) (metis Ints_of_int of_real_of_int_eq) qed next assume ?rhs then consider n::int where"w = z + of_real (2 * of_int n * pi)"
| n::int where" w = -z + of_real ((2 * of_int n + 1) * pi)" using Ints_cases by blast thenshow ?lhs proof cases case 1 thenshow ?thesis using Periodic_Fun.sin.plus_of_int [of z n] by (auto simp: algebra_simps) next case 2 thenshow ?thesis using Periodic_Fun.sin.plus_of_int [of "-z""n"] apply (simp add: algebra_simps) by (metis add.commute add.inverse_inverse add_diff_cancel_left diff_add_cancel sin_plus_pi) qed qed
lemma complex_cos_eq: fixes w :: complex shows"cos w = cos z \ (\n \ \. w = z + of_real(2*n*pi) \ w = -z + of_real(2*n*pi))"
(is"?lhs = ?rhs") proof assume ?lhs then consider "sin ((w + z) / 2) = 0" | "sin ((z - w) / 2) = 0" by (metis mult_eq_0_iff cos_diff_cos right_minus_eq zero_neq_numeral) thenshow ?rhs proof cases case 1 thenobtain n where"w + z = of_int n * (complex_of_real pi * 2)" by (auto simp: sin_eq_0 algebra_simps) thenhave"w = -z + of_real(2 * of_int n * pi)" by (auto simp: algebra_simps) thenshow ?thesis using Ints_of_int by blast next case 2 thenobtain n where"z = w + of_int n * (complex_of_real pi * 2)" by (auto simp: sin_eq_0 algebra_simps) thenhave"w = z + complex_of_real (2 * of_int(-n) * pi)" by (auto simp: algebra_simps) thenshow ?thesis using Ints_of_int by blast qed next assume ?rhs thenobtain n::int where w: "w = z + of_real (2* of_int n*pi) \
w = -z + of_real(2*n*pi)" using Ints_cases by (metis of_int_mult of_int_numeral) thenshow ?lhs using Periodic_Fun.cos.plus_of_int [of z n] apply (simp add: algebra_simps) by (metis cos.plus_of_int cos_minus minus_add_cancel mult.commute) qed
lemma sin_eq: "sin x = sin y \ (\n \ \. x = y + 2*n*pi \ x = -y + (2*n + 1)*pi)" using complex_sin_eq [of x y] by (simp only: sin_of_real Re_complex_of_real of_real_add [symmetric] of_real_minus [symmetric] of_real_mult [symmetric] of_real_eq_iff)
lemma cos_eq: "cos x = cos y \ (\n \ \. x = y + 2*n*pi \ x = -y + 2*n*pi)" using complex_cos_eq [of x y] unfolding cos_of_real by (metis Re_complex_of_real of_real_add of_real_minus)
lemma sinh_complex: fixes z :: complex shows"(exp z - inverse (exp z)) / 2 = -\ * sin(\ * z)" by (simp add: sin_exp_eq field_split_simps exp_minus)
lemma sin_i_times: fixes z :: complex shows"sin(\ * z) = \ * ((exp z - inverse (exp z)) / 2)" using sinh_complex by auto
lemma sinh_real: fixes x :: real shows"of_real((exp x - inverse (exp x)) / 2) = -\ * sin(\ * of_real x)" by (simp add: exp_of_real sin_i_times)
lemma cosh_complex: fixes z :: complex shows"(exp z + inverse (exp z)) / 2 = cos(\ * z)" by (simp add: cos_exp_eq field_split_simps exp_minus exp_of_real)
lemma cosh_real: fixes x :: real shows"of_real((exp x + inverse (exp x)) / 2) = cos(\ * of_real x)" by (simp add: cos_exp_eq field_split_simps exp_minus exp_of_real)
lemma sinh_conv_sin: "sinh z = -\ * sin (\*z)" by (simp add: sinh_field_def sin_i_times exp_minus)
lemma cosh_conv_cos: "cosh z = cos (\*z)" by (simp add: cosh_field_def cos_i_times exp_minus)
lemma tanh_conv_tan: "tanh z = -\ * tan (\*z)" by (simp add: tanh_def sinh_conv_sin cosh_conv_cos tan_def)
lemma sin_conv_sinh: "sin z = -\ * sinh (\*z)" by (simp add: sinh_conv_sin)
lemma cos_conv_cosh: "cos z = cosh (\*z)" by (simp add: cosh_conv_cos)
lemma tan_conv_tanh: "tan z = -\ * tanh (\*z)" by (simp add: tan_def sin_conv_sinh cos_conv_cosh tanh_def)
lemma sinh_complex_eq_iff: "sinh (z :: complex) = sinh w \
(\<exists>n\<in>\<int>. z = w - 2 * \<i> * of_real n * of_real pi \<or>
z = -(2 * complex_of_real n + 1) * \<i> * complex_of_real pi - w)" (is "_ = ?rhs") proof - have"sinh z = sinh w \ sin (\ * z) = sin (\ * w)" by (simp add: sinh_conv_sin) alsohave"\ \ ?rhs" by (subst complex_sin_eq) (force simp: field_simps complex_eq_iff) finallyshow ?thesis . qed
subsection\<^marker>\<open>tag unimportant\<close>\<open>Taylor series for complex exponential, sine and cosine\<close>
declare power_Suc [simp del]
lemma Taylor_exp_field: fixes z::"'a::{banach,real_normed_field}" shows"norm (exp z - (\i\n. z ^ i / fact i)) \ exp (norm z) * (norm z ^ Suc n) / fact n" proof (rule field_Taylor[of _ n "\k. exp" "exp (norm z)" 0 z, simplified]) show"convex (closed_segment 0 z)" by (rule convex_closed_segment [of 0 z]) next fix k x assume"x \ closed_segment 0 z" "k \ n" show"(exp has_field_derivative exp x) (at x within closed_segment 0 z)" using DERIV_exp DERIV_subset by blast next fix x assume x: "x \ closed_segment 0 z" have"norm (exp x) \ exp (norm x)" by (rule norm_exp) alsohave"norm x \ norm z" using x by (auto simp: closed_segment_def intro!: mult_left_le_one_le) finallyshow"norm (exp x) \ exp (norm z)" by simp qed auto
text\<open>For complex @{term z}, a tighter bound than in the previous result\<close> lemma Taylor_exp: "norm(exp z - (\k\n. z ^ k / (fact k))) \ exp\Re z\ * (norm z) ^ (Suc n) / (fact n)" proof (rule complex_Taylor [of _ n "\k. exp" "exp\Re z\" 0 z, simplified]) show"convex (closed_segment 0 z)" by (rule convex_closed_segment [of 0 z]) next fix k x assume"x \ closed_segment 0 z" "k \ n" show"(exp has_field_derivative exp x) (at x within closed_segment 0 z)" using DERIV_exp DERIV_subset by blast next fix x assume"x \ closed_segment 0 z" thenobtain u where u: "x = complex_of_real u * z""0 \ u" "u \ 1" by (auto simp: closed_segment_def scaleR_conv_of_real) thenhave"u * Re z \ \Re z\" by (metis abs_ge_self abs_ge_zero mult.commute mult.right_neutral mult_mono) thenshow"Re x \ \Re z\" by (simp add: u) qed auto
lemma assumes"0 \ u" "u \ 1" shows cmod_sin_le_exp: "cmod (sin (u *\<^sub>R z)) \ exp \Im z\" and cmod_cos_le_exp: "cmod (cos (u *\<^sub>R z)) \ exp \Im z\" proof - have mono: "\u w z::real. w \ u \ z \ u \ (w + z)/2 \ u" by simp have *: "(cmod (exp (\ * (u * z))) + cmod (exp (- (\ * (u * z)))) ) / 2 \ exp \Im z\" proof (rule mono) show"cmod (exp (\ * (u * z))) \ exp \Im z\" using assms by (auto simp: abs_if mult_left_le_one_le not_less intro: order_trans [of _ 0]) show"cmod (exp (- (\ * (u * z)))) \ exp \Im z\" using assms by (auto simp: abs_if mult_left_le_one_le mult_nonneg_nonpos intro: order_trans [of _ 0]) qed have"cmod (sin (u *\<^sub>R z)) = cmod (exp (\ * (u * z)) - exp (- (\ * (u * z)))) / 2" by (auto simp: scaleR_conv_of_real norm_mult norm_power sin_exp_eq norm_divide) alsohave"\ \ (cmod (exp (\ * (u * z))) + cmod (exp (- (\ * (u * z)))) ) / 2" by (intro divide_right_mono norm_triangle_ineq4) simp alsohave"\ \ exp \Im z\" by (rule *) finallyshow"cmod (sin (u *\<^sub>R z)) \ exp \Im z\" . have"cmod (cos (u *\<^sub>R z)) = cmod (exp (\ * (u * z)) + exp (- (\ * (u * z)))) / 2" by (auto simp: scaleR_conv_of_real norm_mult norm_power cos_exp_eq norm_divide) alsohave"\ \ (cmod (exp (\ * (u * z))) + cmod (exp (- (\ * (u * z)))) ) / 2" by (intro divide_right_mono norm_triangle_ineq) simp alsohave"\ \ exp \Im z\" by (rule *) finallyshow"cmod (cos (u *\<^sub>R z)) \ exp \Im z\" . qed
lemma Taylor_sin: "norm(sin z - (\k\n. complex_of_real (sin_coeff k) * z ^ k)) \<le> exp\<bar>Im z\<bar> * (norm z) ^ (Suc n) / (fact n)" proof - have mono: "\u w z::real. w \ u \ z \ u \ w + z \ u*2" by arith have *: "cmod (sin z -
(\<Sum>i\<le>n. (-1) ^ (i div 2) * (if even i then sin 0 else cos 0) * z ^ i / (fact i))) \<le> exp \<bar>Im z\<bar> * cmod z ^ Suc n / (fact n)" proof (rule complex_Taylor [of "closed_segment 0 z" n "\k x. (-1)^(k div 2) * (if even k then sin x else cos x)" "exp\Im z\" 0 z, simplified]) fix k x show"((\x. (- 1) ^ (k div 2) * (if even k then sin x else cos x)) has_field_derivative
(- 1) ^ (Suc k div 2) * (if odd k then sin x else cos x))
(at x within closed_segment 0 z)" by (cases "even k") (intro derivative_eq_intros | simp add: power_Suc)+ next fix x assume"x \ closed_segment 0 z" thenshow"cmod ((- 1) ^ (Suc n div 2) * (if odd n then sin x else cos x)) \ exp \Im z\" by (auto simp: closed_segment_def norm_mult norm_power cmod_sin_le_exp cmod_cos_le_exp) qed have **: "\k. complex_of_real (sin_coeff k) * z ^ k
= (-1)^(k div 2) * (if even k then sin 0 else cos 0) * z^k / of_nat (fact k)" by (auto simp: sin_coeff_def elim!: oddE) show ?thesis by (simp add: ** order_trans [OF _ *]) qed
lemma Taylor_cos: "norm(cos z - (\k\n. complex_of_real (cos_coeff k) * z ^ k)) \<le> exp\<bar>Im z\<bar> * (norm z) ^ Suc n / (fact n)" proof - have mono: "\u w z::real. w \ u \ z \ u \ w + z \ u*2" by arith have *: "cmod (cos z -
(\<Sum>i\<le>n. (-1) ^ (Suc i div 2) * (if even i then cos 0 else sin 0) * z ^ i / (fact i))) \<le> exp \<bar>Im z\<bar> * cmod z ^ Suc n / (fact n)" proof (rule complex_Taylor [of "closed_segment 0 z" n "\k x. (-1)^(Suc k div 2) * (if even k then cos x else sin x)" "exp\Im z\" 0 z, simplified]) fix k x assume"x \ closed_segment 0 z" "k \ n" show"((\x. (- 1) ^ (Suc k div 2) * (if even k then cos x else sin x)) has_field_derivative
(- 1) ^ Suc (k div 2) * (if odd k then cos x else sin x))
(at x within closed_segment 0 z)" by (cases "even k") (intro derivative_eq_intros | simp add: power_Suc)+ next fix x assume"x \ closed_segment 0 z" thenshow"cmod ((- 1) ^ Suc (n div 2) * (if odd n then cos x else sin x)) \ exp \Im z\" by (auto simp: closed_segment_def norm_mult norm_power cmod_sin_le_exp cmod_cos_le_exp) qed have **: "\k. complex_of_real (cos_coeff k) * z ^ k
= (-1)^(Suc k div 2) * (if even k then cos 0 else sin 0) * z^k / of_nat (fact k)" by (auto simp: cos_coeff_def elim!: evenE) show ?thesis by (simp add: ** order_trans [OF _ *]) qed
text\<open>Apparently redundant. But many arguments involve integers.\<close> lemma ln3_gt_1: "ln 3 > (1::real)" by (simp add: less_trans [OF ln_272_gt_1])
subsection\<open>The argument of a complex number (HOL Light version)\<close>
definition\<^marker>\<open>tag important\<close> is_Arg :: "[complex,real] \<Rightarrow> bool" where"is_Arg z r \ z = of_real(norm z) * exp(\ * of_real r)"
definition\<^marker>\<open>tag important\<close> Arg2pi :: "complex \<Rightarrow> real" where"Arg2pi z \ if z = 0 then 0 else THE t. 0 \ t \ t < 2*pi \ is_Arg z t"
lemma is_Arg_2pi_iff: "is_Arg z (r + of_int k * (2 * pi)) \ is_Arg z r" by (simp add: algebra_simps is_Arg_def)
lemma is_Arg_eqI: assumes"is_Arg z r"and"is_Arg z s"and"abs (r-s) < 2*pi"and"z \ 0" shows"r = s" using assms unfolding is_Arg_def by (metis Im_i_times Re_complex_of_real exp_complex_eqI mult_cancel_left mult_eq_0_iff)
text\<open>This function returns the angle of a complex number from its representation in polar coordinates.
Due to periodicity, its range is arbitrary. \<^term>\<open>Arg2pi\<close> follows HOL Light in adopting the interval \<open>[0,2\<pi>)\<close>.
But we have the same periodicity issue with logarithms, and it is usual to adopt the same interval for the complex logarithm and argument functions. Further on down, we shall define both functions for the interval \<open>(-\<pi>,\<pi>]\<close>.
The present version is provided for compatibility.\<close>
lemma Arg2pi_0 [simp]: "Arg2pi(0) = 0" by (simp add: Arg2pi_def)
lemma Arg2pi_unique_lemma: assumes"is_Arg z t" and"is_Arg z t'" and"0 \ t" "t < 2*pi" and"0 \ t'" "t' < 2*pi" and"z \ 0" shows"t' = t" using is_Arg_eqI assms by force
lemma Arg2pi: "0 \ Arg2pi z \ Arg2pi z < 2*pi \ is_Arg z (Arg2pi z)" proof (cases "z=0") case True thenshow ?thesis by (simp add: Arg2pi_def is_Arg_def) next case False obtain t where t: "0 \ t" "t < 2*pi" and ReIm: "Re z / cmod z = cos t""Im z / cmod z = sin t" using sincos_total_2pi [OF complex_unit_circle [OF False]] by blast thenhave z: "is_Arg z t" unfolding is_Arg_def using t False ReIm by (intro complex_eqI) (auto simp: exp_Euler sin_of_real cos_of_real field_split_simps) show ?thesis apply (simp add: Arg2pi_def False) apply (rule theI [where a=t]) using t z False apply (auto intro: Arg2pi_unique_lemma) done qed
corollary\<^marker>\<open>tag unimportant\<close> shows Arg2pi_ge_0: "0 \ Arg2pi z" and Arg2pi_lt_2pi: "Arg2pi z < 2*pi" and Arg2pi_eq: "z = of_real(norm z) * exp(\ * of_real(Arg2pi z))" using Arg2pi is_Arg_def by auto
lemma Arg2pi_unique: "\of_real r * exp(\ * of_real a) = z; 0 < r; 0 \ a; a < 2*pi\ \ Arg2pi z = a" by (rule Arg2pi_unique_lemma [unfolded is_Arg_def, OF _ Arg2pi_eq]) (use Arg2pi [of z] in\<open>auto simp: norm_mult\<close>)
lemma cos_Arg2pi: "cmod z * cos (Arg2pi z) = Re z"and sin_Arg2pi: "cmod z * sin (Arg2pi z) = Im z" using Arg2pi_eq [of z] cis_conv_exp Re_rcis Im_rcis unfolding rcis_def by metis+
lemma Arg2pi_minus: assumes"z \ 0" shows "Arg2pi (-z) = (if Arg2pi z < pi then Arg2pi z + pi else Arg2pi z - pi)" apply (rule Arg2pi_unique [of "norm z", OF complex_eqI]) using cos_Arg2pi sin_Arg2pi Arg2pi_ge_0 Arg2pi_lt_2pi [of z] assms by (auto simp: Re_exp Im_exp)
lemma Arg2pi_times_of_real2 [simp]: "0 < r \ Arg2pi (z * of_real r) = Arg2pi z" by (metis Arg2pi_times_of_real mult.commute)
lemma Arg2pi_divide_of_real [simp]: "0 < r \ Arg2pi (z / of_real r) = Arg2pi z" by (metis Arg2pi_times_of_real2 less_irrefl nonzero_eq_divide_eq of_real_eq_0_iff)
lemma Arg2pi_le_pi: "Arg2pi z \ pi \ 0 \ Im z" proof (cases "z=0") case False have"0 \ Im z \ 0 \ Im (of_real (cmod z) * exp (\ * complex_of_real (Arg2pi z)))" by (metis Arg2pi_eq) alsohave"\ = (0 \ Im (exp (\ * complex_of_real (Arg2pi z))))" using False by (simp add: zero_le_mult_iff) alsohave"\ \ Arg2pi z \ pi" by (simp add: Im_exp) (metis Arg2pi_ge_0 Arg2pi_lt_2pi sin_lt_zero sin_ge_zero not_le) finallyshow ?thesis by blast qed auto
lemma Arg2pi_lt_pi: "0 < Arg2pi z \ Arg2pi z < pi \ 0 < Im z" using Arg2pi_le_pi [of z] by (smt (verit, del_insts) Arg2pi_0 Arg2pi_le_pi Arg2pi_minus uminus_complex.simps(2) zero_complex.simps(2))
lemma Arg2pi_eq_0: "Arg2pi z = 0 \ z \ \ \ 0 \ Re z" proof (cases "z=0") case False thenhave"z \ \ \ 0 \ Re z \ z \ \ \ 0 \ Re (exp (\ * complex_of_real (Arg2pi z)))" by (metis cis.sel(1) cis_conv_exp cos_Arg2pi norm_ge_zero norm_le_zero_iff zero_le_mult_iff) alsohave"\ \ Arg2pi z = 0" proof - have [simp]: "Arg2pi z = 0 \ z \ \" using Arg2pi_eq [of z] by (auto simp: Reals_def) moreoverhave"\z \ \; 0 \ cos (Arg2pi z)\ \ Arg2pi z = 0" by (smt (verit, ccfv_SIG) Arg2pi_ge_0 Arg2pi_le_pi Arg2pi_lt_pi complex_is_Real_iff cos_pi) ultimatelyshow ?thesis by (auto simp: Re_exp) qed finallyshow ?thesis by blast qed auto
corollary\<^marker>\<open>tag unimportant\<close> Arg2pi_gt_0: assumes"z \ \\<^sub>\\<^sub>0" shows"Arg2pi z > 0" using Arg2pi_eq_0 Arg2pi_ge_0 assms dual_order.strict_iff_order unfolding nonneg_Reals_def by fastforce
lemma Arg2pi_eq_pi: "Arg2pi z = pi \ z \ \ \ Re z < 0" using Arg2pi_le_pi [of z] Arg2pi_lt_pi [of z] Arg2pi_eq_0 [of z] Arg2pi_ge_0 [of z] by (fastforce simp: complex_is_Real_iff)
lemma Arg2pi_eq_0_pi: "Arg2pi z = 0 \ Arg2pi z = pi \ z \ \" using Arg2pi_eq_0 Arg2pi_eq_pi not_le by auto
lemma Arg2pi_of_real: "Arg2pi (of_real r) = (if r<0 then pi else 0)" using Arg2pi_eq_0_pi Arg2pi_eq_pi by fastforce
lemma Arg2pi_real: "z \ \ \ Arg2pi z = (if 0 \ Re z then 0 else pi)" using Arg2pi_eq_0 Arg2pi_eq_0_pi by auto
lemma Arg2pi_inverse: "Arg2pi(inverse z) = (if z \ \ then Arg2pi z else 2*pi - Arg2pi z)" proof (cases "z=0") case False show ?thesis apply (rule Arg2pi_unique [of "inverse (norm z)"]) using Arg2pi_eq False Arg2pi_ge_0 [of z] Arg2pi_lt_2pi [of z] Arg2pi_eq_0 [of z] by (auto simp: Arg2pi_real in_Reals_norm exp_diff field_simps) qed auto
lemma Arg2pi_eq_iff: assumes"w \ 0" "z \ 0" shows"Arg2pi w = Arg2pi z \ (\x. 0 < x \ w = of_real x * z)" (is "?lhs = ?rhs") proof assume ?lhs thenhave"(cmod w) * (z / cmod z) = w" by (metis Arg2pi_eq assms(2) mult_eq_0_iff nonzero_mult_div_cancel_left) thenshow ?rhs by (metis assms divide_pos_pos of_real_divide times_divide_eq_left times_divide_eq_right zero_less_norm_iff) qed auto
lemma Arg2pi_inverse_eq_0: "Arg2pi(inverse z) = 0 \ Arg2pi z = 0" by (metis Arg2pi_eq_0 Arg2pi_inverse inverse_inverse_eq)
lemma Arg2pi_le_div_sum: assumes"w \ 0" "z \ 0" "Arg2pi w \ Arg2pi z" shows"Arg2pi z = Arg2pi w + Arg2pi(z / w)" by (simp add: Arg2pi_divide assms)
lemma Arg2pi_le_div_sum_eq: assumes"w \ 0" "z \ 0" shows"Arg2pi w \ Arg2pi z \ Arg2pi z = Arg2pi w + Arg2pi(z / w)" using assms by (auto simp: Arg2pi_ge_0 intro: Arg2pi_le_div_sum)
lemma Arg2pi_diff: assumes"w \ 0" "z \ 0" shows"Arg2pi w - Arg2pi z = (if Arg2pi z \ Arg2pi w then Arg2pi(w / z) else Arg2pi(w/z) - 2*pi)" using assms Arg2pi_divide Arg2pi_inverse [of "w/z"] Arg2pi_eq_0_pi by (force simp add: Arg2pi_ge_0 Arg2pi_divide not_le split: if_split_asm)
lemma Arg2pi_add: assumes"w \ 0" "z \ 0" shows"Arg2pi w + Arg2pi z = (if Arg2pi w + Arg2pi z < 2*pi then Arg2pi(w * z) else Arg2pi(w * z) + 2*pi)" using assms Arg2pi_diff [of "w*z" z] Arg2pi_le_div_sum_eq [of z "w*z"] Arg2pi [of "w * z"] by auto
lemma Arg2pi_times: assumes"w \ 0" "z \ 0" shows"Arg2pi (w * z) = (if Arg2pi w + Arg2pi z < 2*pi then Arg2pi w + Arg2pi z
else (Arg2pi w + Arg2pi z) - 2*pi)" using Arg2pi_add [OF assms] by auto
lemma Arg2pi_cnj_eq_inverse: assumes"z \ 0" shows "Arg2pi (cnj z) = Arg2pi (inverse z)" proof - have"\r>0. of_real r / z = cnj z" by (metis assms complex_norm_square nonzero_mult_div_cancel_left zero_less_norm_iff zero_less_power) thenshow ?thesis by (metis Arg2pi_times_of_real2 divide_inverse_commute) qed
lemma Arg2pi_cnj: "Arg2pi(cnj z) = (if z \ \ then Arg2pi z else 2*pi - Arg2pi z)" by (metis Arg2pi_cnj_eq_inverse Arg2pi_inverse Reals_cnj_iff complex_cnj_zero)
lemma Arg2pi_exp: "0 \ Im z \ Im z < 2*pi \ Arg2pi(exp z) = Im z" by (simp add: Arg2pi_unique exp_eq_polar)
lemma complex_split_polar: obtains r a::real where"z = complex_of_real r * (cos a + \ * sin a)" "0 \ r" "0 \ a" "a < 2*pi" using Arg2pi cis.ctr cis_conv_exp unfolding Complex_eq is_Arg_def by fastforce
lemma Re_Im_le_cmod: "Im w * sin \ + Re w * cos \ \ cmod w" proof (cases w rule: complex_split_polar) case (1 r a) with sin_cos_le1 [of a \<phi>] show ?thesis apply (simp add: norm_mult cmod_unit_one) by (metis (no_types, opaque_lifting) abs_le_D1 distrib_left mult.commute mult.left_commute mult_left_le) qed
subsection\<^marker>\<open>tag unimportant\<close>\<open>Analytic properties of tangent function\<close>
lemma field_differentiable_at_tan: "cos z \ 0 \ tan field_differentiable at z" unfolding field_differentiable_def using DERIV_tan by blast
lemma field_differentiable_within_tan: "cos z \ 0 \<Longrightarrow> tan field_differentiable (at z within s)" using field_differentiable_at_tan field_differentiable_at_within by blast
lemma continuous_within_tan: "cos z \ 0 \ continuous (at z within s) tan" using continuous_at_imp_continuous_within isCont_tan by blast
lemma continuous_on_tan [continuous_intros]: "(\z. z \ s \ cos z \ 0) \ continuous_on s tan" by (simp add: continuous_at_imp_continuous_on)
lemma holomorphic_on_tan: "(\z. z \ s \ cos z \ 0) \ tan holomorphic_on s" by (simp add: field_differentiable_within_tan holomorphic_on_def)
subsection\<open>The principal branch of the Complex logarithm\<close>
instantiation complex :: ln begin
definition\<^marker>\<open>tag important\<close> ln_complex :: "complex \<Rightarrow> complex" where"ln_complex \ \z. THE w. exp w = z & -pi < Im(w) & Im(w) \ pi"
text\<open>NOTE: within this scope, the constant Ln is not yet available!\<close> lemma assumes"z \ 0" shows exp_Ln [simp]: "exp(ln z) = z" and mpi_less_Im_Ln: "-pi < Im(ln z)" and Im_Ln_le_pi: "Im(ln z) \ pi" proof - obtain\<psi> where z: "z / (cmod z) = Complex (cos \<psi>) (sin \<psi>)" using complex_unimodular_polar [of "z / (norm z)"] assms by (auto simp: norm_divide field_split_simps) obtain\<phi> where \<phi>: "- pi < \<phi>" "\<phi> \<le> pi" "sin \<phi> = sin \<psi>" "cos \<phi> = cos \<psi>" using sincos_principal_value [of "\"] assms by (auto simp: norm_divide field_split_simps) have"exp(ln z) = z & -pi < Im(ln z) & Im(ln z) \ pi" unfolding ln_complex_def apply (rule theI [where a = "Complex (ln(norm z)) \"]) using z assms \<phi> apply (auto simp: field_simps exp_complex_eqI exp_eq_polar cis.code) done thenshow"exp(ln z) = z""-pi < Im(ln z)""Im(ln z) \ pi" by auto qed
lemma Ln_exp [simp]: assumes"-pi < Im(z)""Im(z) \ pi" shows"ln(exp z) = z" proof (rule exp_complex_eqI) show"\Im (ln (exp z)) - Im z\ < 2 * pi" using assms mpi_less_Im_Ln [of "exp z"] Im_Ln_le_pi [of "exp z"] by auto qed auto
subsection\<^marker>\<open>tag unimportant\<close>\<open>Relation to Real Logarithm\<close>
lemma field_differentiable_at_Ln: "z \ \\<^sub>\\<^sub>0 \ Ln field_differentiable at z" using field_differentiable_def has_field_derivative_Ln by blast
lemma field_differentiable_within_Ln: "z \ \\<^sub>\\<^sub>0 \<Longrightarrow> Ln field_differentiable (at z within S)" using field_differentiable_at_Ln field_differentiable_within_subset by blast
lemma isCont_Ln' [simp,continuous_intros]: "\isCont f z; f z \ \\<^sub>\\<^sub>0\ \ isCont (\x. Ln (f x)) z" by (blast intro: isCont_o2 [OF _ continuous_at_Ln])
lemma continuous_within_Ln [continuous_intros]: "z \ \\<^sub>\\<^sub>0 \ continuous (at z within S) Ln" using continuous_at_Ln continuous_at_imp_continuous_within by blast
lemma continuous_on_Ln [continuous_intros]: "(\z. z \ S \ z \ \\<^sub>\\<^sub>0) \ continuous_on S Ln" by (simp add: continuous_at_imp_continuous_on continuous_within_Ln)
lemma continuous_on_Ln' [continuous_intros]: "continuous_on S f \ (\z. z \ S \ f z \ \\<^sub>\\<^sub>0) \ continuous_on S (\x. Ln (f x))" by (rule continuous_on_compose2[OF continuous_on_Ln, of "UNIV - nonpos_Reals" S f]) auto
lemma holomorphic_on_Ln' [holomorphic_intros]: "(\z. z \ A \ f z \ \\<^sub>\\<^sub>0) \ f holomorphic_on A \ (\z. Ln (f z)) holomorphic_on A" using holomorphic_on_compose_gen[OF _ holomorphic_on_Ln, of f A "- \\<^sub>\\<^sub>0"] by (auto simp: o_def)
lemma analytic_on_ln [analytic_intros]: assumes"f analytic_on A""f ` A \ \\<^sub>\\<^sub>0 = {}" shows"(\w. ln (f w)) analytic_on A" proof - have *: "ln analytic_on (-\\<^sub>\\<^sub>0)" by (subst analytic_on_open) (auto intro!: holomorphic_intros) have"(ln \ f) analytic_on A" by (rule analytic_on_compose_gen[OF assms(1) *]) (use assms(2) in auto) thus ?thesis by (simp add: o_def) qed
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.