Direct solver for a cubic mean segment