Re: Questions about Abs[_]
- To: mathgroup at smc.vnet.net
- Subject: [mg55531] Re: [mg55511] Questions about Abs[_]
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Mon, 28 Mar 2005 02:42:07 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
On 27 Mar 2005, at 09:42, Steeve Brechmann (schumi) wrote:
>
> Hi,
>
> I define,
>
> G0[r_List, r0_List]:=(Exp[I k
> Norm[r-r0]/(4*Pi*Norm[r-r0]))*((1+(I/(k*Norm[r-r0]))-(1/(k^2*Norm[r-
> r0]^2)))*IdentityMatrix[3]-(1/Norm[r-r0]^2)*(1+((3*I)/(k*Norm[r-r0]))-
> (3/(k^2*Norm[r-r0]^2)))*Outer[Times,r-r0,r-r0])
Your code does not work. It can't be the one you have actually used.
>
> where
>
> r = {x,y,z}
> r0={x0,y0,z0}
> ri={x0,y0,-z0}
> rsn=r0+{0,0,2*n*d}
> rim=ri+{0,0,2*m*d}
>
> When i want to compute
>
> G0r0rim=G0[r0,rim]
>
> I find something odd...
>
> 1) Why Abs[2*z0-2*d*m] doesn't give 2*Abs[z0-m*d] ?
Why should it? Even Simplify won't convert Abs[2*z0-2*d*m] to
2*Abs[z0-m*d] because, first of all, Simplify does not use a
transformation function that would do this and secondly even if it did
the default complexity of the two expressions is the same. So if you
really insist on this transformation you will have to do something
like:
f[expr_] := expr /. Abs[(k_)*x] :> k*Abs[x] /; k > 0
Simplify[Abs[2*z0 - 2*d*m], TransformationFunctions ->
{Automatic, f}, ComplexityFunction ->
(1/Depth[#1] + LeafCount[#1] & )]
2*Abs[z0 - d*m]
This Depth increasing ComplexityFunction is not very natural and may
well do undesirable things to the rest of your expression so it may be
better to look for something better that makes k*Abs[x] less complex
than Abs[k*x]. However, I can't see anything obvious and natural at the
same time so
if you do not mind factoring other subexpressions you might prefer to
use something like this:
Map[Factor, Sin[2*x + 2] + Abs[2*z0 - 2*d*m] + (2*z0 - 2*d*m)^2, {1,
Infinity}]
4*(d*m - z0)^2 + 2*Abs[d*m - z0] + Sin[2*(x + 1)]
>
> 2) Why Abs[2*z0-2*d*m] doesn't simplify with (2*z0-2*d*m)^2 ?
??
Andrzej Kozlowski