The above is perhaps the best known formula and is also rarely understood. Although the formula for the area of ββa circle was already known in Ancient Greece, its justification is not easy at all. So it’s a great topic to enrich the “Why?” series.

As you can see above – a square and a circle of the same area are not “somehow intuitively easy” related. Moreover, it has even been shown that squaring a circle (a procedure performed using a compass and a ruler without a scale) is impossible! And here comes the brilliant idea with a rectangle. Before I tell you what it is, let’s take a look at what the ΟΒ·rΒ² formula really says.

So there are slightly more than 3 squares of the side r in the circle with radius r.

I worked hard on this animation, I hope you like it. Let me know in the comments

Note – the following is not a formal proof, it only illustrates the inference method used by the Ancient Greeks (such as Archimedes’ and determination of the number pi).

It can be seen that the circumference of the regular n-gon circumscribed on the circle is

$$C_n=na$$

and its area is the sum of the areas of the triangles with the base a and the height equal to the circle radius r.

$$A_n=n\frac{ar}{2}=\frac{nar}{2}$$

Substituting

$$A_n=\frac{C_nr}{2}$$

As n gets bigger, Aβ approximates the circle’s area more and more closely, and Cβ approximates its circumference. In the “limit step” (infinitesimal) we get the

$$C=\lim C_n=2\pi r$$

$$A=\lim A_n=\lim \frac{C_nr}{2}=\frac{r}{2}\lim C_n=…$$

$$…=\frac{r}{2}C=\frac{r}{2}2\pi r=\pi r^2$$

$$A=\pi r^2$$

The proof I am going to present will not be based on integrating the circle equation. I am going to use sequences and their limits and the squeeze theorem.

Let be given three real sequences aβ, bβ, and cβ. If “almost everywhere” (i.e. omitting at most finite many terms) there is a relation

$$a_n\leq b_n\leq c_n$$

and

$$\lim a_n = \lim c_n = g$$

then

$$\lim b_n = g$$

$$\lim_{x\to 0}\frac{\sin x}{x} = 1$$

I remember from high school, in physics classes, my teacher repeatedly assumed that for small x the function sin (x) can be approximated well by x. It is a results of sin(x) expansion into the Taylor series – let me omit the explanation. However, I will calculate the limit using L’HΓ΄pital’s rule. Later on it is going to be very useful

$$\lim_{x\to 0}\frac{\sin x}{x}=\big(\frac{0}{0}\big)\text{ L’HΓ΄pital’s rule}=$$

$$=\lim_{x\to 0}\frac{(\sin x)\prime}{x\prime}=\lim_{x\to 0}\frac{\cos x}{1}=$$

$$=\frac{\cos 0}{1}=\frac{1}{1}=1$$

$$\lim_{x\to 0}\frac{\sin x}{x} = 1$$

Let us consider regular n-gon circumscribed on a circle and inscribed inside a circle. Let us call “Outer area” the are of the circumscribed n-gon and denote it by Oβ. Similarly, we will call the inscribed n-gon area as “Inner area”, marking it Iβ.

Obviously

$$I_n\leq A\leq O_n$$

where A states for the area of a circle.

In the next step, we divide n-gon into n-triangles. Note that in this way the full angle was also divided into n equal parts. The area of the “outer triangle” will be Tβ and the area of the inner triangle tβ.

$$O_n=nT_n$$

$$I_n=nt_n$$

**We determine the area of the “outer” triangle by**

$$T_n=Br$$

but

$$\frac{B}{r}=\tan\beta=\frac{\sin\beta}{\cos\beta}$$

$$\frac{B}{r}r^2=r^2\frac{\sin\beta}{\cos\beta}$$

$$Br=r^2\frac{\sin\beta}{\cos\beta}$$

$$T_n=r^2\frac{\sin\beta}{\cos\beta}=r^2\frac{\sin\frac{\pi}{n}}{\cos\frac{\pi}{n}}$$

