Symbolic mathematics manipulates equations using named quantities instead of only fixed numbers. With SymPy, you define symbols, provide equations, and ask a solver to return numerical or general results. section 1.6
Two trains, one system of equations
Represent the train problem with Va + Vp = 450 and Vp = 2Va. SymPy returns Va = 150 and Vp = 300. Replacing the numbers with D, t, and Vpx produces formulas for the general case. section 1.6
Listing 1.2 Symbolic solution in SymPy
from sympy import *
Va, Vp, Vpx, D, t = symbols('Va Vp Vpx D t') #1
solution = solve([
Vp - Va * Vpx,
Va * t + Vp * t - D
], (Va, Vp))
print(solution)
Inspect the SymPy listing that solves the generalized train equations symbolically. section 1.6
