.. SPDX-FileCopyrightText: 2022 Dominik Vilsmeier SPDX-License-Identifier: GPL-3.0-or-later Computation of Jacobians ======================== There are two types of methods for computing Jacobians: `AnalyticalJacobianMethod`_ and `NumericalJacobianMethod`_. The analytical method uses dedicated analytical formulas for computing Jacobians from Twiss data. The numerical method, on the other hand, uses finite difference approximation to obtain the Jacobian. The different methods can be imported from ``accinv.jacobian``. Typically, they are used together with a `Model`_ and then serve as an argument for the `Loco`_ class: .. code-block:: python from accinv.jacobian import AnalyticalJacobianMethod, NumericalJacobianMethod from accinv.loco import Loco from accinv.model import Madx model = Madx(path='path/to/script.madx') loco = Loco( # Both of the following are valid choices: model_and_jacobian_method=(model, AnalyticalJacobianMethod), model_and_jacobian_method=(model, NumericalJacobianMethod), # Fill in remaining arguments here: ..., ) The advantage of the analytical method is that it is faster to compute. However, at the moment, it is only available for quadrupole errors. The numerical method, on the other hand, works for any kind of parameters. .. _AnalyticalJacobianMethod: ../../api/accinv.jacobian.html#accinv.jacobian.AnalyticalJacobianMethod .. _NumericalJacobianMethod: ../../api/accinv.jacobian.html#accinv.jacobian.NumericalJacobianMethod .. _Model: ../../api/accinv.model.html#accinv.model.Model .. _Loco: ../../api/accinv.loco.html#accinv.loco.Loco