Post Closed as "off-topic" by MarcoB, corey979, Feyre, Simon Rochester, Sascha
2 edited tags
| link
1
source | link

optional arguments into function definition

It is possible to express the "same" function as a function of different variables in Mathematica using the following construct:

v[t_, "t"] := v0 - g t
v[y_, "y"] := Sqrt[v0^2 - 2 g (y - y0)]

Where the first is $v$ as a function of $t$ and the second is $v$ as a function of $y$.

Plugging in $t=y=0$ is done as follows:

v[0, "t"] 
v[0, "y"]

Which yields the following (expected) result:

v0
Sqrt[v0^2 + 2 g y0]

My question is simple. Nowhere in the Mathematica documentation can I find this extra "t" or "y" string argument that goes into the v[] function. I would like to understand what this argument is, why it exists and what are its limitations. The only thing I found is this, which does address additional arguments but comes at them from the point of view of optional variables. What I am doing is different. I am using the same letter to functions of two different variables, where each variable is required (not optional).