Tag Info

New answers tagged

2

Just to illustrate versatility of Mathematica: Plot3D[2 x - y, {x, -2, 2}, {y, -2, 2}, RegionFunction -> Function[{x, y, z}, x^2 + y^2 < 4]] f = TransformedField["Cartesian" -> "Polar", 2 x - y, {x, y} -> {r, t}]; j = Simplify[Det[Outer[D[#1, #2] &, {r Cos[t], r Sin[t]}, {r, t}]]]; Integrate[f j, {r, 0, 2}, {t, 0, 2 Pi}] where the ...


2

While belisarius's comment answers the question, an arguably better way to achieve these is to use regions. For example, the plot is less choppy and there is less rounding error when integrating (for this example at least). (* without regions *) f[x_, y_] := 2*x - y (* choppy plot *) Plot3D[f[x, y], {y, -2, 2}, {x, -1*Sqrt[4 - y^2], Sqrt[4 - y^2]}] (* ...


1

If you do the integral without taking the limit, you get the following: Defft[x_] := (-1 + x)^4 foo = Integrate[x^2/(λ Defft[x] + x^2 Dmol), {x, 0, 1}, Assumptions -> Dmol ∈ Reals && λ ∈ Reals && Dmol > 1 && λ > 0] The conditions in the ConditionalExpression are saying that none of the roots of the polynomial in the ...


4

Here's one speed-up: Use approximate machine real inputs. Outer is a bit faster than Table here. Clear[x, y]; f[x_, y_] := (Cos[x] Sin[y])/2 (*The surface.*) df[x_, y_] = D[f[x, y], {{x, y}}]; normalVector[a_, b_] := Join[-df[a, b], {1}]; tangentVector[x_, y_, θ_] := Join[#, {df[x, y].#}] &@{Cos[θ], Sin[θ]}; xr = yr = 1; n = 20.; (* < this ...


2

Just for fun: f[x_, y_] := Cos[x] Sin[y]/2 grd[u_, v_] := Grad[z - f[x, y], {x, y, z}] /. {x -> u, y -> v}; tg[x0_, y0_, {a_, b_}] := With[{ru = {1, 0, D[f[x, y], x] /. {x -> x0, y -> y0}}, rv = {0, 1, D[f[x, y], y] /. {x -> x0, y -> y0}}}, a ru + b rv] tn[x_, y_, {s_, t_}] := With[{pt = {x, y, f[x, y]}}, Graphics3D[{Point[pt], ...


3

As stated in the OP Mathematica finds this value of the integral within seconds f0 = Integrate[x^2 Log[1 - E^-x], {x, 0, \[Infinity]}] (* Out[21]= -(\[Pi]^4/45) *) Most probably Mathematica employs this standard procedure: 1) solve the indefinte integral, i.e. find an antiderivative 2) check continuity of the antiderivative 3) use the fundamental ...


4

As simple as it sound, use Set instead of delayed assignment. i.e., replace your := in the function definitions with =. First, make sure everything is safe by clearing x,y,a,b as: ClearAll[x,y,a,b] Then, define your functions as: f[x_, y_] = (Cos[x] Sin[y])/2.; (*The surface.*) fx[a_, b_] = Module[{x, y}, D[f[x, y], x] /. {x -> a, y -> b}]; ...


3

I would localize the variables inside the DynamicModule created by the Manipulate by using the ControlType -> None (or simply None for short) specification. This use is discussed here: What does None mean in a control specification for Manipulate? ControlType -> None Vs. Module inside Manipulate (i.e. making everything local) Code: ...


9

Just wanted to update everyone that things are much simpler, - there is built in support for this: MeshFunctions -> {"ArcLength"} So for our case: Show[{ ParametricPlot3D[KnotData[{3, 1}, "SpaceCurve"][t], {t, 0, 2 Pi}, (* the trick *) Mesh -> 15, MeshFunctions -> {"ArcLength"}, (* styles *) MeshStyle -> Directive[Red, ...


5

Products are polynomials in x: Table[Expand[Product[x^k*(1-x^k), {k, 1, n}]], {n, 1, 3}] (* {x - x^2, x^3 - x^4 - x^5 + x^6, x^6 - x^7 - x^8 + x^10 + x^11 - x^12} *) Integration of polynomials is easy: Table[Integrate[Expand[Product[x^k*(1-x^k), {k, 1, n}]], x], {n, 1, 3}] (* {x^2/2 - x^3/3, x^4/4 - x^5/5 - x^6/6 + x^7/7, x^7/7 - x^8/8 - x^9/9 + x^11/11 ...


7

evenFQ[f_] := Simplify[f[t] - f[-t]] === 0 oddFQ[f_] := Simplify[f[t] + f[-t]] === 0 Examples: ef[x_] := x^2 of[x_] := x^3 evenFQ/@ {ef, of} {True, False} oddFQ/@ {ef, of} {False, True} evenFQ /@ {# &, Im, Sin, Tan, Sinh, Erf} {False, False, False, False, False, False} oddFQ /@ {# &, Im, Sin, Tan, Sinh, Erf} { True, ...


5

Rather than imposing x>0 one can also do FullSimplify[ ForAll[x, myOddFunction[x] == myOddFunction[-x]]] which yields False.


4

You need Simplify with an assumption: myOddFunction[x_] := x^3; Simplify[ Equal[myOddFunction[x], myOddFunction[-x]], x > 0 ] False Refine also works in this case, again with the appropriate assumption: Refine[Equal[myOddFunction[x], myOddFunction[-x]], x > 0] False


1

This is a stab at cleaning it up. I put in table form so you can see how to loop over a. Needs["NumericalCalculus`"] Table[ g[t_] = {-(a + 2*Cos[2*t])*Sin[3*t], (a + 2*Cos[2*t])*Cos[3*t], 2*Sin[2*t]}; dg[t_] = If[t - 2*Pi <= 0, g'[t], g'[2*Pi]]; tfn = Module[{s}, NDSolveValue[{t'[s] == 1/Norm[dg[t[s]]], t[0] == 0, ...


6

[Edit notice: I'll put the gist up front.] 10 π is not wrong With proper assumptions given, the integral evaluates as desired by the OP, to 6 π. Without them, it gives one of the correct values of the integral, 10 π, the one that in some sense is more likely, but without the correct conditions attached. (One may well argue that is a bug. However, ...


0

Doesn't exist is only depends on the angle t. z = ComplexExpand[r*Exp[I*t]]; Limit[(1 - z)/(1 - Conjugate[z]), r -> 1] output: (-1 + Cos[t] + I Sin[t])/(-1 + Conjugate[Cos[t]] - I Conjugate[Sin[t]]) Explanation Click HERE


2

Oddly, if you follow the hints given in the ConditionalExpressions you can get pointed to the right answer although constrained to an overly restrictive region. $Version "10.1.0 for Mac OS X x86 (64-bit) (March 24, 2015)" expr = (1 + 16 Tan[2 x - y]^2)/(1 + 4 Tan[2 x - y]^2); Integrate[expr, {x, 0, 2 Pi}] ConditionalExpression[9*Pi, -(Pi/2) ...


1

Integrate and NIntegrate agree on this matter: Table[Integrate[(1+16 Tan[2 x-y]^2)/(1+4 Tan[2 x-y]^2),{x,0,2Pi}],{y,0,10,2}] (*==> {6π,6π,6π,6π,6π,6π}*) Table[NIntegrate[(1+16 Tan[2 x-y]^2)/(1+4 Tan[2 x-y]^2),{x,0,2Pi}],{y,0,10,2}] (*==> {18.8496,18.8496,18.8496,18.8496,18.8496,18.8496}*) N[6Pi] (*==> 18.8496*)


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


3

Edit: see the bottom of this post for the best solution. The documentation for CoefficientList says: The dimensions of the array returned by CoefficientList are determined by the values of the Exponent[poly, vari]. ser1 = Series[ArcTan[x]/(1 - x^2), {x, 0, 10}]; ser2 = Series[ArcTan[x]/(1 - x), {x, 0, 10}]; Exponent[ser1, x] Exponent[ser2, x] 9 ...


4

Doing the z integration first it takes less than a minute to run Timing[ Assuming[\[Theta]\[Element]Reals&&h\[Element]Reals&&h>0&&x\[Element]Reals&&y\[Element]Reals&&z\[Element]Reals&&z>0, Integrate[r*Integrate[(7695*h*x^2*y^2*z^6*Sin[2*\[Theta]])/(2*Pi*(h^2 + x^2 + y^2)^(5/2)*(h^2 + x^2 + y^2 + 2*h*z ...


9

Converting to polar coordinates helps with the xy integral: Assuming[θ ∈ Reals && h ∈ Reals && h > 0 && x ∈ Reals && y ∈ Reals && z ∈ Reals && z > 0, Integrate[((7695 h x^2 y^2 z^6 Sin[2 θ]) / (2 π (h^2 + x^2 + y^2)^(5/2) (h^2 + x^2 + y^2 + 2 h z + z^2)^8) /. {x -> r Cos[t], y -> r ...


8

It has to do with the default behavior of GenerateConditions in multivariate integrals. Setting it explicitly to True will help in this case. Some explanation may be found here or here. The gist is that, for multiple integration, automatically checking conditions and issuing provisos for all but the final integration is typically both too costly (in speed) ...


7

The "trick" which works frequently when Mathematica refuses to calculate a definite integral is to calculate first the indefinite integral, then take the limits at the ends of the integration interval and subtract the results. Here we go. Let the integrand be f = -((cA Log[1 + mgl^2/sa1])/(-1 + x)) + (cA Log[-(sa1/(-mgl^2 - sa1))])/(1 - x) + (cA cF Log[-1 ...


5

This s not an answer but an extended comment about results with v10.1 $Version "10.1.0 for Mac OS X x86 (64-bit) (March 24, 2015)" Integrate[1/(x y z), {x, 0, 1}, {y, 0, 1}, {z, 0, 1}] 0 Integrate[1./(x y z), {x, 0, 1}, {y, 0, 1}, {z, 0, 1}] 0 However,NIntegrate gives the a large result in either case with convergence warnings ...


3

Try this ClearAll[r, phi, th] x = r[t]*Cos[phi[t]]*Sin[th[t]]; D[x, t] (* -r[t] Sin[phi[t]] Sin[th[t]] Derivative[1][phi][t] + Cos[phi[t]] Sin[th[t]] Derivative[1][r][t] + Cos[phi[t]] Cos[th[t]] r[t] Derivative[1][th][t] *) Expressions like r = r[t]; can lead to infinite recursions.


7

It seems, that findExponentialGeneratingFunction would be equivalent to FindGeneratingFunction of the sequence {a1/0!,a2/1!,a3/2!,...}. Therefore findExponentialGeneratingFunction = FindGeneratingFunction[#1/(Factorial /@ Range[0, Length@#1 - 1]), #2] & findExponentialGeneratingFunction[{1,1,1,1,1,1,1,1},x] (* Exp[x] *)


2

Log[2] + Sum[(-1)^(k + 1) (x - 2)^k/(k 2^k), {k, 1, Infinity}] Log[x] Since Log is complex or unbounded for non-positive argument, the maximum difference is undefined for x <= 0 Log /@ {0, -1/4} // InputForm {-Infinity, I*Pi - Log[4]} The maximum difference will be arbitrarily large as x gets arbitrarily close to 0+. Clear[f] f[x_, n_] := ...


4

Perhaps this? Clear[DoubleContourIntegral]; DoubleContourIntegral[field_?VectorQ, surface : {changeOfVars : ({x_, y_, z_} -> param : {xuv_, yuv_, zuv_}), {u_, u1_, u2_}, {v_, v1_, v2_}}] := Integrate[ Dot[field /. Thread[changeOfVars], Cross[D[param, u], D[param, v]]], {u, u1, u2}, {v, v1, v2}]; Clear[a, b, c]; S = {{x, y, z} -> ...


1

Limit[(x - 2)/(2 x - 1)^(1/x), x -> 0] produces -2 E^(2 + 2 I Interval[{0, \[Pi]}]) This is a highly oscillatory function near the origin, much like Sin[1/x]. To plot the function try Plot[Re[(x - 2)/(2 x - 1)^(1/x)], {x, -1, 1}, PlotPoints -> 100, PlotStyle -> {Thin, Black}].


2

Adapting linearExpand from my answer to How to do algebra on unsolved integrals?, we can come up with some transformations to factor separable multiple integrals. The function someFunction internally deals with and returns Inactive integrals, which can be evaluated with Activate, if appropriate or desired. Examples someFunction[Integrate[p[x] p[y], {x, ...


1

As requested, I'm expanding on my comment above, in which I noted that $$ \frac{n^{x} - n^{-x}}{n^x + n^{-x}} = \tanh [ (\ln n) x] $$ If you want to coax Mathematica to show this for you, you have to be a little tricky. In particular, Mathematica will automatically evaluate Exp[Log[n] x] into n^x unless you tell it not to. However, if you Hold the ...


3

I can break the calculations down, but I cannot really explain the first one. This seems wrong: Integrate[DiracDelta[x] + Exp[-x], {x, 0, b}] (* ConditionalExpression[-Cosh[b] + 2 HeavisideTheta[b] + Sinh[b], b ∈ Reals] *) Its limit is 2. The ConditionalExpression suggests that Integrate is using assumptions to make choices. Let's help it out ...


2

I'd use Root. First, put your polynomial in pure functional form: fpoly = Function[Evaluate[poly /. x -> #]] Now, note that Root rigorously orders roots, putting real roots before complex ones. This is a 36th order polynomial, so look at the 36th root: Im[Root[fpoly, 36]] == 0 (* False *)


0

Maybe for this case use: someFunction[int_] := (int /. _[y] :> 1/2)^2


8

This will work with any number of independent integrants. Define: repl[l_] := # /. Thread[#[[All, 1]] -> Table[x, {Length[#]}]] &[l] inTfaC[int_] := Times @@ MapThread[Integrate[#1, #2] &, repl /@ {First[#], Rest[#]} &[ int /. {Integrate -> List, Times -> List}]] Now verify: test = Integrate[p[x] p[y] q[z] r[s] r[u], {x, ...


3

I can't speak for what's happening with your second example, but to answer your second question, you can ensure DiracDelta is included by integrating over a larger interval then taking a limit. Limit[Integrate[f[x], {x, -ε, ∞}, Assumptions -> 0 < ε < 1/10^10], ε -> 0] 2


11

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: Length@CoefficientList[poly, x] - 1 (* 36 *)


3

You can also use FindInstance, specifying the domain over all reals pol = 331776*x^36 - 11943936*x^34 + 195747840*x^32 - 1932263424*x^30 + 12809871360*x^28 - 60216016896*x^26 + 206610186240*x^24 - 524928024576*x^22 + 991718940672*x^20 - 1386996203520*x^18 + 1415900528640*x^16 - 1026732589056*x^14 + 505483296768*x^12 - 158084628480*x^10 + ...


4

There is probably a better way to do this, but one can find the degree of a polynomial via the length of the CoefficientList, and one can get the number of real roots by adding up the multiplicities given by RootIntervals: poly = 331776*x^36 - 11943936*x^34 + 195747840*x^32 - 1932263424*x^30 + 12809871360*x^28 - 60216016896*x^26 + 206610186240*x^24 ...


3

I think that you can use RootIntervals to do what you want: poly = 331776*x^36 - 11943936*x^34 + 195747840*x^32 - 1932263424*x^30 + 12809871360*x^28 - 60216016896*x^26 + 206610186240*x^24 - 524928024576*x^22 + 991718940672*x^20 - 1386996203520*x^18 + 1415900528640*x^16 - 1026732589056*x^14 + 505483296768*x^12 - 158084628480*x^10 + ...


2

Limit takes Assumptions Clear[f] f[x_] := Limit[(n^x - n^(-x))/(n^x + n^(-x)), n -> Infinity] Assuming[{#}, f[x]] & /@ {x < 0, x == 0, x > 0} {-1, 0, 1} Plot[f[x], {x, -5, 5}, Exclusions -> 0, Epilog -> {Red, AbsolutePointSize[6], Point[{0, f[0]}]}]


6

In a sense, the returned solutions are valid, but only over a restricted domain. We can determine the domain for each solution with something like Reduce[ode && -Infinity < t < Infinity /. sol, t] We can join the domain with the corresponding solution via ConditionExpression. ode = {x'[t] == Sqrt[x[t]], x[0] == 4}; dsol = DSolve[ode, x, ...


1

For this problem you are likely better off performing a zillion simulations and determining the proportion of times that the product is greater than c. Below is described a brute-force way to obtain the desired probability for 2 and 3 variables. If c > 0 and with 2 random normal variables either both need to be positive or both need to be negative for ...


1

I think the graph in your book contains an error. When we look closely at the graph of Alexei, then we see that for m=8 and g=0.2, the graph crosses the y-axis at 0.84. In the picture in your book, this is not the case and the crossing is at {0, 0.65} (the plot is log-scaled!). Additionally, Alexei's graph ends in {4, 0.67} while in your book this is the ...


4

The reason this is happening might be because Mathematica is internally producing AppellF1 functions. If you replace Sqrt[b^2 - c^2] with Sqrt[k] and integrate, then afterwards put back the b^2 - c^2 you get this mess ... tmp = Integrate[1/(-Sqrt[k] + b*Cosh[x] + c*Sinh[x])^(1/2), x]; tmp //. k -> b^2 - c^2 (* Result *) (1/(Sqrt[1 - b^2/c^2] c))2 ...


0

You might do as follows: ClearAll[F, z]; F[z_] := 0.5*(1 + Erf[z/Sqrt[2]]); p[lgB_, g_, m_] := 1 - (1/Sqrt[2*Pi])* NIntegrate[ F[z]^(-1 + m)/E^(0.5*((-2^(lgB/2))*g + z)^2), {z, -1000, 1000}, MaxRecursion -> 12]; Plot[{p[lgB, 0.2, 8]}, {lgB, -4, 4}] yielding this The key points are tha (i) I substituded B=^lgB, thus, introduced ...


2

If you plot the real parts of each half of your integral together Plot[{Re[-2^p Beta[2/3, -p, 1 + p]], Re[((-1)^p Hypergeometric2F1[1, 1, 1 - p, 2])/p]}, {p, 0, 10}] you'll see that each half goes to infinity in opposite directions, so the two singularities must cancel each other. Mathematica is stumbling over combining the two separate singularities ...


0

Just add an output line: rect4[f_, a_, b_, n_] := (ex = Integrate[f[y], {y, a, b}] // N; res = {}; rat = {}; nErr = 0.0; Do[(h = (b - a)/2.^nt; tmp = h Sum[f[a + i h], {i, 0, 2^nt - 1}]; oErr = nErr; nErr = Abs[ex - tmp]; AppendTo[res, nErr]; If[nt > 1, AppendTo[rat, nErr/oErr]];), {nt, 0, n}]; Grid[Thread[{Range[0, n], ...


1

In version 8 the integral is very simply solved without any explicit assuptions: $Version (* Out[6]= "8.0 for Microsoft Windows (64-bit) (October 7, 2011)" *) Integrate[Sqrt[a + b Cos[q]], q] (* Out[5]= (2 Sqrt[a + b Cos[q]] EllipticE[q/2, (2 b)/(a + b)])/Sqrt[(a + b Cos[q])/(a + b)] *)



Top 50 recent answers are included