Please share your thought

$$0!=1$$

The assumed value of 1 may seem quite obvious if you consider the recursive formula. However, it did not satisfy me “mathematically”. That’s why I decided to write these few sentences. I will give motivations for the less advanced ones, but there will also be motivations for slightly more insiders.

For integer n > 0 factorial is defined as follows

$$n!=n\times (n-1)\times (n-2)\times \ldots \times 2\times 1$$

With ease you can see that below recursive formula follows

$$n!=n\times (n-1)!$$

$$1!=1$$

Small transformation of

$$n!=n\times (n-1)!$$

gives

$$(n-1)!=\frac{n!}{n}$$

Substituting n = 1

$$(1-1)!=\frac{1!}{1}$$

$$0!=1!=1$$

This explanation, although easy, does not provide (in my opinion) deep enough understanding of “why this should be the best option”.

Let’s assume we have a set containing n elements

$$\{1,2,\ldots,n\}$$

Now let”s count possible ordering of elements is this set

- n ways of selecting first element (because we have the whole set available)
- n-1 ways of selecting second element (because the first was already selected, there are n-1 left)
- n-2 ways of selecting third element (because the two were already selected, there are n-2 left)
- …
- n- (k-1) ways of selecting element number k (because the k-1 were already selected, n- (k-1) remain)
- 2 ways of selecting element number n-1 (because the n-2 were selected, still 2 remain)
- 1 way of selecting element number n (because the n-1 were were selected, remained only one)

Finally, counting all possible ways, we get

$$n\times (n-1)\times (n-2)\times \ldots \times 2\times 1=n!$$

Conclusion: Factorial of n counts the number of permutation of a set containing n elements.

The k-permutations of n are the different ordered arrangements of a k-element subset of an n-set. The number of such k-permutations of n is

$$P_k^n = n\times (n-1)\times (n-2)\times\ldots\times \bigg(n-(k-1)\bigg) = \frac{n!}{(n-k)!}$$

It is easy to see that n-permutation of n is a permutation, so

$$P_n^n=n!$$

$$n! = \frac{n!}{(n-n)!} = \frac{n!}{0!}$$

The next insight why 0!=1 is the correct definition comes from that for any n > 0 we should have

$$0! \times n! = n!$$

Function

$$f:A\to B$$

Function f : A â B, where for every a â A there is f(a) = b â B, defines the relationship between elements a and b. We can say that the elements a â A and b â B are in relation “f” if and only if f(a) = b.

Function is a binary relation, meaning function can be expressed a subset of a Cartesian product.

$$(a,b)\in f \subseteq A\times B \iff f(a)=b$$

Injective function is a function that preserves distinctness: it never maps distinct elements of its domain to the same element of its codomain. Shortly

$$x\neq y \Rightarrow f(x) \neq f(y)$$

A function f is surjective (or onto) if for every element b in codomain, there is at least one element a in the domain such such that f(a)=b . It is not required that x be unique.

$$f:A\to B$$

$${\large \displaystyle\forall_{b \in B} \quad\displaystyle\exists_{a\in A}\quad}f(a)=b$$

Bijective function, or one-to-one correspondence, is a function where each element of one set is paired with exactly one element of the other set, and each element of the other set is paired with exactly one element of the first set. There are no unpaired elements.

In mathematical terms, a bijective function is both injective and surjective mapping of a set A to a set B.

Permutation is a function that returns the order of a set, i.e. if we consider the n-element set {1, 2, âŚ, n} then permutation will be a function

$$p:\{1, 2, …, n\}\to\{1, 2, …, n\}$$

satisfying the bijective function condition.

By asking about the number of permutations we can equally ask about the number of different bijections from a given set into itself.

An empty function is every function whose domain is an empty set.

$$f:\emptyset\to B$$

The empty function “chart” is an empty set, as the Cartesian product of domain and codomain is empty.

$$\emptyset\times B = \emptyset$$

The empty function preserves distinctness (is injective), because in the domain (an empty set) there are no two different elements for which the value of the function is equal.

Let’s analyse the function that maps empty to empty set

