Homework Assignment 1 
Name: Yoon Tiem Leong
Matrix Number: 54321

Qeustion:

Sample code 2.1.5 generates a familiy of curve on the same graph,with each curve associated with a different initial angle. This is done simply by setting the B2overm = 0 in the following code.

g=9.81 (*in unit of m/s^2*);
v0=700.0 (* in unit of m/s, magnitude of initial velocity *);
x0=0 (* in unit of m*);y0=0 (* in unit of m*);
Deltat=0.1 (*in unit of second *);
NStep = IntegerPart[(40000/Deltat)+1]; (* Number of total time step *)
B2overm=0.0;(* B2/m, in unit of m^(-1) *)

For[j=0,j≤5,j++,
v[0]=v0;x[0]=x0;y[0]=y0;
angle0=(Pi/6)+j*(5*Pi/180);(* in unit of radian *)
Print["j= ",j,"  "," angle in degree ",N[angle0*180/Pi]];
vx[0]=v0*Cos[angle0];vy[0]=v0*Sin[angle0];
For [i=0,i≤NStep,i++,
v[i]=Sqrt[vx[i]^2+vy[i]^2];
x[i+1]=x[i]+vx[i]*Deltat;
vx[i+1]=vx[i]-B2overm*v[i]*vx[i]*Deltat;
y[i+1]=y[i]+vy[i]*Deltat;
vy[i+1]=vy[i]-g*Deltat-B2overm*v[i]*vy[i]*Deltat;

If[y[i+1]<0,
ilast=i+1;
Print["y[i+1]<0 ",y[i+1]<0];Break[];
](*end if *)
];(* end for i*)

txyj[j]=Table[{x[i]/1000,y[i]/1000},{i,0,ilast}];
];(*end for j*)
txy=Table[txyj[j],{j,6,11}];
ListPlot[txy,Joined->True,AxesLabel->{"y (km)","x (km)"},PlotRange->All]
(*ListPlot[{txyj[1],txyj[2]},Joined->True,AxesLabel->{"y (km)","x (km)"},PlotRange->All]*)

Question:

Either your scan your handwritten solution on a piece of paper and then scanned it into pdf, take a ‘snapshot’ of the pdf document, and then paste the ‘snapshot’ here. 


Or alternatively, type your solution using Word and equation editor, covert it into pdf, and then take a snapshot of the pdf copy to paste it into your solution.nb.