Re: What is the problem? There are no images and no wrong reports for
- To: mathgroup at smc.vnet.net
- Subject: [mg112364] Re: What is the problem? There are no images and no wrong reports for
- From: peter <justwanglunwei at gmail.com>
- Date: Sat, 11 Sep 2010 05:43:15 -0400 (EDT)
- References: <i6a5dp$kim$1@smc.vnet.net>
On Sep 9, 4:21 pm, Bill Rowe <readn... at sbcglobal.net> wrote: > On 9/7/10 at 2:02 AM, justwanglun... at gmail.com (peter) wrote: > > > > >Hello Mathematica community, I really need some help.... I realized > >there are some mistakes in this program, but I can't find out what > >it is, I keep trying for weeks, still there are some problem, I > >never used Mathematica before > >a==Exp[(-2r^2)/3]; b==BesselJ[0,(r*Sqrt[x^2+y^2])/0.8]; c==r= ^2= > ; > >d==5a; > >Plot[Abs[Integrate[r*b*a*Exp[-I(c+d)]dr,{r,0,=E2=88=9E}]]^2,{x,-0.0 > >,0.01}, {y,-0.01,0.01}] > >=EF=BC=88I is Complex i=EF=BC=89 > > Your email is coming through somewhat garbled. The best way to > post code in email is to select the cell in Mathematica you want > to post and ensure the format of that cell is in InputForm > before doing the copy/paste into email. You can make any cell be > in InputForm by selecting the cell then going to the Cell menu > selecting ConvertTo->InputForm. On a Mac, this also has a > shortcut key of cmd-shift-I. There should be a similar shortcut > on other platforms. Also, it is a good idea to avoid using > special characters such as Greek symbols for something to be > posted. Doing the above will make your post easier to read and > avoid the problem being seen in your post. > > I am going to have to guess a bit as to the source of your > problem. Judging by what appears to be part of an error message > it looks like you might be using a complex variable for the > upper integration limit. But since this part is garbled, I > cannot be sure about this or if this is part of the issue. > > It also appears you are explicitly using dr to be have the usual > meaning this has in a text. That portion of the integral should > not be used when doing integration with Mathematica. The dr term > will be seen by Mathematica as a separate variable with no > dependence on r multiplying the other terms in the integrand. > > The Integrate command should be outside the Plot command or you > should use Evaluate to force evaluation of the integral before > Plot tries to actually plot the integral. > > That is > > g[x_] = Integrate[y Exp[y], {y, 0, x}]; > Plot[g[x], {x, 0, 2}] > > will generate a plot reasonably quickly > > But > > Plot[Integrate[y Exp[y], {y, 0, x}],{x, 0, 2}] > > will also create the same plot but will run much slower since > the integral is being evaluated repeatedly for every value of x > Plot uses to create the graphic. > > Note, hear I used Set (=) not SetDelayed (:=) when defining g. > Had I used SetDelayed here, there would have been no improvement > in time required to generate the plot. > > Also, for this example, I used an integral that has a closed > form solution. For integrals where no closed form solution > exists there won't be much to gain by having the integral > outside the Plot command. But in these cases it is probably > better to use NIntegrate rather than Integrate. i'm sorry for the garbled...thank you for your advise,that's a lot help...