# Tag Info

2

I'll use a simpler form for an example. One can keep track of the least value that has given an error/warning message in a variable. It can be set whenever a message is generated using Check. The use of Quiet is optional. You may want to limit the messages that trigger a Check or that are suppressed by Quiet. See their documentation for more. I also ...

3

Try this idea: Plot[If[x < 0, Integrate[Exp[x*z^2], {z, -\[Infinity], \[Infinity]}], None], {x, -1, 1}] Within this example you will get the following plot: Have fun!

1

The error occurs because of the integral extending to Infinity. If I simply do NIntegrate[r*BesselJ[0, 10*r]* (BesselJ[0, Sqrt[0.01/r]] - 1 + BesselJ[1, 1]/ BesselY[1, 1]*(2/Pi*Log[0.5*Exp[EulerGamma]*Sqrt[0.01/r]] - BesselY[0, Sqrt[0.01/r]])), {r, 0.01, 10000}] I get the error NIntegrate::ncvb: "NIntegrate failed to converge to prescribed accuracy ...

3

I think the problem is that your integrand is just too large numerically to be handled correctly. Are you sure the expressions you are using are based on sound model or mathematics? The number they generate are so large. I can't imagine real physical problem will produce such values. Trying just integrating over x by fixing y to see the problem. I went only ...

5

The error I get is that the integrals do not converge. I expect that this is because the empirical PDFs are zero far from the data, and Mathematica does not automatically take $0\log 0$ to be $0$. You can do it explicitly as follows: NIntegrate[With[{f = PDF[smoothDistribution1D, x]}, If[f > 0, f Log[f], 0]], {x, -∞, ∞}] (* -1.4238 *) Compared to the ...

2

It works OK when you set your integration limits correctly and you don't forget the Jacobian: g[r_, theta_, z_] := f[r Cos[theta], r Sin[theta], z] f[x_, y_, z_] := (x + y + z)^2 a = NIntegrate[f[x, y, z] Boole[x^2 + y^2 <= 1.78^2], {x, -2, 2}, {y, -2, 2}, {z, 0.4, 1.4}]; b = NIntegrate[g[r, theta, z] r, {r, 0, 1.78}, {theta, 0, 2 Pi}, {z, 0.4, ...

3

However, evaluating gf does not seem to work When Mathematica returns DifferentialRoot as solution to a differential equation, it really means M could not solve the ODE. This is not the necessarily the case with DifferenceRoot as you found out (I do not know much about DifferenceRoot, but I've seen DifferentialRoot before many times). Here is an ...

1

This question really belongs on physics.stackexchange.com. You can post your propagation equations there using TeX. TeXForm[] will do the conversion for you if you don't know TeX. For a 2-D case around a non-rotating spherical planet as you appear to be attempting, I use these propagation equations with NDSolve[]: {v'[t]==-Sin[\[Gamma][t]] ...

1

Your results are converted to MachinePrecision because you divide by the machine precision number Pi/2.0. You can get exact solutions with Integrate and use N. This will be more accurate than NIntegrate. Block[{m = 4}, p = Table[ Integrate[f[t]*Tn[t]*wt[t], {t, 0, 1}]/(Pi/2), {j, 0, m - 1}]; ] p[[1]] = p[[1]]/2; p (* {-BesselJ[0, π], 0, 2 ...

7

Besides trivial observations that one cannot evaluate numerically integrals involving symbolic constants there are more interesting aspects of the problem at hand. First one should realize that a standard numeric approach is not appropriate for this kind of problems, since the integrand involves singular points (zero in the denominator) thus it is not ...

1

For numeric integration you need to assign numeric values for all parameters (e.g., k) and the product of k and x must include a space (k x) or an asterisk (k*x). With[{k = 1 + I, r1 = 1, r = 1.1}, Table[ nu = -(2 m - 1)/2.; NIntegrate[BesselI[-nu, k x]/x, {x, r1, r}], {m, 6}]] {0.0691516 + 0.0652726 I, 0.00791225 + 0.0454624 I, -0.00714297 ...

0

Ok dude, if you want to get convergence on this type of stiffness you need a "more well posed problem", you can't have too much pendulus and little friction at the same time,for avoid confusion this is just a numerical issue. In other words if you want more Pendulos take there biggers! The problem converge on n=4 if r=10.. I personally think this is a ...

2

From the docs, solConstraint2[x0_, p0_, m_, ω_, time_] := NDSolve[{x'[t] == p[t]/m, p'[t] == -m ω^2 x[t], x[0] == x0, p[0] == p0}, {x, p}, {t, 0, time}, Method -> {"TimeIntegration" -> {"Projection", "Invariants" -> energy[x[t], p[t], m, ω]}}] This keeps the energy to within about 0.12 of its starting value. Not great, but it does not ...

3

I do not know offhand what is a good way to recast as a DAE. One way to enforce the algebraic constraint, without getting an overdetermined (albeit consistent) system, is to use the projection method. I cribbed some of the submethod settings from advanced documentation in tutorial/NDSolveProjection. sol2[x0_, p0_, m_, ω_, time_] := NDSolve[{x'[t] == ...

4

Here is a plot of your function $\frac{\epsilon r}{\epsilon^2 + (\omega-z^2 + r^2)^2}$ (code for ComplexPlotR2 at end of answer): ComplexPlotR2[ CCompileR2[(1/10)/((1/10 - x^2 + y^2)^2 + 1/100) y], {-10, 10, 0.02}, {0, 10, 0.02}] As you can see, it is nonzero on a pair of lines that extend to infinity, so it is not unexpected that the integral might ...

1

From the "Details" section of the documentation for Evaluate: "Evaluate only overrides HoldFirst, etc. attributes when it appears directly as the head of the function argument that would otherwise be held." and from the "Possible Issues" section: "Evaluate works only on the first level, directly inside a held function." f[x_] := ...

2

DensityPlot[EuclideanDistance[{x, y, 0}, {0, 0, 12}], {x, -15, 15}, {y, -4, 4}, AspectRatio -> Automatic] NIntegrate[EuclideanDistance[{x, y, 0}, {0, 0, 12}], {x, -15, 15}, {y, -4, 4}]/(30 8) (* 14.8171 *) {a, b, c, d, e} = {{0, 0, 12}, {-15, -4, 0}, {-15, 4, 0}, {15, 4, 0}, {15, -4, 0}}; coords = {{b, c, d, e}, {a, b, c}, {a, c, d}, ...

4

dist = UniformDistribution[{{-15, 15}, {-4, 4}}]; avgdist = NExpectation[Norm[{x, y, 12}], {x, y} \[Distributed] dist] (* or NExpectation[EuclideanDistance[{x, y, 0}, {0, 0, 12}], {x, y} \[Distributed] dist] *) (* 14.8171 *) Update: You can also obtain the average distance symbolically using Integrate[Sqrt[c^2 + x^2 + y^2] Boole[-a < x < a ...

4

Perhaps this will help in your general use-cases. Part of the problem comes down to how the tetrahedron region is described. Apparently(?), when the coordinates are approximate reals, the finite element method is invoked. Specifying another method appears to cause the message and the integral not being evaluated. However, if exact coordinates are given, ...

Top 50 recent answers are included