A little too much I think. After a while I'd forgotten my highschool math. Taking my mind of it for the weekend has helped.
[huge snip of sensible stuff]
Indeed, this is the case I discribed in my reply to Peter. It showed up in my simulations. I've now solved it by accelerating for half the requested time with max ramp. Certainly not optimal and results in a trapezoid lower than max speed. Should be optimal if I use half of your calculated new time instead. But I'll have to test how long the int-->float-->sqrt-->float-->int route takes or come up with an alternate solution.
You understood perfectly, so no corrections required. Thanks for your input.