Example 4 Given a positive integer $n$ and a positive number $M$, for all arithmetic sequences $a_{1}, a_{2}$, $a_{3}, \cdots$ satisfying the condition $a_{1}^{2}+a_{n+1}^{2} \leqslant M$, try to find the maximum value of $S=a_{n+1}+a_{n+2}+\cdots+a_{2 n+1}$.
Solution: In the arithmetic sequence $\left\{a_{n}\right\}$, $a_{2 n+1}=a_{1}+2 n d=2\left(a_{1}+n d\right)-a_{1}=2 a_{n+1}-a_{1}$.
Since $S=a_{n+1}+a_{n+2}+\cdots+a_{2 n+1}=\frac{a_{n+1}+a_{2 n+1}}{2}(n+1)=\frac{\left(3 a_{n+1}-a_{1}\right)}{2}(n+1)$.
Also, $M \geqslant a_{1}^{2}+a_{n+1}^{2}=\frac{1}{10}\left(1+3^{2}\right)\left[\left(-a_{1}\right)^{2}+a_{n+1}^{2}\right] \geqslant \frac{1}{10}\left(3 a_{n+1}-a_{1}\right)^{2}$.
Therefore, $\sqrt{10 M} \geqslant 3 a_{n+1}-a_{1}$.
Thus, $S \leqslant \frac{n+1}{2} \sqrt{10 M}$.
Hence, $S_{\text {max }}=\frac{10}{2}(n+1) \sqrt{M}$, at this point $a_{1}=\frac{\sqrt{10 M}}{8}, a_{n+1}=\frac{3 \sqrt{10 M}}{8}$.
Comment: This problem combines inequalities and sequences well, with a certain level of skill in transformation.