**We determine the area of the “inner” triangle by**

$$t_n=bh$$

but

$$\frac{b}{r}=\sin\beta$$

$$b=r\sin\beta$$

and

$$\frac{h}{r}=\cos\beta$$

$$h=r\cos\beta$$

substituting

$$t_n=r\sin\beta\cdot r\cos\beta=r^2\sin\beta\cos\beta$$

using trigonometric identities

$$t_n=r^2\sin\beta\cos\beta=\frac{r^2}{2}2\sin\beta\cos\beta=…$$

$$…=\frac{r^2}{2}\sin2\beta=\frac{r^2}{2}\sin\alpha$$

$$t_n=\frac{r^2}{2}\sin\alpha=\frac{r^2}{2}\sin\frac{2\pi}{n}$$

**Final sequences**

$$O_n=nT_n=nr^2\frac{\sin\frac{\pi}{n}}{\cos\frac{\pi}{n}}$$

$$I_n=nt_n=\frac{nr^2}{2}\sin\frac{2\pi}{n}$$

**The limit of Oβ ad Iβ**

$$\lim O_n=\lim nr^2\frac{\sin\frac{\pi}{n}}{\cos\frac{\pi}{n}}=$$

$$=\lim \frac{nr^2}{\cos\frac{\pi}{n}}\cdot\frac{\pi}{n}\cdot\frac{\sin\frac{\pi}{n}}{\frac{\pi}{n}}=$$

$$=\lim \frac{\pi r^2}{\cos\frac{\pi}{n}}\cdot\frac{\sin\frac{\pi}{n}}{\frac{\pi}{n}}=\frac{\pi r^2}{\cos 0}\cdot 1=$$

$$=\frac{\pi r^2}{1}=\pi r^2$$

$$\lim O_n=\pi r^2$$

$$\lim I_n=\lim\frac{nr^2}{2}\sin\frac{2\pi}{n}=$$

$$=\lim \frac{nr^2}{2}\cdot \frac{2\pi}{n}\cdot\frac{\sin\frac{2\pi}{n}}{\frac{2\pi}{n}}=$$

$$=\lim \pi r^2\cdot\frac{\sin\frac{2\pi}{n}}{\frac{2\pi}{n}}=\pi r^2\cdot 1=\pi r^2$$

$$\lim I_n=\pi r^2$$

**Final conclusion**

From the squeeze theorem we conclude that the area of the circle is

$$A=\lim O_n=\lim I_n=\pi r^2$$

This is a perfect task for scalar calculator

```
scalar > O(n,r)=n*r^2*sin(pi/n)/cos(pi/n)
scalar > I(n,r)=n/2*r^2*sin(2*pi/n)
scalar > O(3,1)
e1 = 5.196152422706632
scalar > O(7,1)
e2 = 3.371022331652701
scalar > O(20,1)
e3 = 3.1676888064907254
scalar > O(1000,1)
e4 = 3.141602989056156
scalar > I(3,1)
e5 = 1.299038105676658
scalar > I(7,1)
e6 = 2.7364101886381045
scalar > I(20,1)
e7 = 3.090169943749474
scalar > I(1000,1)
e8 = 3.141571982779475
```

**Plus the graph presenting sequences convergence**

```
//The area of a circle.scg
var = n
from = 3
to = 100
miny = pi-0.5
maxy = pi+0.5
exp1 = O(n,1)
exp2 = I(n,1)
exp3 = pi
line1 = 0
line2 = 0
by = 1
curs = 1
```

Take care! Greetings.

I hope I gave you some pleasure ???? with Scalar. Thank you for the 2019. Merry Christmas!

You come from all over the world. I’m very happy about this. Below is a map of people visiting ScalarMath.org.

Click and share ? some good energy with me – simple app rating is the best present I can receive ????

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

]]>Let’s start with the list of functions and options available in Scalar, which are linked to prime numbers. On the calculator screen, long click on the **“example /?”** button. As a result you will get the help dialog containing search option. Enter “prime” keyword.

