HW6.1_solutions

# HW6.1_solutions - Real f,a,b,L,MP Integer step a=1 b=2 L =...

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

Ch. 6, Problem 10 Program binom Integer n,k,bicoef,fact *implement do loops to calculate binomial coefficients with n running from 0-10 *and k running from 0 through n for every such n. DO 10 n = 1,10 DO 10 k = 0,n bicoef = fact(n)/(fact(k) * fact(n-k)) print'(A1,I2,A1/A1,I2,A1)','(',n,')','(',k,')' print*, 'binomial coefficient =',bicoef 10 continue END *function subprogram to calculate factorials Function fact(n) Integer n,i,fact fact=1 Do 10 i= 2,n fact = fact*i 10 continue RETURN END ------------------------------------------- Ch. 6, Problem 19 Program bisec

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Real f,a,b,L,MP Integer step a=1. b=2. L = b-a step = 0 *implement do while condition to keep bisecting subintervals and determining in which *half f changes sign until a very small length subinterval is reached and a solution *is determined DO WHILE (abs(L) .GT. 0.0000000001) MP = (a+b)/2 IF ((f(a)*f(MP)) .LT. 0)THEN B = MP L = b-a ELSE A = MP L = b-a ENDIF step = step + 1 ENDDO print*, 'A solution of (x**3 + x - 5) is:',MP END *define function to find root of FUNCTION f(x) REAL f,x f = x**3 + x -5 RETURN END...
View Full Document

{[ snackBarMessage ]}

### Page1 / 2

HW6.1_solutions - Real f,a,b,L,MP Integer step a=1 b=2 L =...

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

View Full Document
Ask a homework question - tutors are online