symforce.jacobian_helpers module¶
- tangent_jacobians(expr, args)[source]¶
Compute jacobians of expr, a Lie Group element which is a function of the Lie Group elements in args. Jacobians are derivatives in the tangent space of expr with respect to changes in the tangent space of the arg, as opposed to jacobians of the storage of either which could be trivially computed with
sf.Matrix.jacobian
orsf.Expr.diff
.This uses
tangent_jacobians_first_order()
internally.- Parameters:
- Returns:
The jacobian ``expr_D_arg`` for each arg in ``args``, where each ``expr_D_arg`` is of shape –
MxN
, withM
the tangent space dimension ofexpr
andN
the tangent space dimension ofarg
- Return type:
- tangent_jacobians_first_order(expr, args)[source]¶
An implementation of
tangent_jacobians()
using first-order simplifications of retract and local_coordinates.The interface is the same as for
tangent_jacobians()
.This is the method described in Section V.B.2 of the SymForce paper.
If
expr = f(arg)
, then the jacobian we want to return is the derivative oflocal_coordinates(f(arg), f(retract(arg), t)
with respect to tangent vector t att = 0
.local_coordinates
andretract
, however, are often complicated functions which are hard to symbolically differentiate when composed with f. To avoid this issue, we replace them with first order approximations. The result is something which we can easily symbolically differentiate.This works because the approximations become exact in the limit as
t -> 0
.While the output returned is different than that returned by
tangent_jacobians_chain_rule()
, they are the same when evaluated numerically.tangent_jacobians_first_order
(almost?) always returns expressions which require fewer ops after cse.
- tangent_jacobians_chain_rule(expr, args)[source]¶
An implementation of
tangent_jacobians()
using the symbolic chain rule withtangent_D_storage
andstorage_D_tangent
.The interface is the same as for
tangent_jacobians()
.This is the method described in Section V.B.1 of the SymForce paper.
If
expr = f(arg)
, then the jacobian we want to return is the derivative oflocal_coordinates(f(arg), f(retract(arg), t)
with respect to tangent vector t att = 0
.local_coordinates
andretract
, however, are often complicated functions which are hard to symbolically differentiate. To avoid this issue, we compute their derivatives ahead of time, then use the chain rule.While the output returned is different than that returned by
tangent_jacobians_first_order()
, they are the same when evaluated numerically.tangent_jacobians_first_order()
(almost?) always returns expressions which require fewer ops after cse.