Matematika

paket "matematika";

The matematika package comes with various mathematical functions and constants. Below is a comprehensive list.

Variables:

  1. pi
  2. e
  3. beskonacno
  4. minusBeskonacno

Functions:

  1. apsolutnaVrijednost
  2. arccos
  3. arcsin
  4. sin
  5. cos
  6. tg
  7. arctg
  8. korijen
  9. eNa
  10. ln
  11. log
  12. log10
  13. log2
  14. max
  15. min
  16. zaokruzi
  17. kubniKorijen
  18. uStepenima

Variables

Constant pi

Pi is the mathematical constant that represents the ratio of a circle’s circumference to its diameter.

ispis(pi);
Output:

3.141592653589793

Constant e

e is the mathematical constant known as Euler’s number. It is the base of the natural logarithm.

ispis(e);
Output:

2.718281828459045

Infinity

Bosscript has separate constants for positive and negative infinity.

ispis(beskonacno);
ispis(minusBeskonacno);
ispis(apsolutnaVrijednost(22));

ispis(apsolutnaVrijednost(-22));

ispis(apsolutnaVrijednost(0));
Output:

22
22
0

arccos

The arccos function returns the arc cosine of a provided broj.

ispis(arccos(1));

ispis(arccos(0));

ispis(arccos(100));
Output:

0
1.5707963267948966 "comment">// π/2
NaN

arcsin

The arcsin function returns the arc sine of a provided broj.

ispis(arcsin(0));

ispis(arcsin(1));

ispis(arcsin(100));
Output:

0
1.5707963267948966 "comment">// π/2
NaN

sin

The sin function returns the sine of a provided broj.

ispis(sin(90));

ispis(sin(0));

ispis(sin(45));
Output:

1
0
0.7071067811865475

cos

The cos function returns the cosine of a provided broj.

ispis(cos(90));

ispis(cos(0));

ispis(cos(45));
Output:

0
1
0.7071067811865476

tg

The tg function returns the tangent of a provided broj.

ispis(tg(90));

ispis(tg(0));

ispis(tg(45));
Output:

1.633123935319537E16 "comment">// Actually undefined
0
1

arctg

The arctg function returns the arc tangent of a provided broj.

ispis(arctg(0));

ispis(arctg(1));

ispis(arctg(100));
Output:

0
0.7853981633974483
1.5607966601082315

korijen

The korijen function returns the square root of a provided broj.

ispis(korijen(144));

ispis(korijen(2));

ispis(korijen(0));
Output:

12
1.4142135623730951
0
ispis(korijen(-1));
Error: Square root cannot be calculated for negative numbers. Value -1 is invalid.

eNa

The eNa function returns Euler’s number e raised to the power of the provided broj

ispis(eNa(2));

ispis(eNa(-1));

ispis(eNa(0));
Output:

7.38905609893065
0.36787944117144233
1

ln

The ln function returns the natural logarithm of the provided broj.

ispis(ln(14));

ispis(ln(32));

ispis(ln(e));
Output:

2.6390573296152584
3.4657359027997265
1
ispis(ln(-1));
Error: Cannot calculate ln of -1.0: Value must be a positive number

log

The log function computes the logarithm of the value x to the given base b.

ispis(log(45, 4));

ispis(log(45, 2));

ispis(log(45, 5));

ispis(log(45, 1));
Output:

2.7459265481648374
5.491853096329675
2.3652123889719707
NaN

log10

The log10 function computes the common logarithm (base 10) of the provided broj.

ispis(log10(142));

ispis(log10(12));

ispis(log10(-50));
Output:

2.1522883443830563
1.0791812460476249
NaN

log2

The log2 function computes the binary logarithm (base 2) of the provided broj.

ispis(log2(142));

ispis(log2(12));

ispis(log2(-50));
Output:

7.149747119504682
3.5849625007211565
NaN

max

The max function returns the greater of the two provided broj values.

ispis(max(2, 3));

ispis(max(2, -3));

ispis(max(1, 1));

Output:

33
2
1

min

The min function returns the smaller of the two provided broj values.

ispis(min(2, 33));

ispis(min(-2, 33));

ispis(min(2, 2));

Output:

2
-2
2

zaokruzi

The zaokruzi function rounds the given value x towards the closest integer with ties rounded towards even integer.

ispis(zaokruzi(33.33333333));

ispis(zaokruzi(1.25));

ispis(zaokruzi(3.55));
Output:

33
1
4

kubniKorijen

The kubniKorijen function returns the cubic root of a provided broj.

ispis(kubniKorijen(144));

ispis(kubniKorijen(2));

ispis(kubniKorijen(0));
Output:

5.241482788417793
1.2599210498948732
0

uStepenima

The uStepenima function converts an angle measured in radians to an approximately equivalent angle measured in degrees.

"comment">// Convert π/2 radians to degrees
ispis(uStepenima(1.5707963267948966));
Output:

90