Repository: scipy/scipy

Issue:
scipy.integrate.solve_ivp displays a runtime warning when integration error is zero
When running scipy.integrate.solve_ivp with time-dependent inputs, a runtime warning is displayed although the result is OK. 
This happens when the error in the ODE solver is zero and the error_norm is zero. When trying to calculate the next step-size, there is a division by zero. 
I would suggest to check for zero error before calculating next step size, in order to avoid the runtime warning. Line 143-149 could be changed to the following:
```
            if error_norm == 0.0:
                h_abs *= MAX_FACTOR
                step_accepted = True
            elif error_norm < 1:
                h_abs *= min(MAX_FACTOR,
                             max(1, SAFETY * error_norm ** (-1 / (order + 1))))
                step_accepted = True
            else:
                h_abs *= max(MIN_FACTOR,
                             SAFETY * error_norm ** (-1 / (order + 1)))
```
Example below based on MATLAB example: https://se.mathworks.com/help/matlab/ref/ode45.html#bu3l43b

The runtime error will occur at t ~ 8.2 s, when the derivative is zero.

### Reproducing code example:
```
from functools import partial

import matplotlib.pyplot as plt
import numpy as np
from scipy.integrate import solve_ivp


def calc_derivatives(t: float, y: np.ndarray, ft: np.ndarray, f: np.ndarray, 
                     gt: np.ndarray, g: np.ndarray) -> np.ndarray:
    fi = np.interp(t, ft, f)  # Interpolate the data set (ft,f) at time t
    gi = np.interp(t, gt, g)  # Interpolate the data set (gt,g) at time t
    dydt = -fi * y + gi  # Evaluate ODE at time t
    return dydt


def main():
    ft = np.linspace(0.0, 5.0, 25)
    f = ft ** 2.0 - ft - 3.0

    gt = np.linspace(1.0, 6.0, 25)
    g = 3.0 * np.sin(gt - 0.25)

    solution = solve_ivp(partial(calc_derivatives, ft=ft, f=f, gt=gt, g=g),
                         t_span=(1.0, 9.0), y0=[1.0], method='RK45', 
                         dense_output=True, max_step=0.1, rtol=1.0e-2, 
                         atol=1.0e-4)

    fig, ax = plt.subplots()
    ax.plot(solution.t, solution.y[0])
    ax.grid(True)
    ax.legend(loc='best', frameon=True)

    plt.show()


if __name__ == '__main__':
    main()
```

### Error message:
```
/scipy/integrate/_ivp/rk.py:145: RuntimeWarning: divide by zero encountered in double_scalars
  max(1, SAFETY * error_norm ** (-1 / (order + 1))))
```

### Scipy/Numpy/Python version information:
```
>>> import sys, scipy, numpy; 
>>> print(scipy.__version__, numpy.__version__, sys.version_info)
1.0.0 1.13.3 sys.version_info(major=3, minor=6, micro=3, releaselevel='final', serial=0)
```




Discussion:

Resolving patch:
diff --git a/scipy/integrate/_ivp/rk.py b/scipy/integrate/_ivp/rk.py
--- a/scipy/integrate/_ivp/rk.py
+++ b/scipy/integrate/_ivp/rk.py
@@ -140,7 +140,10 @@ def _step_impl(self):
             scale = atol + np.maximum(np.abs(y), np.abs(y_new)) * rtol
             error_norm = norm(error / scale)
 
-            if error_norm < 1:
+            if error_norm == 0.0:
+                h_abs *= MAX_FACTOR
+                step_accepted = True
+            elif error_norm < 1:
                 h_abs *= min(MAX_FACTOR,
                              max(1, SAFETY * error_norm ** (-1 / (order + 1))))
                 step_accepted = True


Test patch: