(* ------------------------------------------------------ *)
(*     dn.nb   Cauchy integral formula in Mathematica     *)
(* -----------------------------------------------------  *)
(* This is just an entertainment by Richard Hall         *)

(* The path w + a  is circle of radius b and centre a for t in [0, 2Pi] *)

w[t_,b_] := b Exp[I t]

w[t,b]

z[x_,y_] := x+ I y

(* Four simple test functions  *)

f1[s_] := s^3

f2[s_] := Exp[-s]

f3[s_] := Exp[-s] s^2

f4[s_] := Sin[s]*s^2

(* Try to avoid complications of pure functions in Mathematica         *)

(* Cauchy formula simplified for a circular path radius b centre a>0  *)
(* we get a numerator factor of w from w'[t] = i w[t]                 *)
(* Thus dn finds the nth derivative of f(z) at z = a  by integration  *)

dn[f_,a_,n_] := FullSimplify[(n!/(2 Pi)) Integrate[f[w[t,b]+a]/w[t,b]^n,{t,0,2 Pi},
Assumptions->{b > 0,a > 0}]]

dn[f1,a,1]

dn[f1,a,2]

dn[f1,a,4]

dn[f2,a,1]

dn[f2,a,2]

dn[f3,a,2]

(* check directly *)

f3''[a]

dn[f4,a,1]