MathGroup Archive 2007

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

Search the Archive

Re: a problem with integrate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg72687] Re: a problem with integrate
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Mon, 15 Jan 2007 05:27:32 -0500 (EST)
  • Organization: The Open University, Milton Keynes, UK
  • References: <eocsb3$6st$1@smc.vnet.net>

starryin wrote:
> 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]
-----------^
You have a syntax error: the symbol for exponential is E.

> 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!
> 

Note that you do not need to wrap your expression with N. What you must 
do is to ensure that the function f is called only for numerical values. 
(See [1] for detail explanation.)

In[1]:=
g[x0_, y0_, y1_, z1_] := (1/10)*Sqrt[x0^2 + (y1 - y0)^2 + z1^2]*
    (Abs[y1 - y0]/x0 + 1)
f[(y_)?NumericQ, (z_)?NumericQ, (y1_)?NumericQ, (z1_)?NumericQ,
    (x0_)?NumericQ, (y0_)?NumericQ] :=
   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, 2.44},
    {y1, 0, 69}, {z, 0, 2.44}, {y, 30.84, 34.5}]
D1[3, 5]

Out[4]=
0.209833

Regards,
Jean-Marc

[1]  "How do I write a function which evaluates only when the argument 
is a number?" 
http://support.wolfram.com/mathematica/kernel/features/evalwhennumber.html


  • Prev by Date: Re: Limit and Root Objects
  • Next by Date: plot question
  • Previous by thread: Re: a problem with integrate
  • Next by thread: Re: a problem with integrate