100 Exercises / linear algebra / Linear algebra 100 Exercises
Identifying Manufacturing Process Stability by Eigenvalues | Learning Linear Algebra with Python No.051–060
Check equipment-network stability with eigenvalue bounds, condition numbers, power iteration, Lanczos and QR methods, and transient responses.
A process model can be stable in the long term while amplifying a disturbance temporarily. Using a fictional four-machine network, we check positive semidefiniteness, eigenvalue bounds, condition numbers and time responses. We also compare numerical methods for computing eigenvalues.
About this article This article adapts Jupyter Notebooks used in corporate training by Surikobo or its representative, Hiroshi Wayama, with permission from the participating companies.
All data listed is fictional and has no relation whatsoever to real companies, factories, or figures.
Introduction: Practical Challenges in Manufacturing Covered in This Article
Consider the line where load deviations from cutting, cleaning, heat treatment, and inspection carry over to the next shift. With state and propagation matrix , the update is .
Common situations on site
- There are process-specific KPIs, but the ripple effects between processes are not being evaluated.
- There are simulation results, but sensitivity to parameter errors is unknown.
- Slow eigenvalue calculations on large-scale equipment data
Why is this issue so difficult to judge?
Stability is determined by the inherent structure of the entire matrix. In asymmetric matrices, even long-term stability can have short-term amplification, and measurement errors and rounding errors also affect judgment.
Exercises in this article
Structural eigenvalues are evaluated in No.051 to 054, and numerical reliability is checked in No.055. Compare calculation methods in No.056–058, and integrate them into time response and stability judgment in No.059–060.
Preparing the Python environment
We use NumPy, pandas, Matplotlib, and SciPy. Fix the random number seed and separate the rounding of display and internal calculations.
Setup code: Preparing the Python environment (click to expand)
import sys, numpy as np, pandas as pd, matplotlib, matplotlib.pyplot as plt
from scipy.linalg import expm
from scipy.sparse import diags
from scipy.sparse.linalg import eigsh
from IPython.display import display
rng = np.random.default_rng(51060)
np.set_printoptions(precision=4, suppress=True)
plt.rcParams.update({"figure.figsize": (7.2, 4.2), "axes.grid": True})
print(
"Python",
sys.version.split()[0],
"NumPy",
np.__version__,
"pandas",
pd.__version__,
"Matplotlib",
matplotlib.__version__,
)
Python 3.14.4 NumPy 2.5.1 pandas 3.0.3 Matplotlib 3.11.0
Creation of Fictional Data
The nonnegative matrix describes how deviations in four machines propagate to the next shift. We generate 120 shifts. Diagonal components carry over themselves, while non-diagonal components carry over between processes. In practice, the estimated period and model version are recorded.
Setup code: Creation of Fictional Data (click to expand)
equipment = ["Cutting", "Washing", "HeatTreat", "Inspection"]
A = np.array(
[
[0.56, 0.10, 0.03, 0.02],
[0.08, 0.50, 0.11, 0.03],
[0.04, 0.09, 0.61, 0.10],
[0.03, 0.04, 0.12, 0.48],
]
)
states = np.zeros((120, 4))
states[0] = [1.2, -0.5, 0.8, 0.3]
for t in range(1, 120):
states[t] = A @ states[t - 1] + rng.normal(0, 0.12, 4)
display(pd.DataFrame(A, index=equipment, columns=equipment).round(2))
plt.plot(states[:40])
plt.title("Standardized equipment deviations")
plt.xlabel("Shift")
plt.ylabel("Standardized deviation")
plt.legend(equipment, ncol=2)
plt.grid(True)
plt.tight_layout()
plt.show()
| Cutting | Washing | HeatTreat | Inspection | |
|---|---|---|---|---|
| Cutting | 0.56 | 0.10 | 0.03 | 0.02 |
| Washing | 0.08 | 0.50 | 0.11 | 0.03 |
| HeatTreat | 0.04 | 0.09 | 0.61 | 0.10 |
| Inspection | 0.03 | 0.04 | 0.12 | 0.48 |

