Consider the following cases:
(1) If there exists a such that f(a)=a, then f(a)+f−1(a)=2a=2013. So this is impossible.
(2) If there exist a=b such that f(a)=b and f(b)=a, then f(a)+f−1(a)=2b=2013. So this is impossible.
(3) If there exist three distinct numbers a,b,c such that f(a)=b,f(b)=c and f(c)=a, then f(a)+f−1(a)=b+c and f(b)+f−1(b)=c+a. Since b+c=c+a=2013, we get b=c, which contradicts the assumption.
(4) If there exist k (with k≥5) distinct numbers a1,a2,…,ak such that f(a1)=a2,f(a2)=a3,…,f(ak−1)=ak and f(ak)=a1, then f(a2)+f−1(a2)=a3+a1=2013=f(a4)+f−1(a4)=a5+a3, which gives a1=a5, contradicting the assumption.
(5) If there exist 4 distinct numbers a,b,c,d such that f(a)=b,f(b)=c,f(c)=d and f(d)=a, then f(b)+f−1(b)=a+c=2013=f(d)+f−1(d), i.e., c=2013−a; also f(a)+f−1(a)=b+d=2013=f(c)+f−1(c), i.e., d=2013−b. Therefore (a,b,c,d)=(a,b,2013−a,2013−b) forms a cyclic group.
Since only (5) can hold, it suffices to determine 503 cyclic groups (ai,bi,2013−ai,2013−bi) to determine such a function f. Since ai and 2013−ai respectively have one less than 1007 and one greater than 1007; the same holds for bi and 2013−bi; so we may assume 1≤ai,bi≤1006 in order to determine (ai,bi,2013−ai,2013−bi) (at this point it is no longer a cyclic group, but an ordered group). Choosing a1,b1,a2,b2,⋯,a503,b503 in order from {1,2,⋯,1006}, there are 1006! possibilities; however, these 503 groups have no order among themselves, so the number of f is:
503!1006!