40 by (simp add: scaleR_conv_of_real field_simps) |
40 by (simp add: scaleR_conv_of_real field_simps) |
41 qed |
41 qed |
42 |
42 |
43 theorem exp_Euler: "exp(ii * z) = cos(z) + ii * sin(z)" |
43 theorem exp_Euler: "exp(ii * z) = cos(z) + ii * sin(z)" |
44 proof - |
44 proof - |
45 have "(\<lambda>n. (cos_coeff n + ii * sin_coeff n) * z^n) |
45 have "(\<lambda>n. (cos_coeff n + ii * sin_coeff n) * z^n) |
46 = (\<lambda>n. (ii * z) ^ n /\<^sub>R (fact n))" |
46 = (\<lambda>n. (ii * z) ^ n /\<^sub>R (fact n))" |
47 proof |
47 proof |
48 fix n |
48 fix n |
49 show "(cos_coeff n + ii * sin_coeff n) * z^n = (ii * z) ^ n /\<^sub>R (fact n)" |
49 show "(cos_coeff n + ii * sin_coeff n) * z^n = (ii * z) ^ n /\<^sub>R (fact n)" |
50 by (auto simp: cos_coeff_def sin_coeff_def scaleR_conv_of_real field_simps elim!: evenE oddE) |
50 by (auto simp: cos_coeff_def sin_coeff_def scaleR_conv_of_real field_simps elim!: evenE oddE) |
72 lemma cos_exp_eq: "cos z = (exp(ii * z) + exp(-(ii * z))) / 2" |
72 lemma cos_exp_eq: "cos z = (exp(ii * z) + exp(-(ii * z))) / 2" |
73 by (simp add: exp_Euler exp_minus_Euler) |
73 by (simp add: exp_Euler exp_minus_Euler) |
74 |
74 |
75 subsection{*Relationships between real and complex trig functions*} |
75 subsection{*Relationships between real and complex trig functions*} |
76 |
76 |
77 declare sin_of_real [simp] cos_of_real [simp] |
|
78 |
|
79 lemma real_sin_eq [simp]: |
77 lemma real_sin_eq [simp]: |
80 fixes x::real |
78 fixes x::real |
81 shows "Re(sin(of_real x)) = sin x" |
79 shows "Re(sin(of_real x)) = sin x" |
82 by (simp add: sin_of_real) |
80 by (simp add: sin_of_real) |
83 |
81 |
84 lemma real_cos_eq [simp]: |
82 lemma real_cos_eq [simp]: |
85 fixes x::real |
83 fixes x::real |
86 shows "Re(cos(of_real x)) = cos x" |
84 shows "Re(cos(of_real x)) = cos x" |
87 by (simp add: cos_of_real) |
85 by (simp add: cos_of_real) |
88 |
86 |
98 by auto |
96 by auto |
99 also have "... sums (exp (cnj z))" |
97 also have "... sums (exp (cnj z))" |
100 by (rule exp_converges) |
98 by (rule exp_converges) |
101 finally have "(\<lambda>n. cnj (z ^ n /\<^sub>R (fact n))) sums (exp (cnj z))" . |
99 finally have "(\<lambda>n. cnj (z ^ n /\<^sub>R (fact n))) sums (exp (cnj z))" . |
102 moreover have "(\<lambda>n. cnj (z ^ n /\<^sub>R (fact n))) sums (cnj (exp z))" |
100 moreover have "(\<lambda>n. cnj (z ^ n /\<^sub>R (fact n))) sums (cnj (exp z))" |
103 by (metis exp_converges sums_cnj) |
101 by (metis exp_converges sums_cnj) |
104 ultimately show ?thesis |
102 ultimately show ?thesis |
105 using sums_unique2 |
103 using sums_unique2 |
106 by blast |
104 by blast |
107 qed |
105 qed |
108 |
106 |
109 lemma cnj_sin: "cnj(sin z) = sin(cnj z)" |
107 lemma cnj_sin: "cnj(sin z) = sin(cnj z)" |
110 by (simp add: sin_exp_eq exp_cnj field_simps) |
108 by (simp add: sin_exp_eq exp_cnj field_simps) |
111 |
109 |
112 lemma cnj_cos: "cnj(cos z) = cos(cnj z)" |
110 lemma cnj_cos: "cnj(cos z) = cos(cnj z)" |
113 by (simp add: cos_exp_eq exp_cnj field_simps) |
111 by (simp add: cos_exp_eq exp_cnj field_simps) |
114 |
112 |
115 lemma exp_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> exp z \<in> \<real>" |
|
116 by (metis Reals_cases Reals_of_real exp_of_real) |
|
117 |
|
118 lemma sin_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> sin z \<in> \<real>" |
|
119 by (metis Reals_cases Reals_of_real sin_of_real) |
|
120 |
|
121 lemma cos_in_Reals [simp]: "z \<in> \<real> \<Longrightarrow> cos z \<in> \<real>" |
|
122 by (metis Reals_cases Reals_of_real cos_of_real) |
|
123 |
|
124 lemma complex_differentiable_at_sin: "sin complex_differentiable at z" |
113 lemma complex_differentiable_at_sin: "sin complex_differentiable at z" |
125 using DERIV_sin complex_differentiable_def by blast |
114 using DERIV_sin complex_differentiable_def by blast |
126 |
115 |
127 lemma complex_differentiable_within_sin: "sin complex_differentiable (at z within s)" |
116 lemma complex_differentiable_within_sin: "sin complex_differentiable (at z within s)" |
128 by (simp add: complex_differentiable_at_sin complex_differentiable_at_within) |
117 by (simp add: complex_differentiable_at_sin complex_differentiable_at_within) |
139 lemma holomorphic_on_cos: "cos holomorphic_on s" |
128 lemma holomorphic_on_cos: "cos holomorphic_on s" |
140 by (simp add: complex_differentiable_within_cos holomorphic_on_def) |
129 by (simp add: complex_differentiable_within_cos holomorphic_on_def) |
141 |
130 |
142 subsection{* Get a nice real/imaginary separation in Euler's formula.*} |
131 subsection{* Get a nice real/imaginary separation in Euler's formula.*} |
143 |
132 |
144 lemma Euler: "exp(z) = of_real(exp(Re z)) * |
133 lemma Euler: "exp(z) = of_real(exp(Re z)) * |
145 (of_real(cos(Im z)) + ii * of_real(sin(Im z)))" |
134 (of_real(cos(Im z)) + ii * of_real(sin(Im z)))" |
146 by (cases z) (simp add: exp_add exp_Euler cos_of_real exp_of_real sin_of_real) |
135 by (cases z) (simp add: exp_add exp_Euler cos_of_real exp_of_real sin_of_real) |
147 |
136 |
148 lemma Re_sin: "Re(sin z) = sin(Re z) * (exp(Im z) + exp(-(Im z))) / 2" |
137 lemma Re_sin: "Re(sin z) = sin(Re z) * (exp(Im z) + exp(-(Im z))) / 2" |
149 by (simp add: sin_exp_eq field_simps Re_divide Im_exp) |
138 by (simp add: sin_exp_eq field_simps Re_divide Im_exp) |
154 lemma Re_cos: "Re(cos z) = cos(Re z) * (exp(Im z) + exp(-(Im z))) / 2" |
143 lemma Re_cos: "Re(cos z) = cos(Re z) * (exp(Im z) + exp(-(Im z))) / 2" |
155 by (simp add: cos_exp_eq field_simps Re_divide Re_exp) |
144 by (simp add: cos_exp_eq field_simps Re_divide Re_exp) |
156 |
145 |
157 lemma Im_cos: "Im(cos z) = sin(Re z) * (exp(-(Im z)) - exp(Im z)) / 2" |
146 lemma Im_cos: "Im(cos z) = sin(Re z) * (exp(-(Im z)) - exp(Im z)) / 2" |
158 by (simp add: cos_exp_eq field_simps Im_divide Im_exp) |
147 by (simp add: cos_exp_eq field_simps Im_divide Im_exp) |
159 |
148 |
|
149 lemma Re_sin_pos: "0 < Re z \<Longrightarrow> Re z < pi \<Longrightarrow> Re (sin z) > 0" |
|
150 by (auto simp: Re_sin Im_sin add_pos_pos sin_gt_zero) |
|
151 |
|
152 lemma Im_sin_nonneg: "Re z = 0 \<Longrightarrow> 0 \<le> Im z \<Longrightarrow> 0 \<le> Im (sin z)" |
|
153 by (simp add: Re_sin Im_sin algebra_simps) |
|
154 |
|
155 lemma Im_sin_nonneg2: "Re z = pi \<Longrightarrow> Im z \<le> 0 \<Longrightarrow> 0 \<le> Im (sin z)" |
|
156 by (simp add: Re_sin Im_sin algebra_simps) |
|
157 |
160 subsection{*More on the Polar Representation of Complex Numbers*} |
158 subsection{*More on the Polar Representation of Complex Numbers*} |
161 |
159 |
162 lemma exp_Complex: "exp(Complex r t) = of_real(exp r) * Complex (cos t) (sin t)" |
160 lemma exp_Complex: "exp(Complex r t) = of_real(exp r) * Complex (cos t) (sin t)" |
163 by (simp add: exp_add exp_Euler exp_of_real) |
161 by (simp add: exp_add exp_Euler exp_of_real sin_of_real cos_of_real) |
164 |
162 |
165 lemma exp_eq_1: "exp z = 1 \<longleftrightarrow> Re(z) = 0 \<and> (\<exists>n::int. Im(z) = of_int (2 * n) * pi)" |
163 lemma exp_eq_1: "exp z = 1 \<longleftrightarrow> Re(z) = 0 \<and> (\<exists>n::int. Im(z) = of_int (2 * n) * pi)" |
166 apply auto |
164 apply auto |
167 apply (metis exp_eq_one_iff norm_exp_eq_Re norm_one) |
165 apply (metis exp_eq_one_iff norm_exp_eq_Re norm_one) |
168 apply (metis Re_exp cos_one_2pi_int mult.commute mult.left_neutral norm_exp_eq_Re norm_one one_complex.simps(1) real_of_int_def) |
166 apply (metis Re_exp cos_one_2pi_int mult.commute mult.left_neutral norm_exp_eq_Re norm_one one_complex.simps(1) real_of_int_def) |
181 qed |
179 qed |
182 |
180 |
183 lemma exp_complex_eqI: "abs(Im w - Im z) < 2*pi \<Longrightarrow> exp w = exp z \<Longrightarrow> w = z" |
181 lemma exp_complex_eqI: "abs(Im w - Im z) < 2*pi \<Longrightarrow> exp w = exp z \<Longrightarrow> w = z" |
184 by (auto simp: exp_eq abs_mult) |
182 by (auto simp: exp_eq abs_mult) |
185 |
183 |
186 lemma exp_integer_2pi: |
184 lemma exp_integer_2pi: |
187 assumes "n \<in> Ints" |
185 assumes "n \<in> Ints" |
188 shows "exp((2 * n * pi) * ii) = 1" |
186 shows "exp((2 * n * pi) * ii) = 1" |
189 proof - |
187 proof - |
190 have "exp((2 * n * pi) * ii) = exp 0" |
188 have "exp((2 * n * pi) * ii) = exp 0" |
191 using assms |
189 using assms |
206 apply (auto simp: sin_add cos_add) |
204 apply (auto simp: sin_add cos_add) |
207 apply (metis add.commute diff_add_cancel mult.commute) |
205 apply (metis add.commute diff_add_cancel mult.commute) |
208 done |
206 done |
209 qed |
207 qed |
210 |
208 |
211 lemma exp_i_ne_1: |
209 lemma exp_i_ne_1: |
212 assumes "0 < x" "x < 2*pi" |
210 assumes "0 < x" "x < 2*pi" |
213 shows "exp(\<i> * of_real x) \<noteq> 1" |
211 shows "exp(\<i> * of_real x) \<noteq> 1" |
214 proof |
212 proof |
215 assume "exp (\<i> * of_real x) = 1" |
213 assume "exp (\<i> * of_real x) = 1" |
216 then have "exp (\<i> * of_real x) = exp 0" |
214 then have "exp (\<i> * of_real x) = exp 0" |
217 by simp |
215 by simp |
218 then obtain n where "\<i> * of_real x = (of_int (2 * n) * pi) * \<i>" |
216 then obtain n where "\<i> * of_real x = (of_int (2 * n) * pi) * \<i>" |
219 by (simp only: Ints_def exp_eq) auto |
217 by (simp only: Ints_def exp_eq) auto |
223 by simp |
221 by simp |
224 then show False using assms |
222 then show False using assms |
225 by (cases n) (auto simp: zero_less_mult_iff mult_less_0_iff) |
223 by (cases n) (auto simp: zero_less_mult_iff mult_less_0_iff) |
226 qed |
224 qed |
227 |
225 |
228 lemma sin_eq_0: |
226 lemma sin_eq_0: |
229 fixes z::complex |
227 fixes z::complex |
230 shows "sin z = 0 \<longleftrightarrow> (\<exists>n::int. z = of_real(n * pi))" |
228 shows "sin z = 0 \<longleftrightarrow> (\<exists>n::int. z = of_real(n * pi))" |
231 by (simp add: sin_exp_eq exp_eq of_real_numeral) |
229 by (simp add: sin_exp_eq exp_eq of_real_numeral) |
232 |
230 |
233 lemma cos_eq_0: |
231 lemma cos_eq_0: |
234 fixes z::complex |
232 fixes z::complex |
235 shows "cos z = 0 \<longleftrightarrow> (\<exists>n::int. z = of_real(n * pi) + of_real pi/2)" |
233 shows "cos z = 0 \<longleftrightarrow> (\<exists>n::int. z = of_real(n * pi) + of_real pi/2)" |
236 using sin_eq_0 [of "z - of_real pi/2"] |
234 using sin_eq_0 [of "z - of_real pi/2"] |
237 by (simp add: sin_diff algebra_simps) |
235 by (simp add: sin_diff algebra_simps) |
238 |
236 |
239 lemma cos_eq_1: |
237 lemma cos_eq_1: |
240 fixes z::complex |
238 fixes z::complex |
241 shows "cos z = 1 \<longleftrightarrow> (\<exists>n::int. z = of_real(2 * n * pi))" |
239 shows "cos z = 1 \<longleftrightarrow> (\<exists>n::int. z = of_real(2 * n * pi))" |
242 proof - |
240 proof - |
243 have "cos z = cos (2*(z/2))" |
241 have "cos z = cos (2*(z/2))" |
244 by simp |
242 by simp |
246 by (simp only: cos_double_sin) |
244 by (simp only: cos_double_sin) |
247 finally have [simp]: "cos z = 1 \<longleftrightarrow> sin (z/2) = 0" |
245 finally have [simp]: "cos z = 1 \<longleftrightarrow> sin (z/2) = 0" |
248 by simp |
246 by simp |
249 show ?thesis |
247 show ?thesis |
250 by (auto simp: sin_eq_0 of_real_numeral) |
248 by (auto simp: sin_eq_0 of_real_numeral) |
251 qed |
249 qed |
252 |
250 |
253 lemma csin_eq_1: |
251 lemma csin_eq_1: |
254 fixes z::complex |
252 fixes z::complex |
255 shows "sin z = 1 \<longleftrightarrow> (\<exists>n::int. z = of_real(2 * n * pi) + of_real pi/2)" |
253 shows "sin z = 1 \<longleftrightarrow> (\<exists>n::int. z = of_real(2 * n * pi) + of_real pi/2)" |
256 using cos_eq_1 [of "z - of_real pi/2"] |
254 using cos_eq_1 [of "z - of_real pi/2"] |
273 apply (rule_tac [2] x="-(x+1)" in exI) |
271 apply (rule_tac [2] x="-(x+1)" in exI) |
274 apply (rule_tac x="-(x+1)" in exI) |
272 apply (rule_tac x="-(x+1)" in exI) |
275 apply (simp_all add: algebra_simps) |
273 apply (simp_all add: algebra_simps) |
276 done |
274 done |
277 finally show ?thesis . |
275 finally show ?thesis . |
278 qed |
276 qed |
279 |
277 |
280 lemma ccos_eq_minus1: |
278 lemma ccos_eq_minus1: |
281 fixes z::complex |
279 fixes z::complex |
282 shows "cos z = -1 \<longleftrightarrow> (\<exists>n::int. z = of_real(2 * n * pi) + pi)" |
280 shows "cos z = -1 \<longleftrightarrow> (\<exists>n::int. z = of_real(2 * n * pi) + pi)" |
283 using csin_eq_1 [of "z - of_real pi/2"] |
281 using csin_eq_1 [of "z - of_real pi/2"] |
284 apply (simp add: sin_diff) |
282 apply (simp add: sin_diff) |
285 apply (simp add: algebra_simps of_real_numeral equation_minus_iff) |
283 apply (simp add: algebra_simps of_real_numeral equation_minus_iff) |
286 done |
284 done |
287 |
285 |
288 lemma sin_eq_1: "sin x = 1 \<longleftrightarrow> (\<exists>n::int. x = (2 * n + 1 / 2) * pi)" |
286 lemma sin_eq_1: "sin x = 1 \<longleftrightarrow> (\<exists>n::int. x = (2 * n + 1 / 2) * pi)" |
289 (is "_ = ?rhs") |
287 (is "_ = ?rhs") |
290 proof - |
288 proof - |
291 have "sin x = 1 \<longleftrightarrow> sin (complex_of_real x) = 1" |
289 have "sin x = 1 \<longleftrightarrow> sin (complex_of_real x) = 1" |
299 apply (auto simp: of_real_numeral) |
297 apply (auto simp: of_real_numeral) |
300 done |
298 done |
301 also have "... = ?rhs" |
299 also have "... = ?rhs" |
302 by (auto simp: algebra_simps) |
300 by (auto simp: algebra_simps) |
303 finally show ?thesis . |
301 finally show ?thesis . |
304 qed |
302 qed |
305 |
303 |
306 lemma sin_eq_minus1: "sin x = -1 \<longleftrightarrow> (\<exists>n::int. x = (2*n + 3/2) * pi)" (is "_ = ?rhs") |
304 lemma sin_eq_minus1: "sin x = -1 \<longleftrightarrow> (\<exists>n::int. x = (2*n + 3/2) * pi)" (is "_ = ?rhs") |
307 proof - |
305 proof - |
308 have "sin x = -1 \<longleftrightarrow> sin (complex_of_real x) = -1" |
306 have "sin x = -1 \<longleftrightarrow> sin (complex_of_real x) = -1" |
309 by (metis Re_complex_of_real of_real_def scaleR_minus1_left sin_of_real) |
307 by (metis Re_complex_of_real of_real_def scaleR_minus1_left sin_of_real) |
315 apply (rule injD [OF inj_of_real [where 'a = complex]], auto) |
313 apply (rule injD [OF inj_of_real [where 'a = complex]], auto) |
316 done |
314 done |
317 also have "... = ?rhs" |
315 also have "... = ?rhs" |
318 by (auto simp: algebra_simps) |
316 by (auto simp: algebra_simps) |
319 finally show ?thesis . |
317 finally show ?thesis . |
320 qed |
318 qed |
321 |
319 |
322 lemma cos_eq_minus1: "cos x = -1 \<longleftrightarrow> (\<exists>n::int. x = (2*n + 1) * pi)" |
320 lemma cos_eq_minus1: "cos x = -1 \<longleftrightarrow> (\<exists>n::int. x = (2*n + 1) * pi)" |
323 (is "_ = ?rhs") |
321 (is "_ = ?rhs") |
324 proof - |
322 proof - |
325 have "cos x = -1 \<longleftrightarrow> cos (complex_of_real x) = -1" |
323 have "cos x = -1 \<longleftrightarrow> cos (complex_of_real x) = -1" |
332 apply (rule injD [OF inj_of_real [where 'a = complex]], auto) |
330 apply (rule injD [OF inj_of_real [where 'a = complex]], auto) |
333 done |
331 done |
334 also have "... = ?rhs" |
332 also have "... = ?rhs" |
335 by (auto simp: algebra_simps) |
333 by (auto simp: algebra_simps) |
336 finally show ?thesis . |
334 finally show ?thesis . |
337 qed |
335 qed |
338 |
336 |
339 lemma dist_exp_ii_1: "norm(exp(ii * of_real t) - 1) = 2 * abs(sin(t / 2))" |
337 lemma dist_exp_ii_1: "norm(exp(ii * of_real t) - 1) = 2 * abs(sin(t / 2))" |
340 apply (simp add: exp_Euler cmod_def power2_diff algebra_simps) |
338 apply (simp add: exp_Euler cmod_def power2_diff sin_of_real cos_of_real algebra_simps) |
341 using cos_double_sin [of "t/2"] |
339 using cos_double_sin [of "t/2"] |
342 apply (simp add: real_sqrt_mult) |
340 apply (simp add: real_sqrt_mult) |
343 done |
341 done |
344 |
342 |
345 lemma sinh_complex: |
343 lemma sinh_complex: |
367 shows "of_real((exp x + inverse (exp x)) / 2) = cos(ii * of_real x)" |
365 shows "of_real((exp x + inverse (exp x)) / 2) = cos(ii * of_real x)" |
368 by (simp add: cos_exp_eq divide_simps exp_minus of_real_numeral exp_of_real) |
366 by (simp add: cos_exp_eq divide_simps exp_minus of_real_numeral exp_of_real) |
369 |
367 |
370 lemmas cos_ii_times = cosh_complex [symmetric] |
368 lemmas cos_ii_times = cosh_complex [symmetric] |
371 |
369 |
372 lemma norm_cos_squared: |
370 lemma norm_cos_squared: |
373 "norm(cos z) ^ 2 = cos(Re z) ^ 2 + (exp(Im z) - inverse(exp(Im z))) ^ 2 / 4" |
371 "norm(cos z) ^ 2 = cos(Re z) ^ 2 + (exp(Im z) - inverse(exp(Im z))) ^ 2 / 4" |
374 apply (cases z) |
372 apply (cases z) |
375 apply (simp add: cos_add cmod_power2 cos_of_real sin_of_real) |
373 apply (simp add: cos_add cmod_power2 cos_of_real sin_of_real) |
376 apply (simp add: cos_exp_eq sin_exp_eq exp_minus exp_of_real Re_divide Im_divide) |
374 apply (simp add: cos_exp_eq sin_exp_eq exp_minus exp_of_real Re_divide Im_divide) |
377 apply (simp only: left_diff_distrib [symmetric] power_mult_distrib) |
375 apply (simp only: left_diff_distrib [symmetric] power_mult_distrib) |
385 apply (simp add: sin_add cmod_power2 cos_of_real sin_of_real cos_double_cos exp_double) |
383 apply (simp add: sin_add cmod_power2 cos_of_real sin_of_real cos_double_cos exp_double) |
386 apply (simp add: cos_exp_eq sin_exp_eq exp_minus exp_of_real Re_divide Im_divide) |
384 apply (simp add: cos_exp_eq sin_exp_eq exp_minus exp_of_real Re_divide Im_divide) |
387 apply (simp only: left_diff_distrib [symmetric] power_mult_distrib) |
385 apply (simp only: left_diff_distrib [symmetric] power_mult_distrib) |
388 apply (simp add: cos_squared_eq) |
386 apply (simp add: cos_squared_eq) |
389 apply (simp add: power2_eq_square algebra_simps divide_simps) |
387 apply (simp add: power2_eq_square algebra_simps divide_simps) |
390 done |
388 done |
391 |
389 |
392 lemma exp_uminus_Im: "exp (- Im z) \<le> exp (cmod z)" |
390 lemma exp_uminus_Im: "exp (- Im z) \<le> exp (cmod z)" |
393 using abs_Im_le_cmod linear order_trans by fastforce |
391 using abs_Im_le_cmod linear order_trans by fastforce |
394 |
392 |
395 lemma norm_cos_le: |
393 lemma norm_cos_le: |
396 fixes z::complex |
394 fixes z::complex |
397 shows "norm(cos z) \<le> exp(norm z)" |
395 shows "norm(cos z) \<le> exp(norm z)" |
398 proof - |
396 proof - |
399 have "Im z \<le> cmod z" |
397 have "Im z \<le> cmod z" |
400 using abs_Im_le_cmod abs_le_D1 by auto |
398 using abs_Im_le_cmod abs_le_D1 by auto |
403 apply (rule order_trans [OF norm_triangle_ineq], simp) |
401 apply (rule order_trans [OF norm_triangle_ineq], simp) |
404 apply (metis add_mono exp_le_cancel_iff mult_2_right) |
402 apply (metis add_mono exp_le_cancel_iff mult_2_right) |
405 done |
403 done |
406 qed |
404 qed |
407 |
405 |
408 lemma norm_cos_plus1_le: |
406 lemma norm_cos_plus1_le: |
409 fixes z::complex |
407 fixes z::complex |
410 shows "norm(1 + cos z) \<le> 2 * exp(norm z)" |
408 shows "norm(1 + cos z) \<le> 2 * exp(norm z)" |
411 proof - |
409 proof - |
412 have mono: "\<And>u w z::real. (1 \<le> w | 1 \<le> z) \<Longrightarrow> (w \<le> u & z \<le> u) \<Longrightarrow> 2 + w + z \<le> 4 * u" |
410 have mono: "\<And>u w z::real. (1 \<le> w | 1 \<le> z) \<Longrightarrow> (w \<le> u & z \<le> u) \<Longrightarrow> 2 + w + z \<le> 4 * u" |
413 by arith |
411 by arith |
429 done |
427 done |
430 qed |
428 qed |
431 |
429 |
432 subsection{* Taylor series for complex exponential, sine and cosine.*} |
430 subsection{* Taylor series for complex exponential, sine and cosine.*} |
433 |
431 |
434 context |
432 context |
435 begin |
433 begin |
436 |
434 |
437 declare power_Suc [simp del] |
435 declare power_Suc [simp del] |
438 |
436 |
439 lemma Taylor_exp: |
437 lemma Taylor_exp: |
440 "norm(exp z - (\<Sum>k\<le>n. z ^ k / (fact k))) \<le> exp\<bar>Re z\<bar> * (norm z) ^ (Suc n) / (fact n)" |
438 "norm(exp z - (\<Sum>k\<le>n. z ^ k / (fact k))) \<le> exp\<bar>Re z\<bar> * (norm z) ^ (Suc n) / (fact n)" |
441 proof (rule complex_taylor [of _ n "\<lambda>k. exp" "exp\<bar>Re z\<bar>" 0 z, simplified]) |
439 proof (rule complex_taylor [of _ n "\<lambda>k. exp" "exp\<bar>Re z\<bar>" 0 z, simplified]) |
442 show "convex (closed_segment 0 z)" |
440 show "convex (closed_segment 0 z)" |
443 by (rule convex_segment [of 0 z]) |
441 by (rule convex_segment [of 0 z]) |
444 next |
442 next |
457 by (auto simp: closed_segment_def) |
455 by (auto simp: closed_segment_def) |
458 next |
456 next |
459 show "z \<in> closed_segment 0 z" |
457 show "z \<in> closed_segment 0 z" |
460 apply (simp add: closed_segment_def scaleR_conv_of_real) |
458 apply (simp add: closed_segment_def scaleR_conv_of_real) |
461 using of_real_1 zero_le_one by blast |
459 using of_real_1 zero_le_one by blast |
462 qed |
460 qed |
463 |
461 |
464 lemma |
462 lemma |
465 assumes "0 \<le> u" "u \<le> 1" |
463 assumes "0 \<le> u" "u \<le> 1" |
466 shows cmod_sin_le_exp: "cmod (sin (u *\<^sub>R z)) \<le> exp \<bar>Im z\<bar>" |
464 shows cmod_sin_le_exp: "cmod (sin (u *\<^sub>R z)) \<le> exp \<bar>Im z\<bar>" |
467 and cmod_cos_le_exp: "cmod (cos (u *\<^sub>R z)) \<le> exp \<bar>Im z\<bar>" |
465 and cmod_cos_le_exp: "cmod (cos (u *\<^sub>R z)) \<le> exp \<bar>Im z\<bar>" |
468 proof - |
466 proof - |
469 have mono: "\<And>u w z::real. w \<le> u \<Longrightarrow> z \<le> u \<Longrightarrow> w + z \<le> u*2" |
467 have mono: "\<And>u w z::real. w \<le> u \<Longrightarrow> z \<le> u \<Longrightarrow> w + z \<le> u*2" |
470 by arith |
468 by arith |
471 show "cmod (sin (u *\<^sub>R z)) \<le> exp \<bar>Im z\<bar>" using assms |
469 show "cmod (sin (u *\<^sub>R z)) \<le> exp \<bar>Im z\<bar>" using assms |
483 apply (auto simp: abs_if mult_left_le_one_le) |
481 apply (auto simp: abs_if mult_left_le_one_le) |
484 apply (meson mult_nonneg_nonneg neg_le_0_iff_le not_le order_trans) |
482 apply (meson mult_nonneg_nonneg neg_le_0_iff_le not_le order_trans) |
485 apply (meson less_eq_real_def mult_nonneg_nonpos neg_0_le_iff_le order_trans) |
483 apply (meson less_eq_real_def mult_nonneg_nonpos neg_0_le_iff_le order_trans) |
486 done |
484 done |
487 qed |
485 qed |
488 |
486 |
489 lemma Taylor_sin: |
487 lemma Taylor_sin: |
490 "norm(sin z - (\<Sum>k\<le>n. complex_of_real (sin_coeff k) * z ^ k)) |
488 "norm(sin z - (\<Sum>k\<le>n. complex_of_real (sin_coeff k) * z ^ k)) |
491 \<le> exp\<bar>Im z\<bar> * (norm z) ^ (Suc n) / (fact n)" |
489 \<le> exp\<bar>Im z\<bar> * (norm z) ^ (Suc n) / (fact n)" |
492 proof - |
490 proof - |
493 have mono: "\<And>u w z::real. w \<le> u \<Longrightarrow> z \<le> u \<Longrightarrow> w + z \<le> u*2" |
491 have mono: "\<And>u w z::real. w \<le> u \<Longrightarrow> z \<le> u \<Longrightarrow> w + z \<le> u*2" |
494 by arith |
492 by arith |
495 have *: "cmod (sin z - |
493 have *: "cmod (sin z - |
496 (\<Sum>i\<le>n. (-1) ^ (i div 2) * (if even i then sin 0 else cos 0) * z ^ i / (fact i))) |
494 (\<Sum>i\<le>n. (-1) ^ (i div 2) * (if even i then sin 0 else cos 0) * z ^ i / (fact i))) |
497 \<le> exp \<bar>Im z\<bar> * cmod z ^ Suc n / (fact n)" |
495 \<le> exp \<bar>Im z\<bar> * cmod z ^ Suc n / (fact n)" |
498 proof (rule complex_taylor [of "closed_segment 0 z" n "\<lambda>k x. (-1)^(k div 2) * (if even k then sin x else cos x)" "exp\<bar>Im z\<bar>" 0 z, |
496 proof (rule complex_taylor [of "closed_segment 0 z" n "\<lambda>k x. (-1)^(k div 2) * (if even k then sin x else cos x)" "exp\<bar>Im z\<bar>" 0 z, |
499 simplified]) |
497 simplified]) |
500 show "convex (closed_segment 0 z)" |
498 show "convex (closed_segment 0 z)" |
501 by (rule convex_segment [of 0 z]) |
499 by (rule convex_segment [of 0 z]) |
502 next |
500 next |
517 by (auto simp: closed_segment_def) |
515 by (auto simp: closed_segment_def) |
518 next |
516 next |
519 show "z \<in> closed_segment 0 z" |
517 show "z \<in> closed_segment 0 z" |
520 apply (simp add: closed_segment_def scaleR_conv_of_real) |
518 apply (simp add: closed_segment_def scaleR_conv_of_real) |
521 using of_real_1 zero_le_one by blast |
519 using of_real_1 zero_le_one by blast |
522 qed |
520 qed |
523 have **: "\<And>k. complex_of_real (sin_coeff k) * z ^ k |
521 have **: "\<And>k. complex_of_real (sin_coeff k) * z ^ k |
524 = (-1)^(k div 2) * (if even k then sin 0 else cos 0) * z^k / of_nat (fact k)" |
522 = (-1)^(k div 2) * (if even k then sin 0 else cos 0) * z^k / of_nat (fact k)" |
525 by (auto simp: sin_coeff_def elim!: oddE) |
523 by (auto simp: sin_coeff_def elim!: oddE) |
526 show ?thesis |
524 show ?thesis |
527 apply (rule order_trans [OF _ *]) |
525 apply (rule order_trans [OF _ *]) |
528 apply (simp add: **) |
526 apply (simp add: **) |
529 done |
527 done |
530 qed |
528 qed |
531 |
529 |
532 lemma Taylor_cos: |
530 lemma Taylor_cos: |
533 "norm(cos z - (\<Sum>k\<le>n. complex_of_real (cos_coeff k) * z ^ k)) |
531 "norm(cos z - (\<Sum>k\<le>n. complex_of_real (cos_coeff k) * z ^ k)) |
534 \<le> exp\<bar>Im z\<bar> * (norm z) ^ Suc n / (fact n)" |
532 \<le> exp\<bar>Im z\<bar> * (norm z) ^ Suc n / (fact n)" |
535 proof - |
533 proof - |
536 have mono: "\<And>u w z::real. w \<le> u \<Longrightarrow> z \<le> u \<Longrightarrow> w + z \<le> u*2" |
534 have mono: "\<And>u w z::real. w \<le> u \<Longrightarrow> z \<le> u \<Longrightarrow> w + z \<le> u*2" |
537 by arith |
535 by arith |
538 have *: "cmod (cos z - |
536 have *: "cmod (cos z - |
539 (\<Sum>i\<le>n. (-1) ^ (Suc i div 2) * (if even i then cos 0 else sin 0) * z ^ i / (fact i))) |
537 (\<Sum>i\<le>n. (-1) ^ (Suc i div 2) * (if even i then cos 0 else sin 0) * z ^ i / (fact i))) |
540 \<le> exp \<bar>Im z\<bar> * cmod z ^ Suc n / (fact n)" |
538 \<le> exp \<bar>Im z\<bar> * cmod z ^ Suc n / (fact n)" |
541 proof (rule complex_taylor [of "closed_segment 0 z" n "\<lambda>k x. (-1)^(Suc k div 2) * (if even k then cos x else sin x)" "exp\<bar>Im z\<bar>" 0 z, |
539 proof (rule complex_taylor [of "closed_segment 0 z" n "\<lambda>k x. (-1)^(Suc k div 2) * (if even k then cos x else sin x)" "exp\<bar>Im z\<bar>" 0 z, |
542 simplified]) |
540 simplified]) |
543 show "convex (closed_segment 0 z)" |
541 show "convex (closed_segment 0 z)" |
544 by (rule convex_segment [of 0 z]) |
542 by (rule convex_segment [of 0 z]) |
545 next |
543 next |
561 by (auto simp: closed_segment_def) |
559 by (auto simp: closed_segment_def) |
562 next |
560 next |
563 show "z \<in> closed_segment 0 z" |
561 show "z \<in> closed_segment 0 z" |
564 apply (simp add: closed_segment_def scaleR_conv_of_real) |
562 apply (simp add: closed_segment_def scaleR_conv_of_real) |
565 using of_real_1 zero_le_one by blast |
563 using of_real_1 zero_le_one by blast |
566 qed |
564 qed |
567 have **: "\<And>k. complex_of_real (cos_coeff k) * z ^ k |
565 have **: "\<And>k. complex_of_real (cos_coeff k) * z ^ k |
568 = (-1)^(Suc k div 2) * (if even k then cos 0 else sin 0) * z^k / of_nat (fact k)" |
566 = (-1)^(Suc k div 2) * (if even k then cos 0 else sin 0) * z^k / of_nat (fact k)" |
569 by (auto simp: cos_coeff_def elim!: evenE) |
567 by (auto simp: cos_coeff_def elim!: evenE) |
570 show ?thesis |
568 show ?thesis |
571 apply (rule order_trans [OF _ *]) |
569 apply (rule order_trans [OF _ *]) |
908 apply (cases "a=0", simp) |
906 apply (cases "a=0", simp) |
909 apply (rule_tac x= "exp(Ln(a) / n)" in exI) |
907 apply (rule_tac x= "exp(Ln(a) / n)" in exI) |
910 apply (auto simp: exp_of_nat_mult [symmetric]) |
908 apply (auto simp: exp_of_nat_mult [symmetric]) |
911 done |
909 done |
912 |
910 |
|
911 subsection{*The Unwinding Number and the Ln-product Formula*} |
|
912 |
|
913 text{*Note that in this special case the unwinding number is -1, 0 or 1.*} |
|
914 |
|
915 definition unwinding :: "complex \<Rightarrow> complex" where |
|
916 "unwinding(z) = (z - Ln(exp z)) / (of_real(2*pi) * ii)" |
|
917 |
|
918 lemma unwinding_2pi: "(2*pi) * ii * unwinding(z) = z - Ln(exp z)" |
|
919 by (simp add: unwinding_def) |
|
920 |
|
921 lemma Ln_times_unwinding: |
|
922 "w \<noteq> 0 \<Longrightarrow> z \<noteq> 0 \<Longrightarrow> Ln(w * z) = Ln(w) + Ln(z) - (2*pi) * ii * unwinding(Ln w + Ln z)" |
|
923 using unwinding_2pi by (simp add: exp_add) |
|
924 |
|
925 |
913 subsection{*Derivative of Ln away from the branch cut*} |
926 subsection{*Derivative of Ln away from the branch cut*} |
914 |
927 |
915 lemma |
928 lemma |
916 assumes "Im(z) = 0 \<Longrightarrow> 0 < Re(z)" |
929 assumes "Im(z) = 0 \<Longrightarrow> 0 < Re(z)" |
917 shows has_field_derivative_Ln: "(Ln has_field_derivative inverse(z)) (at z)" |
930 shows has_field_derivative_Ln: "(Ln has_field_derivative inverse(z)) (at z)" |
942 using complex_differentiable_at_Ln complex_differentiable_within_subset by blast |
955 using complex_differentiable_at_Ln complex_differentiable_within_subset by blast |
943 |
956 |
944 lemma continuous_at_Ln: "(Im(z) = 0 \<Longrightarrow> 0 < Re(z)) \<Longrightarrow> continuous (at z) Ln" |
957 lemma continuous_at_Ln: "(Im(z) = 0 \<Longrightarrow> 0 < Re(z)) \<Longrightarrow> continuous (at z) Ln" |
945 by (simp add: complex_differentiable_imp_continuous_at complex_differentiable_within_Ln) |
958 by (simp add: complex_differentiable_imp_continuous_at complex_differentiable_within_Ln) |
946 |
959 |
|
960 lemma isCont_Ln' [simp]: |
|
961 "\<lbrakk>isCont f z; Im(f z) = 0 \<Longrightarrow> 0 < Re(f z)\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. Ln (f x)) z" |
|
962 by (blast intro: isCont_o2 [OF _ continuous_at_Ln]) |
|
963 |
947 lemma continuous_within_Ln: "(Im(z) = 0 \<Longrightarrow> 0 < Re(z)) \<Longrightarrow> continuous (at z within s) Ln" |
964 lemma continuous_within_Ln: "(Im(z) = 0 \<Longrightarrow> 0 < Re(z)) \<Longrightarrow> continuous (at z within s) Ln" |
948 using continuous_at_Ln continuous_at_imp_continuous_within by blast |
965 using continuous_at_Ln continuous_at_imp_continuous_within by blast |
949 |
966 |
950 lemma continuous_on_Ln [continuous_intros]: "(\<And>z. z \<in> s \<Longrightarrow> Im(z) = 0 \<Longrightarrow> 0 < Re(z)) \<Longrightarrow> continuous_on s Ln" |
967 lemma continuous_on_Ln [continuous_intros]: "(\<And>z. z \<in> s \<Longrightarrow> Im(z) = 0 \<Longrightarrow> 0 < Re(z)) \<Longrightarrow> continuous_on s Ln" |
951 by (simp add: continuous_at_imp_continuous_on continuous_within_Ln) |
968 by (simp add: continuous_at_imp_continuous_on continuous_within_Ln) |
954 by (simp add: complex_differentiable_within_Ln holomorphic_on_def) |
971 by (simp add: complex_differentiable_within_Ln holomorphic_on_def) |
955 |
972 |
956 |
973 |
957 subsection{*Relation to Real Logarithm*} |
974 subsection{*Relation to Real Logarithm*} |
958 |
975 |
959 lemma ln_of_real: |
976 lemma Ln_of_real: |
960 assumes "0 < z" |
977 assumes "0 < z" |
961 shows "Ln(of_real z) = of_real(ln z)" |
978 shows "Ln(of_real z) = of_real(ln z)" |
962 proof - |
979 proof - |
963 have "Ln(of_real (exp (ln z))) = Ln (exp (of_real (ln z)))" |
980 have "Ln(of_real (exp (ln z))) = Ln (exp (of_real (ln z)))" |
964 by (simp add: exp_of_real) |
981 by (simp add: exp_of_real) |
1260 |
1280 |
1261 lemma continuous_at_csqrt: |
1281 lemma continuous_at_csqrt: |
1262 "(Im z = 0 \<Longrightarrow> 0 < Re(z)) \<Longrightarrow> continuous (at z) csqrt" |
1282 "(Im z = 0 \<Longrightarrow> 0 < Re(z)) \<Longrightarrow> continuous (at z) csqrt" |
1263 by (simp add: complex_differentiable_within_csqrt complex_differentiable_imp_continuous_at) |
1283 by (simp add: complex_differentiable_within_csqrt complex_differentiable_imp_continuous_at) |
1264 |
1284 |
|
1285 corollary isCont_csqrt' [simp]: |
|
1286 "\<lbrakk>isCont f z; Im(f z) = 0 \<Longrightarrow> 0 < Re(f z)\<rbrakk> \<Longrightarrow> isCont (\<lambda>x. csqrt (f x)) z" |
|
1287 by (blast intro: isCont_o2 [OF _ continuous_at_csqrt]) |
|
1288 |
1265 lemma continuous_within_csqrt: |
1289 lemma continuous_within_csqrt: |
1266 "(Im z = 0 \<Longrightarrow> 0 < Re(z)) \<Longrightarrow> continuous (at z within s) csqrt" |
1290 "(Im z = 0 \<Longrightarrow> 0 < Re(z)) \<Longrightarrow> continuous (at z within s) csqrt" |
1267 by (simp add: complex_differentiable_imp_continuous_at complex_differentiable_within_csqrt) |
1291 by (simp add: complex_differentiable_imp_continuous_at complex_differentiable_within_csqrt) |
1268 |
1292 |
1269 lemma continuous_on_csqrt [continuous_intros]: |
1293 lemma continuous_on_csqrt [continuous_intros]: |