In 1804, when she was 24, Somerville got married to Samuel Grieg. She found that marriage gave her independence from her parents. She began studying algebra. She had two sons, but her husband died in 1807. As a widow, she found more freedom to study and learned many more mathematical concepts."Mary Somerville." Scientists: Their Lives and Works, UXL, 2006. Student Resources in Context. Accessed 31 Mar. 2017.