Documentation

c Coefficient for Systems

c as Tensor, Matrix, and Vector

This topic describes how to write the coefficient c in equations such as

(cu)+au=f.

For 2-D systems, the coefficient c is an N-by-N-by-2-by-2 tensor with components c(i,j,k,l). N is the number of equations (see Systems of PDEs). For 3-D systems, c is an N-by-N-by-3-by-3 tensor.

For 2-D systems, the notation (cu) represents an N-by-1 matrix with an (i,1)-component

j=1N(xci,j,1,1x+xci,j,1,2y+yci,j,2,1x+yci,j,2,2y)uj.

For 3-D systems, the notation (cu) represents an N-by-1 matrix with an (i,1)-component

j=1N(xci,j,1,1x+xci,j,1,2y+xci,j,1,3z)uj+j=1N(yci,j,2,1x+yci,j,2,2y+yci,j,2,3z)uj+j=1N(zci,j,3,1x+zci,j,3,2y+zci,j,3,3z)uj.

All representations of the c coefficient begin with a "flattening" of the tensor to a matrix. For 2-D systems, the N-by-N-by-2-by-2 tensor flattens to a 2N-by-2N matrix, where the matrix is logically an N-by-N matrix of 2-by-2 blocks.

(c(1,1,1,1)c(1,1,1,2)c(1,2,1,1)c(1,2,1,2)c(1,N,1,1)c(1,N,1,2)c(1,1,2,1)c(1,1,2,2)c(1,2,2,1)c(1,2,2,2)c(1,N,2,1)c(1,N,2,2)c(2,1,1,1)c(2,1,1,2)c(2,2,1,1)c(2,2,1,2)c(2,N,1,1)c(2,N,1,2)c(2,1,2,1)c(2,1,2,2)c(2,2,2,1)c(2,2,2,2)c(2,N,2,1)c(2,N,2,2)c(N,1,1,1)c(N,1,1,2)c(N,2,1,1)c(N,2,1,2)c(N,N,1,1)c(N,N,1,2)c(N,1,2,1)c(N,1,2,2)c(N,2,2,1)c(N,2,2,2)c(N,N,2,1)c(N,N,2,2))

For 3-D systems, the N-by-N-by-3-by-3 tensor flattens to a 3N-by-3N matrix, where the matrix is logically an N-by-N matrix of 3-by-3 blocks.

(c(1,1,1,1)c(1,1,1,2)c(1,1,1,3)c(1,2,1,1)c(1,2,1,2)c(1,2,1,3)c(1,N,1,1)c(1,N,1,2)c(1,N,1,3)c(1,1,2,1)c(1,1,2,2)c(1,1,2,3)c(1,2,2,1)c(1,2,2,2)c(1,2,2,3)c(1,N,2,1)c(1,N,2,2)c(1,N,2,3)c(1,1,3,1)c(1,1,3,2)c(1,1,3,3)c(1,2,3,1)c(1,2,3,2)c(1,2,3,3)c(1,N,3,1)c(1,N,3,2)c(1,N,3,3)c(2,1,1,1)c(2,1,1,2)c(2,1,1,3)c(2,2,1,1)c(2,2,1,2)c(2,2,1,3)c(2,N,1,1)c(2,N,1,2)c(2,N,1,3)c(2,1,2,1)c(2,1,2,2)c(2,1,2,3)c(2,2,2,1)c(2,2,2,2)c(2,2,2,3)c(2,N,2,1)c(2,N,2,2)c(2,N,2,3)c(2,1,3,1)c(2,1,3,2)c(2,1,3,3)c(2,2,3,1)c(2,2,3,2)c(2,2,3,3)c(2,N,3,1)c(2,N,3,2)c(2,N,3,3)c(N,1,1,1)c(N,1,1,2)c(N,1,1,3)c(N,2,1,1)c(N,2,1,2)c(N,2,1,3)c(N,N,1,1)c(N,N,1,2)c(N,N,1,3)c(N,1,2,1)c(N,1,2,2)c(N,1,2,3)c(N,2,2,1)c(N,2,2,2)c(N,2,2,3)c(N,N,2,1)c(N,N,2,2)c(N,N,2,3)c(N,1,3,1)c(N,1,3,2)c(N,1,3,3)c(N,2,3,1)c(N,2,3,2)c(N,2,3,3)c(N,N,3,1)c(N,N,3,2)c(N,N,3,3))

