MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: a problem with integrate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg72678] Re: a problem with integrate
  • From: Peter Pein <petsie at dordos.net>
  • Date: Mon, 15 Jan 2007 04:51:19 -0500 (EST)
  • References: <eocsb3$6st$1@smc.vnet.net>

starryin schrieb:
> hello everyone,i'm a student in China.i meet with a problem when i
> using mathematica to do this expression
> 
> ?[x0_, y0_, y1_, z1_] := N[(1/10)*Sqrt[x0^2 + (y1 - y0)^2 +
> z1^2]*(Abs[y1 - y0]/x0 + 1)]
> f[y_, z_, y1_, z1_, x0_, y0_] := N[1/((2*Pi*?[x0, y0, y1,
> z1]^2)*N[e^(((y - y1)^2 + (z - z1)^2)/(2*?[x0, y0, y1, z1]^2))]),5]
> D1[x0_, y0_] := NIntegrate[f[y, z, y1, z1, x0, y0], {z1, 0, 2.44}, {y1,
> 0, 69}, {z, 0, 2.44}, {y, 30.84, 34.5}]
> 
> after i define the function ,i input D1[3,5] to get one answer ,but i
> got a warning message:
> 
> Integrand epr(i can not paste the expression here) is not numerical at
> {z1, y1, z, y}= {1.22`, 34.5`, 1.22`, 32.67'}.
> 
> who can tell me how can i solve the problem? do i need to use Integrate
> instead of NIntegrate? or do i need to add some other parameter ?
> i' m so sorry that my english is not good enough to express my question
> ?but i still wish some one can solve my problem
> thanks!
> 

Hi,

1.) your variable "e" is undefined. I _guess_ you wanted "E" instead.
2.) there is no need to use N[..] inside your functions, but it should not do
too much harm (I didn't investigate this point further). NIntegrate[] works
already with inexact numbers.
3.) In this case, NIntegrate gives a fast result, when using the option
Method->Multidimensional.

After replacing the unreadable functionname by "g", I get the following:

In[1]:=
g[x0_, y0_, y1_, z1_] :=
  (1/10)*Sqrt[x0^2 + (y1 - y0)^2 + z1^2]*(Abs[y1 - y0]/x0 + 1);

f[y_, z_, y1_, z1_, x0_, y0_] :=
  1/((2*Pi*g[x0, y0, y1, z1]^2)*
    E^(((y - y1)^2 + (z - z1)^2)/(2*g[x0, y0, y1, z1]^2)));

D1[x0_, y0_] :=
  NIntegrate[f[y, z, y1, z1, x0, y0], {z1, 0, 61/25}, {y1, 0, 69},
    {z, 0, 61/25}, {y, 771/25, 69/2}, Method -> MultiDimensional];

D1[3,5]//Timing

Out[4]=
{0.031 Second,0.209833}

Is this result inside the expected range?


Cheers,
Peter


  • Prev by Date: Trouble with reading from file
  • Next by Date: Re: Re: Limit and Root Objects
  • Previous by thread: a problem with integrate
  • Next by thread: Re: a problem with integrate