Routine User Tutorials¶
Welcome to NLSQ! This tutorial series will guide you through curve fitting using NLSQ’s 3-Workflow System - a simple but powerful approach that handles everything from small datasets to 100M+ points automatically.
Note
Coming from SciPy? NLSQ is a drop-in replacement. Your existing code will work with minimal changes. See Migration Guide.
The 3-Workflow System¶
NLSQ provides three workflows that cover all curve fitting use cases:
Workflow |
When to Use |
Bounds |
Speed |
|---|---|---|---|
|
Standard fitting (default) |
Optional |
Fastest |
|
Multiple local minima, unknown initial guess |
Required |
Moderate |
|
HPC clusters, long-running jobs |
Required |
Varies |
Quick Start¶
Here’s all you need to fit data with NLSQ:
from nlsq import fit
import jax.numpy as jnp
# Define your model
def exponential(x, a, b, c):
return a * jnp.exp(-b * x) + c
# Fit with default workflow (auto)
popt, pcov = fit(exponential, xdata, ydata, p0=[1.0, 0.5, 0.0])
# For global optimization (requires bounds)
popt, pcov = fit(
exponential,
xdata,
ydata,
p0=[1.0, 0.5, 0.0],
workflow="auto_global",
bounds=([0, 0, -1], [10, 5, 1]),
)
That’s it! NLSQ automatically handles memory management, GPU acceleration, and optimization strategy selection.
Tutorial Series¶
Learning Path¶
# |
Chapter |
What You’ll Learn |
Time |
|---|---|---|---|
1 |
Install NLSQ, fit your first curve, interpret results |
20 min |
|
2 |
Master the 3-workflow system: auto, auto_global, hpc |
30 min |
|
3 |
Built-in models, custom models, model validation |
25 min |
|
4 |
Data input, uncertainties, bounds, large datasets |
25 min |
|
5 |
GPU setup, usage, multi-GPU |
20 min |
|
6 |
Desktop GUI application for interactive fitting |
15 min |
|
7 |
Common issues and solutions |
15 min |
Prerequisites¶
Python 3.12 or higher
Basic Python knowledge (variables, functions, imports)
Basic understanding of scientific data (x, y coordinates)
No prior curve fitting experience is required.
Next Steps After Tutorials¶
How-To Guides - Solve specific problems
Reference - API reference documentation
Advanced User Tutorials - Advanced API tutorials for custom workflows