Tag Info

Hot answers tagged

8

It's numeric integration. So it has no means of "knowing" the correct result is zero. In the process error estimates will be formed and if they are larger than the estimated result, this is a problem. But of course they must be larger since the actual result is zero. The way to tame this is to specify an AccuracyGoal that is attainable using the given ...


6

Just consider the first integral. expr = x (A Ac (m2 + m1 (-1 + x)) + V Vc (m1 + m2 - m1 x))/(8 π^2 (-mh^2 (-1 + x) + (m2^2 + m1^2 (-1 + x)) x)); denominator = Collect[Denominator[expr], x] 8 mh^2 π^2 + 8 (-m1^2 + m2^2 - mh^2) π^2 x + 8 m1^2 π^2 x^2 It has two singular points. sol = Solve[denominator == 0, x] // Simplify If the singular ...


3

Here is another way that uses the Graphics object directly: gr = ParametricPlot3D[{Cos[u], Sin[u] + Cos[v], Sin[v]}, {u, 0, 2 Pi}, {v, -Pi, Pi}] We discretize the graphics using DiscretizeGraphics mr = DiscretizeGraphics[Normal[gr /. (Lighting -> _) :> Lighting -> Automatic]] We compute the convex hull hull = ...


3

The problem seems to be that the values are very small, smaller than can be represented by a machine numbers. Perhaps NIntegrate decides the answer is zero. You can use arbitrary-precision numbers, which you can do with the WorkingPrecision option, to get nonzero values. a2 = 525/10; u = 2*i - 1/2; u1 = u*Pi/2; u2 = u1/a2; u4 = -1/5^2; Table[NIntegrate[ ...


3

Mathematica 10 now supports the Finite Element Method for certain classes of PDEs. Documentation: Reference Detailed user guide Advanced documentation on FEM programming The FEM related functions are in NDSolve`FEM` and can be made directly accessible using Needs["NDSolve`FEM`"]


2

Your integral is very unlikely to exist in terms of elementary functions. In particular, it involves terms of the form $$ \int\exp\left[-\frac12\sqrt{a\, \text{poly}(\xi)+b \xi^{0.998906}}\right]\text d\xi, $$ which is very unfriendly as regards symbolic integration. Note that in general symbolic integration is not possible; do you have some specific reason ...


2

Comment: I think you want D instead of Derivative. Also == instead of =. And you probably want the functions defined with patterns z_ etc. But there are errors that you'll have to address. (Or perhaps someone else.) ClearAll[φ, η, r, u]; φ[z_] = q*(1/z + (-1*q)/(-1*z)); η[z_] := k*(1/z + (-1*q)/(-1*z)); r[ρ_, z_] := Sqrt[ρ^2 + z^2]; pde = D[u[t, ρ, z], ...


2

In Version 10, once the points have been obtained as per user21's approach, we can tetrahedralize them directly using DelaunayMesh pf = {Cos[u], Sin[u] + Cos[v], Sin[v]}; pp = ParametricPlot3D[pf, {u, 0, 2 Pi}, {v, -Pi, Pi}] data = Reap[ParametricPlot3D[Sow[pf], {u, 0, 2 Pi}, {v, -Pi, Pi}]][[2, 1]]; pts = Cases[data, {_?NumericQ, _?NumericQ, ...


2

In any attempt to debug a code - make it as simple as possible. Neither the For-loops nor the Export make things easier. Try to break things down - if I evaluate f[0.1, 0.1, 0.1, -1] I already get nonsense. One (!) of the problems is the definition of the function f, as you try to calculate the derivative for numerical parameters. Something along the line ...


2

Your assumption is wrong. The correct result is Integrate[x^2, {x, 5, 9}] 604/3 (201.333...) With TrapezoidalRule you can only approximate this result: NIntegrate[x^2, {x, 5, 9}, Method -> {"TrapezoidalRule", "Points" -> 3, "RombergQuadrature" -> False}, MaxRecursion -> 10, PrecisionGoal -> 6] 201.333


2

Including "SymbolicProcessing" -> False in the Method for NIntegrate gives equivalent timings with or without the NumericQ pattern test in the function's definition. n = 1000; (* iterations in Do loops *) test[a_] := a^2; test2[a_?NumericQ] := a^2; Do[NIntegrate[test[a], {a, -0.5, 0.5}, Method -> {Automatic, "SymbolicProcessing" -> ...


1

If I use exact coefficients, I get an exact answer with Integrate after a couple of minutes: GE[Theta_, A_, B_] := CopulaDistribution[{"Binormal", Theta}, {ExponentialDistribution[A], ExponentialDistribution[B]}]; Delta = 4/100; A = 10/100; B = 10; Theta = 90/100; T = 5; GExpExp[x_, s_] := PDF[GE[Theta, A, B], {x, s}] ...


1

I post this not as a specific answer but I think it may provide some insights. Experts and WRI would have to answer. The following will only work for positive valued functions (polygons breaking on x axis ->problems...remediable but I just post this as a quick insight). NIntegrate aims to provide best approximation within working precision. It seems there ...


1

not an answer but a neat trick to pull out the weights that are used: method = {"TrapezoidalRule", "Points" -> 2, "RombergQuadrature" -> False}; r = 2; integrate once to learn the values: xvals = Reap[i0=Quiet@NIntegrate[x^2, {x, 1, 5}, Method -> method, MaxRecursion -> r, EvaluationMonitor :> Sow[x]]] // Last // ...


1

All of your integrals can be done with Integrate. These initial calculations are slow but by using Set rather than SetDelayed their subsequent use will be much quicker. You will also get better precision. Since you are comparing with experimental results presumably you satisfy the conditions suppressed by GenerateConditions -> False. If you want to see ...


1

I have interpreted this question as per george2079s comment. I think this may a case of "asking too much" but I defer to numerical experts. Note: Manipulate[ Plot[Evaluate[ BesselJ[2, 2 x] BesselJ[2, us[[1]] x] x Exp[u4 x^2]], {x, 0, s}, PlotRange -> {-0.003, 0.003}], {s, {5, 10, 20, 30, 40, 50}}] Then testing for small upper limits (noting ...


1

Assuming that if the integrand is complex we should take it to be zero, you can do this: uplim = 50; arg = If[Im@# > 0, 0, #] &@ N[2 Sqrt[z + 3/8 + 2^2]* Total@Table[((5^k)*Exp[-5])/(k!*Sqrt[2 \[Pi] 2^2])* Exp[-((z - k)^2)/(2 2^2)], {k, 0, uplim}] ]; Plot[arg, {z, -10, 20}] NIntegrate[arg, {z, -\[Infinity], \[Infinity]}] This ...


1

It cannot be real, since zunder the radical goes to minus infinity. Anyway, if you only need a numerical table, why do not you do something like this: f[y_, sig_, n_] := NIntegrate[ 2 Sqrt[z + 3/8 + sig^2]* Sum[((y^k)*Exp[-y])/(k!*Sqrt[2 \[Pi] sig^2])* Exp[-((z - k)^2)/(2 sig^2)], {k, 0, n}], {z, -\[Infinity], \[Infinity]}] Here nis ...


1

Let f[x_,y_] := Sin[x + y^2]. To plot the intersection of f[x,y] == z with z == 0.5, use Plot3D[f[x, y], {x, -3, 3}, {y, -2, 2}, MeshFunctions -> Function[{x, y, z}, z], Mesh -> {{0.5}}] To plot this curve in the plane, ContourPlot[f[x, y] == 0.5, {x, -3, 3}, {y, -2, 2}] Further reading: documentation of Mesh, MeshFunction, ContourPlot How can ...


1

I believe your use of Part to extract a single value from the result of berrycur is causing NIntegrate to symbolically integrate your function. Try evaluating the indefinite integral for a clue as to what is going on, e.g. Integrate[berrycur[x, y][[1]], x, y] (x^2 y)/2 If you clean-up your function definition to return a single value: ...


1

Delete the Table in berrycur,and then change to berrycur[kxkx_?NumericQ, kyky_?NumericQ, i_] NIntegrate[berrycur[kx, ky, 1], {kx, -2 \[Pi], 2 \[Pi]}, {ky, 0, 4 \[Pi]/Sqrt[3]}] 12.5664



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