Fork me on GitHub
#clojure-europe
<
2022-09-18
>
reefersleep09:09:38

Good morning!

reefersleep09:09:04

Trying to (re?)learn some maths. Having some fun implementing matrix multiplication in the REPL.

reefersleep09:09:58

I'm unsure if I ever really encountered matrix multiplication in my education. I still don't know exactly what I can model onto it.

reefersleep10:09:40

Which maths do you get good use of in your programming ventures?

val_waeselynck19:09:32

So, a couple of months ago I just got started at this new full-stack Clojure role, and since then I've found myself doing Gaussian Processes, Poisson Processes, statistical learning, elliptical geometry, multivariate calculus, and whatever linear algebra baggage comes with all that stuff, and not all that much Clojure. None of this was in the initial job description, so I guess you never know where the job might take you 😛

val_waeselynck19:09:15

But to be fair, this math stuff mostly originated from the domain (natural hazards modeling), it didn't have much to do with general programming.

val_waeselynck19:09:22

As for math to be used in general programming, relational algebra and basic predicates / propositional logic comes to mind.

val_waeselynck19:09:59

But I think what I use most in programming, although that's not explicit in my code, is the proficiency with very general and basic concepts like sets and functions. I find that functions tend to have a different role in math than in programming: rather than computational building blocks, they tend to represent various "perspectives" or "questions" or "reductions" on a given problem. I find myself using this sort of concept all the time to structure my programs and elucidate their essence.

reefersleep07:09:35

yeah, I’m just doing joe webprogramming. I doubt much advanced math is going to appear in this domain (on this project). I could try to inject it myself 😛

reefersleep07:09:53

Your notion of functions is interesting, and, I think, also embedded in thoughtful code writing in programmers who know nothing in particular in math.

lemontea15:09:42

@U06GS6P1N soooo that’s how little Hobbit ended up in Mordor!

val_waeselynck16:09:30

> Your notion of functions is interesting, and, I think, also embedded in thoughtful code writing in programmers who know nothing in particular in math. Sure. I find the math to provide a perspective which is useful, but by no means mandatory, and not equally useful to everyone. A mathematical perspective is wasted on some people, because it's not the best way for their brain to tackle the problem (just like Emacs is wasted on me).

reefersleep19:09:56

I've got a linguistic bachelor. In some ways, I think it aids my programming and communication around programming.

reefersleep19:09:26

So it's not all wasted, even if it didn't directly lead to anything

reefersleep10:09:55

My girlfriend thinks you have to be good at math to learn to program. I say no. Some aspects, like abstract thinking, might benefit you, but you don't need anything beyond the very basics (addition, subtraction, multiplication and division) for some things. I mean, you can get by even with addition and subtraction, depending on the situation. Maybe I'm wrong, though! Maybe I'm missing out on a lot of efficiency or more advanced programming that I could be doing, because I've neglected to educate myself in this field. What do you say?

pez10:09:20

Recently I had some use for matrix multiplication in particular when implementing a Linear Programming algorithm (Simplex), for a configuration optimizer I was working with. Less recently (like 30 years ago) I employed matrix multiplication when implementing 3D bezier curves in a PostScript application. So with some decades apart, I guess I have had use for it. 😃 Not that I learnt matrix multiplication in school. I only have senior high school schooling. To me these kind of things is something I study either because I need it for something or because I get curious about it.

reefersleep13:09:37

Sounds like a fun application!

reefersleep13:09:48

gotta love those swooping beziers

pez14:09:30

PostScript is a very fun language. Clojure is the first language since back then that brought me joy in similar measures.

reefersleep14:09:59

huh, it's concatenative

reefersleep14:09:49

wait, that doesn't mean what I thought it did

reefersleep14:09:09

I thought it meant it was similar to J and APL

reefersleep14:09:25

