Skip to content

Conversation

@ChrisRackauckas-Claude
Copy link

Summary

  • Fixed documentation in initialization.md that incorrectly claimed a "well-conditioned" initialization system would produce a NonlinearSystem
  • The actual behavior is that a NonlinearLeastSquaresProblem is returned because the pendulum system is structurally singular (has unassigned variables)
  • Changed the solver example from TrustRegion() (which is for NonlinearProblem) to GaussNewton() (which works with NonlinearLeastSquaresProblem)

Details

Line 483 of the original documentation stated:

notice that we instead obtained a NonlinearSystem

However, running the code shows that InitializationProblem returns a NonlinearLeastSquaresProblem for this case because:

  1. The system is structurally singular (has unassigned variables like xˍtt(t))
  2. Per src/initialization.jl, only systems that are both fully determined AND structurally non-singular get NonlinearProblem/SCCNonlinearProblem

Test plan

  • Verified the code examples run correctly with the updated solver

Fixes #4024

🤖 Generated with Claude Code

@ChrisRackauckas-Claude
Copy link
Author

Updated PR Description

The PR has been updated with an actual code fix (not just documentation changes).

Changes

  1. src/initialization.jl: Modified get_initialization_problem_type to return NonlinearProblem for square initialization systems (neqs == nunknown) even if structurally singular. Only SCCNonlinearProblem now requires structural non-singularity.

  2. docs/src/tutorials/initialization.md: Fixed typo "NonlinearSystem" → "NonlinearProblem"

Root Cause

The structural analysis performs bipartite graph matching without numerical substitution. With the pendulum constraint differentiated to -2xˍt*x - 2yˍt*y = 0, the structural analysis sees both xˍt and yˍt as variables. However, when y=0 is substituted numerically, the term -2yˍt*y vanishes, leaving xˍt uniquely determined.

Solution

For initialization systems, structural singularity is informational only. A square system may still be solvable even if structurally singular because numerical values can eliminate terms.

Testing

  • ODEProblem(pend, [x => 1, y => 0, g => 1], ...) now returns NonlinearProblem
  • ODE solves correctly with x=1, y=0, D(x)=0, D(y)=0, λ=0
  • Underdetermined systems still return NonlinearLeastSquaresProblem

Note: Please update the PR title to: fix: return NonlinearProblem for structurally singular but square initialization systems

The documentation example for a well-conditioned initialization system was
using `[x => 1, y => 0.0, g => 1]` which results in a structurally singular
system (returning NonlinearLeastSquaresProblem).

Changed to `[x => 1, D(x) => 0.0, g => 1]` with `guesses = [λ => 1, y => 0]`
which properly specifies the derivative and results in a well-conditioned
NonlinearProblem (actually SCCNonlinearProblem) as intended.

Also fixed "NonlinearSystem" -> "NonlinearProblem" which is the correct type.

Fixes SciML#4024

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ChrisRackauckas-Claude ChrisRackauckas-Claude force-pushed the fix-initialization-tutorial-docs branch from 43a5254 to 5a897cf Compare December 8, 2025 18:11
@ChrisRackauckas-Claude
Copy link
Author

PR Updated - Docs-only fix

After discussion, the fix has been simplified to a documentation-only change:

Change

Changed the initialization example from:

[x => 1, y => 0.0, g => 1], guesses ==> 1]

To:

[x => 1, D(x) => 0.0, g => 1], guesses ==> 1, y => 0]

Rationale

  • Specifying D(x) => 0 instead of y => 0 is the correct way to create a well-conditioned system
  • With x=1 on the unit circle, y is determined by the constraint x² + y² = 1
  • With D(x)=0 specified, the system is fully determined and returns SCCNonlinearProblem (the optimal case)
  • Also fixed "NonlinearSystem" → "NonlinearProblem" (the correct type name)

The code changes to src/initialization.jl have been reverted as they are not needed with this documentation fix.

@ChrisRackauckas ChrisRackauckas merged commit c3bd84a into SciML:master Dec 8, 2025
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error in initialization tutorial

2 participants