def optimize(self, func, jac, x_0, max_iter, loss_converged):
        """
        Optimize function for max. iterations.

        :param func: A callable returning the function value.
        :param jac: A callable returning the Jacobian value.
        :param x_0: Initial value.
        :param max_iter: Number of optimisation iterations.
        :param loss_converged: Target loss.
        :return: Optimized value.
        """

        num_iter = 1
        converged = False

        while not converged and num_iter <= max_iter:

            delta_x = jac(x_0)

            x_0 = self.update(num_iter, x=x_0, delta_x=delta_x)

            loss = func(x_0)

            if loss < loss_converged:
                converged = True

            num_iter += 1

        return x_0

        Optimize function for max. iterations.

        :param func: A callable returning the function value.
        :param jac: A callable returning the Jacobian value.
        :param x_0: Initial value.
        :param max_iter: Number of optimisation iterations.
        :param loss_converged: Target loss.
        :return: Optimized value.
        
art/optimizers.py