def getdzs(h, gz, N):
    """Given a domain size h, a grading factor gz and a number of points N
    this function returns the grid size of the first and the last
    points.
    Usage: dz1,dzN=getdzs(h,gz,N)
    """
    # Compute the common ratio of the sequence
    r = gz ** (1.0 / (N - 1))
    if r != 1:
        dz1 = h * (1.0 - r) / (1.0 - r ** (N - 1))
        dzN = gz * dz1
    else:
        dz1 = h / float(N - 1)
        dzN = dz1

    z = 0
    for i in range(N - 1):
        zn = z + r ** i * dz1
        z = zn
        #  print i+1,z

    #  print some output
    print("grid size of the first and last cells:")
    print("dz[0]=", dz1)
    print("dz[N-1]=", dzN)

    return dz1, dzN