I would try to generalize this function. You can do this logic by doing subs. Then, at the top, you can just have a dictionary of equation types and their general forms, and have a single function that checks them, which takes the type as an argument. It doesn't have to be done for this PR, though.