mathlib4 review helperopen PRs by @wwylele on leanprover-community/mathlib4

← queue

#46596 feat(Analysis/SpecialFunctions): modified Bessel function of the first kind

t-analysis CI success

+114 −4 · 1 file · 1 commit · head 82a1b9a · updated 9 days ago · Files changed on GitHub

PR description

Define besselI next to existing besselJ and provide similar APIs


#43070 has been inactive with stale code despite multiple pings on the Zulip thread, so this PR is my attempt.

I stopped before the derivative formula. The derivative formula could be derived using the besselI <-> besselJ conversion, but it turns out not shorter than just copying the proof from besselJ, because the conversion needs to handle a neighborhood for the derivative. I am not particularly happy about it, so I defer it to future PR for potentially better idea.

AI usage: one of the two conversion lemma besselI_eq_mul_besselJ_of_lt_arg was suggest by Claude during chat (I later realized this is also part of dlmf 10.27.E6). I originally wanted to add a π / 2 < x.arg version with more awkward coefficients in the formula. All code was entirely written by me.

Conversation on GitHub 2
github-actions[bot] · comment · 2026-11-26
PR summary 82a1b9a0d4
Import changes for modified files

No significant changes to the import graph

<details><summary>Import changes for all files</summary>

|Files|Import difference| |-|-|

</details>


<details><summary>

Declarations diff (regex)

</summary>

+ analyticAt_besselI + analyticAt_besselI_int + analyticOnNhd_besselI + analyticOnNhd_besselI_int + besselI + besselI_def + besselI_eq_mul_besselJ_of_arg_le + besselI_eq_mul_besselJ_of_lt_arg + besselI_int_eq_mul_besselJ + besselI_int_neg + besselI_neg_int + besselI_zero + even_besselI + odd_besselI + two_mul_self_mul_besselI <details> <summary>You can run this locally as follows</summary>

## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>

</details>

The doc-module for scripts/pr_summary/declarations_diff.sh in the undefined repository contains some details about this script.

</details>

<details><summary>

Declarations diff (Lean)

</summary>

✅ Lean-aware diff — post-build, computed from the Lean environment (commit 82a1b9a).

  • +15 new declarations
  • −0 removed declarations
+Complex.analyticAt_besselI
+Complex.analyticAt_besselI_int
+Complex.analyticOnNhd_besselI
+Complex.analyticOnNhd_besselI_int
+Complex.besselI
+Complex.besselI_def
+Complex.besselI_eq_mul_besselJ_of_arg_le
+Complex.besselI_eq_mul_besselJ_of_lt_arg
+Complex.besselI_int_eq_mul_besselJ
+Complex.besselI_int_neg
+Complex.besselI_neg_int
+Complex.besselI_zero
+Complex.even_besselI
+Complex.odd_besselI
+Complex.two_mul_self_mul_besselI

</details>


No changes to strong technical debt. No changes to weak technical debt.

Current commit 82a1b9a0d4 Reference commit 58ee1ad10f

This script lives in the undefined repository. To run it locally, from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.py pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).
github-actions[bot] · comment · 2026-11-26
Crossref diff

| Declaration | Reference | Comment | |---|---|---| | undefined | undefined | | | undefined | undefined | | | undefined | undefined | | | undefined | undefined | | | undefined | undefined | |

Mathlib/Analysis/SpecialFunctions/Bessel.lean +114 −4

