Thanks for the idea, Kasper! This works, but has a somewhat unexpected outcome.
I can use the output of f to isolate the value x[f(x)]. However, if I use the output to try and replace a value x[f(x)] <- AD(0) for example, I get an error "invalid subscript type 'complex'". ADOverload is enabled for "[<-". I'm having a somewhat difficult time circumventing this. Among others, I've tried c(head(x , f(x)-1) , AD(0) , tail(x , f(x)-1)), x[cumsum(rep(1 , f(x)]... which also fail.
Thanks again for taking a look.
-Abe