▁of ▁the ▁object , ▁g ▁is ▁the ▁acceleration ▁due ▁to ▁gravity , ▁and ▁h ▁is ▁the ▁alt itude ▁of ▁the ▁object . ▁If ▁m ▁is ▁expressed ▁in ▁kil og rams , ▁g ▁in ▁m / s 2 ▁and ▁h ▁in ▁metres ▁then ▁U ▁will ▁be ▁calculated ▁in ▁jou les . ▁ ▁Hence , ▁the ▁potential ▁difference ▁is ▁ ▁General ▁formula ▁ ▁However , ▁over ▁large ▁variations ▁in ▁distance , ▁the ▁approximation ▁that ▁g ▁is ▁constant ▁is ▁no ▁longer ▁valid , ▁and ▁we ▁have ▁to ▁use ▁calculus ▁and ▁the ▁general ▁mathematical ▁definition ▁of ▁work ▁to ▁determine ▁gravit ational ▁potential ▁energy . ▁For ▁the ▁computation ▁of ▁the ▁potential ▁energy , ▁we ▁can ▁integrate ▁the ▁gravit ational ▁force , ▁whose ▁magnitude ▁is ▁given ▁by ▁Newton ' s ▁law ▁of ▁grav itation , ▁with ▁respect ▁to ▁the ▁distance ▁r ▁between ▁the ▁two ▁bodies . ▁Using ▁that ▁definition , ▁the ▁gravit ational ▁potential ▁energy ▁of ▁a ▁system ▁of ▁masses ▁m 1 ▁and ▁M 2 ▁at ▁a ▁distance ▁r ▁using ▁gravit ational ▁constant ▁G ▁is ▁ ▁, ▁ ▁where ▁K ▁is ▁an ▁arbitrary ▁constant ▁dependent ▁on ▁the ▁choice ▁of ▁dat um ▁from ▁which ▁potential ▁is ▁measured . ▁Cho osing ▁the ▁convention ▁that ▁K = 0 ▁( i . e . ▁in ▁relation ▁to ▁a ▁point ▁at ▁infinity ) ▁makes ▁calculations ▁simpler , ▁al beit ▁at ▁the ▁cost ▁of ▁making ▁U ▁negative ; ▁for ▁why ▁this ▁is ▁phys ically ▁reasonable , ▁see ▁below . ▁ ▁Given ▁this ▁formula ▁for ▁U , ▁the ▁total ▁potential ▁energy ▁of ▁a ▁system ▁of ▁n