kill(all)$

maxima :programming , back substitution for list of elements,version 1.0
peter.vlasschaert@gmail.com,26/04/2020 

load packages
===========

load(lrats)$

iteration :
======

s1:p(n+1)=k*p(n)-R(n);

s1a:p(n+1)=k*p(i)-R(i);

s2:subst([n=n-1],s1);

s2a:p(i)=k*p(i-1)-R(i-1);

s3:subst([n=n-2],s1);

ss1:lhs(s1)=subst([s2],rhs(s1)),expand;

ss2:lhs(s1)=subst([s3],rhs(ss1)),expand;

qq(n,i,k):=p(n-i-1)*k-R(n-i-1);

qq(n,-1,k);

1e) step :prepare array
=================

kk:[0,0,0,0,0,0];

2e) list array with expression = s1
=========================

for i:1 thru length(kk) do(
kk[i]: p(n-i)=ev(qq(n,i,k),nouns)
);

3e) element of the list :1 to length(kk)
===========================

kk[3];

4e)  full list kk
==========

kk;

length(kk);

show difference between use : subst & psubst
==================================

 a)  use: substitution
===============
Maxima:'subst'

f1(i):=subst(kk,kk[i]);

f1(2);

lhs(kk[1])=rhs(f1(1)),expand;

lhs(kk[2])=rhs(f1(2)),expand;

b) use:psubstitution
==============
Maxima : 'psubst'

f2(i):=psubst(kk,kk[i]);

f2(1);

f2(2);

lhs(kk[1])=rhs(f2(1)),expand;