A = MatrixSymbol('A', 3, 3)
x = MatrixSymbol('x', 3, 1)
dt = symbols('dt')
k1 = A * x
k2 = A * (x + S(1) / 2 * k1 * dt)
k3 = A * (x + S(1) / 2 * k2 * dt)
k4 = A * (x + k3 * dt)
final = dt * S(1) / 6 * (k1 + k2 + k3 + k4)
Matrix(final).expand()
How to expand matrix expression in sympy