# Tag Info

3

Just spelunking a little I got this for the harmonic oscillator problem: eqs = {y[1]'[T] == y[2][T], y[2]'[T] == -y[1][T]}; iniconds = {y[1][0] == 1, y[2][0] == 0}; invariants = {1/2 (y[1][T]^2 + y[2][T]^2)}; vars = {y[1][T], y[2][T]}; system = {eqs, iniconds, vars, {T, 0, 10}, {}, invariants, {}}; erksol = NDSolve[NDSolveProblem@system, Method -> ...

6

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

0

f[x1_, x2_] := PDF[MultinormalDistribution[{0, 0}, {{1, .5}, {.5, 1}}], {x1, x2}]; NIntegrate[ Max[Exp[x1] + Exp[x2] - 3, 0] f[x1, x2], {x2, -Infinity, Infinity}, {x1, -Infinity, Infinity}, MinRecursion -> 2, MaxRecursion -> 5] (* 1.22555 *) NIntgrate will complain about convergence, tinker with AccuracyGoal and precision options as desired ...

4

I believe your code is not working as you are not incrementing your iterator t. I present the following (using FoldList) as alternative iterative approach. euler2d[f_, g_, h_, t0_, f0_, g0_, n_] := FoldList[#1 + h {f[#2, First@#1, Last@#1], g[#2, First@#1, Last@#1]} &, {f0, g0}, Range[t0, t0 + n h , h]] Note in this case the interval of ...

4

I suspect you want the principal value, since the integral is divergent. Integrate[ z Exp[I z r]/Sqrt[z^2 + m^2], {z, -∞, ∞}, PrincipalValue -> True, Assumptions -> m > 0 && r ∈ Reals] (* 2 I m BesselK[1, m Abs[r]] Sign[r] *) If r > 0, then it agrees with your expected answer. Another derivation, although it seems more ...

1

In lieu of a working example in the current OP to work with, yes, this can be done. An example of two bouncing balls with differing velocity retention on bounce: eventtab = Table[With[{n = n}, WhenEvent[y[n][t] == 0, y[n]'[t] -> (-0.95 + n/100) y[n]'[t]]], {n, 2}] NDSolve[{y[1]''[t] == -9.81, y[1][0] == 5, y[1]'[0] == 0, y[2]''[t] == -4, ...

1

As it is already mentioned in the comments, the initial condition Derivative[1, 0][u][0.001, x] == 0, should not appear there. After it removal the equation is solved as expected: eps4 = 0; phi6m4V = NDSolveValue[{D[u[t, x], x, x] - D[u[t, x], t]/ Sqrt[t^2 + x^2] == -6 u[t, x]^5 + (8 + 4 eps4) u[t, x]^3 - (2 + 4 eps4) u[t, x], ...

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

0

It's usually much better in my experience to scale the variables. You get no underflow this way, and stiffness is partially ameliorated, although if a system is stiff it will probably stay that way. As an example, try to be as a-dimensional as possible. Take some main unit/molecule/entity/whatever magnitude as your reference scale, and then work everything ...

3

You can do the whole thing analytically: (*ϵ=78.36; λ=0.548881;*) Clear[ϵ, λ]; funcin = 1/(ϵ * π) * Exp[-(2*r + λ * Sqrt[r^2 + ρ^2 - 2*r*ρ * Cos[θ]])] * r^2 * Sin[θ] * 1 / Sqrt[ρ^2 + r^2 - 2*r*ρ * Cos[θ]]; intfuncinang = Assuming[r > 0 && ρ > 0 && ϵ > 0 && λ > 0, Integrate[funcin, {θ, 0, π}, {ϕ, 0, 2 π}] ] (* ...

1

You can do the integrals over the angular variables analytically; the result will be a function of r, ρ : intth = 2 Pi Integrate[funcin, θ]; integ[ρ_] = (intth /. θ -> Pi) - (intth /. θ -> 0) ; output = Table[{ρ, NIntegrate[integ[ρ], {r, 0, Infinity}]}, {ρ, 0.1, 3,0.05}] ; ListLinePlot[output]

2

Give this a whirl: ifun = Interpolation[{{0, 0}, {1, 1}, {2, 3}, {3, 4}, {4, 3}, {5, 0}}]; out1 = NIntegrate[x*ifun[x], {x, 0, 5}]; xifun = FunctionInterpolation[x*ifun[x], {x, 0, 5, .01}]; out2 = Integrate[xifun[x], {x, 0, 5}]; Row[{out1, N[out2]}, " "] (* 32.5694 32.5694 *)

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

1

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, dist},(*Some Characteristic Distance, assuming no isolated points*) f = Nearest[data]; dist = 3 Max[EuclideanDistance[Last@f[#, 2], #] ...

3

Use Mesh and MeshFunctions: gr1 = ParametricPlot3D[ Evaluate[{x[t], y[t], p2[t]} /. sol2], {t, 0, tfin}, PlotPoints -> 4000, MeshFunctions -> {#1 &}, Mesh -> {{0}}, MeshStyle -> {Directive[PointSize[Medium], Red]}, BoxRatios -> {1, 1, 1}, ViewPoint -> {1, 0, -2}, DisplayFunction -> Identity]

1

As I mentioned in my comment, the easiest way to integrate a list of values is to use Interpolation with Integrate or NIntegrate. As Jens noted, the upgrade information for ListIntegrate, an obsolete function also mentions the same thing. For the sake of completeness, here's how you'd do it: With[{if = Interpolation[(* list of {x, y} pairs *), ...

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

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

3

fnintegrate[ exp_ , lim__ ] := Module[{f, vars}, vars = #[[1]] & /@ List[lim]; Distribute[f[exp]] //. f[a_ b_ /; And @@ ((D[a, #] == 0) & /@ vars) ] :> a f[b] /. f[y_] :> NIntegrate[y, lim] ] fnintegrate[ 11.94 a[1, 1]^2 Cos[x]^2 Cos[θ]^2 + (etc ) , {θ, 0, 2}, {x, 0, 1}] ...

5

You have to be able to reduce the integrand to a sum of terms in which the symbolic constants are factors of the term. Then you can separate the terms and their factors. Gather the factors that are constants, and numerically integrate the (product of the) function-factors of each term. expr = 11.94 a[1, 1]^2 Cos[x]^2 Cos[θ]^2 + 21.31` c[1, 1]^2 ...

0

Just some points: $a$ is a function of $x$ and $t$. Hence $f$ as defined will be a function of $x$.,ie. $f(x)=\int_0^\infty g(x,t)\, dt$ where $g(x,t)$ is your integrand. To numerically integrate (as question title asks &given function of Gaussian's[diffusion eqn soln]), $f(x)$ needs a numerical argument. I am not sure what your ultimate aim is. ...

0

Does this help, first you replace your equation as, Simplify[(k1*a[t])/(a[t] + k2) dt /. a[t] -> (Q/(4*Pi*N*t)^(3/2))*exp (-x^2/(4*N*t))] (dt exp k1 Q x^2)/(-32 k2 [Pi]^(3/2) (N t)^(5/2) + exp Q x^2) Now apply integral, Integrate[ Simplify[-((dt exp k1 Q x^2)/(32 N \[Pi]^(3/2) t (N t)^( 3/2) (k2 - (exp Q x^2)/(32 N \[Pi]^(3/2) t (N ...

0

I tried a few random values for constants and it worked for me. Here are some things you might be doing wrong: Using N as a variable: N is a protected symbol. Use n Using Integrate instead of NIntegrate when you want a numerical answer Defining the integral as a function: You are using $t$ as the integration variable, not as a function parameter.

2

Let's start with the simplest problem. You ask for NIntegrate[NIntegrate[y, {x, 0, 1}], {y, 0, 1}]. This doesn't work because when the internal integral is being evaluated, y doesn't have any values (hence the error). A simple way to fix this is to do the double integral rather than trying to do two single integrals. Hence: NIntegrate[y, {x, 0, 1}, {y, 0, ...

0

Once the trivial things are fixed -- I borrowed the definition of Pl from the Wolfram Community posting -- the problem is that NDSolve has trouble setting up the initial conditions from r[0] == 0.000025, in particular, I suppose for Pb[0]. The solution is to specify both r[0] and Pb[0]. OP's setup I converted each parameter setting to a Rule, so I could ...

3

iMass = 4; iVel0 = {1.0, 1.0, 1.0}; iTime = 1.0; iMagn = Dot[iPos[time], iPos[time]]^0.5; iForce = ((12.3/iMagn) - 1.2)*Normalize[iPos[time]]; iAccel = iForce/iMass; iPos0 = {0.0, 10000, 0.0}; sol = NDSolve[ {iPos''[time] == iAccel, iPos'[iTime] == iVel0, iPos[iTime] == iPos0}, iPos, {time, iTime, 10}] ParametricPlot3D[Evaluate[iPos[time] /. sol], ...

2

That means the boundary conditions defined should fit the the range of t and r in NDSolve command. You have 4 values: {t,0,10} and {r,0,100}, so you have to define the conditions at these 4 values. Here you define at r = s = 1 but you run r from 0 to 100. You need to define the boundary condition at r = 0 and at r = 100. But I don't know which boundary ...

1

To respond to the comment-question of sebhofer: The internal integral is calculated analytically to the end: Integrate[Exp[-(y - \[Mu])^2/(2*\[Sigma]^2)], {y, x, \[Infinity]}, Assumptions -> {\[Sigma] > 0, \[Mu] > 0}] (* Sqrt[\[Pi]/2] \[Sigma] Erfc[(x - \[Mu])/(Sqrt[2] \[Sigma])] *) Introducing the new variables: x=sigma*ksi and mu=sigma*m ...

1

Lets consider some parameters: \[Sigma] = 1; \[Mu] = 1; n = 10; k = 4; I think n should be greater than k for your case. NIntegrate[((1/(Sqrt[2*Pi]*\[Sigma]))*Exp[-(x^2/(2*\[Sigma]^2))])* NIntegrate[((1/(Sqrt[2*Pi]*\[Sigma]))* Exp[-((y - \[Mu])^2/(2*\[Sigma]^2))]), {y, x, Infinity}]^(n - k), {x, -Infinity, Infinity}]^k It gives 0.029438

2

Humm... This integral is zero. So the answer to your question is zero for any x, y $$\frac{1}{(x \cos(\theta)+y \sin(\theta))^\frac{5}{2}}$$ Clear[theta, x, y]; f = 1/(x Cos[theta] + y Sin[theta])^(5/2); int = Integrate[f, theta]; int /. theta -> 2 Pi int /. theta -> 0 (int /. theta -> 2 Pi) - (int /. theta -> 0) (* 0 *) Update ...

10

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

Top 50 recent answers are included