$$f:\emptyset\to\emptyset$$

Such a function is a bijection because it is injective function (as shown above) and there is no element in codomain (the codomain is an empty set) that is not in relation to the elements in the domain.

Please note that there is exactly one such a bijection, which is a results of that the function is a subset of the Cartesian product of domain and codomain. In this case this is only one possible set.

$$f:\emptyset\to\emptyset$$

$$\emptyset\times\emptyset = \emptyset$$

The empty set has exactly one subset, which is the empty set – thus such a bijection is uniquely defined.

I wrote above that the number of permutations of an n-element set equals the number of distinct bijective functions from this set into itself.

Following – the permutation of 0-element set corresponds to the bijection from an empty set into the empty set/

The special case of empty function is just 1 – and I presented the proof that there exists only one such a function

Pretty deep insight why 0! should by 1.

In mathematics, the Gamma function is one of the extensions of the factorial function with its argument shifted down by 1, to real and complex numbers.

$$\Gamma(z)=\displaystyle\int_0^{+\infty}t^{z-1}e^{-t}dt$$

After integration by parts we get the recursive formula

$$\Gamma(z+1)=z\cdot\Gamma(z)$$

Let’s see the value of

$$\Gamma(1)=?$$

$$\Gamma(1)=\displaystyle\int_0^{+\infty}e^{-t}dt=\displaystyle\int_{-\infty}^{0}e^{t}dt$$

Following

$$\Gamma(n+1)=n!$$

$$0! = \Gamma(1) = 1$$

Functions in Scalar Calculator, that support Gamma special function

**Gamma(x)**– Gamma special function Î(s)**sgnGamma(x)**– Signum of Gamma special function, Î(s)**logGamma(x)**– Log Gamma special function, lnÎ(s)**diGamma(x)**– Digamma function as the logarithmic derivative of the Gamma special function, Ď(x)**GammaL(s,x)**– Lower incomplete gamma special function, Îł(s,x)**GammaU(s,x)**– Upper incomplete Gamma special function, Î(s,x)**GammaP(s,x) , GammaRegL(s,x)**– Lower regularized P gamma special function, P(s,x)**GammaQ(s,x), GammaRegU(s,x)**– Upper regularized Q Gamma special function, Q(s,x)

Based on Taylor series expansion of e^x it is easy to show that

$$e=\displaystyle\sum_{n=0}^\infty\frac{1}{n!}=\frac{1}{0!}+\frac{1}{1!}+\frac{1}{2!}+\frac{1}{3!}+\ldots$$

Thanks for reading! All the best

If you have smiled, please **click the link** and give Scalar some stars – It really helps and makes me smile as well

If you have smiled, please **click the link** and give Scalar some stars – It really helps and makes me smile as well

Scalar implements broad support for the normal distribution:

**pNor(x, mean stdv)**– Probability Distribution Function for normal distribution**cNor(x, mean, stdv)**– Cumulative Distribution Function for normal distribution**rNor(mean, stdv)**– Random numbers generation from normal distribution**[Nor]**– Random variable from N(0,1) normal distribution

Additionally nice function graph example

It is said that multiplication is a short notation of repeated addition, which is absolutely true and, with a limitation to integers, a fairly obvious fact.

**4 Ă 3 = 3 + 3 + 3 + 3 = 4 + 4 + 4 = 3 Ă 4 = 12**

These two fundamental multiplication properties can be written as follows

commutative property: **a Ă b = b Ă a**

example: **3 Ă 4 = 4 Ă 3**

distributive property: **a Ă (b + c) = a Ă b + a Ă c**

example: **3 Ă 4 = 3 Ă (1 + 3) = 3 Ă 1 +3 Ă 3 = 3 + 9 = 12**

Mathematicians, defining the arithmetic of negative numbers, wanted to be consistent with the already developed arithmetic of positive numbers and zero. Based on the interpretation of the short notation of repeated addition, we can easily justify the following:

**â3 Ă 4 = (â3) + (â3) + (â3) + (â3) = â12**

