Tag Info

Hot answers tagged

46

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


28

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


19

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


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 


16

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


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

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


15

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


15

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


14

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


14

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


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


13

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


13

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


13

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


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

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

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


12

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

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

eq = -70.5 + 450.33 x^2 - 25 x^4; roots = x /. NSolve[eq == 0, x] Min@Select[roots, Positive] 0.397412


12

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


11

FullSimplify is Simplify with additional transformation rules; some of these rules may be necessary to simplify a polynomial to a form where you can see the equality explicitly. In case of polynomials, I usually use Simplify@Expand to group terms the same way; Expand brings the polynomial in an unambiguous standard form, at which point both results should ...


11

Since we can consider $f$ as a $4-$th order polynomial (with respect to $y$) we can always factorize it as you claim in terms of radicals, but for the sake of simplicity let's start writing it symbolically in terms of the Root objects defining $f$ to be p[x,y]: p[x_, y_] := x^9 - x^6 + 4 x^5 y + 2 x^3 y^2 - y^4 pf[x_, y_] = -Times @@ (y - (y /. {ToRules @ ...


11

Since Mathematica offers powerful symbolic capabilities I find that more effective solution to the problem uses exact numbers instead of machine precission ones and consequently exploits appropriate symbolic functions. The given matrix m: m = {{0.04 - 0.4 b, 0, 0.04 - 0.4 b}, {0, -0.08 - 1.2 b, -0.06 - 0.9 b}, {1.04 - 0.4 b, 2.08 - 0.8 b, 0}}; ...


10

Your question cannot realistically be answered. One almost never knows what specifically comprises such an impediment. Here is a Groebner basis for your system of polynomials, computed for degree reverse lexicographic order. It takes some time to do this. Not sure if it will run in reasonable time directly; I used a numeric approximation and rationalized ...


10

There is no need for the Modulus option in CharacteristicPolynomial, since PolynomialMod serves that purpose. Assume we have a matrix m e.g. : m = RandomInteger[10, {5, 5}] m // MatrixForm {{10, 1, 4, 10, 9}, {1, 9, 6, 1, 5}, {9, 7, 9, 1, 0}, {1, 10, 8, 0, 4}, {4, 0, 4, 7, 10}} then CharacteristicPolynomial[m, x] 2310 - 4008 x + 1739 x^2 - ...


10

Defining your polynomial as p[x_, a_, b_, c_] := the formula I'd do this : Manipulate[ CountRoots[ p[x, a, b, c], {x, 0, Infinity}], {a, -100, 100}, {b, -100, 100}, {c, -100, 100}] If a plot is needed one can proceed this way : ListContourPlot3D[ Table[ CountRoots[ p[x, a, b, c], {x, 0, Infinity}], {a, -10, ...


10

Solve with Modulus We can use Solve with domain specification like i.e. Integers, or with e.g. integers modulo 5, then instead of specifying the domain one uses Modulus : Solve[x^2 + 4 == 0, x, Modulus -> 5] {{x -> 1}, {x -> 4}} Times @@ ( x - Last @@@ %) Expand[ %, Modulus -> 5] (-4 + x) (-1 + x) 4 + x^2 For an integer $n$, ...


10

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



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