# Question:definition of a matrix by using a function (i,j)->f(i,j)

## Question:definition of a matrix by using a function (i,j)->f(i,j)

Maple

Hi,

In the code below I do not understand why f(3,1) cannot be computed : it returns the conjugate of D1[2,2] although I have defined it as a random number. Maybe you understand this ? Actually I first got an error message of the type "bad index into matrix". Thus I wrote ''D1''[t, t] instead of D1[t, t] to fix the issue in the product.

with(LinearAlgebra);
D1 := evalf(RandomMatrix(3));
f := (i, j) -> if i = j then D1[i, i]; elif i = j + 1 then (1 - abs(D1[i, i])^2)^(1/2)*(1 - abs(D1[j, j])^2)^(1/2); elif j + 1 < i then (1 - abs(D1[i, i])^2)^(1/2)*(1 - abs(D1[j, j])^2)^(1/2)*product(-conjugate(''D1''[t, t]), t = j + 1 .. i - 1); else 0; end if;
f(1, 1);
f(1, 2), f(1, 3);
f(2, 2);
f(2, 3);
f(3, 3);
f(2, 1);
f(3, 2);
f(3, 1);
Modu := evalf(Matrix(3, (i, j) -> f(i, j)));

f(3,1) is given by 3222.984487*conjugate(D1[2, 2]): I do not get why the value of D1[2,2] is ignored.

﻿