Student Support Forum: 'Multiple Rules to Expr w/ multiple variables' topicStudent Support Forum > General > "Multiple Rules to Expr w/ multiple variables"

 Next Comment > Help | Reply To Topic
 Author Comment/Response Victor 05/25/12 3:03pm I'm trying to understand rules and transformations by applying them to simply expressions, but I came across this problem when I tried to apply it to trigonometric functions. I have a simple function, f[a_,b_]:=a+b, and I want to apply the transformations a:>Cos[a] and b:>Sin[b] such that f[a,b]=Cos[a]+Sin[b]. Therefore, I entered into Mathematica: f[a_,b_]:=a+b/.{a:>Cos[a],b:>Sin[b]} I'm pretty sure that I have entered it correctly, but if not please let me know. The transformation works for implicit values, for instance f[x,y]=Cos[x]+Sin[y]. However, when I try f[Pi,Pi] Mathematica gives me -2, which seems to be 2Cos[Pi] instead of Cos[Pi]+Sin[Pi] which is -1. Why is Mathematica behaving like this? What can I do to reach my desired transformation? Attachment: Forum.nb, URL: ,

 Subject (listing for 'Multiple Rules to Expr w/ multiple variables') Author Date Posted Multiple Rules to Expr w/ multiple variables Victor 05/25/12 3:03pm Re: Multiple Rules to Expr w/ multiple variables jf 05/26/12 1:59pm
 Next Comment > Help | Reply To Topic