'Check if `x` yields the objective value close enough to
the optimal value.
Parameters
x : ndarray, shape (n,)
The point to test.
ftol : float
Maximum allowed relative error in the objective function value.
Returns
bool
Whether `x` is optimal enough. If `x` violates bounds constraints
then False is returned.'

def check_answer(self, x, ftol):

    if (((self.lb is not None) and np.any((x < self.lb))) or ((self.ub is not None) and np.any((x > self.ub)))):
        return False
    f = np.sum((self.fun(x) ** 2))
    return (f < ((1 + ftol) * self.fopt))
