Re: condition and pattern matching
- To: mathgroup at smc.vnet.net
- Subject: [mg44892] Re: [mg44885] condition and pattern matching
- From: Daniel Lichtblau <danl at wolfram.com>
- Date: Sat, 6 Dec 2003 04:45:30 -0500 (EST)
- References: <200312051031.FAA09180@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
ram wrote: > > I would like to integrate the function from {0,h}. > > \!\(\((E\^\(\(-I\)\ k\ Abs[\(-h\) + z]\)\/Abs[\(-h\) + z] + > E\^\(\(-I\)\ k\ Abs[h + z]\)\/Abs[h + z] - > \(2\ E\^\(\(-I\)\ k\ Abs[z]\)\ Cos[h\ k]\)\/Abs[z])\)\ Csc[h\ k]\^2\ > Sin[k\ \((h - Abs[z])\)]\) > > Is there any way that I can replace Abs function by its values? I know that > the following cases for condition matching work > > fac[n_ /; n > 0] := n! > m /:Greater[m,n]=True; > fac[m] > gg[m_,n_]:=m-n /; m>n > u/:Greater[u,v]=True; > gg[u,v] > > But I can not find a way to apply above ideas when expressions are > involved. Thanks for any help. > > Ram Kochhar It diverges, due to a singularity at the origin. In[2]:= InputForm[Integrate[ (1/(E^(I*k*Abs[-h + z])*Abs[-h + z]) + 1/(E^(I*k*Abs[h + z])*Abs[h + z]) - (2*Cos[h*k])/(E^(I*k*Abs[z])*Abs[z]))*Csc[h*k]^2*Sin[k*(h - Abs[z])], {z,0,h}, Assumptions->{h>0,k>0}]] Integrate::idiv: 1 2 Cos[h k] Integral of (---------------------------- + <<1>> - ------------------) I k Abs[-h + z] I k Abs[z] E Abs[-h + z] E Abs[z] <<1>> does not converge on {0, h}. Integrate::idiv: 1 2 Cos[h k] Integral of (---------------------------- + <<1>> - ------------------) I k Abs[-h + z] I k Abs[z] E Abs[-h + z] E Abs[z] <<1>> does not converge on {0, h}. Out[2]//InputForm= Csc[h*k]^2*Integrate[(1/(E^(I*k*Abs[-h + z])*Abs[-h + z]) + 1/(E^(I*k*Abs[h + z])*Abs[h + z]) - (2*Cos[h*k])/(E^(I*k*Abs[z])*Abs[z]))* Sin[k*(h - Abs[z])], {z, 0, h}, Assumptions -> {h > 0, k > 0}] The numeric example below may help to show what is happening. You have a term of the form 1/z so the integral diverges logarithmically as you approach the origin from the right. In[14]:= InputForm[NIntegrate[ (1/(E^(I*k*Abs[-h + z])*Abs[-h + z]) + 1/(E^(I*k*Abs[h + z])*Abs[h + z]) - (2*Cos[h*k])/(E^(I*k*Abs[z])*Abs[z]))*Csc[h*k]^2*Sin[k*(h - Abs[z])] /. {k->2.2,h->4.6}, {z,.01,4.6}]] Out[14]//InputForm= -5.610184273698055 - 7.452163944484216*I In[15]:= InputForm[NIntegrate[ (1/(E^(I*k*Abs[-h + z])*Abs[-h + z]) + 1/(E^(I*k*Abs[h + z])*Abs[h + z]) - (2*Cos[h*k])/(E^(I*k*Abs[z])*Abs[z]))*Csc[h*k]^2*Sin[k*(h - Abs[z])] /. {k->2.2,h->4.6}, {z,.001,4.6}]] Out[15]//InputForm= -11.068854032540559 - 7.409240422031397*I In[16]:= InputForm[NIntegrate[ (1/(E^(I*k*Abs[-h + z])*Abs[-h + z]) + 1/(E^(I*k*Abs[h + z])*Abs[h + z]) - (2*Cos[h*k])/(E^(I*k*Abs[z])*Abs[z]))*Csc[h*k]^2*Sin[k*(h - Abs[z])] /. {k->2.2,h->4.6}, {z,.0001,4.6}]] Out[16]//InputForm= -16.583460196486023 - 7.4048907215947875*I In[17]:= InputForm[NIntegrate[ (1/(E^(I*k*Abs[-h + z])*Abs[-h + z]) + 1/(E^(I*k*Abs[h + z])*Abs[h + z]) - (2*Cos[h*k])/(E^(I*k*Abs[z])*Abs[z]))*Csc[h*k]^2*Sin[k*(h - Abs[z])] /. {k->2.2,h->4.6}, {z,.00001,4.6}]] Out[17]//InputForm= -22.103615633575806 - 7.4044551823817875*I Daniel Lichtblau Wolfram Research
- References:
- condition and pattern matching
- From: "ram" <amli@comcast.net>
- condition and pattern matching