costate computation by an adaptive pseudospectral methodreza marzban deepai