## Solving integral involving absolute value of a vector

I am trying to integrate the following in mathematica:
$$\int_0^r \frac{exp(-k_d(|\vec{r}-\vec{r_j}|+|\vec{r}-\vec{r_i}|)}{|\vec{r}-\vec{r_j}|\times|\vec{r}-\vec{r_i}|}r^2dr$$.
I have first defined, the following functions,
$$\vec p(x,y,z)= (x-x_j)\hat i + (y-y_j)\hat j+(z-z_j)\hat k$$
Similarly,
$$\vec q(x,y,z)= (x-x_i)\hat i + (y-y_i)\hat j+(z-z_i)\hat k$$.
And,
$$\vec r(x,y,z)=x\hat i + y\hat j+z\hat k$$
Then I clicked the integration symbol in the classroom assistant panel and typed the integrand in the $$expr$$ portion. While typing this, I have used $$Abs$$ to take modulus of the functions $$\vec p(x,y,z)$$ and $$\vec q(x,y,z)$$ . I have included the limits as $$0$$ to $$Abs(r)$$ and the $$var$$ as $$r$$ in the integration symbol. But when I press( Shift + Enter ) no output value is shown . Can anyone tell me where I have made mistake ?

## Fitting an integral function given a set of data points

I have a set of measures of the resistivity of a given material at different thicknesses and I’m trying to fit them using the Fuchs-Sondheimer model. My code is:

data = {{8.1, 60.166323}, {8.5, 47.01784}, {14, 52.534961}, {15,     50.4681111501753}, {20, 39.0704975714401}, {30,     29.7737879177201}, {45, 22.4406}, {50, 15.2659673601299}, {54,     18.189933218482}, {73, 14.8377093467966}, {100,     15.249523361101}, {137, 15.249523361101}, {170,     10.7190970441753}, {202, 15.249523361101}, {230, 10.9744085456615}}  G[d_, l_, p_] := NIntegrate[(y^(-3) - y^(-5)) (1 - Exp[-yd/l])/(1 - pExp[-yd/l]), {y,0.01, 1000}];  nlm  = NonlinearModelFit[data, 1/(1 - (3 l/(2 d)) G [d, l, p]) , {{l, 200}, {p, 4}}, d, Method -> NMinimize] 

However it returns me these errors:

NIntegrate::inumr: The integrand ((1-E^(-(yd/l))) (-(1/y^5)+1/y^3))/(1-pExp[-(yd/l)]) has evaluated to non-numerical values for all sampling points in the region with boundaries {{0.01,1000}}. 
NonLinearModelFit: the function value is not a real number at {l,p} = {200.,4.} 

I think that the problem is in the way in which I defined the integral function G[d, l, p], because I had to fit a different set of data points with a different function of only one variable which I defined through the NIntegrate function and it gave me no error. Could anyone please help me?

## How do I use Solve to find a variable in the integral?

I have the following formula: $$t(a) = \frac{1}{H_0}\int_0^a \frac{da’}{\sqrt{\Omega_{r,0}a^{-2} + \Omega_{m,0}a^{-1}+\Omega_{\Lambda,0}a^2 + (1-\Omega_0)}}$$ I want to go in the opposite direction. That is, I want to know what a is given t. $$a(t) = ??$$ Can I use Solve to find this value?

## Solve Improper Integrate using Residue theorem for this integral [migrated]

I am trying to solve this integral

$$\int_{-\infty}^\infty \frac{x\cdot sin(x)}{x^2+4} \cdot dx$$

I have applied the residue theorem on a semicircle of radius $$R> 2$$, $$\gamma$$, so I have

$$\int_\gamma \frac{z\cdot sin(z)}{z^2+4} \cdot dz = \int_{-R}^R \frac{x\cdot sin(x)}{x^2+4} \cdot dx+ \int_{C_R} \frac{z\cdot sin(z)}{z^2+4} \cdot dz$$

where $$C_R = \{ z : z=R e^{i \theta} , \theta \in (0,\pi)\}$$, but I cannot limit the second integral to eliminate this contribution when $$R \to \infty$$ and I don’t know how I could do the integral in another way

## Plot integral expression

Trying to plot in Mathematica with an integral as the iterator

Plot[x, {Integrate[1/Sqrt[0.31*x + 0.68*x^4 + 0.01*x^2], x], 0, 10^7}] 

But get the error that it the integral can’t be used as an iterator. On the other hand if I try

Plot[Integrate[1/Sqrt[0.31*x + 0.68*x^4 + 0.01*x^2], x], {x, 0, 10^7}] 

I get the ‘invalid integration variable or limit’ error.

## NIntegrate does not evaluate this finite integral composed of divergent parts

I would like to numerically evaluate the following integral:

$$I = \int_{-\infty}^\infty d\tau_3 \int_{-\infty}^\infty d\tau_4 \frac{1}{1+\tau_3^2} \left\lbrace \frac{2}{1+\tau_4^2} \log (\tau_3 – \tau_4)^2 + \left(\frac{1}{1+\tau_3^2} + \frac{1}{1+\tau_4^2} \right) \phi(\tau_3,\tau_4) \right\rbrace \tag{1}$$

with $$\phi(r,s)$$ a complicated function as defined in the code below. Note that the first term with the log is divergent, but that this divergence is canceled by another divergence present in the 2nd term with the $$\phi$$-function. When I try to evaluate the integral, NIntegrate stays unevaluated. Why is that, and what is the numerical value of this integral?

Here is the code I used so far:

S[\[Tau]3_, \[Tau]4_] := (\[Tau]3 - \[Tau]4)^2/(1 + \[Tau]3^2); a[\[Tau]3_, \[Tau]4_] := 1/4 Sqrt[4*R[\[Tau]3, \[Tau]4]*S[\[Tau]3, \[Tau]4] - (1 - R[\[Tau]3, \[Tau]4] - S[\[Tau]3, \[Tau]4])^2] ;  F[\[Tau]3_, \[Tau]4_] := I Sqrt[-((1 - R[\[Tau]3, \[Tau]4] - S[\[Tau]3, \[Tau]4] - 4 I*a[\[Tau]3, \[Tau]4])/(1 - R[\[Tau]3, \[Tau]4] - S[\[Tau]3, \[Tau]4] + 4 I*a[\[Tau]3, \[Tau]4]))]; phi[\[Tau]3_, \[Tau]4_] := 1/a[\[Tau]3, \[Tau]4] Im[PolyLog[2, F[\[Tau]3, \[Tau]4]*Sqrt[R[\[Tau]3, \[Tau]4]/S[\[Tau]3, \[Tau]4]]] + Log[Sqrt[R[\[Tau]3, \[Tau]4]/S[\[Tau]3, \[Tau]4]]] Log[1 - F[\[Tau]3, \[Tau]4]*Sqrt[R[\[Tau]3, \[Tau]4]/S[\[Tau]3, \[Tau]4]]]]; NIntegrate[1/(1^2 + \[Tau]3^2) (2/(1^2 + \[Tau]4^2)Log[(\[Tau]3 - \[Tau]4)^2] + (1/(1^2 + \[Tau]3^2) + 1/(1^2 + \[Tau]4^2)) phi[\[Tau]3, \[Tau]4]), {\[Tau]3, -\[Infinity], \[Infinity]}, {\[Tau]4, -\[Infinity], \[Infinity]}] 

## How to use Trapezoidal Rule for approximating a definite integral from 0 to 30*60 5*v(t)\ dt

velocitydata = {200., 20.895780994409773, 10.986275727656292, 7.662410953506851, 5.998125878448737, 4.999000299900035, 4.332731606838267, 3.8567493313695387, 3.4997265945392857, 3.2220233380309256, 2.9998500112490625, 2.818065371605392, 2.666574078896326, 2.538386439381941, 2.428509477589222, 2.3332814832098125, 2.249956055974918, 2.176432934011989, 2.1110785329900605, 2.0526031497377395, 1.9999750004687404, 1.9523588169189425, 1.9090711873829898, 1.8695475468930842, 1.8333174191886965, 1.7999856001727976, 1.7692176833495532, 1.7407288016266662, 1.714274781445695, 1.6896451269910564, 1.6666574074845673, 1.645152730757279, 1.6249920654878016, 1.6060532320957523, 1.5882284246323966, 1.5714221574736715, 1.5555495542185434, 1.540534914053686, 1.526310504474162, 1.512815539733553, 1.4999953125219725, 1.4878004527119568, 1.4761862919948983, 1.4651123171705347, 1.4545416979860029, 1.4444408779281612, 1.4347792183895953, 1.4255286882592237, 1.4166635923132485, 1.408160332863668, 1.3999972000084, 1.3921541865573845, 1.3846128243129732, 1.3773560388842774, 1.3703680206329807, 1.3636341096975493, 1.3571406933360788, 1.350875114074985, 1.3448255873594115, 1.3389811275780437, 1.3333314814853396, 1.3278670681722977, 1.3225789248464297, 1.317458657775475, 1.3124983978300822, 1.3076907601301937, 1.3030288073598948, 1.2985060163674613, 1.2941162477124264, 1.2898537178607008, 1.285712973762941, 1.2816888695812, 1.2777765453550067, 1.2739714074208954, 1.27026911041953, 1.266665540742242, 1.2631568012844059, 1.259739197386856, 1.2564092238587217, 1.253163552985859, 1.2499990234386442, 1.2469126300014062, 1.2439015140533525, 1.240962954737622, 1.2380943607611097, 1.2352932627731243, 1.2325573062757642, 1.2298842450232272, 1.2272719348711656, 1.2247183280406884, 1.222221467764759, 1.2197794832875768, 1.2173905851900841, 1.2150530610170482, 1.2127652711832684, 1.2105256451383326, 1.2083326777710777, 1.2061849260364514, 1.204081005788894, 1.2020195888076308, 1.19999940000045, 1.1980192147735902, 1.1960778565563392, 1.1941741944698308, 1.192307141130332, 1.1904756505780585, 1.1886787163232235, 1.1869153695016552, 1.1851846771328776, 1.1834857404740797, 1.181817693463864, 1.180179701250117, 1.1785709587967457, 1.1769906895643907, 1.1754381442605732, 1.1739125996550557, 1.172413357456473, 1.170939743246574, 1.1694911054686528, 1.1680668144669837, 1.166666261574285, 1.1652888582444303, 1.1639340352278151, 1.162601241786949, 1.1612899449500012, 1.1599996288001782, 1.1587297937989383, 1.1574799561411815, 1.1562496471406645, 1.155038412644, 1.1538458124717037, 1.15267141988484, 1.1515148210759136, 1.150375614682726, 1.1492534113239998, 1.1481478331556445, 1.1470585134465943, 1.1459850961732263, 1.14492723563141, 1.1438845960653052, 1.142856851312065, 1.1418436844616617, 1.1408447875310836, 1.1398598611522026, 1.1388886142726473, 1.137930763869054, 1.1369860346721006, 1.1360541589027657, 1.1351348760192783, 1.1342279324742568, 1.1333330814815654, 1.1324500827924304, 1.1315787024803974, 1.1307187127347191, 1.1298698916617953, 1.1290320230942965, 1.1282048964076306, 1.1273883063434234, 1.1265820528397013, 1.1257859408674835, 1.1249997802735017, 1.1242233856287802, 1.1234565760828248, 1.1226991752231794, 1.1219510109401198, 1.1212119152962696, 1.120481724400925, 1.1197602782888993, 1.1190474208036916, 1.1183429994848042, 1.1176468654590366, 1.1169588733355942, 1.116278881104856, 1.1156067500406535, 1.114942344605917, 1.1142855323615606, 1.1136361838784714, 1.112994172652481, 1.1123593750222056, 1.1117316700896378, 1.1111109396433867};

## Integral $\int_{d_1}^{d_2} \int_{-L/2}^{L/2} \int_{-L/2}^{L/2} \frac{1}{(x^2+y^2+z^2)^3} dx dy dz$

I’m trying to integrate the following integral in the Mathematica, but it seems it doesn’t return an analytical closed form, neither numbers when I give values for both $$d_{1,2}$$ and $$L$$.

$$\int_{d_1}^{d_2} \int_{-L/2}^{L/2} \int_{-L/2}^{L/2} \frac{1}{(x^2+y^2+z^2)^3} dx dy dz$$

Is there any trick that might be useful for this case?

## Why does Mathematica return imaginary results for this integral?

(1/h)*Integrate[-Log[Abs[Cos[x]]], {x, a, h}] `

This integral should be real-valued.