(which I've always wanted to try)

pez15:09:15

I'd say PostScript is more similar to LISP than J (which I had to look up) and APL. I don't know anything about those, though, so there might be resemblances.

pez15:09:02

It was a long time ago I programmed in PostScript, but as I recall it it is a bit like wrapping LISP inside out. Quite data oriented. Code is just data. You can push some data onto the stack and then just say that this data is a program. It's quite idiomatic PostScript to write self modifying programs.

pez15:09:48

If you've programmed a HP calculator, you can get an idea about one aspect of PostScript.

reefersleep07:09:33

Sounds fun! 😄

pez10:09:37

I should add that I was not the main developer in the Simplex implementation. I didn't know Clojure well enough to be able to pull it off. It was my main Clojure mentor who created most of the thing. I mentioned it in this thread, trying to encourage him to publish it, because it's a wonderful thing: https://clojureverse.org/t/writing-a-new-parser-for-the-prolin-library-using-instaparse/7028 But I needed to study the math involved quite a bit to be able to contribute in any meaningful way.

reefersleep13:09:14

That's the rub imo. I occasionally come upon articles that use mathematical notation to explain things that are probably not that complex, but it's impenetrable to me due to the language used - sometimes even when it's written out in prose and not mathematical notation.

reefersleep13:09:18

That's part of my motivation to learn and relearn 🙂

reefersleep13:09:42

I wanna be that kind of wizard, too. Or at least assistent regional wizard.

pez13:09:13

You're a wizard in my book already. Please keep following your curiosity!

reefersleep13:09:53

Funny that you mention simplex and bezier curves. I'm dabbling in generative art currently, using Perlin noise and bezier curves. Hoping to get a deeper understanding of Perlin and Simplex noise at some point, currently it's just a black box tool. Have been trying to gain an understanding of bezier curves, there are some great tutorials and videos out there that explain them conceptually. But generally I let libraries do the heavy lifting and only use bespoke math I don't have a library fn at hand 😄

reefersleep13:09:00

aww thanks ❤️

reefersleep13:09:35

Wait, are you talking about Simplex as in Simplex noise?

reefersleep07:09:22

Something something optimization, got it

reefersleep07:09:48

or maximization

pez07:09:39

We used it for maximization.

reefersleep07:09:02

I didn’t mean that in a derisive way, other than my lack of knowledge 🙂

reefersleep07:09:19

I’ve heard of linear programming before, but haven’t quite grokked it

pez07:09:29

Didn't take it like that! 😃

pez07:09:19

I can't say I have grokked it, either. But given a Linear Programming shaped problem it is a wonderful and efficient solution.

pez07:09:39

I think you very seldom need to implement Simplex. It's very good to know about that it exists, so you can look for library support. In our case, we needed to implement it in CLJC. That's when it gets mathy. 😃

reefersleep07:09:56

Ah. Was reconciling cljs and clj number types and mathematical operations difficult?

pez08:09:38

Not for our particular application. But I think this might have been part of why my colleague hesitated to publish it as a public library. If you only need the Clojure part of it, it could get an issue with some compromise around the precision. (Speculating here, this was years ago and I didn't know much about Clojure or ClojureScript.)

reefersleep20:09:52

:face_with_monocle:

lemontea15:09:53

@reefersleep funny that you’d talk about this topic - I am a math major… 👉👈

🧑‍🏫 1
lemontea15:09:38

… and I struggle to recall from my memory instances where “hard math” is critical to CS in a sufficiently “practical” context lol

reefersleep15:09:02

What's your business domain for your programming work?

lemontea15:09:11

day job (previously)? well e-commerce, logistic, etc, nothing out of the ordinary

lemontea15:09:20

yup. Actually, logistics have some operation research + combinatorial optimisation problems too

lemontea15:09:51

(not that there aren’t application…

lemontea15:09:00

… it’s just that most are rather “niche”)

lemontea15:09:32

(but it could be because (pure)-math itself is already sufficiently niche that anything it touches also become niche by association XD)

reefersleep15:09:44

graphics application and statistics are the only relevant domains that immediately come to my mind

👍 1
lemontea15:09:11

but if you insist on some example, here’s a “generic” one: • background: the 6 main area of pure maths are: number theory, algebra, geometry, analysis, discrete math; (foundations) • Some Graph algorithms/Graph Theory are fully pure math, but also rather CS’y. The line/difference b/w them can get blurry. • Foundation of math is heavily intertwined with CS. Logic - not “just” ordinary logic, but logic as a formal system, meta-logic, and non-standard logic systems are all important to Programming language theory. And then there’s Category Theory (just ask the static typing ppl - but don’t blame me if you get trapped in a lecture room for hours lol)…

lemontea15:09:34

… and if you are willing to go full hardcore, there’s Homotopy Type Theory (applying a combination of Algebraic Topology + Foundation of math)

lemontea15:09:10

… (example of non-standard logic: modal logic and temporal logic. Some academic research blah blah blah trying to reason rigorously about concurrency issue in your program, preferably in an automated manner blah blah blah lol)

reefersleep15:09:43

You're mentioning both things that I know I don't know and things that I didn't know existed 😅

lemontea15:09:34

Hope that helped. A nice thing about the latter type is that it immediately goes to the former type once you hear about it 😉

lemontea15:09:02

• number theory is “easy (to think of applications)” - crypto. Enough said 🙀

lemontea15:09:40

(concrete example: zk-snark and zero knowledge proof. Homomorphic encryption - uses some commutative algebra too)

lemontea15:09:57

• Algebra and geometry can be hard to think of examples. Some that I heard during my times in universities: Persistent homology, Information Geometry - both in ML/AI

lemontea15:09:16

• analysis: well, to be pedantic (because the entrance requirement to study analysis is to be pedantic) - technically every time you solve a differential equation with computer or that kinds of thing, some numerical algorithms are used which is backed up by pure math

lemontea15:09:24

but what do I really think? well, a bit tired today, but I can think of two points: • “Just programming” doesn’t require much math. But if you do a certain kind of “software engineering” where you need to invent a whole new class of technology, then math may give you the background to find a solution/design/algorithm faster • Pure mathematics have grown exponentially in the last 2 centuries. But since high school only get you to “early modern age”, and even undergrad degree doesn’t get you fully updated, most people don’t know how vast the frontier is

borkdude15:09:49

My wife is also a math major :-D

😍 2
lemontea15:09:55

you lucky guy! :face_with_cowboy_hat:

lread15:09:13

good+morning!

lemontea16:09:21

Very thick math book for reference/inspiration/when you have lots of $$ to spare (both are picked for illustrating the “exponential growth” aspect I mentioned above): https://press.princeton.edu/books/hardcover/9780691118802/the-princeton-companion-to-mathematics https://link.springer.com/book/10.1007/978-3-642-56478-9

reefersleep17:09:51

I think most of what you've mentioned is well beyond the scope I imagined getting into. But who knows, one thing might lead to another 🙂

reefersleep17:09:24

Right now, I'm sussing out basic geometry, the aforementioned matrices (with no idea what to use them for), and maybe I should revisit some very basic equational axioms to ensure a solid foundation

reefersleep17:09:56

Using geometry for graphics/art is very interesting to me, and whatever equations and matrices and whatnot that can aid that are, by nature of usefulness, also interesting. I think I'd have to have an unnaturally long life to really consider getting into pure mathematics - I've seen things that are interesting in their own right, but without an immediate application and without immortality, the interest/time ratio isn't good enough.

lemontea18:09:10

well, one does not simply walk into Mordor 😇

lemontea18:09:54

(sometimes, life has a way of making an unexpected turn for you - the best laid plan of man and mice, that kind of thing)

reefersleep07:09:00

Indeed. You’re enjoying your tea, and suddenly a company of dwarves descend upon your home.

reefersleep17:09:44

At least for now!

👌 1
val_waeselynck19:09:32

So, a couple of months ago I just got started at this new full-stack Clojure role, and since then I've found myself doing Gaussian Processes, Poisson Processes, statistical learning, elliptical geometry, multivariate calculus, and whatever linear algebra baggage comes with all that stuff, and not all that much Clojure. None of this was in the initial job description, so I guess you never know where the job might take you 😛

val_waeselynck19:09:15

But to be fair, this math stuff mostly originated from the domain (natural hazards modeling), it didn't have much to do with general programming.

val_waeselynck19:09:22

As for math to be used in general programming, relational algebra and basic predicates / propositional logic comes to mind.

val_waeselynck19:09:59

But I think what I use most in programming, although that's not explicit in my code, is the proficiency with very general and basic concepts like sets and functions. I find that functions tend to have a different role in math than in programming: rather than computational building blocks, they tend to represent various "perspectives" or "questions" or "reductions" on a given problem. I find myself using this sort of concept all the time to structure my programs and elucidate their essence.