Completed function to generate characteristic equations