equal
deleted
inserted
replaced
1470 |
1470 |
1471 subsection {* The formula for geometric sums *} |
1471 subsection {* The formula for geometric sums *} |
1472 |
1472 |
1473 lemma geometric_sum: |
1473 lemma geometric_sum: |
1474 assumes "x \<noteq> 1" |
1474 assumes "x \<noteq> 1" |
1475 shows "(\<Sum>i=0..<n. x ^ i) = (x ^ n - 1) / (x - 1::'a::field)" |
1475 shows "(\<Sum>i<n. x ^ i) = (x ^ n - 1) / (x - 1::'a::field)" |
1476 proof - |
1476 proof - |
1477 from assms obtain y where "y = x - 1" and "y \<noteq> 0" by simp_all |
1477 from assms obtain y where "y = x - 1" and "y \<noteq> 0" by simp_all |
1478 moreover have "(\<Sum>i=0..<n. (y + 1) ^ i) = ((y + 1) ^ n - 1) / y" |
1478 moreover have "(\<Sum>i<n. (y + 1) ^ i) = ((y + 1) ^ n - 1) / y" |
1479 proof (induct n) |
1479 proof (induct n) |
1480 case 0 then show ?case by simp |
1480 case 0 then show ?case by simp |
1481 next |
1481 next |
1482 case (Suc n) |
1482 case (Suc n) |
1483 moreover from Suc `y \<noteq> 0` have "(1 + y) ^ n = (y * inverse y) * (1 + y) ^ n" by simp |
1483 moreover from Suc `y \<noteq> 0` have "(1 + y) ^ n = (y * inverse y) * (1 + y) ^ n" by simp |
1488 |
1488 |
1489 |
1489 |
1490 subsection {* The formula for arithmetic sums *} |
1490 subsection {* The formula for arithmetic sums *} |
1491 |
1491 |
1492 lemma gauss_sum: |
1492 lemma gauss_sum: |
1493 "(2::'a::comm_semiring_1)*(\<Sum>i\<in>{1..n}. of_nat i) = |
1493 "(2::'a::comm_semiring_1)*(\<Sum>i\<in>{1..n}. of_nat i) = of_nat n*((of_nat n)+1)" |
1494 of_nat n*((of_nat n)+1)" |
|
1495 proof (induct n) |
1494 proof (induct n) |
1496 case 0 |
1495 case 0 |
1497 show ?case by simp |
1496 show ?case by simp |
1498 next |
1497 next |
1499 case (Suc n) |
1498 case (Suc n) |
1573 show ?case by simp |
1572 show ?case by simp |
1574 qed |
1573 qed |
1575 |
1574 |
1576 lemma nat_diff_setsum_reindex: |
1575 lemma nat_diff_setsum_reindex: |
1577 fixes x :: "'a::{comm_ring,monoid_mult}" |
1576 fixes x :: "'a::{comm_ring,monoid_mult}" |
1578 shows "(\<Sum>i=0..<n. f (n - Suc i)) = (\<Sum>i=0..<n. f i)" |
1577 shows "(\<Sum>i<n. f (n - Suc i)) = (\<Sum>i<n. f i)" |
1579 apply (subst setsum_reindex_cong [of "%i. n - Suc i" "{0..< n}"]) |
1578 apply (subst setsum_reindex_cong [of "%i. n - Suc i" "{..< n}"]) |
1580 apply (auto simp: inj_on_def) |
1579 apply (auto simp: inj_on_def) |
1581 apply (rule_tac x="n - Suc x" in image_eqI, auto) |
1580 apply (rule_tac x="n - Suc x" in image_eqI, auto) |
1582 done |
1581 done |
1583 |
1582 |
1584 subsection {* Products indexed over intervals *} |
1583 subsection {* Products indexed over intervals *} |