# Multivariate second order polynomial expansion.

### Description

Expand matrix columns into linear, square, and unique product columns.

### Usage

1 |

### Arguments

`X` |
vector or matrix. If a vector, it will be converted to
a column matrix. If it is desired that the squares
and products of a |

`FUN` |
Binary function which forms the products of the columns.
By default, this is '*', but other |

`...` |
Options for FUN. Not needed if FUN doesn't have options. |

### Details

Form a matrix with columns composed of into linear, square, and product columns:

*[X | FUN(X[,i], X[,j])]*

where *i, j* are the unique combinations of *i* and *j*,
including *i=j*.

By default, the function used to form the squares and
products, FUN, is just conventional multiplication = '*', but any
*commuting* binary operator can be used.

This particular expansion is often applied in

General Method of Data Handling (GMDH).

Nonlinear Slow Feature Analysis (SFA). Performing a multivariate polynomial of second degree expansion in all the features, then performing

*linear*SFA on the resulting expanded feature matrix, is a very common approach, and in fact is the default method in`sfa2 {rSFA}`

.

### Value

*[X,X^2,unique products of columns of X]*. The unique
products are in row major upper right triangular order.
Thus, for X with columns 1:3, the order is

*X[,1]^2, X[,2]^2, X[,3]^2,
X[,1]*X[,2], X[,1]*X[,3], X[,2]*X[,3]*

### See Also

`sfa2`

### Examples

1 2 3 | ```
# # Examples
# eQuad(1:5)
# eQuad(matrix(1:12,ncol=3),FUN=`+`)
``` |