[GOAL]
n : ℕ
⊢ hermite (n + 1) = X * hermite n - ↑derivative (hermite n)
[PROOFSTEP]
rw [hermite]
[GOAL]
n : ℕ
⊢ hermite n = (fun p => X * p - ↑derivative p)^[n] 1
[PROOFSTEP]
induction' n with n ih
[GOAL]
case zero
⊢ hermite Nat.zero = (fun p => X * p - ↑derivative p)^[Nat.zero] 1
[PROOFSTEP]
rfl
[GOAL]
case succ
n : ℕ
ih : hermite n = (fun p => X * p - ↑derivative p)^[n] 1
⊢ hermite (Nat.succ n) = (fun p => X * p - ↑derivative p)^[Nat.succ n] 1
[PROOFSTEP]
rw [Function.iterate_succ_apply', ← ih, hermite_succ]
[GOAL]
⊢ hermite 1 = X
[PROOFSTEP]
rw [hermite_succ, hermite_zero]
[GOAL]
⊢ X * ↑C 1 - ↑derivative (↑C 1) = X
[PROOFSTEP]
simp only [map_one, mul_one, derivative_one, sub_zero]
[GOAL]
n : ℕ
⊢ coeff (hermite (n + 1)) 0 = -coeff (hermite n) 1
[PROOFSTEP]
simp [coeff_derivative]
[GOAL]
n k : ℕ
⊢ coeff (hermite (n + 1)) (k + 1) = coeff (hermite n) k - (↑k + 2) * coeff (hermite n) (k + 2)
[PROOFSTEP]
rw [hermite_succ, coeff_sub, coeff_X_mul, coeff_derivative, mul_comm]
[GOAL]
n k : ℕ
⊢ coeff (hermite n) k - (↑(k + 1) + 1) * coeff (hermite n) (k + 1 + 1) =
    coeff (hermite n) k - (↑k + 2) * coeff (hermite n) (k + 2)
[PROOFSTEP]
norm_cast
[GOAL]
n k : ℕ
hnk : n < k
⊢ coeff (hermite n) k = 0
[PROOFSTEP]
obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_lt hnk
[GOAL]
case intro
n k : ℕ
hnk : n < n + k + 1
⊢ coeff (hermite n) (n + k + 1) = 0
[PROOFSTEP]
clear hnk
[GOAL]
case intro
n k : ℕ
⊢ coeff (hermite n) (n + k + 1) = 0
[PROOFSTEP]
induction' n with n ih generalizing k
[GOAL]
case intro.zero
k✝ k : ℕ
⊢ coeff (hermite Nat.zero) (Nat.zero + k + 1) = 0
[PROOFSTEP]
apply coeff_C
[GOAL]
case intro.succ
k✝ n : ℕ
ih : ∀ (k : ℕ), coeff (hermite n) (n + k + 1) = 0
k : ℕ
⊢ coeff (hermite (Nat.succ n)) (Nat.succ n + k + 1) = 0
[PROOFSTEP]
have : n + k + 1 + 2 = n + (k + 2) + 1 := by ring
[GOAL]
k✝ n : ℕ
ih : ∀ (k : ℕ), coeff (hermite n) (n + k + 1) = 0
k : ℕ
⊢ n + k + 1 + 2 = n + (k + 2) + 1
[PROOFSTEP]
ring
[GOAL]
case intro.succ
k✝ n : ℕ
ih : ∀ (k : ℕ), coeff (hermite n) (n + k + 1) = 0
k : ℕ
this : n + k + 1 + 2 = n + (k + 2) + 1
⊢ coeff (hermite (Nat.succ n)) (Nat.succ n + k + 1) = 0
[PROOFSTEP]
rw [Nat.succ_eq_add_one, coeff_hermite_succ_succ, add_right_comm, this, ih k, ih (k + 2), mul_zero, sub_zero]
[GOAL]
n : ℕ
⊢ coeff (hermite n) n = 1
[PROOFSTEP]
induction' n with n ih
[GOAL]
case zero
⊢ coeff (hermite Nat.zero) Nat.zero = 1
[PROOFSTEP]
apply coeff_C
[GOAL]
case succ
n : ℕ
ih : coeff (hermite n) n = 1
⊢ coeff (hermite (Nat.succ n)) (Nat.succ n) = 1
[PROOFSTEP]
rw [coeff_hermite_succ_succ, ih, coeff_hermite_of_lt, mul_zero, sub_zero]
[GOAL]
case succ
n : ℕ
ih : coeff (hermite n) n = 1
⊢ n < n + 2
[PROOFSTEP]
simp
[GOAL]
n : ℕ
⊢ degree (hermite n) = ↑n
[PROOFSTEP]
rw [degree_eq_of_le_of_coeff_ne_zero]
[GOAL]
case pn
n : ℕ
⊢ degree (hermite n) ≤ ↑n
case p1 n : ℕ ⊢ coeff (hermite n) n ≠ 0
[PROOFSTEP]
simp_rw [degree_le_iff_coeff_zero, Nat.cast_lt]
[GOAL]
case pn
n : ℕ
⊢ ∀ (m : ℕ), n < m → coeff (hermite n) m = 0
[PROOFSTEP]
rintro m hnm
[GOAL]
case pn
n m : ℕ
hnm : n < m
⊢ coeff (hermite n) m = 0
[PROOFSTEP]
exact coeff_hermite_of_lt hnm
[GOAL]
case p1
n : ℕ
⊢ coeff (hermite n) n ≠ 0
[PROOFSTEP]
simp [coeff_hermite_self n]
[GOAL]
n : ℕ
⊢ leadingCoeff (hermite n) = 1
[PROOFSTEP]
rw [← coeff_natDegree, natDegree_hermite, coeff_hermite_self]
[GOAL]
n k : ℕ
hnk : Odd (n + k)
⊢ coeff (hermite n) k = 0
[PROOFSTEP]
induction' n with n ih generalizing k
[GOAL]
case zero
n k✝ : ℕ
hnk✝ : Odd (n + k✝)
k : ℕ
hnk : Odd (Nat.zero + k)
⊢ coeff (hermite Nat.zero) k = 0
[PROOFSTEP]
rw [Nat.zero_eq, zero_add k] at hnk
[GOAL]
case zero
n k✝ : ℕ
hnk✝ : Odd (n + k✝)
k : ℕ
hnk : Odd k
⊢ coeff (hermite Nat.zero) k = 0
[PROOFSTEP]
exact coeff_hermite_of_lt hnk.pos
[GOAL]
case succ
n✝ k✝ : ℕ
hnk✝ : Odd (n✝ + k✝)
n : ℕ
ih : ∀ {k : ℕ}, Odd (n + k) → coeff (hermite n) k = 0
k : ℕ
hnk : Odd (Nat.succ n + k)
⊢ coeff (hermite (Nat.succ n)) k = 0
[PROOFSTEP]
cases' k with k
[GOAL]
case succ.zero
n✝ k : ℕ
hnk✝ : Odd (n✝ + k)
n : ℕ
ih : ∀ {k : ℕ}, Odd (n + k) → coeff (hermite n) k = 0
hnk : Odd (Nat.succ n + Nat.zero)
⊢ coeff (hermite (Nat.succ n)) Nat.zero = 0
[PROOFSTEP]
rw [Nat.succ_add_eq_succ_add] at hnk
[GOAL]
case succ.zero
n✝ k : ℕ
hnk✝ : Odd (n✝ + k)
n : ℕ
ih : ∀ {k : ℕ}, Odd (n + k) → coeff (hermite n) k = 0
hnk : Odd (n + Nat.succ Nat.zero)
⊢ coeff (hermite (Nat.succ n)) Nat.zero = 0
[PROOFSTEP]
rw [coeff_hermite_succ_zero, ih hnk, neg_zero]
[GOAL]
case succ.succ
n✝ k✝ : ℕ
hnk✝ : Odd (n✝ + k✝)
n : ℕ
ih : ∀ {k : ℕ}, Odd (n + k) → coeff (hermite n) k = 0
k : ℕ
hnk : Odd (Nat.succ n + Nat.succ k)
⊢ coeff (hermite (Nat.succ n)) (Nat.succ k) = 0
[PROOFSTEP]
rw [coeff_hermite_succ_succ, ih, ih, mul_zero, sub_zero]
[GOAL]
case succ.succ
n✝ k✝ : ℕ
hnk✝ : Odd (n✝ + k✝)
n : ℕ
ih : ∀ {k : ℕ}, Odd (n + k) → coeff (hermite n) k = 0
k : ℕ
hnk : Odd (Nat.succ n + Nat.succ k)
⊢ Odd (n + (k + 2))
[PROOFSTEP]
rwa [Nat.succ_add_eq_succ_add] at hnk
[GOAL]
case succ.succ
n✝ k✝ : ℕ
hnk✝ : Odd (n✝ + k✝)
n : ℕ
ih : ∀ {k : ℕ}, Odd (n + k) → coeff (hermite n) k = 0
k : ℕ
hnk : Odd (Nat.succ n + Nat.succ k)
⊢ Odd (n + k)
[PROOFSTEP]
rw [(by rw [Nat.succ_add, Nat.add_succ] : n.succ + k.succ = n + k + 2)] at hnk
[GOAL]
n✝ k✝ : ℕ
hnk✝ : Odd (n✝ + k✝)
n : ℕ
ih : ∀ {k : ℕ}, Odd (n + k) → coeff (hermite n) k = 0
k : ℕ
hnk : Odd (Nat.succ n + Nat.succ k)
⊢ Nat.succ n + Nat.succ k = n + k + 2
[PROOFSTEP]
rw [Nat.succ_add, Nat.add_succ]
[GOAL]
case succ.succ
n✝ k✝ : ℕ
hnk✝ : Odd (n✝ + k✝)
n : ℕ
ih : ∀ {k : ℕ}, Odd (n + k) → coeff (hermite n) k = 0
k : ℕ
hnk : Odd (n + k + 2)
⊢ Odd (n + k)
[PROOFSTEP]
exact (Nat.odd_add.mp hnk).mpr even_two
[GOAL]
x✝ : ℕ
⊢ coeff (hermite (2 * 0 + x✝)) x✝ = (-1) ^ 0 * ↑(2 * 0 - 1)‼ * ↑(Nat.choose (2 * 0 + x✝) x✝)
[PROOFSTEP]
simp
[GOAL]
n : ℕ
⊢ coeff (hermite (2 * (n + 1) + 0)) 0 = (-1) ^ (n + 1) * ↑(2 * (n + 1) - 1)‼ * ↑(Nat.choose (2 * (n + 1) + 0) 0)
[PROOFSTEP]
convert coeff_hermite_succ_zero (2 * n + 1) using 1
  -- porting note: ring_nf did not solve the goal on line 165
[GOAL]
case h.e'_3
n : ℕ
⊢ (-1) ^ (n + 1) * ↑(2 * (n + 1) - 1)‼ * ↑(Nat.choose (2 * (n + 1) + 0) 0) = -coeff (hermite (2 * n + 1)) 1
[PROOFSTEP]
rw [coeff_hermite_explicit n 1, (by rw [Nat.left_distrib, mul_one, Nat.succ_sub_one] : 2 * (n + 1) - 1 = 2 * n + 1),
  Nat.doubleFactorial_add_one, Nat.choose_zero_right, Nat.choose_one_right, pow_succ]
[GOAL]
n : ℕ
⊢ 2 * (n + 1) - 1 = 2 * n + 1
[PROOFSTEP]
rw [Nat.left_distrib, mul_one, Nat.succ_sub_one]
[GOAL]
case h.e'_3
n : ℕ
⊢ -1 * (-1) ^ n * ↑((2 * n + 1) * (2 * n - 1)‼) * ↑1 = -((-1) ^ n * ↑(2 * n - 1)‼ * ↑(2 * n + 1))
[PROOFSTEP]
push_cast
[GOAL]
case h.e'_3
n : ℕ
⊢ -1 * (-1) ^ n * ((2 * ↑n + 1) * ↑(2 * n - 1)‼) * 1 = -((-1) ^ n * ↑(2 * n - 1)‼ * (2 * ↑n + 1))
[PROOFSTEP]
ring
[GOAL]
n k : ℕ
⊢ coeff (hermite (2 * (n + 1) + (k + 1))) (k + 1) =
    (-1) ^ (n + 1) * ↑(2 * (n + 1) - 1)‼ * ↑(Nat.choose (2 * (n + 1) + (k + 1)) (k + 1))
[PROOFSTEP]
let hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * (2 * n - 1)‼ * Nat.choose (2 * n + k) k
[GOAL]
n k : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
⊢ coeff (hermite (2 * (n + 1) + (k + 1))) (k + 1) =
    (-1) ^ (n + 1) * ↑(2 * (n + 1) - 1)‼ * ↑(Nat.choose (2 * (n + 1) + (k + 1)) (k + 1))
[PROOFSTEP]
have hermite_explicit_recur :
  ∀ n k : ℕ, hermite_explicit (n + 1) (k + 1) = hermite_explicit (n + 1) k - (k + 2) * hermite_explicit n (k + 2) :=
  by
  intro n k
  simp only
    -- Factor out (-1)'s.
  rw [mul_comm (↑k + _ : ℤ), sub_eq_add_neg]
  nth_rw 3 [neg_eq_neg_one_mul]
  simp only [mul_assoc, ← mul_add, pow_succ]
  congr 2
    -- Factor out double factorials.
  norm_cast
    -- porting note: ring_nf did not solve the goal on line 186
  rw [(by rw [Nat.left_distrib, mul_one, Nat.succ_sub_one] : 2 * (n + 1) - 1 = 2 * n + 1), Nat.doubleFactorial_add_one,
    mul_comm (2 * n + 1)]
  simp only [mul_assoc, ← mul_add]
  congr 1
    -- Match up binomial coefficients using `Nat.choose_succ_right_eq`.
  rw [(by ring : 2 * (n + 1) + (k + 1) = 2 * n + 1 + (k + 1) + 1), (by ring : 2 * (n + 1) + k = 2 * n + 1 + (k + 1)),
    (by ring : 2 * n + (k + 2) = 2 * n + 1 + (k + 1))]
  rw [Nat.choose, Nat.choose_succ_right_eq (2 * n + 1 + (k + 1)) (k + 1), Nat.add_sub_cancel, Int.negSucc_eq]
    -- porting note: ring could not solve the goal so the lines 195, 198-200 were added.
  ring_nf
  simp only [sub_eq_add_neg, ← neg_mul, ← right_distrib _ _ ((-(1 : ℤ)) ^ n), ← neg_add]
  norm_cast
  simp only [← add_assoc, add_comm]
[GOAL]
n k : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
⊢ ∀ (n k : ℕ), hermite_explicit (n + 1) (k + 1) = hermite_explicit (n + 1) k - (↑k + 2) * hermite_explicit n (k + 2)
[PROOFSTEP]
intro n k
[GOAL]
n✝ k✝ : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
n k : ℕ
⊢ hermite_explicit (n + 1) (k + 1) = hermite_explicit (n + 1) k - (↑k + 2) * hermite_explicit n (k + 2)
[PROOFSTEP]
simp only
  -- Factor out (-1)'s.
[GOAL]
n✝ k✝ : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
n k : ℕ
⊢ (-1) ^ (n + 1) * ↑(2 * (n + 1) - 1)‼ * ↑(Nat.choose (2 * (n + 1) + (k + 1)) (k + 1)) =
    (-1) ^ (n + 1) * ↑(2 * (n + 1) - 1)‼ * ↑(Nat.choose (2 * (n + 1) + k) k) -
      (↑k + 2) * ((-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + (k + 2)) (k + 2)))