These matrices further get flattened into vectors. First the N-by-N matrices of 2-by-2 and 3-by-3 blocks are transformed into "vectors" of 2-by-2 and 3-by-3 blocks. Then the blocks are turned into vectors in the usual column-wise way.

The coefficient vector c relates to the tensor c as follows. For 2-D systems,

(c(1)c(3)c(4N+1)c(4N+3)c(4N(N1)+1)c(4N(N1)+3)c(2)c(4)c(4N+2)c(4N+4)c(4N(N1)+2)c(4N(N1)+4)c(5)c(7)c(4N+5)c(4N+7)c(4N(N1)+5)c(4N(N1)+7)c(6)c(8)c(4N+6)c(4N+8)c(4N(N1)+6)c(4N(N1)+8)c(4N3)c(4N1)c(8N3)c(8N1)c(4N23)c(4N21)c(4N2)c(4N)c(8N2)c(8N)c(4N22)c(4N2)).

Coefficient c(i,j,k,l) is in row (4N(j–1) + 4i + 2l + k – 6) of the vector c.

For 3-D systems,

(c(1)c(4)c(7)c(9N+1)c(9N+4)c(9N+7)c(9N(N1)+1)c(9N(N1)+4)c(9N(N1)+7)c(2)c(5)c(8)c(9N+2)c(9N+5)c(9N+8)c(9N(N1)+2)c(9N(N1)+5)c(9N(N1)+8)c(3)c(6)c(9)c(9N+3)c(9N+6)c(9N+9)c(9N(N1)+3)c(9N(N1)+6)c(9N(N1)+9)c(10)c(13)c(16)c(9N+10)c(9N+13)c(9N+16)c(9N(N1)+10)c(9N(N1)+13)c(9N(N1)+16)c(11)c(14)c(17)c(9N+11)c(9N+14)c(9N+17)c(9N(N1)+11)c(9N(N1)+14)c(9N(N1)+17)c(12)c(15)c(18)c(9N+12)c(9N+15)c(9N+18)c(9N(N1)+12)c(9N(N1)+15)c(9N(N1)+18)c(9N8)c(9N5)c(9N2)c(18N8)c(18N5)c(18N2)c(9N28)c(9N25)c(9N22)c(9N7)c(9N4)c(9N1)c(18N7)c(18N4)c(18N1)c(9N27)c(9N24)c(9N21)c(9N6)c(9N3)c(9N)c(18N6)c(18N3)c(18N)c(9N26)c(9N23)c(9N2)).

Coefficient c(i,j,k,l) is in row (9N(j–1) + 9i + 3l + k – 12) of the vector c.

Express c as numbers, text expressions, or functions, as in f Coefficient for Systems.

Often, your tensor c has structure, such as symmetric or block diagonal. In many cases, you can represent c using a smaller vector than one with 4N2 components for 2-D or 9N2 components for 3-D.

The number of rows in the matrix can differ from 4N2 for 2-D or 9N2 for 3-D, as described in 2-D Systems and 3-D Systems.

In function form for 2-D systems, the number of columns is Nt, which is the number of triangles or tetrahedra in the mesh. The function should evaluate c at the triangle or tetrahedron centroids, as in Specify 2-D Scalar Coefficients in Function Form. Give solvers the function name as a string 'filename', or as a function handle @filename, where filename.m is a file on your MATLAB® path. For details on writing the function, see Calculate Coefficients in Function Form.

For the function form of coefficients of 3-D systems, see Specify 3-D PDE Coefficients in Function Form.

2-D Systems

Scalar c, 2-D Systems

The software interprets a scalar c as a diagonal matrix, with c(i,i,1,1) and c(i,i,2,2) equal to the scalar, and all other entries 0.

(c000000c000000c000000c000000c000000c)

Two-Element Column Vector c, 2-D Systems

The software interprets a two-element column vector c as a diagonal matrix, with c(i,i,1,1) and c(i,i,2,2) as the two entries, and all other entries 0.

(c(1)000000c(2)000000c(1)000000c(2)000000c(1)000000c(2))

Three-Element Column Vector c, 2-D Systems

The software interprets a three-element column vector c as a symmetric block diagonal matrix, with c(i,i,1,1) = c(1), c(i,i,2,2) = c(3), and c(i,i,1,2) = c(i,i,2,1) = c(2).

(c(1)c(2)0000c(2)c(3)000000c(1)c(2)0000c(2)c(3)000000c(1)c(2)0000c(2)c(3))

