# Tag Info

14

For this function: f[z_] := (1 - E^z + z)/(z^3 (z - 1)^2) there are no branch cuts in the complex plane therefore we simply use Cauchy integral theorem and the related formula of the complex residue, i.e. we sum up residues of the function $f$ in the circle $\mid z \mid =2$. Let's denote $$int = \oint_{\mid z \mid =2}\frac{1-e^z+z}{z^3 (z-1)^2}dz$$ Now ...

8

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

8

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

7

If a numerical answer is good enough you can just enter the path. As @Artes said it doesn't have to be the circle exactly. NIntegrate[f[z], {z, 2 - 2 I, 2 + 2 I, -2 + 2 I, -2 - 2 I, 2 - 2 I}] (* 0. - 0.398582 I *) Check : I (-11 + 4 E) Pi // N (* 0. - 0.398582 I *) Another suggestion from @Artes (thanks !) : one can use symbolic integration as well and ...

7

FindSequenceFunction and FindGeneratingFunction can do this. They won't immediately work every time. This is what I did: First notice that if we find $f(x)$ for $k=1$ then the solution for arbitrary $k$ is just $k \,f(kx)$. Then, write the coefficients into a list ... coeffs = {0, 1/6, 0, -1/120, 0, 1/5040, 0, -1/362880, 0, 1/39916800} ... and try ...

6

You could integrate over the region, using Boole: Integrate[ Boole[0 < p < 1 && 0 < e1 < 1/2 && 0 < e2 < 1/2 && (p < e1 || (p) (e1)/((p) (e1) + (1 - p) (1 - e2)) < e1/e2)], {p, 0, 1}, {e1, 0, 1/2}, {e2, 0, 1/2}] (* 1/16 (5 - 6 Log[2] + 2 Log[4]) *)

5

