differentiate from first principles formula