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

There are a few instances, when using trig, relations where multiple solutions (

ID: 3666175 • Letter: T

Question

There are a few instances, when using trig, relations where multiple solutions (or quadrants) :xist. One of such examples is the use of the arc tan() function where theta = atan(y/x). To alleviate this, a function named atan2 was introduced which is defined as A) Create a program, named my_antn2() which calculates atan2() using the logic above. Your program cannot use an tug functions except lor the arctangent function. Your program should be able to handle output of either degrees or radians. B) Test your program with the following data and complete the table in your report.

Explanation / Answer

#include #include// for setprecision, setw #include using namespace std; double PI = 3.141592654; // unfortunately, 3 formulas apply to different ranges of x // atan(x) = x - x^3/3 + x^5/5 - ... for -1 1 // atan(x) = -PI/2 - x^-1 + ... as above for x < -1 double myAtan(double x, int n, double& r_err ) { double a = 0.0;// 1st term double sum = 0.0; // special cases if( x == 1.0 ) return PI/4.0; if( x == -1.0 ) return -PI/4.0; if(n > 0) { if( (x < -1.0) || (x > 1.0) ) { // constant term if( x > 1.0 ) sum = PI/2.0; else sum = -PI/2.0; // initial value of a a = -1.0/x; for(int j=1; j