Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve NLP documentation about ForwardDiff #2000

Merged
merged 2 commits into from
Jun 29, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions docs/src/nlp.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,19 @@ JuMP uses [ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl) to
perform automatic differentiation; see the ForwardDiff.jl
[documentation](http://www.juliadiff.org/ForwardDiff.jl/v0.10.2/user/limitations.html)
for a description of how to write a function suitable for automatic
differentiation. The general guideline is to write code that is generic with
respect to the number type; don't assume that the input to the function is
`Float64`. To register a user-defined function with derivatives computed by
differentiation.

!!! note
The general guideline for writing ForwardDiff-compatible code is is to write
code that is generic with respect to the number type; don't assume that the
input to the function is `Float64`.
```julia
f(x::Float64) = 2 * x # Don't do this.
f(x::Real) = 2 * x # This is good.
f(x) = 2 * x # This is also good.
```

To register a user-defined function with derivatives computed by
automatic differentiation, use the `register` method as in the following
example:

Expand Down