Having an exact input we can find an exact solution: Maximize[{ 5 x^2 + x + 2, -5 <= x <= 5}, x] {132, {x -> 5}} We could simply provide appropriate mathematical tools fulfilling expectations (adequate conditions on derivatives of the function, i.e. vanishing of the first derivative (a critical point) and negativity of the second derivative, ...

5

If you are trying to take the derivative of $\binom{n}{k}p(1-p)^{n-k}$ where "nchoosek" is $\binom{n}{k}=\frac{n!}{k!(n-k)!}$ with respect to $p$ in Mathematica, or specifically, compute $$\frac{d}{dp}\binom{n}{k}p(1-p)^{n-k},$$ then you can do this with D[n!/(k! (n - k)!)*p*(1 - p)^(n - k), p] // Simplify If you are trying to differentiate with respect ...

4

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

2

I managed to teach Mathematica calculate the integral for arbitrary $n$, with a little aid: $$\int_0^L\rho(n,x)\ln(\rho(n,x))dx = (2/L)\int_{0}^{L}\sin^2(n\pi x/L)\ln\left[(2/L)\sin^2(n\pi x/L)\right]dx$$ Mathematica has trouble, apparently, handling all the parameters $(n,L,x)$, so I resort to the following substitution: $n\pi x/L=u \Rightarrow (n\pi/L) ... 2 Here's a way to approach this by defining a function for each$n$, which you can then do separately. L = 1; u[n_, x_] := Sqrt[2/L] Sin[n π x/L]; ρ[n_, x_] := u[n, x]\[Conjugate] u[n, x]; integrand[n_, x_] := Simplify[-ρ[n, x] Log[ρ[n, x]], n ∈ Integers && x ∈ Reals] Now calculate the desired integral: Integrate[integrand[1, x], {x, 0, L}] -1 + ... 2 There are two branch points: $$z=-\frac{1}{2}\pm i \frac{\sqrt{2}}{2}$$ we can set the branch cuts connecting these two points and set up a contour like this (sorry for the poor drawing): The two small circles in green near the two singularities have no contribution, since the function goes as$\frac{1}{\sqrt{z}}$near the poles. And the four blue ... 2 Using @ubpdqn's answer for getting a closed expression for the dependence of the integral on the dimension n. vol[n_] := vol[n] = FullSimplify[Nest[Integrate[# /. r -> Sqrt[r^2 - x^2], {x, -r, r}] &, 2 r, n], Element[r, Reals] && r > 0] ... 2 Clearly It is a bug in Integrate. g = (a/(2*\[Pi]))/((x - x0)^2 + (a/2)^2); Integrate[g, {x, -Infinity, Infinity}] Now do the indefinite integration int0 = Integrate[g, x] % /. {x0 -> 10} /. {a -> 4} (% /. x -> Infinity) - (% /. x -> -Infinity) (* 1 *) I tried to do Full Trace to see if a clue might show up to tell one ... 2 Something like this? n = 5; xi = Array[x, n] f[x_, t_] := -Log[t] - Log[1 - x.x - t^2] {x[1], x[2], x[3], x[4], x[5]} D[f[x, t], t] D[f[xi, t], x[3]] D[f[xi, t], x[1], t]$\frac{2 t}{-t^2-x.x+1}-\frac{1}{t}\frac{2 x(3)}{-t^2-x(1)^2-x(2)^2-x(3)^2-x(4)^2-x(5)^2+1}\frac{4 t ...

1

This isn't really an answer but it is too long for a comment. I didn't look at your first integral, but the second is fairly easy to investigate because it only depends on one parameter. I used two Mathematica tools that often help in kind of situation you find yourself in. Manipulate[ Plot[Tanh[π Sqrt[λ]] Log[1 - Exp[-2 π q Sqrt[λ + 1/4]]], {λ, 0, ...

1

Your results are complex. If this is OK with you, you might apply this: lst = Table[{x,NIntegrate[(0.657721 (1 - (1 - u2) x)^2.547 (1 + (1 - u2) x - u2 x)^2.547 (1 - 0.176 ((1 - u2) x)^1.2) (1 - 0.176 (-(1 - u2) x + u2 x)^1.2))/(((1 - u2) x)^0.056 (-(1 - u2) x + u2 x)^0.056`), {u2, 0, 1}]}, {x, 0.1, 1, 0.05}]; The result ...

1

opt = {a -> 5, b -> 1, c -> 2}; y = a x^2 + b x + c FindMaxValue[{y /. opt, -5 < x < 5}, x] (* 131.999999424241 *) If you want the x value also, use opt = {a -> 5, b -> 1, c -> 2}; y = a x^2 + b x + c; r = FindMaximum[{y /. opt, -5 < x < 5}, x]; Plot[y /. opt, {x, -5, 5},Epilog->{Red, PointSize[Large], Point[{x ...

1

For a quadratic function, sometimes the extreme value (max. or min.) occurs at the vertex, at $x = -b/2a$; otherwise, it will occur at one of the endpoints of the interval. In this case $a =5 >0$, so the maximum will occur at an endpoint, the one farthest from the vertex, $x = -b/2a = -1/10$. Thus it will be the right endpoint, $x = 5$. So, in terms of ...

1

I think I can answer my question. Mathematically, it makes sense to tell Mma which variable is the one to integrate by parts, like LaplaceTransform or D. Taking this into account, I redefine parts like this parts[u_,v_,{x_,n_}]:= Sum[(-1)^m D[u,{x,m}] Nest[Integrate[#,x]&,v,m+1],{m,0,n-1}] + (-1)^n Integrate[D[u,{x,n}] ...

1

The following code yields the correct result: Another interesting fact is that if I omit the assumption that k ∈ Reals, then Mathematica still gets it right, but it takes ~3x more time: What is puzzling though is that if I use Assumptions with Integrate I don't get the expected result: I was under the impression that Assuming[{a1,a2,...}, ...

1

Here's as close as I can get via Mathematica. First, I just simplify the integrand once for all. Having Simplify in the definition of a function could be really slow. Edit: I added the unsimplified versions of the OP's functions, including a substitution of Boole for If, which I omitted to include in the original answer. u[n_, x_] := Boole[0 <= x ...

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