def f(N1, N2, Vg1, Vg2, Ec1, Ec2, Cg1, Cg2, Ecm, e):
    """

    Parameters
    ----------
    N1 : Int
        Number of electrons on dot 1.
    N2 : Int
        Number of electrons on dot 1.
    Vg1 : Float
        Voltage on gate 1.
    Vg2 : Float
        Voltage on gate 2.
    Ec1 : Float
        Charging energy of dot 1.
    Ec2 : Float
        Charging energy of dot 2.
    Cg1 : Float
        Capacitance of gate 1.
    Cg2 : Float
        Capacitance of gate 2.
    Ecm : Float
        Electrostatic coupling energy between the two dots.
    e : Float
        Elementary charge.

    Returns
    -------
    Float
        Electrostatic energy of charges on the gates.

    """
    return -1/e*(Cg1*Vg1*(N1*Ec1+N2*Ecm)+Cg2*Vg2*(N1*Ecm+N2*Ec2))\
        +1/e**2*(0.5*Cg1**2*Vg1**2*Ec1+0.5*Cg2**2*Vg2**2*Ec2+Cg1*Vg1*Cg2*Vg2*Ecm)