Skip to content

The inverse of the inverse should be self in CoordChange #31923

@egourgoulhon

Description

@egourgoulhon

When initializing the inverse of a transition map between two charts, either by the method CoordChange.inverse (computation of the inverse) or by CoordChange.set_inverse (inverse provided by the user), the attribute _inverse of self is set to the inverse object (for caching). Obviously, by symmetry, the attribute _inverse of the inverse should be set to self, but it is not. As a consequence, we have in Sage 9.3:

sage: E.<x,y> = EuclideanSpace()
sage: cart = E.cartesian_coordinates()
sage: polar = E.polar_coordinates()
sage: polar_to_cart = E.coord_change(polar, cart)
sage: polar_to_cart.display()
x = r*cos(ph)
y = r*sin(ph)
sage: cart_to_polar = E.coord_change(cart, polar)
sage: cart_to_polar.display()
r = sqrt(x^2 + y^2)
ph = arctan2(y, x)
sage: polar_to_cart.inverse() is cart_to_polar
True

So far so good, but

sage: cart_to_polar.inverse() is polar_to_cart
...
ValueError: no solution found; use set_inverse() to set the inverse manually

This is fixed in this ticket by the following one-line addition to the code of CoordChange.inverse and CoordChange.set_inverse:

self._inverse._inverse = self

Besides, this ticket improves a little bit the documentation of CoordChange.inverse.

CC: @tscrim @mjungmath @mkoeppe

Component: manifolds

Keywords: chart, transition_map

Author: Eric Gourgoulhon

Branch/Commit: 923196a

Reviewer: Michael Jung

Issue created by migration from https://trac.sagemath.org/ticket/31923

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions