Around The World in ??? Days For today's lab, there are two main goals: Derive the formulas for the distance between two cities, given their latitudes and longitudes. These formulas are to be turned in by the end of the lab period. Make as much progress as possible on your functions for reading the input data and printing the list of cities (see part (a) on page 3). Ideally you should be able to write and test them today. Distance between citiesA point on the surface of a sphere can be uniquely characterized by two angles, the polar angle and the azimuthal angle b, as shown in the diagram below. We can use these angles to estimate the "surface distance" between two cities on Earth, given their latitudes and longitudes. We take the "prime meridian" through Greenwich, England to be b=0. Cities with E (east) longitudes will have positive b values; cities with W (west) longitudes will have negative b values. Cities in the northern hemisphere will have 0 <= a < p/2, while cities in the southern hemisphere will have p/2 < a <= p. A city on the equator (latitude 0) has a = p/2). WNGraphic.838900.eps Work out the formulas for converting a latitude (given in degrees and minutes N or S) into an a -value (in radians). Do the same for converting longitudes to b-values. I suggest implementing these formulas either in Mathematica or in C so you can test them for several latitudes and longitudes to see if they produce reasonable values of a and b. Recall that a minute is 1/60th of a degree. Now figure out the formulas (in terms of R, a , and b) for the x, y, and z coordinates of a point on the surface of a sphere of radius R whose defining angles are (a, b). Assume that the origin is at the center of the sphere. The z coordinate is the easiest one to figure out. To get the x and y coordinates, first project the (bold in the diagram) line segment (from the origin to the point) onto the xy-plane (that projection is also shown in the diagram). What is the length of this projected line segment? How can you use the projection and the angle b to find the values of x and y? Next, suppose that two points P1 and P2 have (a, b) and (a, b) as their defining angles. Consider vectors V and V from the origin to points P and P respectively. Let q be the angle between these vectors. Use your above calculation of the rectangular coordinates (x, y, z) along with the dot product formula to derive a formula for cos q Mathemetica can be a great help in the simplification process; You may have to apply Simplify[] to part of the answer in order to get satisfactory results. The final formula should not be very long. Y?4 Write a small main() function to test your input and output functions. I recommend that you attempt to finish Part (a) in lab today.Part (b) Write in C the function(s) to convert the latitude and longitude values to a and b values. In order to test this feature, modify your output function from part (a) so that it can print the values of a and b.Part (c) Write a function that takes two cities as arguments and calculates the surface distance between them. Test your function by computing and printing the distance of each city in the list from Indianapolis. The latitude of Indianapolis is 39Ê 46' N, and the longitude is 86 9' W. Do the distances printed by your program seem reasonable? Assuming that your program is correct, what could be some sources of discrepancies between the distances printed by your program and the numbers you might find in a world atlas? You do not need to include this output in what you turn in; it is only to give you confidence that your distance function is working. Part (d) Print out the first table showing mileages, etc. Part (e) Sort the cities into wealth order, and test to be sure that it works. Print out the second listing including mileages. Then do the same thing for latitude order. Part (f) Use the population rate figures to update the population for each city to its expected value in 25 years (don't forget to compound). Then redo part (d) based on these figures. You should reuse as much of the code from part (e) as possible instead of having to write entirely new functions to do it all. In fact, reusing code should be a major theme as you write this entire program.³What to turn in: Q?A1. Your formula derivations (due today) 2. A listing of your well-commented program that reads the input file and prints the four lists3. The output from your program. 4. Also email your C source program to anderson with a Subject: line "IFYCSEM exercise 9.1 turnin". The program, its output, and your conclusions paper should be stapled together and signed by all partners. By signing, you attest that you participated significantly in the creation of this program, that you understand what was done, and that you could explain it to other people.ÚUnlike programs due earlier in the term, this program will not be accepted late. You must turn in whatever you have done by the due time (Thursday at 1:30 PM). Do not think that you can get additional credit by continuing to work into the Block 9 period on Thursday. Suggestion: Set up a timetable that includes plans to finish this assignment by Monday night; then you will have plenty of time to cope with unanticipated problems. What to turn in: Q?A1. Your formula derivations (due today) 2. A listing of your well-commented program that reads the input file and prints the four lists3. The output from your program. 4. Also email your C source program to anderson with a Subject: line "IFYCSEM exercise 9.1 turnin". The program, and its outpu should be stapled together and signed by both partners. By signing, you attest that you participated significantly in the creation of this program, that you understand what was done, and that you could explain it to other people. What to turn in: 1. Your formula derivations (due today) 2. A listing of your well-commented program that reads the input file and prints the four lists 3. The output from your program. 4. Also email your C source program to anderson with a Subject: line "IFYCSEM exercise 9.1 turnin". The program, and its output should be stapled together and signed by both partners. By signing, you attest that you participated significantly in the creation of this program, that you understand what was done, and that you could explain it to other people. Next, suppose that two points P1 and P2 have (a, b) and (a, b) as their defining angles. Consider vectors V1 and V2 from the origin to points P1 and P2 respectively. Let q be the angle between these vectors. Use your above calculation of the rectangular coordinates (x, y, z) along with the dot product formula to derive a formula for cos q Mathemetica can be a great help in the simplification process; You may have to apply Simplify[] to part of the answer in order to get satisfactory results. The final formula should not be very long. THe formula for distance in terms of (a, b) and (a,b) is what you should use in oyur C program. What to turn in: Q?A1. Your formula derivations (due today) . A listing of your well-commented program that reads the input file and prints the four lists3. The output from your program. 4. Also email your C source program to anderson with a Subject: line "IFYCSEM exercise 9.1 turnin". The program and its output should be stapled together and signed by both partners. By signing, you attest that you participated significantly in the creation of this program, that you understand what was done, and that you could explain it to other people.