“By adding debt to debt,” we get more debt – intuitive. Now using the

commutative property of multiplication we get:

**4 Ă (â3) = â3 Ă 4 = â12**

At this point, the intuition is a bit more difficult, but the consistency has been preserved. Time to go to the main point – let’s try to answer the question:

**â3 Ă (â4) = ?**

To solve the above, we will use a trick based on the distributive property of multiplication over addition.

**â3 Ă 0 = 0**

**â3 Ă 0 = â3 Ă (â4 + 4) = 0**

**â3 Ă (â4 + 4) = â3 Ă (â4) + (â3) Ă 4 = 0**

**â3 Ă (â4) + (â12) = 0**

**â3 Ă (â4) = 12**

The above has nothing to do with intuition, but it is consistent, i.e. based on the arithmetic of positive numbers and zero, the commutative property of multiplication, the distributive property of multiplication over addition, we are able to justify why multiplying negative numbers must be a positive number.

Suppose we multiply two numbers, where the interpretation of the first is the value of profit or losses, while the meaning of the second one is the multiplication (increase / decrease) of the first value. In this situation, multiplying two negative numbers means reducing the loss, ie the total positive effect of the action.

profit Ă increase = positive effect

profit Ă decrease = negative effect

loss Ă increase = negative effect

**loss Ă decrease = positive effect**

The above explanation can be described as intuitive

Finally a video from Mathologer explaining the above problem (that was a base for the above post).

Let’s run the negative numbers multiplication test using the Scalar calculator.

Test fully successful Thank you for reading! All the best

The syntax for defining user functions is as follows.

**FunctionName(param1 <, param2, …>) = expression**

It is much easier to understand this on the basis of an example – it is really easy. Please note that **you can easily define a function depending on the function you have already defined.** It gives you great flexibility.

**Scalar code result:**

scalar > f(x) = sqrt(x) scalar > g(x) = f(x)^2 scalar > h(x) = g(x)^2 scalar > h(4) e1 = 16 scalar > g(4) e2 = 4 scalar > f(4) e3 = 2 scalar > Showing command history

**Scalar script:**

f(x) = sqrt(x) g(x) = f(x)^2 h(x) = g(x)^2 h(4) g(4) f(4)

I am sure, that from time to time, you will want to check what you have already defined. This is possible using context help. Long click on the “example /?” button, then select the user items option.

Each defined function is available in the Scalar namespace. Nothing prevents you from referring to these names anywhere in the application. **In particular, it allows you to draw graphs of your own functions.**

Nothing special in this case as Scalar has no restrictions. Simply use the similar syntax to the presented in the below example.

**Scalar code result:**

scalar > f(x,y) = sin(x) + cos(y) scalar > f(pi/6, pi/4) e1 = 1.2071067811865475 scalar > 1/2 + sqrt(2)/2 e2 = 1.2071067811865475 scalar > f(x,y,z) = x*y*z scalar > f(1,2,3) e3 = 6 scalar > f(4,5,f(1,2,3)) e4 = 120

**Scalar script:**

f(x,y) = sin(x) + cos(y) f(pi/6, pi/4) 1/2 + sqrt(2)/2 f(x,y,z) = x*y*z f(1,2,3) f(4,5,f(1,2,3))

Scalar provides a special syntax for defining functions with **any (variable) number of parameters.**

**FunctionName(…) = expression**

**“(…)”** is obligatory as it indicates that you create function with variable number of parameters.

**Additionally Scalar provides special keywords that help to build expression defining variadic functions.**

**[npar]**– number of parameters provided by the user on calculation request**par(i)**– value of parameter at index “i”

Please refer to the below example

**Scalar code result:**

scalar > f(...) = [npar] scalar > f(2) e1 = 1 scalar > f(3,1) e2 = 2 scalar > f(4,2,5,6) e3 = 4 scalar > f(...) = sum(i,1,[npar],par(i)) scalar > f(1,2,3,4,5) e4 = 15 scalar > 1+2+3+4+5 e5 = 15

**Scalar script:**

