1
(************************************************************************)
2
(* v * The Coq Proof Assistant / The Coq Development Team *)
3
(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *)
4
(* \VV/ **************************************************************)
5
(* // * This file is distributed under the terms of the *)
6
(* * GNU Lesser General Public License Version 2.1 *)
7
(************************************************************************)
9
(*i $Id: Cos_rel.v 10710 2008-03-23 09:24:09Z herbelin $ i*)
12
Require Import Rfunctions.
13
Require Import SeqSeries.
14
Require Import Rtrigo_def.
15
Open Local Scope R_scope.
17
Definition A1 (x:R) (N:nat) : R :=
18
sum_f_R0 (fun k:nat => (-1) ^ k / INR (fact (2 * k)) * x ^ (2 * k)) N.
20
Definition B1 (x:R) (N:nat) : R :=
21
sum_f_R0 (fun k:nat => (-1) ^ k / INR (fact (2 * k + 1)) * x ^ (2 * k + 1))
24
Definition C1 (x y:R) (N:nat) : R :=
25
sum_f_R0 (fun k:nat => (-1) ^ k / INR (fact (2 * k)) * (x + y) ^ (2 * k)) N.
27
Definition Reste1 (x y:R) (N:nat) : R :=
32
(-1) ^ S (l + k) / INR (fact (2 * S (l + k))) *
33
x ^ (2 * S (l + k)) * ((-1) ^ (N - l) / INR (fact (2 * (N - l)))) *
34
y ^ (2 * (N - l))) (pred (N - k))) (pred N).
36
Definition Reste2 (x y:R) (N:nat) : R :=
41
(-1) ^ S (l + k) / INR (fact (2 * S (l + k) + 1)) *
42
x ^ (2 * S (l + k) + 1) *
43
((-1) ^ (N - l) / INR (fact (2 * (N - l) + 1))) *
44
y ^ (2 * (N - l) + 1)) (pred (N - k))) (
47
Definition Reste (x y:R) (N:nat) : R := Reste2 x y N - Reste1 x y (S N).
49
(* Here is the main result that will be used to prove that (cos (x+y))=(cos x)(cos y)-(sin x)(sin y) *)
50
Theorem cos_plus_form :
51
forall (x y:R) (n:nat),
53
A1 x (S n) * A1 y (S n) - B1 x n * B1 y n + Reste x y n = C1 x y (S n).
55
unfold A1, B1 in |- *.
57
(cauchy_finite (fun k:nat => (-1) ^ k / INR (fact (2 * k)) * x ^ (2 * k))
58
(fun k:nat => (-1) ^ k / INR (fact (2 * k)) * y ^ (2 * k)) (
62
(fun k:nat => (-1) ^ k / INR (fact (2 * k + 1)) * x ^ (2 * k + 1))
63
(fun k:nat => (-1) ^ k / INR (fact (2 * k + 1)) * y ^ (2 * k + 1)) n H)
71
(-1) ^ S (l + k) / INR (fact (2 * S (l + k))) *
73
((-1) ^ (S n - l) / INR (fact (2 * (S n - l))) *
74
y ^ (2 * (S n - l)))) (pred (S n - k))) (
75
pred (S n))) with (Reste1 x y (S n)).
81
(-1) ^ S (l + k) / INR (fact (2 * S (l + k) + 1)) *
82
x ^ (2 * S (l + k) + 1) *
83
((-1) ^ (n - l) / INR (fact (2 * (n - l) + 1)) *
84
y ^ (2 * (n - l) + 1))) (pred (n - k))) (
85
pred n)) with (Reste2 x y n).
91
(-1) ^ p / INR (fact (2 * p)) * x ^ (2 * p) *
92
((-1) ^ (k - p) / INR (fact (2 * (k - p))) * y ^ (2 * (k - p))))
96
(-1) ^ k / INR (fact (2 * k)) *
98
(fun l:nat => C (2 * k) (2 * l) * x ^ (2 * l) * y ^ (2 * (k - l))) k)
106
(-1) ^ S p / INR (fact (2 * S p)) *
109
C (2 * S p) (S (2 * l)) * x ^ S (2 * l) * y ^ S (2 * (p - l))) p
114
(* (- old ring compat *)
120
(-1) ^ p / INR (fact (2 * p + 1)) * x ^ (2 * p + 1) *
121
((-1) ^ (k - p) / INR (fact (2 * (k - p) + 1)) *
122
y ^ (2 * (k - p) + 1))) k) n) with (sum_f_R0 sin_nnn (S n)).
125
apply sum_eq; intros.
126
induction i as [| i Hreci].
128
unfold C in |- *; simpl in |- *.
130
unfold sin_nnn in |- *.
131
rewrite <- Rmult_plus_distr_l.
132
apply Rmult_eq_compat_l.
134
pose (Wn := fun i0:nat => C (2 * S i) i0 * x ^ i0 * y ^ (2 * S i - i0)).
137
(fun l:nat => C (2 * S i) (2 * l) * x ^ (2 * l) * y ^ (2 * (S i - l)))
138
(S i)) with (sum_f_R0 (fun l:nat => Wn (2 * l)%nat) (S i)).
142
C (2 * S i) (S (2 * l)) * x ^ S (2 * l) * y ^ S (2 * (i - l))) i) with
143
(sum_f_R0 (fun l:nat => Wn (S (2 * l))) i).
144
apply sum_decomposition.
145
apply sum_eq; intros.
147
apply Rmult_eq_compat_l.
148
replace (2 * S i - S (2 * i0))%nat with (S (2 * (i - i0))).
151
apply sum_eq; intros.
153
apply Rmult_eq_compat_l.
154
replace (2 * S i - 2 * i0)%nat with (2 * (S i - i0))%nat.
163
(-1) ^ p / INR (fact (2 * p + 1)) * x ^ (2 * p + 1) *
164
((-1) ^ (k - p) / INR (fact (2 * (k - p) + 1)) *
165
y ^ (2 * (k - p) + 1))) k) n) with
171
(-1) ^ p / INR (fact (2 * p + 1)) * x ^ (2 * p + 1) *
172
((-1) ^ (k - p) / INR (fact (2 * (k - p) + 1)) *
173
y ^ (2 * (k - p) + 1))) k) n);[idtac|ring].
176
replace (sin_nnn 0%nat) with 0.
178
change (pred (S n)) with n.
179
(* replace (pred (S n)) with n; [ idtac | reflexivity ]. *)
180
apply sum_eq; intros.
182
unfold sin_nnn in |- *.
185
apply sum_eq; intros.
187
(*repeat rewrite Rmult_assoc.*)
188
(* rewrite (Rmult_comm (/ INR (fact (2 * S i)))). *)
189
repeat rewrite <- Rmult_assoc.
190
rewrite <- (Rmult_comm (/ INR (fact (2 * S i)))).
191
repeat rewrite <- Rmult_assoc.
192
replace (/ INR (fact (2 * S i)) * C (2 * S i) (S (2 * i0))) with
193
(/ INR (fact (2 * i0 + 1)) * / INR (fact (2 * (i - i0) + 1))).
194
replace (S (2 * i0)) with (2 * i0 + 1)%nat; [ idtac | ring ].
195
replace (S (2 * (i - i0))) with (2 * (i - i0) + 1)%nat; [ idtac | ring ].
196
replace ((-1) ^ S i) with (-1 * (-1) ^ i0 * (-1) ^ (i - i0)).
199
pattern i at 2 in |- *; replace i with (i0 + (i - i0))%nat.
202
symmetry in |- *; apply le_plus_minus; assumption.
204
unfold Rdiv in |- *; repeat rewrite <- Rmult_assoc.
205
rewrite <- Rinv_l_sym.
207
rewrite Rinv_mult_distr.
208
replace (S (2 * i0)) with (2 * i0 + 1)%nat;
209
[ apply Rmult_eq_compat_l | ring ].
210
replace (2 * S i - (2 * i0 + 1))%nat with (2 * (i - i0) + 1)%nat.
213
apply INR_fact_neq_0.
214
apply INR_fact_neq_0.
215
apply INR_fact_neq_0.
219
apply sum_eq; intros.
221
apply sum_eq; intros.
223
repeat rewrite <- Rmult_assoc.
224
rewrite <- (Rmult_comm (/ INR (fact (2 * i)))).
225
repeat rewrite <- Rmult_assoc.
226
replace (/ INR (fact (2 * i)) * C (2 * i) (2 * i0)) with
227
(/ INR (fact (2 * i0)) * / INR (fact (2 * (i - i0)))).
228
replace ((-1) ^ i) with ((-1) ^ i0 * (-1) ^ (i - i0)).
230
pattern i at 2 in |- *; replace i with (i0 + (i - i0))%nat.
233
symmetry in |- *; apply le_plus_minus; assumption.
235
unfold Rdiv in |- *; repeat rewrite <- Rmult_assoc.
236
rewrite <- Rinv_l_sym.
238
rewrite Rinv_mult_distr.
239
replace (2 * i - 2 * i0)%nat with (2 * (i - i0))%nat.
242
apply INR_fact_neq_0.
243
apply INR_fact_neq_0.
244
apply INR_fact_neq_0.
245
unfold Reste2 in |- *; apply sum_eq; intros.
246
apply sum_eq; intros.
247
unfold Rdiv in |- *; ring.
248
unfold Reste1 in |- *; apply sum_eq; intros.
249
apply sum_eq; intros.
250
unfold Rdiv in |- *; ring.
254
Lemma pow_sqr : forall (x:R) (i:nat), x ^ (2 * i) = (x * x) ^ i.
256
assert (H := pow_Rsqr x i).
257
unfold Rsqr in H; exact H.
260
Lemma A1_cvg : forall x:R, Un_cv (A1 x) (cos x).
262
assert (H := exist_cos (x * x)).
266
unfold cos_n, infinite_sum in p.
271
unfold Un_cv in |- *; unfold R_dist in |- *; intros.
272
elim (p eps H1); intros.
276
(sum_f_R0 (fun k:nat => (-1) ^ k / INR (fact (2 * k)) * x ^ (2 * k)) n) with
277
(sum_f_R0 (fun i:nat => (-1) ^ i / INR (fact (2 * i)) * (x * x) ^ i) n).
278
apply H2; assumption.
281
replace ((x * x) ^ i) with (x ^ (2 * i)).
285
case (exist_cos (Rsqr x)).
286
unfold Rsqr in |- *; intros.
287
unfold cos_in in p_i.
289
apply uniqueness_sum with (fun i:nat => cos_n i * (x * x) ^ i); assumption.
292
Lemma C1_cvg : forall x y:R, Un_cv (C1 x y) (cos (x + y)).
294
assert (H := exist_cos ((x + y) * (x + y))).
298
unfold cos_n, infinite_sum in p.
300
cut (cos (x + y) = x0).
303
unfold Un_cv in |- *; unfold R_dist in |- *; intros.
304
elim (p eps H1); intros.
308
(sum_f_R0 (fun k:nat => (-1) ^ k / INR (fact (2 * k)) * (x + y) ^ (2 * k)) n)
311
(fun i:nat => (-1) ^ i / INR (fact (2 * i)) * ((x + y) * (x + y)) ^ i) n).
312
apply H2; assumption.
315
replace (((x + y) * (x + y)) ^ i) with ((x + y) ^ (2 * i)).
319
case (exist_cos (Rsqr (x + y))).
320
unfold Rsqr in |- *; intros.
321
unfold cos_in in p_i.
323
apply uniqueness_sum with (fun i:nat => cos_n i * ((x + y) * (x + y)) ^ i);
327
Lemma B1_cvg : forall x:R, Un_cv (B1 x) (sin x).
329
case (Req_dec x 0); intro.
333
unfold Un_cv in |- *; unfold R_dist in |- *; intros; exists 0%nat; intros.
335
(sum_f_R0 (fun k:nat => (-1) ^ k / INR (fact (2 * k + 1)) * 0 ^ (2 * k + 1))
337
unfold Rminus in |- *; rewrite Rplus_opp_r; rewrite Rabs_R0; assumption.
338
induction n as [| n Hrecn].
340
rewrite tech5; rewrite <- Hrecn.
342
unfold ge in |- *; apply le_O_n.
343
assert (H0 := exist_sin (x * x)).
347
unfold sin_n, infinite_sum in p.
349
cut (sin x = x * x0).
352
unfold Un_cv in |- *; unfold R_dist in |- *; intros.
353
cut (0 < eps / Rabs x);
355
| unfold Rdiv in |- *; apply Rmult_lt_0_compat;
356
[ assumption | apply Rinv_0_lt_compat; apply Rabs_pos_lt; assumption ] ].
357
elim (p (eps / Rabs x) H3); intros.
361
(sum_f_R0 (fun k:nat => (-1) ^ k / INR (fact (2 * k + 1)) * x ^ (2 * k + 1))
364
sum_f_R0 (fun i:nat => (-1) ^ i / INR (fact (2 * i + 1)) * (x * x) ^ i) n).
367
sum_f_R0 (fun i:nat => (-1) ^ i / INR (fact (2 * i + 1)) * (x * x) ^ i) n -
370
(sum_f_R0 (fun i:nat => (-1) ^ i / INR (fact (2 * i + 1)) * (x * x) ^ i) n -
371
x0)); [ idtac | ring ].
373
apply Rmult_lt_reg_l with (/ Rabs x).
374
apply Rinv_0_lt_compat; apply Rabs_pos_lt; assumption.
375
rewrite <- Rmult_assoc.
376
rewrite <- Rinv_l_sym.
377
rewrite Rmult_1_l; rewrite <- (Rmult_comm eps); unfold Rdiv in H4; apply H4;
379
apply Rabs_no_R0; assumption.
388
case (exist_sin (Rsqr x)).
389
unfold Rsqr in |- *; intros.
390
unfold sin_in in p_i.
393
(H1 := uniqueness_sum (fun i:nat => sin_n i * (x * x) ^ i) x0 x1 p_i s).
394
rewrite H1; reflexivity.