# HG changeset patch # User huffman # Date 1313768383 25200 # Node ID 33572a766836ba6da23a413448e0dad4f60d398d # Parent 3bdc02eb16371de4405f6fab27fde4ed40c29e33 fold definitions of sin_coeff and cos_coeff in Maclaurin lemmas diff -r 3bdc02eb1637 -r 33572a766836 src/HOL/Decision_Procs/Approximation.thy --- a/src/HOL/Decision_Procs/Approximation.thy Fri Aug 19 07:45:22 2011 -0700 +++ b/src/HOL/Decision_Procs/Approximation.thy Fri Aug 19 08:39:43 2011 -0700 @@ -839,7 +839,8 @@ cos_eq: "cos x = (\ i = 0 ..< 2 * n. (if even(i) then (-1 ^ (i div 2))/(real (fact i)) else 0) * (real x) ^ i) + (cos (t + 1/2 * (2 * n) * pi) / real (fact (2*n))) * (real x)^(2*n)" (is "_ = ?SUM + ?rest / ?fact * ?pow") - using Maclaurin_cos_expansion2[OF `0 < real x` `0 < 2 * n`] by auto + using Maclaurin_cos_expansion2[OF `0 < real x` `0 < 2 * n`] + unfolding cos_coeff_def by auto have "cos t * -1^n = cos t * cos (n * pi) + sin t * sin (n * pi)" by auto also have "\ = cos (t + n * pi)" using cos_add by auto @@ -951,7 +952,8 @@ sin_eq: "sin x = (\ i = 0 ..< 2 * n + 1. (if even(i) then 0 else (-1 ^ ((i - Suc 0) div 2))/(real (fact i))) * (real x) ^ i) + (sin (t + 1/2 * (2 * n + 1) * pi) / real (fact (2*n + 1))) * (real x)^(2*n + 1)" (is "_ = ?SUM + ?rest / ?fact * ?pow") - using Maclaurin_sin_expansion3[OF `0 < 2 * n + 1` `0 < real x`] by auto + using Maclaurin_sin_expansion3[OF `0 < 2 * n + 1` `0 < real x`] + unfolding sin_coeff_def by auto have "?rest = cos t * -1^n" unfolding sin_add cos_add real_of_nat_add left_distrib right_distrib by auto moreover diff -r 3bdc02eb1637 -r 33572a766836 src/HOL/MacLaurin.thy --- a/src/HOL/MacLaurin.thy Fri Aug 19 07:45:22 2011 -0700 +++ b/src/HOL/MacLaurin.thy Fri Aug 19 08:39:43 2011 -0700 @@ -417,32 +417,32 @@ cos (x + real (m) * pi / 2)" by (simp only: cos_add sin_add real_of_nat_Suc add_divide_distrib left_distrib, auto) +lemma sin_coeff_0 [simp]: "sin_coeff 0 = 0" + unfolding sin_coeff_def by simp (* TODO: move *) + lemma Maclaurin_sin_expansion2: "\t. abs t \ abs x & sin x = - (\m=0..m=0..t. sin x = - (\m=0..m=0.. 0; 0 < x |] ==> \t. 0 < t & t < x & sin x = - (\m=0..m=0.. \t. 0 < t & t \ x & sin x = - (\m=0..m=0..m=0..<(Suc n). - (if even m then -1 ^ (m div 2)/(real (fact m)) else 0) * 0 ^ m) = 1" + "(\m=0..<(Suc n). cos_coeff m * 0 ^ m) = 1" by (induct "n", auto) lemma cos_expansion_lemma: @@ -499,10 +497,7 @@ lemma Maclaurin_cos_expansion: "\t. abs t \ abs x & cos x = - (\m=0..m=0.. 0 |] ==> \t. 0 < t & t < x & cos x = - (\m=0..m=0.. 0 |] ==> \t. x < t & t < 0 & cos x = - (\m=0..m=0..m=0.. inverse(real (fact n)) * \x\ ^ n" + "abs(sin x - (\m=0.. inverse(real (fact n)) * \x\ ^ n" proof - have "!! x (y::real). x \ 1 \ 0 \ y \ x * y \ 1 * y" by (rule_tac mult_right_mono,simp_all) @@ -592,6 +581,7 @@ apply (safe dest!: mod_eqD, simp_all) done show ?thesis + unfolding sin_coeff_def apply (subst t2) apply (rule sin_bound_lemma) apply (rule setsum_cong[OF refl])