GD for multiple variables