Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.3K Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Can you include Integrate[] in a function definition?

Posted 10 years ago
POSTED BY: Joao M
4 Replies
Posted 10 years ago
POSTED BY: jmcarapuco
Posted 10 years ago

Hi Joao, I suspect the convergence problem occurs for field points inside your slab, where there are nonzero source values. There the calculation of integral values includes cancellations of very large but opposite contributions of nearby source points. I think I see reasonable behavior outside the slab. Please see the attached notebook.

There are contributors to this forum who know a lot more about NIntegrate than I -- maybe one of them will make a comment.

Best, David

Attachments:
POSTED BY: David Keith
Posted 10 years ago

Thank you David, but when using NIntegrate I get this error.

NIntegrate::inumr: The integrand (Sqrt[1-(a-x)^2/(Plus[<<2>>]^2+Plus[<<2>>]^2+Plus[<<2>>]^2)] Sqrt[1-(-b+y)^2/(Plus[<<2>>]^2+Plus[<<2>>]^2+Plus[<<2>>]^2)])/((a-x)^2+(b-y)^2+(c-z)^2) has evaluated to non-numerical values for all sampling points in the region with boundaries {{-(1/400000),1/400000},{-\[Infinity],0.},{-(3/20000000),3/20000000}}. >>

And when I then try Bz[0, 0, 100*10^-9] ( which is a more realistic value for my work than 1,1,1) it tells me the following:

Numerical integration converging too slowly; suspect one of the \
following: singularity, value of the integration is 0, highly \
oscillatory integrand, or WorkingPrecision too small. >>

The odd integrand (Sin[\[Theta][0,0,1/10000000,a,b,c]] \
    Sin[\[Alpha][0,0,1/10000000,a,b,c]])/r[0,0,1/10000000,a,b,c]^2 is \
    being considered as zero over the specified region, but may actually \


be divergent. >>
POSTED BY: Joao M
Posted 10 years ago

It's probably having a difficult time with the symbolic integral. You could use a numerical method with NIntegrate:

In[10]:= 
Bz[x_, y_, z_] := ((\[Mu]*J)/(4*Pi))*
  NIntegrate[(Sin[\[Theta][x, y, z, a, b, c]]*
      Sin[\[Alpha][x, y, z, a, b, c]])/(r[x, y, z, a, b, 
       c])^2, {a, -w/2, 
    w/2}, {b, -\[Infinity], \[Infinity]}, {c, -t/2, t/2}]

In[11]:= 
Bz[1, 1, 1] (*this gives neverending evaluation for example*)

Out[11]= -2.35619*10^-9
POSTED BY: David Keith
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard