this is bairstow's method , i need to put newton-raphson in a subroutine and i don't know whats wrong i keep getting the wrong answer when i execute please help(adsbygoogle = window.adsbygoogle || []).push({});

Code (Text):

parameter (np=100)

parameter (eps=1e-3)

real a(np) ,b(np),c(np)

real r ,s ,ri,si

integer n,i

write(*,*)'n,r,s'

read(*,*)n,r,s

do i=n+1,1,-1

write(*,*)'a(i)'

read(*,*) a(i)

end do

10 ri=r

si=s

b(n+1)=a(n+1)

b(n)=a(n)+r*b(n+1)

do i=n-1,1,-1

b(i)=a(i)+r*b(i+1)+s*b(i+2)

end do

c(n+1)=b(n+1)

c(n)=b(n)+r*c(n+1)

do i=n-1,1,-1

c(i)=b(i)+r*c(i+1)+s*c(i+2)

end do

do i=n+1,1,-1

write(*,*) i,a(i),b(i),c(i)

end do

write(*,*)

d=c(3)*c(3)-c(2)*c(4)

r=r-(1./d)*(c(3)*b(2)-c(4)*b(1))

s=s-(1./d)*(-c(2)*b(2)+c(3)*b(1))

if(sqrt(ri**2-r**2).ge.eps.or.sqrt(si**2-s**2).ge.eps) goto 10

write(*,*) r,s

end

thanks in advance :)

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# I need help in Fortran please -- Bairstow's method & Newton-Raphson

Have something to add?

Draft saved
Draft deleted

Loading...

Similar Threads - need help Fortran | Date |
---|---|

Need help with FORTRAN | Jun 8, 2016 |

I need help to solve ODE with rk4 y" + 2y =0 in fortran | Jun 4, 2015 |

FORTRAN Code Error - Need Help | Mar 13, 2013 |

Need Help with my Fortran Code | Mar 9, 2013 |

Need help in Fortran | Dec 24, 2012 |

**Physics Forums - The Fusion of Science and Community**