c#,algorithm,time-complexity,square-root,newtons-method

What is a good rule of thumb for the number of iterations on a number, if one exists? Newton's method has quadratic convergence, ie. at every step of the algorithm, the number of significant digits in the answer doubles. Thus the algorithm computes square roots upto D digits of...

java,algorithm,math,square-root

Up front: It should be noted that processors capable of doing sqrt as a machine instruction will be fast enough. No doubt, its (micro)program uses Newton-Raphson, and this algorithm is of quadratic convergence, doubling the number of accurate digits with each iteration. So, ideas like this one aren't really worth...

c#,string,parsing,if-statement,square-root

Try this: txtOutput.Text = "Equation has two real roots: " + "\r\nroot1: " + (-coefficientB + Math.Sqrt(discriminant)) / (2 * coefficientA) + "\r\nroot2: " + (-coefficientB - Math.Sqrt(discriminant)) / (2 * coefficientA); You were bracketing the formula incorrectly....

I believe you should use relative error for the termination, and not the absolute error. while (abs((guess*guess-x) / guess) > 0.00001) Otherwise it will take very long time (it's not an infinite loop) to compute square root of very long values. http://en.wikipedia.org/wiki/Approximation_error Cheers! EDIT: moreover, as pointed below in the...

python,square-root,bisection,epsilon

The issues in the cases are - First Case : You are assuming that the input you get x would always be positive , since you are always setting it to high, so when sending a negative number, ans in first iteration is -13.5 and since (-13.5)**3 is negative, it...

Try to use this algorithm which use Newton's iteration: import java.util.Scanner; public class Main { public static void main(String args[]) { double number, t, squareRoot; Scanner input = new Scanner(System.in); number = input.nextDouble(); squareRoot = number / 2; do { t = squareRoot; squareRoot = (t + (number / t))...

My team and I came across the same problem a year or two ago. MathWorks explained that the sqrt() function has an issue with powers when they are added. To overcome this issue and achieve the same result, square each term outside of the sqrt() function: input1 = 4^2; input2...

The problem does not say to ignore the integer part of the numbers. By specifying a precision of 100 decimal digits simply means that 100 digits will be used during the computations not that you'll get the first 100 exact decimal digits. Simply increase the precision to ensure the...

You have to find a spigot algorithm that caluclates one digit after another and then append digits to your result display as you find them. (To find an algorithm, you'd have to ask on mathoverflow or use google.)

applescript,calculator,square-root

You can just set the exponent to 0.5. For example: set num_ to 25.1 set sqrt_ to num_ ^ 0.5 ...

I have created a working version of your program. The instructions you provided give us a bunch of steps that I used in my code. As the procedure indicates, we first locate the integer part and try to find the "closest" square. In the given example, the "closest" square to...

lua,double,rounding,square-root

The variable is not irrational, it is floating-point, so it isn't even real. (the square-root of 2 is irrational though, and thus cannot be accurately represented by it) Just use more digits for your literal, and the round-trip conversion will work. An IEEE double-precision floating-point value needs 17 significant decimal...