# Tag Info

49

In general, a typical root of a negative number is complex, so you need to get rid of most roots. A nice approach would be Root, e.g. Root[ x^3 + 8, #] & /@ Range[3] {-2, 1 - I Sqrt[3], 1 + I Sqrt[3]} To get only real roots you can do : Select[Root[ x^3 + 8, #] & /@ Range[3], Re[#] == # &] {-2} This is a handy approach when you ...

38

If you Rationalize your real numbers you will be able to use Mathematica's arbitrary precision engine: poly2 = Rationalize[poly[z], 0]; Plot[poly2, {z, 0, 1}, WorkingPrecision -> 50] Arbitrary and machine precision Mathematica has two kinds of numeric calculations: machine precision, and arbitrary precision. Machine precision is fast but is ...

23

You may use a function, which gives you the "real Power": rprule=(b_?Negative)^Rational[m_,n_?OddQ]:>(-(-b)^(1/n))^m; Attributes[realPower]={Listable, NumericFunction,OneIdentity} (* same as Power *) realPower[b_?Negative, Rational[m_, n_?OddQ]] := (-(-b)^(1/n))^m; realPower[x_,y_]:=Power[x,y]; realPower[x_]:=x//.rprule; Then you'll get: ...

22

Mathematica 9 introduces two new functions, CubeRoot and Surd, that give real-valued roots: In[1]:= CubeRoot[-8] Out[1]= -2 In[2]:= Surd[-32, 5] Out[2]= -2 You can use these to plot real roots: Plot[CubeRoot[x], {x, -3, 3}] Note that these functions are undefined for complex numbers: In[5]:= CubeRoot[1 + I] CubeRoot::preal: The parameter 1+I ...

18

For computing the genus of a plane algebraic curve implicitly defined by a squarefree polynomial $f(x,y)$ there are different softwares available in the literature. Remark: I assume you are interested in computing the genus when the coefficients of the defining polynomial of the curve are either integers or rationals right? This is the case of exact data. ...

18

I will show a method that is conjectural, though i believe it is correct. It differs from the more common approach of using (quadratic) birational transformations to force singularities to be double points. More a detailed approach to that, see Madelina's response. Also I cover the exact case, although at least some of this could be adopted to the case of ...

18

I was waiting for OP to post his answer before posting mine. In any event, here's a general routine for performing polynomial depression (where completing the square corresponds to the quadratic case): depress[poly_] := depress[poly, First@Variables[poly]] depress[poly_, x_] /; PolynomialQ[poly, x] := Module[{n = Exponent[poly, x], x0}, x0 = ...

18

You can make plots sort of like this: Or this: Or this: ...by taking advantage of Image and Fourier using the following code. The plots will have a brightness proportional to the multiplicity of the root, and you can change the colors, convolution properties, etc., although it doesn't provide axes (you'll have to figure that out yourself). ...

17

This is caused by a bug in RootReduce for Root objects representing last coordinates of solutions of triangular systems. The bug affects cases where the last coordinate of the solution is real, but some of the other coordinates are not real. Thanks for pointing it out. The problem can be fixed with the following patch (you can put it in your init.m file). ...

17

Short answer is Expand[(x + y)^2] x^2 + 2 x y+ y^2 But I recommend you to look at the following tutorials. Transforming Algebraic Expressions Putting Expressions into Different Forms And of course a super tutorial: Algebraic Manipulation Also this palette maybe really useful: Top Menu >> Palettes >> Other >> Algebraic Manipulation

17

You can use PolynomialForm : Collect[(1 + x + Cos[s] x^2)^3, x] // PolynomialForm[#, TraditionalOrder -> True] & Cos[s]^3 x^6 + 3 Cos[s]^2 x^5 + (3 Cos[s]^2 + 3 Cos[s]) x^4 + (6 Cos[s] + 1) x^3 + (3 Cos[s] + 3) x^2 + 3 x + 1

17

You can use GroebnerBasis: eq = (a + b)^10 - a^10 - b^10; eqXY = GroebnerBasis[{eq, a + b - x, a b - y}, {x, y}, {a, b}]; (*out*){10 x^8 y - 35 x^6 y^2 + 50 x^4 y^3 - 25 x^2 y^4 + 2 y^5} Check: First@Expand[eqXY /. x -> (a + b) /. y -> a b] === Expand[eq] (*out*)True --EDIT-- Following @DanielLichtblau's suggestion, it's better to do this in ...

16

In general, to get a list of all the cube roots of -8 (or the $m$ roots of any number $n$), you can use either the the Roots or Solve or Reduce functions. Roots[x^3 == -8, x] (* Out[1]= x == 2 || x == 2 (-1)^(2/3) || x == -2 (-1)^(1/3) *) Reduce and Solve are perhaps more flexible because you can specify the domain that you want or leave it out for all ...

16

