Skip to content

Commit 2f39cbe

Browse files
committed
Box scaling
1 parent 239617f commit 2f39cbe

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

Interval/Box/Basic.lean

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ def sqr (z : Box) : Box :=
9090
let w := z.re * z.im
9191
⟨z.re.sqr - z.im.sqr, w.scaleB 1
9292

93+
/-- Power of two scaling -/
94+
@[irreducible] def scaleB (z : Box) (t : Int64) : Box :=
95+
⟨z.re.scaleB t, z.im.scaleB t⟩
96+
9397
-- Definition lemmas
9498
lemma neg_def {z : Box} : -z = ⟨-z.re, -z.im⟩ := rfl
9599
lemma add_def {z w : Box} : z + w = ⟨z.re + w.re, z.im + w.im⟩ := rfl
@@ -174,6 +178,18 @@ noncomputable instance : ApproxRing Box ℂ where
174178
← pow_two z'.im, mul_comm z'.im, ← two_mul]
175179
approx
176180

181+
/-- `Box` scaling approximates `ℂ` -/
182+
@[approx] lemma approx_scaleB (az : approx z z') (t : Int64) :
183+
approx (z.scaleB t) (z' * 2 ^ (t : ℤ)) := by
184+
have two : (2 : ℂ) = (2 : ℝ) := by norm_num
185+
simp only [scaleB, instApprox, two, Complex.mul_re, ← Complex.ofReal_zpow, Complex.ofReal_im,
186+
mul_zero, sub_zero, Complex.ofReal_re, Complex.mul_im, zero_add]
187+
approx
188+
189+
/-- `Box` doubling approximates `ℂ` -/
190+
@[approx] lemma approx_scaleB_one (az : approx z z') : approx (z.scaleB 1) (2 * z') := by
191+
simpa only [Int64.coe_one, zpow_one, mul_comm _ (2 : ℂ)] using approx_scaleB az 1
192+
177193
/-!
178194
### Multiplication and division by `I`
179195
-/

0 commit comments

Comments
 (0)