[PROOFSTEP]
rw [mul_comm (↑k + _ : ℤ), sub_eq_add_neg]
[GOAL]
n✝ k✝ : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
n k : ℕ
⊢ (-1) ^ (n + 1) * ↑(2 * (n + 1) - 1)‼ * ↑(Nat.choose (2 * (n + 1) + (k + 1)) (k + 1)) =
    (-1) ^ (n + 1) * ↑(2 * (n + 1) - 1)‼ * ↑(Nat.choose (2 * (n + 1) + k) k) +
      -((-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + (k + 2)) (k + 2)) * (↑k + 2))
[PROOFSTEP]
nth_rw 3 [neg_eq_neg_one_mul]
[GOAL]
n✝ k✝ : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
n k : ℕ
⊢ (-1) ^ (n + 1) * ↑(2 * (n + 1) - 1)‼ * ↑(Nat.choose (2 * (n + 1) + (k + 1)) (k + 1)) =
    (-1) ^ (n + 1) * ↑(2 * (n + 1) - 1)‼ * ↑(Nat.choose (2 * (n + 1) + k) k) +
      -((-1 * 1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + (k + 2)) (k + 2)) * (↑k + 2))
[PROOFSTEP]
simp only [mul_assoc, ← mul_add, pow_succ]
[GOAL]
n✝ k✝ : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
n k : ℕ
⊢ -1 * ((-1) ^ n * (↑(2 * (n + 1) - 1)‼ * ↑(Nat.choose (2 * (n + 1) + (k + 1)) (k + 1)))) =
    -1 * ((-1) ^ n * (↑(2 * (n + 1) - 1)‼ * ↑(Nat.choose (2 * (n + 1) + k) k))) +
      -((-1 * 1) ^ n * (↑(2 * n - 1)‼ * (↑(Nat.choose (2 * n + (k + 2)) (k + 2)) * (↑k + 2))))
