Theorem: Real.cos_quadratic_upper_bound
File: Mathlib/Analysis/SpecialFunctions/Trigonometric/Bounds.lean

Proof steps:
state_before: x : ℝ
hx : |x| ≤ π
⊢ cos x ≤ 1 - 2 / π ^ 2 * x ^ 2
state_after: case inr
x : ℝ
hx : |x| ≤ π
this : ∀ {x : ℝ}, |x| ≤ π → 0 ≤ x → cos x ≤ 1 - 2 / π ^ 2 * x ^ 2
hx₀ : ¬0 ≤ x
⊢ cos x ≤ 1 - 2 / π ^ 2 * x ^ 2

x✝ x : ℝ
hx : |x| ≤ π
hx₀ : 0 ≤ x
⊢ cos x ≤ 1 - 2 / π ^ 2 * x ^ 2
tactic: wlog hx₀ : 0 ≤ x
state_before: x✝ x : ℝ
hx : |x| ≤ π
hx₀ : 0 ≤ x
⊢ cos x ≤ 1 - 2 / π ^ 2 * x ^ 2
state_after: x✝ x : ℝ
hx : x ≤ π
hx₀ : 0 ≤ x
⊢ cos x ≤ 1 - 2 / π ^ 2 * x ^ 2
tactic: rw [abs_of_nonneg hx₀] at hx
state_before: x✝ x : ℝ
hx : x ≤ π
hx₀ : 0 ≤ x
⊢ cos x ≤ 1 - 2 / π ^ 2 * x ^ 2
state_after: x✝ x : ℝ
hx : x ≤ π
hx₀ : 0 ≤ x
hderiv : ∀ (x : ℝ), HasDerivAt (fun x => 1 - 2 / π ^ 2 * x ^ 2 - cos x) (-(2 / π ^ 2 * (↑2 * x ^ (2 - 1))) - -sin x) x
⊢ cos x ≤ 1 - 2 / π ^ 2 * x ^ 2
tactic: have hderiv (x) : HasDerivAt (fun x ↦ 1 - 2 / π ^ 2 * x ^ 2 - cos x) _ x :=
    (((hasDerivAt_pow ..).const_mul _).const_sub _).sub $ hasDerivAt_cos _
state_before: x✝ x : ℝ
hx : x ≤ π
hx₀ : 0 ≤ x
hderiv : ∀ (x : ℝ), HasDerivAt (fun x => 1 - 2 / π ^ 2 * x ^ 2 - cos x) (-(2 / π ^ 2 * (↑2 * x ^ (2 - 1))) - -sin x) x
⊢ cos x ≤ 1 - 2 / π ^ 2 * x ^ 2
state_after: x✝ x : ℝ
hx : x ≤ π
hx₀ : 0 ≤ x
hderiv : ∀ (x : ℝ), HasDerivAt (fun x => 1 - 2 / π ^ 2 * x ^ 2 - cos x) (sin x - 2 / π ^ 2 * 2 * x) x
⊢ cos x ≤ 1 - 2 / π ^ 2 * x ^ 2
tactic: simp only [Nat.cast_ofNat, Nat.succ_sub_succ_eq_sub, tsub_zero, pow_one, ← neg_sub', neg_sub,
    ← mul_assoc] at hderiv
state_before: x✝ x : ℝ
hx : x ≤ π
hx₀ : 0 ≤ x
hderiv : ∀ (x : ℝ), HasDerivAt (fun x => 1 - 2 / π ^ 2 * x ^ 2 - cos x) (sin x - 2 / π ^ 2 * 2 * x) x
⊢ cos x ≤ 1 - 2 / π ^ 2 * x ^ 2
state_after: x✝ x : ℝ
hx : x ≤ π
hx₀ : 0 ≤ x
hderiv : ∀ (x : ℝ), HasDerivAt (fun x => 1 - 2 / π ^ 2 * x ^ 2 - cos x) (sin x - 2 / π ^ 2 * 2 * x) x
hmono : MonotoneOn (fun x => 1 - 2 / π ^ 2 * x ^ 2 - cos x) (Icc 0 (π / 2))
⊢ cos x ≤ 1 - 2 / π ^ 2 * x ^ 2
tactic: have hmono : MonotoneOn (fun x ↦ 1 - 2 / π ^ 2 * x ^ 2 - cos x) (Icc 0 (π / 2)) := by
    -- Compiles without this option, but somewhat slower.
    set_option tactic.skipAssignedInstances false in
    refine monotoneOn_of_hasDerivWithinAt_nonneg
      (convex_Icc ..)
      (Continuous.continuousOn $ by fun_prop)
      (fun x _ ↦ (hderiv _).hasDerivWithinAt)
      fun x hx ↦ sub_nonneg.2 ?_
    have ⟨hx₀, hx⟩ := interior_subset hx
    calc 2 / π ^ 2 * 2 * x
        = 2 / π * (2 / π * x) := by ring
      _ ≤ 1 * sin x := by
          gcongr; exacts [div_le_one_of_le two_le_pi (by positivity), two_div_pi_mul_le_sin hx₀ hx]
      _ = sin x := one_mul _
