David Majda
October 22, 2015
310

# Mathematics, Surprisingly

Do programmers need advanced mathematics? And what if they are designing and implementing a programming language? In the talk I will show where I needed mathematics in my work at Jut and how bad job I would have done without understanding it. You can think of this as a small contribution to a discussion about education of programmers and the role of mathematics and other theoretical subjects in it.

Presented at Rubyslava #52 (Data Science Edition).

October 22, 2015

## Transcript

1. MATHEMATICS
SURPRISINGLY
David Majda
Bratislava · October 22, 2015

2. INTRODUCTION

3. {
time: "2015-05-03T09:29:15.000Z"
space: "default",
source_type: "metric",
name: "response_time",
value: 134.675
}

reduce -every :5s: max(value) by host | @timechart;
keep time, value | @logger
)

reduce -every :5s: max(value) by host | @timechart;
keep time, value | @logger
)
@timechart
reduce
keep @logger

6. DEMO

7. LOGIC
ALGEBRA I
ALGEBRA II
GEOMETRY & PHYSICS

8. LOGIC

or (status = 404 and url !~ …)

or (status = 404 and url !~ …)

12. Conjunctive normal form

13. (a
1,1
∨ … ∨ a
1,m(1)
)

(a
n,1
∨ … ∨ a
n,m(n)
)

or (status = 404 and url !~ …)

15. read (status = 500 or status = 404)
and (status = 500 or url !~ …)

16. read (status = 500 or status = 404)
and (status = 500 or url !~ …)

17. ALGEBRA I

18. read … | reduce c = count(x)
s = sum(x)
m = max(x)

19. { c: 3, s: 6, m: 3 }
read … | reduce c = count(x)
s = sum(x)
m = max(x)
{ x: 1 }
{ x: 2 }
{ x: 3 }

20. { c: 2, s: 3, m: 2 }
read … | reduce c = count(x)
s = sum(x)
m = max(x)
{ x: 1 }
{ x: 2 }

21. { c: 1, s: 1, m: 1 }
read … | reduce c = count(x)
s = sum(x)
m = max(x)
{ x: 1 }

22. { c: ?, s: ?, m: ? }
read … | reduce c = count(x)
s = sum(x)
m = max(x)
(nothing)

23. { c: 0, s: ?, m: ? }
read … | reduce c = count(x)
s = sum(x)
m = max(x)
(nothing)

24. { c: 0, s: ?, m: ? }
read … | reduce c = count(x)
s = sum(x)
m = max(x)
(nothing)

25. { c: 0, s: 0, m: ? }
read … | reduce c = count(x)
s = sum(x)
m = max(x)
(nothing)

26. { c: 0, s: 0, m: ? }
read … | reduce c = count(x)
s = sum(x)
m = max(x)
(nothing)

27. { c: 0, s: 0, m: undefined }
read … | reduce c = count(x)
s = sum(x)
m = max(x)
(nothing)

28. { c: 0, s: 0, m: undefined }
read … | reduce c = count(x)
s = sum(x)
m = max(x)
(nothing)

29. Identity element

30. e: ∀a(e ⊕ a = a ⊕ e = a)

31. { c: 0, s: 0, m: -Infinity }
read … | reduce c = count(x)
s = sum(x)
m = max(x)
(nothing)

32. ALGEBRA II

33. read … value > 0.95
| reduce c = count()

34. Elasticsearch
Cassandra
| reduce c = count()

35. Elasticsearch
Cassandra
| reduce c = count()

36. Associativity

37. (a ⊕ b) ⊕ c = a ⊕ (b ⊕ c)

38. count
count_unique
sum
avg
min
max
first
last
pluck
percentile
sigma

39. count
count_unique
sum
avg
min
max
first
last
pluck
percentile
sigma

40. Monoid

41. Set S, operation ⊕ : S ⨉ S → S
1. ⊕ is associative on elements of S
2. S contains identity element under ⊕

42. GEOMETRY
&
PHYSICS

44. Moment
Duration
:2015-04-01T20:05:27.034:
:now:
:3 weeks and 1 day ago:
:20:05:27.034:
:3s:
:1 hour and 23 minutes:

45. read time < :2015-04-01: - :1 day:

46. N * D → D
D * N → D
N / D → N
D / N → D
D % N → D
M + D → M
D + M → M
D + D → D
M - M → D
M - D → M
D - D → D

47. Affine space

48. m
1
m
2
m
2
t
d
1
d
2

49. N * D → D
D * N → D
N / D → N
D / N → D
D % N → D
M + D → M
D + M → M
D + D → D
M - M → D
M - D → M
D - D → D

50. N * D → D
D * N → D
N / D → N
D / N → D
D % N → D
M + D → M
D + M → M
D + D → D
M - M → D
M - D → M
D - D → D

51. N * D → D
D * N → D
N / D → N
D / N → D
D % N → D
M + D → M
D + M → M
D + D → D
M - M → D
M - D → M
D - D → D

52. N * D → D
D * N → D
N / D → N
D / N → D
D % N → D
M + D → M
D + M → M
D + D → D
M - M → D
M - D → M
D - D → D

53. N * D → D
D * N → D
N / D → N
D / N → D
D % N → D
M + D → M
D + M → M
D + D → D
M - M → D
M - D → M
D - D → D

54. Dimensional analysis

55. v = s / t
η = P
out
/ P
in

56. N * D → D
D * N → D
N / D → N
D / N → D
D % N → D
M + D → M
D + M → M
D + D → D
M - M → D
M - D → M
D - D → D

57. N * D → D
D * N → D
N / D → N
D / N → D
D % N → D
M + D → M
D + M → M
D + D → D
M - M → D
M - D → M
D - D → D

58. N * D → D
D * N → D
D / D → N
D / N → D
D % N → D
M + D → M
D + M → M
D + D → D
M - M → D
M - D → M
D - D → D

59. N * D → D
D * N → D
D / D → N
D / N → D
D % N → D
M + D → M
D + M → M
D + D → D
M - M → D
M - D → M
D - D → D

60. N * D → D
D * N → D
D / D → N
D / N → D
D % N → D
M + D → M
D + M → M
D + D → D
M - M → D
M - D → M
D - D → D

61. N * D → D
D * N → D
D / D → N
D / N → D
D % D → D
M + D → M
D + M → M
D + D → D
M - M → D
M - D → M
D - D → D

62. CONCLUSION

63. QUESTIONS?

64. WHERE NEXT?
http://en.wikipedia.org/wiki/Conjunctive_normal_form
http://en.wikipedia.org/wiki/Disjunctive_normal_form
http://en.wikipedia.org/wiki/Identity_element
http://en.wikipedia.org/wiki/Associative_property
http://en.wikipedia.org/wiki/Monoid
http://en.wikipedia.org/wiki/Affine_space
http://en.wikipedia.org/wiki/Dimensional_analysis

65. IMAGE CREDITS
http://commons.wikimedia.org/wiki/File:Torus.png