No.051: Positive Semidefinite Matrix
Meaning in Practice
It serves as the foundation to prevent unbalanced losses between processes and covariance matrices from returning negative evaluations. However, if there is a zero eigenvalue, there will be deviation directions that are not evaluated.
Approach to Analysis and Modeling
A symmetric matrix satisfies for any if all eigenvalues are non-negative. We use Laplacian to penalize process discrepancies.
Check with Python
W = np.array([[0, 1, 0.2, 0], [1, 0, 0.7, 0.1], [0.2, 0.7, 0, 0.9], [0, 0.1, 0.9, 0]])
L = np.diag(W.sum(1)) - W
ev = np.linalg.eigvalsh(L)
loss = np.einsum("ij,jk,ik->i", states, L, states)
display(pd.DataFrame({"eigenvalue": ev}).round(6))
print("minimum loss", loss.min())
plt.hist(loss, bins=18)
plt.title("Cross-equipment imbalance loss")
plt.xlabel(r"$x^T L x$")
plt.ylabel("Shifts")
plt.grid(True)
plt.tight_layout()
plt.show()
| eigenvalue | |
|---|---|
| 0 | -0.000000 |
| 1 | 0.725724 |
| 2 | 2.206091 |
| 3 | 2.868186 |
minimum loss 0.005229475856508912

Reading the results
The eigenvalues are nonnegative within rounding error, and the computed losses are nonnegative. A uniform shift of all machines lies in the zero-eigenvalue mode. Monitor the overall shift separately from differences between machines.
No.052: Rayleigh Quotient
Meaning in Practice
The Rayleigh quotient measures how much of a one-step update remains along the original direction. It is distinct from the updated vector length or the long-term decay rate.
Approach to Analysis and Modeling
For real nonzero and , we have . Thus lies between the smallest and largest eigenvalues of . It is the coefficient of the projection of onto , not .
Check with Python
S = (A + A.T) / 2
X = rng.normal(size=(2000, 4))
X /= np.linalg.norm(X, axis=1, keepdims=True)
rq = np.einsum("ij,jk,ik->i", X, S, X)
sev = np.linalg.eigvalsh(S)
print("sample", rq.min(), rq.max(), "theory", sev[0], sev[-1])
plt.hist(rq, bins=30)
plt.axvline(sev[-1], color="red", ls="--")
plt.title("Rayleigh quotients")
plt.xlabel("Rayleigh quotient")
plt.ylabel("Count")
plt.grid(True)
plt.tight_layout()
plt.show()
sample 0.4034253637601614 0.7513199375074551 theory 0.3994312035852489 0.7546030144172374

Reading the results
Sample values are within the theoretical range. You can focus on monitoring process combinations close to the maximum values, but the long-term stability of asymmetric is checked separately with eigenvalues.
No.053: Gershgorin’s Theorem
Meaning in Practice
High-speed screening that estimates eigenvalue ranges from only the coefficient table, suitable for routine monitoring during model updates.
Approach to Analysis and Modeling
All eigenvalues lie in the union of disks , where . If for every row, all disks lie strictly inside the unit circle and the discrete system is asymptotically stable.
Check with Python
c = np.diag(A)
r = np.sum(abs(A), 1) - abs(c)
g = pd.DataFrame({"center": c, "radius": r, "right": c + r}, index=equipment)
display(g.round(3))
th = np.linspace(0, 2 * np.pi, 300)
for name, ci, ri in zip(equipment, c, r):
plt.plot(ci + ri * np.cos(th), ri * np.sin(th), label=name)
e = np.linalg.eigvals(A)
plt.scatter(e.real, e.imag, c="black", marker="x")
plt.title("Gershgorin disks and eigenvalues")
plt.xlabel("Real part")
plt.ylabel("Imaginary part")
plt.gca().set_aspect("equal", adjustable="box")
plt.legend(loc="upper left", bbox_to_anchor=(1.02, 1.0))
plt.grid(True)
plt.tight_layout()
plt.show()
| center | radius | right | |
|---|---|---|---|
| Cutting | 0.56 | 0.15 | 0.71 |
| Washing | 0.50 | 0.22 | 0.72 |
| HeatTreat | 0.61 | 0.23 | 0.84 |
| Inspection | 0.48 | 0.19 | 0.67 |

