src/HOL/Analysis/Complex_Transcendental.thy
changeset 75494 eded3fe9e600
parent 74513 67d87d224e00
child 76137 175e6d47e3af
equal deleted inserted replaced
75485:d8ee3e4d74ef 75494:eded3fe9e600
   489   also have "... = ?rhs"
   489   also have "... = ?rhs"
   490     by (auto simp: algebra_simps)
   490     by (auto simp: algebra_simps)
   491   finally show ?thesis .
   491   finally show ?thesis .
   492 qed
   492 qed
   493 
   493 
       
   494 lemma cos_gt_neg1:
       
   495   assumes "(t::real) \<in> {-pi<..<pi}"
       
   496   shows   "cos t > -1"
       
   497 proof -
       
   498   have "cos t \<ge> -1"
       
   499     by simp
       
   500   moreover have "cos t \<noteq> -1"
       
   501   proof
       
   502     assume "cos t = -1"
       
   503     then obtain n where n: "t = (2 * of_int n + 1) * pi"
       
   504       by (subst (asm) cos_eq_minus1) auto
       
   505     from assms have "t / pi \<in> {-1<..<1}"
       
   506       by (auto simp: field_simps)
       
   507     also from n have "t / pi = of_int (2 * n + 1)"
       
   508       by auto
       
   509     finally show False
       
   510       by auto
       
   511   qed
       
   512   ultimately show ?thesis by linarith
       
   513 qed
       
   514 
   494 lemma dist_exp_i_1: "norm(exp(\<i> * of_real t) - 1) = 2 * \<bar>sin(t / 2)\<bar>"
   515 lemma dist_exp_i_1: "norm(exp(\<i> * of_real t) - 1) = 2 * \<bar>sin(t / 2)\<bar>"
   495 proof -
   516 proof -
   496   have "sqrt (2 - cos t * 2) = 2 * \<bar>sin (t / 2)\<bar>"
   517   have "sqrt (2 - cos t * 2) = 2 * \<bar>sin (t / 2)\<bar>"
   497     using cos_double_sin [of "t/2"] by (simp add: real_sqrt_mult)
   518     using cos_double_sin [of "t/2"] by (simp add: real_sqrt_mult)
   498   then show ?thesis
   519   then show ?thesis
   527     then show ?thesis
   548     then show ?thesis
   528       by (simp add: cos_eq_0 algebra_simps) (metis Ints_of_int of_real_of_int_eq)
   549       by (simp add: cos_eq_0 algebra_simps) (metis Ints_of_int of_real_of_int_eq)
   529   qed
   550   qed
   530 next
   551 next
   531   assume ?rhs
   552   assume ?rhs
   532   then consider n::int where "w = z + of_real (2 * of_int n * pi)" 
   553   then consider n::int where "w = z + of_real (2 * of_int n * pi)"
   533               | n::int where  " w = -z + of_real ((2 * of_int n + 1) * pi)"
   554               | n::int where  " w = -z + of_real ((2 * of_int n + 1) * pi)"
   534     using Ints_cases by blast
   555     using Ints_cases by blast
   535   then show ?lhs
   556   then show ?lhs
   536   proof cases
   557   proof cases
   537     case 1
   558     case 1
   538     then show ?thesis
   559     then show ?thesis
   539       using Periodic_Fun.sin.plus_of_int [of z n]
   560       using Periodic_Fun.sin.plus_of_int [of z n]
   540       by (auto simp: algebra_simps)
   561       by (auto simp: algebra_simps)
   541   next
   562   next
   542     case 2
   563     case 2
   543     then show ?thesis 
   564     then show ?thesis
   544       using Periodic_Fun.sin.plus_of_int [of "-z" "n"]
   565       using Periodic_Fun.sin.plus_of_int [of "-z" "n"]
   545       apply (simp add: algebra_simps)
   566       apply (simp add: algebra_simps)
   546       by (metis add.commute add.inverse_inverse add_diff_cancel_left diff_add_cancel sin_plus_pi)
   567       by (metis add.commute add.inverse_inverse add_diff_cancel_left diff_add_cancel sin_plus_pi)
   547   qed
   568   qed
   548 qed
   569 qed
  1049     shows "Arg2pi z > 0"
  1070     shows "Arg2pi z > 0"
  1050   using Arg2pi_eq_0 Arg2pi_ge_0 assms dual_order.strict_iff_order
  1071   using Arg2pi_eq_0 Arg2pi_ge_0 assms dual_order.strict_iff_order
  1051   unfolding nonneg_Reals_def by fastforce
  1072   unfolding nonneg_Reals_def by fastforce
  1052 
  1073 
  1053 lemma Arg2pi_eq_pi: "Arg2pi z = pi \<longleftrightarrow> z \<in> \<real> \<and> Re z < 0"
  1074 lemma Arg2pi_eq_pi: "Arg2pi z = pi \<longleftrightarrow> z \<in> \<real> \<and> Re z < 0"
  1054     using Arg2pi_le_pi [of z] Arg2pi_lt_pi [of z] Arg2pi_eq_0 [of z] Arg2pi_ge_0 [of z] 
  1075     using Arg2pi_le_pi [of z] Arg2pi_lt_pi [of z] Arg2pi_eq_0 [of z] Arg2pi_ge_0 [of z]
  1055     by (fastforce simp: complex_is_Real_iff)
  1076     by (fastforce simp: complex_is_Real_iff)
  1056 
  1077 
  1057 lemma Arg2pi_eq_0_pi: "Arg2pi z = 0 \<or> Arg2pi z = pi \<longleftrightarrow> z \<in> \<real>"
  1078 lemma Arg2pi_eq_0_pi: "Arg2pi z = 0 \<or> Arg2pi z = pi \<longleftrightarrow> z \<in> \<real>"
  1058   using Arg2pi_eq_0 Arg2pi_eq_pi not_le by auto
  1079   using Arg2pi_eq_0 Arg2pi_eq_pi not_le by auto
  1059 
  1080 
  1301     by (simp add: le_neq_trans)
  1322     by (simp add: le_neq_trans)
  1302   let ?U = "{w. -pi < Im(w) \<and> Im(w) < pi}"
  1323   let ?U = "{w. -pi < Im(w) \<and> Im(w) < pi}"
  1303   have 1: "open ?U"
  1324   have 1: "open ?U"
  1304     by (simp add: open_Collect_conj open_halfspace_Im_gt open_halfspace_Im_lt)
  1325     by (simp add: open_Collect_conj open_halfspace_Im_gt open_halfspace_Im_lt)
  1305   have 2: "\<And>x. x \<in> ?U \<Longrightarrow> (exp has_derivative blinfun_apply(Blinfun ((*) (exp x)))) (at x)"
  1326   have 2: "\<And>x. x \<in> ?U \<Longrightarrow> (exp has_derivative blinfun_apply(Blinfun ((*) (exp x)))) (at x)"
  1306     by (simp add: bounded_linear_Blinfun_apply bounded_linear_mult_right has_field_derivative_imp_has_derivative)   
  1327     by (simp add: bounded_linear_Blinfun_apply bounded_linear_mult_right has_field_derivative_imp_has_derivative)
  1307   have 3: "continuous_on ?U (\<lambda>x. Blinfun ((*) (exp x)))"
  1328   have 3: "continuous_on ?U (\<lambda>x. Blinfun ((*) (exp x)))"
  1308     unfolding blinfun_mult_right.abs_eq [symmetric] by (intro continuous_intros)
  1329     unfolding blinfun_mult_right.abs_eq [symmetric] by (intro continuous_intros)
  1309   have 4: "Ln z \<in> ?U"
  1330   have 4: "Ln z \<in> ?U"
  1310     by (auto simp: mpi_less_Im_Ln *)
  1331     by (auto simp: mpi_less_Im_Ln *)
  1311   have 5: "Blinfun ((*) (inverse z)) o\<^sub>L Blinfun ((*) (exp (Ln z))) = id_blinfun"
  1332   have 5: "Blinfun ((*) (inverse z)) o\<^sub>L Blinfun ((*) (exp (Ln z))) = id_blinfun"
  1484   hence "(Ln (1 + z) - z) = (\<Sum>i. (-(z^2)) * inverse (of_nat (i+2)) * (-z)^i)"
  1505   hence "(Ln (1 + z) - z) = (\<Sum>i. (-(z^2)) * inverse (of_nat (i+2)) * (-z)^i)"
  1485     by (simp add: sums_iff)
  1506     by (simp add: sums_iff)
  1486   also have A: "summable (\<lambda>n. norm z^2 * (inverse (real_of_nat (Suc (Suc n))) * cmod z ^ n))"
  1507   also have A: "summable (\<lambda>n. norm z^2 * (inverse (real_of_nat (Suc (Suc n))) * cmod z ^ n))"
  1487     by (rule summable_mult, rule summable_comparison_test_ev[OF _ summable_geometric[of "norm z"]])
  1508     by (rule summable_mult, rule summable_comparison_test_ev[OF _ summable_geometric[of "norm z"]])
  1488        (auto simp: assms field_simps intro!: always_eventually)
  1509        (auto simp: assms field_simps intro!: always_eventually)
  1489   hence "norm (\<Sum>i. (-(z^2)) * inverse (of_nat (i+2)) * (-z)^i) 
  1510   hence "norm (\<Sum>i. (-(z^2)) * inverse (of_nat (i+2)) * (-z)^i)
  1490       \<le> (\<Sum>i. norm (-(z^2) * inverse (of_nat (i+2)) * (-z)^i))"
  1511       \<le> (\<Sum>i. norm (-(z^2) * inverse (of_nat (i+2)) * (-z)^i))"
  1491     by (intro summable_norm)
  1512     by (intro summable_norm)
  1492        (auto simp: norm_power norm_inverse norm_mult mult_ac simp del: of_nat_add of_nat_Suc)
  1513        (auto simp: norm_power norm_inverse norm_mult mult_ac simp del: of_nat_add of_nat_Suc)
  1493   also have "norm ((-z)^2 * (-z)^i) * inverse (of_nat (i+2)) \<le> norm ((-z)^2 * (-z)^i) * 1" for i
  1514   also have "norm ((-z)^2 * (-z)^i) * inverse (of_nat (i+2)) \<le> norm ((-z)^2 * (-z)^i) * 1" for i
  1494     by (intro mult_left_mono) (simp_all add: field_split_simps)
  1515     by (intro mult_left_mono) (simp_all add: field_split_simps)
  1523     then have w: "Im w \<le> pi" "- pi < Im w"
  1544     then have w: "Im w \<le> pi" "- pi < Im w"
  1524       using Im_Ln_le_pi [of z]  mpi_less_Im_Ln [of z]  assms
  1545       using Im_Ln_le_pi [of z]  mpi_less_Im_Ln [of z]  assms
  1525       by auto
  1546       by auto
  1526     have "\<bar>Im w\<bar> < pi/2 \<longleftrightarrow> 0 < Re(exp w)"
  1547     have "\<bar>Im w\<bar> < pi/2 \<longleftrightarrow> 0 < Re(exp w)"
  1527     proof
  1548     proof
  1528       assume "\<bar>Im w\<bar> < pi/2" then show "0 < Re(exp w)" 
  1549       assume "\<bar>Im w\<bar> < pi/2" then show "0 < Re(exp w)"
  1529         by (auto simp: Re_exp cos_gt_zero_pi split: if_split_asm)
  1550         by (auto simp: Re_exp cos_gt_zero_pi split: if_split_asm)
  1530     next
  1551     next
  1531       assume R: "0 < Re(exp w)" then 
  1552       assume R: "0 < Re(exp w)" then
  1532       have "\<bar>Im w\<bar> \<noteq> pi/2"
  1553       have "\<bar>Im w\<bar> \<noteq> pi/2"
  1533         by (metis cos_minus cos_pi_half mult_eq_0_iff Re_exp abs_if order_less_irrefl)
  1554         by (metis cos_minus cos_pi_half mult_eq_0_iff Re_exp abs_if order_less_irrefl)
  1534       then show "\<bar>Im w\<bar> < pi/2"
  1555       then show "\<bar>Im w\<bar> < pi/2"
  1535         using cos_lt_zero_pi [of "-(Im w)"] cos_lt_zero_pi [of "(Im w)"] w R
  1556         using cos_lt_zero_pi [of "-(Im w)"] cos_lt_zero_pi [of "(Im w)"] w R
  1536         by (force simp: Re_exp zero_less_mult_iff abs_if not_less_iff_gr_or_eq)
  1557         by (force simp: Re_exp zero_less_mult_iff abs_if not_less_iff_gr_or_eq)
  1786 
  1807 
  1787 lemma Arg_eq_Im_Ln:
  1808 lemma Arg_eq_Im_Ln:
  1788   assumes "z \<noteq> 0" shows "Arg z = Im (Ln z)"
  1809   assumes "z \<noteq> 0" shows "Arg z = Im (Ln z)"
  1789 proof (rule cis_Arg_unique)
  1810 proof (rule cis_Arg_unique)
  1790   show "sgn z = cis (Im (Ln z))"
  1811   show "sgn z = cis (Im (Ln z))"
  1791     by (metis assms exp_Ln exp_eq_polar nonzero_mult_div_cancel_left norm_eq_zero 
  1812     by (metis assms exp_Ln exp_eq_polar nonzero_mult_div_cancel_left norm_eq_zero
  1792               norm_exp_eq_Re of_real_eq_0_iff sgn_eq)
  1813               norm_exp_eq_Re of_real_eq_0_iff sgn_eq)
  1793   show "- pi < Im (Ln z)"
  1814   show "- pi < Im (Ln z)"
  1794     by (simp add: assms mpi_less_Im_Ln)
  1815     by (simp add: assms mpi_less_Im_Ln)
  1795   show "Im (Ln z) \<le> pi"
  1816   show "Im (Ln z) \<le> pi"
  1796     by (simp add: Im_Ln_le_pi assms)
  1817     by (simp add: Im_Ln_le_pi assms)
  2125   have [simp]: "Im x \<noteq> 0 \<Longrightarrow> Im (Ln (- x)) + pi = Arg2pi x" for x
  2146   have [simp]: "Im x \<noteq> 0 \<Longrightarrow> Im (Ln (- x)) + pi = Arg2pi x" for x
  2126     using Arg2pi_Ln  by (simp add: Arg2pi_gt_0 complex_nonneg_Reals_iff)
  2147     using Arg2pi_Ln  by (simp add: Arg2pi_gt_0 complex_nonneg_Reals_iff)
  2127   consider "Re z < 0" | "Im z \<noteq> 0" using assms
  2148   consider "Re z < 0" | "Im z \<noteq> 0" using assms
  2128     using complex_nonneg_Reals_iff not_le by blast
  2149     using complex_nonneg_Reals_iff not_le by blast
  2129   then have [simp]: "(\<lambda>z. Im (Ln (- z)) + pi) \<midarrow>z\<rightarrow> Arg2pi z"
  2150   then have [simp]: "(\<lambda>z. Im (Ln (- z)) + pi) \<midarrow>z\<rightarrow> Arg2pi z"
  2130     using "*" by (simp add: Arg2pi_Ln Arg2pi_gt_0 assms continuous_within) 
  2151     using "*" by (simp add: Arg2pi_Ln Arg2pi_gt_0 assms continuous_within)
  2131   show ?thesis
  2152   show ?thesis
  2132     unfolding continuous_at
  2153     unfolding continuous_at
  2133   proof (rule Lim_transform_within_open)
  2154   proof (rule Lim_transform_within_open)
  2134     show "\<And>x. \<lbrakk>x \<in> - \<real>\<^sub>\<ge>\<^sub>0; x \<noteq> z\<rbrakk> \<Longrightarrow> Im (Ln (- x)) + pi = Arg2pi x"
  2155     show "\<And>x. \<lbrakk>x \<in> - \<real>\<^sub>\<ge>\<^sub>0; x \<noteq> z\<rbrakk> \<Longrightarrow> Im (Ln (- x)) + pi = Arg2pi x"
  2135       by (auto simp add: Arg2pi_Ln [OF Arg2pi_gt_0] complex_nonneg_Reals_iff)
  2156       by (auto simp add: Arg2pi_Ln [OF Arg2pi_gt_0] complex_nonneg_Reals_iff)
  3141 lemma Im_Arctan_of_real [simp]: "Im (Arctan (of_real x)) = 0"
  3162 lemma Im_Arctan_of_real [simp]: "Im (Arctan (of_real x)) = 0"
  3142 proof -
  3163 proof -
  3143   have ne: "1 + x\<^sup>2 \<noteq> 0"
  3164   have ne: "1 + x\<^sup>2 \<noteq> 0"
  3144     by (metis power_one sum_power2_eq_zero_iff zero_neq_one)
  3165     by (metis power_one sum_power2_eq_zero_iff zero_neq_one)
  3145   have ne1: "1 + \<i> * complex_of_real x \<noteq> 0"
  3166   have ne1: "1 + \<i> * complex_of_real x \<noteq> 0"
  3146     using Complex_eq complex_eq_cancel_iff2 by fastforce 
  3167     using Complex_eq complex_eq_cancel_iff2 by fastforce
  3147   have "Re (Ln ((1 - \<i> * x) * inverse (1 + \<i> * x))) = 0"
  3168   have "Re (Ln ((1 - \<i> * x) * inverse (1 + \<i> * x))) = 0"
  3148     apply (rule norm_exp_imaginary)
  3169     apply (rule norm_exp_imaginary)
  3149     using ne
  3170     using ne
  3150     apply (simp add: ne1 cmod_def)
  3171     apply (simp add: ne1 cmod_def)
  3151     apply (auto simp: field_split_simps)
  3172     apply (auto simp: field_split_simps)
  3820     by (simp add: Im_Arcsin_of_real assms)
  3841     by (simp add: Im_Arcsin_of_real assms)
  3821 next
  3842 next
  3822   fix x'
  3843   fix x'
  3823   assume "- (pi / 2) \<le> x'" "x' \<le> pi / 2" "x = sin x'"
  3844   assume "- (pi / 2) \<le> x'" "x' \<le> pi / 2" "x = sin x'"
  3824   then show "x' = Re (Arcsin (complex_of_real (sin x')))"
  3845   then show "x' = Re (Arcsin (complex_of_real (sin x')))"
  3825     unfolding sin_of_real [symmetric] 
  3846     unfolding sin_of_real [symmetric]
  3826     by (subst Arcsin_sin) auto
  3847     by (subst Arcsin_sin) auto
  3827 qed
  3848 qed
  3828 
  3849 
  3829 lemma of_real_arcsin: "\<bar>x\<bar> \<le> 1 \<Longrightarrow> of_real(arcsin x) = Arcsin(of_real x)"
  3850 lemma of_real_arcsin: "\<bar>x\<bar> \<le> 1 \<Longrightarrow> of_real(arcsin x) = Arcsin(of_real x)"
  3830   by (metis Im_Arcsin_of_real add.right_neutral arcsin_eq_Re_Arcsin complex_eq mult_zero_right of_real_0)
  3851   by (metis Im_Arcsin_of_real add.right_neutral arcsin_eq_Re_Arcsin complex_eq mult_zero_right of_real_0)