This is the generic function you might use:
The arguments y and exponent are given, your case y=32, exponent=7;
Next step is to find 2 numbers (which should form an interval), let's say a and b, so that bisectionRoot(a,y,exponent) is positive, and bisectionRoot(b,y,exponent) is negative
At this point, you will have:
Now you should send the midst of a and b, let's name it c, calculated as c=(a+b)/2 to the function:
You have now 3 possibilities:
- limit_c==0; // lucky, this is the root (that means c);
- limit_b and limit_c have opposite signs (+/- or -/+) // the root lies between b and c;
- limit_b and limit_c have the same sign (+/+ or -/-) // the root lies between a and c;
If 2., c becomes the new a If 3., c becomes the new b. Repeat the steps.
Because the result is anyway an approximation, you may either set a certain number of steps from the beginning or, better, set a minimal size of the interval (between a and b) where your root is situated (the floated point above everything is 0 in the value of limit_c).
Hope it helps.
Note: I hope I did not inverse the cases. It's a long time since I studied algebra.