Sie sind auf Seite 1von 10

CF 1 LAB ASSIGNMENT 12

Task 1:
Open the file Excel 1 in the folder. Use functions to calculate statistics for the
Storeys, Metres, and Cost columns.

Result:

Task 2:
Open the file Excel 2 in the folder. Create an If function to rate the players based
on the following criteria: If a player scores more than 15 points he has a High score.
Otherwise he must Try harder. Copy the function down to rate all the players.

Result:

Task 3:
Convert the data in Excel 3 into a line chart.

Result:

MS-25710

AHMED SIDDIQUE

Weight Fluctuations over 4 Weeks

Task 4:
Open the file Excel 4 in the folder. Draw a scatter graph using data in the first 2
columns, 9 rows. Draw a linear trend line and enter the values of slope and
intercept. Use these values to forecast the values of resistance at temperatures 22,
0, and 100.

Result:

Task 5:
A radioactive substance has a half-life of 5 sec, generate the data yourself in an
excel sheet showing the number of atoms with time upto 100 sec. Take initial N as

MS-25710

AHMED SIDDIQUE

100000. Now draw the semi log graph for the radioactive decay showing the
logarithmic nature.

Result:

Task 6:
Apply Newton Raphson method to find the solution of f(x). Take initial x as 1 Stop
the simulation once the difference between x i and xi+1 is less than 0.005. That xi will
be considered as our solution.

Codes for program:


PROGRAM NEWTON RAPHSON METHOD
! PROROGRAM STATEMENT
! \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
! FOR AN EQUATION F(X) AND ITS DERIVATIVE APPLY NEWTON
! RAPHSON METHOD TO FIND THE SOLUTION OF F(X). TAKE
! INITIAL X AS 0 AND FIND THE NEXT VALUE
! STOP THE SIMULATION ONCE THE DIFFERENCE BETWEEN XI
! AND XI+1 IS LESS THAN 0.005. THAT XI WILL BE
! CONSIDERED AS OUR SOLUTION.
! \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
! VARIABLE DECLARATION
! =====================================

MS-25710

AHMED SIDDIQUE

IMPLICIT NONE
REAL X,XI,XJ,A,B
INTEGER I
PRINT'(/,A)','----------LAB 12 TASK 6------------'
PRINT'(/,A)','

NEWTON RAPHSON METHOD'

! INPUT
! =====================================
PRINT'(/,A)','This program will return the value of f(x) for
2 following expressions'
PRINT'(/,A)','f(x) = x^3 - 8'
PRINT'(/,A)','f''(x) = 3x^2'
! INITILIZATION OF VARIABLES
! =====================================
XJ = 1.0
! CALCULATINS AND RESULT
! =====================================
10

XI = XJ
A = (XI**3) - 8.0
B = 3.0*(XI**2)
XJ = XI - (A/B)
IF (ABS(XJ-XI).GE.0.005) GO TO 10
X = XJ
PRINT'(/,A,F8.3)','The solution of equation is ',X

END PROGRAM NEWTON RAPHSON METHOD

MS-25710

AHMED SIDDIQUE

Result:

Task 7:
Bisection method is used to solve the transcendental equations. This scheme is
based on the intermediate value theorem for continuous functions. Consider a
transcendental equation f (x) = 0 which has a zero in the interval [a,b] and f (a) * f
(b) < 0. Bisection scheme computes the zero, say c, by repeatedly halving the
interval [a,b]. That is, starting with c = (a+b) / 2 the interval [a,b] is replaced either
with [c,b] or with [a,c] depending on the sign of f (a) * f (c) . This process is
continued until the zero is obtained.

Codes for program:


PROGRAM BISECTION METHOD
! PROROGRAM STATEMENT
! \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
! BISECTION METHOD IS USED TO SOLVE THE TRANSCENDENTAL
! EQUATIONS. THIS SCHEME IS BASED ON THE INTERMEDIATE
! VALUE THEOREM FOR CONTINUOUS FUNCTIONS.
! \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
! VARIABLE DECLARATION
! =====================================
IMPLICIT NONE
MS-25710