This function is analytic for all `x` when `a` is an integer. (see `Complex.anal
32$J_a(0) = 0$ for all complex $a \ne 0$. For $a = 0$, we have $J_0(0) = 1$.
33(See `Complex.besselJ_zero`)
35## `Complex.besselI a x`: modified Bessel function of the first kind $I_a(x)$
37Similarly, we define $I_a(x)$ using
38$$
39I_a(x) = (x / 2)^a \frac{₀F₁(-; a + 1; (x/2)^2)} {Γ(a + 1)}
40$$
41Lemmas `Complex.besselI_eq_mul_besselJ_of_arg_le` and `Complex.besselI_eq_mul_besselJ_of_lt_arg`
42provide conversion between `Complex.besselI` and `Complex.besselJ` on two overlapping domains. For
43integer `a`, they unify into `Complex.besselI_int_eq_mul_besselJ`.
45## TODO
47* Bessel function of the second kind
$J_a(0) = 0$ for all complex $a \ne 0$. For $a = 0$, we have $J_0(0) = 1$.
53@[expose] public noncomputable section
55open Nat FormalMultilinearSeries
56open scoped Real
58namespace Complex
local notation "F₀₁(" a ")" => regularizedHGFun 0 {(a : ℂ)}
63@[pp_nodot, dlmf 10.2.E2]
64noncomputable def besselJ (a x : ℂ) := (x / 2) ^ a * F₀₁(a + 1) (- (x / 2) ^ 2)
def besselI newL66–68
66/-- Modified Bessel function of the first kind $I_a(x)$. -/
67@[pp_nodot, dlmf 10.25.E2]
68noncomputable def besselI (a x : ℂ) := (x / 2) ^ a * F₀₁(a + 1) ((x / 2) ^ 2)
70local notation "J" => besselJ
71local notation "I_" => besselI
73theorem besselJ_def : J = fun a x ↦ (x / 2) ^ a * F₀₁(a + 1) (- (x / 2) ^ 2) := rfl
theorem besselI_def newL75–75
−/-- `J a` is even or odd when $a$ is even or odd, respectively. -/
75theorem besselI_def : I_ = fun a x ↦ (x / 2) ^ a * F₀₁(a + 1) ((x / 2) ^ 2) := rfl
theorem besselI_eq_mul_besselJ_of_arg_le newL77–89
77@[dlmf 10.27.E6]
78theorem besselI_eq_mul_besselJ_of_arg_le (a : ℂ) {x : ℂ} (hx : x.arg ≤ π / 2) :
79 I_ a x = (-I) ^ a * J a (x * I) := calc
80 _ = (-I) ^ a * I ^ a * (x / 2) ^ a * F₀₁(a + 1) ((x / 2) ^ 2) := by
81 rw [← mul_cpow (by simp [Real.pi_pos, Real.pi_nonneg])]
82 simp [besselI]
83 _ = (-I) ^ a * ((x * I / 2) ^ a * F₀₁(a + 1) ((x / 2) ^ 2)) := by
84 rw [mul_div_right_comm, mul_cpow (by simp; grind [neg_pi_lt_arg])]
85 ring
86 _ = _ := by
87 congr
88 conv_rhs => rw [div_pow, mul_pow, I_sq]
89 ring
theorem besselI_eq_mul_besselJ_of_lt_arg newL91–103
91@[dlmf 10.27.E6]
92theorem besselI_eq_mul_besselJ_of_lt_arg (a : ℂ) {x : ℂ} (hx : -π / 2 < x.arg) :
93 I_ a x = I ^ a * J a (-x * I) := calc
94 _ = I ^ a * (-I) ^ a * (x / 2) ^ a * F₀₁(a + 1) ((x / 2) ^ 2) := by
95 rw [← mul_cpow (by simp [Real.pi_pos, Real.pi_nonneg])]
96 simp [besselI]
97 _ = I ^ a * ((x * (-I) / 2) ^ a * F₀₁(a + 1) ((x / 2) ^ 2)) := by
98 rw [mul_div_right_comm, mul_cpow (by simp; grind [arg_le_pi])]
99 ring
100 _ = _ := by
101 congrm _ * ($(by ring) ^ a * F₀₁(a + 1) ?_)
102 conv_rhs => rw [div_pow, mul_pow, I_sq]
103 ring
theorem besselJ_int_neg changedL105–107
105/-- `besselJ a` is even or odd when $a$ is even or odd, respectively. -/
106theorem besselJ_int_neg (a : ℤ) (x : ℂ) : J a (-x) = (-1) ^ a * J a x := by
107 simp [besselJ_def, ← mul_assoc, neg_div, ← mul_zpow]
theorem besselI_int_neg newL109–111
109/-- `besselI a` is even or odd when $a$ is even or odd, respectively. -/
110theorem besselI_int_neg (a : ℤ) (x : ℂ) : I_ a (-x) = (-1) ^ a * I_ a x := by
111 simp [besselI_def, ← mul_assoc, neg_div, ← mul_zpow]
theorem besselI_int_eq_mul_besselJ newL113–120
113theorem besselI_int_eq_mul_besselJ (a : ℤ) (x : ℂ) :
114 I_ a x = (-I) ^ a * J a (x * I) := by
115 by_cases! hx : x.arg ≤ π / 2
116 · simp [besselI_eq_mul_besselJ_of_arg_le a hx]
117 · have hx : -π / 2 < x.arg := by grind [Real.pi_pos]
118 rw [besselI_eq_mul_besselJ_of_lt_arg a hx, neg_mul, besselJ_int_neg, cpow_intCast]
119 conv_rhs => rw [neg_eq_neg_one_mul, mul_zpow]
120 ring
122theorem odd_besselJ {a : ℤ} (ha : Odd a) : Function.Odd (J a) := by
123 intro x
124 simp [besselJ_int_neg, ha.neg_zpow]
theorem odd_besselI newL126–128
126theorem odd_besselI {a : ℤ} (ha : Odd a) : Function.Odd (I_ a) := by
127 intro x
128 simp [besselI_int_neg, ha.neg_zpow]
130theorem even_besselJ {a : ℤ} (ha : Even a) : Function.Even (J a) := by
131 intro x
132 simp [besselJ_int_neg, ha.neg_zpow]
theorem even_besselI newL134–136
−/-- `J a` is analytic outside of the branch cut on the negative real axis. -/
134theorem even_besselI {a : ℤ} (ha : Even a) : Function.Even (I_ a) := by
135 intro x
136 simp [besselI_int_neg, ha.neg_zpow]
theorem analyticAt_besselJ changedL138–141
138/-- `besselJ a` is analytic outside of the branch cut on the negative real axis. -/
139@[fun_prop]
140theorem analyticAt_besselJ (a : ℂ) {x : ℂ} (h : x ∈ slitPlane) : AnalyticAt ℂ (J a) x := by
141 fun_prop (disch := simpa [slitPlane] using h) [besselJ]
theorem analyticAt_besselI newL143–146
143/-- `besselI a` is analytic outside of the branch cut on the negative real axis. -/
144@[fun_prop]
145theorem analyticAt_besselI (a : ℂ) {x : ℂ} (h : x ∈ slitPlane) : AnalyticAt ℂ (I_ a) x := by
146 fun_prop (disch := simpa [slitPlane] using h) [besselI]
148@[fun_prop]
149theorem analyticOnNhd_besselJ (a : ℂ) : AnalyticOnNhd ℂ (J a) slitPlane :=
150 fun _ hz ↦ analyticAt_besselJ a hz
theorem analyticOnNhd_besselI newL152–154
−/-- For integer `a`, `J a` and `J (-a)` are related by a sign. -/
152@[fun_prop]
153theorem analyticOnNhd_besselI (a : ℂ) : AnalyticOnNhd ℂ (I_ a) slitPlane :=
154 fun _ hz ↦ analyticAt_besselI a hz
theorem besselJ_neg_int changedL156–159
156/-- For integer `a`, `besselJ a` and `besselJ (-a)` are related by a sign. -/
157@[dlmf 10.4.E1]
158theorem besselJ_neg_int (a : ℤ) (x : ℂ) : J (-a) x = (-1) ^ a * J a x := by
159 wlog! ha : 0 ≤ a
theorem besselJ_neg_int (a : ℤ) (x : ℂ) : J (-a) x = (-1) ^ a * J a x := by
171 rw [regularizedHGFun_zero_singleton_neg_nat_add_one, neg_pow, h, zpow_natCast]
172 ring
theorem besselI_neg_int newL174–179
174/-- For integer `a`, `besselI a` and `besselI (-a)` are equal. -/
175@[dlmf 10.27.E1]
176theorem besselI_neg_int (a : ℤ) (x : ℂ) : I_ (-a) x = I_ a x := by
177 rw [← Int.cast_neg, besselI_int_eq_mul_besselJ, besselI_int_eq_mul_besselJ, Int.cast_neg,
178 besselJ_neg_int, zpow_neg, ← inv_zpow, inv_neg, inv_I, neg_neg, ← mul_assoc, ← mul_zpow,
179 mul_neg_one]
181theorem besselJ_neg_comm (a : ℤ) (x : ℂ) : J (-a) x = J a (-x) := by
182 rw [besselJ_neg_int, ← besselJ_int_neg]
theorem analyticAt_besselJ_int changedL184–187
−/-- `J a` is analytic for integer `a`. -/
184/-- `besselJ a` is analytic for integer `a`. -/
185@[fun_prop]
186theorem analyticAt_besselJ_int (a : ℤ) (x : ℂ) : AnalyticAt ℂ (J a) x := by
187 wlog! ha : 0 ≤ a
theorem analyticAt_besselJ_int (a : ℤ) (x : ℂ) : AnalyticAt ℂ (J a) x := b
193 have : AnalyticAt ℂ (fun x ↦ (x / 2) ^ a * F₀₁(a + 1) (- (x / 2) ^ 2)) x := by fun_prop
194 simpa [besselJ_def]
theorem analyticAt_besselI_int newL196–201
196/-- `besselI a` is analytic for integer `a`. -/
197@[fun_prop]
198theorem analyticAt_besselI_int (a : ℤ) (x : ℂ) : AnalyticAt ℂ (I_ a) x := by
199 suffices AnalyticAt ℂ (I_ a ·) x by simpa
200 simp_rw [besselI_int_eq_mul_besselJ]
201 fun_prop
203@[fun_prop]
204theorem analyticOnNhd_besselJ_int (a : ℤ) : AnalyticOnNhd ℂ (J a) .univ :=
205 fun z _ ↦ analyticAt_besselJ_int a z
theorem analyticOnNhd_besselI_int newL207–209
207@[fun_prop]
208theorem analyticOnNhd_besselI_int (a : ℤ) : AnalyticOnNhd ℂ (I_ a) .univ :=
209 fun z _ ↦ analyticAt_besselI_int a z
211theorem besselJ_zero (a : ℂ) : J a 0 = if a = 0 then 1 else 0 := by
212 split_ifs with h <;> simp [besselJ, h, regularizedHGFunCoeff]
theorem besselI_zero newL214–215
214theorem besselI_zero (a : ℂ) : I_ a 0 = if a = 0 then 1 else 0 := by
215 split_ifs with h <;> simp [besselI, h, regularizedHGFunCoeff]
217@[dlmf 10.6.E1]
218theorem two_mul_self_mul_besselJ (a : ℂ) (x : ℂ) :
219 2 * a * J a x = x * J (a - 1) x + x * J (a + 1) x := by
theorem two_mul_self_mul_besselJ (a : ℂ) (x : ℂ) :
233 _ = _ := by
234 grind [cpow_one]
theorem two_mul_self_mul_besselI newL236–247
236@[dlmf 10.29.E1]
237theorem two_mul_self_mul_besselI (a : ℂ) (x : ℂ) :
238 2 * a * I_ a x = x * I_ (a - 1) x - x * I_ (a + 1) x := by
239 by_cases! hx : x.arg ≤ π / 2
240 · have hI : -I ≠ 0 := neg_ne_zero.mpr I_ne_zero
241 simp_rw [besselI_eq_mul_besselJ_of_arg_le _ hx, cpow_add _ _ hI, cpow_sub _ _ hI, cpow_one,
242 div_neg, div_I]
243 linear_combination (-I) ^ a * two_mul_self_mul_besselJ a (x * I)
244 · have hx : -π / 2 < x.arg := by grind [Real.pi_pos]
245 simp_rw [besselI_eq_mul_besselJ_of_lt_arg _ hx, cpow_add _ _ I_ne_zero, cpow_sub _ _ I_ne_zero,
246 cpow_one, div_I]
247 linear_combination I ^ a * two_mul_self_mul_besselJ a (-x * I)
249@[dlmf 10.6.E2]
250theorem mul_deriv_besselJ_eq_besselJ_add_one (a : ℂ) {x : ℂ} (h : x ∈ slitPlane) :
251 x * deriv (J a) x = a * J a x - x * J (a + 1) x := by
0/19 declarations checked

Your review, as Markdown

Paste it as a comment or a review on the PR. Line links to the head commit unfold into code snippets on GitHub.