# Symbolic calculation

Is there any software where this kind of symbolic calculation is possible?

s = 0
for i = 1 to m
j = 2 i + a - t
if (j > 0) s = s + a


I want s as a function of m,a,t, where m,a,t are integers. This is a toy example. In my calculation a lot of if/else, minimum of two values, etc., are involved.

• Mathematica can certainly handle this, but I don't see this a symbolic calculation if all the actual arguments are going to be integer values. I suggest you elaborate on how you intend to use unbound symbols in your work. – m_goldberg Dec 15 '12 at 1:40
• @m_goldberg perhaps he means to evaluate his statement symbolically into closed form. OP, could you please clarify? – VF1 Dec 15 '12 at 1:54
• Otherwise, OP, I recommend taking a look at this. What you wrote in psuedocode can easily be transcribed into MMA. – VF1 Dec 15 '12 at 1:59
• Yes, I want closed form of s. Will you kindly explain how to write this code? – user46185 Dec 15 '12 at 2:23

Sum[Boole[2 i + a - t > 0] a, {i, 1, m}]

• I gotta learn how to use Boole better! – Mark McClure Dec 15 '12 at 3:28
• @user46185 I see that you Accepted this answer. Were you able to adapt this to your larger problem? You mentioned "a lot of if/else" -- generally you want to use Boole and Piecewise which are mathematical constructs rather than If/Which etc. flow control functions, when using Sum, Product etc. to compute a symbolic equivalent. – Mr.Wizard Dec 15 '12 at 5:33