In linear algebra, two n×n matrices A and B are similar if there exists an invertible n×n matrix S such that B=S−1AS.