This looks quite basic, and I have absolutely no idea why it doesn't work.

```
f <- function(x, y){x^2 + 2*y^2 + sin(2*x + y^2)}
# some verification (looks fine)
f(0,0)
f(1,1)
f(-2,2)
# plotted a contour graph (still looks fine)
xgrid <- seq(-3, 3, .01)
ygrid <- seq(-3, 3, .01)
z <- outer(xgrid, ygrid, f)
contour(xgrid, ygrid, z, nlevels = 20)
# optim gives error message
optim(c(0, 0), f)
```

The optim command produces:

"Error in fn(par, ...) : argument "y" is missing, with no default"