[Date Index]
[Thread Index]
[Author Index]
Re: ReplaceAll and ReplaceRepeated Strange Behavior
*To*: mathgroup at smc.vnet.net
*Subject*: [mg111484] Re: ReplaceAll and ReplaceRepeated Strange Behavior
*From*: Eric Loots <eric.loots at gmail.com>
*Date*: Tue, 3 Aug 2010 06:35:48 -0400 (EDT)
Hi,
I'm new to this group, but I'll have a go at this.
The rule dm*Pi -> L/Tan[a] must look for matches of the pattern. I
guess that the pattern just doesn't match in all cases. When you look
at the output after entering the first line of input, you see that one
of the dm * Pi terms is rearranged.
A simple solution to your problem is to apply another for of the rule:
dm -> L / Pi / Tan[a]
Adding Simplify on top of that:
(L*(-L*mu + dm*Pi*Cos[b]))/(dm*Pi*(dm*Pi*mu + L*Cos[b])) /. dm -> L /
=CF=80/Tan[a] // Simplify
gives:
(Cos[b] - mu Tan[a])/(Cos[b] + mu Cot[a])
With respect to copy/paste from a Notebook to the group, I'm using
regular mail to post this reply, and an ordinary copy/past just works.
Regards -- Eric
On 02 Aug 2010, at 13:04, blamm64 wrote:
> Given the expression:
>
> eff == (L*(-L*mu+dm*Pi*Cos[b]))/(dm*Pi*(dm*Pi*mu+L*Cos[b]))
>
> After this I enter
>
> eff /. {dm*Pi -> L/Tan[a]}
>
> and get a result that does not, for a reason I cannot fathom and
> believe to be a bug, replace one instance of dm*Pi. The result of the
> evaluation yields
>
> L*(-L*mu+L*Cos[b]*Cot[a])/(dm*Pi*(L*Cos[b]+L*mu*Cot[a]))
>
> Precisely the same result occurs with eff //.{dm*Pi->L/Tan[a]}
>
> Why is the one remaining dm*Pi not replaced with L/Tan[a]?
>
> In fact, when define manually define eff1 as
>
> eff1 == (L*(-L*mu + L*Cos[b]*Cot[b]))/(dm*Pi*(L*Cos[b]+L*mu*Cot[a]))
>
> which is as you can see the result of the first ReplaceAll execution,
> and then enter
>
> eff1 /. {dm*Pi->L/Tan[a]}
>
> Mathematica returns eff1 unaltered!
>
> Now, I say this is a bug, so of course I'm probably missing something
> and it isn't a bug. I have to jump through syntactic hoops to get the
> 'right' answer:
>
> FullSimplify[eff /.{dm*Pi->L/Tan[a]}]/.{dm*Pi->L/Tan[a]}//FullSimplify
>
> and FullSimplify[eff /. {dm*Pi->L/Tan[a]} does no good either.
>
> It is not at all obvious to me what I might be missing with such an
> apparently simple replacement.
>
> By the way, how do you guys copy input or output from Mathematica
> notebook into this usergroup window? I had to do all this by hand,
> copy it from here into a notebook, and execute the notebook cells just
> to make sure I was getting it correct. I ran across this originally
> when I was constructing a simple notebook for doing some Acme power
> screw calculations.
>
> -Brian Lamm
> (Windows XP x64 Version 2003 SP2, Mathematica 7.0.1)
>
Prev by Date:
**Re: A distribution problem using Mathematica**
Next by Date:
**Re: Bare Bones Backup Button**
Previous by thread:
**Re: ReplaceAll and ReplaceRepeated Strange Behavior**
Next by thread:
**Re: ReplaceAll and ReplaceRepeated Strange Behavior**
| |