|
[Date Index]
[Thread Index]
[Author Index]
Re: Interesting failure of Collect
- To: mathgroup at smc.vnet.net
- Subject: [mg61337] Re: Interesting failure of Collect
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Sun, 16 Oct 2005 00:17:53 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <dipqve$hdt$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Blimbaum, Jerry CIV NSWC PC wrote:
> Given the expr = Sin[p]/(4 Pi a) + Sin[p]/(4 Pi b)
>
> and then applying the command
>
>
> Collect[expr, Sin[p]/(4 Pi)] works as it should, however,
>
> expr2 = Sin[p]/(4 Pi a) - Sin[p]/(4 Pi b)
>
> leaves the expression untouched. (I realize I could use Simplify but
> this problem occurred on a much longer expression and this is intended
> just to convey the basic idea)....for longer expressions the Collect
> process works for all quantities with a + sign but the one with a minus
> sign will not be collected.....strikes me as a "bug".....
>
>
> thanks....jerry blimbaum
>
>
Hi Jerry,
I have got the same behavior with Mathematica 5.2 for Windows XP (see
below). One workaround is to add -- or more precisely to replace the
negative sign by -- an additional parameter, say c, as in the following
example, and to use a replacement rule to change the parameter c by -1.
*Collect* seems to work correctly in this case.
In[8]:=
expr = Sin[p]/(4*Pi*a) + Sin[p]/(4*Pi*b)
Out[8]=
Sin[p]/(4*a*Pi) + Sin[p]/(4*b*Pi)
In[9]:=
Collect[expr, Sin[p]/(4*Pi)]
Out[9]=
((1/a + 1/b)*Sin[p])/(4*Pi)
In[10]:=
expr2 = Sin[p]/(4*Pi*a) - Sin[p]/(4*Pi*b)
Out[10]=
Sin[p]/(4*a*Pi) - Sin[p]/(4*b*Pi)
In[11]:=
Collect[expr2, Sin[p]/(4*Pi)]
Out[11]=
Sin[p]/(4*a*Pi) - Sin[p]/(4*b*Pi)
In[12]:=
expr3 = Sin[p]/(4*Pi*a) + c*(Sin[p]/(4*Pi*b))
Out[12]=
Sin[p]/(4*a*Pi) + (c*Sin[p])/(4*b*Pi)
In[13]:=
Collect[expr3, Sin[p]/(4*Pi)] /. c -> -1
Out[13]=
((1/a - 1/b)*Sin[p])/(4*Pi)
In[14]:=
$Version
Out[14]=
"5.2 for Microsoft Windows (June 20, 2005)"
Best regards,
/J.M.
Prev by Date:
Re: Re: Compile nested loops with depending index variables...
Next by Date:
Re: problem solving polynomial equations
Previous by thread:
Re: Interesting failure of Collect
Next by thread:
surface fitting question
|