I am trying to solve the numerical equation:
sin^2(x)tan(x) = 0.499999
Using a while loop in C. However I was only able to get program to print an answer if
Use a relative difference, such as:
#include static inline double reldiff(double x, double y) { return fabs(x - y) / fmax(fabs(x), fabs(y)); }
Now your test becomes:
if (reldiff(x, y) < 0.01) // 1% as requested