Ex. 5.4 — Loops, standard library, mathematical functions

Ex. 5.4 — Loops, standard library, mathematical functions

You cannot submit for this problem because the homework's deadline is due.

Description

A projectile is fired into the air at an initial speed \(v_0\) and an initial angle \(\theta_0\), with an initial height \(h_0\). Its trajectory can be expressed as

\[y=h_0+\tan(\theta_0)x-\left(\frac{g}{2v_0^2\cos^2\theta_0}\right)x^2,\]

where \(g = 9.81\) is the gravitational acceleration constant.

Implement the bisection method to determine when the projectile touches the ground. Use the constant FLT_EPSILON as the convergence tolerance and \([75, 85]\) as the initial interval for the bisection method.

Hint 1: FLT_EPSILON is defined in <float.h> file and the mathematical functions are defined in <math.h>.
Hint 2: the trigonometric functions expect angles in radians.

Format

Files

GNUMake

If you choose GNUMake, then you should compress assignment.h, ex1.c, ex2.c, ex3.c, ex4.c, main.c, Makefile directly into a zip and submit this zip. (A sample Makefile can be found on Canvas).

If you just finished ex4 and you immediately want to test whether your ex4 is working correctly. You need to modify your main.c, assignment.h, Makefile (delete ex2.c ex3.c ex1.c) and then compress main.c,assignment.h,Makefile,ex4.c into a zip and submit this zip.

The sample Makefile on Canvas has -o main, do not change this main!

CMake

If you choose CMake, then you should compress assignment.h, ex1.c, ex2.c, ex3.c, ex4.c, main.c, CMakeLists.txt directly into a zip and submit this zip. (A sample CMakeLists.txt can be found on Canvas).

If you just finished ex4 and you immediately want to test whether your ex4 is working correctly. You need to modify your main.c, assignment.h, CMakeLists.txt (delete ex2.c ex3.c ex1.c) and then compress main.c,assignment.h,CMakeLists.txt,ex4.c into a zip and submit this zip.

The sample CMakeLists.txt on Canvas has add_executable(main ..., do not change this main! Also, do not change cmake_minimum_required(VERSION 2.7)

Input

one line with a space separated list in the order \(v_0\) \(\theta_0\) height range_min range_max

Output

one line showing the result with six decimals

Sample 1

Input

30 30 1.5 75 85

Output

81.970131

Limitation

1s, 32MiB for each test case.

Homework 5 (Individual)

Not Claimed
Status
Finished
Problems
4
Open Since
2019-10-27 00:00
DDL
2019-10-30 23:59
Extension
72.0 hour(s)