Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

HAND IN LABORATORY TASK: LAB #15 Motion of a charge in an electric field use of

ID: 3704525 • Letter: H

Question

HAND IN LABORATORY TASK: LAB #15 Motion of a charge in an electric field use of the FOR loop Use For loop concept in the following problem. An electron, charge e(constant 1.6 x10-19 C) starts out with a velocity vo from position (0,0) (SEE DIAGRAM BELOW) Is moving perpendicular in an electric field E(2.0x10-12 N/C). The electron will follow a parabolic path given as an x and y position each of which can be solved as a function of time t. The electron has a mass, m (constant 9.1 x 10-31 kg). The electron experiences a force in the y direction only, given by F-eE causing by Newton's second law an acceleration downward =ma. Thus the electron will move in the y direction with the usual kinematic equation y -1/2at with "a" being ay constant in the negative direction solved from FseE=ma The motion in the x direction is dependent only on the Namely, x=vot The velocity in the downward direction is v=at USE A FOR LOOP WITH t the loop variable running from 0 to 0.5 sec in 0.01 increments. Create a labeled table of t, x, y, v showing the motional positions, (ie, x and y). Does the x, y and v results make sense? ANSER. WHY or WHY NOT! Vo

Explanation / Answer

So, I have written a code in C++ for the above problem. Just copy paste the code given below in your IDE and run it. That's it. It will give you the data in the order given in the question (t,x,y,v). The program will also produce an output file where the data is written in to. The only thing I have assumed is the x-velocity or v0 (you can see that I have used 2m/s). Is it given somewhere in the question? If it is given replace it with that value. Otherwise ask your teacher. I can comment on the result when you have that velocity. As of now there is nothing much to say. Hf.

#include <iostream>
#include <cmath>
#include <conio.h>
#include <math.h>
#include <fstream>
using namespace std;
double e = 1.6*pow(10,-19);//charge of the electron
double m = 9.1*pow(10, -31);//mass of the electron
double E = 2*pow(10,-12);//given electric field
double F = e*E;//calculation of force due to electric field;
double a = F/m;//calculation of acceleration in the y-direction
double dt = 0.01;
double maxt = 0.5;
int n = maxt/dt;//total time steps
double v0 = 2; //this is the initial x-velocity which I assumed


int main(){
double t[n];
double x[n];
double y[n];
double v[n];
t[0]=0;
ofstream outputFile;//this is for the output file
outputFile.open("program_data.txt");
outputFile <<"t"<<" "<<"x"<<" "<<"y"<<" "<<"v"<< endl;
cout <<"t"<<" "<<"x"<<" "<<"y"<<" "<<"v"<< endl;
for(int i=0; i<n+2; i++){
x[i]= v0*t[i];//calculation of the displacement in the x-direction
y[i]= 0.5*a*t[i]*t[i];//calculation of the displacement in y-direction
t[i+1]=t[i]+dt;//increment of time
v[i]= a*t[i];//calculation of y-velocity
cout<<t[i]<<" "<<x[i]<<" "<<y[i]<<" "<<v[i]<<endl;
outputFile<<t[i]<<" "<<x[i]<<" "<<y[i]<<" "<<v[i]<<endl;//writing the variables in the outputfile

}
return 0;
}