Timeline for Defining a function of arguments with sub- and superscripts
Current License: CC BY-SA 4.0
14 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 13, 2020 at 9:00 | history | tweeted | twitter.com/StackMma/status/1238389454643122177 | ||
Mar 13, 2020 at 0:06 | history | became hot network question | |||
Mar 12, 2020 at 19:13 | comment | added | Hugh | I have given an answer with an example. | |
Mar 12, 2020 at 19:12 | answer | added | Hugh | timeline score: 9 | |
Mar 12, 2020 at 18:57 | comment | added | HerpDerpington | @Hugh Where do I put the underscores in the definition with the indices? | |
Mar 12, 2020 at 18:55 | comment | added | Hugh |
Mathematica has pattern recognition when looking at arguments of functions. You can have the same function name but have it operate differently when supplied with different types of arguments. Thus you could define f[a,b] and f[x[i], q[j,k]] . You can make a function respond differently if it is supplied with a number or a symbol. The pattern recognition will spot this and take the correct action. I always find it easier to work with a bracket notation. Working with subscripts has got me lost in the past.
|
|
Mar 12, 2020 at 18:44 | comment | added | HerpDerpington | @Hugh If I put the indices in brackets, how can I still pass arguments that replace the variable that had the index, for example $a,b$ in the question? If I see it correctly, I would always have to pass those indices. | |
Mar 12, 2020 at 18:36 | comment | added | Hugh | Yes you can use as many arguments to the brackets as you wish and they can be superscripts or subscripts. The advantage of using the bracket for superscripts is that they will not cause confusion with raising to a power. Note that when you wish to have a pretty, mathematical looking form for your equations or results you can put in a replacement rule to change the bracket form to a superscript or subscript form. | |
Mar 12, 2020 at 17:31 | comment | added | HerpDerpington | @Hugh That answer talks about subscripts, not superscripts. Does that also hold for the former? | |
Mar 12, 2020 at 17:02 | comment | added | Hugh |
I would not recommend superscripts. Instead use the single bracket notation. Thus f[i, j] . See here for why this is not such a good idea. All you have asked to do is absolutely standard in Mathematica.
|
|
Mar 12, 2020 at 16:11 | answer | added | CA Trevillian | timeline score: 3 | |
Mar 12, 2020 at 16:10 | review | First posts | |||
Mar 12, 2020 at 16:24 | |||||
Mar 12, 2020 at 16:06 | comment | added | CA Trevillian | Yes, you should just place the blank pattern in the sub or superscript. | |
Mar 12, 2020 at 16:03 | history | asked | HerpDerpington | CC BY-SA 4.0 |