# Finding Imaginary part of a complex function with 2 arguments

How to make mathematica gives the imaginary part of a certain complex function in the form of trigonometric functions such as sin(s-t) and cos(s-t)?

Clear["Global*"];
et[s_] := Cos[s] + I Sin[s];
etp[s_] := I et[s];
A[s_] := (et[s])^3;
NM[s_, t_] := Im[A[s]/A[t] etp[t]/(et[t] - et[s])];


From the coding, I only manage to get answer

Re[(Cos[s] + I Sin[s])^3/((Cos[t] + I Sin[t])^2
(-Cos[s] + Cos[t] - I Sin[s] + I Sin[t]))]


which is not real expression because still have I. I don't understand why the Im[] doesn't work. Later on I have more complicated function

et[s_]:=(3+2 Cos[2s])(Cos[s] + I Sin[s])


Have a look at ComplexExpand

Clear["Global*"];
et[s_] := Cos[s] + I Sin[s];
etp[s_] := I et[s];
A[s_] := (et[s])^3;
NM[s_, t_] := Im[A[s]/A[t] etp[t]/(et[t] - et[s])];


Let's call your expression e then

e = Re[(Cos[s] +
I Sin[s])^3/((Cos[t] + I Sin[t])^2 (-Cos[s] + Cos[t] -
I Sin[s] + I Sin[t]))]


Re[(Cos[s] + I Sin[s])^3/((Cos[t] + I Sin[t])^2 (-Cos[s] + Cos[t] - I Sin[s] + I Sin[t]))]

This has only wrapped your expression in Re For further work you need to identify which terms are real and which are imaginary. ComplexExpand does this with the default assumption that unidentified symbols are real.

ComplexExpand[e] // Simplify


-(1/2) - Cos[s - t] - Cos[2 (s - t)]

Simplify is not necessary but without it you get a very long expression. Hope that helps.

Clear["Global*"];
et[s_] = Cos[s] + I Sin[s];
etp[s_] = I et[s];
A[s_] = (et[s])^3;

NM[s_, t_] =
Im[A[s]/A[t] etp[t]/(et[t] - et[s])] // ComplexExpand // FullSimplify

(* -Cos[2*s - 2*t] - Cos[s - t] - 1/2 *)
`