You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: tn_doc.m
    path of file: ./repos/poblano_toolbox/docs
    
    the code of the file until where you have to start completion: %% Poblano Toolbox for MATLAB: Truncated Newton Optimization
% Truncated Newton (TN) methods for minimization are Newton methods in
% which the Newton direction is only approximated at each iteration (thus
% reducing computation). Furthermore, the Poblano implementation of the
%
    
function for the truncated Newton method is called |tn|.
%%
%
% <html><hr></html>
%% Introduction
%
% The general steps of the TN method in Poblano is given below in high-level
% pseudo-code [1]:
%%
%
%
% $$
%  \begin{tabular}{ll}
%  \emph{1.} & Input: $x_0$, a starting point\\
%  \emph{2.} & Evaluate $f_0 = f(x_0), g_0 = \nabla f(x_0)$\\
%  \emph{3.} & Set $i=0$\\
%  \emph{4.} & \textbf{while} $\|g_i\| > 0$\\
%  \emph{5.} & \qquad Compute the conjugate gradient stopping tolerance, $\eta_i$\\
%  \emph{6.} & \qquad Compute $p_i$ by solving $\nabla^2f(x_i)p = -g_i$ using a linear conjugate gradient (CG) method\\
%  \emph{7.} & \qquad Compute a step length $\alpha_i$ and set $x_{i+1} = x_i + \alpha_i p_i$\\
%  \emph{8.} & \qquad Set $g_i = \nabla f(x_{i+1})$\\
%  \emph{9.} & \qquad Set $i = i + 1$\\
%  \emph{10.} & \textbf{end