0

I was asking a question about metric space, and metric function, and was confused of what values can a set contain, respectively to the fact, that this set elements are passed as arguments to the metric function:

$$d: M \times M\space to\space \mathbb{R}$$

@Golden_Ratio answered that set may contain from entities of different types, for example

$$M:=\{\text {1(number), \{2, 3\}(vector, array)}\}$$

And arguments of the metric function are provided no matter of the expected type, just like

$$d(x, y)$$

If it is true, how to write the function equation that handles different types of variales, i.e. $x$ may be number as well as vector or a plane, or something else?

If there are kinda conditional statements in math, like in programming, so we can write

d(x, y) =  2x + y.x*y.y, typeof x == integer OR 2y + x.x*x.y
Stdugnd4ikbd
  • 205
  • 1
  • 8
  • First, re-read the (accepted by you) answer to your previous post. The simple example is the distance $d$ between points in the cartesian plane: the cartesian plane is $\mathbb R \times \mathbb R$, i.e. each element (point) is identified by a pair of numbers. The distance maps every pair to a (real) number. Thus $d : \mathbb R \times \mathbb R \to \mathbb R$ that means that the function is $d(P,Q)=r$. – Mauro ALLEGRANZA Feb 17 '23 at 14:44
  • If instead of the cartesian plane $\mathbb R \times \mathbb R$ you have a generic metric space $M$, the function $d$ maps every pair of "points" of $M$ into a real number. Thus, we have $d : M \times M \to \mathbb R$. – Mauro ALLEGRANZA Feb 17 '23 at 14:46
  • @MauroALLEGRANZA, so statement, that a set can consists of different type elements is wrong? – Stdugnd4ikbd Feb 17 '23 at 14:50
  • @Stdugnd4ikbd a set can consist of whatever you want, as long as it is well-defined. – Randall Feb 17 '23 at 14:52
  • @Randall, so how then in function's body to know which variable (that is an element from multi-type $M$) has which type? – Stdugnd4ikbd Feb 17 '23 at 15:02
  • A function has a domain a set $D$, and $D$ has well-defined elements, so I know what I can plug into it. This has nothing to do with any kind of "type" at all. – Randall Feb 17 '23 at 15:03
  • @Randall, so I know what I can plug into it - how? Can You please provide an example of function where domain consists of entities of different types? – Stdugnd4ikbd Feb 17 '23 at 15:09
  • @Stdugnd4ikbd again, "types" are not the way to think about this. math $\neq$ computer science. – Randall Feb 17 '23 at 15:13

1 Answers1

0

There is no issue with understanding functions and their inputs as long as you know well the definition of a function in terms of sets. This has nothing to do with declaring certain objects having certain "types." A function $f: D \to Z$ has domain a well-defined set $D$, so the elements of $D$ are what you plug in, whatever those elements might be (that is up to the user).

One natural example of a function that one could say has inputs of different "types" (but again, that's only confusing a situation that is already clear) is scalar multiplication of vectors. To scale a two-component vector $\mathbf{v} = \langle a, b \rangle \in \mathbb{R}^2$ by a scalar $c \in \mathbb{R}$ we write $c\mathbf{v}= \langle ca, cb\rangle$. This defines a function $$ s: \mathbb{R} \times \mathbb{R}^2 \to \mathbb{R}^2 $$ via $$ s(c,\mathbf{v})=c\mathbf{v}. $$ Thus $s$ is a function with clearly defined domain $\mathbb{R} \times \mathbb{R}^2$ and there are no doubts about the ingredients of the function or how it operates. If you wish to think about the domain as one having two "types"--one scalar, one vector--that's not harmful.

Randall
  • 18,542
  • 2
  • 24
  • 47
  • Do You know what bijection is? – Stdugnd4ikbd Feb 17 '23 at 15:16
  • Yes. How does that matter? – Randall Feb 17 '23 at 15:16
  • Bijection is injection and surjection, but, function can be also only injectional or surjectional – Stdugnd4ikbd Feb 17 '23 at 15:18
  • I don't follow. That makes no sense with the current question. – Randall Feb 17 '23 at 15:18
  • In case of surjectional function A to B, all B elements must have at least one corresponding value from A. So I can pass 2 numbers as arguments to function that expects to receive one as a vector, and it should fail – Stdugnd4ikbd Feb 17 '23 at 15:21
  • Your first sentence is a true statement, but what in the world does that have to do with your question? – Randall Feb 17 '23 at 15:22
  • If you pass two numbers into a function that expects a vector input, you did NOT put two inputs into the function. You only put in one, a vector. – Randall Feb 17 '23 at 15:22
  • answering Your last comment. You understood wrong - if I have function $f$ with to arguments $x$ and $y$, and function expects to have at least one of them to be vector and I pass both as number, should not it fail? – Stdugnd4ikbd Feb 17 '23 at 15:25
  • Of course it should fail. Again, no one here said that it shouldn't fail. – Randall Feb 17 '23 at 15:25
  • I'm deleting my answer because it is no longer clear to me that you have asked what you've intended to ask. – Randall Feb 17 '23 at 15:26
  • Okay, from another side. In function's equation, in case of vectors as arguments, can I operate with separate vector values? For example, the function is $f(x)$ where $x$ should be vector, and I want this function to return a number, that equals first vector element value multiplied by some another value, i.e. $f(x) = x.x * 10$. Can it be possible in math? – Stdugnd4ikbd Feb 17 '23 at 15:29
  • Of course it's possible. I can define a function $f: \mathbb{R}^2 \to \mathbb{R}$ by $f(\langle a, b \rangle) = 10a$. – Randall Feb 17 '23 at 15:30
  • Got You! So now You clearly specify "type" of the argument, using that brackets. That mean that You expecting to receive a vector – Stdugnd4ikbd Feb 17 '23 at 15:32
  • The "type" was already specifed when I said the domain was $\mathbb{R}^2$. – Randall Feb 17 '23 at 15:32
  • What if I also want to use numbers in domain? – Stdugnd4ikbd Feb 17 '23 at 15:33
  • Then do it (see the example in my answer). Your only job is to well-define the domain for the reader so that the inputs are exactly clear. – Randall Feb 17 '23 at 15:33
  • $f(<a,b>,c) = 10a * c$ ? – Stdugnd4ikbd Feb 17 '23 at 15:33
  • So, from this discussion it means, that mathematical formalism supposes just a letter as an argument to be a number. Variable, specified as a letter means a number. If I want to specify vector (which values are numbers) and operate with its members separately, I need to specify them as separate variables.

    Thanks

    – Stdugnd4ikbd Feb 17 '23 at 15:38