Step-by-Step Breakdown:
symbols('x')
This creates a symbolic variable x using the SymPy library.
Unlike regular Python variables, x now behaves as a mathematical symbol.
Expression Definition
expr = (x + 1) * (x - 1)
This is the difference of squares formula:
(a+b)(a−b)=a*−b*
Substituting
a=x and
b=1, we get:
(x+1)(x−1)=x *−1
Expanding the Expression (expand(expr))
The expand() function multiplies and simplifies the expression:
(x+1)⋅(x−1)=x *−1
So, expand(expr) simplifies it to x**2 - 1.
Output:
x**2 - 1
This confirms that the product of (x + 1) and (x - 1) expands to x² - 1.
0 Comments:
Post a Comment