AHMED SIDDIQUE

REAL X,A,B, C, TOLL, YA, YB, YC


INTEGER I, N
PRINT'(/,A)','----------LAB 12 TASK 7------------'
PRINT'(/,A)','

BISECTION METHOD'

! INPUT
! =====================================
PRINT'(/,A)','This program will solve for f(x)'
PRINT'(/,A)','f(x) = 3x + sin(x) - exp(x) = 0'
PRINT*,'Enter the number of iterations you want to perform'
READ*,N
!read*,a
! INITILIZATION OF VARIABLES
! =====================================
TOLL = 0.005
A = 1.0
B = 10.0
I=0
900

FORMAT (/,1X,A,F8.3)

910

FORMAT(/,1X,A,I3,A)
! CALCULATINS AND RESULT
! =====================================

10

I=I+1
IF (I.GT.N) THEN
PRINT 910 ,'Method failed after ',N,' iterations'
ELSE
X=A
YA = (3.0*X) + SIN(X*3.14159/180.0) - EXP(X)
X=B
YB = (3.0*X) + SIN(X*3.14159/180.0) - EXP(X)
C = (A + B)/2.0

MS-25710

AHMED SIDDIQUE

X=C
YC = 3.0*X + SIN(X*3.14159/180.0) - EXP(X)
IF (ABS(YC).LE.TOLL.OR.YC.EQ.0.0) THEN
PRINT 900 ,'With tolrence of 0.005 final value of f(x) is ',YC
PRINT 900 ,'The solution is ',C
GO TO 20
END IF
IF (YC.GT.0.0) THEN
A=C
GOTO 10
ELSE IF (YC.LT.0.0) THEN
B=C
GOTO 10
ELSE
END IF
20

END IF

END PROGRAM BISECTION METHOD

MS-25710

AHMED SIDDIQUE

Result:

Task 8:
Solve the given integral using simpson rule

Codes for program:


PROGRAM SIMPSON RULE
! VARIABLE DECLARATION
! =====================================
IMPLICIT NONE
REAL A,B

! INTERVAL FOR INTEGRATION

REAL X,Y(200), Z(200) ! VARIABLE FOR FUNCTION AND ITS OUTPUT


REAL DX

! DELTA X

REAL INTGC, INTGA


ACTUAL)

! INTEGRAL OF GIVEN FUNCTION (CALCULATED AND

REAL SUM
INTEGER N

! NO. OF SUBINTERVALS

INTEGER I
PRINT'(/,A)','----------LAB 12 TASK 8------------'
PRINT'(/,A)','

MS-25710

SIMPSON RULE'

AHMED SIDDIQUE

! INPUT
! =====================================
PRINT'(/,A)','This program is for calculating
2integral of EXP(X^2)'
! INITILIZATION OF VARIABLES
! =====================================
A = 0.0
B = 2.0
N=4
INTGA = 16.45262776
900

FORMAT (/,2X,A,8X,A,15X,A)

910

FORMAT(/,6X,I3,2(12X,A,F10.7))
! CALCULATINS AND RESULT
! =====================================
PRINT 900 ,'Sub-intervals','Simpson approx.','Error'
DO WHILE (N.LT.128)
SUM = 0.0
N = N*2
DX = (B-A)/N
DO I = 1,N + 1
X = A + DX*(I-1)
Y(I) = EXP(X**2)
IF (I.EQ.1.OR.I.EQ.N+1) THEN
Z(I) = Y(I)
ELSE IF (MOD(I,2).EQ.0) THEN
Z(I) = 4.0*Y(I)
ELSE
Z(I) = 2.0*Y(I)
END IF
SUM = SUM + Z(I)

MS-25710

AHMED SIDDIQUE

END DO
INTGC = (DX/3.0)*SUM
PRINT 910 ,N,' ',INTGC,'

',INTGC-INTGA

END DO
END PROGRAM SIMPSON RULE

Result:

MS-25710

AHMED SIDDIQUE

Das könnte Ihnen auch gefallen