Tag Info

Hot answers tagged symbolic

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

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

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

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

Is this what you want? Clear[Derivative, h]; h[0] = 1; (* to avoid division by zero with OP's example R *) Derivative[1][h][s_] := Block[{Derivative}, h'[\[FormalS]] /. First@Solve[ D[R[a + h[\[FormalS]]] == - \[FormalS], \[FormalS]], h'[\[FormalS]]] /. \[FormalS] -> s ]; Derivative[n_][h][s_] := D[Derivative[n - 1][h][\[...

9

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

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{\... 6 MyLine is embedded in 2D space, thus for$x\in\text{MyLine}$, x is a 2D point and Sin[x] just makes no sense. You probably meant the interval Interval[{-Pi,Pi}] instead, which I think should work. But it doesn't. I don't know why. Maybe a bug? In[27]:= MaxValue[Sin[x], x \[Element] Interval[{-Pi, Pi}]] During evaluation of In[27]:= MaxValue::objfs: The ... 6 Update Based on J.M.'s answer, I have improved my ugly code and used his approach. Otherwise the format is as outlined in original answer. Manipulate[p = {-a, 0}; q = {0, b}; r = {c, 0}; s = mp[a, b, c]; nfb = RegionNearest[Circle[{0, 0}, b]]; nfc = RegionNearest[Circle[{0, 0}, c]]; res = VectorAngle @@@ Partition[Join[{{-a, 0}}, sc[#] & /@ ({u, ... 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

It is because there is no general solution for your problem, even for b being a positive integer: When b is odd, the maximum is positive infinity, while for even b it is not. You may want to use things like Maximize[-x^# + a*x, x] & /@ Table[i, {i, 5}] to observe.

6

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

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