Questions tagged [polynomials]

Questions on the functionality operating on polynomials

Filter by
Sorted by
Tagged with
53 votes
6 answers
12k views

Finding real roots of negative numbers (for example, $\sqrt[3]{-8}$)

Say I want to quickly calculate $\sqrt[3]{-8}$, to which the most obvious solution is $-2$. When I input $\sqrt[3]{-8}$ or Power[-8, 3^-1], Mathematica gives the ...
jtbandes's user avatar
  • 1,422
53 votes
4 answers
21k views

How do I work with Root objects?

I want to solve the trigonometric equation : $$(3-\cos 4x )\cdot (\sin x - \cos x ) = 2.$$ I tried Solve[(3 - Cos[4*x])*(Sin[x] - Cos[x]) == 2, x] It returns the ...
minthao_2011's user avatar
  • 4,503
50 votes
4 answers
3k views

Funny behaviour when plotting a polynomial of high degree and large coefficients

I am trying to plot a polynomial of degree $29$ on the domain $[0,1]$, with fairly large coefficients: ...
AUK1939's user avatar
  • 1,493
35 votes
5 answers
3k views

How do I reassign canonical ordering of symbols?

I have a big polynomial that evaluates to: $$A^2 e^2 \phi ^- \phi ^++A e \phi ^- \phi ^+ c_{2 w} g_Z+\frac{1}{2} A e g h W^- \phi ^+ +\ll13\gg,$$ which is supposed to represent some terms in the ...
QuantumDot's user avatar
  • 19.7k
25 votes
11 answers
8k views

Defining a function that completes the square given a quadratic polynomial expression

How can I write a function that would complete the square in a quadratic polynomial expression such that, for example, CompleteTheSquare[5 x^2 + 27 x - 5, x] ...
Sunday's user avatar
  • 413
24 votes
2 answers
2k views

Code I get from wolfram isn't working in mathematica

I need to perform the factor as shown here factor(s^5+32s^4+363s^3+2092s^2+5052s+4320) https://www.wolframalpha.com/input/?i=factor(s%5E5%2B32s%5E4%2B363s%5E3%...
Melendowski's user avatar
22 votes
7 answers
19k views

How do I replace a variable in a polynomial?

How do I substitue z^2->x in the following polynomial z^4+z^2+4? z^4+z^2+4 /. z^2->x ...
niklasfi's user avatar
  • 2,623
22 votes
4 answers
4k views

How to keep Collect[] result in order?

For example, Collect[(1 + x + Cos[s] x^2)^3, x] gives the result ...
matheorem's user avatar
  • 17.1k
22 votes
4 answers
17k views

Factoring polynomials to factors involving complex coefficients

I've run into some problems using Factor on polynomials with complex coefficient factors. Reading the documentation it looks like it only factors over the ...
jcelios's user avatar
  • 413
22 votes
1 answer
420 views

Undocumented fourth parameter of Collect; how long has it been there?

While tinkering with How to get a list of monomials of a polynomial without coefficients? on a whim I tried a fourth argument in Collect and found: ...
Mr.Wizard's user avatar
  • 272k
21 votes
4 answers
3k views

Neural Network for polynomial fit

I'm trying to build up a neural network with Mathematica 11.0, that should fit data which behaves like a polynom of third order. I thought that an NN with one or two hidden layers can fit any function,...
A.Zachl's user avatar
  • 211
21 votes
2 answers
2k views

Expressing a polynomial as a sum of squares

I encountered a degree 4 polynomial in 8 variables f(a1,a2,a3,a4,b1,b2,b3,b4) that I suspect can be written as a sum of squares. While sostools in MATLAB would find ...
pizzazz's user avatar
  • 311
20 votes
0 answers
336 views

Changes to Coefficient function in v10.2

In the version Mathemaica 10.4, I am very surprised that the core function Coefficient has changed, e.g., ...
Orders's user avatar
  • 1,247
19 votes
2 answers
745 views

How can I get the solutions of $x^n-x-t=0$ in hypergeometric form?

