Step-by-Step Execution:
Importing SymPy Functions
symbols('x'): Creates a symbolic variable x that can be used in algebraic equations.
solve(eq, x): Finds values of x that satisfy the equation.
Equation Definition
eq = x**2 - 4 represents the quadratic equation:
Solving the Equation
The equation can be factored as:
(x−2)(x+2)=0
Setting each factor to zero:
x−2=0⇒x=2
x+2=0⇒x=−2
Output of solve(eq, x)
solve(eq, x) returns a list of solutions:
[2, -2]
This means the equation has two real roots: x = 2 and x = -2.
Final Output
[2, -2]
0 Comments:
Post a Comment