Quick recap: I’m going through and redoing many of my physics videos. The idea is to put together a cohesive playlist that would work through the full physics course. I’m using the approach that skips over some of the more tedious topics—that’s why I’m using the “Just Enough Physics” title (yes, same as my ebook).
Well, I’ve got enough stuff for chapter 1. Here they are. Let me know if you think something should be added.
Constant Velocity in 1D
Example with Constant Velocity
Introduction to Numerical Calculations for Constant Velocity
It’s a tradition. At the end of the year, I like to post “top” stuff. Here are my best graphs. I’m only going to share graphs that I created with Plot.ly—although there are some other ones out there. So, maybe I should say “best plot.ly graphs of 2019”.
Oh, you haven’t used plot.y? That’s OK. Plotly, is an online graphing platform. It’s pretty nice. The thing I really like is that you can create some data in python (with Glowscript) and send it over to plotly for beautification.
One last thing. I don’t yet know how many “best” graphs I have—I haven’t looked yet. Also, these are in no particular order.
What ball is the best to catch with during free fall?
So, by plotting twice the height by time squared, the slope of the line would give the vertical acceleration. In the graph above, the green line is for an acceleration of 9.8 m/s^2 (the value on Earth) and the red line is the average for all the Jedi. Notice that Yoda has a greater acceleration. I think that’s cool.
I always enjoy this course. The students are both diverse and great. They are at LEAST in Calc-I so that means they can probably do some algebra stuff. There are a good number of students that are in even more advanced math classes like Differential Equations and stuff. Oh, and it’s a great chance to get to know the new physics and chemistry majors.
The class isn’t too big (mine started around 30) so that it’s fairly easy to memorize names.
Maybe the best part of the class is watching student videos. OK, I really don’t like watching videos—it can get kind of boring. But I LOVE seeing students make terrible videos and then get better and start figuring things out. It’s awesome when students have never made a video and are afraid to do it, but then really get into it.
Students eventually figure out that I’m not just assessing their videos, but they are learning by making the videos.
One other thing I liked—I always like it: speed dating physics problem solving. Here is a twitter thread on speed dating (from another class).
Also, I did assign and collect homework. I didn’t really grade it (I gave them a score), but it’s like free points and maybe it helps them practice.
One last “good”. I put together this video tutorial on numerical calculations that looks at an object falling on the surface of the moon. I think it’s pretty good. Not sure how much the students used it though.
Yes, there was some bad stuff. Sometimes I felt like students were just sitting there. Even when I was doing interactive activities, they had this blank stare (it seemed). Maybe it was the class time (9:30 AM)—although that doesn’t seem too early. I really don’t know what the problem was. For the most part they were fine.
Another big problem—speed dating. Oh, I get it. Students don’t want to participate. They want to just sit there and take in the fire hose of learning (they think that works). But in the end, most of them seem to get some positive things out of the speed dating. But the room was not super great for this. It’s a standard lecture hall—so I didn’t really have places to put boards. I tried using very small boards, but it just wasn’t perfect.
One final problem—a good number of student just never seemed to fully grasp numerical calculations.
Here are some ideas for the future.
Mounted white boards. If I have to be in that lecture hall, I want to find some ways to put boards somewhere around on the walls.
Plickers. I’m ditching the TurningPoint clickers. I’m tired of constant updates that bork the system. I get it—they want me to upgrade. Not upgrading again. Oh, also with Plickers it shows the student name over their head when they vote.
More in-class stuff. More group problem solving. More activities. More focus on numerical calculations.
I should show the students more of the awesome physics (like stuff from my blog). I don’t do this enough because I get so busy with getting through different topics—but I think the students really like these things. Who cares anyway, it’s the stuff that I love.
Subtitle: “You don’t really understand something until you model it”
Here is the video. It’s great. Watch it.
The basic idea is to predict the path of water that is shot from a spinning sprinkler. In the first case, the water is shot straight out of the spinning pipe. The second case is a little bit trickier with the water shot towards the center of the sprinkler. OK, it’s not actually a sprinkler.
Of course, once a drop of water leaves the sprinkler, it will only have the gravitational force acting on it. So, if you view this from the top—a drop of water should travel in a straight line with a constant velocity. But there is a problem that makes this difficult to predict. It’s that we don’t see the path of one drop of water, we see the path of a water stream.
A water stream is a collection of water drops. Even though one drop might travel in a straight line, the next drop will be “launched” at a different location with a different velocity. This makes it look weird.
OK, so let’s get to a model. I’m going to go over the steps to build this model in VPython.
Build a bar
Don’t try to do everything at once. Let’s just make a spinning bar—I’ll add water balls later. Here is what that spinning bar looks like.
Let me go over some of the important parts of this code.
The bar is an object of type “box”—this is a prebuilt object in VPython. It has two important attributes. The position (pos) is the location of the center of the box. The size is the vector with length, width, and height.
I added a ball so you can see the center (it’s not needed).
The variable “omega” is the angular velocity of the rotation. You can change this if you like.
The variable “theta” is the angular position of the bar—this is used for something later.
In the loop, the rate(100) tells the code to not do any more than 100 loops per second. Since I have a time step of 0.01 seconds, this means 100 loop would take one second—it would run in “real time”.
Don’t worry about line 16 (update theta)—at least not for now.
Line 18 is the important part. There is a rotate function in Vpython. You need to pick the angle (in this case it’s dtheta which is the angular velocity times the time step), the axis of rotation (the z-axis) and the origin of rotation (the origin).
But it works.
Add a single water
The next step is to add a single ball of water to the end of the sprinkler bar. It’s not going to do anything except to “ride around”. Here’s what that looks like. It’s really the same thing except with that ball of water.
GlowScript 2.9 VPython
#Length of sprinkler - just leave this
cent=sphere(pos=vector(0,0,0), radius=0.03*L, color=color.red)
#CHANGE THIS - rotation rate of sprinkler
#CHANGE THIS to -1 to make balls shoot IN
#this is just a spacer to make the scene look nice
tint=0 #this is the "clock" for shooting water
#CHANGE THIS - this is the water ball production rate
f=15 #water per second rate that balls are made
water=water+[sphere(pos=r,radius=0.04*L, color=color.cyan, v=(-1*cross(r,vector(0,0,omega))+a*vwater*r.hat),
water2=water2 +[sphere(pos=r2,radius=0.04*L, color=color.cyan, v=(-1*cross(r2,vector(0,0,omega))+a*vwater*r2.hat),
for ball in water:
for ball2 in water2:
This is what the output looks like. Actually, this is an animation for the case of the water shooting inward (since I already had the gif).
Now for some comments on the code.
When the water ball gets a certain distance away (I think I set it to 3*L), I change the water ball velocity to vector(0,0,0) and then I make it invisible. Otherwise the view would just keep expanding and it would look weird.
I don’t have any other important comments, but I can’t have a one bullet list.
I’m way behind on this one. My plan was to write up something when this question came up in the summer section of algebra-based physics. It was a great question and deserved a full answer. Also, I wanted to make this a tutorial on trinket.io—but maybe I will do that after I write about it here.
So, here’s how it goes. We start off the semester calculating the electric field due to a point charge and then due to multiple point charges (you know—like 2). After that we get into the electric potential difference. Both the potential and the field follow the superposition principle. If you calculate the value due to two charges individually, you can add these together to get the total field or potential.
But there is a big difference. The electric potential difference is a scalar value where as the electric field is a vector. That means that when using the superposition with electric fields, you have to add vectors. Students would prefer to just add scalars—I’m mean, that seems obvious. Does that means that you could just find the electric potential difference for some set of point charges and then use that potential to find the electric field? Yup. You can. And we will.
Let me start with the definition of the electric potential difference. Since it’s really just based on the work done by a conservative force (the electric field), this looks a lot like the definition of work.
Yes, that’s an integral. Yes, I know I said this was for an algebra-based course. But you can’t deny the truth. The “a” and “b” on the limits of integration are the starting and ending points—because remember, it’s really an integral. Also, the “dr” is in the direction of the path from a to b. It doesn’t technically have to be a straight line.
What about an algebra-based course? Really, there are only two options. The most common approach gives the following two equations for electric potential.
The first expression is the electric potential of a point charge with respect to infinity (so the starting point for the integral is an infinite distance away). The second expression is the change in electric potential due to a constant electric field when there is an angle between the field and the displacement.
Oh wait! I forgot to list the value of k. This is the Coulomb constant.
Students can understand the second expression because it’s pretty much the same as the definition of work (for a constant force). The first equation is mostly magic. The one way you can show students where it comes from is to do a numerical calculation of the electric potential difference since they can’t integrate. Did I write about that before? I feel like I did.
Ok, that’s a good start. Now for a problem.
Electric potential due to two point charges
Suppose I have two charges that are both located on the x-axis. Charge 1 is at the origin with a charge of 6 nC. Charge 2 is at x = 0.02 meters with a charge of -2 nC. Here’s a diagram—just for fun.
Let’s start off with the electric potential—as a warm up. What is the value of the electric potential (with respect to infinity) at the location of x = 0.02 meters? Using the equation above for the electric potential due to a point charge, I need to find the potential due to point 1 and then the potential due to point 2—then just add them together (superposition).
First for point 1.
Now for point 2.
This gives a total electric potential:
Finding the Electric Field
Now to find the electric field at that same point. I don’t know how to say this in a nice way, so I will just say it. Since the electric potential is calculated based on an integral of the electric field, the electric field would be an anti-integral. Yes, this means it’s a derivative. But wait! The electric field is a vector and the electric potential is a scalar? How do you get a vector from a scalar? Well, in short—it looks like this.
That upside delta symbol is the del operator. It also looks like this:
Yes, those are partial derivatives. Sorry about that. But you do get a vector in the end. But how can we do this without taking a derivative? The answer is a numerical derivative. Here’s how it works.
Suppose I find the electric potential at three points on the x-axis. The first point is where I want to calculate the electric field. I will call this . The next point is going to be a little bit higher on the x-axis at a location of . The final point will be a little bit lower on the x-axis at . Maybe this diagram will help.
When I take these two end points (not the middle one), I can find the slope. That means the x-component of the electric field will be:
Let’s do this. I’m going to find the x-component of the electric field at that same location (x = 0.02 meters). I don’t want to write it out, so I’m going to do it in python. Here is the link (I wish I could just embed the trinket right into this blog post).
Umm..wow. It worked. Notice that I printed the electric field twice. The first one is from the slope and the second one is by just using the superposition for the electric field. Yes, I knew it SHOULD work—but it actually worked. I’m excited.
Also, just for fun—here is a plot of the electric potential as a function of x. The negative of this slope should give you the x-component of the electric field.
Here you can see something useful. Where on this plot is the electric field (the x-component) equal to zero? Answer: it’s where the slope of this plot is zero (yes, it’s there). Remember, just because the electric field is zero that doesn’t mean the electric potential is zero.
How about this? See if you can find the electric field due to these two charges at a location y = 0.01 and x = 0.0 meters. This is right on the y-axis, but now the electric field clearly has both an x and a y-component. That means you are going to have to do this twice.
It’s the beginning of a new school year—and I’ve got you covered. You want to do something with coding in your physics class, but you don’t know where to start? I’m going to give you a jump start.
I know you are nervous, but don’t worry. You don’t need to be a ‘l33t h4x0rz’ (that’s cool-speak for elite hacker). You just need to get started. Just remember, everyone had to start programing at some point. They all did it—so can you.
What the heck do you call it?
I like to call this stuff “numerical calculations”. I think this is the best name for it because it sort of describes what’s going on. Here’s the general idea:
Take a physics problem (or any problem, really).
Break the problem into a bunch of small and easier problems.
Maybe make some approximations.
Solve all the small problems by using numbers.
Numbers are the key. You have to use numbers in a numerical calculation. The other solution is an analytical calculation. This is the process of solving a problem in terms of known functions—like the trig functions. For an analytic solution, you don’t really have to put in the numbers until the end.
Of course, there isn’t a huge difference in these two solutions (analytical vs. numerical). A great example from Bruce Sherwood (in a discussion at the recent AAPT meeting in Utah) points out the following:
Suppose you get a solution for a mass oscillating on a spring. The analytical solution will be in terms of the cosine function. But then, how do you get values for something like ? Well, you put it in your calculator or you look it up in a table. Oh, you could find the value for cosine by summing an infinite series. But you see—we are back to a numerical calculation.
That’s not exactly what Bruce said, but that’s the basic idea.
Here are some other names for numerical calculations that you might see:
Coding in physics
I’m drawing a blank here—there must be some other words.
But I also like numerical calculations because it doesn’t explicitly say “computer” in it.
Why do numerical calculations in physics?
Let me be brief and just list some points.
Numerical calculations are just part of physics. There are countless physics problems that can only be solved numerically.
Once students get the idea of numerical calculations, they can solve more interesting problems that would otherwise be inaccessible to them.
What about other fields? Meteorology, digital animations, protein folding, economics…the list goes on.
Tools. The tools for numerical calculations are both free and easy to access. You don’t need to install anything and you could even do it on a smart phone (not recommend—but possible).
Finally, numerical calculations helps student understand physics. I’ve always been surprised that when working on a problem with students on a computer, they ask questions. But these questions are rarely about computer syntax. They are usually things about vectors or forces. It’s awesome.
Who is this for?
I’m going to get you started—so this tutorial is geared towards very introductory classes. I use this same stuff in a physics lab for an algebra-based physics course at that college level. I think this would be fine for high school classes also.
If you want more advanced stuff—this might also work as an introduction. For my calculus-based physics course, I start with more complicated stuff.
Also, I am careful to emphasize that students (and faculty) don’t need any prior experience with coding.
Where to start
I like to have a workshop format for my lab or class. I use a projector at the front of the room to go over some points and then stop and let the students work on code either individually or in groups (here is a version of my presentation—feel free to use it). I tell students to bring a computer or tablet if possible. Otherwise they will be in groups of 4 per computer (which is not ideal). Of course some students don’t want to get involved, so a 4 person group is what they want.
Here is the general outline of the workshop format lesson.
Give an overview of numerical calculations (motivation).
Start with an object moving at a constant velocity in one dimension. Let them solve it analytically (hopefully, this is a review).
Next have them take this SAME PROBLEM but solve it by breaking into 7 time steps—but still solving it on paper. NO COMPUTERS YET.
I actually give them a table to fill out. It has 7 rows with columns for time, time step, and position. After a short time, I stop them and go over the calculation for the first row (and maybe the second). Some students can finish this table very quickly, and others not so quick.
Next, they do this same set of calculations with some python code. I give them this program that runs as it is and I go over each line.
So, the students run the code and then modify the code to answer some questions such as:
Where will the car be at a different time? Say 2.2 seconds.
What if you change the velocity the 0.62 m/s, where will it be after 2.2 seconds?
What if the car starts at -0.5 meters?
Stuff like that. Really, I just want them to be able to run the code, read the output, and change the code. It’s sort of a coding ice-breaker.
I’m not going to go over the rest of the workshop—but it’s all there (and more) on the trinket.io site along with the instructor slides. After that first small activity, the students do the following:
A similar problem but with a constant (non-zero) acceleration. This is great because you get a different final answer for the numerical calculation that depends on the size of the time step.
How to make graphs (or at least print out values) so you can get more data.
Solving a problem with two cars—one moving at a constant velocity and one accelerating. This is the classic “police chase” problem. I set up the program (not all the way) but I let them figure out how to change the while loop to get it to run. It’s great because students come up with their own ways of making it work. Sometimes, this is where I stop the class.
Mass oscillating on a spring.
What do you need?
If you want to do this in class, you need some computers or tablets and some time. You could probably do this in sections, just break it into 30 minute activities if you like.
Some other things to consider:
Make sure you work through the material first. It’s important to really know what’s going on so that you can easily help students when they get stuck.
If a group has a program that’s not running right, I really try to get them unstuck. If it’s a silly syntax error, I try to find that right away so they don’t get frustrated.
If you have any questions or need help. let me know.
I’ll be honest. This connection between the electric potential (change in electric potential) and the electric field can get sort of crazy. But let’s just start with a problem and then solve it in more ways than you wanted.
Here is the problem.
Let’s start with the energy to bring an electron to point B. The energy needed would be equal to the change in electric potential energy which is equal to:
That means I just need to calculate the change in electric potential from infinity to point B. Yes, you could also calculate the work needed to move the charge—I’ll do that also.
Since I am dealing with two point charges, I can use the following expression for the potential due to a point charge (with respect to infinity):
Where k is the Coulomb constant ( and r is the distance from the point charge to the final location. Since there are two point charges, the total potential will just be the sum of the two potentials. Let me call the positive charge “1” and the negative charge “2”. That means the total potential will be:
From the original problem, and . The distance will be 6 mm and the distance will be 4 mm (need to convert these to meters).
Putting this all together, I get the following. I will do my calculations in python. Here is the code.
Running gives the following output.
Boom. There is your first answer. What about point A instead of B? Well, in this case, I just have different distances. The distance for both AND are the same. Since they have the same distances but equal and opposite charges, the two potentials will be opposite. When added together, the total potential is zero volts. Yes, the energy needed to put a point charge at A from infinity is zero Joules.
What? Yes. How about this? Suppose you take the electron from infinity on the positive y-axis. As you move down the axis to point A, the electric field is in the x-direction. That means the electric force is in the negative x-direction. You would have to push it in the positive x-direction and move in the y-direction. But that requires ZERO work since the force and displacement are perpendicular.
Oh. You want to get to A from a point of infinity on the positive x-axis? OK. That still works. Remember that for electric potential, the path doesn’t matter—only the change in position (path independent). I can take whatever path I like. I’m going to move in a circle from positive infinity x to positive infinity y. The electric field is zero out there, so that requires zero work. Now I’m at positive infinity y—and I just did that problem. Zero work.
Another way—by calculating the work
Remember that work-energy principle? It says this:
And the work can be defined as the following (if the force and displacement are constant):
Oh, and the force will be the opposite of the electric force where:
So, as you push a charge towards point B (point A is boring—for now) the electric field changes. That means we have a problem. We can’t use the above formula to calculate the work—unless we cheat. Let’s cheat.
Instead of calculating the total work to move the charge to point B, I’m just going to move it a tiny bit. During this tiny move, the electric field (and thus the force) will be approximately constant. Then I can do another tiny move. Keep repeating this until I get to point B. Here is a diagram.
If this distance is short () then the force is approximately constant. That means the tiny amount of work (which I will call ) would be equal to:
OK, just to be clear. This is the force needed to PUSH the electron (with a charge e)—it’s not the electric force on the electron (which is in the opposite direction). Also, the angle between F and the displacement is zero. That means the cosine term is just one. I wrote the force and displacement as scalars because it’s just the magnitude that matters.
Now we are ready for some stuff. Here are the steps I am going to use.
Start at some position far away (but not actually infinity because that would be crazy). It just needs to be far enough away such that the electric force is negligible.
Calculate the total electric field and the force needed to push the electron at this point.
Move some short distance towards point B.
Over this distance, assume the force is constant and calculate the small work done—add this to the total work.
Repeat until you get to point B.
Before making this one program, I’m going to just make a program to plot the electric field from some value up to point B. Here is the plot from that program. (here is the code)
Note that I started from just 5 cm away from the origin—which is TOTALLY not infinity. However, it makes the graph look nice. But still, this is good because it looks like the calculation is working. Now I can use this same calculation go find the work needed to move the electron. Here is the code.
And the output:
Notice that gives a close, but wrong answer (compared to my previous calculation). Why is it wrong? Is it because I started at y = 0.5 meters (I just realized I’ve been using the variable y instead of x—but it should be fine). Or is it wrong because my step size is too big?
The answer can be found by just changing up some stuff. If you move the starting point to 1 meter, you get about the same answer. However, if you change dy to 0.0001, you get the following output.
That works. Oh, I added some more stuff to the output.
One more thing (and then I will look at the electric field in another post). What if I use a different path to get to point B? Instead of coming along the x-axis (which I previously called “y”), I come parallel to the axis a distance of 2 mm above it. Once I get right over point B, I turn down.
This introduces some “special” problems.
I can break this path into two straight pieces (path 1 is parallel to x-axis and path 2 is parallel to y-axis).
Along path 1, the force needed to push the electron is NOT parallel to the path. So, the angle is not zero in . This means I’m going to have to calculate the actual vector value of the electric field at every step along this path.
The same is true along path 2.
But in the end, I should get the same work required—right?
OK, hold on because this is going to get a little more complicated. Let me just include one sketch and then I will share the code for this new path. Here is how to calculate the electric field and work for a particular step in path 1.
Here’s what needs to happen to calculate the electric field (and force) for each step:
Find the vector from the positive charge to step location.
Use this vector to find a unit vector (to give the electric field a direction).
Use that vector to also find the magnitude of the electric field.
Calculate the electric field due to the positive charge (as a vector).
Repeat this for the negative charge.
Add the two vector values for the electric field to get the total electric field.
Multiply by the charge to get the force (which would be in the opposite direction).
Now, to calculate the work done during each small step, I could use the angle between the force and displacement. But I don’t know that. Instead, I can use the vector definition of work:
Yes, that is the dot product. Fortunately, the dot product is already built into VPython (Glowscript). So, once I get a vector value for the force and the displacement I can just use the “dot()” function.
Batteries and bulbs are fun, but they can only go so far. How about a capacitor and a bulb? Yes, let’s do that.
Here is the setup.
This has a battery (2 1.5 volt batteries) connected to a 1 Farad capacitor with a switch. This capacitor is then in parallel with a light bulb. When the switch is closed, the capacitor is charged up to 3 volts. When the switch is opened, the capacitor discharges through the bulb. Notice how it slowly gets dim.
Of course the full circuit doesn’t really matter. I don’t care about charging the capacitor, just the discharging. So here’s the important part.
Let’s start off by applying the Loop Rule to this circuit. If I start from the lower left corner and then go around counterclockwise, I get the following. Oh, I’m assuming zero resistance in the wires.
Where the voltage across the capacitor depends on the charge.
But wait! The current is the flow of charge. Since there is a current, the will be a decrease in charge on the capacitor. A decrease in charge means there will be a lower voltage. This lower voltage makes a smaller current. Maybe you can see the problem. Don’t worry, we can still solve this.
Let’s create a numerical calculation to model the current running in this circuit. The key here is to break the problem into very small time steps. Let me start by using the loop rule and using the following definition of electric current.
Now the loop rule looks like this.
If I use a very small time step, then I can assume that during this time interval the current is constant (it’s not, but this isn’t a bad approximation). From this I can solve for the change in charge.
But what does this change in charge do during this time interval? Yup, it decreases the charge on the capacitor—which in turn decreases the capacitor voltage—which in turn decreases the current. I think I already said that.
After this short time interval, I can find the new charge on the capacitor.
Note: the minus sign is there because the current DECREASES the charge on the capacitor.
That’s it. We are all set. Here is the plan. Break this problem into small time steps. During each step, I will do the following:
Use the current value of charge and the loop rule to calculate the change in charge during the time interval.
Use this change in charge to update the charge on the capacitor.
Repeat until you get bored.
OK. Suppose I am going to do this. I decide to break the problem into a time interval of 0.001 seconds. How many of these intervals would I need to calculate to determine the current in the circuit after 1 second? Yes. That would be 1000 intervals. Who wants to do that many calculations? I sure don’t.
The simplest way to do this many calculations is to train a middle school student how to do each step. It shouldn’t be hard. Oh wait, the middle school student is still busy playing Fortnite. Oh well. Maybe I will train a computer to do it instead. Yes, that’s exactly what I will do.
In this case, I’m going to use python—but you could use really any programming language (or even no computer programming language). The idea of a numerical calculation is to break a problem into small steps. The idea is NOT to use a computer. It just happens that using a computer program makes things easier.
Let me just make a couple of comments on different lines.
Line 4,5 just sets up the stuff to make a graph. Graphing in super easy in this version of python (Glowscript).
Line 14 is the length of the time interval. This is something you could try changing to see what happens. Yes, if you use the trinket.io link above, you can edit the code.
Line 21 looks tricky. It looks like Q will cancel in that equation. Ah HA! But that’s not an algebraic equation. In python, the “=” sign means “make equal” not “it is equal”. So this takes the old value of Q and then updates it to the new Q.
Line 25—same thing happens with time. You have to update time or the loop will run FOREVER!
Line 26. This is how you add a data point to the graph.
This is what you get when you run it.
OK. That looks nice. As we see in real life, the brightness of the light bulb dims rapidly at first and then slowly dies down. This plot seems to agree with actual data (always good for a model to agree with real life).
But what does the textbook say about a circuit like this (called an RC circuit because it has a capacitor and a resistor in it)? Note: this is an algebra-based physics textbook. It gives the following equation for a discharging capacitor.
In this case the is the initial voltage on the capacitor. Well, then let’s plot this solution along with my numerical calculation. Here is the code https://trinket.io/glowscript/f4a3ff8264—and I get the following plot.
Those two plots are right on top of each other. Winning. Oh, go ahead and try to change the time step. Even with a much larger step, this still works.
Some final notes. Why? Why do a numerical calculation?
Numerical calculations are real. They are used in real life. There are plenty of problems that can only be solved numerically.
I think that if physics students create a numerical calculation, they get a better understanding of the physics concepts.
What if you want to treat the bulb as a real lightbulb? In that case the resistance is not constant. Instead, as the bulb heats up the resistance increases. With this numerical calculation you should be able to modify the code to account for a real bulb. It would be pretty tough if you solved this analytically.
What is the point of having students (in an algebra-based course) memorize or even just use the exponential solution for an RC circuit. It might as well just be a magic spell if you just use the equation. I don’t really see the point. However, with the numerical calculation the students can do all the physics.
Suppose a ball is shot at an angle θ with an initial velocity v0. What will the motion be like in polar coordinates?
First, let me start with Newton’s 2nd Law in polar coordinates (I derived this in class).
Once the ball is in the air (and ignoring air resistance) the only force on the ball is the gravitational force. Yes, this would be -mg in the y-direction, but we don’t have a y-direction. Instead, we have polar coordinates. Maybe this picture will help.
The r and θ components of the gravitational force will change as:
If I use these forces with Newton’s law in polar coordinates, I get:
Of course the mass cancels – but now I can solve the first equation for and the second equation for .
It doesn’t matter that these second derivatives depend on the other stuff – I can still calculate them. Once I have those, I can create a numerical calculation to update the velocities and positions. Suppose I have everything know at time(1), then the stuff at time(2) would be:
Now I’m all set to do a numerical calculation. Well, I still need the initial conditions. I could use this:
But wait! There’s a problem. The calculation for has a 1/r term. If r is zero the universe will explode. I can fix this by having the initial r a little bit bigger than zero. Problem solved.