- #1
Qubix
- 82
- 1
I need to define some "general" variables in Mathematica 8, and I wonder if this can be done the following way.
Say ta[n] and tb[m] are my variables, in turn depending on n and m.
I want to define a function, for example
E[ta[n]_ , tb[m]_ ] := Cos[ ta[n] ] + Sin [tb[m] ] (just a simple example).
Then I want to be able to use the above expression in yet another function
S := E[ta[1],tb[2]] + E[ta[3],tb[1]] + etc...
First of all, does this work in Mathematica ?
Second, is S also a function, for example, if the line would stop before etc, should i write it as
S[ta[1]_ , tb[2]_, ta[3]_, tb[1]_ ]?
Remember, ta[1] , ta[2] etc are different variables.
I am asking all this because it would save me a serious amount of time in writing everything down explicitly.
Say ta[n] and tb[m] are my variables, in turn depending on n and m.
I want to define a function, for example
E[ta[n]_ , tb[m]_ ] := Cos[ ta[n] ] + Sin [tb[m] ] (just a simple example).
Then I want to be able to use the above expression in yet another function
S := E[ta[1],tb[2]] + E[ta[3],tb[1]] + etc...
First of all, does this work in Mathematica ?
Second, is S also a function, for example, if the line would stop before etc, should i write it as
S[ta[1]_ , tb[2]_, ta[3]_, tb[1]_ ]?
Remember, ta[1] , ta[2] etc are different variables.
I am asking all this because it would save me a serious amount of time in writing everything down explicitly.