### How to search through a finitely generated matrix group, by Frobenius norm

I am pretty new to Sage. I plan on learning/practicing more, but for now I need a quick way of getting some data, so I'm hoping someone can help me out. BTW I'm a math PhD student just about to do my defense. My thesis is complete but it would just be really cool if I had some worked examples to wow my committee. That's what this has to do with (well... it's a very small sub-portion of the problem, but a necessary one), and anyone who can assist me will happily be included in the acknowledgements.

Suppose I have a finitely generated discrete subgroup H of SL(2,Z), and I have a subgroup G of H. Both of these groups are finitely generated, and I have a list of generators for each group. Given some element h of H, I want an efficient way of telling whether or not there exists an element h of G such that h=gg* where g* is the conjugate transpose of g.

Note that the membership problem is decideable for SL(2,Z), but this problem is much easier than finding an algorithm for that general case.

What I did so far is I computed each generator of G in terms of the generators of H by writing a script that went through by word length. I also computed a list of matrices of the form gg* up to words in G up to length g, but the order in which these show up is not convenient.

So, let h be some element of H, given as a matrix. My plan is to write h in terms of the generators of H, so that I can more easily recognize whether it's of the form I want, by comparing it to the words for the generators of G. But my method of doing this is veeeerry slow, too slow to suit my purposes. An important factor is that there are a *lot* of elements in H that I need to check this on, so I need to be able to run this quickly. Preferably I would define lists of matrices to check, then have a program that just runs through the lists.

I feel like I may be reinventing the wheel in some parts of this, since it seems a fairly common problem to be studying words in matrices. Perhaps there is a pre-built module that has tools I could use but so far I have not found anything.

Thanks in advance.