[Tex/LaTex] Undefined control sequence error in latex when writing equations and using new command

errorsundefined

I have defined parameters using \newcommand and then I wrote some equations in my Latex document . But I got an error which is undefined control sequence :

\begin{document}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{verbatim}
\newcommand{\LC}{{\Gamma}_{\text{L}}}
\newcommand{\interest}{I}
\newcommand{\myr}{r} % the same for the time
\newcommand{\myy}{y}
\newcommand{\cost}{C}
 %\newcommand{\Pev}{{P}_{\text{EV},c,t}}
\newcommand{\rp}[1]{\cost_{\text{p},#1}} %rest to be payed
\newcommand{\ci}[1]{\cost_{\text{I},#1}}     %cost yearly interest
\newcommand{\rb}{\myr_{\text{B}}} %repayment for the bank
\newcommand{\ct}{\cost_{\text{T}}} 
\begin{equation}
\LC = \sum_{\myy=0}^{\lifetime}{\NPC-\rp{\myy}}+\ct
\label{A1}
\end{equation}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{equation}
\rb= \frac{\ct}{\lifetime} 
\label{A2}
\end{equation}
\end{document}

these are more equations with the same errors.

\begin{equation}
\rp{\myy}= 
    \begin{cases}
        \rp{\myy-1} - \rb & , \myy\in\myofbrace{0,\dots,\lifetime} \\
         \ct - \rb & , \myy=0
    \end{cases}
\label{A3} 
 \end{equation}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%it is illustrated by this equation:
\begin{equation}
 \ci{\myy}= 
    \begin{cases}
       \rp{\myy-1} \interest & , \myy\in\myofbrace{0,\dots,\lifetime} \\
       \ct \interest & , \myy=0
    \end{cases} 
\label{A4}
\end{equation}
% t = rest to be payed t-1 * interest rate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Where,
\begin{itemize}
\item $\LC$: Total net present cost.
\item $\myy$: The year index.
\item $\lifetime$: The lifetime of the project.
\item $\NPC$: The operating cost of year 0.
\item $\rp{\myy}$: The rest to be payed for the bank for year $\myy$.
\item $\rp{\myy-1}$: The rest to be payed for the bank for year $\myy-1$.
\item $\ct$:  The capital cost.
\item $\rb$: The repayment for the bank every year.
\item $\ci{\myy}$: The yearly cost interest.
\item $\interest$: The interest rate of the bank. 
\end{itemize}

Best Answer

The error message in the log does show which command is undefined (\lifetime and \NPC) After I had fixed the unrelated errors such as missing \documentclass and mis-placed \begin{document} the log file clearly shows the issue

! Undefined control sequence.
l.19 \LC = \sum_{\myy=0}^{\lifetime
                                   }{\NPC-\rp{\myy}}+\ct
?

I defined \lifetime and \NPC here so it runs without error but I do not know what definition you intended.

\documentclass{article}
\newcommand\lifetime{\mathrm{lifetime}}
\newcommand\NPC{\mathrm{NPC}}


\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{verbatim}
\newcommand{\LC}{{\Gamma}_{\text{L}}}
\newcommand{\interest}{I}
\newcommand{\myr}{r} % the same for the time
\newcommand{\myy}{y}
\newcommand{\cost}{C}
 %\newcommand{\Pev}{{P}_{\text{EV},c,t}}
\newcommand{\rp}[1]{\cost_{\text{p},#1}} %rest to be payed
\newcommand{\ci}[1]{\cost_{\text{I},#1}}     %cost yearly interest
\newcommand{\rb}{\myr_{\text{B}}} %repayment for the bank
\newcommand{\ct}{\cost_{\text{T}}} 
\begin{document}
\begin{equation}
\LC = \sum_{\myy=0}^{\lifetime}{\NPC-\rp{\myy}}+\ct
\label{A1}
\end{equation}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{equation}
\rb= \frac{\ct}{\lifetime} 
\label{A2}
\end{equation}
\end{document}