You're totally right. I don't know what my mind was thinking haha. And yes, I'm aware of the precision issue with floats. I was mostly just experimenting with the runtime, because I've only recently realized the iterative algorithm is way faster than the recursive one for fibonacci numbers.
Ah right. I had thought 100000 was small because I've read that Python can represent numbers up to around 10^308, but that was for floats. When I changed fib(n) to calculate with floats instead the runtime did indeed turn linear.
They're not huge numbers, I ran it in range(0, 100000, 10000). This was the plot I got
The rest of my code is just for clocking runtime and plotting, so there should be nothing special there, but here it is.
import time
from pylab import *
def fib(n):
...f0, f1, = 0, 1
...for i in...
So it's the adding of big numbers that's contributing to the overall complexity? That makes sense, but how do I quantify it? So far my understanding of determining complexity is merely by counting the number of operations.
def fib(n):
f0, f1, = 0, 1
for i in range(n - 1):
f0, f1 = f1, f0 + f1
return f1
It looks like it'd be linear, given there's only one loop, but when I plotted n against runtime, the relationship was quadratic, why?
I've just started programming with Python this summer, and I'm taking a course in computational physics this semester. I've been really enjoying it and programming in general, but I don't have much knowledge in computer science save for intro stuff (string/list methods, functions/classes...
My mechanics prof today said when setting GMm/r2 = ma, the canceling of the small m is actually a bit nuanced because you have to assume the gravitational mass is equal to the inertial mass (though it's supported by experiments). I'm so used to seeing mass as just mass so I'm having a bit of...
You'll want to study physics instead of engineering for sure then. EE does not go into the nuclear domain at all I believe, but they might have an energy domain. There is the nuclear engineering program, but my impression of them is that, beyond the fundamentals, they deal more with ME stuff...
Isaac Newton would've been Isaac Newton no matter what he studied.
Famous/genius academics didn't get there by asking how they can become famous or influential. They just did it because they had it in them. If there's an easy answer to "what should I study in order to become a great scientist"...
k being the one from the harmonic wave ψ(x,t) = Asin(kx - ωt) where k = 2π/λ
The way I see it right now, k is just defined this way to get the period of sin(x) to be λ by using sin(kx), so I wondered if there's something more to it. (Though I know it can be used as an vector to declare the...
Classical Mechanics I
Practical Physics I
Quantum Mechanics II
Ordinary Differential Equations
History/Philosophy: Science and Values
I'm also volunteering in a superconductivity lab, and thinking about a part time job...not sure if I'd kill myself if I do that.
Pretty much everyone in the physical sciences these days has to know programming. C++, fortran, matlab, and what have you. But what about the more core computer science concepts, like algorithms, data structure, numerical analysis, operating systems, etc.? How important are these to those...
(First post, hi everyone.)
I'm reading Griffith's textbook on intro to quantum mech right now. After establishing the following equation
$$\left\langle f(x) \right\rangle = \int f(x)p(x)\,dx$$
And thus
$$\left\langle x \right\rangle = \int x|\Psi|^2\,dx$$
He goes on to find...