569 apply (drule_tac c = "\<bar>h\<bar>" in sums_mult) |
569 apply (drule_tac c = "\<bar>h\<bar>" in sums_mult) |
570 apply (simp add: mult_ac) |
570 apply (simp add: mult_ac) |
571 apply (subgoal_tac "summable (%n. abs (g (h::real) (n::nat))) ") |
571 apply (subgoal_tac "summable (%n. abs (g (h::real) (n::nat))) ") |
572 apply (rule_tac [2] g = "%n. f n * \<bar>h\<bar>" in summable_comparison_test) |
572 apply (rule_tac [2] g = "%n. f n * \<bar>h\<bar>" in summable_comparison_test) |
573 apply (rule_tac [2] x = 0 in exI, auto) |
573 apply (rule_tac [2] x = 0 in exI, auto) |
574 apply (rule_tac j = "suminf (%n. \<bar>g h n\<bar>)" in real_le_trans) |
574 apply (rule_tac j = "\<Sum>n. \<bar>g h n\<bar>" in real_le_trans) |
575 apply (auto intro: summable_rabs summable_le simp add: sums_summable [THEN suminf_mult]) |
575 apply (auto intro: summable_rabs summable_le simp add: sums_summable [THEN suminf_mult]) |
576 done |
576 done |
577 |
577 |
578 |
578 |
579 |
579 |
580 text{* FIXME: Long proofs*} |
580 text{* FIXME: Long proofs*} |
581 |
581 |
582 lemma termdiffs_aux: |
582 lemma termdiffs_aux: |
583 "[|summable (\<lambda>n. diffs (diffs c) n * K ^ n); \<bar>x\<bar> < \<bar>K\<bar> |] |
583 "[|summable (\<lambda>n. diffs (diffs c) n * K ^ n); \<bar>x\<bar> < \<bar>K\<bar> |] |
584 ==> (\<lambda>h. suminf |
584 ==> (\<lambda>h. \<Sum>n. c n * |
585 (\<lambda>n. c n * |
|
586 (((x + h) ^ n - x ^ n) * inverse h - |
585 (((x + h) ^ n - x ^ n) * inverse h - |
587 real n * x ^ (n - Suc 0)))) |
586 real n * x ^ (n - Suc 0))) |
588 -- 0 --> 0" |
587 -- 0 --> 0" |
589 apply (drule dense, safe) |
588 apply (drule dense, safe) |
590 apply (frule real_less_sum_gt_zero) |
589 apply (frule real_less_sum_gt_zero) |
591 apply (drule_tac |
590 apply (drule_tac |
592 f = "%n. \<bar>c n\<bar> * real n * real (n - Suc 0) * (r ^ (n - 2))" |
591 f = "%n. \<bar>c n\<bar> * real n * real (n - Suc 0) * (r ^ (n - 2))" |
646 lemma termdiffs: |
645 lemma termdiffs: |
647 "[| summable(%n. c(n) * (K ^ n)); |
646 "[| summable(%n. c(n) * (K ^ n)); |
648 summable(%n. (diffs c)(n) * (K ^ n)); |
647 summable(%n. (diffs c)(n) * (K ^ n)); |
649 summable(%n. (diffs(diffs c))(n) * (K ^ n)); |
648 summable(%n. (diffs(diffs c))(n) * (K ^ n)); |
650 \<bar>x\<bar> < \<bar>K\<bar> |] |
649 \<bar>x\<bar> < \<bar>K\<bar> |] |
651 ==> DERIV (%x. suminf (%n. c(n) * (x ^ n))) x :> |
650 ==> DERIV (%x. \<Sum>n. c(n) * (x ^ n)) x :> |
652 suminf (%n. (diffs c)(n) * (x ^ n))" |
651 (\<Sum>n. (diffs c)(n) * (x ^ n))" |
653 apply (simp add: deriv_def) |
652 apply (simp add: deriv_def) |
654 apply (rule_tac g = "%h. suminf (%n. ((c (n) * ( (x + h) ^ n)) - (c (n) * (x ^ n))) * inverse h)" in LIM_trans) |
653 apply (rule_tac g = "%h. \<Sum>n. ((c (n) * ( (x + h) ^ n)) - (c (n) * (x ^ n))) * inverse h" in LIM_trans) |
655 apply (simp add: LIM_def, safe) |
654 apply (simp add: LIM_def, safe) |
656 apply (rule_tac x = "\<bar>K\<bar> - \<bar>x\<bar>" in exI) |
655 apply (rule_tac x = "\<bar>K\<bar> - \<bar>x\<bar>" in exI) |
657 apply (auto simp add: less_diff_eq) |
656 apply (auto simp add: less_diff_eq) |
658 apply (drule abs_triangle_ineq [THEN order_le_less_trans]) |
657 apply (drule abs_triangle_ineq [THEN order_le_less_trans]) |
659 apply (rule_tac y = 0 in order_le_less_trans, auto) |
658 apply (rule_tac y = 0 in order_le_less_trans, auto) |
660 apply (subgoal_tac " (%n. (c n) * (x ^ n)) sums (suminf (%n. (c n) * (x ^ n))) & (%n. (c n) * ((x + xa) ^ n)) sums (suminf (%n. (c n) * ( (x + xa) ^ n))) ") |
659 apply (subgoal_tac " (%n. (c n) * (x ^ n)) sums (\<Sum>n. (c n) * (x ^ n)) & (%n. (c n) * ((x + xa) ^ n)) sums (\<Sum>n. (c n) * ( (x + xa) ^ n))") |
661 apply (auto intro!: summable_sums) |
660 apply (auto intro!: summable_sums) |
662 apply (rule_tac [2] powser_inside, rule_tac [4] powser_inside) |
661 apply (rule_tac [2] powser_inside, rule_tac [4] powser_inside) |
663 apply (auto simp add: add_commute) |
662 apply (auto simp add: add_commute) |
664 apply (drule_tac x="(\<lambda>n. c n * (xa + x) ^ n)" in sums_diff, assumption) |
663 apply (drule_tac x="(\<lambda>n. c n * (xa + x) ^ n)" in sums_diff, assumption) |
665 apply (drule_tac x = "(%n. c n * (xa + x) ^ n - c n * x ^ n) " and c = "inverse xa" in sums_mult) |
664 apply (drule_tac x = "(%n. c n * (xa + x) ^ n - c n * x ^ n) " and c = "inverse xa" in sums_mult) |
666 apply (rule sums_unique) |
665 apply (rule sums_unique) |
667 apply (simp add: diff_def divide_inverse add_ac mult_ac) |
666 apply (simp add: diff_def divide_inverse add_ac mult_ac) |
668 apply (rule LIM_zero_cancel) |
667 apply (rule LIM_zero_cancel) |
669 apply (rule_tac g = "%h. suminf (%n. c (n) * ((( ((x + h) ^ n) - (x ^ n)) * inverse h) - (real n * (x ^ (n - Suc 0)))))" in LIM_trans) |
668 apply (rule_tac g = "%h. \<Sum>n. c (n) * ((( ((x + h) ^ n) - (x ^ n)) * inverse h) - (real n * (x ^ (n - Suc 0))))" in LIM_trans) |
670 prefer 2 apply (blast intro: termdiffs_aux) |
669 prefer 2 apply (blast intro: termdiffs_aux) |
671 apply (simp add: LIM_def, safe) |
670 apply (simp add: LIM_def, safe) |
672 apply (rule_tac x = "\<bar>K\<bar> - \<bar>x\<bar>" in exI) |
671 apply (rule_tac x = "\<bar>K\<bar> - \<bar>x\<bar>" in exI) |
673 apply (auto simp add: less_diff_eq) |
672 apply (auto simp add: less_diff_eq) |
674 apply (drule abs_triangle_ineq [THEN order_le_less_trans]) |
673 apply (drule abs_triangle_ineq [THEN order_le_less_trans]) |
675 apply (rule_tac y = 0 in order_le_less_trans, auto) |
674 apply (rule_tac y = 0 in order_le_less_trans, auto) |
676 apply (subgoal_tac "summable (%n. (diffs c) (n) * (x ^ n))") |
675 apply (subgoal_tac "summable (%n. (diffs c) (n) * (x ^ n))") |
677 apply (rule_tac [2] powser_inside, auto) |
676 apply (rule_tac [2] powser_inside, auto) |
678 apply (drule_tac c = c and x = x in diffs_equiv) |
677 apply (drule_tac c = c and x = x in diffs_equiv) |
679 apply (frule sums_unique, auto) |
678 apply (frule sums_unique, auto) |
680 apply (subgoal_tac " (%n. (c n) * (x ^ n)) sums (suminf (%n. (c n) * (x ^ n))) & (%n. (c n) * ((x + xa) ^ n)) sums (suminf (%n. (c n) * ( (x + xa) ^ n))) ") |
679 apply (subgoal_tac " (%n. (c n) * (x ^ n)) sums (\<Sum>n. (c n) * (x ^ n)) & (%n. (c n) * ((x + xa) ^ n)) sums (\<Sum>n. (c n) * ( (x + xa) ^ n))") |
681 apply safe |
680 apply safe |
682 apply (auto intro!: summable_sums) |
681 apply (auto intro!: summable_sums) |
683 apply (rule_tac [2] powser_inside, rule_tac [4] powser_inside) |
682 apply (rule_tac [2] powser_inside, rule_tac [4] powser_inside) |
684 apply (auto simp add: add_commute) |
683 apply (auto simp add: add_commute) |
685 apply (frule_tac x = "(%n. c n * (xa + x) ^ n) " and y = "(%n. c n * x ^ n)" in sums_diff, assumption) |
684 apply (frule_tac x = "(%n. c n * (xa + x) ^ n) " and y = "(%n. c n * x ^ n)" in sums_diff, assumption) |
740 simp del: mult_Suc) |
739 simp del: mult_Suc) |
741 |
740 |
742 text{*Now at last we can get the derivatives of exp, sin and cos*} |
741 text{*Now at last we can get the derivatives of exp, sin and cos*} |
743 |
742 |
744 lemma lemma_sin_minus: |
743 lemma lemma_sin_minus: |
745 "- sin x = |
744 "- sin x = (\<Sum>n. - ((if even n then 0 |
746 suminf(%n. - ((if even n then 0 |
|
747 else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n))) * x ^ n))" |
745 else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n))) * x ^ n))" |
748 by (auto intro!: sums_unique sums_minus sin_converges) |
746 by (auto intro!: sums_unique sums_minus sin_converges) |
749 |
747 |
750 lemma lemma_exp_ext: "exp = (%x. suminf (%n. inverse (real (fact n)) * x ^ n))" |
748 lemma lemma_exp_ext: "exp = (%x. \<Sum>n. inverse (real (fact n)) * x ^ n)" |
751 by (auto intro!: ext simp add: exp_def) |
749 by (auto intro!: ext simp add: exp_def) |
752 |
750 |
753 lemma DERIV_exp [simp]: "DERIV exp x :> exp(x)" |
751 lemma DERIV_exp [simp]: "DERIV exp x :> exp(x)" |
754 apply (simp add: exp_def) |
752 apply (simp add: exp_def) |
755 apply (subst lemma_exp_ext) |
753 apply (subst lemma_exp_ext) |
756 apply (subgoal_tac "DERIV (%u. suminf (%n. inverse (real (fact n)) * u ^ n)) x :> suminf (%n. diffs (%n. inverse (real (fact n))) n * x ^ n) ") |
754 apply (subgoal_tac "DERIV (%u. \<Sum>n. inverse (real (fact n)) * u ^ n) x :> (\<Sum>n. diffs (%n. inverse (real (fact n))) n * x ^ n)") |
757 apply (rule_tac [2] K = "1 + \<bar>x\<bar>" in termdiffs) |
755 apply (rule_tac [2] K = "1 + \<bar>x\<bar>" in termdiffs) |
758 apply (auto intro: exp_converges [THEN sums_summable] simp add: exp_fdiffs, arith) |
756 apply (auto intro: exp_converges [THEN sums_summable] simp add: exp_fdiffs, arith) |
759 done |
757 done |
760 |
758 |
761 lemma lemma_sin_ext: |
759 lemma lemma_sin_ext: |
762 "sin = (%x. suminf(%n. |
760 "sin = (%x. \<Sum>n. |
763 (if even n then 0 |
761 (if even n then 0 |
764 else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n))) * |
762 else (- 1) ^ ((n - Suc 0) div 2)/(real (fact n))) * |
765 x ^ n))" |
763 x ^ n)" |
766 by (auto intro!: ext simp add: sin_def) |
764 by (auto intro!: ext simp add: sin_def) |
767 |
765 |
768 lemma lemma_cos_ext: |
766 lemma lemma_cos_ext: |
769 "cos = (%x. suminf(%n. |
767 "cos = (%x. \<Sum>n. |
770 (if even n then (- 1) ^ (n div 2)/(real (fact n)) else 0) * |
768 (if even n then (- 1) ^ (n div 2)/(real (fact n)) else 0) * |
771 x ^ n))" |
769 x ^ n)" |
772 by (auto intro!: ext simp add: cos_def) |
770 by (auto intro!: ext simp add: cos_def) |
773 |
771 |
774 lemma DERIV_sin [simp]: "DERIV sin x :> cos(x)" |
772 lemma DERIV_sin [simp]: "DERIV sin x :> cos(x)" |
775 apply (simp add: cos_def) |
773 apply (simp add: cos_def) |
776 apply (subst lemma_sin_ext) |
774 apply (subst lemma_sin_ext) |
1323 have "(\<lambda>n. \<Sum>k = n * 2..<n * 2 + 2. |
1321 have "(\<lambda>n. \<Sum>k = n * 2..<n * 2 + 2. |
1324 (if even k then 0 |
1322 (if even k then 0 |
1325 else (- 1) ^ ((k - Suc 0) div 2) / real (fact k)) * |
1323 else (- 1) ^ ((k - Suc 0) div 2) / real (fact k)) * |
1326 x ^ k) |
1324 x ^ k) |
1327 sums |
1325 sums |
1328 suminf (\<lambda>n. (if even n then 0 |
1326 (\<Sum>n. (if even n then 0 |
1329 else (- 1) ^ ((n - Suc 0) div 2) / real (fact n)) * |
1327 else (- 1) ^ ((n - Suc 0) div 2) / real (fact n)) * |
1330 x ^ n)" |
1328 x ^ n)" |
1331 by (rule sin_converges [THEN sums_summable, THEN sums_group], simp) |
1329 by (rule sin_converges [THEN sums_summable, THEN sums_group], simp) |
1332 thus ?thesis by (simp add: mult_ac sin_def) |
1330 thus ?thesis by (simp add: mult_ac sin_def) |
1333 qed |
1331 qed |
1334 |
1332 |
1335 lemma sin_gt_zero: "[|0 < x; x < 2 |] ==> 0 < sin x" |
1333 lemma sin_gt_zero: "[|0 < x; x < 2 |] ==> 0 < sin x" |
1336 apply (subgoal_tac |
1334 apply (subgoal_tac |
1337 "(\<lambda>n. \<Sum>k = n * 2..<n * 2 + 2. |
1335 "(\<lambda>n. \<Sum>k = n * 2..<n * 2 + 2. |
1338 (- 1) ^ k / real (fact (2 * k + 1)) * x ^ (2 * k + 1)) |
1336 (- 1) ^ k / real (fact (2 * k + 1)) * x ^ (2 * k + 1)) |
1339 sums suminf (\<lambda>n. (- 1) ^ n / real (fact (2 * n + 1)) * x ^ (2 * n + 1))") |
1337 sums (\<Sum>n. (- 1) ^ n / real (fact (2 * n + 1)) * x ^ (2 * n + 1))") |
1340 prefer 2 |
1338 prefer 2 |
1341 apply (rule sin_paired [THEN sums_summable, THEN sums_group], simp) |
1339 apply (rule sin_paired [THEN sums_summable, THEN sums_group], simp) |
1342 apply (rotate_tac 2) |
1340 apply (rotate_tac 2) |
1343 apply (drule sin_paired [THEN sums_unique, THEN ssubst]) |
1341 apply (drule sin_paired [THEN sums_unique, THEN ssubst]) |
1344 apply (auto simp del: fact_Suc realpow_Suc) |
1342 apply (auto simp del: fact_Suc realpow_Suc) |