How to find the binomial cube in python
To solve the binomial cube in python, you can use the expand () function of the sympy module.
expand(x)
The argument x is the algebraic expression of the binomial raised to three.
$$ (a+b)^3 $$
The function calculates the cubic power of the binomial, returning the result in symbolic or numerical form.
$$ (a^3+3a^2b+3ab^2+b^3) $$
Note. You must have previously defined the variables x,y,z as symbols using the function Symbols()
Example
To calculate the binomial cube
$$ (x+2)^3 $$
The variable x is defined as a symbol. The algebraic expression (x+2)**3 is assigned to the variable a.
The function expand() calculates the binomial cube
from sympy import Symbol, expand
x=Symbols('x')
a=(x+2)**3
expand(a)
The output result is
x**3 + 6*x**2 + 12*x + 8
The result is equivalent to algebraic expression
$$ x^3 + 6x^2 + 12x + 8$$