Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I'm not sure what you mean under "write", but if you question is about defining 2D array of functions P, you can proceed like this:

N = 5
t = var('t')
P =  Matrix(N,N, lambda i,j: function(f'P_{i}_{j}')(t) if i+j<=N else 0)
print(P)

which gives

[P_0_0(t) P_0_1(t) P_0_2(t) P_0_3(t) P_0_4(t)]
[P_1_0(t) P_1_1(t) P_1_2(t) P_1_3(t) P_1_4(t)]
[P_2_0(t) P_2_1(t) P_2_2(t) P_2_3(t)        0]
[P_3_0(t) P_3_1(t) P_3_2(t)        0        0]
[P_4_0(t) P_4_1(t)        0        0        0]

Then you can work with functions P[i,j] as you like, including defining differential equations over them.

I'm not sure what you mean under "write", but if you question is about defining 2D array of functions P, you can proceed like this:

N = 5
4
t = var('t')
P =  Matrix(N,N, Matrix(N+1,N+1, lambda i,j: function(f'P_{i}_{j}')(t) if i+j<=N else 0)
print(P)

which gives

[P_0_0(t) P_0_1(t) P_0_2(t) P_0_3(t) P_0_4(t)]
[P_1_0(t) P_1_1(t) P_1_2(t) P_1_3(t) P_1_4(t)]
       0]
[P_2_0(t) P_2_1(t) P_2_2(t) P_2_3(t)        0        0]
[P_3_0(t) P_3_1(t) P_3_2(t)        0        0        0]
[P_4_0(t) P_4_1(t)        0        0        0        0]

Then you can work with functions P[i,j] as you like, including defining differential equations over them.