Here's an example of a moment with which every classical music lover is familiar:
There comes a point in virtually every concerto from the classical
period when the orchestra comes to a sudden halt and the soloist takes
flight with a couple of minutes of difficult (or at least
difficult-sounding) passage-work interspersed with fragments of melody
derived from what's been previously heard. This music usually
culminates in an extended trill, after which the orchestra re-enters,
bringing the movement to a speedy conclusion, more often than not
without any further participation from the soloist.
So what's going on?
We can brush very lightly and very quickly over the technical aspects; feel free to skip this paragraph if the technical aspects don't interest you. But for the two readers remaining:
This is the most characteristic closing cadence in classical music, consisting of four chords: the subdominant, the second inversion of the tonic (called, for reasons we're not going to bother ourselves about, a six-four chord), the dominant, and finally the tonic in its root position. Never mind what any of that means, just know that the second of those chords is considered very unstable, and was traditionally the place where an opera singer might improvise some pyrotechnic embellishments before allowing his or her aria to finish.
When the classical era began experimenting with adapting vocal arias for solo instruments and marrying the da capo aria form to that of the symphony, what ultimately emerged was the concerto we now know. And when this was firmly established as a genre in its own right, that same moment and that same chord became the place where soloists could take a few minutes to display their virtuosity. Since in those days the composer and the soloist were usually the same person, the requirement to provide the latter with an opportunity to show off was no great imposition on the former.
It is believed that Mozart (generally regarded as peerless in this form of composition) improvised his own cadenzas at concerts. There's no reason to doubt it; his facility at improvisation had been legendary even when he was a child. This place in his scores was always left blank, with a fermata (pause sign) over the six-four chord, leaving the choice of what to play to the performer's discretion. An exception occurs in those of his concerti with more than one solo instrument, when the practical need for cohesion demands a written-out cadenza, for example:
We could easily have remained ignorant of what sort of thing Mozart himself did in his solo concerti when the cadenza moment hove into view. But fortunately for us, Mozart's students didn't share his improvisational gifts, and so, when a pupil of his was going to play one of his concerti, Mozart accommodatingly wrote out an improvisatory-sounding cadenza for him or her (usually it was her) to use. As a result, we have at least an approximate idea of what Mozart played and for how long he played it before arriving at the trill that welcomes the orchestra back into the fray. Here's an example:
But existing cadenzas of Mozart's own composition are the exception. For most of his concerti, soloists have either had to fend for themselves or adopt the cadenzas that were composed by other pianists or composers. In all but his final piano concerto, Beethoven followed Mozart's example and left the cadenzas unwritten. But later in his career, he thought better of the practice, and published cadenzas for his first four piano concerti, in some cases writing several alternate versions, giving the performer a choice of which to play. (This development coincided with two significant changes in the composer's life, and it's impossible to say whether either--or both --might have played a determinative role: his deafness had become sufficiently acute so that he could no longer perform comfortably in public, and he was beginning to devote himself as a teacher to the not untalented Archduke Rudolf; in either case, he might have felt an urge to be more precise about what interpreters other than himself should play.) In his final, fifth piano concerto, he still includes the six-four chord and the fermata, but this time he inserts an NB, and a note in Italian at the bottom of the page which reads, in rough translation: "One should not play a cadenza here, but go immediately to what follows." What follows is a very short, quite minimal, but fully written-out cadenza:
Unusually, it doesn't end with the orchestra's immediate return, but rather, with a continuation of the piano solo, under which the orchestra gently sidles in. As far as I'm aware, no performer of this concerto, regardless of how subversive or willful, has ever had the, I believe the technical term is chutzpah, to disregard Beethoven's instructions and to--I believe the technical term is potchkey--with what Beethoven specified. That NB is just too stern to flout.
But otherwise? Well, in cases where no original cadenza exists, the only choice is to invent one's own or play something written by someone not the composer. In other cases, performers and composers have abandoned what might seem like sensible scruples and chosen to ignore the composer's explicit intentions, replacing the original cadenza with one of someone else's devising. Most of these are unexceptionable, if not obviously improvements; Brahms, for example, composed cadenzas to some Mozart and Beethoven concerti, and although they're almost never played, they're perfectly plausible. Mendelssohn wrote cadenzas for a number of Mozart concerti, including the one for two pianos, where Mozart's splendid specimen certainly demanded no replacement, and, one might say, barely permitted it. For some reason, Robert Casadesus used to play the composer-written cadenza to Mozart's 16th piano concerto in his performances of the 26th. This was a dumbfounding choice; Casadesus was too knowledgeable a Mozartian to have been unaware of what he was doing, but he went ahead and did it anyway. It didn't cause any grotesque harm; the candenza was in the right key, and even though none of the music in the cadenza related to anything in the concerto being performed, the effect wasn't horribly grating and the final trill delivered everyone home safely.