Reading the results
Here all entries are nonnegative and each diagonal entry plus its disk radius is below 1. This puts every disk inside the unit circle. For a general matrix, checking only the rightmost point is insufficient. A disk extending outside the unit circle does not itself prove instability; compute the eigenvalues in that case.
No.054: Perron-Frobenius Theorem
Meaning in Practice
Using a non-negative process matrix, we indicate the magnitude of common fluctuations and equipment configuration that remain over the long term, and determine the survey priority.
Approach to Analysis and Modeling
In positive matrices, spectral radius is a positive simple eigenvalue, and the corresponding eigenvector has positive components. Normalize the sum to 1 and read the contribution.
Check with Python
vals, vecs = np.linalg.eig(A)
ii = np.argmax(abs(vals))
rho = vals[ii].real
v = abs(vecs[:, ii].real)
v /= v.sum()
pf = pd.DataFrame({"equipment": equipment, "share": v}).sort_values(
"share", ascending=False
)
display(pf.round(4))
print("spectral radius", rho)
plt.bar(pf.equipment, pf.share)
plt.title("Dominant propagation mode")
plt.xlabel("Equipment")
plt.ylabel("Normalized share")
plt.xticks(rotation=15)
plt.grid(True)
plt.tight_layout()
plt.show()
| equipment | share | |
|---|---|---|
| 2 | HeatTreat | 0.3509 |
| 1 | Washing | 0.2395 |
| 3 | Inspection | 0.2104 |
| 0 | Cutting | 0.1993 |
spectral radius 0.754099720331183

Reading the results
The dominant eigenvalue is less than 1, indicating that heat treatment contributes significantly. This is not a determined cause or effect, but rather a priority for sensor scrutiny and improvement experiments.
No.055: Matrix Condition Number
Meaning in Practice
It shows how many times a small error in measurement or coefficient can be amplified into the result of the backward calculation of causal contribution.
Approach to Analysis and Modeling
For an invertible matrix, the 2-norm condition number is . It bounds amplification of relative right-hand-side errors when the coefficient matrix is fixed. The example compares a well-conditioned matrix with one whose first two columns are nearly duplicates.
Check with Python
Mg = np.array([[1, 0.2, 0.1], [0.1, 1.1, 0.2], [0.2, 0.1, 0.9]])
Mb = np.array([[1, 1.001, 0.1], [0.5, 0.5004, 0.2], [0.2, 0.2003, 1]])
y = np.array([1, 0.7, 0.4])
d = np.array([1e-4, -1e-4, 1e-4])
rows = []
for name, M in [("well-conditioned", Mg), ("ill-conditioned", Mb)]:
z = np.linalg.solve(M, y)
zp = np.linalg.solve(M, y + d)
rows.append([name, np.linalg.cond(M), np.linalg.norm(zp - z) / np.linalg.norm(z)])
df = pd.DataFrame(
rows, columns=["case", "condition_number", "relative_solution_change"]
)
display(df.round(6))
plt.bar(df.case, df.condition_number)
plt.yscale("log")
plt.title("Condition numbers")
plt.xlabel("Case")
plt.ylabel("Condition number (log)")
plt.grid(True)
plt.tight_layout()
plt.show()
| case | condition_number | relative_solution_change | |
|---|---|---|---|
| 0 | well-conditioned | 1.664609 | 0.000185 |
| 1 | ill-conditioned | 22771.393274 | 0.000957 |

Reading the results
The ill-conditioned matrix makes the inverse estimate more sensitive. Consider additional information, combining redundant variables or regularization. The condition number describes worst-case sensitivity, not the actual error for every perturbation.
No.056: Power Method
Meaning in Practice
Only the maximum eigenvalues and control modes are updated at low cost in large-scale models, and stability margins are regularly monitored.
Approach to Analysis and Modeling
Iterate and estimate the eigenvalue with the Rayleigh quotient. Convergence requires a uniquely dominant eigenvalue in magnitude and an initial vector containing its mode. The convergence rate depends on the ratio of the next-largest magnitude to the dominant one.
Check with Python
v = np.ones(4) / 2
hist = []
for k in range(25):
w = A @ v
v = w / np.linalg.norm(w)
hist.append(float(v @ (A @ v) / (v @ v)))
df = pd.DataFrame(
{"iteration": range(1, 26), "estimate": hist, "error": abs(np.array(hist) - rho)}
)
display(df.iloc[[0, 1, 2, 4, 9, 24]].round(7))
plt.semilogy(df.iteration, df.error, marker="o")
plt.title("Power-method convergence")
plt.xlabel("Iteration")
plt.ylabel("Absolute error")
plt.grid(True)
plt.tight_layout()
plt.show()
| iteration | estimate | error | |
|---|---|---|---|
| 0 | 1 | 0.745741 | 8.359300e-03 |
| 1 | 2 | 0.750208 | 3.892100e-03 |
| 2 | 3 | 0.752186 | 1.913300e-03 |
| 4 | 5 | 0.753591 | 5.087000e-04 |
| 9 | 10 | 0.754081 | 1.890000e-05 |
| 24 | 25 | 0.754100 | 1.000000e-07 |

