# Tag Info

15

Here's my attempt. To get the matrix representing the Laplacian I use LaplacianFilter on an array of symbols and CoefficientArrays to extract the coefficients. n = 200; shape = ArrayPad[ConstantArray[0, {n/2, n/2}], {{0, n/2}, {0, n/2}}, 1]; shapeVector = Flatten @ Position[Flatten @ shape, 1]; symbolArray = Array[x, {n, n}]; symbolLaplacian = ...

12

You can do the analytic integral in Mathematica too, by telling it to perform the upper integration limit as follows: With[ { i = Integrate[((r^3 - 7)^(2/3)*(1 - (r^3 - 7)^(2/3)/r^2))/r^3, r] }, Simplify[ Limit[i, r -> Infinity] - i /. r -> 2 ] ] (* ==> 23/64 + Pi/(3 Sqrt[3]) - 2 (-(1/7))^(1/3) Hypergeometric2F1[1/3, 1/3, 4/3, ...

12

While the other answers are nice, the icon deserves a closer look: Note, in particular, that four of the six edges are not constrained by the ostensible Dirichlet boundary conditions, nor is it clear that they solve a Neumann problem. And indeed, as I noted in the comments this is supported by the OP's first link. In short, to produce the logo, they took ...

11

This does not completely answer the question, but you can get some useful information from the undocumented option IntegrationMonitor. For example: NIntegrate[Sin[Sqrt[x]], {x, 0, 1}, IntegrationMonitor -> Print] You can see (in the ExperimentalNumericalFunction) that the change of variables $\sqrt{x}\to x$ has been used to convert the integrand to ...

11

The answer is no because of fundamental mathematical limitations which origin in the set theory regarding countability (see e.g. Cantor's theorem) - functions over a given set are more numerous than its (power) cardinality. Neither Mathematica nor any other system can integrate every function in even much more restricted class, namely Riemann integrable ...

11

I had this laying around from a course in numerical linear algebra I taught a few years ago. Here's a matrix whose nonzero elements describe the basic shape. size = 50; nw = Partition[Table[i, {i, 1, size^2}], size]; sw = Partition[Table[i, {i, size^2 + 1, 2*size^2}], size]; se = Partition[Table[i, {i, 2*size^2 + 1, 3*size^2}], size]; L = ...

10

Believe the numerical one. Mathematica simply could not do the symbolic integration. Symbolic integration will travel via a different code path. Here the symbolic integration done using Maple, and it agrees with the numerical solution given by Mathematica's NIntegrate The analytical answer is (7/18)*hypergeom([-1/3, 1, 1], [2, 2], ...

10

You can use Interpolation to construct a function from your data that can be passed to NIntegrate. Here's how: data={ {0.,0.,0.,0.,0.,0.,0.,0.}, {0.,-10.9421,-17.3061,-19.0045,-19.0045,-17.3061,-10.9421,0.}, {0.,-16.8109,-27.6012,-24.8577,-24.8577,-27.6012,-16.8109,0.}, {0.,-19.9862,-34.0245,-28.3369,-28.3369,-34.0245,-19.9862,0.}, ...

10

Try not to supply machine numbers to integrals over infinite domains. They can cause errors that build up to the extent you have seen. Either compute the symbolic integral with exact numbers (and then convert it to a numeric value) L = 2; sn = 1; a = 10^(sn/10); b = 10^(sn/10); c = a/100; result = 2*Sqrt[1/Pi]*Integrate[(1/(E^z*Sqrt[z]))*(1 - (a/(a + ...

10

Just to contribute to the debate, here is some more evidence that supports the proposition that numerical error is the issue. If we run the integral through various permutations of the ways of making exact and approximate calculations, the pattern I think suggests that numerical error is the reason the OP's integral is so far off. (* the integrand and ...

10

Why the order could matter Superficially, picking some values for t, integrating τ, and finally integrating the results over t is a different calculation than calculating it in a different order. Now there are a few things to explain and investigate to show that this naive observation has a bearing on the OP's integral. Broadly, I would say that the ...

9

You can write your own algorithm and use it from NDSolve. For example, for RK4: CRK4[]["Step"[rhs_, t_, h_, y_, yp_]] := Module[{k0, k1, k2, k3 }, k0 = h yp; k1 = h rhs[t + h/2, y + k0/2]; k2 = h rhs[t + h/2, y + k1/2]; k3 = h rhs[t + h/2, y + k2]; {h, (k0 + 2 k1 + 2 k2 + k3)/6}] CRK4[___]["DifferenceOrder"] := 4 CRK4[___]["StepMode"] := Fixed ...

8

Every integral over a function behaving asymptotically (when $x$ goes to infinity) as $\frac{1}{x^\alpha}$ where $\alpha \leq1$ is divergent, it's a mathematical theorem which could be found in every reasonable handbook of calculus. Since Tanh[ π Sqrt[x]] goes to one rapidly we find that the integral is indeed divergent. We can demonstrate this fact with ...

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 ...

7

This question appears to be about Options, not optional arguments. While it is true that OptionsPattern[] is a form of optional argument that is not typically how options themselves are described. Edit: I see that the tutorial refers to options as "named optional arguments" so I guess my understanding of convention was incorrect. The meat of your question ...

6

There is a way to get Mathematica to calculate the equation of a transformed cylinder, which can then be used to calculate the volume. First, since you're translating the cylinder, too, I rewrote your transformation to include the translation. We can also define inequalities to define the cylinder. xform[x_, y_, z_, a_, b_] := RotationTransform[a Pi/2, ...

6

The analytic answer is $$%\sum_{n=1}^\infty \frac{1}{2n(n+1)^2}\sum_{n=1}^\infty \frac{1+3n}{6n^2(n+1)^3}+\sum_{n=1}^\infty \frac{3n^2-1}{6n^2(n+1)^3}=\\ 1+\pi ^2\frac{2 \zeta (3)-9}{72} \approx 0.0958502$$ Therefore, Mathematica is correct. Proof The 3D integral NIntegrate[FractionalPart[x/y] FractionalPart[y/z] FractionalPart[z/x], {x, 0, 1}, ...

6

Using the functions defined in my answer to your previous question here you have the intersections with all three coordinate planes: getOneCluster[pts_List, maxDist_?NumericQ] :=(*Returns a cluster*) Module[{f}, f = Nearest[pts]; FixedPoint[Union@Flatten[f[#, {Infinity, maxDist}] & /@ #, 1] &, {First@pts}]] clusters[data_] := Module[{f, ...

6

Here is a way to get an approximate symbolic expression for the integral. Some of the coefficients are approximate because at some points in the process we need the value of a definite integral at a = 1, and unfortunately those integrals have to be computed numerically. First, a lemma: Let $f(a) = \int_1^\infty g(x, a) \; dx$. Then $f(a) = f(1) + ... 6 This is already bult into Mathematica$Assumptions = {s > 0}; dist = NormalDistribution[m, s]; pdf[x_] = PDF[dist, x]; cf[w_] = CharacteristicFunction[dist, w]; pdf[x] == InverseFourierTransform[cf[w], w, x, FourierParameters -> {1, 1}] // Simplify True cf[w] == FourierTransform[pdf[x], x, w, FourierParameters -> {1, 1}] == ...

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 ...

5

To find the finite-difference formula using m grid points, a polynomial of order m-1 is differentiated. This method is recommended over using Taylor series expansion when the number of grid points becomes large. The Fornberg formula (implemented as function FDFormula in the above link, down the page) can also be used to generate the finite-difference formula ...

5

If you want the volume for InterpolationOrder -> 1, you can use the fact that volume of a segment over a subrectangle is the area of the base times the mean of the altitudes of the four vertices. In your case, the total 4000 x 4000 area is divided into 7 x 7 rectangles. (4000/7)^2 * Total[Partition[AA, {2, 2}, {1, 1}], 4]/4 // Abs (* 2.59749*10^8 *) ...

5

This is a short-coming of how the arguments are evaluated. The symbols k.x[t] is treated as a single term, while g is treated as a list; Plus automatically threads over the list creating a little mess: x''[t] == k.x[t] + g (* x''[t] == {1 + {{1.5, 0.}, {0., 1.5}}.x[t], 2 + {{1.5, 0.}, {0., 1.5}}.x[t]} *) If a 2-vector value is substituted for x[t], this ...

5

s = NDSolve[{y'[t] == {{.1, -.2}, {-.1, .2}}.y[t], y[0] == {1, 1}, WhenEvent[Norm[y[t] - {0.9460552574072016, 1.053944742592798`}] <= .01, y[t] -> {1, 1}]} , y[t], {t, 0, 1}] Plot[y[t] /. s[[1]] /. t -> u, {u, 0, 1}]

5

Observation: First of all I think it is always a useful trick to plot your problematic integrand if possible. It gives us often the clue in case NIntegrate complained about the particular integrand. If we can track down the issue we can often come up with a remedy. Given the following input if one sweeps over the rDet we get the following plots. Given your ...

5

I do not think this is related to floating point errors. I think the closed form solution arrived to in Integrate is not correct. May be wrong branch is taken. To see this more easily, Here is a simpler one (part of the original integral) that gives a symbolic solution, but wrong numerical value for the values when substituted into the expression Clear[a, ...

5

I think the reason NIntegrate is hard to use is that the two terms that are products of a Bessel and a Struve are very large numbers nearly equal numbers being subtracted and perhaps that it the integral converges slowly. Since the OP already knows the answer, it makes me wonder about the purpose of the question, whether it is about how to find the answer ...

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