The answer is no, as you have apprehended. Take and set g to be the indicator on (-2,-1) and h to be zero. Then they're derivatives are equal but they do not differ by a constant. You will need to insist that D be connected if you want this to hold.
Let D be a set of nonzero real numbers. Suppose that the functions and are differentiable and that for all x in D. Do the functions differ by a constant???
so we can say that:
If D is an open interval then, we can define . then we have
for all x in D
So, is constant iff g and h differ by a constant.
however, what i wanted to know is how can we assure that D is an (open) interval?
Maybe I misunderstood you. Let . Define
and h(x)=0. Then you can easily see that g'=h'=0 on D, but g-h=g, which is not a constant.
In general, if D is the disjoint union of several connected components, then you can treat each one "independantly", bumping a function up by a different constant on each piece without changing the derivative.