Four-Element Column Vector c, 2-D Systems

The software interprets a four-element column vector c as a block diagonal matrix.

(c(1)c(3)0000c(2)c(4)000000c(1)c(3)0000c(2)c(4)000000c(1)c(3)0000c(2)c(4))

N-Element Column Vector c, 2-D Systems

The software interprets an N-element column vector c as a diagonal matrix.

(c(1)000000c(1)000000c(2)000000c(2)000000c(N)000000c(N))

    Caution   If N = 2, 3, or 4, the 2-, 3-, or 4-element column vector form takes precedence over the N-element form. For example, if N = 3, and you have a c matrix of the form

    (c1000000c1000000c2000000c2000000c3000000c3),

    you cannot use the N-element form of c. Instead, you must use the 2N-element form. If you give c as the vector [c1;c2;c3], the software interprets c as a 3-element form:

    (c1c20000c2c3000000c1c20000c2c3000000c1c20000c2c3).

    Instead, use the 2N-element form [c1;c1;c2;c2;c3;c3].

2N-Element Column Vector c, 2-D Systems

The software interprets a 2N-element column vector c as a diagonal matrix.

(c(1)000000c(2)000000c(3)000000c(4)000000c(2N1)000000c(2N))

    Caution   If N = 2, the 4-element form takes precedence over the 2N-element form. For example, if your c matrix is

    (c10000c20000c30000c4),

    you cannot give c as [c1;c2;c3;c4], because the software interprets this vector as the 4-element form

    (c1c300c2c40000c1c300c2c4).

    Instead, use the 3N-element form [c1;0;c2;c3;0;c4] or the 4N-element form [c1;0;0;c2;c3;0;0;c4].

3N-Element Column Vector c, 2-D Systems

The software interprets a 3N-element column vector c as a symmetric block diagonal matrix.

(c(1)c(2)0000c(2)c(3)000000c(4)c(5)0000c(5)c(6)000000c(3N2)c(3N1)0000c(3N1)c(3N))

Coefficient c(i,j,k,l) is in row (3i + k + l – 4) of the vector c.

4N-Element Column Vector c, 2-D Systems

The software interprets a 4N-element column vector c as a block diagonal matrix.

(c(1)c(3)0000c(2)c(4)000000c(5)c(7)0000c(6)c(8)000000c(4N3)c(4N1)0000c(4N2)c(4N))

Coefficient c(i,j,k,l) is in row (4i + 2l + k – 6) of the vector c.

2N(2N+1)/2-Element Column Vector c, 2-D Systems

The software interprets a 2N(2N+1)/2-element column vector c as a symmetric matrix. In the following diagram, • means the entry is symmetric.

(c(1)c(2)c(4)c(6)c((N1)(2N1)+1)c((N1)(2N1)+3)c(3)c(5)c(7)c((N1)(2N1)+2)c((N1)(2N1)+4)c(8)c(9)c((N1)(2N1)+5)c((N1)(2N1)+7)c(10)c((N1)(2N1)+6)c((N1)(2N1)+8)c(N(2N+1)2)c(N(2N+1)1)c(N(2N+1)))

Coefficient c(i,j,k,l), for i < j, is in row (2j2 – 3j + 4i + 2l + k – 5) of the vector c. For i = j, coefficient c(i,j,k,l) is in row (2i2 + i + l + k – 4) of the vector c.

4N2-Element Column Vector c, 2-D Systems

The software interprets a 4N2-element column vector c as a matrix.

(c(1)c(3)c(4N+1)c(4N+3)c(4N(N1)+1)c(4N(N1)+3)c(2)c(4)c(4N+2)c(4N+4)c(4N(N1)+2)c(4N(N1)+4)c(5)c(7)c(4N+5)c(4N+7)c(4N(N1)+5)c(4N(N1)+7)c(6)c(8)c(4N+6)c(4N+8)c(4N(N1)+6)c(4N(N1)+8)c(4N3)c(4N1)c(8N3)c(8N1)c(4N23)c(4N21)c(4N2)c(4N)c(8N2)c(8N)c(4N22)c(4N2)).

Coefficient c(i,j,k,l) is in row (4N(j–1) + 4i + 2l + k – 6) of the vector c.

3-D Systems

Scalar c, 3-D Systems

The software interprets a scalar c as a diagonal matrix, with c(i,i,1,1), c(i,i,2,2), and c(i,i,3,3) equal to the scalar, and all other entries 0.

