The art of manipulating an algebraic expression into the desired form.

learn more… | top users | synonyms

32
votes
6answers
4k 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 ...
21
votes
7answers
856 views

How do I get my equation to have the form $(x-a)^2 + (y-b)^2 + (z-c)^2-d = 0$?

I want Mathematica to express the equation $$-11 - 2 x + x^2 - 4 y + y^2 - 6 z + z^2=0$$ in the form $$(x - 1)^2 + (y - 2)^2 + (z - 3)^2 - 25=0$$ How do I tell Mathematica to do that?
17
votes
4answers
519 views

How do I introduce a new variable in a trigonometric equation?

I have the trigonometric equation \begin{equation*} \sin^8 x + 2\cos^8 x -\dfrac{1}{2}\cos^2 2x + 4\sin^2 x= 0. \end{equation*} By putting $t = \cos 2x$, I have \begin{equation*} \dfrac{3}{16} t^4+ ...
15
votes
2answers
568 views

How to define a non-standard algebra in Mathematica?

I want to define an algebra, where there are three elements: 0, 1 and $\infty$ and two operations, addition and multiplication defined, both commutative: $$\begin{align*} 0+0&=0\\ 0+1&=1\\ ...
13
votes
6answers
2k views

Replacing composite variables by a single variable

To replace a single variable by another variable, one can simply use the the replace all (/.) operator (e.g., ...
13
votes
1answer
454 views

Most efficient way to determine conclusively whether an algebraic number is zero

Let x be an algebraic number of unspecified degree, expressed using arithmetic, rational powers, and algebraic integers (edit: ...
13
votes
1answer
406 views

Block Matrix Algebra with Mathematica

I have come up with some BlockMatrix Algebra for Mathematica to make notations easier. I have the following: ...
12
votes
7answers
2k 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 ...
12
votes
4answers
2k views

Is it possible to have Mathematica move all terms to one side of an equation?

I have an inequality expression that I would like to express in terms of the relation of the parameters to zero. More simply, I want to have mathematica move all the terms to one side of the ...
12
votes
4answers
729 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 ...
12
votes
1answer
222 views

ToNumberField won't recognize Root as an explicit algebraic number

In Mathematica 9.0.1, it appears that ToNumberField will not always recognize a Root object as an explicit algebraic number. ...
11
votes
4answers
293 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, ...
11
votes
3answers
1k views

How can I convert a complex number a+b I to the exponent form A Exp(I phi)?

When I have an expression such as: (1/4 + I/4) ((1 - 2 I) x + Sqrt[3] y) it is hard to get an intuition of the number. So I want to convert it to the complex ...
10
votes
2answers
2k views

Why doesn't Mathematica expand Cos[x]^3 Sin[x]^2?

I found some examples of Mathematica's commands usage in an old manual but the program gives me different result than expected ...
10
votes
1answer
229 views

Why is ReplaceAll behaving like this?

I'm learning to use the ReplaceAll function and I found the behavior of which is quite confusing. For Sqrt[f[x, y]] /. f[___] -> u Mathematica returns ...
9
votes
4answers
463 views

How to implement dual numbers in Mathematica?

I wonder how can I implement dual numbers in Mathematica, so that all functions work well with them (as with complex numbers). Particularly, for each function $f$, ...
9
votes
2answers
449 views

Shaping/simplifying equations in a certain way

A problem I am occasionally facing is to simplify an equation not to it's shortest form but to a form that is simple by other means. Often, this is grouping the term according to certain functions, ...
9
votes
2answers
803 views

Expand modulus squared

Is it possible to make a function in Mathematica that expands expressions of the form $$|z + w|^2 = |z|^2 + 2\text{Re} \overline{z}w + |w|^2?$$ Preferably it should also be able to handle things ...
9
votes
1answer
274 views

What is the proper way to verify that two expressions are equivalent?

First of all, it appears to me that $$\left|\frac{1}{x} + x^2\right| \Leftrightarrow \frac{|1 + x^3|}{|x|}$$ is true. I don't know why, but my attempt to verify it in Mathematica failed. ...
9
votes
2answers
486 views

Memory leak issues

I am working with noncommuting objects and basically I am using Mathematica to sort large expressions by normal ordering and simplifying them. To this end, I first create an object called ...
9
votes
2answers
365 views

InverseSeries of multiple variables and multiple equations

CONTEXT Let us consider a bit of the Universe in which we draw spheres (see a high resolution image here). Astronomers have shown that the density within these spheres could be predicted quite ...
8
votes
3answers
495 views

How can I convert x^2 to x*x?

When I try the following code: a b^2 c /. b c -> e Mathematica gives me: a b^2 c but what I want is: ...
8
votes
4answers
546 views

“Evaluating” polynomials of functions (Symbols)

I want to implement the following type evaluation symbolically $$(f^2g + fg + g)(x) \to f(x)^2 g(x) + f(x) g(x) + g(x)$$ In general, on left hand side there is a polynomial in an arbitrary number of ...
8
votes
3answers
366 views

How to extract expression from ConditionalExpression

p1 := y /. {First[Solve[x^2 + y^2 + x == 1, y, Reals]]} ...
8
votes
3answers
1k views

How can I rationalize the denominator of an expression?

Mathematica doesn't rationalize the denominator automatically, and I haven't found anything in the documentation about it. But I found an old post on MathGroup, which proposes a solution using ...
8
votes
1answer
721 views

How do I expand a sum?

I have a problem with Mathematica's symbolic manipulations. As an example, consider the following expression: $$\sum _{i=1}^n -2 x_i \left(-a x_i-b+y_i\right)=0$$ How do I get Mathematica to expand ...
8
votes
4answers
5k 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 ...
7
votes
4answers
2k views

Checking if two trigonometric expressions are equal

Say I have two trigonometric expressions which are a bit complicated. Is there a quick way to check if they reduce to the same thing (that they are equal) using Mathematica? I was solving this: $y'' ...
7
votes
4answers
418 views

Distances between points in periodic cube

How can one implement more efficiently/elegantly/memory savvily the following function which returns a matrix of all Euclidian distances between points in 3D within a cube of width ...
7
votes
2answers
463 views

Manipulating an equation into standard quadratic form?

Say I have an equation of the form $$u s + \frac{1}{v} + \frac{1}{p s + q} = 0$$ (or any form that can be written as a standard quadratic, really, the above form is just an example; they'll all be ...
7
votes
1answer
402 views

Writing an expression as sum of squares of expressions

Suppose we have a symmetric homogeneous polynomial expression $P$ in $X=(x_1,\cdots, x_n)$. I want to check whether there are functions $g(X)$ so that $P$ is of the form $\sum _{1\le i<j\le n} ...
7
votes
1answer
279 views

RootSum result manipulation/simplification

Consider the sum sum1 = Sum[ k/( k^7 - 2 k + 3), {k, Infinity}] ...
7
votes
0answers
103 views

Apart may use Padé method: what's that?

How does Apart work? The page tutorial/SomeNotesOnInternalImplementation#7441 says, "Apart ...
6
votes
3answers
545 views

What function can I use to evaluate $(x+y)^2$ to $x^2 + 2xy + y^2$?

What function can I use to evaluate $(x+y)^2$ to $x^2 + 2xy + y^2$? I want to evaluate It and I've tried to use the most obvious way: simply typing and evaluating $(x+y)^2$, But it gives me only ...
6
votes
8answers
830 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] ...
6
votes
6answers
867 views

How to simplify a complicated Sum in terms of power Sums?

For example, I have: $a=\sum _{r=1}^n x_r \left(\left(\sum _{i=1}^n x_i-x_r\right){}^2-\sum _{i=1}^n x_i^2\right)$ ...
6
votes
1answer
202 views

Maple like collect command in Mathematica

In Maple I often simplify expressions for functions of same argument using the collect command: > collect(a*f(x)+f(y)+x*f(x), f, factor) (a+x)*f(x)+f(y) where ...
6
votes
1answer
119 views

Is there a version of Together that doesn't cancel common factors?

I'm running code that produces a long combination of rational functions with free constants that need to be tuned such that the combination vanishes. My current method is to put the combination over ...
6
votes
3answers
155 views

Is there any way to collect only variables with a specific power?

Suppose I've got this: In[13]:= Expand[(a + b) (b + c) (c + a)] Out[13]= a^2 b + a b^2 + a^2 c + 2 a b c + b^2 c + a c^2 + b c^2 And I want to collect only ...
6
votes
2answers
208 views

How to implement a formal expectation operator over an unknown distribution?

I need to do some simplification of an expression involving averages over a stochastic variable (in order to verify a long analytical calculation). The easiest way to do that, I figured, were if I ...
6
votes
2answers
108 views

Why is ToRadicals[] not able to handle all cases? Is there a workaround?

The documentation for the function ToRadicals says: ♦ There are some cases in which expressions involving radicals can in principle be given, but ...
5
votes
3answers
672 views

Square both sides of an equation?

Can I define an equation (for example, x+1 == y^2 + 2), and tell Mathematica to square both sides? If not, what is an equivalent way to achieve this?
5
votes
5answers
324 views

Isolating characters in a string

I'm struggling to find the right function in mathematica to isolate specific characters in a string. I have got a formula as string (I imported it from an excelfile) like this: y = 0.97*x1 + ...
5
votes
2answers
182 views

How to protect pattern or subexpression when distributing / expanding expression?

I've got an expression like expr = (1-x)(a+b) that I would like to distribute / expand while keeping factors of (1-x) intact, ...
5
votes
4answers
1k 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 ...
5
votes
1answer
194 views

How to substitute the following conditions into an expression?

I have an expression: $p=a\;b\; x + b^2\; y + a\;c\; z$. I want to substitute $a\;b=1$, $b^2 = 2$ and $a\;c = 4$ to obtain $p = x + 2y + 4z$. How can I tell Mathematica to do that? I dont know how to ...
5
votes
2answers
159 views

How to check an algebraic number for membership in a list

I need to check an algebraic number for membership in a list of algebraic numbers. The numbers can be expressed in different forms (combinations of radicals, Root ...
5
votes
1answer
195 views

Numbered symbols

I work with an exterior algebra over $R^n$. I have the basis $\{1,\omega_i\}_{i=1}^n$ in this algebra, and my differential operator is defined as $$d\omega_k=\sum_{i>j>0,i+j=k} (i-j)w_i\wedge ...
5
votes
1answer
124 views

How to apply tags to expression terms?

I often see on this site and at the mathgroup the repeated questions on how to rearrange expression that Mathematica "likes" to keep in one form, but the user prefers in another. Consider this trivial ...
4
votes
2answers
135 views

Unexpected side effect of removing the Orderless attribute from Times

First I make Times orderless: ClearAttributes[Times, Orderless]; Then I evaluate ...