Powers#

Powers are a way to write that we have multiplied a number by itself a given number of times. For example 4 squared is \(4^2 = 4 \times 4\) and 5 cubed would be \(5^3 = 5 \times 5 \times 5\). So more generally, for any positive whole number \(n\):

\[ x^n = \underbrace{x\times x \times \cdots \times x}_{n \textrm{ times}} \]
  • We call \(x\) the base.

  • We call \(n\) the index of the base or its power.

We would either say \(x^n\) as ‘\(x\) raised to the power of \(n\)’, ‘\(x\) to the power of \(n\)’ or ‘\(x\) to the \(n\)’.

Example

We can write \(T \times T \times T \times T \times T\) as \(T^5\). (Note that \(T\) is the base and the power is 5).

Example

When a negative number is raised to an even power then the answer is positive:

\[ (-2)^4 = -2 \times -2 \times -2 \times -2 = 16 \]

In Python, powers are represented using **.

(-2)**4
16

Negative Powers#

We can also have negative numbers as powers, these give fractions called reciprocals. For example \(2^{−1} = \frac{1}{2}\). So more generally:

\[ x^{-n} = \frac{1}{x^n}, \text{ as long as } x \neq 0 \]

Example

We can write \(\frac{1}{qqqqqq}\) as \(\frac{1}{q^6}\), which is the same as \(q^{-6}\).


from sympy import symbols 
q = symbols('q')
1/(q*q*q*q*q*q) == q**(-6)
True

We can simplify multiple terms like in the examples below by collecting together the terms which are the same.

Example

We can simplify \(cccdcd\) to \(c^4d^2\). (Note that we have collected all the c and d together separately)


c, d = symbols('c d') 
c*c*c*d*c*d == c**4*d**2
True

Example

We can simplify \(\frac{xxyzzzz}{abbb}\) to \(\frac{x^2yz^4}{ab^3}\), which we can then write as \(x^2yz^4a^{-1}b^{-3}\).

Special Cases#

  1. Any non zero number raised to the power of 1 is itself, for example \(3^1 = 3\) and \(15^1 = 15\). So we have:

\[ x^1 = x \]
  1. If a number is rasied to the power of 0 then the answer is 1. For example \(4^0 = 1\) and \((−454.786)^0 = 1\). So we have:

\[ x^0 = 1 \]

x = symbols('x')
x**0
\[\displaystyle 1\]

Rules for Powers#

We have the following three rules for when working with powers:

  1. \(x^a \times x^b = x^{a+b}\)

  2. \(\frac{x^a}{x^b} = x^{a-b}\)

  3. \((x^a)^b = x^{a\times b}\)

Example

We can simplify \(\frac{y^3z^2y^4}{z^6}\) to \(y^{3+4}z^{2-6}\), which we can then write as \(y^7z^{-4}\) (we have used rules 1 and 2 here).


from sympy import simplify
x,y,z = symbols('x y z')
simplify(y**3*z**2*y**4/z**6)
\[\displaystyle \frac{y^{7}}{z^{4}}\]

Example

We can simplify \((a^3b^2ca)^2\) to \((a^4b^2c)^2\) to \((a^4)^2(b^2)^2(c)^2\), which we can then write as \(a^8b^4c^2\) using rule 3.


a,b,c = symbols('a b c')
simplify((a**3*b**2*c*a)**2)
\[\displaystyle a^{8} b^{4} c^{2}\]

Roots#

The opposite of squaring a number, say \(4^2 = 16\), is finding the square root, in this case \(\sqrt{16} = 4\). Note the notation for square root is \(\sqrt{}\). The same is true for cubing and cube roots which are denoted \(\sqrt[3]{}\); for example \(3 \times 3 \times 3 = 27\), so \(\sqrt[3]{27} = 3\). In general the opposite of raising a number \(x\) to the power of \(n\) is to find the \(n^\text{th}\) root, which is denoted \(\sqrt[n]{}\).

We also use fractional powers as another, often more useful way, to write roots. So we have that \(\sqrt{x} = x^\frac{1}{2}\) and \(\sqrt[3]{x} = x^\frac{1}{3}\). More generally we have:

\[ x^{\frac{1}{n}} = \sqrt[n]{x} \]

Example

A numerical example: since \(\sqrt[5]{32} = 2\) we could also write \(32^\frac{1}{5}\) = 2


32**(1/5)
2.0

Example

We can write \(\frac{\sqrt{x}}{x} = \frac{x^\frac{1}{2}}{x} = x^{\frac{1}{2}-1}=x^{-\frac{1}{2}}\).


simplify(x**(1/2)/x)
\[\displaystyle x^{-0.5}\]

Example

Simplify the following:

\[ \frac{\sqrt[3]{ab^3}(ac^4)^2}{a^\frac{4}{3}b} \]

Solution: We begin by expanding the brackets in the numerator:

\[\begin{split} \begin{align} \frac{\sqrt[3]{ab^3}(ac^4)^2}{a^\frac{4}{3}b} & = \frac{\sqrt[3]{ab^3}a^2c^8}{a^\frac{4}{3}b} \tag*{The cube root can now be simplified}\\ & = \frac{a^\frac{1}{3}ba^2c^8}{a^\frac{4}{3}b} \tag*{All the powers can be collected}\\ & = a^{\frac{1}{3}-\frac{4}{3}+2}b^{1-1}c^8 \tag*{This can be simplified}\\ & = a^{-1+2}b^{0}c^8 \\ & = ac^8 \end{align} \end{split}\]

Sometimes, sympy is not able to find the best simplification. This is noted in the sympy documention.

simplify((a*b**3)**(1/3)*(a*c**4)**2/(a**(4/3)*b))
\[\displaystyle \frac{a^{0.666666666666667} c^{8} \left(a b^{3}\right)^{0.333333333333333}}{b}\]