src/HOL/Transcendental.thy
changeset 58410 6d46ad54a2ab
parent 57514 bdc2c6b40bf2
child 58656 7f14d5d9b933
equal deleted inserted replaced
58409:24096e89c131 58410:6d46ad54a2ab
   245 subsection {* Alternating series test / Leibniz formula *}
   245 subsection {* Alternating series test / Leibniz formula *}
   246 
   246 
   247 lemma sums_alternating_upper_lower:
   247 lemma sums_alternating_upper_lower:
   248   fixes a :: "nat \<Rightarrow> real"
   248   fixes a :: "nat \<Rightarrow> real"
   249   assumes mono: "\<And>n. a (Suc n) \<le> a n" and a_pos: "\<And>n. 0 \<le> a n" and "a ----> 0"
   249   assumes mono: "\<And>n. a (Suc n) \<le> a n" and a_pos: "\<And>n. 0 \<le> a n" and "a ----> 0"
   250   shows "\<exists>l. ((\<forall>n. (\<Sum>i<2*n. -1^i*a i) \<le> l) \<and> (\<lambda> n. \<Sum>i<2*n. -1^i*a i) ----> l) \<and>
   250   shows "\<exists>l. ((\<forall>n. (\<Sum>i<2*n. (- 1)^i*a i) \<le> l) \<and> (\<lambda> n. \<Sum>i<2*n. (- 1)^i*a i) ----> l) \<and>
   251              ((\<forall>n. l \<le> (\<Sum>i<2*n + 1. -1^i*a i)) \<and> (\<lambda> n. \<Sum>i<2*n + 1. -1^i*a i) ----> l)"
   251              ((\<forall>n. l \<le> (\<Sum>i<2*n + 1. (- 1)^i*a i)) \<and> (\<lambda> n. \<Sum>i<2*n + 1. (- 1)^i*a i) ----> l)"
   252   (is "\<exists>l. ((\<forall>n. ?f n \<le> l) \<and> _) \<and> ((\<forall>n. l \<le> ?g n) \<and> _)")
   252   (is "\<exists>l. ((\<forall>n. ?f n \<le> l) \<and> _) \<and> ((\<forall>n. l \<le> ?g n) \<and> _)")
   253 proof (rule nested_sequence_unique)
   253 proof (rule nested_sequence_unique)
   254   have fg_diff: "\<And>n. ?f n - ?g n = - a (2 * n)" unfolding One_nat_def by auto
   254   have fg_diff: "\<And>n. ?f n - ?g n = - a (2 * n)" unfolding One_nat_def by auto
   255 
   255 
   256   show "\<forall>n. ?f n \<le> ?f (Suc n)"
   256   show "\<forall>n. ?f n \<le> ?f (Suc n)"
   365 theorem summable_Leibniz:
   365 theorem summable_Leibniz:
   366   fixes a :: "nat \<Rightarrow> real"
   366   fixes a :: "nat \<Rightarrow> real"
   367   assumes a_zero: "a ----> 0" and "monoseq a"
   367   assumes a_zero: "a ----> 0" and "monoseq a"
   368   shows "summable (\<lambda> n. (-1)^n * a n)" (is "?summable")
   368   shows "summable (\<lambda> n. (-1)^n * a n)" (is "?summable")
   369     and "0 < a 0 \<longrightarrow>
   369     and "0 < a 0 \<longrightarrow>
   370       (\<forall>n. (\<Sum>i. -1^i*a i) \<in> { \<Sum>i<2*n. -1^i * a i .. \<Sum>i<2*n+1. -1^i * a i})" (is "?pos")
   370       (\<forall>n. (\<Sum>i. (- 1)^i*a i) \<in> { \<Sum>i<2*n. (- 1)^i * a i .. \<Sum>i<2*n+1. (- 1)^i * a i})" (is "?pos")
   371     and "a 0 < 0 \<longrightarrow>
   371     and "a 0 < 0 \<longrightarrow>
   372       (\<forall>n. (\<Sum>i. -1^i*a i) \<in> { \<Sum>i<2*n+1. -1^i * a i .. \<Sum>i<2*n. -1^i * a i})" (is "?neg")
   372       (\<forall>n. (\<Sum>i. (- 1)^i*a i) \<in> { \<Sum>i<2*n+1. (- 1)^i * a i .. \<Sum>i<2*n. (- 1)^i * a i})" (is "?neg")
   373     and "(\<lambda>n. \<Sum>i<2*n. -1^i*a i) ----> (\<Sum>i. -1^i*a i)" (is "?f")
   373     and "(\<lambda>n. \<Sum>i<2*n. (- 1)^i*a i) ----> (\<Sum>i. (- 1)^i*a i)" (is "?f")
   374     and "(\<lambda>n. \<Sum>i<2*n+1. -1^i*a i) ----> (\<Sum>i. -1^i*a i)" (is "?g")
   374     and "(\<lambda>n. \<Sum>i<2*n+1. (- 1)^i*a i) ----> (\<Sum>i. (- 1)^i*a i)" (is "?g")
   375 proof -
   375 proof -
   376   have "?summable \<and> ?pos \<and> ?neg \<and> ?f \<and> ?g"
   376   have "?summable \<and> ?pos \<and> ?neg \<and> ?f \<and> ?g"
   377   proof (cases "(\<forall> n. 0 \<le> a n) \<and> (\<forall>m. \<forall>n\<ge>m. a n \<le> a m)")
   377   proof (cases "(\<forall> n. 0 \<le> a n) \<and> (\<forall>m. \<forall>n\<ge>m. a n \<le> a m)")
   378     case True
   378     case True
   379     hence ord: "\<And>n m. m \<le> n \<Longrightarrow> a n \<le> a m" and ge0: "\<And> n. 0 \<le> a n"
   379     hence ord: "\<And>n m. m \<le> n \<Longrightarrow> a n \<le> a m" and ge0: "\<And> n. 0 \<le> a n"
   411     moreover
   411     moreover
   412     have "\<And>a b :: real. \<bar>- a - - b\<bar> = \<bar>a - b\<bar>"
   412     have "\<And>a b :: real. \<bar>- a - - b\<bar> = \<bar>a - b\<bar>"
   413       unfolding minus_diff_minus by auto
   413       unfolding minus_diff_minus by auto
   414 
   414 
   415     from suminf_minus[OF leibniz(1), unfolded mult_minus_right minus_minus]
   415     from suminf_minus[OF leibniz(1), unfolded mult_minus_right minus_minus]
   416     have move_minus: "(\<Sum>n. - (-1 ^ n * a n)) = - (\<Sum>n. -1 ^ n * a n)"
   416     have move_minus: "(\<Sum>n. - ((- 1) ^ n * a n)) = - (\<Sum>n. (- 1) ^ n * a n)"
   417       by auto
   417       by auto
   418 
   418 
   419     have ?pos using `0 \<le> ?a 0` by auto
   419     have ?pos using `0 \<le> ?a 0` by auto
   420     moreover have ?neg
   420     moreover have ?neg
   421       using leibniz(2,4)
   421       using leibniz(2,4)
  1381       show "x - 1 \<in> {- 1<..<1}" and "(0 :: real) < 1"
  1381       show "x - 1 \<in> {- 1<..<1}" and "(0 :: real) < 1"
  1382         using `0 < x` `x < 2` by auto
  1382         using `0 < x` `x < 2` by auto
  1383       fix x :: real
  1383       fix x :: real
  1384       assume "x \<in> {- 1<..<1}"
  1384       assume "x \<in> {- 1<..<1}"
  1385       hence "norm (-x) < 1" by auto
  1385       hence "norm (-x) < 1" by auto
  1386       show "summable (\<lambda>n. -1 ^ n * (1 / real (n + 1)) * real (Suc n) * x ^ n)"
  1386       show "summable (\<lambda>n. (- 1) ^ n * (1 / real (n + 1)) * real (Suc n) * x ^ n)"
  1387         unfolding One_nat_def
  1387         unfolding One_nat_def
  1388         by (auto simp add: power_mult_distrib[symmetric] summable_geometric[OF `norm (-x) < 1`])
  1388         by (auto simp add: power_mult_distrib[symmetric] summable_geometric[OF `norm (-x) < 1`])
  1389     qed
  1389     qed
  1390     hence "DERIV (\<lambda>x. suminf (?f x)) (x - 1) :> suminf (?f' x)"
  1390     hence "DERIV (\<lambda>x. suminf (?f x)) (x - 1) :> suminf (?f' x)"
  1391       unfolding One_nat_def by auto
  1391       unfolding One_nat_def by auto
  2214 qed auto
  2214 qed auto
  2215 
  2215 
  2216 subsection {* Sine and Cosine *}
  2216 subsection {* Sine and Cosine *}
  2217 
  2217 
  2218 definition sin_coeff :: "nat \<Rightarrow> real" where
  2218 definition sin_coeff :: "nat \<Rightarrow> real" where
  2219   "sin_coeff = (\<lambda>n. if even n then 0 else -1 ^ ((n - Suc 0) div 2) / real (fact n))"
  2219   "sin_coeff = (\<lambda>n. if even n then 0 else (- 1) ^ ((n - Suc 0) div 2) / real (fact n))"
  2220 
  2220 
  2221 definition cos_coeff :: "nat \<Rightarrow> real" where
  2221 definition cos_coeff :: "nat \<Rightarrow> real" where
  2222   "cos_coeff = (\<lambda>n. if even n then (-1 ^ (n div 2)) / real (fact n) else 0)"
  2222   "cos_coeff = (\<lambda>n. if even n then ((- 1) ^ (n div 2)) / real (fact n) else 0)"
  2223 
  2223 
  2224 definition sin :: "real \<Rightarrow> real"
  2224 definition sin :: "real \<Rightarrow> real"
  2225   where "sin = (\<lambda>x. \<Sum>n. sin_coeff n * x ^ n)"
  2225   where "sin = (\<lambda>x. \<Sum>n. sin_coeff n * x ^ n)"
  2226 
  2226 
  2227 definition cos :: "real \<Rightarrow> real"
  2227 definition cos :: "real \<Rightarrow> real"
  2470 
  2470 
  2471 text{*Show that there's a least positive @{term x} with @{term "cos(x) = 0"};
  2471 text{*Show that there's a least positive @{term x} with @{term "cos(x) = 0"};
  2472    hence define pi.*}
  2472    hence define pi.*}
  2473 
  2473 
  2474 lemma sin_paired:
  2474 lemma sin_paired:
  2475   "(\<lambda>n. -1 ^ n /(real (fact (2 * n + 1))) * x ^ (2 * n + 1)) sums  sin x"
  2475   "(\<lambda>n. (- 1) ^ n /(real (fact (2 * n + 1))) * x ^ (2 * n + 1)) sums  sin x"
  2476 proof -
  2476 proof -
  2477   have "(\<lambda>n. \<Sum>k = n * 2..<n * 2 + 2. sin_coeff k * x ^ k) sums sin x"
  2477   have "(\<lambda>n. \<Sum>k = n * 2..<n * 2 + 2. sin_coeff k * x ^ k) sums sin x"
  2478     by (rule sin_converges [THEN sums_group], simp)
  2478     by (rule sin_converges [THEN sums_group], simp)
  2479   thus ?thesis unfolding One_nat_def sin_coeff_def by (simp add: ac_simps)
  2479   thus ?thesis unfolding One_nat_def sin_coeff_def by (simp add: ac_simps)
  2480 qed
  2480 qed
  2481 
  2481 
  2482 lemma sin_gt_zero:
  2482 lemma sin_gt_zero:
  2483   assumes "0 < x" and "x < 2"
  2483   assumes "0 < x" and "x < 2"
  2484   shows "0 < sin x"
  2484   shows "0 < sin x"
  2485 proof -
  2485 proof -
  2486   let ?f = "\<lambda>n. \<Sum>k = n*2..<n*2+2. -1 ^ k / real (fact (2*k+1)) * x^(2*k+1)"
  2486   let ?f = "\<lambda>n. \<Sum>k = n*2..<n*2+2. (- 1) ^ k / real (fact (2*k+1)) * x^(2*k+1)"
  2487   have pos: "\<forall>n. 0 < ?f n"
  2487   have pos: "\<forall>n. 0 < ?f n"
  2488   proof
  2488   proof
  2489     fix n :: nat
  2489     fix n :: nat
  2490     let ?k2 = "real (Suc (Suc (4 * n)))"
  2490     let ?k2 = "real (Suc (Suc (4 * n)))"
  2491     let ?k3 = "real (Suc (Suc (Suc (4 * n))))"
  2491     let ?k3 = "real (Suc (Suc (Suc (4 * n))))"
  2506 qed
  2506 qed
  2507 
  2507 
  2508 lemma cos_double_less_one: "0 < x \<Longrightarrow> x < 2 \<Longrightarrow> cos (2 * x) < 1"
  2508 lemma cos_double_less_one: "0 < x \<Longrightarrow> x < 2 \<Longrightarrow> cos (2 * x) < 1"
  2509   using sin_gt_zero [where x = x] by (auto simp add: cos_squared_eq cos_double)
  2509   using sin_gt_zero [where x = x] by (auto simp add: cos_squared_eq cos_double)
  2510 
  2510 
  2511 lemma cos_paired: "(\<lambda>n. -1 ^ n /(real (fact (2 * n))) * x ^ (2 * n)) sums cos x"
  2511 lemma cos_paired: "(\<lambda>n. (- 1) ^ n /(real (fact (2 * n))) * x ^ (2 * n)) sums cos x"
  2512 proof -
  2512 proof -
  2513   have "(\<lambda>n. \<Sum>k = n * 2..<n * 2 + 2. cos_coeff k * x ^ k) sums cos x"
  2513   have "(\<lambda>n. \<Sum>k = n * 2..<n * 2 + 2. cos_coeff k * x ^ k) sums cos x"
  2514     by (rule cos_converges [THEN sums_group], simp)
  2514     by (rule cos_converges [THEN sums_group], simp)
  2515   thus ?thesis unfolding cos_coeff_def by (simp add: ac_simps)
  2515   thus ?thesis unfolding cos_coeff_def by (simp add: ac_simps)
  2516 qed
  2516 qed
  2539 lemma cos_two_less_zero [simp]:
  2539 lemma cos_two_less_zero [simp]:
  2540   "cos 2 < 0"
  2540   "cos 2 < 0"
  2541 proof -
  2541 proof -
  2542   note fact_Suc [simp del]
  2542   note fact_Suc [simp del]
  2543   from cos_paired
  2543   from cos_paired
  2544   have "(\<lambda>n. - (-1 ^ n / real (fact (2 * n)) * 2 ^ (2 * n))) sums - cos 2"
  2544   have "(\<lambda>n. - ((- 1) ^ n / real (fact (2 * n)) * 2 ^ (2 * n))) sums - cos 2"
  2545     by (rule sums_minus)
  2545     by (rule sums_minus)
  2546   then have *: "(\<lambda>n. - (-1 ^ n * 2 ^ (2 * n) / real (fact (2 * n)))) sums - cos 2"
  2546   then have *: "(\<lambda>n. - ((- 1) ^ n * 2 ^ (2 * n) / real (fact (2 * n)))) sums - cos 2"
  2547     by simp
  2547     by simp
  2548   then have **: "summable (\<lambda>n. - (-1 ^ n * 2 ^ (2 * n) / real (fact (2 * n))))"
  2548   then have **: "summable (\<lambda>n. - ((- 1) ^ n * 2 ^ (2 * n) / real (fact (2 * n))))"
  2549     by (rule sums_summable)
  2549     by (rule sums_summable)
  2550   have "0 < (\<Sum>n<Suc (Suc (Suc 0)). - (-1 ^ n * 2 ^ (2 * n) / real (fact (2 * n))))"
  2550   have "0 < (\<Sum>n<Suc (Suc (Suc 0)). - ((- 1) ^ n * 2 ^ (2 * n) / real (fact (2 * n))))"
  2551     by (simp add: fact_num_eq_if_nat realpow_num_eq_if)
  2551     by (simp add: fact_num_eq_if_nat realpow_num_eq_if)
  2552   moreover have "(\<Sum>n<Suc (Suc (Suc 0)). - (-1 ^ n  * 2 ^ (2 * n) / real (fact (2 * n))))
  2552   moreover have "(\<Sum>n<Suc (Suc (Suc 0)). - ((- 1) ^ n  * 2 ^ (2 * n) / real (fact (2 * n))))
  2553     < (\<Sum>n. - (-1 ^ n * 2 ^ (2 * n) / real (fact (2 * n))))"
  2553     < (\<Sum>n. - ((- 1) ^ n * 2 ^ (2 * n) / real (fact (2 * n))))"
  2554   proof -
  2554   proof -
  2555     { fix d
  2555     { fix d
  2556       have "4 * real (fact (Suc (Suc (Suc (Suc (Suc (Suc (4 * d))))))))
  2556       have "4 * real (fact (Suc (Suc (Suc (Suc (Suc (Suc (4 * d))))))))
  2557        < real (Suc (Suc (Suc (Suc (Suc (Suc (Suc (Suc (4 * d)))))))) *
  2557        < real (Suc (Suc (Suc (Suc (Suc (Suc (Suc (Suc (4 * d)))))))) *
  2558            fact (Suc (Suc (Suc (Suc (Suc (Suc (Suc (4 * d)))))))))"
  2558            fact (Suc (Suc (Suc (Suc (Suc (Suc (Suc (4 * d)))))))))"
  2567     note *** = this
  2567     note *** = this
  2568     have [simp]: "\<And>x y::real. 0 < x - y \<longleftrightarrow> y < x" by arith
  2568     have [simp]: "\<And>x y::real. 0 < x - y \<longleftrightarrow> y < x" by arith
  2569     from ** show ?thesis by (rule sumr_pos_lt_pair)
  2569     from ** show ?thesis by (rule sumr_pos_lt_pair)
  2570       (simp add: divide_inverse mult.assoc [symmetric] ***)
  2570       (simp add: divide_inverse mult.assoc [symmetric] ***)
  2571   qed
  2571   qed
  2572   ultimately have "0 < (\<Sum>n. - (-1 ^ n * 2 ^ (2 * n) / real (fact (2 * n))))"
  2572   ultimately have "0 < (\<Sum>n. - ((- 1) ^ n * 2 ^ (2 * n) / real (fact (2 * n))))"
  2573     by (rule order_less_trans)
  2573     by (rule order_less_trans)
  2574   moreover from * have "- cos 2 = (\<Sum>n. - (-1 ^ n * 2 ^ (2 * n) / real (fact (2 * n))))"
  2574   moreover from * have "- cos 2 = (\<Sum>n. - ((- 1) ^ n * 2 ^ (2 * n) / real (fact (2 * n))))"
  2575     by (rule sums_unique)
  2575     by (rule sums_unique)
  2576   ultimately have "0 < - cos 2" by simp
  2576   ultimately have "0 < - cos 2" by simp
  2577   then show ?thesis by simp
  2577   then show ?thesis by simp
  2578 qed
  2578 qed
  2579 
  2579 
  2675   by (simp add: sin_add cos_double)
  2675   by (simp add: sin_add cos_double)
  2676 
  2676 
  2677 lemma cos_periodic [simp]: "cos (x + 2*pi) = cos x"
  2677 lemma cos_periodic [simp]: "cos (x + 2*pi) = cos x"
  2678   by (simp add: cos_add cos_double)
  2678   by (simp add: cos_add cos_double)
  2679 
  2679 
  2680 lemma cos_npi [simp]: "cos (real n * pi) = -1 ^ n"
  2680 lemma cos_npi [simp]: "cos (real n * pi) = (- 1) ^ n"
  2681   by (induct n) (auto simp add: real_of_nat_Suc distrib_right)
  2681   by (induct n) (auto simp add: real_of_nat_Suc distrib_right)
  2682 
  2682 
  2683 lemma cos_npi2 [simp]: "cos (pi * real n) = -1 ^ n"
  2683 lemma cos_npi2 [simp]: "cos (pi * real n) = (- 1) ^ n"
  2684   by (metis cos_npi mult.commute)
  2684   by (metis cos_npi mult.commute)
  2685 
  2685 
  2686 lemma sin_npi [simp]: "sin (real (n::nat) * pi) = 0"
  2686 lemma sin_npi [simp]: "sin (real (n::nat) * pi) = 0"
  2687   by (induct n) (auto simp add: real_of_nat_Suc distrib_right)
  2687   by (induct n) (auto simp add: real_of_nat_Suc distrib_right)
  2688 
  2688 
  3752 
  3752 
  3753   {
  3753   {
  3754     fix x :: real
  3754     fix x :: real
  3755     assume "\<bar>x\<bar> < 1"
  3755     assume "\<bar>x\<bar> < 1"
  3756     hence "x\<^sup>2 < 1" by (rule less_one_imp_sqr_less_one)
  3756     hence "x\<^sup>2 < 1" by (rule less_one_imp_sqr_less_one)
  3757     have "summable (\<lambda> n. -1 ^ n * (x\<^sup>2) ^n)"
  3757     have "summable (\<lambda> n. (- 1) ^ n * (x\<^sup>2) ^n)"
  3758       by (rule summable_Leibniz(1), auto intro!: LIMSEQ_realpow_zero monoseq_realpow `x\<^sup>2 < 1` order_less_imp_le[OF `x\<^sup>2 < 1`])
  3758       by (rule summable_Leibniz(1), auto intro!: LIMSEQ_realpow_zero monoseq_realpow `x\<^sup>2 < 1` order_less_imp_le[OF `x\<^sup>2 < 1`])
  3759     hence "summable (\<lambda> n. -1 ^ n * x^(2*n))" unfolding power_mult .
  3759     hence "summable (\<lambda> n. (- 1) ^ n * x^(2*n))" unfolding power_mult .
  3760   } note summable_Integral = this
  3760   } note summable_Integral = this
  3761 
  3761 
  3762   {
  3762   {
  3763     fix f :: "nat \<Rightarrow> real"
  3763     fix f :: "nat \<Rightarrow> real"
  3764     have "\<And>x. f sums x = (\<lambda> n. if even n then f (n div 2) else 0) sums x"
  3764     have "\<And>x. f sums x = (\<lambda> n. if even n then f (n div 2) else 0) sums x"
  3776     qed
  3776     qed
  3777     hence "op sums f = op sums (\<lambda> n. if even n then f (n div 2) else 0)" ..
  3777     hence "op sums f = op sums (\<lambda> n. if even n then f (n div 2) else 0)" ..
  3778   } note sums_even = this
  3778   } note sums_even = this
  3779 
  3779 
  3780   have Int_eq: "(\<Sum>n. ?f n * real (Suc n) * x^n) = ?Int"
  3780   have Int_eq: "(\<Sum>n. ?f n * real (Suc n) * x^n) = ?Int"
  3781     unfolding if_eq mult.commute[of _ 2] suminf_def sums_even[of "\<lambda> n. -1 ^ n * x ^ (2 * n)", symmetric]
  3781     unfolding if_eq mult.commute[of _ 2] suminf_def sums_even[of "\<lambda> n. (- 1) ^ n * x ^ (2 * n)", symmetric]
  3782     by auto
  3782     by auto
  3783 
  3783 
  3784   {
  3784   {
  3785     fix x :: real
  3785     fix x :: real
  3786     have if_eq': "\<And>n. (if even n then -1 ^ (n div 2) * 1 / real (Suc n) else 0) * x ^ Suc n =
  3786     have if_eq': "\<And>n. (if even n then (- 1) ^ (n div 2) * 1 / real (Suc n) else 0) * x ^ Suc n =
  3787       (if even n then -1 ^ (n div 2) * (1 / real (Suc (2 * (n div 2))) * x ^ Suc (2 * (n div 2))) else 0)"
  3787       (if even n then (- 1) ^ (n div 2) * (1 / real (Suc (2 * (n div 2))) * x ^ Suc (2 * (n div 2))) else 0)"
  3788       using n_even by auto
  3788       using n_even by auto
  3789     have idx_eq: "\<And>n. n * 2 + 1 = Suc (2 * n)" by auto
  3789     have idx_eq: "\<And>n. n * 2 + 1 = Suc (2 * n)" by auto
  3790     have "(\<Sum>n. ?f n * x^(Suc n)) = ?arctan x"
  3790     have "(\<Sum>n. ?f n * x^(Suc n)) = ?arctan x"
  3791       unfolding if_eq' idx_eq suminf_def sums_even[of "\<lambda> n. -1 ^ n * (1 / real (Suc (2 * n)) * x ^ Suc (2 * n))", symmetric]
  3791       unfolding if_eq' idx_eq suminf_def sums_even[of "\<lambda> n. (- 1) ^ n * (1 / real (Suc (2 * n)) * x ^ Suc (2 * n))", symmetric]
  3792       by auto
  3792       by auto
  3793   } note arctan_eq = this
  3793   } note arctan_eq = this
  3794 
  3794 
  3795   have "DERIV (\<lambda> x. \<Sum> n. ?f n * x^(Suc n)) x :> (\<Sum> n. ?f n * real (Suc n) * x^n)"
  3795   have "DERIV (\<lambda> x. \<Sum> n. ?f n * x^(Suc n)) x :> (\<Sum> n. ?f n * real (Suc n) * x^n)"
  3796   proof (rule DERIV_power_series')
  3796   proof (rule DERIV_power_series')
  3797     show "x \<in> {- 1 <..< 1}" using `\<bar> x \<bar> < 1` by auto
  3797     show "x \<in> {- 1 <..< 1}" using `\<bar> x \<bar> < 1` by auto
  3798     {
  3798     {
  3799       fix x' :: real
  3799       fix x' :: real
  3800       assume x'_bounds: "x' \<in> {- 1 <..< 1}"
  3800       assume x'_bounds: "x' \<in> {- 1 <..< 1}"
  3801       hence "\<bar>x'\<bar> < 1" by auto
  3801       then have "\<bar>x'\<bar> < 1" by auto
  3802 
  3802       then
       
  3803         have *: "summable (\<lambda>n. (- 1) ^ n * x' ^ (2 * n))"
       
  3804         by (rule summable_Integral)
  3803       let ?S = "\<Sum> n. (-1)^n * x'^(2 * n)"
  3805       let ?S = "\<Sum> n. (-1)^n * x'^(2 * n)"
  3804       show "summable (\<lambda> n. ?f n * real (Suc n) * x'^n)" unfolding if_eq
  3806       show "summable (\<lambda> n. ?f n * real (Suc n) * x'^n)" unfolding if_eq
  3805         by (rule sums_summable[where l="0 + ?S"], rule sums_if, rule sums_zero, rule summable_sums, rule summable_Integral[OF `\<bar>x'\<bar> < 1`])
  3807         apply (rule sums_summable [where l="0 + ?S"])
       
  3808         apply (rule sums_if)
       
  3809         apply (rule sums_zero)
       
  3810         apply (rule summable_sums)
       
  3811         apply (rule *)
       
  3812         done
  3806     }
  3813     }
  3807   qed auto
  3814   qed auto
  3808   thus ?thesis unfolding Int_eq arctan_eq .
  3815   thus ?thesis unfolding Int_eq arctan_eq .
  3809 qed
  3816 qed
  3810 
  3817