Reading the results
The estimate approaches the dominant eigenvalue. In production, use the eigenpair residual as a stopping criterion rather than relying only on a fixed iteration count.
No.057: Lanczos Method
Meaning in Practice
From the symmetric sparse matrix of many devices, only the edge eigenvalues are obtained with minimal memory, increasing the update frequency.
Approach to Analysis and Modeling
Lanczos iteration projects a symmetric matrix onto a Krylov subspace and produces a tridiagonal representation. We use eigsh to calculate three extreme eigenvalues of a sparse 400-machine model, then compare with its exact formula.
Check with Python
n = 400
LS = diags(
[0.12 * np.ones(n - 1), 0.62 * np.ones(n), 0.12 * np.ones(n - 1)],
[-1, 0, 1],
format="csr",
)
lv = eigsh(LS, k=3, which="LA", return_eigenvectors=False, v0=np.linspace(1.0, 2.0, n))[
::-1
]
exact = 0.62 + 0.24 * np.cos(np.arange(1, 4) * np.pi / (n + 1))
df = pd.DataFrame(
{"rank": [1, 2, 3], "Lanczos": lv, "exact": exact, "error": abs(lv - exact)}
)
display(df.round(10))
plt.plot(df["rank"], df.Lanczos, "o-", label="Lanczos")
plt.plot(df["rank"], df.exact, "x--", label="Exact")
plt.title("Largest sparse-matrix eigenvalues")
plt.xlabel("Rank")
plt.ylabel("Eigenvalue")
plt.legend()
plt.grid(True)
plt.tight_layout()
plt.show()
| rank | Lanczos | exact | error | |
|---|---|---|---|---|
| 0 | 1 | 0.859993 | 0.859993 | 0.0 |
| 1 | 2 | 0.859971 | 0.859971 | 0.0 |
| 2 | 3 | 0.859934 | 0.859934 | 0.0 |

Reading the results
It does not convert to dense matrices and matches the exact value. For the asymmetric matrix, select the Arnoldi method and record the allowable error, maximum iteration, and residual.
No.058: QR Method
Meaning in Practice
You can inventory all eigenvalues and use them as a standard to verify partial iterative methods.
Approach to Analysis and Modeling
Factor and set . Each step is a similarity transformation, preserving eigenvalues. The symmetric positive definite example has distinct eigenvalues, so this unshifted iteration approaches a diagonal matrix. General symmetric matrices, including some with equal-magnitude positive and negative eigenvalues, need not converge to diagonal form under this simple iteration.
Check with Python
Ak = S.copy()
off = []
for k in range(60):
Q, R = np.linalg.qr(Ak)
Ak = R @ Q
off.append(np.linalg.norm(Ak - np.diag(np.diag(Ak)), "fro"))
qv = np.sort(np.diag(Ak))[::-1]
tv = np.sort(np.linalg.eigvalsh(S))[::-1]
display(pd.DataFrame({"QR": qv, "library": tv, "error": abs(qv - tv)}).round(8))
plt.semilogy(range(1, 61), off)
plt.title("QR off-diagonal convergence")
plt.xlabel("Iteration")
plt.ylabel("Off-diagonal norm")
plt.grid(True)
plt.tight_layout()
plt.show()
| QR | library | error | |
|---|---|---|---|
| 0 | 0.754603 | 0.754603 | 0.000000 |
| 1 | 0.560052 | 0.560052 | 0.000000 |
| 2 | 0.435912 | 0.435914 | 0.000002 |
| 3 | 0.399433 | 0.399431 | 0.000002 |

