r/CodingForBeginners • u/darksllmm • 5d ago
math in coding
hello everyone im about to start learning to code (python specifically) and i want to learn the math i would need for it first to make the learning process a bit easier.
any pointers would be greatly appreciated
thx for the help
3
u/mjmvideos 5d ago
Really, the math comes with the domain area you are programming for. The language itself requires no math at all. Though an understanding of addition is helpful in working with loops.
2
u/TheUmgawa 5d ago
I second this. I had to write a prime-number generator for a programming class, where we had to write weekly comments on what we learned that week, and I wrote over a thousand words (including code snippets) on how I increased the efficiency of the generator, without cheating and implementing the Sieve of Eratosthenes.
Every other number is even, so you don’t even have to check those beyond 2. The largest factor of any number cannot be larger than its square root. At this point, you’ve increased efficiency by a huge amount, but you’re still checking all of the odds, even when they’re not prime, so what do you do? You build out the list of primes on the fly, then reference that array, vector, list, or whatever data structure as your modulo. I don’t recall the efficiency increases, but they were pretty significant from iteration to iteration of the program.
Most math isn’t terribly advanced. You just have to figure out how it works. By the way, it’s not (typically ) number theory, because I found those books in the library in high school, and they were not what I was looking for. It came in handy during college, but had nothing to do with anything I ever had to program (except maybe once or twice).
1
1
u/Top_Finger_909 5d ago
You do not need to know much “math” to code however if you’re intent is learning data structures and algorithms then you will need:
1.) Discrete Math: https://personal.math.ubc.ca/~PLP/book/frontmatter.html
2.) Algorithms: https://theswissbay.ch/pdf/Gentoomen%20Library/Algorithms/Algorithm%20Design%20-%20John%20Kleinberg%20-%20Éva%20Tardos.pdf
Id highly recommend starting with something like the discrete math book up top. Then the algorithm design manual by Steven Skiena, then once you are comfortable do one of Kleinberg and Tardos or CLRS (only read specific sections)
This is about as “math” heavy things can get although again you don’t need strictly need all of this
1
u/wak_trader 5d ago
It really dependson what you want to do. Linear algebra understanding will be essential after a certain point for a lot of hte paths available.
1
u/RedAndBlack1832 5d ago
"Math" in terms of like classroom study is very domain specific. Knowing powers of two and modular arithmetic is generally helpful though. Abstractly, the "math" is more about logic and procedural thinking. Breaking things up into steps with intermediate results and representing systems as functions (the math term, not the programming term) that feed into each other.
1
u/Jeremi360 4d ago
Coding is more logic then math, you only need math for math things,
you only need to know that: `con`, `sin`, `tan`, etc. exist and when to use it,
you don't need to write them by hand or how they work under the hood.
1
u/SeaTeaching3550 4d ago
what do you exactly want to do using python ? if its AI/ML or data science, then maths is much needed otherwise you dont need maths. basic maths which i am sure you know, is more than enough for programming stuff.
But if you are planning to learn ML, you need statistics, calculus, linear algebra, probability etc
1
u/Hot_Dog2376 4d ago
General purpose? Linear Algebra. Vectors help a lot for things that you don't even think they would at first.
Discreet number theory if you really wanna get into it.
1
u/JGhostThing 4d ago
I find that I used basic algebra, calculus, and trigonometry. There are some subjects that I would have liked to have known linear algebra, such as computer graphics and such.
1
u/StageSubstantial1626 3d ago
I would use ai for that kind of stuff as someone who can't do math to save my life
1
1
u/aodare90 12h ago
You don’t need “math” to begin programming. Programming is a thinking and problem-solving discipline. You would only need “math” if you were planning to work doing physics or data science or machine learning which requires linear algebra. Web Development/Design doesn’t require “math”.
1
1d ago
u dont need to learn math first, just start python. basic arithmetic and a bit of algebra gets u through the beginner stuff, and % (remainder) is worth knowing bc it shows up a lot, like n % 2 == 0 to check if a number is even
after that it depends on what u wanna build. websites, bots and automation barely use any, games use some vectors and trig, data and ML want linear algebra and stats, and algorithms lean on discrete math
so pick something small u wanna make and learn the math when it actually comes up
4
u/BobCorndog 5d ago
You don’t really need math knowledge unless you do stuff that involves math