NOTE: (Updated noting the sampling rate and desired frequency) Your post describes extracting a 40 Hz signal at a 100,000 Hz sampling rate. Your filtering implementation will be significantly easier (and more effective) if you apply course low pass filtering and decimation to a lower rate before applying the 2nd order tuned resonator derived from an exponential averager as shown in detail below. Please review this post Fast Integer 8 Hz 2nd Order LP for Microcontroller. I suggest decimating to a 200 Hz sampling rate which is a decimate by 500 (in stages such as 5-10-10).
Once decimated, consider using an exponential averager implementation, following this post for converting the lowpass filter to a bandpass, tunable to any frequency including your desired 40Hz:
Transfer function of second order notch filter
The difference between the notch filter in the post above and an exponential averager, is that the exponential averager has the following transfer function:
$$H(z) = \frac{\alpha z}{z+\alpha-1}$$
I think you will see the similarity and be able to follow the process in the linked post above. A diagram of the implementation as an "Exponential Averager" or low pass filter is shown below. This would create a maximum at DC and would need to be converted to a bandpass implementation similar to what was done in the linked post.
UPDATE: In pursuing the transformation myself I came up with the following result:
$$ H(z) = K\frac{z^2}{z^2-2\beta \cos\omega_n z+\beta^2} $$
Where:
(update, adding the closed-form equation for K)
K is a normalizing constant that is dependent on $\omega_n$ and $\alpha$ given as:
$$K= \alpha \sqrt{\beta^2-2\beta cos(2 \omega_n)+1}$$
$\omega_n$: center normalized radian frequency, between 0 and $2\pi$
$\alpha$: bandwidth constant, bandwidth gets tighter as $\alpha$ approaches 0.
$\beta = 1- \alpha$
The resulting implementation as a tuned 2nd order resonator is shown below.
Below are two examples with different bandwidths at center frequency $\omega_n=\pi/3$. The first plot is with $\alpha =0.1$ and the second plot is with $\alpha = 0.001$.
Note that the very long delay this second filter would have as evidenced by the very steep phase slope through the passband (group delay = $d\phi/d\omega$), as required for any tight bandwidth filter. This would also mean a relatively long convergence time. Given the ability to tune bandwidth and center frequency independently, you can envision how this can enable an optimized implementation for certain applications that is initially wide band for fast convergence while the bandwidth tightens over time to maximize SNR for the signal of interest. This structure can also be used as a bandpass loop filter or in a bandpass Sigma Delta implementation for bandpass sampling.
Below is an equivalent form of the exponential averager that only requires one multiplier as Rick Lyons has shown at the site linked below. Here I have chosen $\alpha$ to be similar to what Rick had done, in that $\alpha$ is a small number approaching 0 to make the bandwidth tighter (this is in contrast to my other post linked above for the notch filter implementation where I used $\alpha$ approaching 1 to be a tighter bandwidth, so swapping $\alpha$ with $1-\alpha$ between these two posts. I think the formula is cleaner if you actually use $\alpha$ as the number approaching 1, in that it eliminates my need to use $\beta$ as I have done above without the formulas appearing too cumbersome.
https://www.dsprelated.com/showarticle/182.php