>>11498080>Are there mathematical methods to better design algorithms for programming?Yes, it's called studying algorithms, graph theory, combinatorics, linear algebra, optimization theory,etc. MIT opencourseware has good introductory materials. Here's a good primer to optimization
https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-253-convex-analysis-and-optimization-spring-2012/Use Diestel and Bollobas for graph theory. Use any proof based linear algebra text like friedman or axler. Use any introductory combinatorics book and then Lovasz's Combinatorial Problems and Exercises. For algorithms, CLRS, Sedgewick, Papadimitriou, etc. are good. This is also good once you've gotten a handle on things
https://www.springer.com/gp/book/9783540441342>I'm always unsure if my algorithms are optimal or what notoptimal in regards to what? Complexity theory studies the difficulty of problems, so you have to give a few examples here that we could easily verify
>The only metric I go by, is how short the code is.this is a really shitty metric. The shortest, most straightforward code to computer a fibonacci number is the straight recursive definition, but it takes exponential time. You can use dynamic programming to make it linear time and constant space. You can use matrix exponentiation or clever doubling to make it logarithmic time and constant space. The implementation does not give you 1-1 insight into the time complexity
>Yes, this is a /sci/ questions because I'm asking for the mathematics.if you want to learn how to write algorithms properly, it's going to take you learning a lot more mathematics. Exactly what is your background?