Tag Info

New answers tagged

1

It's just another story of precision. For the first sample: a = 2/100; NIntegrate[BesselJ[15/2, BesselJZero[15/2, 1] r]^2 r, {r, 0, a}, WorkingPrecision -> 40] N[Integrate[BesselJ[15/2, BesselJZero[15/2, 1] r]^2 r, {r, 0, a}], 40] (* Let's check the difference between the above two result *) %% - % 1.187956028197538867114723184727333535080*10^-27 ...


0

Try this: f = Interpolation[ Table[{r, 10^12 BesselJ[15/2, BesselJZero[15/2, 1]*r]}, {r, 0, 0.02, 0.0005}]]; and then integrate: 10^-12*(NIntegrate[f[r], {r, 0, 0.02}] // Chop) (* 1.67209*10^-14 *) Have fun! Later edit: to address the comment of xzczd: I, indeed, missed the square in my integration. If one adds this square and ...


7

gauMix[x_, means_, vars_] := Total[(E^-(((x - means)^2)/(2*vars)))/Sqrt[2*Pi*vars]]/ Length[means]; means = {-7, 7}; vars = {6, 65/10}; f[x_] := gauMix[x, means, vars]; fxx = Integrate[f[x]*(x^2), {x, -Infinity, Infinity}] (* 221/4 *)


4

eq1 = (1 + E^b)/(1 + E^(9/10 a + b)) == 95/100; a0 = a /. Solve[eq1, a] /. C[1] -> 0 f[b1_, x_] := (1 + E^b1)/(1 + E^(x a0 + b1)) /. b -> b1 Quiet@FindRoot[NIntegrate[f[b, x], {x, 0, Infinity}] == 1, {b, -20}] (* {b -> -29.4444} *)


2

f[x_] = 4/5 * ((1/(4 (1 - x)^3) + 1/(2 (1 - x)^2)) UnitStep[-x] + (1/(4 (1 + x)^3) + 1/(2 (1 + x)^2)) UnitStep[x])//FullSimplify; f[1] = f[1.] = Limit[f[x], x -> 1] 1/8 f[-1] = f[-1.] = Limit[f[x], x -> -1] 1/8 dist = ProbabilityDistribution[f[x], {x, -Infinity, Infinity}]; Plot[f[x], {x, -10, 10}, PlotRange -> {0, ...


0

One way to address the example is to provide input of the same or higher (arbitrary) precision, sofindmassz[0, 0.14921714620005236`15, 0.07455393513003296`15, 1.016522853606922`15, workprec -> 15] (* 0.643229985259241 *) One can get overflow, probably from f1d[h_] := -Exp[ξ[h]/T]/(T (Exp[ξ[h]/T] + 1)^2) because the size of ξ[h] can be quite ...


3

The tutorial "ExplicitRungeKutta" Method for NDSolve shows how to get the built-in coefficients for the the default 2(1) embedded pair: NDSolve`EmbeddedExplicitRungeKuttaCoefficients[2, Infinity] (* {{{1}, {1/2, 1/2}}, {1/2, 1/2, 0}, {1, 1}, {-(1/2), 2/3, -(1/6)}} *) The general syntax for a given method, order, and precision appears to be ...


3

The code as displayed in the Question runs fine for me using Mathematica 10.0.2.0 under Windows 8.1 (64 bit). However, as I noted in a Comment, z0 = 0 causes z[t] to remain zero. Arbitrarily, I set z0 = 0.1 (and also tmax = 5), which produced with data0 {{{3.02779, -18.7347}, {3.02779, 18.7347}}, {{4.02275, 13.1626}, {4.02275, -13.1626}}, {{1.7836, ...


12

The good news is that yes, there is an easy way to put your problem into NDSolve by using the new finite element functionality in v10. The bad news is that it seems the specific problem you're trying to solve is ill-posed. NDSolve can now handle internal boundaries; see e.g. the first figure under "Details" for DirichletCondition. Generating a mesh with ...


4

The periodic driving at one point doesn't seem to be compatible with the boundary conditions expected by NDSolve, so I modified the problem in two ways: first, broaden the point source into a Gaussian, and then incorporate this driving as a source term in the actual differential equation. So we're actually solving the inhomogeneous wave equation here. For ...


2

There are lots of conditionals in there, that you need to carefully look at. Why not do this step by step so you see the issue? Clear[x, t] int1 = Integrate[Sqrt[Exp[3 t + 2] + 3], {t, 0, x}] int2 = Integrate[Sqrt[Exp[6 t - 2] + 5], {t, 0, x}] By passing them for now, we get expr = (First@int1)^2/(First@int2) Limit[expr, x -> 0] (*0*)


2

Update: infinity limit Assumptions -> x > 0 helps Mathematica to find these integrals Limit[(Integrate[Sqrt[Exp[3 t + 2] + 3], {t, 0, x}, Assumptions -> x > 0]^2)/ Integrate[Sqrt[Exp[6 t - 2] + 5], {t, 0, x}, Assumptions -> x > 0], x -> ∞] (* (4 E^3)/3 *) Validation Plot[{(NIntegrate[Sqrt[Exp[3 t + 2] + 3], {t, 0, x}]^2)/ ...


2

Integration in Mathematica treat every symbol as it can be any number (Real, Integer, Complex). Type of number defiantly change the results in some cases (as this one) and does not effect results in other cases. In your case, the Integration depends on the value of x (combination of Imaginary and Real pares of x in case x is Complex) If you want to get ...


2

Not sure what is going on with the different results of Integrate and NIntegrate. This does not mean that the analytic form of $C$ is erroneous. Note that plotting the likelihood function (using the expression of $C$ provided by Integrate and the parameter values you used) over a resticted range of $s$ (instead of $[0,1]$) clearly shows that the ...


3

The problem is numerically unstable for some parameter ranges. We shall show a simple example. Your normalized distribution is given by p[q_, n_, \[Mu]_, \[Nu]_, s_] := Exp[4 n s q] q^(4 n \[Nu] - 1) (1 - q)^(4 n \[Mu] - 1)/(Gamma[4 n \[Mu]] Gamma[ 4 n \[Nu]] Hypergeometric1F1Regularized[4 n \[Nu], 4 n (\[Mu] + \[Nu]), 4 n s]) Check ...


2

Well, I'll take a crack at it, although I think chris identified the nub of the problem in the first comment. We need to tighten up the language from the comments. First, write $$F(\theta)=F(\theta,k)=\sin \theta \int_{-L}^{+L}h(z)\,e^{-ikz\cos \theta} \,dz=\sin \theta \int_{-\infty}^{+\infty}\tilde{h}(z)\,e^{-ikz\cos \theta} \,dz$$ where ...


2

Here is my solution, just change the WhenEvent part to WhenEvent[First@y[t] == 0, y[t] -> {1, Last@y[t]}] sol = NDSolve[{y'[t] == {{.1, -.2}, {-.1, .2}}.y[t], y[0] == {1, 1}, WhenEvent[First@y[t] == 0, y[t] -> {1, Last@y[t]}]}, y, {t, 0, 10}] Plot[Evaluate[y[t] /. sol], {t, 0, 10}] Mathematica gives


2

You could use FindRoot to tweak the period (tmax) and x0 to get back to the starting point, with the other coordinates of the system fixed: map[H_,om_,x0_?NumericQ,y0_,ux0_,uy0_?NumericQ,tmin_,tmax_?NumericQ,xmax_]:=Module[{}, DE=DifferentialEquations[H,om,x0,y0,ux0,uy0]; sol=NDSolve[DE,{x,y,ux,uy},{t,tmin,tmax},MaxSteps->Infinity, ...


5

I think this is merely a matter of precision: Integrate[Exp[I*s*1000]*1/(1 + 10^2*s^2), {s, 0, Infinity}] N[%, 16] π/(20 E^100) + 1/20 I Sqrt[π] MeijerG[{{1/2}, {}}, {{1/2, 1/2}, {0}}, 2500] 0.*10^-45 + 0.0010002002407240688 I If you want to use NIntegrate, then a quick search in the document shows that "LevinRule" is your friend: ...


4

I don't know anything about the structure of an InterpolatingFunction (the documentation doesn't seem to provide much information about it), but could you just reconstruct your function like this: data = {{0.5`, 0.01739227213704432`}, {0.75`,0.01526028474172406`}, {1.`, 0.01376257284655001`}, {1.25`,0.01269413117458243`}, {1.5`, 0.01187709007513161`}, ...


5

h = c = k = 1; b1[x_, y_] := 2 h c^2/(x^5 (Exp[h c y^(3/4)/(x k)] - 1)); rslt[x_?NumericQ] := NIntegrate[2 Pi y b1[x, y], {y, 1, 10}]; LogLogPlot[rslt[x], {x, 1, 10}] Edit: There seems to be an issue with LogLogPlot in V10.0.1 related to this and Bob Hanlon's answer, which has been posted here: LogLogPlot plugs in zero. Error messages are generated, but ...


3

h = 1; c = 1; k = 1; B1 = (2*h*c^2)/(x^5 (Exp[(h*c)/(x*k*y^(-3/4))] - 1)); Rslt can only be evaluated for a numerical value of x so it shoud be defined as Rslt[x_?NumericQ] := NIntegrate[2*Pi*y*B1, {y, 1, 10}] LogLogPlot[Rslt[x], {x, 1, 10}]


3

The given integral can be integrated exactly and quickly. Integrate[fermitotal[beta, k, mu, delta] k^2, {k, 0, 20}] // AbsoluteTiming N@Last[%] (* {0.006876, 8000/3} 2666.67 *) But since, presumably, the OP's actual use-case is not, I'll comment on the set up and the relation of OP's choices to speed. Remarks on the OP's option settings Since it's a ...


1

I'm afraid that this is a bit puzzling indeed. If I use your example and run the NIntegrate without all the fancy options I get {0.006944, 2666.67}. So I assume it has something to do with your options. Leaving out the method, but leaving everything else in place, slows down things dramatically, but it is still doable: {0.561119, 2666.666666667}, ...


0

How about this: fermitotal[beta_?NumericQ, k_?NumericQ, mu_?NumericQ, delta_?NumericQ] := With[{ee = Eigenvalues[{{k^2 - mu, delta}, {delta, -k^2 + mu}}]}, 1/(1 + Exp[beta*ee[[1]]]) + 1/(1 + Exp[beta*ee[[2]]]) ]; nTotal[beta_?NumericQ, mu_?NumericQ, delta_?NumericQ] := NIntegrate[fermitotal[beta, k, mu, delta] *k^2, {k, 0, 20}] nTotal[50, 1, 1/10] // ...


1

Using Picard iterations I get this series solution: First we convert it to standard form $x'=f(x(t),t)$ and apply Picard: Problem: Solve $x^{\prime\prime}\left( t\right) +x\left( t\right) -10\left( 1-x\left( t\right) ^{2}\right) x^{\prime}\left( t\right) =0$ with $x\left( 0\right) =2,x^{\prime}\left( 0\right) =0$ Let ...


3

Although Implicit Euler is described in the documentation, it may not be an implemented Method. In fact, the Wolfram discussion of the Lotka–Volterra Equation actually defines Backward or Implicit Euler, suggesting that it is not an implemented Method: BackwardEuler = {"FixedStep", Method -> {"ImplicitRungeKutta", "Coefficients" -> ...



Top 50 recent answers are included