I need to write a program to find the square root using the Newton-Raphson Method using a guess estimate. the equation for the Newton-Raphson Method is:
xn+1 = xn-xn**2 − a/2*xn
whereby n is the number of iterations.
The assignment tells me that a loop should be performed between 1 and the total number of specified iterations. and also Each step of the loop, the current value of the ‘solution’ should be used to calculate the next value of the solution, in the form specified by the equation.
Hint: Remember, the assignment of a value for a variable evaluates the right side of the equals before performing the assignment itself. This means only one variable for x is needed to calculate each new value; you don’t need ‘old_x’ and ‘new_x’ or similar.
This is what i have so far:
program assign_10_2
implicit none
real :: a, b, x
integer :: c, i, j
write(*,*) 'please enter a value to determine the square root of'
read(*,*) a
write(*,*) 'please enter a value to use as the initial guess for the solution'
read(*,*) b
write(*,*) 'please enter a value for how many iterations it should perform to calculate the value'
read(*,*) c
write(*,*) a, b , c
do i= 1, c, 1
x = b-((b**2-a)/2*b)
write(*,*) i, x
end do
end program assign_10_2
I am by no means asking for the answer just a push in the right direction I am completely new to programming and its all very confusing to me. I know that I have done something wrong with regards to the equation.