[PROOFSTEP]
congr 2
  -- Factor out double factorials.
[GOAL]
n✝ k✝ : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
n k : ℕ
⊢ -1 * ((-1) ^ n * (↑(2 * (n + 1) - 1)‼ * ↑(Nat.choose (2 * (n + 1) + (k + 1)) (k + 1)))) =
    -1 * ((-1) ^ n * (↑(2 * (n + 1) - 1)‼ * ↑(Nat.choose (2 * (n + 1) + k) k))) +
      -((-1 * 1) ^ n * (↑(2 * n - 1)‼ * (↑(Nat.choose (2 * n + (k + 2)) (k + 2)) * (↑k + 2))))
[PROOFSTEP]
norm_cast
  -- porting note: ring_nf did not solve the goal on line 186
[GOAL]
n✝ k✝ : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
n k : ℕ
⊢ Int.negSucc 0 * (Int.negSucc 0 ^ n * ↑((2 * (n + 1) - 1)‼ * Nat.choose (2 * (n + 1) + (k + 1)) (k + 1))) =
    Int.negSucc 0 * (Int.negSucc 0 ^ n * ↑((2 * (n + 1) - 1)‼ * Nat.choose (2 * (n + 1) + k) k)) +
      -((Int.negSucc 0 * 1) ^ n * ↑((2 * n - 1)‼ * (Nat.choose (2 * n + (k + 2)) (k + 2) * (k + 2))))
[PROOFSTEP]
rw [(by rw [Nat.left_distrib, mul_one, Nat.succ_sub_one] : 2 * (n + 1) - 1 = 2 * n + 1), Nat.doubleFactorial_add_one,
  mul_comm (2 * n + 1)]
[GOAL]
n✝ k✝ : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
n k : ℕ
⊢ 2 * (n + 1) - 1 = 2 * n + 1
[PROOFSTEP]
rw [Nat.left_distrib, mul_one, Nat.succ_sub_one]
[GOAL]
n✝ k✝ : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
n k : ℕ
⊢ Int.negSucc 0 * (Int.negSucc 0 ^ n * ↑((2 * n - 1)‼ * (2 * n + 1) * Nat.choose (2 * (n + 1) + (k + 1)) (k + 1))) =
    Int.negSucc 0 * (Int.negSucc 0 ^ n * ↑((2 * n - 1)‼ * (2 * n + 1) * Nat.choose (2 * (n + 1) + k) k)) +
      -((Int.negSucc 0 * 1) ^ n * ↑((2 * n - 1)‼ * (Nat.choose (2 * n + (k + 2)) (k + 2) * (k + 2))))
[PROOFSTEP]
simp only [mul_assoc, ← mul_add]
[GOAL]
n✝ k✝ : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
n k : ℕ
⊢ Int.negSucc 0 * (Int.negSucc 0 ^ n * ↑((2 * n - 1)‼ * ((2 * n + 1) * Nat.choose (2 * (n + 1) + (k + 1)) (k + 1)))) =
    Int.negSucc 0 * (Int.negSucc 0 ^ n * ↑((2 * n - 1)‼ * ((2 * n + 1) * Nat.choose (2 * (n + 1) + k) k))) +
      -((Int.negSucc 0 * 1) ^ n * ↑((2 * n - 1)‼ * (Nat.choose (2 * n + (k + 2)) (k + 2) * (k + 2))))
[PROOFSTEP]
congr 1
  -- Match up binomial coefficients using `Nat.choose_succ_right_eq`.
