added sqrt simplification and fixed LaTeX rendering