Tutorials¶
Learn curve fitting with NLSQ through comprehensive, hands-on tutorials organized for two types of users:
Routine Users: Use the 3-workflow system (auto, auto_global, hpc) via
fit()Advanced Users: Design custom workflows using NLSQ’s API layer
Note
Coming from SciPy? Check out Migration Guide for a quick migration guide.
Choose Your Path¶
Learn the 3-workflow system for standard curve fitting tasks. Covers fit(), GUI, GPU acceleration, and troubleshooting.
~2.5 hours | Beginner-friendly
Design custom optimization pipelines using NLSQ’s API layer. Covers architecture, protocols, orchestration components.
~5 hours | Requires Python experience
Tutorial Sections¶
User-Focused Tutorials
Additional Tutorials
The 3-Workflow System¶
NLSQ’s core feature is the 3-workflow system that automatically handles memory management, optimization strategy, and GPU acceleration:
Workflow |
Description |
Bounds |
Use Case |
|---|---|---|---|
|
Memory-aware local optimization |
Optional |
Default - standard fitting |
|
Memory-aware global optimization |
Required |
Multiple minima, unknown guess |
|
Global + checkpointing |
Required |
Long HPC jobs |
Quick Example¶
from nlsq import fit
import jax.numpy as jnp
def model(x, a, b, c):
return a * jnp.exp(-b * x) + c
# Default workflow (auto)
popt, pcov = fit(model, x, y, p0=[1.0, 0.5, 0.0])
# Global optimization
popt, pcov = fit(
model,
x,
y,
p0=[1.0, 0.5, 0.0],
workflow="auto_global",
bounds=([0, 0, -1], [10, 5, 1]),
)
Prerequisites¶
Routine Tutorials:
Python 3.12 or higher
Basic Python knowledge
No curve fitting experience required
Advanced Tutorials:
Completed routine tutorials
Python classes and type hints
Basic optimization concepts
Next Steps¶
After completing the tutorials:
How-To Guides - Solve specific problems
Concepts & Explanations - Understand concepts in depth
Reference - API reference documentation