[GOAL]
n✝ k✝ : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
n k : ℕ
⊢ Int.negSucc 0 * (Int.negSucc 0 ^ n * ↑((2 * n - 1)‼ * ((2 * n + 1) * Nat.choose (2 * (n + 1) + (k + 1)) (k + 1)))) =
    Int.negSucc 0 * (Int.negSucc 0 ^ n * ↑((2 * n - 1)‼ * ((2 * n + 1) * Nat.choose (2 * (n + 1) + k) k))) +
      -((Int.negSucc 0 * 1) ^ n * ↑((2 * n - 1)‼ * (Nat.choose (2 * n + (k + 2)) (k + 2) * (k + 2))))
[PROOFSTEP]
rw [(by ring : 2 * (n + 1) + (k + 1) = 2 * n + 1 + (k + 1) + 1), (by ring : 2 * (n + 1) + k = 2 * n + 1 + (k + 1)),
  (by ring : 2 * n + (k + 2) = 2 * n + 1 + (k + 1))]
[GOAL]
n✝ k✝ : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
n k : ℕ
⊢ 2 * (n + 1) + (k + 1) = 2 * n + 1 + (k + 1) + 1
[PROOFSTEP]
ring
[GOAL]
n✝ k✝ : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
n k : ℕ
⊢ 2 * (n + 1) + k = 2 * n + 1 + (k + 1)
[PROOFSTEP]
ring
[GOAL]
n✝ k✝ : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
n k : ℕ
⊢ 2 * n + (k + 2) = 2 * n + 1 + (k + 1)
[PROOFSTEP]
ring
[GOAL]
n✝ k✝ : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
n k : ℕ
⊢ Int.negSucc 0 * (Int.negSucc 0 ^ n * ↑((2 * n - 1)‼ * ((2 * n + 1) * Nat.choose (2 * n + 1 + (k + 1) + 1) (k + 1)))) =
    Int.negSucc 0 * (Int.negSucc 0 ^ n * ↑((2 * n - 1)‼ * ((2 * n + 1) * Nat.choose (2 * n + 1 + (k + 1)) k))) +
      -((Int.negSucc 0 * 1) ^ n * ↑((2 * n - 1)‼ * (Nat.choose (2 * n + 1 + (k + 1)) (k + 2) * (k + 2))))
[PROOFSTEP]
rw [Nat.choose, Nat.choose_succ_right_eq (2 * n + 1 + (k + 1)) (k + 1), Nat.add_sub_cancel, Int.negSucc_eq]
  -- porting note: ring could not solve the goal so the lines 195, 198-200 were added.
[GOAL]
n✝ k✝ : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
n k : ℕ
⊢ -(↑0 + 1) *
      ((-(↑0 + 1)) ^ n *
        ↑((2 * n - 1)‼ *
            ((2 * n + 1) * (Nat.choose (2 * n + 1 + (k + 1)) k + Nat.choose (2 * n + 1 + (k + 1)) (k + 1))))) =
    -(↑0 + 1) * ((-(↑0 + 1)) ^ n * ↑((2 * n - 1)‼ * ((2 * n + 1) * Nat.choose (2 * n + 1 + (k + 1)) k))) +
      -((-(↑0 + 1) * 1) ^ n * ↑((2 * n - 1)‼ * (Nat.choose (2 * n + 1 + (k + 1)) (k + 1) * (2 * n + 1))))
[PROOFSTEP]
ring_nf
[GOAL]
n✝ k✝ : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
n k : ℕ
⊢ -(↑(n * (n * 2 - 1)‼ * Nat.choose (2 + n * 2 + k) k * 2 + n * (n * 2 - 1)‼ * Nat.choose (2 + n * 2 + k) (1 + k) * 2 +
              (n * 2 - 1)‼ * Nat.choose (2 + n * 2 + k) k +
            (n * 2 - 1)‼ * Nat.choose (2 + n * 2 + k) (1 + k)) *
        (-1) ^ n) =
    -(↑(n * (n * 2 - 1)‼ * Nat.choose (2 + n * 2 + k) k * 2 + (n * 2 - 1)‼ * Nat.choose (2 + n * 2 + k) k) * (-1) ^ n) -
      ↑(n * (n * 2 - 1)‼ * Nat.choose (2 + n * 2 + k) (1 + k) * 2 + (n * 2 - 1)‼ * Nat.choose (2 + n * 2 + k) (1 + k)) *
        (-1) ^ n
[PROOFSTEP]
simp only [sub_eq_add_neg, ← neg_mul, ← right_distrib _ _ ((-(1 : ℤ)) ^ n), ← neg_add]
[GOAL]
n✝ k✝ : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
n k : ℕ
⊢ -↑(n * (n * 2 - 1)‼ * Nat.choose (2 + n * 2 + k) k * 2 + n * (n * 2 - 1)‼ * Nat.choose (2 + n * 2 + k) (1 + k) * 2 +
              (n * 2 - 1)‼ * Nat.choose (2 + n * 2 + k) k +
            (n * 2 - 1)‼ * Nat.choose (2 + n * 2 + k) (1 + k)) *
      (-1) ^ n =
    -(↑(n * (n * 2 - 1)‼ * Nat.choose (2 + n * 2 + k) k * 2 + (n * 2 - 1)‼ * Nat.choose (2 + n * 2 + k) k) +
          ↑(n * (n * 2 - 1)‼ * Nat.choose (2 + n * 2 + k) (1 + k) * 2 +
              (n * 2 - 1)‼ * Nat.choose (2 + n * 2 + k) (1 + k))) *
      (-1) ^ n
[PROOFSTEP]
norm_cast
[GOAL]
n✝ k✝ : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
n k : ℕ
⊢ -↑(n * (n * 2 - 1)‼ * Nat.choose (2 + n * 2 + k) k * 2 + n * (n * 2 - 1)‼ * Nat.choose (2 + n * 2 + k) (1 + k) * 2 +
              (n * 2 - 1)‼ * Nat.choose (2 + n * 2 + k) k +
            (n * 2 - 1)‼ * Nat.choose (2 + n * 2 + k) (1 + k)) *
      Int.negSucc 0 ^ n =
    -↑(n * (n * 2 - 1)‼ * Nat.choose (2 + n * 2 + k) k * 2 + (n * 2 - 1)‼ * Nat.choose (2 + n * 2 + k) k +
            (n * (n * 2 - 1)‼ * Nat.choose (2 + n * 2 + k) (1 + k) * 2 +
              (n * 2 - 1)‼ * Nat.choose (2 + n * 2 + k) (1 + k))) *
      Int.negSucc 0 ^ n
[PROOFSTEP]
simp only [← add_assoc, add_comm]
[GOAL]
n k : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
hermite_explicit_recur :
  ∀ (n k : ℕ), hermite_explicit (n + 1) (k + 1) = hermite_explicit (n + 1) k - (↑k + 2) * hermite_explicit n (k + 2)
⊢ coeff (hermite (2 * (n + 1) + (k + 1))) (k + 1) =
    (-1) ^ (n + 1) * ↑(2 * (n + 1) - 1)‼ * ↑(Nat.choose (2 * (n + 1) + (k + 1)) (k + 1))