(c000000000c000000000c000000000c000000000c000000000c000000000c000000000c000000000c)

Three-Element Column Vector c, 3-D Systems

The software interprets a three-element column vector c as a diagonal matrix, with c(i,i,1,1), c(i,i,2,2), and c(i,i,3,3) as the three entries, and all other entries 0.

(c(1)000000000c(2)000000000c(3)000000000c(1)000000000c(2)000000000c(3)000000000c(1)000000000c(2)000000000c(3))

Six-Element Column Vector c, 3-D Systems

The software interprets a six-element column vector c as a symmetric block diagonal matrix, with

c(i,i,1,1) = c(1)
c(i,i,2,2) = c(3)
c(i,i,1,2) = c(i,i,2,1) = c(2)
c(i,i,1,3) = c(i,i,3,1) = c(4)
c(i,i,2,3) = c(i,i,3,2) = c(5)
c(i,i,3,3) = c(6).

In the following diagram, • means the entry is symmetric.

(c(1)c(2)c(4)000000c(3)c(5)000000c(6)000000000c(1)c(2)c(4)000000c(3)c(5)000000c(6)000000000c(1)c(2)c(4)000000c(3)c(5)000000c(6))

Nine-Element Column Vector c, 3-D Systems

The software interprets a nine-element column vector c as a block diagonal matrix.

(c(1)c(4)c(7)000000c(2)c(5)c(8)000000c(3)c(6)c(9)000000000c(1)c(4)c(7)000000c(2)c(5)c(8)000000c(3)c(6)c(9)000000000c(1)c(4)c(7)000000c(2)c(5)c(8)000000c(3)c(6)c(3))

N-Element Column Vector c, 3-D Systems

The software interprets an N-element column vector c as a diagonal matrix.

(c(1)000000000c(1)000000000c(1)000000000c(2)000000000c(2)000000000c(2)000000000c(N)000000000c(N)000000000c(N))

    Caution   If N = 3, 6, or 9, the 3-, 6-, or 9-element column vector form takes precedence over the N-element form. For example, if N = 3, and you have a c matrix of the form

    (c(1)000000000c(1)000000000c(1)000000000c(2)000000000c(2)000000000c(2)000000000c(3)000000000c(3)000000000c(3)),

    you cannot use the N-element form of c. If you give c as the vector [c1;c2;c3], the software interprets c as a 3-element form:

    (c(1)000000000c(2)000000000c(3)000000000c(1)000000000c(2)000000000c(3)000000000c(1)000000000c(2)000000000c(3)).

    Instead, use one of these forms:

    • 6N-element form — [c1;0;c1;0;0;c1;c2;0;c2;0;0;c2;c3;0;c3;0;0;c3]

    • 9N-element form — [c1;0;0;0;c1;0;0;0;c1;c2;0;0;0;c2;0;0;0;c2;c3;0;0;0;c3;0;0;0;c3]

3N-Element Column Vector c, 3-D Systems

The software interprets a 3N-element column vector c as a diagonal matrix.

(c(1)000000000c(2)000000000c(3)000000000c(4)000000000c(5)000000000c(6)000000000c(3N2)000000000c(3N1)000000000c(3N))

    Caution   If N = 3, the 9-element form takes precedence over the 3N-element form. For example, if your c matrix is

    (c(1)000000000c(2)000000000c(3)000000000c(4)000000000c(5)000000000c(6)000000000c(7)000000000c(8)000000000c(9)),

    you cannot give c as [c1;c2;c3;c4;c5;c6;c7;c8;c9], because the software interprets this vector as the 9-element form

    (c(1)c(4)c(7)000000c(2)c(5)c(8)000000c(3)c(6)c(9)000000000c(1)c(4)c(7)000000c(2)c(5)c(8)000000c(3)c(6)c(9)000000000c(1)c(4)c(7)000000c(2)c(5)c(8)000000c(3)c(6)c(3)).

    Instead, use one of these forms:

    • 6N-element form — [c1;0;c2;0;0;c3;c4;0;c5;0;0;c6;c7;0;c8;0;0;c9]

    • 9N-element form — [c1;0;0;0;c2;0;0;0;c3;c4;0;0;0;c5;0;0;0;c6;c7;0;0;0;c8;0;0;0;c9]

6N-Element Column Vector c, 3-D Systems

The software interprets a 6N-element column vector c as a symmetric block diagonal matrix. In the following diagram, • means the entry is symmetric.

