Some basic but difficult to implement mathmatical functions