src/HOL/Transcendental.thy
 changeset 50326 b5afeccab2db parent 49962 a8cc904a6820 child 50346 a75c6429c3c3
```     1.1 --- a/src/HOL/Transcendental.thy	Mon Dec 03 18:19:04 2012 +0100
1.2 +++ b/src/HOL/Transcendental.thy	Mon Dec 03 18:19:05 2012 +0100
1.3 @@ -881,7 +881,6 @@
1.4    "(f ---> a) F \<Longrightarrow> ((\<lambda>x. exp (f x)) ---> exp a) F"
1.5    by (rule isCont_tendsto_compose [OF isCont_exp])
1.6
1.7 -
1.8  subsubsection {* Properties of the Exponential Function *}
1.9
1.10  lemma powser_zero:
1.11 @@ -1212,6 +1211,157 @@
1.12    thus ?thesis by auto
1.13  qed
1.14
1.15 +lemma exp_first_two_terms: "exp x = 1 + x + (\<Sum> n. inverse(fact (n+2)) * (x ^ (n+2)))"
1.16 +proof -
1.17 +  have "exp x = suminf (%n. inverse(fact n) * (x ^ n))"
1.18 +    by (simp add: exp_def)
1.19 +  also from summable_exp have "... = (\<Sum> n::nat = 0 ..< 2. inverse(fact n) * (x ^ n)) +
1.20 +      (\<Sum> n. inverse(fact(n+2)) * (x ^ (n+2)))" (is "_ = ?a + _")
1.21 +    by (rule suminf_split_initial_segment)
1.22 +  also have "?a = 1 + x"
1.23 +    by (simp add: numeral_2_eq_2)
1.24 +  finally show ?thesis .
1.25 +qed
1.26 +
1.27 +lemma exp_bound: "0 <= (x::real) ==> x <= 1 ==> exp x <= 1 + x + x^2"
1.28 +proof -
1.29 +  assume a: "0 <= x"
1.30 +  assume b: "x <= 1"
1.31 +  { fix n :: nat
1.32 +    have "2 * 2 ^ n \<le> fact (n + 2)"
1.33 +      by (induct n, simp, simp)
1.34 +    hence "real ((2::nat) * 2 ^ n) \<le> real (fact (n + 2))"
1.35 +      by (simp only: real_of_nat_le_iff)
1.36 +    hence "2 * 2 ^ n \<le> real (fact (n + 2))"
1.37 +      by simp
1.38 +    hence "inverse (fact (n + 2)) \<le> inverse (2 * 2 ^ n)"
1.39 +      by (rule le_imp_inverse_le) simp
1.40 +    hence "inverse (fact (n + 2)) \<le> 1/2 * (1/2)^n"
1.41 +      by (simp add: inverse_mult_distrib power_inverse)
1.42 +    hence "inverse (fact (n + 2)) * (x^n * x\<twosuperior>) \<le> 1/2 * (1/2)^n * (1 * x\<twosuperior>)"
1.43 +      by (rule mult_mono)
1.44 +        (rule mult_mono, simp_all add: power_le_one a b mult_nonneg_nonneg)
1.45 +    hence "inverse (fact (n + 2)) * x ^ (n + 2) \<le> (x\<twosuperior>/2) * ((1/2)^n)"
1.47 +  note aux1 = this
1.48 +  have "(\<lambda>n. x\<twosuperior> / 2 * (1 / 2) ^ n) sums (x\<twosuperior> / 2 * (1 / (1 - 1 / 2)))"
1.49 +    by (intro sums_mult geometric_sums, simp)
1.50 +  hence aux2: "(\<lambda>n. (x::real) ^ 2 / 2 * (1 / 2) ^ n) sums x^2"
1.51 +    by simp
1.52 +  have "suminf (%n. inverse(fact (n+2)) * (x ^ (n+2))) <= x^2"
1.53 +  proof -
1.54 +    have "suminf (%n. inverse(fact (n+2)) * (x ^ (n+2))) <=
1.55 +        suminf (%n. (x^2/2) * ((1/2)^n))"
1.56 +      apply (rule summable_le)
1.57 +      apply (rule allI, rule aux1)
1.58 +      apply (rule summable_exp [THEN summable_ignore_initial_segment])
1.59 +      by (rule sums_summable, rule aux2)
1.60 +    also have "... = x^2"
1.61 +      by (rule sums_unique [THEN sym], rule aux2)
1.62 +    finally show ?thesis .
1.63 +  qed
1.64 +  thus ?thesis unfolding exp_first_two_terms by auto
1.65 +qed
1.66 +
1.67 +lemma ln_one_minus_pos_upper_bound: "0 <= x ==> x < 1 ==> ln (1 - x) <= - x"
1.68 +proof -
1.69 +  assume a: "0 <= (x::real)" and b: "x < 1"
1.70 +  have "(1 - x) * (1 + x + x^2) = (1 - x^3)"
1.71 +    by (simp add: algebra_simps power2_eq_square power3_eq_cube)
1.72 +  also have "... <= 1"
1.73 +    by (auto simp add: a)
1.74 +  finally have "(1 - x) * (1 + x + x ^ 2) <= 1" .
1.75 +  moreover have c: "0 < 1 + x + x\<twosuperior>"
1.77 +  ultimately have "1 - x <= 1 / (1 + x + x^2)"
1.78 +    by (elim mult_imp_le_div_pos)
1.79 +  also have "... <= 1 / exp x"
1.80 +    apply (rule divide_left_mono)
1.81 +    apply (rule exp_bound, rule a)
1.82 +    apply (rule b [THEN less_imp_le])
1.83 +    apply simp
1.84 +    apply (rule mult_pos_pos)
1.85 +    apply (rule c)
1.86 +    apply simp
1.87 +    done
1.88 +  also have "... = exp (-x)"
1.89 +    by (auto simp add: exp_minus divide_inverse)
1.90 +  finally have "1 - x <= exp (- x)" .
1.91 +  also have "1 - x = exp (ln (1 - x))"
1.92 +  proof -
1.93 +    have "0 < 1 - x"
1.94 +      by (insert b, auto)
1.95 +    thus ?thesis
1.96 +      by (auto simp only: exp_ln_iff [THEN sym])
1.97 +  qed
1.98 +  finally have "exp (ln (1 - x)) <= exp (- x)" .
1.99 +  thus ?thesis by (auto simp only: exp_le_cancel_iff)
1.100 +qed
1.101 +
1.102 +lemma exp_ge_add_one_self [simp]: "1 + (x::real) <= exp x"
1.103 +  apply (case_tac "0 <= x")
1.105 +  apply (case_tac "x <= -1")
1.106 +  apply (subgoal_tac "1 + x <= 0")
1.107 +  apply (erule order_trans)
1.108 +  apply simp
1.109 +  apply simp
1.110 +  apply (subgoal_tac "1 + x = exp(ln (1 + x))")
1.111 +  apply (erule ssubst)
1.112 +  apply (subst exp_le_cancel_iff)
1.113 +  apply (subgoal_tac "ln (1 - (- x)) <= - (- x)")
1.114 +  apply simp
1.115 +  apply (rule ln_one_minus_pos_upper_bound)
1.116 +  apply auto
1.117 +done
1.118 +
1.119 +lemma exp_at_bot: "(exp ---> (0::real)) at_bot"
1.120 +  unfolding tendsto_Zfun_iff
1.121 +proof (rule ZfunI, simp add: eventually_at_bot_dense)
1.122 +  fix r :: real assume "0 < r"
1.123 +  { fix x assume "x < ln r"
1.124 +    then have "exp x < exp (ln r)"
1.125 +      by simp
1.126 +    with `0 < r` have "exp x < r"
1.127 +      by simp }
1.128 +  then show "\<exists>k. \<forall>n<k. exp n < r" by auto
1.129 +qed
1.130 +
1.131 +lemma exp_at_top: "LIM x at_top. exp x :: real :> at_top"
1.132 +proof -
1.133 +  { fix r n :: real assume "r < n"
1.134 +    also have "n < 1 + n" by simp
1.135 +    also have "1 + n \<le> exp n" by (rule exp_ge_add_one_self)
1.136 +    finally have "r < exp n" . }
1.137 +  then show ?thesis
1.138 +    by (auto simp: eventually_at_top_dense filterlim_at_top)
1.139 +qed
1.140 +
1.141 +lemma ln_at_0: "LIM x at_right 0. ln x :> at_bot"
1.142 +  unfolding filterlim_at_bot
1.143 +proof safe
1.144 +  fix r :: real
1.145 +  { fix x :: real assume "0 < x" "x < exp r"
1.146 +    then have "ln x < ln (exp r)"
1.147 +      by (subst ln_less_cancel_iff) auto
1.148 +    then have "ln x < r" by simp }
1.149 +  then show "eventually (\<lambda>x. ln x < r) (at_right 0)"
1.150 +    by (auto simp add: dist_real_def eventually_within eventually_at intro!: exI[of _ "exp r"])
1.151 +qed
1.152 +
1.153 +lemma ln_at_top: "LIM x at_top. ln x :> at_top"
1.154 +  unfolding filterlim_at_top
1.155 +proof safe
1.156 +  fix r :: real
1.157 +  { fix x assume "exp r < x"
1.158 +    with exp_gt_zero[of r] have "ln (exp r) < ln x"
1.159 +      by (subst ln_less_cancel_iff) (auto simp del: exp_gt_zero)
1.160 +    then have "r < ln x"
1.161 +      by simp }
1.162 +  then show "eventually (\<lambda>x. r < ln x) at_top"
1.163 +    by (auto simp add: eventually_at_top_dense)
1.164 +qed
1.165 +
1.166  subsection {* Sine and Cosine *}
1.167
1.168  definition sin_coeff :: "nat \<Rightarrow> real" where
```