| 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: , |
|