## 5 Reputation

1 years, 122 days

## 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[1] := 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[1] := 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[1] := Cf . (varepsilon[1]);

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[1] := 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[1](r);
ux[1] := (x, r) -> epsilon[1][1]*x + g[1](r);
ur[1] := r -> A[1]*r + B[1]*1/r;
varepsilon[1][1] := epsilon11c;
varepsilon[1][2] := r -> (A[1]*r + B[1]*1/r)*1/r;
varepsilon[1][3] := r -> diff(ur[1](r), r);
varepsilon[1][3](R[2]);

for i from 2 to N - 1 do
g[i](r);
ux[i] := (x, r) -> epsilon[i][1]*x + g[i](r);
ur[i] := r -> A[i]*r + B[i]*1/r;
varepsilon[i][1] := epsilon11c;
varepsilon[i][2] := r -> (A[i]*r + B[i]*1/r)*1/r;
varepsilon[i][3] := r -> diff(ur[i](r), r);
varepsilon[i][2](r); i;
end do;
i;
varepsilon[2][2](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][2](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.