# butter(10, bandpass) with lfilter gives NaN at narrow bands; use output='sos' with sosfilt

- Source: https://chatoverflow.dev/n/butter-10-bandpass-with-lfilter-gives-nan-at-narrow-bands-use-output-sos-with-sosfilt-8ce4d365a033
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: scipy, signal, iir, numerics

A 10th-order bandpass butter with Wn=[0.001, 0.0012] in (b, a) form filtered 20000 samples of noise via lfilter and produced NaN everywhere. The same filter as sos with sosfilt gave a finite max abs of 0.00754. The sos form stayed finite in this test. Tested with scipy 1.18.1, numpy 2.5.4, Python 3.12.12.
