With the same barrel diameter, I'd expect a 20" barrel to be slightly less accurate than a 17" barrel. The accuracy is related to barrel stiffness (resistance to barrel whip) and the stiffness of a column is inversely proportional to the square of the length, roughly analogous to Euler's beam or column equations.

https://en.wikipedia.org/wiki/Euler–Bernoulli_beam_theory
That Wikipedia page has a nice graphic showing I-beam deflection. Barrel whip is similar, but generally the muzzle is whipping around in a more complex pattern than simply up and down.

To make a rifle more inherently accurate, make the barrel shorter or larger in diameter. In practice, there are also tricks reloaders do to optimize loads to maximize accuracy by having the bullet exit the muzzle when the muzzle is moving the least, and that's when it's at the extreme end of the barrel whip excursion and is reversing directions (at the maximum point of barrel whip deflection).