[PROOFSTEP]
change _ = hermite_explicit _ _
[GOAL]
n k : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
hermite_explicit_recur :
  ∀ (n k : ℕ), hermite_explicit (n + 1) (k + 1) = hermite_explicit (n + 1) k - (↑k + 2) * hermite_explicit n (k + 2)
⊢ coeff (hermite (2 * (n + 1) + (k + 1))) (k + 1) = hermite_explicit (n + 1) (k + 1)
[PROOFSTEP]
rw [← add_assoc, coeff_hermite_succ_succ, hermite_explicit_recur]
[GOAL]
n k : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
hermite_explicit_recur :
  ∀ (n k : ℕ), hermite_explicit (n + 1) (k + 1) = hermite_explicit (n + 1) k - (↑k + 2) * hermite_explicit n (k + 2)
⊢ coeff (hermite (2 * (n + 1) + k)) k - (↑k + 2) * coeff (hermite (2 * (n + 1) + k)) (k + 2) =
    hermite_explicit (n + 1) k - (↑k + 2) * hermite_explicit n (k + 2)
[PROOFSTEP]
congr
[GOAL]
case e_a
n k : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
hermite_explicit_recur :
  ∀ (n k : ℕ), hermite_explicit (n + 1) (k + 1) = hermite_explicit (n + 1) k - (↑k + 2) * hermite_explicit n (k + 2)
⊢ coeff (hermite (2 * (n + 1) + k)) k = hermite_explicit (n + 1) k
[PROOFSTEP]
rw [coeff_hermite_explicit (n + 1) k]
[GOAL]
case e_a.e_a
n k : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
hermite_explicit_recur :
  ∀ (n k : ℕ), hermite_explicit (n + 1) (k + 1) = hermite_explicit (n + 1) k - (↑k + 2) * hermite_explicit n (k + 2)
⊢ coeff (hermite (2 * (n + 1) + k)) (k + 2) = hermite_explicit n (k + 2)
[PROOFSTEP]
rw [(by ring : 2 * (n + 1) + k = 2 * n + (k + 2)), coeff_hermite_explicit n (k + 2)]
  -- porting note: Lean 3 worked this out automatically
[GOAL]
n k : ℕ
hermite_explicit : ℕ → ℕ → ℤ := fun n k => (-1) ^ n * ↑(2 * n - 1)‼ * ↑(Nat.choose (2 * n + k) k)
hermite_explicit_recur :
  ∀ (n k : ℕ), hermite_explicit (n + 1) (k + 1) = hermite_explicit (n + 1) k - (↑k + 2) * hermite_explicit n (k + 2)
⊢ 2 * (n + 1) + k = 2 * n + (k + 2)
[PROOFSTEP]
ring
[GOAL]
n k : ℕ
hnk : Even (n + k)
⊢ coeff (hermite n) k = (-1) ^ ((n - k) / 2) * ↑(n - k - 1)‼ * ↑(Nat.choose n k)
[PROOFSTEP]
cases' le_or_lt k n with h_le h_lt
[GOAL]
case inl
n k : ℕ
hnk : Even (n + k)
h_le : k ≤ n
⊢ coeff (hermite n) k = (-1) ^ ((n - k) / 2) * ↑(n - k - 1)‼ * ↑(Nat.choose n k)
[PROOFSTEP]
rw [Nat.even_add, ← Nat.even_sub h_le] at hnk
[GOAL]
case inl
n k : ℕ
hnk : Even (n - k)
h_le : k ≤ n
⊢ coeff (hermite n) k = (-1) ^ ((n - k) / 2) * ↑(n - k - 1)‼ * ↑(Nat.choose n k)
[PROOFSTEP]
obtain ⟨m, hm⟩ := hnk
[GOAL]
case inl.intro
n k : ℕ
h_le : k ≤ n
m : ℕ
hm : n - k = m + m
⊢ coeff (hermite n) k = (-1) ^ ((n - k) / 2) * ↑(n - k - 1)‼ * ↑(Nat.choose n k)
[PROOFSTEP]
rw [(by linarith [by rwa [Nat.sub_eq_iff_eq_add h_le] at hm ] : n = 2 * m + k), Nat.add_sub_cancel,
  Nat.mul_div_cancel_left _ (Nat.succ_pos 1), coeff_hermite_explicit]
[GOAL]
n k : ℕ
h_le : k ≤ n
m : ℕ
hm : n - k = m + m
⊢ n = 2 * m + k
[PROOFSTEP]
linarith [by rwa [Nat.sub_eq_iff_eq_add h_le] at hm ]
[GOAL]
n k : ℕ
h_le : k ≤ n
m : ℕ
hm : n - k = m + m
⊢ ?m.206711
[PROOFSTEP]
rwa [Nat.sub_eq_iff_eq_add h_le] at hm
[GOAL]
case inr
n k : ℕ
hnk : Even (n + k)
h_lt : n < k
⊢ coeff (hermite n) k = (-1) ^ ((n - k) / 2) * ↑(n - k - 1)‼ * ↑(Nat.choose n k)
[PROOFSTEP]
simp [Nat.choose_eq_zero_of_lt h_lt, coeff_hermite_of_lt h_lt]
[GOAL]
n k : ℕ
⊢ coeff (hermite n) k = if Even (n + k) then (-1) ^ ((n - k) / 2) * ↑(n - k - 1)‼ * ↑(Nat.choose n k) else 0
[PROOFSTEP]
split_ifs with h
[GOAL]
case pos
n k : ℕ
h : Even (n + k)
⊢ coeff (hermite n) k = (-1) ^ ((n - k) / 2) * ↑(n - k - 1)‼ * ↑(Nat.choose n k)
case neg n k : ℕ h : ¬Even (n + k) ⊢ coeff (hermite n) k = 0
[PROOFSTEP]
exact coeff_hermite_of_even_add h
[GOAL]
case neg
n k : ℕ
h : ¬Even (n + k)
⊢ coeff (hermite n) k = 0
[PROOFSTEP]
exact coeff_hermite_of_odd_add (Nat.odd_iff_not_even.mpr h)


[GOAL]
x y : ℝ
h :
  ((∀ (k : ℤ), x ≠ (2 * ↑k + 1) * π / 2) ∧ ∀ (l : ℤ), y ≠ (2 * ↑l + 1) * π / 2) ∨
    (∃ k, x = (2 * ↑k + 1) * π / 2) ∧ ∃ l, y = (2 * ↑l + 1) * π / 2
⊢ tan (x + y) = (tan x + tan y) / (1 - tan x * tan y)
[PROOFSTEP]
simpa only [← Complex.ofReal_inj, Complex.ofReal_sub, Complex.ofReal_add, Complex.ofReal_div, Complex.ofReal_mul,
  Complex.ofReal_tan] using @Complex.tan_add (x : ℂ) (y : ℂ) (by convert h <;> norm_cast)
[GOAL]
x y : ℝ
h :
  ((∀ (k : ℤ), x ≠ (2 * ↑k + 1) * π / 2) ∧ ∀ (l : ℤ), y ≠ (2 * ↑l + 1) * π / 2) ∨
    (∃ k, x = (2 * ↑k + 1) * π / 2) ∧ ∃ l, y = (2 * ↑l + 1) * π / 2
