0
|
4961 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
GROUPS:

# Using Series for a function with NIntegrate

Posted 9 years ago
 Hi everyone, This is my first discussion so I hope I type it well. I've made equations for the magnetic field of two elliptical shaped coils with a distance 2d between them, with the magnetic fields repelling each other. The equations for the x-,y-, and z-component of the magnetic field are: bx[x_?NumericQ, y_?NumericQ, z_?NumericQ] := mu0*i*b*n/(4*Pi)* NIntegrate[((z + d)/(x^2 + y^2 + (z + d)^2 + a^2*Cos[t]^2 + b^2*Sin[t]^2 - 2*a*x*Cos[t] - 2*b*y*Sin[t])^(3/2) - (z - d)/(x^2 + y^2 + (z - d)^2 + a^2*Cos[t]^2 + b^2*Sin[t]^2 - 2*a*x*Cos[t] - 2*b*y*Sin[t])^(3/2)) Cos[t], {t, 0, 2 Pi}] by[x_?NumericQ, y_?NumericQ, z_?NumericQ] := mu0*i*a*n/(4*Pi)* NIntegrate[((z + d)/(x^2 + y^2 + (z + d)^2 + a^2*Cos[t]^2 + b^2*Sin[t]^2 - 2*a*x*Cos[t] - 2*b*y*Sin[t])^(3/2) - (z - d)/(x^2 + y^2 + (z - d)^2 + a^2*Cos[t]^2 + b^2*Sin[t]^2 - 2*a*x*Cos[t] - 2*b*y*Sin[t])^(3/2)) Sin[t], {t, 0, 2 Pi}] bz[x_?NumericQ, y_?NumericQ, z_?NumericQ] := mu0*i*n/(4*Pi)* NIntegrate[(1/(x^2 + y^2 + (z + d)^2 + a^2*Cos[t]^2 + b^2*Sin[t]^2 - 2*a*x*Cos[t] - 2*b*y*Sin[t])^(3/2) - 1/(x^2 + y^2 + (z - d)^2 + a^2*Cos[t]^2 + b^2*Sin[t]^2 - 2*a*x*Cos[t] - 2*b*y*Sin[t])^(3/2)) (a*b - a*y*Sin[t] - b*x*Cos[t]), {t, 0, 2 Pi}]  With constants mu0 = 4*Pi*10^(-7) (*The magnetic permeability of air*); i = 1 (*The current in Ampère*); a = 2*10^-3 (*Distance between origin and ellipse along x in m*); b = 10^-3 (*Distance between origin and ellipse along y in m*); d = 10^-3 (*Distance between the origin of the ellipse and z=0 in m*); n = 255 (*Number of windings*);  I admit the fields look a bit messy, but they can be seen as bx[x,y,z] = constant*NIntegrate[x,y,z]. I want to approximate these fields with a polynomial to the first degree, including cross terms. But using Series just gives  In[30]:= Series[bx[x,0,0],{x,0,1}] During evaluation of In[30]:= NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in t near {t} = {6.28318519448951320385675257047976413268819406710008479421958327293}. NIntegrate obtained -1.05501*10^-10 and 2.0480060268125716*^-7 for the integral and error estimates. >> Out[30]= -2.69029*10^-18+(bx^(1,0,0))[0,0,0] x+O[x]^2  Which does not give a polynomial. Using NSeries gives In[29]:= NSeries[bx[x,0,0],{x,0,1}] Out[29]= (1.02479*10^-10+3.70742*10^-26 I)/x+(6.4359*10^-27-6.58008*10^-27 I)-(1.01518*10^-10+3.68387*10^-26 I) x+O[x]^2  But this is not right because when I plot bx[x,0,0] I see that it looks almost like a linear function bx[x,0,0] = 30x. Eventually I want to evaluate something like: Series[bx[x,y,z],{x,0,1},{y,0,1},{z,0,1}]  Thanks in advance, Ian
3 Replies
Sort By:
Posted 9 years ago
 You could differentiate the functions numerically. In[1]:= mu0 = 4*Pi*10^(-7) (*The magnetic permeability of air*); i = 1 (*The current in AmpĂ¨re*); a = 2*10^-3 (*Distance between origin and ellipse along x in m*); b = 10^-3 (*Distance between origin and ellipse along y in m*); d = 10^-3 (*Distance between the origin of the ellipse and z=0 in m*); n = 255 (*Number of windings*); In[7]:= bx[x_?NumericQ, y_?NumericQ, z_?NumericQ] := mu0*i*b*n/(4*Pi)* NIntegrate[((z + d)/(x^2 + y^2 + (z + d)^2 + a^2*Cos[t]^2 + b^2*Sin[t]^2 - 2*a*x*Cos[t] - 2*b*y*Sin[t])^(3/2) - (z - d)/(x^2 + y^2 + (z - d)^2 + a^2*Cos[t]^2 + b^2*Sin[t]^2 - 2*a*x*Cos[t] - 2*b*y*Sin[t])^(3/2)) Cos[t], {t, 0, 2 Pi}] In[8]:= (bx[10^-3, 0, 0] - bx[-10^-3, 0, 0])/(2 10^-3) Out[8]= 35.7709 `
Posted 9 years ago
 Using Taylor series on the integrand around (0,0,0) does not really help because it is an elliptic integral. In other words: the cosines and sines are the real problems here, and it is not possible to use the series on them because they run from 0 to 2 pi. Therefore, I think the only option is to use the series after the integration, but I could be wrong.
Posted 9 years ago
 Could you do a Taylor series by differentiating the function inside NIntegrate?