code simulates, filters, and inverts matrices