Question: 1. Prime Numbers. (50 Points) In this problem you will use Matlab to compute prime numbers to test your overall knowledge of computer programming with

 1. Prime Numbers. (50 Points) In this problem you will use
Matlab to compute prime numbers to test your overall knowledge of computer
programming with Matlab. Examples of prime numbers are 11 and 13 because
they can only be divided exactly by one and by themselves. To

1. Prime Numbers. (50 Points) In this problem you will use Matlab to compute prime numbers to test your overall knowledge of computer programming with Matlab. Examples of prime numbers are 11 and 13 because they can only be divided exactly by one and by themselves. To receive credit for your work you must implement all the codes with for- loops and must follow all the instructions. The latter implies that you only score points when the answer is correct, there are no partial points (a) Write a code in Matlab that finds how many prime numbers are between 1 and your Student ID. Store your answer in variable N. (10 Points) (b) Write a code in Matlab that finds how many prime numbers are between 1 and your Student ID. The twist is that now you will not count every prime number from beginning to end, as in the previous part, but you will use a non-unit step size for counting. Use the last digit (counting from left to right) of your Student ID as a step size. For example, if your Student ID is 123456 the step size that you will use is 6. If by chance your Student ID ends in a 0 or 1 you will use a (c) Write a code in Matlab that calculates the sum of all prime numbers between 1 (d) Write a code in Matlab that calculates the sum of the prime numbers of part (b) (e) Write a code in Matlab that stores all prime numbers between 1 and your Student (f) Write a code in Matlab that stores all prime numbers of part (b) in the columin step size of 7. Store your answer in variable M. (10 Points) and your Student ID. Store your answer in variable TOTAL. (5 Points) Store your answer in variable SUM. (5 Points) ID in the column vector X. (10 Points) vector Y. (10 Points) 2. Taylor Series (20 Points) The Taylor series approximation of e is simply given by rn n! 7a er (a) Use Matlab to estimate e" with the first 50 terms of the Taylor series. Use what you know about vectors and the built-in function sum to conduct your calculations. Store your answer in variable T50V. (5 Points) (b) Repeat the calculation of the previous part only with for-loops but use the first 500 terms. Usage of vectors and built-in functions is not permitted. Store your answer in variable T50L. (10 Points) (c) Calculate the %error of Part (a). The % error-IE-Al/Ex 100, where E is the exact value and A is the approximate value. Store your answer in variable ERROR. (5 Points) 3. Floating Sphere. (30 Points) Consider a forlorn sphere in the the open sea (maybe it's all that's left from a long for- gotten shipwreck) that is floating because the bouyant force, FB, balances the sphere's weight, W. A sketch for this system is shown in figure 1 0 W -mg Figure 1: A partly submerged sphere to a depth h measured from the sphere's center up to the sea level. The shaded region depicts the spherical cap that is above sea level. The sphere's radius is denoted by R, the density of sea water is denoted by po, the density of the sphere is denoted by p, the weight of the sphere is denoted by W mg, where m is the sphere's mass and g is the acceleration of gravity From Archimides' principle you can deduce that the buoyant force lifts the sphere with a force equal to the weight of the sea water displaced by the submerged volume of the sphere where Po = 1.2 g/cm3 is the density of sea water, V, is the submerged volume of the sphere and g 9.81 m/s2 is the acceleration of gravity. The volume of the spherical cap above sea level, which is highlighted in figure 1 as a shaded region, is determined by the following formula: V(R -h)2 (2R+h), where Ve is the volume of the spherical cap, R- 1.2 m is the radius of the sphere, and h is the vertical distance measured from the center of the sphere to the sea level. The total volume of the sphere, V, is simply: 3 The density of the sphere, p, was determined by an inquisitive engineer who is traveling to the south pole to assist a team of explorers that have recently found a cavern so deep that it seems to lead towards the center of the Earth. The sphere's density was found to be p 1.0752 g/cm. Instructions: Find the depth, h, in meters of the sphere by following these steps: (a) Make a free body diagram that shows all the forces acting on the sphere. (5 Points) Note that the sphere is not drifting in the sea by sea currents, this is a statics problem (b) Conduct a force balance on the sphere and make the resultant force equal to zero for the system to be in equilibrium. The equation that results from this analysis is the equilibrium equation for this system. (5 Points) (c) Rewrite the equilibrium equation in the form f(x) = 0, where x is the only unknown in this problem, which is of course the depth h. All the other variables are known quantities. Note that you will have to relate the mass the sphere and the submerged volume of the sphere to known quantities and formulas given above in order to be able to proceed further. (5 Points) (d) Solve for with the Bisection Method with a tolerance of 10-. You may use any other numerical methods discussed in class to corroborate your answer. Store your answer in variable x. (15 Points)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!