775 where "is_Arg z r \<equiv> z = of_real(norm z) * exp(\<i> * of_real r)" |
775 where "is_Arg z r \<equiv> z = of_real(norm z) * exp(\<i> * of_real r)" |
776 |
776 |
777 definition Arg2pi :: "complex \<Rightarrow> real" |
777 definition Arg2pi :: "complex \<Rightarrow> real" |
778 where "Arg2pi z \<equiv> if z = 0 then 0 else THE t. 0 \<le> t \<and> t < 2*pi \<and> is_Arg z t" |
778 where "Arg2pi z \<equiv> if z = 0 then 0 else THE t. 0 \<le> t \<and> t < 2*pi \<and> is_Arg z t" |
779 |
779 |
|
780 lemma is_Arg_2pi_iff: "is_Arg z (r + of_int k * (2 * pi)) \<longleftrightarrow> is_Arg z r" |
|
781 by (simp add: algebra_simps is_Arg_def) |
|
782 |
|
783 lemma is_Arg_eqI: |
|
784 assumes r: "is_Arg z r" and s: "is_Arg z s" and rs: "abs (r-s) < 2*pi" and "z \<noteq> 0" |
|
785 shows "r = s" |
|
786 proof - |
|
787 have zr: "z = (cmod z) * exp (\<i> * r)" and zs: "z = (cmod z) * exp (\<i> * s)" |
|
788 using r s by (auto simp: is_Arg_def) |
|
789 with \<open>z \<noteq> 0\<close> have eq: "exp (\<i> * r) = exp (\<i> * s)" |
|
790 by (metis mult_eq_0_iff vector_space_over_itself.scale_left_imp_eq) |
|
791 have "\<i> * r = \<i> * s" |
|
792 by (rule exp_complex_eqI) (use rs in \<open>auto simp: eq exp_complex_eqI\<close>) |
|
793 then show ?thesis |
|
794 by simp |
|
795 qed |
|
796 |
780 text\<open>This function returns the angle of a complex number from its representation in polar coordinates. |
797 text\<open>This function returns the angle of a complex number from its representation in polar coordinates. |
781 Due to periodicity, its range is arbitrary. @{term Arg2pi} follows HOL Light in adopting the interval $[0,2\pi)$. |
798 Due to periodicity, its range is arbitrary. @{term Arg2pi} follows HOL Light in adopting the interval $[0,2\pi)$. |
782 But we have the same periodicity issue with logarithms, and it is usual to adopt the same interval |
799 But we have the same periodicity issue with logarithms, and it is usual to adopt the same interval |
783 for the complex logarithm and argument functions. Further on down, we shall define both functions for the interval $(-\pi,\pi]$. |
800 for the complex logarithm and argument functions. Further on down, we shall define both functions for the interval $(-\pi,\pi]$. |
784 The present version is provided for compatibility.\<close> |
801 The present version is provided for compatibility.\<close> |
922 assumes "z \<notin> \<real>\<^sub>\<ge>\<^sub>0" |
939 assumes "z \<notin> \<real>\<^sub>\<ge>\<^sub>0" |
923 shows "Arg2pi z > 0" |
940 shows "Arg2pi z > 0" |
924 using Arg2pi_eq_0 Arg2pi_ge_0 assms dual_order.strict_iff_order |
941 using Arg2pi_eq_0 Arg2pi_ge_0 assms dual_order.strict_iff_order |
925 unfolding nonneg_Reals_def by fastforce |
942 unfolding nonneg_Reals_def by fastforce |
926 |
943 |
927 lemma Arg2pi_of_real: "Arg2pi(of_real x) = 0 \<longleftrightarrow> 0 \<le> x" |
|
928 by (simp add: Arg2pi_eq_0) |
|
929 |
|
930 lemma Arg2pi_eq_pi: "Arg2pi z = pi \<longleftrightarrow> z \<in> \<real> \<and> Re z < 0" |
944 lemma Arg2pi_eq_pi: "Arg2pi z = pi \<longleftrightarrow> z \<in> \<real> \<and> Re z < 0" |
931 using Arg2pi_le_pi [of z] Arg2pi_lt_pi [of z] Arg2pi_eq_0 [of z] Arg2pi_ge_0 [of z] |
945 using Arg2pi_le_pi [of z] Arg2pi_lt_pi [of z] Arg2pi_eq_0 [of z] Arg2pi_ge_0 [of z] |
932 by (fastforce simp: complex_is_Real_iff) |
946 by (fastforce simp: complex_is_Real_iff) |
933 |
947 |
934 lemma Arg2pi_eq_0_pi: "Arg2pi z = 0 \<or> Arg2pi z = pi \<longleftrightarrow> z \<in> \<real>" |
948 lemma Arg2pi_eq_0_pi: "Arg2pi z = 0 \<or> Arg2pi z = pi \<longleftrightarrow> z \<in> \<real>" |
935 using Arg2pi_eq_0 Arg2pi_eq_pi not_le by auto |
949 using Arg2pi_eq_0 Arg2pi_eq_pi not_le by auto |
|
950 |
|
951 lemma Arg2pi_of_real: "Arg2pi (of_real r) = (if r<0 then pi else 0)" |
|
952 using Arg2pi_eq_0_pi Arg2pi_eq_pi by fastforce |
936 |
953 |
937 lemma Arg2pi_real: "z \<in> \<real> \<Longrightarrow> Arg2pi z = (if 0 \<le> Re z then 0 else pi)" |
954 lemma Arg2pi_real: "z \<in> \<real> \<Longrightarrow> Arg2pi z = (if 0 \<le> Re z then 0 else pi)" |
938 using Arg2pi_eq_0 Arg2pi_eq_0_pi by auto |
955 using Arg2pi_eq_0 Arg2pi_eq_0_pi by auto |
939 |
956 |
940 lemma Arg2pi_inverse: "Arg2pi(inverse z) = (if z \<in> \<real> then Arg2pi z else 2*pi - Arg2pi z)" |
957 lemma Arg2pi_inverse: "Arg2pi(inverse z) = (if z \<in> \<real> then Arg2pi z else 2*pi - Arg2pi z)" |
1652 by (simp add: Arg_def Im_Ln_eq_0) (metis less_eq_real_def of_real_Re of_real_def scale_zero_left) |
1669 by (simp add: Arg_def Im_Ln_eq_0) (metis less_eq_real_def of_real_Re of_real_def scale_zero_left) |
1653 |
1670 |
1654 corollary Arg_ne_0: assumes "z \<notin> \<real>\<^sub>\<ge>\<^sub>0" shows "Arg z \<noteq> 0" |
1671 corollary Arg_ne_0: assumes "z \<notin> \<real>\<^sub>\<ge>\<^sub>0" shows "Arg z \<noteq> 0" |
1655 using assms by (auto simp: nonneg_Reals_def Arg_eq_0) |
1672 using assms by (auto simp: nonneg_Reals_def Arg_eq_0) |
1656 |
1673 |
1657 lemma Arg_of_real: "Arg(of_real x) = 0 \<longleftrightarrow> 0 \<le> x" |
1674 lemma Arg_of_real: "Arg (of_real r) = (if r<0 then pi else 0)" |
1658 by (simp add: Arg_eq_0) |
1675 by (simp add: Im_Ln_eq_pi Arg_def) |
1659 |
1676 |
1660 lemma Arg_eq_pi_iff: "Arg z = pi \<longleftrightarrow> z \<in> \<real> \<and> Re z < 0" |
1677 lemma Arg_eq_pi_iff: "Arg z = pi \<longleftrightarrow> z \<in> \<real> \<and> Re z < 0" |
1661 proof (cases "z=0") |
1678 proof (cases "z=0") |
1662 case False |
1679 case False |
1663 then show ?thesis |
1680 then show ?thesis |
1710 by (rule Arg_unique [of "exp(Re z)"]) (auto simp: exp_eq_polar) |
1727 by (rule Arg_unique [of "exp(Re z)"]) (auto simp: exp_eq_polar) |
1711 |
1728 |
1712 lemma Ln_Arg: "z\<noteq>0 \<Longrightarrow> Ln(z) = ln(norm z) + \<i> * Arg(z)" |
1729 lemma Ln_Arg: "z\<noteq>0 \<Longrightarrow> Ln(z) = ln(norm z) + \<i> * Arg(z)" |
1713 by (metis Arg_def Re_Ln complex_eq) |
1730 by (metis Arg_def Re_Ln complex_eq) |
1714 |
1731 |
|
1732 lemma continuous_at_Arg: |
|
1733 assumes "z \<notin> \<real>\<^sub>\<le>\<^sub>0" |
|
1734 shows "continuous (at z) Arg" |
|
1735 proof - |
|
1736 have [simp]: "(\<lambda>z. Im (Ln z)) \<midarrow>z\<rightarrow> Arg z" |
|
1737 using Arg_def assms continuous_at by fastforce |
|
1738 show ?thesis |
|
1739 unfolding continuous_at |
|
1740 proof (rule Lim_transform_within_open) |
|
1741 show "\<And>w. \<lbrakk>w \<in> - \<real>\<^sub>\<le>\<^sub>0; w \<noteq> z\<rbrakk> \<Longrightarrow> Im (Ln w) = Arg w" |
|
1742 by (metis Arg_def Compl_iff nonpos_Reals_zero_I) |
|
1743 qed (use assms in auto) |
|
1744 qed |
|
1745 |
|
1746 lemma continuous_within_Arg: "z \<notin> \<real>\<^sub>\<le>\<^sub>0 \<Longrightarrow> continuous (at z within S) Arg" |
|
1747 using continuous_at_Arg continuous_at_imp_continuous_within by blast |
1715 |
1748 |
1716 |
1749 |
1717 subsection\<open>Relation between Ln and Arg2pi, and hence continuity of Arg2pi\<close> |
1750 subsection\<open>Relation between Ln and Arg2pi, and hence continuity of Arg2pi\<close> |
1718 |
1751 |
1719 lemma Arg2pi_Ln: |
1752 lemma Arg2pi_Ln: |
4059 have "\<And>z. cmod z = 1 \<Longrightarrow> \<exists>x\<in>{0..1}. \<gamma> (Arg2pi z / (2*pi)) = \<gamma> x" |
4092 have "\<And>z. cmod z = 1 \<Longrightarrow> \<exists>x\<in>{0..1}. \<gamma> (Arg2pi z / (2*pi)) = \<gamma> x" |
4060 by (metis Arg2pi_ge_0 Arg2pi_lt_2pi atLeastAtMost_iff divide_less_eq_1 less_eq_real_def zero_less_mult_iff pi_gt_zero zero_le_divide_iff zero_less_numeral) |
4093 by (metis Arg2pi_ge_0 Arg2pi_lt_2pi atLeastAtMost_iff divide_less_eq_1 less_eq_real_def zero_less_mult_iff pi_gt_zero zero_le_divide_iff zero_less_numeral) |
4061 moreover have "\<exists>z\<in>sphere 0 1. \<gamma> x = \<gamma> (Arg2pi z / (2*pi))" if "0 \<le> x" "x \<le> 1" for x |
4094 moreover have "\<exists>z\<in>sphere 0 1. \<gamma> x = \<gamma> (Arg2pi z / (2*pi))" if "0 \<le> x" "x \<le> 1" for x |
4062 proof (cases "x=1") |
4095 proof (cases "x=1") |
4063 case True |
4096 case True |
4064 then show ?thesis |
4097 with Arg2pi_of_real [of 1] loop show ?thesis |
4065 apply (rule_tac x=1 in bexI) |
4098 by (rule_tac x=1 in bexI) (auto simp: pathfinish_def pathstart_def \<open>0 \<le> x\<close>) |
4066 apply (metis loop Arg2pi_of_real divide_eq_0_iff of_real_1 pathfinish_def pathstart_def \<open>0 \<le> x\<close>, auto) |
|
4067 done |
|
4068 next |
4099 next |
4069 case False |
4100 case False |
4070 then have *: "(Arg2pi (exp (\<i>*(2* of_real pi* of_real x))) / (2*pi)) = x" |
4101 then have *: "(Arg2pi (exp (\<i>*(2* of_real pi* of_real x))) / (2*pi)) = x" |
4071 using that by (auto simp: Arg2pi_exp divide_simps) |
4102 using that by (auto simp: Arg2pi_exp divide_simps) |
4072 show ?thesis |
4103 show ?thesis |