⊢ ((∀ (k : ℤ), ↑x ≠ (2 * ↑k + 1) * ↑π / 2) ∧ ∀ (l : ℤ), ↑y ≠ (2 * ↑l + 1) * ↑π / 2) ∨
    (∃ k, ↑x = (2 * ↑k + 1) * ↑π / 2) ∧ ∃ l, ↑y = (2 * ↑l + 1) * ↑π / 2
[PROOFSTEP]
convert h
[GOAL]
case h.e'_1.h.e'_1.h.h.a
x y : ℝ
h :
  ((∀ (k : ℤ), x ≠ (2 * ↑k + 1) * π / 2) ∧ ∀ (l : ℤ), y ≠ (2 * ↑l + 1) * π / 2) ∨
    (∃ k, x = (2 * ↑k + 1) * π / 2) ∧ ∃ l, y = (2 * ↑l + 1) * π / 2
a✝ : ℤ
⊢ ↑x = (2 * ↑a✝ + 1) * ↑π / 2 ↔ x = (2 * ↑a✝ + 1) * π / 2
[PROOFSTEP]
norm_cast
[GOAL]
case h.e'_1.h.e'_2.h.h.a
x y : ℝ
h :
  ((∀ (k : ℤ), x ≠ (2 * ↑k + 1) * π / 2) ∧ ∀ (l : ℤ), y ≠ (2 * ↑l + 1) * π / 2) ∨
    (∃ k, x = (2 * ↑k + 1) * π / 2) ∧ ∃ l, y = (2 * ↑l + 1) * π / 2
a✝ : ℤ
⊢ ↑y = (2 * ↑a✝ + 1) * ↑π / 2 ↔ y = (2 * ↑a✝ + 1) * π / 2
[PROOFSTEP]
norm_cast
[GOAL]
case h.e'_2.h.e'_1.h.e'_2.h.a
x y : ℝ
h :
  ((∀ (k : ℤ), x ≠ (2 * ↑k + 1) * π / 2) ∧ ∀ (l : ℤ), y ≠ (2 * ↑l + 1) * π / 2) ∨
    (∃ k, x = (2 * ↑k + 1) * π / 2) ∧ ∃ l, y = (2 * ↑l + 1) * π / 2
x✝ : ℤ
⊢ ↑x = (2 * ↑x✝ + 1) * ↑π / 2 ↔ x = (2 * ↑x✝ + 1) * π / 2
[PROOFSTEP]
norm_cast
[GOAL]
case h.e'_2.h.e'_2.h.e'_2.h.a
x y : ℝ
h :
  ((∀ (k : ℤ), x ≠ (2 * ↑k + 1) * π / 2) ∧ ∀ (l : ℤ), y ≠ (2 * ↑l + 1) * π / 2) ∨
    (∃ k, x = (2 * ↑k + 1) * π / 2) ∧ ∃ l, y = (2 * ↑l + 1) * π / 2
x✝ : ℤ
⊢ ↑y = (2 * ↑x✝ + 1) * ↑π / 2 ↔ y = (2 * ↑x✝ + 1) * π / 2
[PROOFSTEP]
norm_cast
[GOAL]
x : ℝ
⊢ tan (2 * x) = ↑2 * tan x / (↑1 - tan x ^ 2)
[PROOFSTEP]
have := @Complex.tan_two_mul x
[GOAL]
x : ℝ
this : Complex.tan (2 * ↑x) = 2 * Complex.tan ↑x / (1 - Complex.tan ↑x ^ 2)
⊢ tan (2 * x) = ↑2 * tan x / (↑1 - tan x ^ 2)
[PROOFSTEP]
norm_cast at *
[GOAL]
θ : ℝ
⊢ tan θ ≠ 0 ↔ ∀ (k : ℤ), θ ≠ ↑k * π / 2
[PROOFSTEP]
rw [← Complex.ofReal_ne_zero, Complex.ofReal_tan, Complex.tan_ne_zero_iff]
[GOAL]
θ : ℝ
⊢ (∀ (k : ℤ), ↑θ ≠ ↑k * ↑π / 2) ↔ ∀ (k : ℤ), θ ≠ ↑k * π / 2
[PROOFSTEP]
norm_cast
[GOAL]
θ : ℝ
⊢ tan θ = 0 ↔ ∃ k, θ = ↑k * π / 2
[PROOFSTEP]
rw [← not_iff_not, not_exists, ← Ne, tan_ne_zero_iff]
[GOAL]
n : ℤ
⊢ ∃ k, ↑n * π / 2 = ↑k * π / 2
[PROOFSTEP]
use n
[GOAL]
⊢ ContinuousOn tan {x | cos x ≠ 0}
[PROOFSTEP]
suffices ContinuousOn (fun x => sin x / cos x) {x | cos x ≠ 0}
  by
  have h_eq : (fun x => sin x / cos x) = tan := by ext1 x; rw [tan_eq_sin_div_cos]
  rwa [h_eq] at this
