0

I want to define a function that is called by another function. When we define the called function, which notations could it use? Hence, can it use the same notations as the function is called.

In programming we can use the same parameter names for each function since their namespaces are not affected by the function it is called from.


Here is a very simple example:

Let $A^{}_{N} = \{a^{}_{{1}},a^{}_{{2}},\dotsc,a^{}_{{\lvert N\rvert}}\} \\ B^{}_{N} = \{b^{}_{{1}},b^{}_{{2}},\dotsc,b^{}_{{\lvert N\rvert}}\} \\ Y{}_{N} = \{y^{}_{{1}},y^{}_{{2}},\dotsc,y^{}_{{\lvert N\rvert}}\} $ and

$C(A_N, B_N, Y_N) = \sum_{n \in N} R(a_{n},b_{n},y_{n})$


Here when I define a function $R$, can its parameter has the same notation as $a_n$, $b_n$, $y_n$:

$R(a_n,b_n,y_n) = a_n * 100 + b_n + y_n$

Or should I come up with different notations naming like:

  • $R(\hat{a}_n,\hat{b}_n,\hat{y}_n) = a_n * 100 + \hat{b}_n + \hat{y}_n$
  • $R(\hat{a},\hat{b},\hat{y}) = \hat{a} * 100 + \hat{b} + \hat{y}$
  • $R(a',b',y') = a' * 100$ + b' + y'

Thank you for your valuable time and help.

alper
  • 101
  • What you wrote is fine, though it's technically ambiguous as a function (since it's not clear what the domain of R is). Seems more natural to define $R(x) = 100x$ where the sequence $(a_i)$ takes values in the (specified) domain of $R$. Remember functions in math are comprised of a domain, a codomain, and a rule assigning a (single) value of the codomain to each element of the domain. – Brevan Ellefsen Oct 18 '22 at 10:21
  • If $R$ takes multiple parameters could I do $R(x,y,z,...)$ ? I updated my question for this. For example if I have some other definition for $x$ as well , could I still do $R(x)$? – alper Oct 18 '22 at 10:37
  • Don't edit your question so much that it fundamentally changes the question.... Ask a new one instead. And no, functions in math must have a fixed number of inputs (namely one). Functions are a mapping from a domain to a codomain by a specified rule, nothing more and nothing less. As such, functions in math ALL take a single input (we still sometimes write it as if there are multiple inputs, by splitting the input in a canonical way. These are technically different functions though) – Brevan Ellefsen Oct 18 '22 at 10:41
  • @BrevanEllefsen Remember functions in math are comprised of a domain, a codomain, and a rule assigning a (single) value of the codomain to each element of the domain Can you clearify this? Is $R(x)$ and $C(A_n)$ considered to be in the same domain or different domain? – alper Oct 19 '22 at 11:42
  • $R$ is a function, $x$ is a value in the domain of $R$, and $R(x)$ is a value in the codomain of $R$. Since we need to define the map from inputs to outputs when defining a function, we usually give it in terms of codomain values... For example, consider the function $f\colon \mathbb R \to \mathbb R$ given by $f(x) = x^2$. This means the domain and codomain of $f$ are the real numbers, and $f$ returns the square of whatever real number you feed into it. Note the codomain is bigger than the range aka image (since you can't reach all real numbers via squaring, i.e. the negative numbers)... – Brevan Ellefsen Oct 19 '22 at 14:49
  • ... and that defining $f(y) = y^2$ yields the same function. When defining a function, the variable used is considered a dummy variable, so technically anything works. (In practice certain variables names are used in specific contexts... Think of it as the equivalent to reserved namespace values in programming to make it easier on a reader). When actually evaluating a function the variable is no longer considered dummy. For example, we might set $x = 2$ and then find $f(x) = x^2 = 2^2 = 4$. This is a slight abuse of notation, but is standard for conciseness – Brevan Ellefsen Oct 19 '22 at 14:53
  • If you want to plug a function into another function it's called composition. For example, if $g\colon \mathbb R \to \mathbb R$ is given by $g(x) = \sin x$, then $f(g(x)) = \sin(x) ^2$ and $g(f(x)) = \sin(x^2)$ (which are not the same). Note the codomain of the inside function has to match the domain of the outside function for this to make sense. Note a sequence is technically a function (whose domain is some subset of the natural numbers) so to write $C(a_n)$ you must have first defined functions $C$ and $a_n$ before composing them – Brevan Ellefsen Oct 19 '22 at 15:08

0 Answers0