File size: 4,094 Bytes
4a56cd6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import Mathlib

namespace OAI

noncomputable section

open scoped BigOperators

namespace Problem367.ExponentialTaylor

theorem norm_exp_I_taylor_two_le (x : ℝ) :
    β€–Complex.exp ((x : β„‚) * Complex.I) - 1 - (x : β„‚) * Complex.I +
      (x : β„‚) ^ 2 / 2β€– ≀ 4 * |x| ^ 3 := by
  have hnorm : β€–(x : β„‚) * Complex.Iβ€– = |x| := by simp
  by_cases hx : |x| ≀ 1
  Β· have h := Complex.exp_bound (x := (x : β„‚) * Complex.I)
      (by simpa only [hnorm] using hx) (n := 3) (by norm_num)
    have heq : (βˆ‘ m ∈ Finset.range 3,
        ((x : β„‚) * Complex.I) ^ m / (m.factorial : β„‚)) =
        1 + (x : β„‚) * Complex.I - (x : β„‚) ^ 2 / 2 := by
      norm_num [Finset.sum_range_succ, mul_pow, Complex.I_sq]
      ring
    rw [heq, hnorm] at h
    norm_num at h
    have heq' : Complex.exp ((x : β„‚) * Complex.I) - 1 - (x : β„‚) * Complex.I +
        (x : β„‚) ^ 2 / 2 =
        Complex.exp ((x : β„‚) * Complex.I) -
          (1 + (x : β„‚) * Complex.I - (x : β„‚) ^ 2 / 2) := by ring
    rw [heq']
    exact h.trans (by nlinarith [abs_nonneg x, pow_nonneg (abs_nonneg x) 3])
  Β· have hx1 : 1 ≀ |x| := (lt_of_not_ge hx).le
    have hsq : |x| ≀ |x| ^ 2 := by nlinarith [abs_nonneg x]
    have hcube : |x| ^ 2 ≀ |x| ^ 3 := by nlinarith [sq_nonneg (|x| - 1)]
    calc
      _ ≀ β€–Complex.exp ((x : β„‚) * Complex.I) - 1 - (x : β„‚) * Complex.Iβ€– +
          β€–(x : β„‚) ^ 2 / 2β€– := norm_add_le _ _
      _ ≀ (β€–Complex.exp ((x : β„‚) * Complex.I) - 1β€– +
          β€–(x : β„‚) * Complex.Iβ€–) + β€–(x : β„‚) ^ 2 / 2β€– := by
        gcongr
        exact norm_sub_le _ _
      _ ≀ ((β€–Complex.exp ((x : β„‚) * Complex.I)β€– + β€–(1 : β„‚)β€–) +
          β€–(x : β„‚) * Complex.Iβ€–) + β€–(x : β„‚) ^ 2 / 2β€– := by
        gcongr
        exact norm_sub_le _ _
      _ = 2 + |x| + |x| ^ 2 / 2 := by norm_num
      _ ≀ 4 * |x| ^ 3 := by nlinarith

theorem norm_exp_I_mul_taylor_two_le (a x : ℝ) :
    β€–Complex.exp (((a * x : ℝ) : β„‚) * Complex.I) - 1 -
      ((a * x : ℝ) : β„‚) * Complex.I + (((a * x : ℝ) : β„‚) ^ 2) / 2β€– ≀
      4 * |a| ^ 3 * |x| ^ 3 := by
  simpa only [abs_mul, mul_pow, mul_assoc] using norm_exp_I_taylor_two_le (a * x)

theorem norm_exp_neg_sub_one_add_le_sq {x : ℝ} (hx : 0 ≀ x) :
    β€–Complex.exp ((-x : ℝ) : β„‚) - 1 + (x : β„‚)β€– ≀ x ^ 2 := by
  have heq : Complex.exp ((-x : ℝ) : β„‚) - 1 + (x : β„‚) =
      ((Real.exp (-x) - 1 + x : ℝ) : β„‚) := by simp
  rw [heq, Complex.norm_real, Real.norm_eq_abs]
  by_cases hsmall : x ≀ 1
  Β· have h := Real.norm_exp_sub_one_sub_id_le (x := -x) (by simpa [abs_of_nonneg hx] using hsmall)
    simpa only [Real.norm_eq_abs, sub_neg_eq_add, sq_abs, neg_sq] using h
  Β· have hlarge : 1 ≀ x := (lt_of_not_ge hsmall).le
    have hnonneg : 0 ≀ Real.exp (-x) - 1 + x := by
      linarith [Real.add_one_le_exp (-x)]
    rw [abs_of_nonneg hnonneg]
    have hbound : Real.exp (-x) ≀ 1 := Real.exp_le_one_iff.mpr (neg_nonpos.mpr hx)
    nlinarith

theorem norm_recurrence_error_le_sum
    (z a : β„• β†’ β„‚) (e : β„• β†’ ℝ) (n : β„•)
    (ha : βˆ€ k < n, β€–a kβ€– ≀ 1)
    (he : βˆ€ k < n, β€–z (k + 1) - a k * z kβ€– ≀ e k) :
    β€–z n - (∏ k ∈ Finset.range n, a k) * z 0β€– ≀
      βˆ‘ k ∈ Finset.range n, e k := by
  induction n with
  | zero => simp
  | succ n ih =>
    have hprev := ih (fun k hk => ha k (Nat.lt_succ_of_lt hk))
      (fun k hk => he k (Nat.lt_succ_of_lt hk))
    rw [Finset.prod_range_succ, Finset.sum_range_succ]
    have heq : z (n + 1) - ((∏ k ∈ Finset.range n, a k) * a n) * z 0 =
        (z (n + 1) - a n * z n) +
          a n * (z n - (∏ k ∈ Finset.range n, a k) * z 0) := by ring
    rw [heq]
    calc
      _ ≀ β€–z (n + 1) - a n * z nβ€– +
          β€–a n * (z n - (∏ k ∈ Finset.range n, a k) * z 0)β€– := norm_add_le _ _
      _ ≀ e n + 1 * (βˆ‘ k ∈ Finset.range n, e k) := by
        apply add_le_add (he n (by omega))
        rw [norm_mul]
        exact mul_le_mul (ha n (by omega)) hprev (norm_nonneg _) (by norm_num)
      _ = _ := by ring

end Problem367.ExponentialTaylor

end

end OAI