[GOAL]
this : ContinuousOn (fun x => sin x / cos x) {x | cos x ≠ 0}
⊢ ContinuousOn tan {x | cos x ≠ 0}
[PROOFSTEP]
have h_eq : (fun x => sin x / cos x) = tan := by ext1 x; rw [tan_eq_sin_div_cos]
[GOAL]
this : ContinuousOn (fun x => sin x / cos x) {x | cos x ≠ 0}
⊢ (fun x => sin x / cos x) = tan
[PROOFSTEP]
ext1 x
[GOAL]
case h
this : ContinuousOn (fun x => sin x / cos x) {x | cos x ≠ 0}
x : ℝ
⊢ sin x / cos x = tan x
[PROOFSTEP]
rw [tan_eq_sin_div_cos]
[GOAL]
this : ContinuousOn (fun x => sin x / cos x) {x | cos x ≠ 0}
h_eq : (fun x => sin x / cos x) = tan
⊢ ContinuousOn tan {x | cos x ≠ 0}
[PROOFSTEP]
rwa [h_eq] at this
[GOAL]
⊢ ContinuousOn (fun x => sin x / cos x) {x | cos x ≠ 0}
[PROOFSTEP]
exact continuousOn_sin.div continuousOn_cos fun x => id
[GOAL]
⊢ ContinuousOn tan (Ioo (-(π / 2)) (π / 2))
[PROOFSTEP]
refine' ContinuousOn.mono continuousOn_tan fun x => _
[GOAL]
x : ℝ
⊢ x ∈ Ioo (-(π / 2)) (π / 2) → x ∈ {x | cos x ≠ 0}
[PROOFSTEP]
simp only [and_imp, mem_Ioo, mem_setOf_eq, Ne.def]
[GOAL]
x : ℝ
⊢ -(π / 2) < x → x < π / 2 → ¬cos x = 0
[PROOFSTEP]
rw [cos_eq_zero_iff]
[GOAL]
x : ℝ
⊢ -(π / 2) < x → x < π / 2 → ¬∃ k, x = (2 * ↑k + 1) * π / 2
[PROOFSTEP]
rintro hx_gt hx_lt ⟨r, hxr_eq⟩
[GOAL]
case intro
x : ℝ
hx_gt : -(π / 2) < x
hx_lt : x < π / 2
r : ℤ
hxr_eq : x = (2 * ↑r + 1) * π / 2
⊢ False
[PROOFSTEP]
cases' le_or_lt 0 r with h h
[GOAL]
case intro.inl
x : ℝ
hx_gt : -(π / 2) < x
hx_lt : x < π / 2
r : ℤ
hxr_eq : x = (2 * ↑r + 1) * π / 2
h : 0 ≤ r
⊢ False
[PROOFSTEP]
rw [lt_iff_not_ge] at hx_lt
[GOAL]
case intro.inl
x : ℝ
hx_gt : -(π / 2) < x
hx_lt : ¬x ≥ π / 2
r : ℤ
hxr_eq : x = (2 * ↑r + 1) * π / 2
h : 0 ≤ r
⊢ False
[PROOFSTEP]
refine' hx_lt _
[GOAL]
case intro.inl
x : ℝ
hx_gt : -(π / 2) < x
hx_lt : ¬x ≥ π / 2
r : ℤ
hxr_eq : x = (2 * ↑r + 1) * π / 2
h : 0 ≤ r
⊢ x ≥ π / 2
[PROOFSTEP]
rw [hxr_eq, ← one_mul (π / 2), mul_div_assoc, ge_iff_le, mul_le_mul_right (half_pos pi_pos)]
[GOAL]
case intro.inl
x : ℝ
hx_gt : -(π / 2) < x
hx_lt : ¬x ≥ π / 2
r : ℤ
hxr_eq : x = (2 * ↑r + 1) * π / 2
h : 0 ≤ r
⊢ 1 ≤ 2 * ↑r + 1
[PROOFSTEP]
simp [h]
[GOAL]
case intro.inr
x : ℝ
hx_gt : -(π / 2) < x
hx_lt : x < π / 2
r : ℤ
hxr_eq : x = (2 * ↑r + 1) * π / 2
h : r < 0
⊢ False
[PROOFSTEP]
rw [lt_iff_not_ge] at hx_gt
[GOAL]
case intro.inr
x : ℝ
hx_gt : ¬-(π / 2) ≥ x
hx_lt : x < π / 2
r : ℤ
hxr_eq : x = (2 * ↑r + 1) * π / 2
h : r < 0
⊢ False
[PROOFSTEP]
refine' hx_gt _
[GOAL]
case intro.inr
x : ℝ
hx_gt : ¬-(π / 2) ≥ x
hx_lt : x < π / 2
r : ℤ
hxr_eq : x = (2 * ↑r + 1) * π / 2
h : r < 0
⊢ -(π / 2) ≥ x
[PROOFSTEP]
rw [hxr_eq, ← one_mul (π / 2), mul_div_assoc, ge_iff_le, neg_mul_eq_neg_mul, mul_le_mul_right (half_pos pi_pos)]
[GOAL]
case intro.inr
x : ℝ
hx_gt : ¬-(π / 2) ≥ x
hx_lt : x < π / 2
r : ℤ
hxr_eq : x = (2 * ↑r + 1) * π / 2
h : r < 0
⊢ 2 * ↑r + 1 ≤ -1
[PROOFSTEP]
have hr_le : r ≤ -1 := by rwa [Int.lt_iff_add_one_le, ← le_neg_iff_add_nonpos_right] at h
[GOAL]
x : ℝ
hx_gt : ¬-(π / 2) ≥ x
hx_lt : x < π / 2
r : ℤ
hxr_eq : x = (2 * ↑r + 1) * π / 2
h : r < 0
⊢ r ≤ -1
[PROOFSTEP]
rwa [Int.lt_iff_add_one_le, ← le_neg_iff_add_nonpos_right] at h
[GOAL]
case intro.inr
x : ℝ
hx_gt : ¬-(π / 2) ≥ x
hx_lt : x < π / 2
r : ℤ
hxr_eq : x = (2 * ↑r + 1) * π / 2
h : r < 0
hr_le : r ≤ -1
⊢ 2 * ↑r + 1 ≤ -1
[PROOFSTEP]
rw [← le_sub_iff_add_le, mul_comm, ← le_div_iff]
[GOAL]
case intro.inr
x : ℝ
hx_gt : ¬-(π / 2) ≥ x
hx_lt : x < π / 2
r : ℤ
hxr_eq : x = (2 * ↑r + 1) * π / 2
h : r < 0
hr_le : r ≤ -1
⊢ ↑r ≤ (-1 - 1) / 2
[PROOFSTEP]
norm_num
[GOAL]
case intro.inr
x : ℝ
hx_gt : ¬-(π / 2) ≥ x
hx_lt : x < π / 2
r : ℤ
hxr_eq : x = (2 * ↑r + 1) * π / 2
h : r < 0
hr_le : r ≤ -1
⊢ ↑r ≤ -1
[PROOFSTEP]
rw [← Int.cast_one, ← Int.cast_neg]
[GOAL]
case intro.inr
x : ℝ
hx_gt : ¬-(π / 2) ≥ x
hx_lt : x < π / 2
r : ℤ
hxr_eq : x = (2 * ↑r + 1) * π / 2
h : r < 0
hr_le : r ≤ -1
⊢ ↑r ≤ ↑(-1)
[PROOFSTEP]
norm_cast
[GOAL]
case intro.inr
x : ℝ
hx_gt : ¬-(π / 2) ≥ x
hx_lt : x < π / 2
r : ℤ
hxr_eq : x = (2 * ↑r + 1) * π / 2
h : r < 0
hr_le : r ≤ -1
⊢ 0 < 2
[PROOFSTEP]
exact zero_lt_two
[GOAL]
this : -(π / 2) < π / 2
⊢ Tendsto (fun x => tan ↑x) atBot atBot
[PROOFSTEP]
rw [tendsto_comp_coe_Ioo_atBot this]
[GOAL]
this : -(π / 2) < π / 2
⊢ Tendsto tan (𝓝[Ioi (-(π / 2))] (-(π / 2))) atBot
[PROOFSTEP]
exact tendsto_tan_neg_pi_div_two
[GOAL]
this : -(π / 2) < π / 2
⊢ Tendsto (fun x => tan ↑x) atTop atTop
[PROOFSTEP]
rw [tendsto_comp_coe_Ioo_atTop this]
[GOAL]
this : -(π / 2) < π / 2
⊢ Tendsto tan (𝓝[Iio (π / 2)] (π / 2)) atTop
[PROOFSTEP]
exact tendsto_tan_pi_div_two
[GOAL]
x : ℝ
⊢ cos (arctan x) ^ 2 = ↑1 / (↑1 + x ^ 2)
[PROOFSTEP]
rw_mod_cast [one_div, ← inv_one_add_tan_sq (cos_arctan_pos x).ne', tan_arctan]
[GOAL]
x : ℝ
⊢ sin (arctan x) = x / sqrt (↑1 + x ^ 2)
[PROOFSTEP]
rw_mod_cast [← tan_div_sqrt_one_add_tan_sq (cos_arctan_pos x), tan_arctan]
[GOAL]
x : ℝ
⊢ cos (arctan x) = ↑1 / sqrt (↑1 + x ^ 2)
[PROOFSTEP]
rw_mod_cast [one_div, ← inv_sqrt_one_add_tan_sq (cos_arctan_pos x), tan_arctan]
[GOAL]
x : ℝ
h : x ∈ Ioo (-1) 1
⊢ arcsin x = arctan (x / sqrt (↑1 - x ^ 2))
[PROOFSTEP]
rw_mod_cast [arctan_eq_arcsin, div_pow, sq_sqrt, one_add_div, div_div, ← sqrt_mul, mul_div_cancel', sub_add_cancel,
  sqrt_one, div_one]
[GOAL]
case hb
x : ℝ
h : x ∈ Ioo (↑(Int.negSucc 0)) 1
⊢ 1 - x ^ 2 ≠ 0
[PROOFSTEP]
simp at h
[GOAL]
case hx
x : ℝ
h : x ∈ Ioo (↑(Int.negSucc 0)) 1
⊢ 0 ≤ 1 - x ^ 2
[PROOFSTEP]
simp at h
[GOAL]
x : ℝ
h : x ∈ Ioo (↑(Int.negSucc 0)) 1
⊢ 1 - x ^ 2 ≠ 0
[PROOFSTEP]
simp at h
[GOAL]
x : ℝ
h : x ∈ Ioo (↑(Int.negSucc 0)) 1
⊢ 0 ≤ 1 - x ^ 2
[PROOFSTEP]
simp at h
[GOAL]
case hb
x : ℝ
h : -1 < x ∧ x < 1
⊢ 1 - x ^ 2 ≠ 0
[PROOFSTEP]
nlinarith [h.1, h.2]
[GOAL]
case hx
x : ℝ
h : -1 < x ∧ x < 1
⊢ 0 ≤ 1 - x ^ 2
[PROOFSTEP]
nlinarith [h.1, h.2]
[GOAL]
x : ℝ
h : -1 < x ∧ x < 1
⊢ 1 - x ^ 2 ≠ 0
[PROOFSTEP]
nlinarith [h.1, h.2]
[GOAL]
x : ℝ
h : -1 < x ∧ x < 1
⊢ 0 ≤ 1 - x ^ 2
[PROOFSTEP]
nlinarith [h.1, h.2]
[GOAL]
⊢ arctan 0 = 0
[PROOFSTEP]
simp [arctan_eq_arcsin]
[GOAL]
x y : ℝ
h : tan x = y
hx : x ∈ Ioo (-(π / 2)) (π / 2)
⊢ tan (arctan y) = tan x
[PROOFSTEP]
rw [tan_arctan, h]
[GOAL]
⊢ π / 4 ∈ Ioo (-(π / 2)) (π / 2)
[PROOFSTEP]
constructor
[GOAL]
case left
⊢ -(π / 2) < π / 4
[PROOFSTEP]
linarith [pi_pos]
[GOAL]
case right
⊢ π / 4 < π / 2
[PROOFSTEP]
linarith [pi_pos]
[GOAL]
x : ℝ
⊢ arctan (-x) = -arctan x
[PROOFSTEP]
simp [arctan_eq_arcsin, neg_div]
[GOAL]
x : ℝ
h : 0 ≤ x
⊢ arctan x = arccos (sqrt (↑1 + x ^ 2))⁻¹
[PROOFSTEP]
rw [arctan_eq_arcsin, arccos_eq_arcsin]
[GOAL]
x : ℝ
h : 0 ≤ x
⊢ arcsin (x / sqrt (↑1 + x ^ 2)) = arcsin (sqrt (1 - (sqrt (↑1 + x ^ 2))⁻¹ ^ 2))
x : ℝ h : 0 ≤ x ⊢ 0 ≤ (sqrt (↑1 + x ^ 2))⁻¹
[PROOFSTEP]
swap
[GOAL]
x : ℝ
h : 0 ≤ x
⊢ 0 ≤ (sqrt (↑1 + x ^ 2))⁻¹
[PROOFSTEP]
exact inv_nonneg.2 (sqrt_nonneg _)
[GOAL]
x : ℝ
h : 0 ≤ x
⊢ arcsin (x / sqrt (↑1 + x ^ 2)) = arcsin (sqrt (1 - (sqrt (↑1 + x ^ 2))⁻¹ ^ 2))
[PROOFSTEP]
congr 1
[GOAL]
case e_a
x : ℝ
h : 0 ≤ x
⊢ x / sqrt (↑1 + x ^ 2) = sqrt (1 - (sqrt (↑1 + x ^ 2))⁻¹ ^ 2)
[PROOFSTEP]
rw_mod_cast [← sqrt_inv, sq_sqrt, ← one_div, one_sub_div, add_sub_cancel', sqrt_div, sqrt_sq h]
[GOAL]
case e_a.hx
x : ℝ
h : 0 ≤ x
⊢ 0 ≤ x ^ 2
case e_a
x : ℝ
h : 0 ≤ x
⊢ 1 + x ^ 2 ≠ 0
case e_a x : ℝ h : 0 ≤ x ⊢ 0 ≤ (1 + x ^ 2)⁻¹
[PROOFSTEP]
all_goals positivity
[GOAL]
case e_a.hx
x : ℝ
h : 0 ≤ x
⊢ 0 ≤ x ^ 2
[PROOFSTEP]
positivity
[GOAL]
case e_a
x : ℝ
h : 0 ≤ x
⊢ 1 + x ^ 2 ≠ 0
[PROOFSTEP]
positivity
[GOAL]
case e_a
x : ℝ
h : 0 ≤ x
⊢ 0 ≤ (1 + x ^ 2)⁻¹
[PROOFSTEP]
positivity
[GOAL]
x : ℝ
h : 0 < x
⊢ arccos x = arctan (sqrt (↑1 - x ^ 2) / x)
[PROOFSTEP]
rw [arccos, eq_comm]
[GOAL]
x : ℝ
h : 0 < x
⊢ arctan (sqrt (↑1 - x ^ 2) / x) = π / 2 - arcsin x
[PROOFSTEP]
refine' arctan_eq_of_tan_eq _ ⟨_, _⟩
[GOAL]
case refine'_1
x : ℝ
h : 0 < x
⊢ tan (π / 2 - arcsin x) = sqrt (↑1 - x ^ 2) / x
[PROOFSTEP]
rw_mod_cast [tan_pi_div_two_sub, tan_arcsin, inv_div]
[GOAL]
case refine'_2
x : ℝ
h : 0 < x
⊢ -(π / 2) < π / 2 - arcsin x
[PROOFSTEP]
linarith only [arcsin_le_pi_div_two x, pi_pos]
[GOAL]
case refine'_3
x : ℝ
h : 0 < x
⊢ π / 2 - arcsin x < π / 2
[PROOFSTEP]
linarith only [arcsin_pos.2 h]