We’re rewarding the question askers & reputations are being recalculated! Read more.
13

Some experimentation shows that the NDSolve problem is associated exclusively with z with no feedback to x or yT, because dz and dyT are independent of z. It is, therefore, convenient first to compute x and yT, and only then to compute z. For paramsGood, deqns = {dx, dyT, initx, bc1x, bc2x, inityT}; deqnz = {dz, initz, bc1z, bc2z}; {xSoln, yTSoln} = ...


10

For this problem, you must specify a solution method. Since the system of equations is nonlinear and the equation for y does not contain derivatives with respect to r, we must choose "MethodOfLines". It solves all problems right away. The code contains Quiet, since function xI is used outside the machine number, for example, 1/2.71828^726.112is calculated. ...


9

Numeric solution In this example I compute the $W_2$ geodesic (Wasserstein distance) between two densities defined as InterpolatingFunction. (* unnormalized density functions *) uf = Interpolation[{{-2, .5}, {0, 2}, {.5, 1}, {1, .5}}]; ug = Interpolation[{{-1, 1}, {0, .5}, {1, 2}, {2, .5}}]; (* normalized density functions *) f[x_] = uf[x]/NIntegrate[uf[x]...


9

I think your approach with Nearest is basically equivalent to some sort of zeroth order interpolation. It would be much better to just use Interpolation with InterpolationOrder->1 instead. So: lst = First @ Import["/Users/carlw/Downloads/trial.xlsx"]; if = Interpolation[lst, InterpolationOrder -> 1]; Visualization: Plot3D[if[x, y], {x, -65, 139}, {y,...


9

Fully NDSolve-based Solution Adjustion for spatial step size together with temporal step size helps. I've used parameters mentioned in the comment for testing: mol[n:_Integer|{_Integer..}, o_:"Pseudospectral"] := {"MethodOfLines", "SpatialDiscretization" -> {"TensorProductGrid", "MaxPoints" -> n, "MinPoints" -> n, "DifferenceOrder" -> o}...


8

The first thing I noticed in the author code is that this is not an exact reproduction of the Verlet algorithm. Second, there is no vector implementation, which is the main advantage of the Verlet algorithm. If we correct both inaccuracies, we get a code that is not inferior in speed to the standard solver with an option similar to Verlet's algorithm. We ...


7

You can use NDSolveValue to create an interpolating function representation of the inverse. Basically, suppose you want to invert f. Then: f[finv[x]] == x where finv is the inverse function. So, an ODE for the inverse function is: D[f[finv[x]] == x, x] f'[finv[x]] finv'[x] == 1 Let's use this for your G function: g[x_] := UnitTriangle[x-3] G[x_] := ...


6

Another solution is to use Simplify`PWToUnitStep: s1 = NDSolve[{equa00 // Simplify`PWToUnitStep, x[0] == 1, x'[0] == 1}, x, {t, 0, 50}]


5

Changing the last line to: s1 = NDSolve[{equa00, x[0] == 1, x'[0] == 1}, x, {t, 0, 50}, SolveDelayed -> True] or s1 = NDSolve[{equa00, x[0] == 1, x'[0] == 1}, x, {t, 0, 50}, Method -> {"EquationSimplification" -> "Residual"}] seems help for your problem. In reponse to updated question on plot slution To plot your solution, maybe this is ...


5

I think the first behavior is arguably a bug and I reported a suggested fix ([CASE:4344046]). When NDSolve uses the Shooting method, sometimes the initial conditions it tries leads to stiffness. At that point the method fails, and NDSolve returns unevaluated. The only message the user sees the stiffness/singularity message NDSolve::ndsz. However, the ...


4

After studying the article and theses, as well as article Ground-state properties and elementary excitations of quantum droplets in dipolar Bose-Einstein condensates from which the ansatz was taken, I came to the conclusion that the ansatz may not have been calibrated to find the magnitude of the energy. Therefore, we calibrate the ansatz using the data in ...


4

Can be used ParametricNDSolveValue F = 1.2; sol = ParametricNDSolveValue[{f'[ x] (1 + 20 f[x] (1 - f[x]) f[x]^2) == -f[x], f[0] == a}, f, {x, 0, 5}, {a}]; M[a_?NumericQ] := (NIntegrate[sol[a][x], {x, 0, 5}] - F)^2 sol1 = NMinimize[{M[a], 0 < a < 1}, a] (*{1.03015*10^-21, {a -> 0.69524}}*) General view of the solution and optimal ...


4

An InterpolatingFunction has weak singularities at each point of the interpolating grid. They confound the default integration rules, which are a based on the assumption that the integrand is smooth. You can specify the singularities sometimes with Method -> "InterpolationPointsSubdivision", but it does not work here, maybe because of the complexity of p1....


3

Simply increasing the MaxRecursion gives an answer without the NIntegrate::ncvb message: paverage = NIntegrate[p1, {t, 40, 40 + period}, MaxRecursion -> 100]/period (* {-311.506} *) BTW, looking at your function over this range, it does not look like the period is 23.14. Plot[p1, {t, 40, 40 + period}] EDIT: Extra method @MichaelE2's answer is so ...


3

Knowing f[x]==FF'[x] you can expand your ode and solve without need of additional NMinimize. Only additional constraints FF[5] == 1.5,FF[0] == 0 are necessary erg = NDSolveValue[{FF'[x] == f[x],f'[x] (1 + 20 f[x] (1 - f[x]) f[x]^2) == -f[x], FF[5] == 1.2,FF[0] == 0}, {f, FF}, {x, 0, 5} ] Plot[{ erg[[1]][x]} , {x, 0, 5}]


3

The underlying issue is already discussed in What's behind Method -> {"EquationSimplification" -> "Residual"} so I'd like not to talk too much about it in this answer. In short, NDSolve is having difficulty in recognizing the system is an ODE system and the DAE solver of NDSolve isn't strong enough (at least now) so we need to ...


3

The integral is calculated exactly f= Integrate[Func[x, y, a, n], x] (*Out[]= (a n (x - y)^( 1 - n) ((-1 + a) y)^n Hypergeometric2F1[1, 1 - n, 2 - n, ( x - y)/((-1 + a) y)])/((-1 + a) (-1 + n) y)*) But the integral diverges at the lower limit x=4ywith n=125/100,a=4. Check f/. {x -> 4 y, a -> 4, n -> 125/100} (*Out[]= -\[Infinity]*)


3

It is necessary to divide the equation into two (second order), add the initial data and boundary conditions. Here is the code without adding boundary conditions ClearAll[u, x, t, a, b, c, w, n]; c = 1; n = 1; a = 1; b = 1; w = 1; pde = {D[u[t, x], t, t] - c*D[u[t, x], x, x] - n*D[v[t, x], t] == 0, v[t, x] == D[u[t, x], x, x]}; ics = {u[0, x] == 0, v[...


3

From the documentation: NSum first localizes the values of all variables, then evaluates f with the variables being symbolic, and then repeatedly evaluates the result numerically. It's the symbolic evaluation that produces the message. The fix is to prevent symbolic input to NIntegrate: f[n_Integer, x_?NumericQ] := NIntegrate[1/(n t (E^t - 1)), {t, x, ...


2

You can evaluate the a and b integrals symbolically with the Fundamental Theorem of Calculus. Integrate might not compute the definite integral directly. It gets bogged down in checking convergence or branches or something, and I did not wait to see if it would come up with something. OTOH Integrate returns the antiderivative rather quickly. We can ...


2

This is an extended comment versus an answer, but you can improve your interpolation by performing it on log-log transformed. If you ListPlot mydata, you will see that much of the data is up against the x=0 axis. ListPlot[mydata] Since your data looks much nicer and spread out on a ListLogLogPlot, you can perform the interpolation on Log-Log transformed ...


2

I think the Numerical Method of Lines Tutorial demonstrates a relatively clean way of setting up your type of problem. You did not define $\alpha$, $G$, $\Omega$, $M$ or $V2$, so I chose arbitrary and uninteresting values (coupled systems are very easy to make unstable). Here is an example workflow: n = 5; f = 5; G = 1; alpha = 1; omega = 1/10; V1 = ...


2

I think a key issue is the inability to resolve your source term, $x_I$, relative to your domain. Three parameter sets have been given through the course of the discussion. If we assume that we will use the same spatial and temporal domain for each parameter set, then a Plot3D of the source term reveals the relative feature size of the pulse. Plot3D[xI /. ...


2

The problem with this code is to track output NDSolve[] must exactly match input InterpolatingFunctionCoordinates[]. To do this, separate the variables X[t] and X. tmax = 30; X0 = {1, 0.9, 2, 0.5, -1}; X0d = {0, 0, 0, 0, 0}; \[Omega] = {0.5, 0.6, 0.7, 0.8, 0.9, 1}; mt = ConstantArray[0, {1000, 6}]; M = SparseArray[{{i_, i_} -> 2, {i_, j_} /; Abs[...


2

I am not sure whether this is what you want. Remove["Global`*"] // Quiet; F = 1.2; eq = {f'[x] (1 + 20 f[x] (1 - f[x]) f[x]^2) == -f[x], g[0] == 0, g[5] == F, g'[x] == f[x]}; {gSol, fSol} = NDSolveValue[eq, {g, f}, {x, 0, 5}]; {gSol, fSol} // ListLinePlot Remove["Global`*"] // Quiet; F = 1.2; eq = {f'[x] (1 + 20 f[x] (1 - f[x]) f[x]^2) == -f[x], f[0] ...


2

Your ODE can be solved exactly, by the way. The time to reach a singularity is given by the following integral, if it converges: Integrate[ -1/(b0 alp1[mu1]^2 + b1 alp1[mu1]^3), {alp1[mu1], α1, Infinity}] (* 0.451388 *) Therefore the IVP has a singularity around mu1 = 0.451. This agrees with the numerical integration performed by NDSolve (for nf = 4)...


1

Here is the sort of thing I meant in my comment: 1. Get a single piecewise function constraint = equa00 /. Equal -> Subtract // PiecewiseExpand 2. Solve each piece for x''[t] solvexpp = x''[t] /. First@Solve[# == 0, x''[t]] &; newode = x''[t] == MapAt[solvexpp, constraint, {{-1}, {1, 1, 1}}] A PiecewiseFunction can have more pieces. You can add ...


1

The "computational result" is obtained using NIntegrate with default WorkingPrecision -> MachinePrecision and PrecisionGoal -> Automatic (which usually is equivalent to PrecisionGoal -> 6): cr = NIntegrate[Exp[-x]*Log[Exp[-x]/((Exp[-x] + 10 Exp[-10 x])/2)], {x, 0, Infinity}]; SetPrecision[cr, 50] 0....


1

With macOS Catalina 10.15 $Version (* "12.0.0 for Mac OS X x86 (64-bit) (April 7, 2019)" *) The precision of your distribution is only machine precision due to the presence of low precision numbers; specifically, 0.5 dist1 = TruncatedDistribution[{0, ∞}, MixtureDistribution[{0.5, 0.5}, { NormalDistribution[30.0505043478260844836, 1....


1

I could get some results by defining before the my data block: diffeq = {T'[t]/T[t] == -1/(1 + (1/3)*T[t]/f[T[t]]*f'[T[t]])} boundary = {T[-40] == 10^10} odeqs = diffeq~Join~boundary Where I took freedom to change 0.3 to (1/3), since they're not equal and your equation seems to use the latter. And then using after defining f[x_]: sol = NDSolve[odeqs, T, {...


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