state_before: x✝ x : ℝ
hx : x ≤ π
hx₀ : 0 ≤ x
hderiv : ∀ (x : ℝ), HasDerivAt (fun x => 1 - 2 / π ^ 2 * x ^ 2 - cos x) (sin x - 2 / π ^ 2 * 2 * x) x
hmono : MonotoneOn (fun x => 1 - 2 / π ^ 2 * x ^ 2 - cos x) (Icc 0 (π / 2))
hconc : ConcaveOn ℝ (Icc (π / 2) π) fun x => 1 - 2 / π ^ 2 * x ^ 2 - cos x
⊢ cos x ≤ 1 - 2 / π ^ 2 * x ^ 2
state_after: x✝ x : ℝ
hx : x ≤ π
hx₀ : 0 ≤ x
hderiv : ∀ (x : ℝ), HasDerivAt (fun x => 1 - 2 / π ^ 2 * x ^ 2 - cos x) (sin x - 2 / π ^ 2 * 2 * x) x
hmono : MonotoneOn (fun x => 1 - 2 / π ^ 2 * x ^ 2 - cos x) (Icc 0 (π / 2))
hconc : ConcaveOn ℝ (Icc (π / 2) π) fun x => 1 - 2 / π ^ 2 * x ^ 2 - cos x
⊢ 0 ≤ 1 - 2 / π ^ 2 * x ^ 2 - cos x
tactic: rw [← sub_nonneg]
state_before: x✝ x : ℝ
hx : x ≤ π
hx₀ : 0 ≤ x
hderiv : ∀ (x : ℝ), HasDerivAt (fun x => 1 - 2 / π ^ 2 * x ^ 2 - cos x) (sin x - 2 / π ^ 2 * 2 * x) x
hmono : MonotoneOn (fun x => 1 - 2 / π ^ 2 * x ^ 2 - cos x) (Icc 0 (π / 2))
hconc : ConcaveOn ℝ (Icc (π / 2) π) fun x => 1 - 2 / π ^ 2 * x ^ 2 - cos x
⊢ 0 ≤ 1 - 2 / π ^ 2 * x ^ 2 - cos x
state_after: case inl
x✝ x : ℝ
hx : x ≤ π
hx₀ : 0 ≤ x
hderiv : ∀ (x : ℝ), HasDerivAt (fun x => 1 - 2 / π ^ 2 * x ^ 2 - cos x) (sin x - 2 / π ^ 2 * 2 * x) x
hmono : MonotoneOn (fun x => 1 - 2 / π ^ 2 * x ^ 2 - cos x) (Icc 0 (π / 2))
hconc : ConcaveOn ℝ (Icc (π / 2) π) fun x => 1 - 2 / π ^ 2 * x ^ 2 - cos x
hx' : x ≤ π / 2
⊢ 0 ≤ 1 - 2 / π ^ 2 * x ^ 2 - cos x

case inr
x✝ x : ℝ
hx : x ≤ π
hx₀ : 0 ≤ x
hderiv : ∀ (x : ℝ), HasDerivAt (fun x => 1 - 2 / π ^ 2 * x ^ 2 - cos x) (sin x - 2 / π ^ 2 * 2 * x) x
hmono : MonotoneOn (fun x => 1 - 2 / π ^ 2 * x ^ 2 - cos x) (Icc 0 (π / 2))
hconc : ConcaveOn ℝ (Icc (π / 2) π) fun x => 1 - 2 / π ^ 2 * x ^ 2 - cos x
hx' : π / 2 ≤ x
⊢ 0 ≤ 1 - 2 / π ^ 2 * x ^ 2 - cos x
tactic: obtain hx' | hx' := le_total x (π / 2)