JuliaSmoothOptimizers / JuliaSmoothOptimizers/JSOSolvers.jl
Math typo in residual norm calculation (`2 * √f` instead of `√(2 * f)`)
- Dominant language
- Julia
- Stars
- 78
- Forks
- 18
- Avg merge
- 1h 30m
- Merged PRs (30d)
- 1
Description
**Description:**
In `trunkls.jl`, the residual norm is calculated using `2 * √f` to set and check the stopping tolerance `ϵF`.
Because the least-squares objective is $f = \frac{1}{2} \Vert{}F(x)\Vert{}^2$, the expression `2 * √f` mathematically evaluates to:
$$2 \sqrt{\frac{1}{2} \Vert{}F(x)\Vert{}^2} = \sqrt{2} \Vert{}F(x)\Vert{} \approx 1.414 \Vert{}F(x)\Vert{}$$
This unintentionally scales the residual norm by $\sqrt{2}$, making the stopping condition ~41% stricter than what is explicitly stated in the docstring (`‖F(xᵏ)‖ ≤ Fatol + Frtol * ‖F(x⁰)‖`).
**Proposed Fix:**
Change the 2 to be inside the square root: `√(2 * f)`.
Alternatively, since `rt` (the residual vector) is already evaluated and available in the loop, use `norm(rt)` directly to avoid the square root operation altogether.
Contributor guide
Research direction
Start in trunkls.jl and locate the loop where 2 * √f sets and checks ϵF; inspect the already-available rt residual there. Make the residual norm match the stopping-tolerance docstring, then run the repository's existing tests to verify the stopping behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100