Please turn in this assignment (and all future assignments for this course) by emailing them to me . Please use the subject of "Physics 222 HW4" for these assignments (if you use the link above, the subject will be added automatically). Please attach the source code to any programs that you write for this assignment. If you write more than one program, attach each separately. When answering the questions themselves feel free to answer directly in the body of your message (or attach your answers). I may take off points for assignments that are not sent to me in the correct form.
Write a program that will use a separate function or subroutine to calculate all of the following quantities for a given integer:
Feel free to reuse your prime number code, but beware that you will have to take care of cases such as 0, 1, and negative numbers.
Show your results when using the following numbers as input: -127, 51, 0, -23459, 453, 77779, -1, and 7.
In this problem, you will solve write a C++ or Fortran progam to find the maximum height reached by a model rocket. Further background on the physics of model rockets is available from the Physics 332 Rocket Lab . In this problem use real/float variables that are at least 8 bytes (kind=8/double precision). The relevant force equation is :
F = m(t)a = -m(t)g -k v2 +T(t)where T(t)=b t(1-t) is the time-dependant thrust for times from 0 to 1 second, with the thrust being 0 at all other times and b=16 N/s2. k is the drag coeffient, k= 1/2 Cw ρ A, where Cw=1.0 is a constant, A=0.00100 m2 is the area, and ρ is the density of air (1.2 kg/m3). Since the loss of mass of the rocket engine is responsible for the thrust, dm/dt is proportional to -T(t). The mass of the rocket before launch is 0.120 kg, while the mass after is 0.070 kg. So:
mi = mi-1 - 6/b * (mo - mf)*Ti*Δt
To solve the rocket equation
numerically, you will need to solve its difference
vi= vi-1+ Δt (-g - k vi-12/mi + Ti/mi)After finding the speed, you will be able to find the height from:
xi = xi-1 + Δt viOf course to solve either of the above, you will already have to have forms for Ti and mi.
Think carefully about what condition must be met in order to find the maximum height.
The time step size Δt can be crucial to getting accurate results. Find the maximum height with time steps of:
Plot the height of the rocket as a function of time using the PGPlot library. Include a postscript (.ps) plot graph of the 0.00001 s time step case in your email for this assignment.
Do these results seem to be approaching any limiting value. Do you trust these results? Why or why not?