Computable Range Reduction for Trigonometric Functions #
This file implements range reduction for sin and cos to improve Taylor series convergence for intervals far from 0.
Problem #
Standard Taylor series for sin/cos centered at 0 have remainder bounds of
|x|^{n+1} / (n+1)!. For intervals far from 0 (e.g., [10, 11]), this remainder
is huge even for moderate n.
Solution: Range Reduction #
Use the periodicity of sin/cos:
sin(x) = sin(x - 2πk)for any integer kcos(x) = cos(x - 2πk)for any integer k
By choosing k to bring x - 2πk into [-π, π], the Taylor series converges much faster since |x - 2πk| ≤ π ≈ 3.14.
Main definitions #
twoPiRatLo,twoPiRatHi- Rational bounds for 2πreduceToMainPeriod- Shift interval to be near 0sinComputableReduced,cosComputableReduced- Computable evaluation with range reduction
Shared range-reduction API #
Instances For
Instances For
Instances For
Instances For
theorem
LeanCert.Core.IntervalRat.mem_shiftInterval_of_mem
{x : ℝ}
{I : IntervalRat}
{k : ℤ}
(hx : x ∈ I)
:
Computable reduced evaluation #
Computable sin evaluation with range reduction.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Computable cos evaluation with range reduction.
Equations
- One or more equations did not get rendered due to their size.
Instances For
theorem
LeanCert.Core.IntervalRat.mem_sinComputableReduced
{x : ℝ}
{I : IntervalRat}
(hx : x ∈ I)
(n : ℕ := 10)
:
sin x ∈ sinComputableReduced I for all x ∈ I
theorem
LeanCert.Core.IntervalRat.mem_cosComputableReduced
{x : ℝ}
{I : IntervalRat}
(hx : x ∈ I)
(n : ℕ := 10)
:
cos x ∈ cosComputableReduced I for all x ∈ I