derivatives.rst 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. .. default-domain:: cpp
  2. .. cpp:namespace:: ceres
  3. .. _chapter-on_derivatives:
  4. ==============
  5. On Derivatives
  6. ==============
  7. Ceres Solver, like all gradient based optimization algorithms, depends
  8. on being able to evaluate the objective function and its derivatives
  9. at arbitrary points in its domain. Indeed, defining the objective
  10. function and its `Jacobian
  11. <https://en.wikipedia.org/wiki/Jacobian_matrix_and_determinant>`_ is
  12. the principal task that the user is required to perform when solving
  13. an optimization problem using Ceres Solver. The correct and efficient
  14. computation of the Jacobian is the key to good performance.
  15. Ceres Solver offers considerable flexibility in how the user can
  16. provide derivatives to the solver. She can use:
  17. #. :ref:`chapter-analytical_derivatives`: The user figures out the
  18. derivatives herself, by hand or using a tool like `Maple
  19. <https://www.maplesoft.com/products/maple/>`_ or `Mathematica
  20. <https://www.wolfram.com/mathematica/>`_, and implements them in a
  21. :class:`CostFunction`.
  22. #. :ref:`chapter-numerical_derivatives`: Ceres numerically computes
  23. the derivative using finite differences.
  24. #. :ref:`chapter-automatic_derivatives`: Ceres automatically computes
  25. the analytic derivative using C++ templates and operator
  26. overloading.
  27. Which of these three approaches (alone or in combination) should be
  28. used depends on the situation and the tradeoffs the user is willing to
  29. make. Unfortunately, numerical optimization textbooks rarely discuss
  30. these issues in detail and the user is left to her own devices.
  31. The aim of this article is to fill this gap and describe each of these
  32. three approaches in the context of Ceres Solver with sufficient detail
  33. that the user can make an informed choice.
  34. For the impatient amongst you, here is some high level advice:
  35. #. Use :ref:`chapter-automatic_derivatives`.
  36. #. In some cases it maybe worth using
  37. :ref:`chapter-analytical_derivatives`.
  38. #. Avoid :ref:`chapter-numerical_derivatives`. Use it as a measure of
  39. last resort, mostly to interface with external libraries.
  40. For the rest, read on.
  41. .. toctree::
  42. :maxdepth: 1
  43. spivak_notation
  44. analytical_derivatives
  45. numerical_derivatives
  46. automatic_derivatives
  47. interfacing_with_autodiff
  48. inverse_and_implicit_function_theorems