ok, i was going to try to do the bartok, but it's 2 oclock in the morning, and you can't find that piece anywhere online! sooo, bach it is...
This invention is divided into 3 main sections. The main motive is expressed in the first 2 measures, serving as the expository function. The right and left hands switch turns doodling sixteenth notes, and the left hand follows the right hand's lead most of the time. The first section starts out in d minor, but measure 9 seems like it has modulated to F major on a V chord, and stays in F; the 1st section ends on a PAC in F
The second section starts with this really harsh trill for 3 measures in the right hand with the left hand doodling underneath. It seems to act as a transitional function, as well as a development in the invention, because I think it modulates to a minor in measure 26. The left hand decides to mimic the right hand again and begins playing the harsh trill with the right hand doodling above it. This section ends in a Pac in a minor.
The last section is back to d minor, leading back to the expository section. There's a cadential extension for four measures in measures 48-52. It finally ends on a PAC in the original key.