Hot answers tagged

11

Some explanations first The substitution in the question introduces the reduced wave function $u(r)$ by solving the original radial equation in polar coordinates, $$-\frac{1}{2}\left(R''(r)+\frac {1}{r}R'(r)\right) - \frac{1}{r}R(r) + \frac {m^2}{2r^2}R(r) = E R(r)$$ using the ansatz $$R(r)\equiv \frac{1}{\sqrt{r}}u(r)$$ The apparently divergent ...


8

The following is not particularly fast and could be more accurate but does make progress toward the goals set in the Question. To begin, consider the analytical properties of f, as defined in the Question. By observation, it has branch points at {I Sqrt[6/5] ξ, I Sqrt[2/5] ξ} and their conjugates. Poles are obtained by p /. ...


4

Changing parameter values during integration works better with DiscreteVariables. But I think the problem with OP's code, in the question and the OP's answer, has more to do with Mathematica numerics. My solution Clear[bind]; zdot = 1/2 (1 - z[t]); ydot = 1/20*y[t] + z[t] - x[t]; xdotbind = D[Solve[-ydot - zdot == 0, x[t]][[1, 1, 2]], t] /. {y'[t] -> ...


4

I am not sure I understand the question 100% but here is what I think you are looking for: {vals3DL0, funs3DL0} = NDEigensystem[-(R''[r]/2) - (R'[r]/r) - (R[r]/r), R[r], {r, 0, 200}, 3, Method -> {"Eigensystem" -> {"Arnoldi", "Criteria" -> "RealPart"}, "SpatialDiscretization" -> {"FiniteElement", {"MeshOptions" -> \ ...


3

The problem is that you are not using large enough precision goal for an oscillatory integrand with very small absolute values over the integration range. Look at the log plot -- there are more oscillations than the ones visible with Plot: The remedy is to use higher precision goal. Try this: NIntegrate[ Re[(x^4 Sin[x b])/(9 + 4 d^2 x^2)^6 1/ 2 ...


3

Below is a workaround for the simple case. The OP can say whether it works more general. I haven't quite tracked down yet why the system is set up incorrectly with the default Method -> {"EquationSimplification" -> "Solve"} and with Method -> {"EquationSimplification" -> "Residual"}. But it works in this case with Method -> ...


2

I'd suggest a simpler approach that seems to work just fine: Use arbitrary precision input if you can. In your case, instead of d -> 0.001/5, use d -> 5/1000 integrand = Re[(x^4 Sin[x b])/(9 + 4 d^2 x^2)^6 1/2 E^(-(1/2) x^2 - I x c - 1/2 a^2) (Erfc[(I x - c)/Sqrt[2]] + E^(2 I x c) Erfc[(I x + c)/Sqrt[2]]) /. {b -> 5, ...


2

Short answer: One workaround is to use Method -> "LevinRule" instead. Long answer: As mentioned by Xavier in a comment above, changing BesselJ[0, x] to BesselJ[0, Re[x]] resolves the issue: NIntegrate[{1, -1} BesselJ[0, Re@x], {x, 0, ∞}, WorkingPrecision -> 32, Method -> "ExtrapolatingOscillatory"] Precision /@ % ...


2

You can also use the built-in functions Expectation or NExpectation taking the function argument x to be uniformly distributed over the interval {a,b}. f[x_] := 1/1000 x^4 - 280/1000 x^2 + 25 Expectation[f[x], Distributed[x, UniformDistribution[{a, b}]]] NExpectation[f[x], Distributed[x, UniformDistribution[{-12, 12}]]] 15.7072 ...


2

See also Average Function and Average Value of a Function. Say you have messured values and express them with the Function f(x): f[x_] := 1/1000 x^4 - 280/1000 x^2 + 25 You can Plot that Function: Plot[f[x], {x, -15, 15}] And you like to find the average value as of -12 ... 12 a = -12; b = 12; solNI = NIntegrate[f[x], {x, a, b}]/(b - a) ...


2

So, after playing around with this problem all day, I finally stumbled upon a version of the code that gives me my desired result, although I'm not at all clear on why it works where other versions fail. First, here is the working version: zdot=.5*(1-z[t]); ydot=.05*y[t]+z[t]-x[t]; ...


2

the culprit here is AccuracyGoal: a = 3; c = 6; d = 0.00033; b = 2; NIntegrate[ x^3 (SphericalBesselJ[0, b x] + SphericalBesselJ[2, b x])/(4 d^2 x^2 + 9)^6 1/ 2 E^(-(1/2) x^2 - I x c - 1/2 a^2) (1 + E^(2 I x c) - I E^(2 I x c) Erfi[(x - I c)/Sqrt[2]] - I Erfi[(x + I c)/Sqrt[2]]), {x, 0, 8}, MaxRecursion -> 22, AccuracyGoal ...


2

I was just inspired by @kglr to illustrate: f[x_] := 1/1000 x^4 - 280/1000 x^2 + 25; sim[a_, b_, n_] := With[{u = RandomVariate[UniformDistribution[{a, b}], n]}, {#, f@#} & /@ u]; Manipulate[ Module[{res = sim[a, b, n], mn = Integrate[f[x], {x, a, b}]/(b - a)}, Show[Plot[f[x], {x, a, b}], ListPlot[res, PlotStyle -> Red], GridLines ...



Only top voted, non community-wiki answers of a minimum length are eligible