Skip to content

Math typo in residual norm calculation (2 * √f instead of √(2 * f)) #369

Description

@farhadrclass

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions