11

4

I want to define two subscripted functions `Subscript[f,1]`

and `Subscript[f,2]`

. To keep the assignments local, I would like to associate the definitions with `f`

if possible. My current solution is to write the following.

```
f/:Subscript[f,1]:=Function[x,g[x]]
f/:Subscript[f,2]:=Function[x,h[x]]
```

The resulting definition is stored as an UpValue for `f`

, which is acceptable for me. Is it possible to construct a similar definition using pattern matching? I am looking for an analog to the following pair of definitions.

```
f[x_]:=g[x] (*definition 1*)
f:=Function[x,g[x]] (*definition 2*)
```

In other words, I am currently using a definition akin to definition 2 above for my subscripted functions. Is it possible to write a definition analogous to definition 1 above?

Do you mean

`f /: Subscript[f[x_], 1] := g[x]`

? Seems quite straight forward, so if that's your question you almost answered it yourself. – jVincent – 2012-08-16T20:03:56.0302@jVincent, he doesn't mean that. He wants it for

`Subscript[f,1][x_]`

which would be too deep for an`UpValue`

– Rojo – 2012-08-16T20:11:39.143I don't know a neat solution to these things, but workarounds are possible. Check out if symbolising the subscript is good for you – Rojo – 2012-08-16T20:14:44.367

Rojo is correct; thank you for clarifying my intentions. – Carl Morris – 2012-08-29T14:49:54.480