All of the polynomial functions, have an option Modulus which allows you to specify an integer field, like $\mathbb{Z}_5$. In particular, Factor works on your example polynomial Factor[x^2+4, Modulus -> 5] (* (1 + x) (4 + x) *) Additionally, IrreduciblePolynomialQ works to determine irreducibility of $x^2+2$, as follows IrreduciblePolynomialQ[x^2 + ...

16

Here is a very simple way to do it: Table[1/i! D[M, {a, i}] /. a -> 0, {i, 0, 3}] (* ==> {{{15, 0}, {0, 2}}, {{0, 1}, {1, 0}}, {{1, 5}, {-5, 0}}, {{0, 0}, {0, 0}}} *) This works even if the entries are not polynomials. If they are, you can replace the arbitrary maximum 3 in the Table index by the degree of the polynomial: Max[Exponent[M, a]] ...

16

Something like this might be helpful. It replaces the unsorted list of symbols with a sorted list, lets Mathematica rearrange the expression in the normal way, and then applies a HoldForm before replacing the symbols back again. reorderSymbols[expr_, symbols_List] := With[{s = symbols}, HoldForm[Evaluate[expr /. Thread[s -> Sort@s]]] /. Thread[Sort@s ...

16

The reason why the replacement doesn't work is that replacement rules are not mathematical replacements, but pure structural replacements. Therefore the replacement z^2->x just looks for occurrences of the pattern z^2 and replaces that with x. Now z^4 doesn't match that pattern. Also note that rules operate on the internal form, which doesn't always ...

16

Here is another way to look at the OP's plot, which came to me after reading Daniel Lichtblau's comment under the question. His comment is worth emphasizing, which I think the following will show. (Mr.Wizard alludes to the issue in his remark on validity near the end of his answer.) Let's say that machine precision is binary64, which has 53 bits of ...

15

The following (taken from the Mathematica documentation) will do what you ask. Expand[FromDigits[Reverse[{0, 1, 23, 5, 15, 0, 0, 0}], x]] x + 23 x^2 + 5 x^3 + 15 x^4 I found the needed code in Properties & Relations section of the documentation page on CoefficientList. In general, it is a good idea to look for information on inverses in the ...

14

This question is not trivial as it would seem and a detailed discussion could help to understand the issue, especially when we deal with roots of special functions, however to do the task as simply as possible this would be the best way : f[x_] := LegendreP[6, x] Reduce[f[x] == 0, x, Reals] == Reduce[f[x] == 0, x] True Reduce[f[x] == 0, x, Reals] ...

14

As you said in your comment that you just want a well displayed formula, I suggest using Row to force specific orders. A rough example will look like following, you might want to adjust the priority level according to your needs: expr = A^2 e^2 SuperMinus[\[Phi]] SuperPlus[\[Phi]] + A e SuperMinus[\[Phi]] SuperPlus[\[Phi]] Subscript[c, 2 w] Subscript[g, ...

14

The most straightforward way would be FindRoot[ eq, {x, 0}] but since this specific polynomial eq has a singular Jacobian at x == 0 (evaluate e.g. Reduce[ D[ eq, x] == 0, x]) one would rather use FindRoot[ eq, {x, x0}] for small x0 > 0. The argument x0 depends on a case by case basis, but for the problem at hand an appropriate value might be 0 < x0 ...

14

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

To implement what you intended to do, I suggest to take a look at this approach : hermite[0, x_] := 1 hermite[1, x_] := 2 x hermite[n_Integer /; n >= 2, x_] := hermite[n, x] = Expand[2 x*hermite[n - 1, x] - 2 (n - 1) hermite[n - 2, x]] Now you shouldn't have problems anymore. Recalling that there are in Mathematica the Hermite polynomials ...

13

In[409]:= PolynomialReduce[z^4 + z^2 + 4, z^2 - x, {z, x}][[2]] Out[409]= 4 + x + x^2 This is similar to the Solve approach in that both use algebraic means to effect the substitution. But one can be a bit more general using PolynomialReduce (by taking advantage of term orders, say). For further detail on this approach, might have a look at some ...

12

You were definitely on the right track with MonomialList. Here is a solution. Others will probably find nicer ways. Using the trick found here, we first define a Format that looks like "Plus" but doesn't rearrange things: Format[myPlus[expr__]] := Row[Riffle[{expr}, "+"]] With this format in hand, we can wrap your original function in the following: ...

12

You have some errors in your syntax: you name your lists x_sample and y_sample, but in Mathematica, an underscore is not allowed in names (as it is reserved to patterns). your last sum runs from 0, but in Mathematica, the first element in a List has index 1 your last sum should run until the number of data points, not 4 furthermore, I would advise you to ...

12

Here a similar symbol replacement method to the one Simon used, in my own style. reorder[expr_, pats_List] := Module[{h, rls}, rls = MapIndexed[x : # :> h[#2, x] &, pats]; HoldForm @@ {expr /. rls} /. h[_, x_] :> x ] This definition allows you, within the standard limits of pattern matching expressions (e.g. FullForm) of course, to ...

12

Collect Since it hasn't been mentioned (and one can interpret the question in another way) I'd recommend to use also Collect (it can be applied not only to polynomials) : Collect[(x + y)^2, x] x^2 + 2 x y + y^2 In more general cases it would be handy to use the second argument in the form of List, e.g. Collect[(x + y)^2, {x, y}]. Comparing it to ...

12

Here is an approach that doesn't rely on undocumented features or on low-level box manipulations. We're dealing with a polynomial, so we can simply collect its coefficients and arrange them any way we like as follows: c0 = Collect[(1 + x + Cos[s] x^2)^3, x]; cx = CoefficientList[c0, x] x^Range[0, Exponent[c0, x]] (* ==> {1, 3 x, x^2 (3 + 3 Cos[s]), x^3 ...

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