If I understand the problem correctly, there is simple math. The condition consists of two equations in which there are only two unknowns: y[i] and z[i] .
y[i] = y[i-1]*d1 +x[i]*d2 + z[i]*d3 z[i] = z[i-1]*d4 + y[i]*d5
And such things are solved very easily, by substituting the expression from the first equation into the second.
Watch your hands:
- Instead of
y[i] , we substitute its value into the second equation:
z[i] = z[i-1]*d4 + d5*(y[i-1]*d1 +x[i]*d2 + z[i]*d3)
- We divide both sides of the equation by
d5 :
z[i]/d5 = z[i-1]*d4/d5 + y[i-1]*d1 +x[i]*d2 + z[i]*d3
- Transferring
z[i]*d3 to the left:
z[i]/d5 - z[i]*d3 = z[i-1]*d4/d5 + y[i-1]*d1 +x[i]*d2
- Multiply back by
d5 :
z[i] - z[i]*d3*d5 = z[i-1]*d4 + (y[i-1]*d1 +x[i]*d2)*d5
- In the left part we put
z[i] for the brackets:
z[i]*(1 - d3*d5) = z[i-1]*d4 + (y[i-1]*d1 +x[i]*d2)*d5
- We divide both parts by
(1 - d3*d5) :
z[i] = (z[i-1]*d4 + (y[i-1]*d1 +x[i]*d2)*d5) / (1 - d3*d5)
And now we know how to calculate z[i] , which does not depend on y[i] .
Therefore, the solution is:
// ΠΈΠ½ΠΈΡΠΈΠ°Π»ΠΈΠ·Π°ΡΠΈΡ for i := 0 to n do begin x[i] := ??? end; y[0] := ??? z[0] := ??? // Π²ΡΡΠΈΡΠ»Π΅Π½ΠΈΠ΅ for i := 1 to n do begin z[i] := (z[i-1]*d4 + (y[i-1]*d1 +x[i]*d2)*d5) / (1 - d3*d5); y[i] := y[i-1]*d1 +x[i]*d2 + z[i]*d3; end;