Accelerating the pace of engineering and science

# Documentation

## a or d for Systems

### Coefficients a or d

This section describes how to write the coefficients a or d in the equation

$d\frac{\partial u}{\partial t}-\nabla \cdot \left(c\otimes \nabla u\right)+au=f,$

or in similar equations. a and d are N-by-N matrices, where N is the number of equations, see Systems of PDEs.

Express the coefficients as numbers, text expressions, or functions, as in f for Systems.

The number of rows in the matrix is either 1, N, N(N+1)/2, or N2, as described in the next few sections. If you choose to express the coefficients in functional form, the number of columns is Nt, which is the number of triangles in the mesh. The function should evaluate a or d at the triangle centroids, as in Scalar PDE 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 how to write the function, see Calculate Coefficients in Function Form.

Often, a or d have structure, either as symmetric or diagonal. In these cases, you can represent a or d using fewer than N2 rows.

### Scalar a or d

The software interprets a scalar a or d as a diagonal matrix.

$\left(\begin{array}{cccc}a& 0& \cdots & 0\\ 0& a& \cdots & 0\\ ⋮& ⋮& \ddots & ⋮\\ 0& 0& \cdots & a\end{array}\right)$

### N-Element Column Vector a or d

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

$\left(\begin{array}{cccc}d\left(1\right)& 0& \cdots & 0\\ 0& d\left(2\right)& \cdots & 0\\ ⋮& ⋮& \ddots & ⋮\\ 0& 0& \cdots & d\left(N\right)\end{array}\right)$

For example, if N = 3, a or d could be

`a = char('sin(x) + cos(y)','cosh(x.*y)','x.*y./(1+x.^2+y.^2)') % or d`
```a =

sin(x) + cos(y)
cosh(x.*y)
x.*y./(1+x.^2+y.^2)```

### N(N+1)/2-Element Column Vector a or d

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

$\left(\begin{array}{ccccc}a\left(1\right)& a\left(2\right)& a\left(4\right)& \cdots & a\left(N\left(N-1\right)/2\right)\\ ·& a\left(3\right)& a\left(5\right)& \cdots & a\left(N\left(N-1\right)/2+1\right)\\ ·& ·& a\left(6\right)& \cdots & a\left(N\left(N-1\right)/2+2\right)\\ ⋮& ⋮& ⋮& \ddots & ⋮\\ ·& ·& ·& \cdots & a\left(N\left(N+1\right)/2\right)\end{array}\right)$

Coefficient a(i,j) is in row (j(j–1)/2+i) of the vector a.

### N2-Element Column Vector a or d

The software interprets an N2-element column vector a or d as a matrix.

$\left(\begin{array}{cccc}d\left(1\right)& d\left(N+1\right)& \cdots & d\left({N}^{2}-N+1\right)\\ d\left(2\right)& d\left(N+2\right)& \cdots & d\left({N}^{2}-N+2\right)\\ ⋮& ⋮& \ddots & ⋮\\ d\left(N\right)& d\left(2N\right)& \cdots & d\left({N}^{2}\right)\end{array}\right)$

Coefficient a(i,j) is in row (N(j–1)+i) of the vector a.