Ritz method for transition paths and quasipotentials of rare diffusive events