SciPy — overview of submodules
WHAT is SciPy?
WHY submodules? Loading everything would be slow and memory-heavy. SciPy is deliberately
split so you pay only for the corner of mathematics you actually use. This is the 80/20 rule
baked into the design: 20% of submodules (stats, optimize, integrate, linalg,
interpolate) cover ~80% of real scientific work.
The map of submodules

HOW to remember the split: every submodule answers a verb — solve, optimize, integrate, interpolate, test, filter, transform.
WHY first principles? Two mini-derivations using SciPy
You don't have to trust SciPy — you can derive-from-scratch what each routine does and check it agrees.
1. scipy.integrate.quad — what is it really doing?
Derive a baseline (trapezoid rule) to understand what quad improves on:
Approximate area of one strip of width between points by a trapezoid:
Sum all strips:
quad is far smarter (adaptive, high order) but converges to the same true value.
2. scipy.optimize.minimize — what does "minimize" mean?
Derive the optimum by hand to predict the answer:
3. scipy.linalg.solve — solving
Common mistakes
Flashcards
What is SciPy built on top of?
Why is SciPy split into submodules?
Which submodule solves and does decompositions?
scipy.linalg.Which submodule minimizes functions and finds roots / curve fits?
scipy.optimize.Which submodule does numerical integration and ODE solving?
scipy.integrate.Which submodule has probability distributions and statistical tests?
scipy.stats.Which submodule handles huge mostly-zero matrices?
scipy.sparse.Which submodule has Fourier transforms?
scipy.fft.What two values does integrate.quad return?
(value, abserr).Why prefer scipy.linalg over numpy.linalg?
In modern SciPy, does import scipy; scipy.stats work without explicitly importing the submodule?
__getattr__; explicit import is still good style though.What does optimize.minimize need besides the function?
x0 (it descends from there).Which submodule has interpolation routines?
scipy.interpolate.Which submodule has special functions like Bessel and gamma?
scipy.special.Which submodule gives physical constants like and ?
scipy.constants.Recall Feynman: explain to a 12-year-old
NumPy is like a giant box of LEGO bricks (numbers). SciPy is the instruction-booklet folder:
one booklet teaches you to build a bridge (linear algebra), another a roller-coaster (optimization),
another a measuring-area machine (integration). You don't dump out every booklet at once — you
grab just the one for what you're building today. That's why you write
"give me the statistics booklet" → from scipy import stats.
Concept Map
Hinglish (regional understanding)
Intuition Hinglish mein samjho
Dekho, NumPy tumhe deta hai fast arrays — yaani numbers ka dabba. Lekin un numbers par actual
kaam karne ke liye — jaise integration, equation solve karna, optimization, statistics — uske
liye aata hai SciPy. SciPy NumPy ke upar bana hua hai, aur ye chhote-chhote submodules mein
divided hai. Har submodule ek alag mathematics ka kaam karta hai: linalg matrix solve karta hai,
optimize function ka minimum dhoondta hai, integrate area/ODE nikalta hai, stats mein
probability distributions hain, sparse se bade khaali-khaali matrices handle hote hain.
Ek important point: modern SciPy (1.8 ke baad) mein submodules lazily load hote hain, isliye
import scipy; scipy.stats.norm ab bina explicit import ke bhi chal jaata hai. Phir bhi achhi style
yahi hai ki tum explicitly from scipy import optimize, stats likho — clear rehta hai aur purani
versions par bhi safe hai. 80/20 rule yaad rakho: paanch submodules
(stats, optimize, integrate, linalg, interpolate) hi 80% kaam cover kar dete hain.
Sabse achhi cheez — tumhe SciPy par "andhe bharose" nahi karna. Jaise note mein dikhaya, pehle
haath se derive karo (jaise ka minimum par), phir SciPy se verify karo. Isko bolte
hain Forecast-then-Verify: pehle answer predict, phir check. Aur dhyaan rakho quad do cheezein
deta hai — value aur error bound — dono ko unpack karo. Yehi habit tumhe ek strong scientific
programmer banayegi.