Hot answers tagged

12

s = {w, x, y, z}; sum = {-1, 3, 5, 8}; add = Plus @@@ Subsets[s, {3}] (* {w + x + y, w + x + z, w + y + z, x + y + z} *) Solve[add == sum, s] (* {{w -> -3, x -> 0, y -> 2, z -> 6}} *)


11

The region within the three curves can be plotted and its area determined using Mathematica's geometric capabilities. RegionPlot[y < 3/x && y < 12 x && y > x/12, {x, 0, 6}, {y, 0, 6}, PlotPoints -> 200, FrameLabel -> {x, y}] and integrate its area by Area[ImplicitRegion[y < 3/x && y < 12 x && y ...


10

Here is one way: noIn[y_, x_] = y; noIn[Indeterminate, x_] = Round[x]; transIn[x_] = noIn[(1 + Erf[2 ArcTanh[2 x - 1]])/2, x]; transOut[x_] = noIn[(1 - Erf[2 ArcTanh[2 x - 1]])/2, x]; SeedRandom[15] f[x_, y_] = RandomReal[{-1, 1}, 4].Sin[RandomReal[{-2, 2}, {4, 4}].{1, x, y, x^(4/3)}]/3; r[t_] = {1/2 + Sin[t] + t^(3/2) - (t/2)^2, Sin[t] - t^2 + (2 t/3)^5 - ...


10

mat = ConstantArray[1, {4, 4}] - IdentityMatrix[4]; LinearSolve[mat, {-1, 3, 5, 8}] {6, 2, 0, -3}


9

Perhaps this? ip[f_, g_, v_] := Module[{x, y, int}, int = (((f /. v -> x) - (f /. v -> y)) ((g /. v -> x) - (g /. v -> y)))/(x - y)^2; Integrate[int, {x, -1, 1}, {y, -1, 1}] ]; Orthogonalize[x^Range[4], ip[##, x] &] (* {x/2, 1/2 Sqrt[3/2] x^2, 3/2 Sqrt[5/13] (-((2 x)/3) + x^3), 15/8 Sqrt[21/31] (-((14 x^2)/15) + x^4)} *) The ...


7

I do not know how you get the answer you post $2 \frac{\mu^2}{\mu^2+4 k^2}$, but if you tell Mathematica that both $\mu,\theta$ are either positive or negative at the same time, you get a similar answer but one that has a $\log$ in it: Clear[x, mu,k] integrand = Sin[x]/(1 + (4 k^2)/mu^2 (Sin[x/2])^2); Assuming[ Element[{mu, k}, Reals] && {mu, k} ...


7

Rules. Lots of rules. See the implementation notes in the documentation. I don't know of a way to show Mathematica's intermediate steps, but you can load the Rubi symbolic integration package, which will in fact show how it does an integral with ShowSteps=True;. Also it seems to work better than Mathematica's integrator. Int[Sin[x]^2/(x^2 + 1), x] Rule ...


6

I think because of your parameters it's having a hard time inferring convergence / continuity conditions. For instance, the integral diverges when $\eta < 0$. You can specify assumptions and get the result: Integrate[E^(-η(x - q) - E^(-η(x - q))), {x, t, ∞}, Assumptions -> η > 0] (1 - E^-E^((q - t)η))/η Side note, Mathematica has no problem ...


5

The original problem is an interesting example where a direct usage of Solve and NSolve fails. However Reduce can succeed solving it if we set unknowns in an appropriate order, thus there is no need to play with numerical functionality if symbolic one can resolve the given system. We can observe that there is a solution under the given condition with a == ...


5

I seem to be getting different results depending on whether I use OP's suggested inner product in the comments, or if I use the polarization identity. Before everything else, however, here is a routine by Velvel Kahan for evaluating the divided difference of a polynomial, based on Horner's method: polynomialDividedDifference[poly_, {x_, a_, b_}] /; ...


5

Direct Integration Possible issues in performing the integrations include choice of Assumptions, branch cuts in the integrands, and how limits are taken. Addressing the first of these gives five solutions. il[f_, s_, t_] := Module[{r}, 1/(2 π I) Integrate[f Exp[s t], {s, r - I ∞, r + I ∞}, Assumptions -> r > 2 && t > 0]] ...


5

Confirmed for 10.4.1 as Alexei. However, WolframAlpha still gives the c/s result. See result from Wolfram|Alpha And using the properties of Dirac delta function, I would say that c/s is the correct one. May be a bug of the new 10.4.1? You can test with numeric constants, and Mathematica gives the correct answer. But symbolic result is wrong, ...


5

This integral has not a value in Riemann's sense, then it has not a value independent of your particular problem, as many people already commented above. Hence, it is better to use the residue theorem, and decide whether you want to include the residue from the pole at +b, at -b, both ou none. Therefore: rplus = Residue[E^(I a x)/(x^2 - b^2), {x, b}] ...


5

Sometimes they're equal: Block[{a = 2, b = 4}, {NIntegrate[E^(I a x)/(x^2 - b^2), {x, -Infinity, -b - I, b + I, Infinity}], -((π (I Abs[b] Cos[a b] + b Sin[a b]))/b^2) // N} ] (* {-0.77704 + 0.114275 I, -0.77704 + 0.114275 I} *) Kidding aside, perhaps you should specify PrincipalValue -> True (which I just noticed, belatedly, than Daniel ...


4

In Mathematica notation $Assumptions = ϕ ∈ Reals F[ϕ_, m_] := Integrate[1/Sqrt[1 - m Sin[θ]^2], {θ, 0, ϕ}] Plot[F[ϕ, -1], {ϕ, - Pi, π}, PlotStyle -> Red] In Maple notation F[\[Phi]_, k_] := Integrate[1/Sqrt[1 - k^2 Sin[\[Theta]]^2], {\[Theta], 0, \[Phi]}] Plot[F[\[Phi], I], {\[Phi], -2 Pi, 2 \[Pi]}] In maple


4

First of all there is somewhere in Mma a package for numerical calculation of derivatives, but I did not manage to find a reference. To offer a way to calculate the derivative. You could use the interpolation function. Here is your list: lst = {{0, 1}, {5/999, 0.999925}, {5/333, 0.9997}, {25/999, 0.999325}, {35/999, 0.998801}, {5/111, 0.998127}, ...


4

MapAt[D[#, x] &, Piecewise[{{x^2, 0 <= x <= 1}, {x, x <= 4}}], {{1, ;; , 1}}] Note: this function works for expressions with Head Piecewise. For general expressions that contain Piecewise subexpressions, it can be used with ReplaceAll as follows: Y[x_] = Piecewise[{{x^2, 0 <= x <= 1}, {x, x <= 4}}]*F + Piecewise[{{x^4, 0 <= ...


4

When you use Mathematica, you could start with a plot like this Plot[{3/x, 12 x, x/12}, {x, 0, 10}, PlotRange -> {{0, 10}, {0, 10}}] Then you can see where the area is which you should integrate. And by using Solve[3/x == 12 x, x], Solve[12 x == x/12, x] and Solve[x/12 == 3/x, x] you can calculate the three intersections which are 0, 0.5 and 6. ...


3

I think you mean you want to calculate the area between a function and the x-axis. Define the function : g[x_] := E^(5 x) Show the area between the function and x-axis over the interval [−4,2] : Plot[g[x], {x, -4, 2}, PlotRange -> Full, Filling -> Axis, FillingStyle -> Yellow] With the knowledge of Calculus, the area can be computed with ...


3

Analysis of the error (bug?) We can see from the trace below that the second limit, which carries out a ratio test for the product, mistakenly yields -17 (which would indicate divergence, if correct). Trace[ NProduct[(n^2)!/stirling[n^2], {n, 1, Infinity}], _Limit, TraceInternal -> True, TraceForward -> True] There might have been some ...


3

You can define a custom transformation function: sepint[expr_] := expr /. Integrate[Plus[a_, b_], c_] :> Plus[Integrate[a, c], Integrate[b, c]] Then apply it to the expression. The ComplexityFunction can be used to eliminate the DiracDelta in the expression. Simplify[Integrate[ Integrate[K[x, z] u[z], {z, -Infinity, +Infinity}] K[x, y] + ...


3

The problem is that you are not using large enough precision goal for an oscillatory integrand with very small absolute values over the integration range. Look at the log plot -- there are more oscillations than the ones visible with Plot: The remedy is to use higher precision goal. Try this: NIntegrate[ Re[(x^4 Sin[x b])/(9 + 4 d^2 x^2)^6 1/ 2 ...


3

Let, $$ f=\frac{z-e^{i \pi/2 n}}{z^{2 n}+1} $$ Then, in Mathematica code, the following seems to work, Limit[f, z -> Exp[(I Pi)/(2 n)], Assumptions -> n >= 1/2] which gives the result, $$ -\frac{e^{i \pi/2 n}}{2n} $$ The problem isn't that Mathematica is handling the $0/0$ limit incorrectly. It's that Mathematica, without additional information, ...


3

This is your definition: m = 1; u[x_, t_] = (t^\[Alpha]*x*(2*t^2 + (1 + \[Alpha])*(2 + \[Alpha])))/ Gamma[3 + \[Alpha]]; Your code makes 3.19 seconds on Mma10.4.1 DUt = FullSimplify[(1/Gamma[m - \[Alpha]])*Integrate[(t - \[Tau])^(m - \[Alpha] - 1)*D[u[x, \[Tau]], {\[Tau], m}], {\[Tau], 0, t}], Assumptions -> {m - 1 < \[Alpha] < m, t ...


2

It should be mentioned at this juncture that ExtremeValueDistribution[] is built-in; up to a normalizing factor, your distribution is equivalent to ExtremeValueDistribution[q, 1/η]. Thus, PDF[ExtremeValueDistribution[q, 1/η], x] // Simplify E^(-E^((q - x) η) + (q - x) η) η SurvivalFunction[ExtremeValueDistribution[q, 1/η], t] // Simplify 1 - E^-E^((q ...


2

I have accepted Jens' method, since it works and with a minimum of inconvenience. However, it is more useful when generalized to multiple derivatives, so I will show what I did to accomplish that below. I also want to present two other work-arounds that I came up with. I do not like either as well as Jens', but they may be useful in cases where one does not ...


2

Braces [], brackets {}, and parenthesis () all have different meanings in mathematica. Sorry for the post. I will read the documentation and tutorials more completely.


2

One could also feed the ODE into DifferentialRoot[] (along with arbitrary initial conditions) and then apply FunctionExpand[]. sol = FunctionExpand[DifferentialRoot[Function[{y, x}, {y''[x] + 2 y'[x] + 5 y[x] == x Cos[x], y[0] == C[1], y'[0] == C[2]}]][x]]; ...


2

Here's a symbolic-algebraic way, based on the cylindrical algebraic decomposition (CAD) that Reduce computes. (* Disk/Washer method *) Clear[x, y, z]; eqns = {y == (x - 2)^4, 8 x - y == 16}; axis = x == 10; {depV} = Variables[Subtract @@ axis]; {indepV} = Complement[{x, y}, {depV}]; vars = {indepV, depV}; components = Map[ Reduce[#, vars] &, (* ...


2

Lets start with a simpler case Integrate[q0/(-1 + a q^2), q] $\frac{\log \left(1-a \text{q}^2\right)}{2 a}$ When you put limit [0,A], it has no problem with q=0. But it is not defined when $aA^2>1$. So you always have to obey that condition. You can check that by Integrate[q0/(-1 + a q0^2), {q0, 0, A}] In your second case Integrate[q0/(-1 + 12. ...



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