# Major examples

Use this example index to jump to code examples in the documentation. The examples marked [demo] are available at the Matlab command line or from the Sparse Grid Interpolation demo page within the Matlab help browser.

## Grid visualization

- Plot available sparse grid types for level
`N = 3`

,`D = 2`

[example] - Plot a 3D sparse grid with points colored according to level [example]
- Plot the set of multi-indices
`S_k`

of a two-dimensional dimension-adaptive sparse grid interpolant [example]

: Plot available sparse grid types for level**cmpgrids**`N = 4`

,`D = 2`

[demo]

## Piecewise linear basis functions

- Interpolate a simple two-dimensional function [example]
- Construct an interpolant of Branin's function [example]
- Perform multiple evaluations at once: vectorized call to
`spinterp`

[example], [example]

: Interpolate a simple two-dimensional function [demo]**spdemo**

: Compare multilinear interpolation schemes for the test functions of Gerz [demo]**spcompare**

## Polynomial basis functions

- Construct a polynomial interpolant of Branin's function (dimension-adaptive and non-adaptive) [example]

: Error plots for multilinear vs. polynomial basis functions [demo]**spcomparepoly**

## Dimension-adaptive sparse grids

- Recovery of a quadratic function with a tridiagonal Hessian (
`d = 100`

, piecewise linear and polynomial basis functions) [example]

: Dimension-adaptive interpolation of a simple two-dimensional function [demo]**spadaptdemo**

: Illustrates the dimension-adaptive construction[demo]**spadaptanim**

: Compares the error: adaptive vs. non-adaptive [demo]**spadapterror**- Comparison of different degrees of dimensional adaptivity [example]
- Adjusting the adaptivity degree during interpolant construction [example]

## Computing Derivatives

- Computing the derivatives of a bivariate piecewise multilinear interpolant [example]
- Augmented derivatives to achieve continuity [example]
- Derivatives of polynomial interpolants [example]

: Error plots for the derivative computation schemes [demo]**spcomparederiv**

## Numerical Integration

- Comparison of regular sparse grids for a 5d test problem [example]
- Integrating a high-dimensional dimension-adaptive interpolant [example]

## Optimization

- Using the optimization algorithms:
`spcgsearch`

[example],`spcompsearch`

[example],`spfminsearch`

[example],`spmultistart`

[example] - Optimizing a high-dimensional interpolant [example]
- Using third-party optimization methods [example]

## Providing additional options

- Setting the minimum/maximum number of support nodes [example]
- Re-using previous results [example]
- Using the VariablePositions property [example]

## Functions with multiple outputs

- Call to
`spvals`

: Function header type examples 6 [example], 7 [example], 8 [example], and 9 [example] - Construct interpolant and compute interpolated values [example]
- Approximate ODE output simultaneously at multiple time steps [example]

: Interpolate a function with multiple output arguments [demo]**spdemovarout**

## Performance related examples and demos

- Vectorizing the objective function [example]
- Re-using previous results [example], [example]
- Using
`sppurge`

to increase the performance when evaluating the sparse grid interpolants [example], [example]

: Measure the performance of the hierarchical construction of the interpolant [demo]**timespvals**

: Measure the performance of the hierarchical construction of Chebyshev-polynomial-based interpolants, with and without using a fast DCT [demo]**timespvalsdct**

: Measure the performance of computing 1000 interpolated values [demo]**timespinterp**

: Measure the performance of computing both interpolated values and gradients [demo]**timespderiv**