def update_Fpsi(Fpsi, psi, f, dx, a, b):
    """
    Used to solve the one-dimensional electrostatic Poisson equation,

        psi'' = -f,

    under Dirichlet (fixed potential) boundary conditions:

        psi[0] = a
        psi[-1] = b

    Arguments
    ---------
    Fpsi : vector of length N
        Vector to update.
    psi : vector of length N
        last estimate of the electrostatic potential [V]
    f : vector of length N
        source term [V cm**-2]
    dx : scalar
        grid spacing [cm]
    a : float
        left Dirichlet boundary value [V]
    b : float
        right Dirichlet boundary value [V]
    """
    dx2 = dx * dx
    Fpsi[1:-1] = psi[:-2] - 2 * psi[1:-1] + psi[2:] + f[1:-1] * dx2
    Fpsi[0] = psi[0] - a
    Fpsi[-1] = psi[-1] - b
