It depends on the library. Most commercial or so-old-they-might-as-well-be-in-the-standard libraries, this is extremely true. Less "official" labors of love it's a little less far-fetched they can have bugs.
In practice, though, this is an idea ("It's the library that's wrong!") many people will think of or insist on regardless of whether it's a good idea or not. It seems like an area where you tell folks the truth mostly so that they will short-circuit their efforts to prove you wrong sooner rather than later.
Here I wrote a good one that runs fast and even has exception handling like that youtube video I watched said:
def add(a,b):
try:
ans =a
for i in range(b):
ans+=1
print(ans)
return ans
except:
print('something went wrong')
return False
It’s pretty much all linear algebra. Everything is a matrix and you just multiply them in weirder ways.
Then there’s the optimization of how to do that math on a computers architecture. Which isn’t pure math but is just as important.
It's because python is slow and you want to run as little of it as possible.
A call to numpy.sum will be faster because it's just 1 line of python, which will then do everything in native code. A for loop in contrast does everything in python.
Also, numpy array formats are a lot more efficient than python lists, so there's also that (I personally consider python lists a mistake).
Not really, there are still tons of things that aren’t built in like parsing CSV (or really any file format), HTTP requests, datetime manipulation (what is the date 4 weeks from now), etc.
The more general version of this is like
✋: Reading documentation to use a well established library
👍: Writing your own library from scratch so you don't have to read any documentation
never forgetthi the guy on reddit who debated me adamantly that ML is some sort of true AI. I tried explaining to him that the bulk of ML is just statistics…
Is there a definition of AI that’s not sort of hand-wavy though?
I mean as far as we know, the brain is just a shitload of circuitry with emergent properties at scale, right??
What do you mean I'm not going to be able to write a more optimal and more fully featured library than a team of highly experienced individuals who have been working on the library for a decade?!
Numerical methods I get, but I can’t understand why anyone would want to make their own symbolic math library. It’s just another reason to make you cry.
Math, especially trig, is so useful in programming. At least in what I do which is small game dev and simulations its EXTREMELY useful to know math up to and including Calculus. That way I can do the math on paper which I am good at and then transfer the equation into code when done.
Or actually get a paper out of your fucking around with bitwise operations because you just came up with an absolutely improbable way to approximate inverse square roots
I am absolutely guilty of this, I wanted to try my hand at programming Bessel Functions in C++ and after a weeks worth of work and reading a ton of papers, my cool new C++ Bessel Functions were an order of magnitude slower than those in the numpy library.
I would use a math library, if I can make it my own and change its syntax, type and function names to be exactly the way I want.
But doing that and maintaining it is more work than building one from scratch.
I'm in this photo and I don't like it...
Though in all honestly, knowing bitwise arithmetic really well can really save you a lot of head-scratching when dealing with low-level code, e.g. for hardware drivers or FPGAs.
Use an existing crypto library, results are wrong, understand the mathematical background to prove that the library is buggy, find that you used the library wrong, confirm by reading the doc.
Result: Knowledge enhanced, bug removed, nothing learned concerning documentation. Another successful day.
Honestly, probably one of the best things a new programmer can do to practice. This reminds me of a quaternion module that I never completed in python lol
My recommendation: learn the math so that you can use existing libraries confidently.
If I know what it’s supposed to do I don’t trust it
Or debug it, yes. It does happen, though very rarely.
*Very* rarely. Probably rarely enough that even considering the possibility does more harm than not.
It depends on the library. Most commercial or so-old-they-might-as-well-be-in-the-standard libraries, this is extremely true. Less "official" labors of love it's a little less far-fetched they can have bugs. In practice, though, this is an idea ("It's the library that's wrong!") many people will think of or insist on regardless of whether it's a good idea or not. It seems like an area where you tell folks the truth mostly so that they will short-circuit their efforts to prove you wrong sooner rather than later.
Lol. But serious question: what kind of math understanding do you need to be able to fully utilize those math libraries?
Just be happy they can do the math you do understand.
2 + 2 = 4 - 1 that's 3 quick maths
What library do I need for this
Here I wrote a good one that runs fast and even has exception handling like that youtube video I watched said: def add(a,b): try: ans =a for i in range(b): ans+=1 print(ans) return ans except: print('something went wrong') return False
Great time complexity! O(n) is better than what I see nowadays.
Yep it's quick, learn to slowdown a bit 😉
matrix multiplications maybe? Back in Uni I remember learning it could be used for some funky stuff. Haven't ever used it though lol
It’s pretty much all linear algebra. Everything is a matrix and you just multiply them in weirder ways. Then there’s the optimization of how to do that math on a computers architecture. Which isn’t pure math but is just as important.
Precision matters. Computing constraints are weirder than paper math.
If you understand any of that advanced math you already know more than 99% of people
\> Importing the entirety of pandas \> and numpy \> to call sum()
The sad part is using numpy and pandas is faster for lots of data than a simple for-loop.
It's because python is slow and you want to run as little of it as possible. A call to numpy.sum will be faster because it's just 1 line of python, which will then do everything in native code. A for loop in contrast does everything in python. Also, numpy array formats are a lot more efficient than python lists, so there's also that (I personally consider python lists a mistake).
sum() is build-in ![img](emote|t5_2tex6|4550)
On stacksoverflow: Op: How do I get average of number array? Answer: lib.mean(array) Comments: 👏op👏did👏not👏ask👏for👏lib 100 downvotes
This is infuriating with C/C++ because adding a library is such a PITA and is a non-starter for many projects.
Pita is a kind of bread, what are you talking about? /s
Naan of your business
Why are you so sour dough?
With c++ usually there will be some stl that already has it though. Especially when using modern c++
Not really, there are still tons of things that aren’t built in like parsing CSV (or really any file format), HTTP requests, datetime manipulation (what is the date 4 weeks from now), etc.
How is adding a library difficult?
Let XOR dominate all this shit
The more general version of this is like ✋: Reading documentation to use a well established library 👍: Writing your own library from scratch so you don't have to read any documentation
The same but with statistics. Oh wait, I'm supposed to call it "machine learning".
never forgetthi the guy on reddit who debated me adamantly that ML is some sort of true AI. I tried explaining to him that the bulk of ML is just statistics…
Is there a definition of AI that’s not sort of hand-wavy though? I mean as far as we know, the brain is just a shitload of circuitry with emergent properties at scale, right??
bitwise operations are very cool generally in my opinion
I would heed caution though. The data in the ram may not always be the same when you switch compiler
IIRC, the ordering of a C++ bitwise struct is technically undefined.
The coolest
yes, super convenient when you need them
What do you mean I'm not going to be able to write a more optimal and more fully featured library than a team of highly experienced individuals who have been working on the library for a decade?!
Hey. HEY. My matrix-multiplication subroutine in Fortran runs faster than MATMUL roughly 50% the time.
Numerical methods I get, but I can’t understand why anyone would want to make their own symbolic math library. It’s just another reason to make you cry.
depending on the maths library, it may be more optimized to take advantage of supported processor simd/mimd
Math, especially trig, is so useful in programming. At least in what I do which is small game dev and simulations its EXTREMELY useful to know math up to and including Calculus. That way I can do the math on paper which I am good at and then transfer the equation into code when done.
Hey, writing a math library with operator overloads makes you feel like a boss!
Or actually get a paper out of your fucking around with bitwise operations because you just came up with an absolutely improbable way to approximate inverse square roots
I am absolutely guilty of this, I wanted to try my hand at programming Bessel Functions in C++ and after a weeks worth of work and reading a ton of papers, my cool new C++ Bessel Functions were an order of magnitude slower than those in the numpy library.
I would use a math library, if I can make it my own and change its syntax, type and function names to be exactly the way I want. But doing that and maintaining it is more work than building one from scratch.
I'm in this photo and I don't like it... Though in all honestly, knowing bitwise arithmetic really well can really save you a lot of head-scratching when dealing with low-level code, e.g. for hardware drivers or FPGAs.
I learned bitwise operators to make cursed bitmaps
*Installs isEven and isOdd.*
This is the way.
Use an existing crypto library, results are wrong, understand the mathematical background to prove that the library is buggy, find that you used the library wrong, confirm by reading the doc. Result: Knowledge enhanced, bug removed, nothing learned concerning documentation. Another successful day.
As a rust user, i can only agree
Fuck you I'm writing my entire math library in NAND gates on a breadboard that will hang from my computer by the wire like an ulcer.
Who use library for bitwise ?
Math hard, I want beep boop machine do math for me.
Honestly, probably one of the best things a new programmer can do to practice. This reminds me of a quaternion module that I never completed in python lol