Question: Help with mapping a function

I have the following variable

s1:=(1/2/Pi+Q*cos(k*phi))^3*cos(k*phi)/(1+beta^2*(1/2/Pi+Q*cos(k*phi))^2)^2;

 

and then I make a substitution as follows

s2:= subs(cos(k*phi)=((1-u^2) / (1+u^2)),sin(k*phi)=((2*u) / (1+u^2)), s1)*1/(1 + u^2);  -----(1)

 

Now if I set up a function f that maps u to the right hand side of (1) above as follows

f:=u->(1/2/Pi+Q*(1-u^2)/(1+u^2))^3*(1-u^2)/((1+u^2)^2*(1+beta^2*(1/2/Pi+Q*(1-u^2)/(1+u^2))^2)^2); ---- (2)

 

where I have manually typed in the right hand side of (1) in expression (2) then the mapping works fine. But if I try to make s2 a mapping function as follows I get a mapping to the substitution and not a mapping to the expression on the right hand side of (2) as desired

s2:= u->subs(cos(k*phi)=((1-u^2) / (1+u^2)),sin(k*phi)=((2*u) / (1+u^2)), s1)*1/(1 + u^2);

 

In the program I am working on s1 will vary in form and s2 will substitute expressions in u depending on whether cosine or sine appears in s1. So I can't manually enter the value of s2 each time a substitution has been made. So my question is how do I set up a function that maps u onto the result of the substitution that is made at s2? That is to say after I make the substitution at s2 (equation 1 above) how can I map the result of the substitution to a function? Please help.

Please Wait...