$x^3-x-t=0$ has three roots that can be expressed in hypergeometric form, for example $$x_1=-1-\frac{t}{2}{_2F_1\left(\frac{1}{3},\frac{2}{3};\frac{3}{2};\frac{27t^2}{4} \right)}+\frac{3t^2}{8} {...
vito's user avatar
  • 8,958
19 votes
2 answers
6k views

Why does Mathematica order polynomial forms in reverse from traditional order?

I could very well be missing something obvious, but this has always bugged me with Mathematica and I don't know why it does it or how to fix it. If I enter any polynomial, say, x^2 + x - 1 for ...
Brendan's user avatar
  • 535
18 votes
5 answers
1k views

Decomposing a matrix with polynomial elements into a polynomial with matrix coefficients

Let's say I have a matrix, $\mathbf{M}$, that is polynomially dependent on a single variable, such as M = {{15 + a^2, a + 5 a^2}, {a - 5 a^2, 2}} and I want to ...
rcollyer's user avatar
  • 34k
18 votes
5 answers
6k views

How do I find the degree of a multivariable polynomial automatically?

I have a very simple question which appears not to have already been answered on this forum. Is there built-in functionality that returns the degree of a multivariable polynomial? For example if the ...
Rob2181's user avatar
  • 527
18 votes
4 answers
6k views

Is there a way to Collect[] for more than one symbol?

Oftentimes you find yourself looking for polynomials in multiple variables. Consider the following expression: a(x - y)^3 + b(x - y) + c(x - y) + d as you can ...
niklasfi's user avatar
  • 2,623
17 votes
4 answers
785 views

What is Mathematica's equivalent to Maple's collect with distributed option?

Given a polynomial in $x,y$, I want to collect on $x,y$ and any products of these also. As given using Maple's collect with the distributed option. Currently Mathematica will collect on $x$ then ...
Nasser's user avatar
  • 144k
17 votes
6 answers
6k views

Create a polynomial of a given degree

In Mathematica, how can I create a polynomial function in given variables of a given degree with unknown coefficents? That is, I am looking for a function ...
Posch79's user avatar
  • 313
17 votes
2 answers
2k views

Solving quintic in radicals

I need to find an explicit expression in radicals for the real root of the quintic equation ...
Vladimir Reshetnikov's user avatar
17 votes
1 answer
892 views

Mathematica incorrectly giving zero for partial derivative

Bug introduced in 9.0 and fixed in 11.1 Mathematica is incorrectly reporting that the partial derivative of a certain expression is zero. I try to compute the following: ...
Izaak Meckler's user avatar
16 votes
5 answers
4k views

Computing the genus of an algebraic curve

How-to compute the genus of an algebraic curve in Mathematica ? In my case the algebraic curve is explicitly defined by a polynomial.
Ghassen Hamrouni's user avatar
16 votes
5 answers
4k views

How to get exact roots of this polynomial?

The equation $$ 64x^7 -112x^5 -8x^4 +56x^3 +8x^2 -7x - 1 = 0 $$ has seven solutions $x = 1$, $x = -\dfrac{1}{2}$ and $x = \cos \dfrac{2n\pi}{11}$, where $n$ runs from $1$ to $5$. With ...
minthao_2011's user avatar
  • 4,503
16 votes
2 answers
663 views

Does NRoots own an abstract counterpart? If not, can we write one?

We know when solving linear algebra equations, despite its abstract syntax, LinearSolve is much faster compared to Solve: ...
xzczd's user avatar
  • 66.2k
15 votes
2 answers
5k views

Gram-Schmidt Process for Polynomials

I want to implement the Gram Schimdt procedure to the vector space of polynomials of degree up to 5, i.e. I want to find an orthogonal basis from the set of vectors $v=(1,x,x^2,x^3,x^4,x^5)$. The ...
user avatar
15 votes
2 answers
1k views

Factorizing polynomials over fields other than $\mathbb{C}$

I'd like to take a polynomial in $\mathbb{Z}_5[x]$ of the form $ax^2+bx+c$ and factor it into irreducible polynomials. For example: Input... x^2+4 Output... <...
Harold's user avatar
  • 1,017
15 votes
3 answers
849 views

What are Root objects with multiple polynomials?

In Mathematica 9 a new flavor of Root object with multiple polynomials was introduced. For example, ...
Laila Podlesny's user avatar
14 votes
2 answers
783 views

Finding the number of odd quintinomial coefficients

I am searching for the number of odd coefficients of $\qquad (x^4 + x^3 + x^2 + x + 1)^n$ for arbitrary $n$. It took some hours to compute the result for $n=12207$. There are $16333$ odd ...
ZaMoC's user avatar
  • 6,697
14 votes
4 answers
990 views

Why Mathematica can not factorize polynomials over algebraic fields?

I noticed that a factorization over algebraic fields is useless in Mathematica. Here is the example over the field containing I*Sqrt[3]: ...
Aus Man's user avatar
  • 181
14 votes
2 answers
777 views

How can I compute the representation matrices of a point group under given basis functions?

Take the $C_{3v}$ point group for example: ...
goodluck's user avatar
  • 605
14 votes
1 answer
195 views

What's going on here? Some kind of rationalization "under the covers"?

Observe: eq = (.25 a + .5 b + .25 c); CoefficientRules[eq^2] CoefficientRules[eq^2 // Expand] results in {{2, 0, 0} -> 1/16, {1, 1, 0} -> 1/4, {1, 0, 1} -...
ciao's user avatar
  • 25.8k
13 votes
3 answers
2k views

Factor a polynomial over the reals

I can't seem to find a function in Mathematica that factors a polynomial over the reals. Obviously, Factor doesn't work since it works over the integers, over $\mathbb{Z}_p$, or some algebraic fields ...
Veliko's user avatar
  • 349
13 votes
3 answers
11k views

Get polynomial interpolation formula

I'm attempting to get a polynomial interpolation formula out of Mathematica but I am absolutely lost. I stared out using ...
BOMEz's user avatar
  • 233
13 votes
1 answer
450 views

ToNumberField won't recognize Root as an explicit algebraic number

Bug fixed in 10.0.0 In Mathematica 9.0.1, it appears that ToNumberField will not always recognize a Root object as an explicit ...
Tobias Hagge's user avatar
  • 1,382
13 votes
1 answer
1k views

Rearranging a Polynomial

In Mathematica 8.04 on Windows, I want to display a formula in standard textbook format. The formula is the variance of an $N$-security portfolio. For two securities it is: $$w_1^2\sigma_1^2+w_2^2\...
Tim Mayes's user avatar
  • 1,449
12 votes
4 answers
1k views

How to replace every possible $A+B$ and $AB$ in expansion of $(A+B)^{10}-A^{10}-B^{10}$ with $x$ and $y$, respectively?

I would like to replace every possible $A+B$ and $AB$ in expansion of $(A+B)^{10}-A^{10}-B^{10}$ with $x$ and $y$, respectively. How to do it with the simplest code in Mathematica? For example, \...
kiss my armpit's user avatar
12 votes
5 answers
8k views

How to define a polynomial/function from an array of coefficients?

I have the coefficients of my desired polynomial in an array CoefArr (I'm new to mathematica, so I think of everything as arrays, it is actually a list I believe) starting with the constant at index 1....
Gest's user avatar
  • 123
12 votes
4 answers
1k views

Any efficient way to make complete homogeneous symmetric functions in Mathematica?

We do have elementary symmetric functions, SymmetricPolynomial[k, {x_1, ..., x_n}] . But I didn't find complete homogeneous symmetric functions. The induction ...
Osiris Xu's user avatar
  • 1,019
12 votes
2 answers
791 views

Surprises simplifying simple polynomials

I came across some somewhat surprising behavior of Simplify today, on something very simple. Let's take two cubic polynomials that we know have the same value: <...
Pillsy's user avatar
  • 18.5k
12 votes
2 answers
697 views

How to deduce a generator formula for a polynomial sequence?

Consider a polynomial sequence $\{p_n\}$ generated by some (simple) rule: $$ \begin{array}{l} p_1(x)=x \\ p_2(x)=2 x-x^2 \\ p_3(x)= x^3-3 x^2+3 x \\ p_4(x)=-x^4+4 x^3-6 x^2+4 x \\ p_5(x)= x^5-5 x^4+...
faleichik's user avatar
  • 12.7k
12 votes
1 answer
393 views

Using Mathematica to find an alternative continued fraction for $\zeta(5)$

Given the Riemann zeta function $\zeta(n)$. I. $x=\zeta(3)$ Using Euler's continued fraction formula, we can form $\zeta(3)$'s cfrac as, $$Ax+B = \cfrac{1}{v_1 - \cfrac{1^6}{v_2 - \cfrac{2^6}{...
Tito Piezas III's user avatar
11 votes
3 answers
4k views

Get the coefficient matrix from a quadratic form

Suppose I have a quadratic form of qf = a x^2 + b y^2 + c z^2 + 2 d x y + 2 e x z + 2 f y z How can I easily to get the symmetric matrix A, such that $X^TAX=qf$?...
van abel's user avatar
  • 1,235
11 votes
6 answers
2k views

Can Mathematica tell me if a polynomial has all real roots?

I am trying on this polynomial, ...
user6818's user avatar
  • 1,181
11 votes
3 answers
3k views

How can we plot the complex roots of an equation?

If we'd like to display the $n$ roots of a polynomial on the complex plane as points, how can we do this? For example, if we have the equation $x^3 + x^2 + x + 1$, how can we plot the 3 roots as ...
Matt Groff's user avatar
  • 1,141
11 votes
3 answers
9k views

First positive root

Simple question but problem with NSolve. I need help how to extract first positive root? For example: ...
Pipe's user avatar
  • 1,099
11 votes
2 answers
677 views

Out of memory when computing a coefficient of a large symmetric polynomial

...
PalmTopTigerMO's user avatar
11 votes
3 answers
3k views

Checking if the roots of a function are real

I'm trying to determine if the roots of a function are real. How would you do that? (In particular I'm interested in verifying that the roots of LegendreP[6, x] ...
JONASS's user avatar
  • 113
11 votes
4 answers
1k views

Mathematica function equivalent to MATLAB's residue function (partial fraction expansion)

I am looking for a Mathematica function equivalent to MATLAB's residue function. If there is no Mathematica equivalent, I would like to write a function that given ...
jacobi16's user avatar
  • 155
11 votes
1 answer
1k views

How can I plot a Chebyshev spiral?

The Chebyshev polynomials T_n of the first kind are a certain set of orthogonal polynomials. They can be defined by T_n(cos(x))=cos(nx), the first of them are T_0(x) = 1 T_1(x) = x T_2(x) = ...
Frank's user avatar
  • 113

1
2 3 4 5
20