# Structure and Sparsity Detection

Using the tracing system provided by Symbolics.jl expressions, Symbolics.jl can automatically detect the sparsity patterns of Julia functions in an efficient way. This functionality is described in more detail in the paper:

```
@article{gowda2019sparsity,
title={Sparsity Programming: Automated Sparsity-Aware Optimizations in Differentiable Programming},
author={Gowda, Shashi and Ma, Yingbo and Churavy, Valentin and Edelman, Alan and Rackauckas, Christopher},
year={2019}
}
```

Please cite this work if the functionality is used.

## Sparsity Detection

`Symbolics.jacobian_sparsity`

— Function`jacobian_sparsity(ops::AbstractVector, vars::AbstractVector)`

Return the sparsity pattern of the Jacobian of an array of expressions with respect to an array of variable expressions.

`jacobian_sparsity(op!,output::Array{T},input::Array{T}) where T<:Number`

Return the sparsity pattern of the Jacobian of the mutating function `op!(output,input,args...)`

.

`Symbolics.hessian_sparsity`

— Function`hessian_sparsity(ops::AbstractVector, vars::AbstractVector)`

Return the sparsity pattern of the Hessian of an array of expressions with respect to an array of variable expressions.

## Structure Detection

`Symbolics.islinear`

— Function```
islinear(ex, u)
```

Check if an expression is linear with respect to a list of variable expressions.

`Symbolics.isaffine`

— Function```
isaffine(ex, u)
```

Check if an expression is affine with respect to a list of variable expressions.