# Tag Info

43

In the first case PowerExpand comes to the rescue: PowerExpand@Power[p^(n m) q, 1/n] (* Out: p^m q^(1/n) *) Note however that "the transformations made by PowerExpand are correct only if $c$ is an integer or $a$ and $b$ are positive real numbers". Generally speaking, your assumptions can be listed in Reduce, Simplify, or FullSimplify using the ...

18

I can't help you with functions beyond Reduce, Simplify, ... but I can offer you a tip to help with reducing errors from manual translation. In order to validate that your manual transformation is correct, one can subtract the original expression from the manual transformation and then use Simplify on that expression. Sometimes it will return zero using ...

17

One thing is to make sure you have all the assumptions stated properly. For instance, the first two cases can be handled by passing all the assumptions to FullSimplify FullSimplify[Power[p^(n m) q, 1/n], Assumptions -> {q > 0, p > 0, n ∈ Integers, m ∈ Integers}] p^m q^(1/n) and FullSimplify[(p^n q)/(p^m r), Assumptions -> {q > 0, p &...

17

I use Mathematica in much the same way as you, although in the context of multi-stage physics derivations. Since no one has mentioned it, I'll describe an obvious approach to successive rewrites of an expression. I label each step a calculation with an indexed symbol that I can refer to later. This is preferable to In's and Out's whose numbers can change if ...

17

I believe there are at least three cases treated separately by Derivative. 1) A function defined by a Symbol. This follows the the rule cited in the documentation. g[x___] := f[x]; Derivative[1][g][x] // Trace (* { { g' , { g[#1] <-- Here the rule is being applied , f[#1] } , f'[#1] & } , (f'[#1] &)[x] , f'[x] } ...

13

I often find that Simplify, etc work better when applied to parts of an expression. As I mentioned in this post, using something like Collect[expression, {selectedvariables}, Simplify[#, options -> values]& ] can work well in this respect. More generally, if you wish to simplify a particular Part, try expression[[index]] = Simplify[expression[[...

12

I think the reason, at least primarily, that it works differently for Plus is the following from its documentation: Unlike other functions, Plus applies built-in rules before user-defined ones. It may seem a little obscure, because perhaps we don't know all the rules, but these two are mentioned explicitly: Plus[] is taken to be 0. ...

12

I don't know what Mathematica is doing, but there are two ways to justify the result (if you're willing to accept different formulations of integrability). In an analogy with Cesàro summability, the 2 Cos[1] is the "Cesàro sum" $$\int_0^\infty f(u) \; du \buildrel C \over = \lim_{z \rightarrow \infty} {1 \over z} \int_0^z \int_0^y f(u) \; du \; dy$$ of the ...

11

For symbolic matrices, at dimension 12, Det switches from a memoization version of cofactor expansion to one-step row reduction. If the input is exact then denominators can be (and I believe are) removed. The approximate coefficient case is another story entirely; "exact" polynomial division will fail due to round-off error. Here is a 12x12 example with a ...

10

There is another option, using the relatively new tensor capabilities of Mathematica. This is pretty much copied from another answer by jose, but I don't need any assumptions here: TensorExpand[KroneckerProduct[X, X] + KroneckerProduct[-X, X]] (* ==> 0 *) TensorExpand[KroneckerProduct[2 X, 3 Y]] (* ==> 6 KroneckerProduct[X, Y] *) There is a ...

10

This is following Jens's suggestion to use a different Unicode glyph, but different from the answer linked in the corresponding comment. We can use Unicode directly, so let's just find a letter-like modifier glyph that looks good. A quick search for "prime" gives a nice solution in MODIFIER LETTER PRIME. You can type it using the notation \:02b9 which ...

10

To elaborate a bit on Michael's comment, let's first consider this statement from the docs: Sum and Product use over 100 pages of Wolfram Language code. Executing ?Sum* will in fact show you some of the internal routines used behind the scenes by the function Sum[]. You, the regular user, are not usually intended to access these by yourself; however, ...

10

Consider Derivative[1][f[##] &] // FullForm Function[0] Function[0][x] 0 So the snippet you quote from the docs might not be entirely accurate; might not be considering such an edge case as ##. I believe that Derivative is looking for head Slot when detects a pure function goes on to rewrite it, so it ignores head SlotSequence -- i.e., ...

9

Update, December 22 I've developed a version that is more robust. I believe it should work in general, but I'm sure there are some corner cases that won't work (and probably some-not-so-corner cases too). As before we add rules to the almost-no-built-in-meaning NonCommutativeMultiply (**): Clear[ncm] ncm[a__] := NonCommutativeMultiply[a] Unprotect@...

8

One way to avoid the singularity in 0-th coefficient is to regularize the original function. The problem is due to it being a polynomial, which is why we get powers of n in denominator by partial integration - the procedure that is obviously failing for the 0-th harmonic. Obviously this is a shortcoming for the current way Mathematica computes Fourier ...

7

As mentioned in my comment to the question, I think the best solution is to use a Unicode character (see also the answer by The Vee). Here is a modified version of my earlier answer: SetOptions[EvaluationNotebook[], InputAliases -> DeleteDuplicates@ Join[{"'" -> FromCharacterCode[700]}, InputAliases /. Quiet[Options[...

7

Since Mathematica 10, there is the TypeSystem Context, that is nearly what you might be looking for. It is just a wrapper around patterns. TypeSystemConformsQ[ {1, 2, 3}, TypeSystemVector[TypeSystem`IntegerT, 3] ] (* --> True *) It is the thing being used internally by Dataset-related functions. (Maybe one should say something like Dataset[{}] ...

7

I'm just going to walk through all of it. If something is too pedantic, skip it. Module[{f,g}... creates a scoping construct so the definitions of f and g are local to this code. Tally[a] produces a list of all the elements in a and a count for each element. For instance, Tally[{a,a,b,c,a,d,d}] would give {{a,3},{b,1},{c,1},{d,2}}. The strange ...

7

As a workaround you can generate a sequence and use FindSequenceFunction max = 10; seq = Sum[StirlingS2[i, 2], {i, 0, #}] & /@ Range[max] (* {0, 1, 4, 11, 26, 57, 120, 247, 502, 1013} *) f[n_] = FindSequenceFunction[seq][n] // Simplify (* -1 + 2^n - n *) seq === (f /@ Range[max]) (* True *)

7

The null space is going to be a very large matrix. I'll show how to generate the space of nonnull vectors (I think that might be called the coimage or something like that). I will demonstrate this method for dimensions 56 by 1000 (56 because that's how many xyz monomials there are through degree 5). deg = 5; monoms = Union[ Flatten[Outer[Times, Sequence ...

7

Simplify[a^2 + a*b^2 + b, b^2 == c - a] (* b + a c *) Or a^2 + a*b^2 + b /. b^2 -> c - a // Simplify (* b + a c *)

7

What about computing a general $t$-bound integral: expr = Integrate[Exp[-2 ((x + y)/2 - b)^2/(2*a)], {x, -t, t}, {y, -t, t}]; And then expanding in series around $t=\infty$: Series[expr, {t, Infinity, 3}] // Normal // PowerExpand // FullSimplify $\frac{a^2 \left(e^{-\frac{(b-t)^2}{a}}+e^{-\frac{(b+t)^2}{a}}\right)}{t^2}-4 a e^{-\frac{b^2}{a}}-4 \sqrt{\... 7 I upvoted the other responses. That said, there is a better way. CoefficientList[ Resultant[x^3 + a2*x^2 + a1*x + a0, y - (x^3 + x + 1), x], y] (* Out[1179]= {-1 + 4 a0 - 3 a0^2 + a0^3 - a1 - 2 a0 a1 + 2 a1^2 + a0 a1^2 - a1^3 + a2 + a0 a2 - 2 a0^2 a2 - 3 a1 a2 + 3 a0 a1 a2 + a0 a2^2 - a1 a2^2 + a2^3, 3 - 6 a0 + 3 a0^2 + a1 - 2 a1^2 + a1^3 - 2 a2 - ... 6 I'm a little bit late to this party, but I had written this function for another question that turned out not to need it, so I'll put this here. My strategy is to straightforwardly calculate the integral via this formula$\$ \begin{align} \int f(\vec x) &\, \exp\left( - \frac 1 2 \sum_{i,j=1}^{n}A_{ij} x_i x_j \right) d^nx = \\ & \sqrt{(2\pi)^n\over ...

6

The solution is a straightforward application of Integrate. Integrate[Exp[-((x - x0)^2 + (y - y0)^2)/(2 c) - I (kx x + ky y)], {x, -Infinity, Infinity}, {y, -Infinity, Infinity}, Assumptions -> c > 0] (* 2 c E^(-(1/2) c (kx^2 + ky^2) - I (kx x0 + ky y0)) π *)

6

Everything you want in the question can be done by defining the derivative of the Norm: Derivative[1][Norm][z_] := z/Norm[z] D[Norm[x - y], {x}] (* ==> (x - y)/Norm[x - y] *) Simplify[D[Norm[x - y], {y}]] (* ==> (-x + y)/Norm[x - y] *) Here, the syntax I used for the derivatives is such that it would remain valid if x or y were replaced by vectors ...

5

From solution provided by kirma to your previous question Sum[24 n + 12 n^2, {n, 1, Infinity}, Regularization -> "Dirichlet"] (* -2 *) From solution provided by xzczd to your previous question ramanujanSum[f_] := Block[{x, n}, FullSimplify[-Sum[ BernoulliB[n, 1]/n SeriesCoefficient[ f[x], {x, 0, n - 1}], {n, \[Infinity]}], n >= 1]]...

5

We will go by solving one equation at a time and generating the corresponding replacement rules. Beware of possible numerical instabilities. The following is the equivalence between the code in your edited example and my code on the previous incarnation of this answer. I think this is enough for you to use it. Please note that the only claim on the ...

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]] Grid[...

5

Here is code for a function bSolve which is to be used essentially like Solve. Given some equations as its first argument and some variables (or in fact more complicated expressions) as its second argument, it finds the values of the variables, eliminating all occurrences of p[...]. The probability of a is denoted by p[a] and the conditional probability of ...

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