How to define a function with subscripted variable in Mathematica?

252 Views Asked by At

How to define a function with subscripted variable? I want to write the following expression $$f[a_9] =1+ a_7 + a_9$$

I tried to write "f[Subscript[a, 9]_ ] := 1+ [Subscript[a, 7]+ [Subscript[a, 9]" but it doesn't work

1

There are 1 best solutions below

0
On

See https://mathematica.stackexchange.com/search?q=subscript+variable.

I wasn't able to find a straight answer there or make it work myself; it sounds like subscripting is suboptimal for this purpose. There are lots of workarounds you could do where you render it to appear as a subscript after the fact (maybe with $PrePrint), depending on what exactly you're trying to accomplish.