(** This file is part of the Coquelicot formalization of real analysis in Coq: http://coquelicot.saclay.inria.fr/  Copyright (C) 2011-2015 Sylvie Boldo #<br /># Copyright (C) 2011-2015 Catherine Lelay #<br /># Copyright (C) 2011-2015 Guillaume Melquiond  This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the COPYING file for more details. *)
(** This file describes an experiment: most 18-year old French students pass an exam called Baccalaureate which ends the high school and is required for attending the university. We took the 2013 mathematics test of the scientific Baccalaureate at the same time as the students. The pdf of the test is available #<a href="https://www.lri.fr/~lelay/Bac2013/Bac_S_2013_Metropole.pdf">here</a>#. This file is dedicated to the mathematics specialty exercise, done after the exam. *)
Open Scope R_scope.
(** * Bac 2013 - Exercice 4 spécialité *)
(** 1. Exprimer v (S n) et c (S n) en fonction de v n et c n *)
Fixpoint v (n : nat) : R :=
match n with
| O => 7 / 10 * 250000
| S n => 95 / 100 * v n + 1 / 100 * c n
end
with c (n : nat) : R :=
match n with
| O => 3 / 10 * 250000
| S n => 5 / 100 * v n + 99 / 100 * c n
end.
(** 2. Définition de la matrice A *)
Definition A : matrix 2 2 :=
[[95/100, 1/100 ] ,
[ 5/100, 99/100]].
Definition X (n : nat) : matrix 2 1 :=
[[v n],[c n]].
(** 3. Diagonalisation *)
Definition P : matrix 2 2 :=
[[1,-1], [5,1]].
Definition Q : matrix 2 2 :=
[[1,1],[-5,1]].
Goal mult P Q = [[6,0],[0,6]].
apply (coeff_mat_ext_aux 0 0) => i j Hi Hj.
rewrite coeff_mat_bij => //.
rewrite /coeff_mat /= /mult /plus /=.
(destruct i as [ | i] ; destruct j as [ | j] ; rewrite /zero /= ; try ring) ;
(try (destruct i as [ | i]) ; try (destruct j as [ | j]) ; rewrite /zero /= ; try ring) ;
rewrite sum_Sn sum_O /= /plus /= ; ring.
Qed.
Goal mult Q P = [[6,0],[0,6]].
apply (coeff_mat_ext_aux 0 0) => i j Hi Hj.
rewrite coeff_mat_bij => //.
rewrite /coeff_mat /= /mult /plus /=.
(destruct i as [ | i] ; destruct j as [ | j] ; rewrite /zero /= ; try ring) ;
(try (destruct i as [ | i]) ; try (destruct j as [ | j]) ; rewrite /zero /= ; try ring) ;
rewrite sum_Sn sum_O /= /plus /= ; ring.
Qed.
Definition P' : matrix 2 2 :=
[[1 / 6,1 / 6],[-5 / 6,1 / 6]].
Definition D : matrix 2 2 := [[1,0],[0,94 / 100]].
(** 4. Terme général et limite de la suite v n *)

Lemma lim_c : is_lim_seq c (208333 + 1 / 3).