Reading the results
Even in a no-shift educational implementation, the library results will match. In production, we use faster and verified eigvalsh to avoid proprietary implementations.
No.059: Matrix Function
Meaning in Practice
From the temperature, concentration, and vibration models for continuous time, the state after any time and the return time are calculated.
Approach to Analysis and Modeling
For a constant continuous-time model , the solution is . The matrix exponential is not the elementwise exponential.
Check with Python
F = np.array([[-0.45, 0.16, 0], [0.08, -0.34, 0.10], [0, 0.12, -0.28]])
x0 = np.array([2, 0.2, 1])
tt = np.linspace(0, 16, 65)
tr = np.array([expm(F * t) @ x0 for t in tt])
print("eigenvalues", np.linalg.eigvals(F))
display(
pd.DataFrame(
tr[[0, 16, 32, 64]],
index=tt[[0, 16, 32, 64]],
columns=["Zone A", "Zone B", "Zone C"],
).round(4)
)
plt.plot(tt, tr)
plt.title("Thermal deviation response")
plt.xlabel("Time (hours)")
plt.ylabel("Temperature deviation")
plt.legend(["Zone A", "Zone B", "Zone C"])
plt.grid(True)
plt.tight_layout()
plt.show()
eigenvalues [-0.5359+0.j -0.3573+0.j -0.1768+0.j]
| Zone A | Zone B | Zone C | |
|---|---|---|---|
| 0.0 | 2.0000 | 0.2000 | 1.0000 |
| 4.0 | 0.4321 | 0.3274 | 0.4242 |
| 8.0 | 0.1406 | 0.1839 | 0.2078 |
| 16.0 | 0.0275 | 0.0454 | 0.0518 |

Reading the results
Every eigenvalue has negative real part, so deviations decay without external input. Estimate the time to return to an acceptable band for maintenance planning, and separately assess external inputs, saturation and delays.
No.060: Matrix Stability
Meaning in Practice
Integrate asymptotic stability, short-term maximum amplification, and stability margin to determine the criteria for alerts and re-identification.
Approach to Analysis and Modeling
Discrete-time systems are asymptotic stable if . represents transient amplification in the worst direction. Set an internal threshold including estimated errors instead of boundary 1.
Check with Python
hh = np.arange(31)
gain = np.array([np.linalg.norm(np.linalg.matrix_power(A, int(k)), 2) for k in hh])
pi = int(np.argmax(gain))
display(
pd.DataFrame(
{
"metric": ["spectral radius", "margin", "peak gain", "peak shift"],
"value": [rho, 1 - rho, gain[pi], pi],
}
).round(4)
)
plt.plot(hh, gain, marker="o", ms=3)
plt.axhline(1, color="red", ls="--")
plt.title("Worst-case propagation gain")
plt.xlabel("Shifts ahead")
plt.ylabel(r"$\|A^k\|_2$")
plt.grid(True)
plt.tight_layout()
plt.show()
| metric | value | |
|---|---|---|
| 0 | spectral radius | 0.7541 |
| 1 | margin | 0.2459 |
| 2 | peak gain | 1.0000 |
| 3 | peak shift | 0.0000 |

Reading the results
The example is asymptotically stable and shows no substantial transient amplification. In practice, perturb the estimated coefficients within plausible uncertainty ranges. A threshold such as can be an organization-specific trigger to refit the model; it is not a universal stability boundary.
Using the results in practice
This model is stable, but “less than 1” is not the only conclusion. There is a common mode invisible to positive semidefinite loss, and in the dominant mode, the contribution of heat treatment is large, and the condition number showed that the inverse calculation of causal contribution can become unstable. Simple boundaries, control value updates, large-scale partial calculations, and overall audits are used according to different applications.
Preparing for practical use
- Time synchronization, missed measurement handling, standardization, and unification of product types and equipment conditions
- Testing prediction errors and residuals outside the learning period
- Record the condition number, eigenpair residuals, allowable errors, and library versions
- Aligning stability margins, transitional peaks, and return times with quality and maintenance standards
- Determine drift detection, relearning conditions, approvers, and rollbacks
Mathematical stability is not about safety or quality assurance itself. Combine FMEA, control charts, equipment knowledge, and experimental planning.
Conclusion
We compared row-sum eigenvalue bounds, power and Lanczos approximations, and QR iteration. Check the spectral radius for long-term stability and norms of matrix powers for short-term amplification. Examine conditioning when calculations are sensitive to input errors, and repeat these checks when the model changes.
Consultations for Corporations
At the Surikobo, we support everything from organizing equipment and quality data to process propagation models, anomaly sign monitoring, simulation, site explanations, and operational design.
📩 Contact Us: www.surikobo.co.jp/contact
Please contact us to discuss your project.