# Shape Functions

## What is a shape function?

Shape Functions are used in a method for interpolating between values. It lends itself most readily to computerised methods of interpolating higher order multi-variable problems, but we can start with a simple example, e.g. if we have a function where we know values:

$$n$$ $$x_{n}$$ $$y_{n}$$
0 0 7
1 1 9

We can write an expression to interpolate between these values

\begin{align} y & = \sum^{n} y_{n} S_{n}(x) \\ y & = 7 \times S_{0}(x) + 9 \times S_{1}(x) \end{align}

where $$S_{0}(x)$$ and $$S_{1}(x)$$ are Shape Functions. The choice of function to use is mostly arbitrary, but will have the properties:

\begin{align} S_{n}(x_{m}) & = 1\textrm{ where } n = m \\ & = 0\textrm{ where } n \neq m \end{align}

For the above example, we could select Shape Functions:

\begin{align} S_{0}(x) & = 1 - x \\ S_{1}(x) & = x \end{align}

and then evaluate the expression:

$y = 7(1 - x) + 9x$

Now we can use this expression to interpolate between the values in the table, e.g. $$x = 0.3$$

\begin{align} y & = 7(1 - 0.3) + 9 \times 0.3 \\ y & = 7.6 \end{align}

## Shape function in two variables

Consider a function $$f(x, y)$$ where we know values on a grid:

$$n$$ $$x_{n}$$ $$y_{n}$$ $$F_{n}$$
0 0 0 f(0, 0)
1 0 1 f(0, 1)
2 1 0 f(1, 0)
3 1 1 f(1, 1)

We can write an expression to interpolate between these values

$f(x, y) = \sum_{n=1}^{4} F_{n} S_{n}(x, y)$

and select shape functions of the form:

$S_{n}(x, y) = A_{n}x + B_{n}y + C_{n}xy + D_{n}$

with coefficients:

$$n$$ $$A_{n}$$ $$B_{n}$$ $$C_{n}$$ $$D_{n}$$
0 -1 -1 1 1
1 0 1 -1 0
2 1 0 -1 0
3 0 0 1 0