Message Boards Message Boards

0
|
6856 Views
|
12 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Can coordinate description cause numerical integrals to vary?

Posted 9 years ago

The title does not quite capture the issue. I have a function I am integrating over a spherical volume, actually two spherical volumes. I define a vector that originated within one volume and terminates in the second volume. I now integrate this vector function over both volumes.

When I set up the integrand in spherical coordinates vs using cylindrical coordinate...by symmetry it is easy to use either coordinate system...the numerical integration does not give the same results. There is a persistent "bias" in the spherical coordinate system. It is easy to determine which approach is in error since there is a limit each integral should parametrically approach.

If I have in fact not made an error in the integrand in one or the other coordinate system, is this outcome a possibility using numerical integation? The integrals are not analytical.

I can get into more details but first I would like to know if there is something "quirky" in Mathematica relating to such an issue.

POSTED BY: Luther Nayhm
12 Replies

Two possible leads come to mind. One is that the overlap between the two volumes may have been incorrectly described in one of the two coordinate systems. The other is that your vector may be discontinuous precisely in the region where one coordinate system is singular.

POSTED BY: Gianluca Gorni
Posted 9 years ago

Good points, but the two volumes do not overlap and the integrands have no poles. I am betting on my having made some stupid mistake and am blind to it.

Refer to the attachment: I have two non-overlapping volumes with a common z-axis with individual coordinates located a distance d apart located at the symmetrical center of the objects...spheres. Each coordinate system is independent except for the z-axis separation d linking the two systems. I found that Mathematica does not render the functional form for the vector in the most efficient grouping of terms for the integration, so I help it out by manually expanding and grouping terms into a linear string. In doing so, the vector does result in a common angular term given by Cos[t2-t1}, where t stands for theta and 1 and 2 are the separate coordinate systems. There are also other common terms such as Sin[t1]Sin[t2} etc. This just a standard expansion of the components in the xyz coordinate systems expressed in either spherical or cylindrical coordinates and then the length of the vector found by taking the square root of the sum of the squares of the three components. Basic algebra and trigonometry. No poles and no zeros.

The irony is that I set the problem up in the two coordinate systems to check that I was NOT making a mistake. Now I don't have any way of telling which is correct, except in the limit of large d, the integrand should approach a constant value of 1, since I am normalizing the integrand with another analytical function that does behave properly. No manipulations of precision or accuracy change the values that are calculated. I use ListPlot[Table[NIntegrate]]] to see what values I have calculated and I cannot get rid of the unwanted and unexpected "bias"...and the resulting integrated value is always larger than the comparable values calculated using cylindrical coordinates.

I have set up the integrand a dozen times starting from scratch, so either I am making the same mistake over and over or else Mathematica is doing something funky.

Attachments:
POSTED BY: Luther Nayhm

Luther, if you could post some code it might make it easier to have a look.

POSTED BY: Jason Biggs
Posted 9 years ago

OK, attached.

Attachments:
POSTED BY: Luther Nayhm
Posted 9 years ago

Stumped, huh? I have continued to look for a stupid error but cannot find one.

However, here's a thought. The attached plot shows a type of consistent behavior. This plot should be flat, unity, with very little slope if any. But the origin always shows a small bias and the rest of the plot shows an increase in value when it should not. Could this be a rounding error of some sort? Could the integrand be numerically integrated differently when there are as many angular functions as for this one? The denominator has the appearance of a function when integrated produces an elliptical integral, only with a more complex argument.

I have not tried to force the integration method, yet, but maybe selecting the method may change the results. I will experiment and get back with you.

Attachments:
POSTED BY: Luther Nayhm
Posted 9 years ago

I introduced various methods and rules into the numerical integration...one at a time. These are indicated in the new attachment.

While the bias appears to be an artifact of some sort, the methods used caused the results to be closer to what was expected. However, in all cases, as the variable parameter was adjusted, the results all either increase or decreased as shown in the attachment.

