ass4_solutions

ass4_solutions - solutions.txt Mon Jan 16 14:32:12 2012 1 1:

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: solutions.txt Mon Jan 16 14:32:12 2012 1 1: 2:******************************************* 3:./q1_ans/roots.f90 4: 5:PROGRAM roots 6:!******* Main program for root finding 7:!* 8:!* Uses bisection and newton-raphson from the 9:!* module "roots_mod" 10: 11: USE roots_mod !*** Use the required module 12: 13: !REAL :: a=-20,b=0 !** Equation One 14: !REAL :: a=-1,b=1 !** Equation Two 15: !REAL :: a=1,b=2 !** Equation Three 16: REAL :: x=12 !** Newton Raphson 17: 18: REAL :: root 19: REAL, PARAMETER :: tol=0.0001 20: 21: INTEGER :: i,iters 22: INTEGER, PARAMETER :: maxiters=200 23: LOGICAL, PARAMETER :: output=. TRUE . 24: LOGICAL, DIMENSION(2) :: conv 25: 26: root=newt_raph(x,tol,maxiters,iters,conv,output) !** Return root in x 27: 28: !root=bisection(a,b,tol,maxiters,iters,conv,output=. TRUE .) 29: 30: IF (conv(1)) THEN 31: PRINT(/, "The root is estimated as : " ,F10.6),root !** Bisection 32: PRINT( "The number of iterations taken was" ,i5),iters 33: ELSE 34: PRINT*, "Unsuccessful Convergence" 35: ENDIF 36: 37: IF (conv(2)) PRINT*, "Max iters exceeded : Unsuccessful Convergence" 38: 39:END PROGRAM roots 40: 41:******************************************* 42: 43: 44:******************************************* 45:./q1_ans/res.f90 46: 47:================== RESULTS ================= 48: 49:Equation One 50:============ 51: 52: Iters a b root f(root) 53: 1 -20.000000 0.000000 -10.000000 0.767387 54: 2 -20.000000 -10.000000 -15.000000 0.414978 55: 3 -20.000000 -15.000000 -17.500000 0.188819 56: 4 -20.000000 -17.500000 -18.750000 0.068040 57: 5 -20.000000 -18.750000 -19.375000 0.006490 58: 6 -20.000000 -19.375000 -19.687500 -0.024472 59: 7 -19.687500 -19.375000 -19.531250 -0.008979 60: 8 -19.531250 -19.375000 -19.453125 -0.001241 61: 9 -19.453125 -19.375000 -19.414062 0.002626 62: 10 -19.453125 -19.414062 -19.433594 0.000693 63: 11 -19.453125 -19.433594 -19.443359 -0.000274 64: 12 -19.443359 -19.433594 -19.438477 0.000209 65: 13 -19.443359 -19.438477 -19....
View Full Document

This note was uploaded on 02/13/2012 for the course MATH 5806 taught by Professor Brooks during the Fall '10 term at Minnesota.

Page1 / 2

ass4_solutions - solutions.txt Mon Jan 16 14:32:12 2012 1 1:

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online