# Question:Difficulties with function definition

## Question:Difficulties with function definition

Maple 2019
```restart;
with(Physics);
with(LinearAlgebra);
N := 4;

Cf := Matrix(6, 6, (z, p) -> C[z, p, 1], shape = symmetric);
sigma := Vector(6, [sigma[1, 1, 1], sigma[2, 2, 1], sigma[3, 3, 1], sigma[1, 2, 1], sigma[1, 3, 1], sigma[2, 3, 1]]);
varepsilon := Vector(6, [varepsilon[1, 1, 1], varepsilon[2, 2, 1], varepsilon[3, 3, 1], gamma[1, 2, 1], gamma[1, 3, 1], gamma[2, 3, 1]]);
sigma := Cf . (varepsilon);

for i from 2 to N do
C[i] := Matrix(6, 6, (z, p) -> C[z, p, i], shape = symmetric);
sigma[i] := Vector(6, [sigma[1, 1, i], sigma[2, 2, i], sigma[3, 3, i], sigma[1, 2, i], sigma[1, 3, i], sigma[2, 3, i]]);
varepsilon[i] := Vector(6, [varepsilon[1, 1, i], varepsilon[2, 2, i], varepsilon[3, 3, i], gamma[1, 2, i], gamma[1, 3, i], gamma[2, 3, i]]);
sigma[i] := (C[i]) . (varepsilon[i]);
end do;

B := 0;

for i to N do
Parameters(epsilon11c, C[1, 1, i], C[1, 2, i], C[2, 2, i], C[2, 3, i], R[i], A[i], B[i + 1], P);
end do;

g(r);
ux := (x, r) -> epsilon*x + g(r);
ur := r -> A*r + B*1/r;
varepsilon := epsilon11c;
varepsilon := r -> (A*r + B*1/r)*1/r;
varepsilon := r -> diff(ur(r), r);
varepsilon(R);

for i from 2 to N - 1 do
g[i](r);
ux[i] := (x, r) -> epsilon[i]*x + g[i](r);
ur[i] := r -> A[i]*r + B[i]*1/r;
varepsilon[i] := epsilon11c;
varepsilon[i] := r -> (A[i]*r + B[i]*1/r)*1/r;
varepsilon[i] := r -> diff(ur[i](r), r);
varepsilon[i](r); i;
end do;
i;
varepsilon(r);```

Hi everyone,

I am currently writing a code on maple and I am finding difficulties in this section.

When I define the functions this way, the result I get from the loop "for" for varepsilon[i](r) is the same and doesnt depend on i value. I also tried to define it another way that would give me different results but I would end up with being unable to replace the variable "r" with its values (I would get r(R2)).

I would be grateful if you could advice me with this matter. 