def get_mu(x, knots, mu=None):
    """
    Find the knot interval index (mu) for a given value x
    This is a prerequisite for alg 2.20 and 2.21.
    Optional to supply a suggestion to try first.
    Throws on error.
    """
    if mu != None:
        if x >= knots[mu] and x < knots[mu+1]:
            return mu
    for mu in range(0, len(knots)-1):
        if x >= knots[mu] and x < knots[mu+1]:
            return mu
    raise RuntimeError("Illegal knot vector or x value")