Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Python problem vox = v0 * math.cos(theta * math.pi/180) voy = v0 * math.sin(thet

ID: 3307602 • Letter: P

Question

Python problem

vox = v0 * math.cos(theta * math.pi/180)
voy = v0 * math.sin(theta * math.pi/180)
g = 9.8

For the next problems, consider the trajectory problem with a linear drag force where we derived the following relations, 2. (5 pts) Write a program that when run from the command line prompts the user to enter vo in m/s and in degrees for the projectile s initial velocity, then prompts the user for the drag term in s. The program should then solve for the time at which the projectile returns to the horizontal, y = 0, using Newton's method. 3. (5 pts) Assume the cannon is situated on a cliff of height h in meters. Write a second version that additionally prompts for the height of the cannon above the plain over which it is aimed. Have the program solve for the range of the cannon and print out the answer

Explanation / Answer

Here is the 3 question solution:-

clc;
clear all;
close all;
format long;

v0=input('Enter initial velocity in m/s : ');
theta=input('Enter angle in degree : ');
ga=input('Enter the drag coefficient : ');
h=input('Enter the height above which projectile is fired : ');
vox=v0*cos(theta*pi/180);
voy=v0*sin(theta*pi/180);
g=9.8;


syms t
f=-g*t/ga+(voy+g/ga)/ga*(1-exp(-ga*t))-h;
tol=10^(-8);
% % % N-R Method

s(1)=4;
for n=1:100
    l1=subs(f,s(n));
    l2=subs(diff(f),s(n));
    s(n+1)=s(n)-l1/l2;
    e=abs(s(n+1)-s(n));
    if (e < tol)
        break;
    end
end
fprintf('Time at which projectile return to ground : %f second ', s(end) );

x=vox/ga*(1-exp(-ga*s(end)));
fprintf('Range of projectile : %f meter ',x);

OUTPUT:

Enter initial velocity in m/s : 80
Enter angle in degree : 30
Enter the drag coefficient : 0.75
Enter the height above which projectile is fired : 5
Time at which projectile return to ground : 4.894477 second
Range of projectile : 90.024645 meter