# Is there a central difference/gradient function somewhere?

**URL:** <https://discourse.julialang.org/t/is-there-a-central-difference-gradient-function-somewhere/19454>\
**Category:** General Usage\
**Created:** [January 9, 2019, 10:30pm UTC](https://discourse.julialang.org/t/is-there-a-central-difference-gradient-function-somewhere/19454 "2019-01-09T22:30:27Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Mattriks](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mattriks/32/351_2.png) [@Mattriks](https://discourse.julialang.org/u/Mattriks)\
**Post date:** [January 10, 2019, 8:55am UTC](https://discourse.julialang.org/t/is-there-a-central-difference-gradient-function-somewhere/19454/2 "2019-01-10T08:55:30Z")

</div>

There is a function `gradvecfield()` in [`CoupledFields.jl`](https://github.com/Mattriks/CoupledFields.jl). It’s used by [`Gadfly.jl`](https://github.com/GiovineItalia/Gadfly.jl/) to calculate the gradient vector field for [`Geom.vectorfield`](http://gadflyjl.org/stable/gallery/geometries/#%5BGeom.vectorfield%5D(@ref)-1). `gradvecfield()` works like this:

```julia
using CoupledFields
kernelpars = GaussianKP(X)
∇g = gradvecfield([a b], X, Y, kernelpars)

```

where `a` is a smoothness parameter, `b` is a ridge parameter, `X` and `Y` are matrices, and `Y = g(X)`.

---

_[View the full topic](https://discourse.julialang.org/t/is-there-a-central-difference-gradient-function-somewhere/19454)._