Scalar functions list:

**ispr(n)**– prime number test (is number a prime?)**Pi(n)**– prime-counting function – Pi(x)**nfact(x**) – prime decomposition – number of distinct prime factors**factval(number, factorid)**– prime decomposition – factor value at position between 1 β¦ nfact(n) – ascending order by factor value**factexp(number, factorid)**– prime decomposition – factor exponent / multiplicity at position between 1 β¦ nfact(n) – ascending order by factor value**factor expr**– prime factorization – calculate expression, return result in the form of prime factors**fact expr**– the same as factor

Prime test function **ispr(n)** returns 1 if the number is prime and 0 otherwise. Using sigma summation operator **sum(arg, from, to, expr)** plus combination with **ispr(n)** it is very easy to count primes in a given range. Please refer to the below example:

**Scalar code result:**

scalar > ispr(1) e15 = 0 scalar > ispr(2) e16 = 1 scalar > ispr(3) e17 = 1 scalar > ispr(4) e18 = 0 scalar > sum(n,1,1000,ispr(n)) e19 = 168 scalar > Pi(1000) e20 = 168 scalar > Pi(10000000) e21 = 664579

**Scalar script:**

ispr(1) ispr(2) ispr(3) ispr(4) sum(n,1,1000,ispr(n)) Pi(1000) Pi(10000000)

Above example shows also the **Pi(n)** prime-counting function.

This time I will show visually the quality of various approximations of **Pi(n)** prime-counting function:

**Pi(n)**– prime-counting function – definition can be found here,**li(n)**– logarithmic integral – a special function – please refer to the definition here,**n/ln(n)**– Gauss-Legendre approximation of Pi(n)

**Prime-counting function in the range between 2 and 100**

**Scalar graph script:**

var = n from = 2 to = 100 exp1 = Pi(n) exp2 = n/ln(n) exp3 = li(n) by = 1 curs = 1

**Prime-counting function in the range between 2 and 2000**

**Scalar graph script: **

var = n from = 2 to = 2000 exp1 = Pi(n) exp2 = n/ln(n) exp3 = li(n) by = 1 curs = 1

**Prime-counting function in the range between 2 and 150000000**

** Scalar graph script: **

var = n from = 2 to = 150e6 exp1 = Pi(n) exp2 = n/ln(n) exp3 = li(n) by = 1e6 curs = 1

To get prime factors for a given number just use **factor **or **fact** Scalar command. Please refer to the below screenshots:

**Scalar code result:**

scalar > fact 324 e8 = 2^2 * 3^4 eps = 0 scalar > nfact(324) e9 = 2 scalar > factval(324,1) e10 = 2 scalar > factexp(324,1) e11 = 2 scalar > factval(324,2) e12 = 3 scalar > factexp(324,2) e13 = 4 scalar > e10^e11 * e12^e13 e14 = 324

**Scalar script:**

fact 324 nfact(324) factval(324,1) factexp(324,1) factval(324,2) factexp(324,2)

**Scalar code result:**

scalar > fact 324 e1 = 2^2 * 3^4 eps = 0 scalar > fact 254*5 e2 = 2^1 * 5^1 * 127^1 eps = 0 scalar > fact 1254685755845 e3 = 5^1 * 250937151169^1 eps = 0 scalar > n=2598 scalar > fact n e4 = 2^1 * 3^1 * 433^1 eps = 0

**Scalar script:**

fact 324 fact 254*5 fact 1254685755845 n=2598 fact n

Counting primes is a time consuming task.

In order to significantly accelerate the calculation Scalar implements Sieve of Eratosthenes. The only thing you have to do is to go to the settings screen and enter in the “Max num in primes cache” option the range that will be examined. After doing so, Scalar will build the cache that will be saved in memory for further usage.

Say bye bye for prolonging progress bar!

**Best regards! **