Newton Method MIPS
Newton’s Method Calculation
A quadratic equation with one variable is a equation that can be rearranged
in standard form as ax? + be + c= 0
where a ( a ‡ 0 ), b, and c are constants.
The Newton’s method is an iterative method that can be used to find the roots of a
function. It involves choosing an initial guess and then repeatedly refining it until the
solution is found.
In this problem, we are going to use the Newton’ method to solve a quadratic equation with
one variable. The inputs correspond to values a, b, and c respectively and the output are
the solutions 21 and X2 in increasing order.
1. All the numbers in the calculation are taken as single-precision float.
2. We make sure there must be two different solutions to this equation.
3. We make sure a, b and c are non-zero.
4. When you substitute your solution 2’n
into the equation, the absolute value of the
result f(In) should be less than 1e-6. Once a result satisfying to this precision, it
is considered to be a correct result, and iteration cannot be continued.
5. You can use abs.s to get the absolute value.
6. About the output, there is only one newline between the smaller value and the bigger
The process is like this:
After reading a, b and c, first calculate
, then minus le-6 as the first guess
2 /Smaller for smaller 2n , and add 1e-6 as the first guess 2f Bigger
for bigger In
Let’s calculate smaller I’n
as an example. The euation is like f(x) = ax? + ba + c ,and
calculate f(2n)| with our first guess fSmaller , and check whether f(2n) is less
than le-6. If it satisfies, then this In is one of the results, but if not, calculate 2n+1
like this 2n+1
as the next iteration’s input.