I would like to know how to perform algebraic operations with pure functions.
Simple version:
Here's a silly toy model: I want to transform the algebraic expression Sin*Cos into the function evaluated at r, that is, Sin[r]*Cos[r]. But I could not find any way to use Apply or Evaluate to do this. In other words, I would like to make Mathematica understand that something like this is true:
(Sin*Cos)[r_] := Sin[r_]*Cos[r_]
and analogously for all other possible pure functions. I realize that this means I need to convert
(Sin[#] &) Cos[#] &
into the version without the first '&', so that the whole expression defines only one pure function:
(Sin[#]) Cos[#] &[r]
Full version:
I have more elaborate algebraic expressions with two symbols 'Fm' and 'Fp', which I think as representing pure functions that will be defined later. These expressions involve derivatives, squares, etc., of these functions, for instance:
4 Fm Derivative[1][Fm]
or
1/4 Fp (2 Fp - Fp^3/Fm^2 + 4 Fm Derivative[1][Fm] Derivative[1][Fp])
I then want to simplify these expressions when I choose explicit pure functions, such as:
Fm = Sin[#] &;
Fp = Sin[#] Cos[#] &;
But when I declare these pure functions as above and then re-evaluate the expressions, I get:
4 (Cos[#1] &) (Sin[#1] &)
1/4 (Sin[#1] Cos[#1] &) (2 (Sin[#1] Cos[#1] &) - (Sin[#1] Cos[#1] &)^3/(Sin[#1] &)^2 + 4 (Cos[#1] &) (Sin[#1] &) (Cos[#1]^2 - Sin[#1]^2 &))
and instead I would like to get
4 Cos[#1] Sin[#1] &
1/4 (Sin[#1] Cos[#1]) (2 (Sin[#1] Cos[#1]) - (Sin[#1] Cos[#1])^3/(Sin[#1])^2 + 4 (Cos[#1]) (Sin[#1]) (Cos[#1]^2 - Sin[#1]^2)) &
Again, the solution to this is essentially erasing the '&'s systematically (except the very last one); but I don't know how to make it work. Any help would be greatly appreciated!!