f(...) = [npar] f(2) f(3,1) f(4,2,5,6) f(...) = sum(i,1,[npar],par(i)) f(1,2,3,4,5) 1+2+3+4+5

Thank you for your time

All the bets!

**In Scalar you can simply write x = 2, y = 2 * x**, etc. Try it yourself. Pay particular attention to the fact that when defining the argument y, which depends on the argument x, the change in the value of x affects the value of y. In other words, Scalar remembers the expressions that define the arguments and uses these expressions at the time of requesting the value.

**Scalar code result:**

scalar > x = 2 scalar > x e1 = 2 scalar > 2*x + 4 e2 = 8 scalar > y = 2*x + 4 scalar > y e3 = 8 scalar > x = 3 scalar > y e4 = 10

**Scalar script:**

x = 2 x 2*x + 4 y = 2*x + 4 y x = 3 y

In terms of dependencies between arguments Scalar does not define any restrictions. You can create wide and deep dependency trees. This is well illustrated by the example below.

**Scalar code result:**

scalar > a = 3 scalar > b = 3*a + 2 scalar > c = a*b scalar > d = a + b + c scalar > d e1 = 47 scalar > a = 4 scalar > d e2 = 74 scalar > a = 5 scalar > d e3 = 107

**Scalar script:**

a = 3 b = 3*a + 2 c = a*b d = a + b + c d a = 4 d a = 5 d

In certain situations, it is convenient to check how user elements are defined. Use the list command to do this.

**list**

Please note that Scalar assigns the results of the calculations to the constant, while the arguments are marked separately.

**Scalar code result:**

scalar > list Type Name/Value ---- ---------- Constant: e1 = 47.0 ----- d Constant: e2 = 74.0 ----- d Constant: e3 = 107.0 ----- d Argument: a = 5.0 ----- a = 5 Argument: b = 17.0 ----- b = 3*a + 2 Argument: c = 85.0 ----- c = a*b Argument: d = 107.0 ----- d = a + b + c

**Scalar script:**

list

You can also use context help to verify the elements definition. Long click on the “example /?” button, then in the dialog select the user items.

The difference between the user constant and the user argument is fundamental. T**he constant only remembers the value, the argument remembers the expression, thanks to which the value can be calculated. **You can define your own constant by adding the const command at the beginning.

**const **def

**Scalar code result:**

scalar > x = 3 scalar > const y = x^2 scalar > y e1 = 9 scalar > x = 10 scalar > y e2 = 9 scalar > list Type Name/Value ---- ---------- Constant: y = 9.0 ----- y = x^2 Constant: e1 = 9.0 ----- y Constant: e2 = 9.0 ----- y Argument: x = 10.0 ----- x = 10

**Scalar script:**

x = 3 const y = x^2 y x = 10 y list

It’s all for today. Thank you

The most frequently used numbers are 2 and 5. It is also well visible the effect of multi-use of the digit 0 considering particular user perspective. The digit, that is used the least often, is 7.

Digit | Clicks [%] | Users [%] |

0 | 12.8% | 7.8% |

1 | 12.5% | 11.0% |

2 | 17.5% | 16.0% |

3 | 11.3% | 12.0% |

4 | 6.5% | 8.0% |

5 | 15.3% | 14.4% |

6 | 9.9% | 10.7% |

7 | 3.9% | 6.1% |

8 | 5.3% | 7.3% |

9 | 5.1% | 6.6% |

Sequence: 2, 5, 0, 1, 3, 6, 4, 8, 9, 7

Digit | Clicks [%] | Users [%] |

2 | 17.5% | 16.0% |

5 | 15.3% | 14.4% |

0 | 12.8% | 7.8% |

1 | 12.5% | 11.0% |

3 | 11.3% | 12.0% |

6 | 9.9% | 10.7% |

4 | 6.5% | 8.0% |

8 | 5.3% | 7.3% |

9 | 5.1% | 6.6% |

7 | 3.9% | 6.1% |

Sequence: 2, 5, 3, 1, 6, 4, 0, 8, 9, 7

Digit | Clicks [%] | Users [%] |

2 | 17.5% | 16.0% |

