Repository: scipy/scipy

Issue:
problem with scipy.signal.butter with 1000+ points array
### Please describe the issue in detail here, and for bug reports fill in the fields below.

When I produce a filter from the butter function, it works all fine for up to 1000 points.
Then trouble starts to happen somehow... The problem shows very clearly starting at 8000 points onwards, 10000 has it real bad and it only get worst
the filter has higher transfer function values than 1, and furthermore has a rather chaotic behaviour. The signal is therefore not filtered properly.


### Reproducing code example:

<<A short code example that reproduces the problem. It should be self-contained, i.e., possible to run as-is via 'python myproblem.py'>>

Here's a simple enough function and code to play with the number of points in the input


```
import numpy as np
from numpy import sin
from scipy.signal import butter, freqz, lfilter
import matplotlib.pyplot as plt



def show_the_problem(point_number):
    #we will show the problem here
    # our "data"
    x = np.linspace(0, 2*np.pi, point_number)
    y = sin(x) + 0.3* sin(10*x)
    
    # sampling frequency would be 1/ sampling_time
    sampling_frequency = point_number/(2*np.pi)
    # hence the nyquist frequency
    nyq = sampling_frequency/2
    # desired cutoff frequency, in Hertz
    cutoff = 1
    # normalized for the function butter
    normalized_cutoff = cutoff/nyq

    b,a = butter(6, normalized_cutoff)
    w, h = freqz(b, a, point_number)
    #filtered data
    y_filtered = lfilter(b, a, y)
    
    
     
    # plotting part
    plt.close("all")
    plt.figure()
    thefigure = plt.gcf()
    thefigure.subplots_adjust(hspace=1)
    plt.subplot(3,1,1)
    plt.plot(x, y)
    plt.title("'data'")
    plt.subplot(3,1,2)
    plt.xlim(0, cutoff * 10)
    plt.plot(nyq * w /np.pi, np.abs(h))
    plt.title("filter response")
    plt.subplot(3,1,3)
    plt.plot(x, y_filtered)
    plt.title("filtered data")
    
    return None
```

### Error message:
as a matter of fact, if i try with a very large number of points, like 100000, then i get this error:
```
<<Full error message, if any (starting from line Traceback: ...)>>

show_the_problem(100000)
/opt/anaconda3/lib/python3.6/site-packages/scipy/signal/filter_design.py:444: RuntimeWarning: divide by zero encountered in true_divide
  npp_polyval(zm1, a, tensor=False))
/opt/anaconda3/lib/python3.6/site-packages/scipy/signal/filter_design.py:444: RuntimeWarning: invalid value encountered in true_divide
  npp_polyval(zm1, a, tensor=False))
```

### Scipy/Numpy/Python version information:
```
<<Output from 'import sys, scipy, numpy; print(scipy.__version__, numpy.__version__, sys.version_info)'>>
1.0.0 1.14.0 sys.version_info(major=3, minor=6, micro=4, releaselevel='final', serial=0)
```




Discussion:
If you look at your `b` coefficients you can spot the issue. This is a known problem for dealing with transfer functions, for example, https://www.mathworks.com/help/signal/ref/butter.html
Marking as a documentation problem since I think we need to document this better so that users are less surprised.

Resolving patch:
diff --git a/scipy/signal/filter_design.py b/scipy/signal/filter_design.py
--- a/scipy/signal/filter_design.py
+++ b/scipy/signal/filter_design.py
@@ -2842,6 +2842,12 @@ def butter(N, Wn, btype='low', analog=False, output='ba', fs=None):
 
     The ``'sos'`` output parameter was added in 0.16.0.
 
+    If the transfer function form ``[b, a]`` is requested, numerical
+    problems can occur since the conversion between roots and
+    the polynomial coefficients is a numerically sensitive operation,
+    even for N >= 4. It is recommended to work with the SOS
+    representation.
+
     Examples
     --------
     Design an analog filter and plot its frequency response, showing the


Test patch: