Q:

Python: Computing matrices with arbitrary elements?

How can I in python create and calculate solutions for matrices with arbitrary elements?
For example, let's say I want to create square matrix with elements: a,a,a,a and add it up to square matrix with elements: b,b,b,b.
The result should then be a+b for each element in the new matrix, as letters.
Other example, I multiply a matrix by scalar k and want the k's inside the matrix. I will receive an error if I don't specify exact value of k, but I want it to be arbitrarily valued and show up as "k".

A:

EDIT: as suggested by PM 2Ring,  SymPy might be solution.
other answer:
I think TensorFlow might help you in this case. 
Although, Writing equations might be slightly different in this case.
import tensorflow as tf

# define your variables before hand.
# tf.placeholder(<type of element>, <dimensions>)
arr1 = tf.placeholder(tf.float32, [2,2])
arr2 = tf.placeholder(tf.float32, [2,2])

# if it doesn't have dimension no need to mention.
scalar = tf.placeholder(tf.float32)

# these are your arrays which contain those arbitrary values you mentioned
multiplied_array = arr1*scalar
added_array = arr1+arr2
adding_to_multiplied = multiplied_array+arr1

# to evaluate these into any number, you need a session
sess = tf.Session()

# just provide values of arr1, scalar, arr2 to evaluate the results
print(sess.run(multiplied_array,{arr1:[[1,2],[3,4]],scalar:22}))
print(sess.run(added_array,{arr1:[[1,2],[3,4]],arr2:[[5,6],[7,8]]}))
print(sess.run(adding_to_multiplied,{arr1:[[1,2],[3,4]],arr2:[[5,6],[7,8]],scalar:22}))

