optim want parameters passed in as a vector, ufortunately it means rewriting your function so that it pulls out x and y from the first and second positions of a generic double vector like so

# parm[1] will be x and parm[2] will be y
f <- function(parm){parm[1]^2 + 2*parm[2]^2 + sin(2*parm[1] + parm[2]^2)}
# some verification (looks fine)
f(c(0,0))
f(c(1,1))
f(c(-2,2))
optim(c(0,0),f)