I have some conceptual trouble understanding the differences between rhythm and melody.
I get that harmony is the vertical dimension of music (thinking in terms of sheet music or a piano roll view in a DAW) and melody is the horizontal dimension. However, the way rhythm is defined seems to place it on the horizontal dimension as well. The problem then, as a mathematician might put it, is that harmony and melody already provide a basis for the two dimensions of sheet/piano roll music. In particular, if a melody completely defines a horizontal slice of music (or maybe more geometrically precisely, a curve passing through only one note at a time), how is it still possible for the rhythm to vary while holding the melody constant?
My grade school understanding was that rhythm was the percussion's contribution to the horizontal dimension and melody was the non-percussion's contribution to it, so that a melody would not completely define the horizontal dimension, but only the role of certain instruments in occupying it, but I don't think this explanation is correct, because people attempt to illustrate the concept of rhythm on non-percussive instruments as well.
To offer another guess at how melody may not completely define the horizontal dimension, is it the case that melody is only concerned with the order of notes, while rhythm takes credit for their duration? For example, if I specify a string of notes such as A, C, E, G, F, C#, A, B, A, C, A, does this string, in and of itself, constitute a melody, even though the string might sound very different depending on the duration of each note?
How do rhythm and melody compete and cooperate to define the horizontal space of music?