Making calculations using counter
A combination of forloop
and calc
:
\documentclass[10pt,a4paper]{article}
\usepackage{amsmath}
\usepackage{calc}
\usepackage{forloop}
\begin{document}
\hsize=8cm
\newcounter{k}\newcounter{j}%
\begin{align}
%forloop[ step ]{ counter }{ initial value }{ condition }{ code }
\nonumber
\forloop{k}{1}{\value{k} < 11}{
\setcounter{j}{2*\value{k}-1}
\\ y_{\arabic{k}}&=A_{\arabic{k},\arabic{j}} x_{\arabic{j}}
\addtocounter{j}{1}
+A_{\arabic{k},\arabic{j}} x_{\arabic{j}}
}
\end{align}
\end{document}
Here another approach using l3int:
\documentclass{article}
\usepackage{amsmath}
\usepackage{xparse} %dt. Silbentrennung
\ExplSyntaxOn
\cs_generate_variant:Nn \int_set:Nn { Nx }
\NewDocumentCommand \Formula { O{1} O{1} m }
{
\int_step_inline:nnnn
{ #1 }%initial value
{ #2 }%step
{ #3 - #2 }%final value
{ \formula_func_aux:n { ##1 } \\ }%code
\formula_func_aux:n { #3 } %last line without \\
}
\cs_new:Npn \formula_func_aux:n #1
{
\int_gset:Nn \g_tmpa_int { #1 }
y \sb{ \int_use:N \g_tmpa_int } &=
\int_gset:Nn \g_tmpb_int { 2 * \g_tmpa_int -1 }
A \sb{ \int_use:N \g_tmpa_int , \int_use:N \g_tmpb_int }
x \sb{ \int_use:N \g_tmpb_int }
+
\int_gset:Nn \g_tmpb_int { 2 * \g_tmpa_int }
A \sb{ \int_use:N \g_tmpa_int , \int_use:N \g_tmpb_int }
x \sb{ \int_use:N \g_tmpb_int }
}
\ExplSyntaxOff
\begin{document}
\begin{align}
\Formula{2}
\end{align}
\begin{align}
\Formula[1][2]{6}
\end{align}
\end{document}
This also uses no counters but is perhaps a bit simpler than jfbu's but is the same idea.
\documentclass{article}
\usepackage{amsmath}
\newcommand\y[1]{%
y_{\the#1}&=A_{\the#1\,\the\numexpr2*#1-1\relax}
+A_{\the#1\,\the\numexpr2*#1\relax}
x_{\the\numexpr2*#1\relax}}
\def\lp#1#2#3{\ifnum#1=#3\relax\stoplp\fi#2{\numexpr#1\relax}\\\lp{\numexpr#1+1\relax}#2{#3}}
\def\stoplp#1\\#2#3#4#5{#1}
\begin{document}
\begin{align}
\lp1\y{10}
\end{align}
\end{document}