(c(1)c(2)c(4)000000c(3)c(5)000000c(6)000000000c(7)c(8)c(10)000000c(9)c(11)000000c(12)000000000c(6N5)c(6N4)c(6N2)000000c(6N3)c(6N1)000000c(6N))

Coefficient c(i,j,k,l) is in row (6i + k + 1/2l(l–1) – 6) of the vector c.

9N-Element Column Vector c, 3-D Systems

The software interprets a 9N-element column vector c as a block diagonal matrix.

(c(1)c(4)c(7)000000c(2)c(5)c(8)000000c(3)c(6)c(9)000000000c(10)c(13)c(16)000000c(11)c(14)c(17)000000c(12)c(15)c(18)000000000c(9N8)c(9N5)c(9N2)000000c(9N7)c(9N4)c(9N1)000000c(9N6)c(9N3)c(9N))

Coefficient c(i,j,k,l) is in row (9i + 3l + k – 12) of the vector c.

3N(3N+1)/2-Element Column Vector c, 3-D Systems

The software interprets a 3N(3N+1)/2-element column vector c as a symmetric matrix. In the following diagram, • means the entry is symmetric.

(c(1)c(2)c(4)c(7)c(10)c(13)c(3(N1)(3(N1)+1)/2+1c(3(N1)(3(N1)+1)/2+4c(3(N1)(3(N1)+1)/2+7c(3)c(5)c(8)c(11)c(14)c(3(N1)(3(N1)+1)/2+2c(3(N1)(3(N1)+1)/2+5c(3(N1)(3(N1)+1)/2+8c(6)c(9)c(12)c(15)c(3(N1)(3(N1)+1)/2+3c(3(N1)(3(N1)+1)/2+6c(3(N1)(3(N1)+1)/2+9c(16)c(17)c(19)c(3(N1)(3(N1)+1)/2+10c(3(N1)(3(N1)+1)/2+13c(3(N1)(3(N1)+1)/2+16c(18)c(20)c(3(N1)(3(N1)+1)/2+11c(3(N1)(3(N1)+1)/2+14c(3(N1)(3(N1)+1)/2+17c(21)c(3(N1)(3(N1)+1)/2+12c(3(N1)(3(N1)+1)/2+15c(3(N1)(3(N1)+1)/2+18c(3N(3N+1)/25)c(3N(3N+1)/24)c(3N(3N+1)/22)c(3N(3N+1)/23)c(3N(3N+1)/21)c(3N(3N+1)/2))

Coefficient c(i,j,k,l), for i < j, is in row (9(j–1)(j–2)/2 + 6(j–1) + 9i + 3l + k – 12) of the vector c. For i = j, coefficient c(i,j,k,l) is in row (9(i–1)(i–2)/2 + 15(i–1) + 1/2l(l–1) + k) of the vector c.

9N2-Element Column Vector c, 3-D Systems

The software interprets a 9N2-element column vector c as a matrix.

(c(1)c(4)c(7)c(3N+1)c(3N+4)c(3N+7)c(9N(N1)+1)c(9N(N1)+4)c(9N(N1)+7)c(2)c(5)c(8)c(3N+2)c(3N+5)c(3N+8)c(9N(N1)+2)c(9N(N1)+5)c(9N(N1)+8)c(3)c(6)c(9)c(3N+3)c(3N+6)c(3N+9)c(9N(N1)+3)c(9N(N1)+6)c(9N(N1)+9)c(10)c(13)c(16)c(3N+10)c(3N+13)c(3N+16)c(9N(N1)+10)c(9N(N1)+13)c(9N(N1)+16)c(11)c(14)c(17)c(3N+11)c(3N+14)c(3N+17)c(9N(N1)+11)c(9N(N1)+14)c(9N(N1)+17)c(12)c(15)c(18)c(3N+12)c(3N+15)c(3N+18)c(9N(N1)+12)c(9N(N1)+15)c(9N(N1)+18)c(3N8)c(3N5)c(3N2)c(6N8)c(6N5)c(6N2)c(9N28)c(9N25)c(9N22)c(3N7)c(3N4)c(3N1)c(6N7)c(6N4)c(6N1)c(9N27)c(9N24)c(9N21)c(3N6)c(3N3)c(3N)c(6N6)c(6N3)c(6N)c(9N26)c(9N23)c(9N2))

Coefficient c(i,j,k,l) is in row (9N(j–1) + 9i + 3l + k – 12) of the vector c.

Related Examples

Was this topic helpful?