The synchrotron spectrum of the M87 jet