I suspect that what you want to do can be done by gradef(r(t),r1(t)); This means that diff(r(t),t) will come out as r1(t). But maybe that is not what you desire. RJF