MapAt complaint
- To: mathgroup at yoda.physics.unc.edu
- Subject: MapAt complaint
- From: wmm at chem.wayne.edu (Martin McClain)
- Date: Fri, 5 Nov 93 14:46:43 EST
Dear MathGroupers:
I am a fairly experienced Mma user, but quite frequently I cannot
get MapAt to do what I want. My question: Am I missing something obvious,
or does MapAt really need to be extended? Here is the latest example:
I want to go from expr1 = 1+Sin[a+b]+Sin[a-b]
to expr2 = 1 + 2 Cos[a] Sin[b].
Simplify or Factor[#,Trig->True]& does this if applied to parts 2 and 3 of
expr1, but it gets discouraged and does nothing if applied to the whole
thing. So alternatively, I would like to use MapAt to make Simplify work
on parts 2 and 3 together. But I can't find any one-line way to do this.
If you try
MapAt[Simplify,expr1,{{2},{3}}]
it seems to try the two parts separately, producing no change. If you try
MapAt[Simplify,expr1,{{2,3}}]
it thinks you mean MapAt[Simplify,expr1,{2,3}] and complains that there is
no part {2,3}. Of course, it can always be done by extracting,
Simplifying, and replacing, but I am looking for an easy one liner. Any
suggestions?
Thanks- Martin McClain, Chem Dept, Wayne State University, Detroit