5 | 15.3% | 14.4% |

3 | 11.3% | 12.0% |

1 | 12.5% | 11.0% |

6 | 9.9% | 10.7% |

4 | 6.5% | 8.0% |

0 | 12.8% | 7.8% |

8 | 5.3% | 7.3% |

9 | 5.1% | 6.6% |

7 | 3.9% | 6.1% |

By removing the digits 0 and 3, we get the same order in terms of per clicks and per users perspectives.

Sequence position | Digits by Clicks | Digit by Users |

1 | 2 | 2 |

2 | 5 | 5 |

3 | 0 | 3 |

4 | 1 | 1 |

5 | 3 | 6 |

6 | 6 | 4 |

7 | 4 | 0 |

8 | 8 | 8 |

9 | 9 | 9 |

10 | 7 | 7 |

Interesting! All the best!

Entering numbers in the form of fractions is done using the following syntax:

**a_b**: a – numerator, b – denominator, converted to decimal:**a/b****a_b_c**: a – whole, b – numerator, c – denominator, converted to decimal:**a+c/b**

Please follow the below example:

**Scalar code result:**

scalar > 1_3 e1 = 0.3333333333333333 scalar > 1_3 + 1_6 e2 = 0.5 scalar > 2_3_4 e3 = 2.75 scalar > 100_2_10 e4 = 100.2 scalar > 8^1_3 e5 = 2 scalar > -5_13_3 e6 = -9.333333333333332

**Scalar script:**

1_3 1_3 + 1_6 2_3_4 100_2_10 8^1_3 -5_13_3

Result of any expression can be presented as a fraction. Please use below syntax:

**frac** expression

**The conversion procedure in some cases may give an approximate result.** That is why it is worth observing the epsilon parameter.

Please follow below examples:

**Scalar code result:**

scalar > frac 0.5 e1 = 1/2 eps = 0 scalar > frac -1.3 e2 = -1-3/10 eps = 0 scalar > frac 1.3 e3 = 1+3/10 eps = 0 scalar > 3-2/13 e4 = 2.8461538461538463 scalar > frac 2.8461538461538463 e5 = 2+11/13 eps = 0 scalar > frac pi e6 = 3+14159265358979/100000000000000 eps = 0.0000000000000031086244689504383

**Scalar script:**

frac 0.5 frac -1.3 frac 1.3 3-2/13 frac 2.8461538461538463 frac pi

The decimal to fraction conversion algorithm is carried out in a few steps. The first step is to try to find an accurate representation through an optimized search method. You can control the search range using the parameter available in the application options.

**To Fraction Init Search Size** – Maximum number for initial search of denominator – default value 10000

Thank you for reading and thank you for using Scalar. If you like my app **please make me a gift posting a review on Google Play store – links below.**

All the best!

]]>- Convert decimal system
**to other numeral systems** - Convert
**other numeral systems**into a decimal system - Enter values simultaneously in
**different numeral systems** - Acquire
**information about the digits of a given numbe**r on the basis of the indicated numeral system

Stay tuned, this is exciting

Conversion of the number to different numeral systems is done at the end, i.e. after determining the value of the expression. User indicates in which numeral system the result should be presented. General syntax:

**<NumeralSystem> expression**

- binary:
**bin expression** - octal:
**oct expression** - decimal:
**expression** - hexadecimal:
**hex expression** - base-n:
**base.n expression**

Please follow the below examples

**Scalar code result:**

scalar > bin 127 e1 = b.1111111 eps = 0 scalar > oct 127 e2 = o.177 eps = 0 scalar > hex 127 e3 = h.7F eps = 0 scalar > base.3 127 e4 = b3.11201 eps = 0 scalar > base.16 127 e5 = h.7F eps = 0 scalar > base.9 (1+3)*4 e6 = b9.17 eps = 0

**Scalar script:**

bin 127 oct 127 hex 127 base.3 127 base.16 127 base.9 (1+3)*4

The mathematical engine of Scalar always works in one numeral system, so before it is possible to determine the result of an expression, all values given in different numeral systems are converted to one decimal standard. In Scalar you can enter numbers using any numeral system. General syntax:

