Math is beautiful, Math is ugly

Photo by Roman Mager on Unsplash

My discrete math class has allowed me to see math in a new way. Some days when I am doing homework, I think that math is beautiful — it makes so much sense and it fits together in such a way that is akin to beauty. Then, there are other days when math is truly ugly — when things make no sense at all, there appears to be no pattern, no logic, and no reason (at least none that make sense to me.)

Today, math is both beautiful and ugly. One set of questions involves finding a ‘simple’ formula for the first 10 terms of a given sequence. For one question, I looked at the numbers, and came up with a formula. I decided to write a python function to test it, and thankfully, it worked! Then, I decided to look at the official answer, and low and behold there is a completely different formula. So, I wrote another python function to test the official answer, and it produces the same results as my solution.

I started thinking a bit more  about it. The book solution is: 3n – 2 and the input into this function is the numbers 1-10. My solution is 3*n + 4, and the input into this function is the sequence given in the problem: 1, 7, 25, 79, 241, 727, 2185, 6559, 19681, 59047. My solution does not produce the initial element in the sequence (1), but it gives the desired result — it provides a way to figure out which number comes next. The book solution gives a more complete formula, in that any number n can be plugged in, rather than my solution which requires plugging in the prior number in the sequence. I am sure more “mathy” people would have more ideas (and comments) about this, but for me, I just like solving problems and seeing other solutions, and how / why a solution works and which solution may be better (or worse) depending upon what is needed. Lesson learned!

Essentially, I am using my math class to aid with my study of programming. I am writing short functions in python3 to determine if I have the correct solution, but this is also helping me to learn  python3, since I learned python 2.7 in school. In addition, I am using an IDE, PyCharm, and I have connected my GitHub to PyCharm, so my PyCharm and GitHub skills are improving. I am also learning how to use the Sympy library, which is currently my favorite python library! Why bother figuring out summations, when a few lines of code using Sympy will solve it? (My favorite line of code from today is: x.doit() — shouldn’t all function calls look like this?)

Comments are closed.

Blog at

Up ↑