Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double trqs(double a)
- {
- double low = 0;
- double mid = a/2;
- double high = a;
- double squared = high * high;
- const double epsilon = 0.000001;
- while(low < high && (squared + epsilon < a * a || squared - epsilon > a * a)){
- if( squared + epsilon < a) {
- low = (low + mid) / 2;
- } else if (squared - epsilon > a) {
- high = (high + mid) / 2;
- }
- mid = (high + low) / 2;
- squared = mid * mid;
- }
- return mid;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement