Six years ago I was laid off from an engineering job, and I decided it was time, after 16 years in the field, to review some of the fundamentals that I had forgotten in the intervening time. One of my co-workers, before I left, had been working with his daughter on Algebra using the site Purple Math. I also read James Gleick’s book Chaos at that time, and that got me interested in doing a little exploring.
I started by reviewing geometry, algebra, calculus, and differential equations using the The Easy Way series. I checked them out of the library and this led me to reading some of the other books on the shelves there. I came to realize that there was a whole world of mathematics that I really had no idea existed, especially after I made the attempt to read a math paper from arXiv and realized that I had no idea what the first paragraph was saying. Hilbert Spaces? Riemannian Geometry? Topological forms? Rings? Lie Groups? What were these things? More importantly, why had we not studied those in school? They were interesting, much more interesting, than the calculations that I had to master in high school and college.
In any case, I’ve found that math is also important in programming, both for solving problems like the permutations program that I covered recently, as well as others. It’s also important for designing algorithms, and so on. Logic is a part of mathematics and is the basis for all computer programs.
So what I’d like to do in this occasional series is look at some of the concepts I come across in the course of learning to program. I figure the first couple will look at permutations, and some basic set theory. I will also look at the trials and tribulations I am having of learning to put math equations in LaTeX for my blog posts!
I’m a little late on this one – Usually I put it up in January, but never late than never!
It seems like I read less this year than in previous years, but a lot of what I was doing was working through coding exercises. Also, we moved in the middle of the year, and a whole lot of bad stuff happened too. At one point I was working two jobs. So, life happening plus less time to read combined with working through coding textbooks meant this year was anemic when it came to books. Still, I hope you find some value in the list below. There are books on history, international affairs, religion, mathematics, epidemiology, and of course, many fiction books.
Today started out frustrating, although it wasn’t a bad day. It took me three hours to figure out the trapezoidal method of integration, because none of the descriptions I could find were very clear. I coded it up in Python – The annoying thing being, that I’m learning Python concurrently. This is all for a class in Nonlinear Dynamics, one of the big tools for complexity science. The next thing I need to do is learn to plot the results; for now, I am copy-pasting into Excel and letting it create a chart. Sadly, such tutorials as there are on the web do not allow me to get up and running quickly for plotting the graphs I need. I’ll just add it to the list…
I also read through a chapter of SQL (database language) on scripts. For our semester project, I have decided to create a fictitious library that will use my not-fictitious collection of books. For this week’s assignment, we need to create a script that is logical for our business; I’m pondering what that might be for my library.
Finally, reading. I’m working my way through Samantha Power‘s book on Genocide. It’s painful reading, mainly because of the inaction of the United States on the subject over the years. I don’t know what the answer is; I’m not a huge fan of R2P (Responsibility to Protect). But inaction doesn’t seem to be a good answer either.
That’s all for today. Below is the Python code I wrote for the Trapezoidal method for a Simple Harmonic Oscillator.
g = input(“Enter X Sub 0: “)
Xsub0 = float(g)
h = input(“Enter V sub 0: “)
Vsub0 = float(h)
B = input(“Enter Friction (B): “)
friction = float(B)
g = input(“Enter Gravity (g): “)
gravity = float(g)
m = input(“Enter Mass (m): “)
mass = float(m)
k = input(“Enter Spring Constant (K): “)
KConstant = int(k)
t = input(“Enter time step (del-t): “)
deltaT = float(t)
e = input(“Enter end time: “)
endTime = float(e)
i = 0.0
Xnow = Xsub0
Vnow = Vsub0
while i <= endTime:
vprime = gravity – ((friction/mass) * Vnow) – ((KConstant/mass) * Xnow)
vODE = vprime
xODE = Vnow
vectorX = deltaT * xODE
vectorV = deltaT * vODE
XNew = Xnow + vectorX
VNew = Vnow + vectorV
Xone = XNew
Vone = VNew
vprime = gravity – ((friction/mass) * VNew) – ((KConstant/mass) * XNew)
vODE2 = vprime
xODE2 = VNew
vectorX = (deltaT * .5) * (xODE + xODE2)
vectorV = (deltaT * .5) * (vODE + vODE2)
XNew = Xnow + vectorX
VNew = Vnow + vectorV
Xnow = XNew
Vnow = VNew
###print(“X at ” + str(i) + ” is ” + str(XNew) + “\t\t\t” + “V at ” + str(i) + ” is ” + str(VNew))
print(str(XNew) + “\t\t\t” + str(VNew))
i += deltaT