**<NumericalSystemPrefix.>NumberLiteral**

- binary:
**b.XXXX** - octal:
**o.XXXX** - decimal:
**XXXX** - hexadecimal:
**h.XXXX** - base-n:
**b<n>.XXXX**

Please follow the below examples

**Scalar code result:**

scalar > hex 123 e1 = h.7B eps = 0 scalar > h.7b e2 = 123 scalar > 123-h.7b e3 = 0 scalar > hex h.7b e4 = h.7B eps = 0 scalar > bin h.7b e5 = b.1111011 eps = 0 scalar > b1.11111 e6 = 5 scalar > b1.11111 - 5 e7 = 0

**Scalar script:**

hex 123 h.7b 123-h.7b hex h.7b bin h.7b b1.11111 b1.11111 - 5

Scalar is very flexible, thus there is no limitation in terms of entering number in various numeral systems.

**Scalar code result:**

scalar > b1.11111*5 e1 = 25 scalar > x = b16.7b + b1.11111 scalar > x e2 = 128 scalar > 2*x e3 = 256 scalar > hex 2*x e4 = h.100 eps = 0 scalar > h.100 e5 = 256 scalar > base.1 32 e6 = b1.11111111111111111111111111111111 eps = 0

**Scalar script:**

b1.11111*5 x = b16.7b + b1.11111 x 2*x hex 2*x h.100 base.1 32

Using a standard alphabet, i.e. alphabetical order of letters, you can enter numbers in a numeral system with **base between 1 and 36**. In case of any larger bases, please use the function **base (n, …)** that accepts many parameters.

**Scalar code result:**

scalar > base.3 56 e1 = b3.2002 eps = 0 scalar > base(3, 2, 0, 0, 2) e2 = 56 scalar > base(256, 2, 0, 0, 2) e3 = 33554434 scalar > base(256, 54, 125, 36, 2) e4 = 914170882 scalar > base.23 10000000 e5 = b23.1CGKDE eps = 0 scalar > b23.1cgkde e6 = 10000000

**Scalar script:**

base.3 56 base(3, 2, 0, 0, 2) base(256, 2, 0, 0, 2) base(256, 54, 125, 36, 2) base.23 10000000 b23.1cgkde

During the conversion of the result to the indicated numeral system, only the integer part is converted. Please follow the epsilon remark to be sure what part was not converted.

**Scalar code result:**

scalar > pi^e e1 = 22.45915771836104 scalar > bin pi^e e2 = b.10110 eps = 0.45915771836104113 scalar > e^pi e3 = 23.140692632779263 scalar > bin e^pi e4 = b.10111 eps = 0.14069263277926325 scalar > bin -e^pi e5 = -b.10111 eps = 0.14069263277926325

**Scalar script:**

pi^e bin pi^e e^pi bin e^pi bin -e^pi

Scalar provides several clever functions that allow **to obtain information about the digits of a given number.** Long press the “example /?” button and enter “numeral” in the search field. You will be presented with the list of functions.

**ndig10(x)**– number of digits of a number in base 10**ndig(x, base)**– number of digits of a number in any base**dig10(x, position)**– digit of a number in base 10 at specified position**dig(x, position, base)**– digit of a number in any base at specified position

And a few examples:

**Scalar code result:**

scalar > base.3 1234567 e1 = b3.2022201111201 eps = 0 scalar > ndig10(1234567) e2 = 7 scalar > ndig(1234567, 3) e3 = 13 scalar > dig10(1234567, 5) e4 = 5 scalar > dig(1234567, 5, 3) e5 = 2 scalar > dig(h.abfd, 3, 16) e6 = 15

**Scalar script:ďťż**

base.3 1234567 ndig10(1234567) ndig(1234567, 3) dig10(1234567, 5) dig(1234567, 5, 3) dig(h.abfd, 3, 16)

Thank you for reading and thank you for using Scalar. If you like my app **please make me a gift posting a review on Google Play store.**

Best regards

]]>