Starting from:

$29.99

CSCI2202 Assignment 2 Solution

(1) (a) [8] Solve the non-linear equation: . The origin
of the problem is explained in the notes. .
(b) [7] Find the point of intersection of the curves: y = x3 − 2x + 1 and y = x2. Specify your answer to 4 decimal places.
(2) [15] Consider a game where the contestant is presented with three doors. Behind one of the doors is a car (the “prize”’), behind the other two are goats. The contestant chooses a door, but the host (who knows where the prize is) opens one of the other two doors (never revealing the prize). The contestant is now given the choice of switching to the other door. Create a simulation that plays the game N times (input by the user ), using each of the two strategies (switch door selected or not switch door selected). Estimate the chance of winning for each of the two strategies as a ratio of wins to the total number of attempts N. Run the simulation and report your results for N = 10000 and N = 100000 games.
1
2
(3) [20] In labs 3 and 7 you computed and plotted the trajectory of a projectile, neglecting air-resistance (drag) on the projectile. In this problem you will incorporate air resistance. The drag force f, for a projectile (like a football or a tennis ball) is proportional to the square of the projectile’s speed: f = Dv2 and the direction of f is opposite to the direction of the projectile’s velocity.
→−f = −Dv→−v → fx = −Dv · vx & fy = −Dv · vy
Where fx,fy are the components of the drag force and the proportionality constant D is given by:

where A is the cross-sectional area of the projectile (a ball of mass m), CD is the drag coefficient (dependent on the shape of the projectile) and ρ is the density of air.
From Newton’s second law, the acceleration of the “ball” is proportional to the external unbalanced force: The xv and y component of the net force on the ball are:
The particle moves in the +x and +y direction. The negative signs on the x and y components of the acceleration indicate that these are opposite to the direction of motion. Knowing the mass of the projectile (ball), the acceleration can be computed.
• (i) Use numpy and Matplolib to compute and plot the trajectory of a baseball, projected at a speed and angle input by the user. The program should print the maximum height and the range that the ball reaches. The steps to compute the positions and velocities are given below.
• (ii) Plot the trajectory of the baseball with and without air resistance on the same plot.
For a regulation baseball, assume m = 0.145Kg, the radiu sr = 0.0366m, CD = 0.5 and the density of air (at standard temperature and pressure) is ρ = 1.2kg/m3.
(a) Choose a time interval ∆t and define the initial values of x,y,vx,vy,t. (choose ∆t to be a suitable value in the range 0.05 to 0.1).
(b) Choose N - the maximum number of intervals (this gives the max. time: tmax = N ∗ ∆t for the numerical solution). So at the kth timestep: tk = k ∗ ∆t. Experiment with various values for N and ∆t, to find a suitable plot for the trajectory.
3
(c) Iterate (loop) the next 4 steps repeating the steps while n < N or t < tmax. A convenient way to do this is to use the range function in the form range(1, N+1).
(See: https://docs.python.org/3/library/functions.html#func-range).
(d) Compute ax = −(D/m)v · vx and ay = −g − (D/m)v · vy
(e) Compute the new velocity components at a time ∆t later:
vx−new = vx−curr + ∆vx = vx−curr + ax ∗ ∆t
&
vy−new = vy−curr + ∆vy = vy−curr + ay ∗ ∆t
(f) Compute the new position coordinates at a time ∆t later:

&
.
(g) Set the current positions and velocities to the new positions and velocities and jump back to step (d) and repeat.

More products