A numerical solution represents unknowns with evaluated numbers rather than generalized symbols. For a system of equations, it gives a concrete set of values that satisfies the equations when such a solution can be found. section 1.6
SymPy can find numerical solutions by declaring variables, combining equations into a system, and calling solve. The resulting values can then be turned into program code. section 1.6
A two-equation system
Given Vp = 2Va and Va + Vp = 450, SymPy returns Va = 150 and Vp = 300. These numbers describe the single solution directly; replacing 450 or 2 with symbols instead produces a symbolic formula. section 1.6
Listing 1.1 Numeric solution in SymPy
from sympy import *
Va, Vp = symbols('Va Vp') #1
solution = solve([
Vp - Va * 2,
Va * 1 + Vp * 1 - 450
], (Va, Vp))
print(solution)
This listing shows the complete SymPy workflow for obtaining a numerical solution. section 1.6
Numerical methods are especially useful for large systems: a million equations may be solved numerically, while symbolic computation can become impractical even for an 8 × 8 system. Underspecified systems are different: their solutions may form a line, plane, or hyperplane rather than one set of numbers, so they are rarely solved numerically. section 3.2.2 section 3.2.2
