Tag Info

Hot answers tagged

25

Fixed (see below) Here's an approach: r1 = Exp[-x^3 - y] - 1 == z; r2 = y == z; We create ImplicitRegions: reg1 = ImplicitRegion[r1, {x, y, z}]; reg2 = ImplicitRegion[r2, {x, y, z}]; The intersection of these regions is the line you seek: reg = RegionIntersection[reg1, reg2]; And here is the length (note the inclusion of the range of values in ...


23

The plan is first get the "external" contour and then use Green's theorem to find its area. r[t_] := {-9 Sin[2 t] - 5 Sin[3 t], 9 Cos[2 t] - 5 Cos[3 t], 0} (*find the intersections*) tr = Quiet@ToRules@Reduce[{r@t1 == r@t2, 0 < t1 < t2 < 2 Pi}, {t1, t2}]; pt = {t1, t2} /. {tr} // Flatten; pts = SortBy[pt, N@# &]; pps = Partition[pts, 2]; Now ...


19

After a lengthy study (I'm using version 8) I conclude that there is a bug in Mathematica in the Integrate function when applied to a Sqrt integrand. Ok. let's go (some patience is required because of the long text) Let us define the functions corresponding to your integrals. Remark: because of the relation $1 + cos(2x) = 2 cos^2(x)$ the two forms of ...


17

Since another answer provides misleading results I'm motivated to explain what's wrong there and suggest a correct solution. One can guess that the error there has been produced by DiscretizeRegion or by an improper parametrization of the curve with RegionIntersection (more likely the former reason). Let's start from the begining defining the following ...


17

SphericalPlot3D is having problems where the radius goes to infinity. You can use RegionFunction to restrict the plotting region to a range where the function is well-behaved: SphericalPlot3D[ Sqrt[1/(Sin[θ]^2 Cos[2 ϕ] - Cos[θ]^2)], {θ, 0, π}, {ϕ, 0, 2 π}, MaxRecursion -> 4, PlotRange -> {-3, 3}, RegionFunction -> Function[{x, y, z, θ, ϕ, ...


16

$Version (* "8.0 for Microsoft Windows (64-bit) (October 7, 2011)" *) Direct attack fails: Timing[Convolve[Sinc[x], Exp[-x^2], x, y]] (* Out[218]= {59.296, Convolve[Sinc[x], E^-x^2, x, y]} *) or, equivalently, Timing[Integrate[Sinc[x] Exp[-(x - y)^2], {x, -∞, ∞}] ] $\left\{49.92,\int_{-\infty }^{\infty } e^{-(x-y)^2} \text{Sinc}[x] \, dx\right\}$ ...


15

Having experienced similar problematic issues with Mathematica I instantly thought that expanding the fraction in the integrand i.e. applying Appart could resolve the problem, and indeed it does: Integrate[ Apart[(1 - x)(1 + 2x)^6/Sqrt[1 - x^2]], {x, -1, 1}]/Pi 15 These arguments apply to this case as well Bug in mathematica analytic integration? i.e. ...


14

Update a working approach using Fourier transforms The following method is based on the idea that the Laplace operator is just a multiplication with $-k^2$ in Fourier space. Therefore, I first find the Fourier transform of the $1/r$ potential and then do an inverse Fourier transform of that result, multiplied by $-k^2$ (which I call laplacianFT in the ...


14

The "canonical" way in Mathematica is f[x_, y_] := x^2 + y^2 g[x_, y_] := x^4 + 4 x y + 2 y^4 - 8 Maximize[{f[x, y], g[x, y] == 0}, {x, y}] If you want to make explicit usage of the Lagrange multiplier: ss = N@Solve[Grad[f[x, y] + λ g[x, y], {x, y}] == 0 && g[x, y] == 0, {x, y, λ}, Reals] gives the {x, y} coordinates of the maxs and mins. ...


13

In this second answer I give the cause for the mismatch in the integrals, show how to remove it, and make a suggestion to improve the function Integrate[]. Simplified restatement of the problem In order to focus on the core of the problem we consider the simpler integral $\int_0^1 \sqrt{\cos (2 π k r)+1} \, dr$. It has the square root and the cosine ...


13

The integrals can in fact be done exactly, but only if you make some use of the symmetries of the problem first. The circular ring geometry implies that the magnetic field will look the same in any vertical plane going through the rotation axis (which we call the z axis). Therefore, we don't need to specify three independent variables x, y and z to do the ...


13

As you notniced, the result is not correct. This is not uncommon with definite integrals, as the system needs to detect any special behaviour inbetween the integration bounds, which is hard. For this reason it's a good idea to verify such integrals numerically. We can get the correct result like this (please evaluate in a fresh kernel without ...


13

[This is not a full response, but too much detail for a comment.] The general rule is that any integral that can behave differently on a measure zero set in the space of real values of parameters is a candidate for giving a result that will not be what you want. There are other caveats as well, for example in dealing with multiple integrals. And sometimes ...


13

Yes, this is a bug in the more general function RegionMeasure. I knew there were some edge cases in the handling of inexact numberics, but I was unaware of such a simple example. I will forward this bug internally. Workarounds include using the parametric (2-argument) form of ArcLength, and using DiscretizeRegion to preprocess regions before sending them ...


13

Introduction as of 31 January 2015 This is a very interesting problem which on trying to solve it with Mathematica requires skilled handling in an interactive way ("man-machine-interaction"). What do you do when Mathematica refuses to solve an integral? How to help solving integrals which Mathematica declares (erroneously) as divergent. I have done an ...


13

There is a specific function called CountRoots, which does exactly what you want: CountRoots[poly, x] (* 12 *) You can then compare this number to the number of roots given by the length of the coefficient list: Exponent[poly, x] (* 36 *)


13

Update: a way of joining (taking the union of) the first rectangle and first circle, so that the edge form only marks the exterior of the joined form p = 100; curve = Line@ Table[{.53, 0} + {.07, Sqrt[0.5]} {Sin[-2 Pi k /p], Cos[-2 Pi k /p]}, {k, -1 + p/2}]; poly = Polygon[Join[t1 = Table[{.47, 0} + {.07, Sqrt[0.5]} {Sin[-2 Pi k /p], ...


12

$Version (* Out[228]= "8.0 for Microsoft Windows (64-bit) (October 7, 2011)" *) The result provided by Mathematica is correct: Integrate[a/(a^2 + Sin[t]^2), {t, 0, 2 π}] (* Out[213]= (2 π)/(Sqrt[1 + 1/a^2] a) *) Now the same procedure as "always" which "explains" the zero result. The indefinite integral is Integrate[a/(a^2 + Sin[t]^2), t] (* ...


11

From Weierstrass Approximation Theorem we know there is such a polynomial, moreover there are infinitely many polynomials satisfying given criterion. Therefore we would like to find those ones of the minimal order. Since we are supposed to exploit series approximations we define a polynomial of n - th order approximating 6 ArcTan[x] for x such that ...


11

Partial sums of this sequence are given by: Sum[(-1)^(n + 1) Cos[3^n x]^3/3^n, {n, 1, m}] (* output: 1/4 Cos[3 x] - 1/4 (-(1/3))^m Cos[3^(1 + m) x] *) For real $x$, we know this converges because $\cos(3^{1+m}x)$ is bounded. Mathematica does not assume $x$ is real and, as Bob Hanlon notes, will produce the correct result by evaluating a partial sum, ...


11

I suspect you are correct in your assessment. Since there are approximate numbers in the input, Maximize punts to NMaximize, which uses penalty methods to enforce some constraints (not sure why it needs them here for linear constraints; I need to check into that). You can get better behavior by forcing real values. NMaximize[{Re[(h*10)/(300*(100 - (l^.5 + ...


11

Use NDSolve antiD = NDSolveValue[{f'[x] == Sqrt[1 + x^3], f[0] == 0}, f, {x, 0, 10}] Example usage: Plot[antiD[x], {x, 0, 10}] Alternatively... This works because this function can be antidifferentiated (by Mathematica). antiD = FunctionInterpolation[ Evaluate @ Integrate[Sqrt[1 + x^3], {x, 0, t}, Assumptions -> 0 < t < 10], {t, 0, ...


11

$$\mathbb{P} \big(\sum_{i=1}^{m} (A_i + S_i) \le L < \sum_{i=1}^{m+1} (A_i + S_i) \big) = \frac{\mu ^m (2 \lambda +\mu )}{2^{m+1} (\lambda +\mu )^{m+1}}$$ Observing: d1 = TransformedDistribution[ a + s, {a \[Distributed] ExponentialDistribution[λ], s \[Distributed] ExponentialDistribution[μ]}] (* ...


11

I've got a theory.... Let's try to get the antiderivative: Integrate[(1 + 16*Tan[2*x - y]^2)/(1 + 4*Tan[2*x - y]^2), x, Assumptions -> y \[Element] Reals] (*returns 5 x - (5 y)/2 - ArcTan[2 Tan[2 x - y]] *) Seems legit. You can test with D[5 x - (5 y)/2 - ArcTan[2 Tan[2 x - y]], x] and plot or rearrange. This antiderivative is technically correct, ...


11

Just purely for fun: to illustrate approximation of volume integral. Manipulate[ Module[{dp, dpl, dpu, r = Range[0, 1, 1/n], f, cc, lb, la, ub, ua, ll, ul}, dp = Range[0, 1, 1/#] & /@ Range[2, 100]; dpl = Total[Pi Most[#]/(Length@# - 1)] & /@ dp; dpu = Total[Pi Rest[#]/(Length@# - 1)] & /@ dp; f = Sqrt /@ r; cc = Partition[{#, 0, ...


10

Here is the derivation promised earlier. I have chosen to create a new answer in order not to mix things up and because it shows some handling which I like to call "man-machine" interaction with Mathematica. And, sorry for the "Greeks", but I find it very cumbersome to reedit them :-( $Version "8.0 for Microsoft Windows (64-bit) (October 7, 2011)" ...


10

Taylor polynomials of order n aren't necessarily the nth degree polynomials that optimally approximate a function on a given interval. We can use linear least squares to find the optimal polynomials for a fixed n. inn[f_, g_, x_] := Integrate[f g, {x, -1/Sqrt[3], 1/Sqrt[3]}] LeastSquarePolynomial[f_, x_, n_] := With[{pows = x^Range[0, n]}, pows . ...


10

The limit is definitely computed correctly. Keep in mind that Limit assumes the variable (n, in this case) is continuous. Thus, this is a specific example of the general fact that $f(x)\sin(g(x))$ oscillates back and forth over the whole real line, whenever $f(x)$ and $g(x)$ both increase to $\infty$ with $x$. A plot verifies this is correct. ...


10

Thanks to Artes for helping me sort out bugs in this answer. Solve[E^(-x^3 - y) - 1 - y == 0, y] {{y -> -1 + ProductLog[E^(1 - x^3)]}} To account for that fact that $-4 < y = z < 4$ we need to find the range of allowed $x$ values. FindRoot[-1 + ProductLog[E^(1 - x^3)] == 4, {x, 1}] {x -> -1.77681} FindRoot[-1 + ProductLog[E^(1 - ...


10

Brute force approach: g[y0_] := x /. FindRoot[ Exp[-(x^3 + y)] - 1 == y /. y -> y0 , {x, -4, 4}] line = Table[{g[y], y, y}, {y, -1, 4, .0001}]; Graphics3D[Line@line] Total[Norm@(Subtract @@ #) & /@ Partition[line, 2, 1]] 10.9513



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