I am still at a loss to understand how the results can be so variable and, for me, useless.

Does the new work advance the discussion or is it hopeless bogged down in unknowns?

Attachments:
POSTED BY: Luther Nayhm

Interesting. But the integrand in your notebook is not a vector-function (which should have three components - ok, this gave only three independent integrands). What do you really want to do?

Could you show what you are doing in cylindrical coordinates?

And:

"except in the limit of large d, the integrand should approach a constant value of 1"

If I am not completely wrong the integrand you give in your notebook should tend to zero for d -> Infinity (Numerator d (more precisely d r1^2 r2^2 Sin[p1]Sin[p2], denominator (d^2)^(3/2) = d^3 )

POSTED BY: Hans Dolhaine
Posted 9 years ago

I can see I have confused you good folks. I apologize.

The first attachment, Z.docx, shows how I form the vector between the two objects...spheres or in some cases disks. I then take the magnitude of this vector and combine like terms. Mathematica does not do it automatically in a form that is efficient...when I combine terms I get Cos[t2-t1} and thereby lose other trigonometric functions.

This vector length connects two volume elements which can contain charge. I am looking for the mutual interaction between these elemental forces integrated over the whole volumes....I don't want to use the point-charge model except to model the point-charge interactions between the elemental volumes. In cylindrical coordinates, I want to find the mutual attraction between the plates of a capacitor exactly by using areal charge densities...or I can find the mutual attraction or repulsion for volume charges, too.

Since I am using force, I also want to find the Cosine of each elemental mutual force, which by symmetry is the only net non-zero mutual force, so I multiply the inverse-square function by Cos of each incremental vector with the z-axis....this is just the Z component divide by the total vector length. Therefore, when the parameter d...the separations of the centers of each volume or areal distribution goes to infinity, the total integral goes to unity, since I am dividing by the traditional inverse square model that only considers the value of inverse d square and does go to zero.

I believe what may be happening is that the numerator and denominator integrals get so small that I am approaching dividing zero by zero...or at least dividing two very small numbers by one another. The working hypothesis is that at large separations the two integrals approach the same value. In cylindrical coordinates, things seem to work out well, but the same problem set up in spherical coordinates does not "behave," which is what I am grappling with.

I have attached a new worksheet with both the spherical and the cylindrical models for comparison.

Attachments:
POSTED BY: Luther Nayhm
Posted 9 years ago

I have continued to look into what may be occurring. Is it possible that the way Mathematica treats variables as complex variables that I am getting into branch-cut problems with the spherical coordinate system? I thought that by defining the limits of integration I could eliminate that issue, but if that is not so, then how do I determine if I am having branch cut issues and how might I resolve those issues?

It has been a long time since I worked with complex variables, so be gentle.

POSTED BY: Luther Nayhm

I understand you want to calculate the interaction between the two spheres. If I do it I do not find a difference between using polar or cylindrical coordinates for sphere2. See notebook. Ok., there is a small difference, but that is certainely due to numerical errors in the integration.

regards hd

Attachments:
POSTED BY: Hans Dolhaine
Posted 9 years ago

Interesting approach. Much more compact than my own, which is simply klunky lumping everything into one statement.

I will play with your code and see if I find how or why my calculations are so divergent.

This took a bit of effort on your part and I appreciate your efforts. I am unfamiliar with some of you syntax but I will follow up with a postmortem.

When I executed your equivalence statements, the first one simply ran until I aborted and then did it again, at which point it executed instantly. I have had that issue before in defining some function. I also notice that when I copy and paste, sometimes I have to delete and reenter certain code for it to execute. Not sure why it is happening.

But thanks again for your efforts.

POSTED BY: Luther Nayhm
Posted 9 years ago

I think I found an error.

If you would, could we take this part of the discussion off line, because it does not add to addressing my initial question.

Once we get past this issue we can resume the discussion here.

Luther@LutherNayhm.org

POSTED BY: Luther Nayhm
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract