0% found this document useful (0 votes)
53 views211 pages

An Educational Numerical Methods Package PDF

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 211

UNIVERSITY OF JORDAN

FACULTY OF ENGINEERING AND TECHNOLOGY


ELECTRICAL ENGINEERING DEPARTMENT

B. SC. GRADUATION PROJECT


"AN EDUCATIONAL NUMERICAL METHODS PACKAGE FOR
SOLVING PARTIAL-DIFFERENTIAL EQUATIONS"

BY : YOUSOF H. KUTKUT
ADVISOR : DR. SOUHEIL F. ODEH

MAY 1994
AMMAN - JORDAN
 7R/LIHDQGWR6SLULW
 7R)DPLO\*RRG7LPHV
DQG*RRG)ULHQGV
III

PREFACE
This project was proposed by Dr. Souheil F. Odeh as a graduation requirement
from the E.E. Department at the University of Jordan, it was one among many other
projects proposed by faculty members in the Department at that time.

It was originally proposed under the name, start of quote "All the learned1 numerical
methods for solving Elliptic, Parabolic, and Hyperbolic PDEs will be programmed and
integrated into a user-friendly interactive educational software package written in C. The
Elliptic type must include Dirichlet, Neumann, and Mixed Boundary Value Problems.
The software must utilize the various techniques such as Gauss-Seidel, A.D.I. method,
Direct method, and the Crank-Nicolson method." end of quote.

I chose this project to be my graduation project since I like working on numerical


methods, and I realized that there's extensive use of Partial-Differential Equations (PDEs)
in almost all scientific fields. Before taking this project I had no idea about anything even
related to the C language, so I started from scratch and learned what I needed in order to
accomplish my task. The compiler used was Borland C version 3.1, and I used the project
facility presented in that version for multi-file projects.

Working on the project I found that there was a great number of cases of PDEs and
various numerical methods that gave optimal solutions for numerous cases, that were not
originally required by the assigned project, in spite of that I decided to program as much
of these as possible so the user2 of the package would be able to solve his/her problem in
as many different numerical methods as possible. Taking generality of the cases presented
and memory requirements into consideration, the package ended in giving the user 150
options to choose from.

A user-friendly and educational approach was also taken into consideration while
programming the package, even though some numerical methods gave faster and more
accurate results than others, the user was given the choice to use any of the numerical
methods3 he/she wishes for solving his/her PDE.

All numerical methods used were of iterative nature due to the extreme advantages gained
when using iterative methods in solving PDEs by Finite-Difference. The direct method
was not presented as an option. The reasons behind undertaking this approach are
clarified in the Introduction.
1: According to [5] under numerical methods for solving PDEs, pp. 1082 - 1106.
2: Emphasizing on the problems that are usually encountered in the engineering field.
3: Complete listing of all numerical methods used and PDE cases encountered are given in Chapter 1.

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


PREFACE IV

Acknowledgments are a bore for the reader, but a source of true pleasure to the author. In
spite of my desire for pleasure, omissions from this list were inevitable, and for this I
apologize.

I wish to extend my depth of gratitude to the following people:

To Dr. Souheil Odeh for his continuous guidance and efforts throughout my study in the
E.E. Department at the University of Jordan and in particular during the work on this
project.

To All faculty members in the E.E. Department at the University of Jordan, to whom I
owe a great deal, for their helping me to see beyond what one usually expects to see.

Also to my friends Bashar Arafeh, Nael Shabaro, Ra'ed Al-Zyoud, Rami Odwan, Ayman
Hamed and Ali Ghrayeb who have been a supporting hand all throughout.

Lastly but certainly mostly, to my parents who have been all that I could ever ask for, and
for putting up with me through all my ups and downs.

Yousof H. Kutkut

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


V

$%#%
7KLV SURMHFW UHSRUWV RQ WKH ZRUN GRQH WR SURJUDP D XVHU IULHQGO\ HGXFDWLRQDO QXPHULFDO

PHWKRGV SDFNDJH IRU VROYLQJ 3DUWLDO'LIIHUHQWLDO (TXDWLRQV 3'(V RI (OOLSWLF

3DUDEROLF DQG +\SHUEROLF W\SHV LQ &

$OO QXPHULFDO PHWKRGV XVHG ZHUH RI LWHUDWLYH QDWXUH WR WDNH DGYDQWDJH RI WKH VSDUVH DQG

GLDJRQDOO\ GRPLQDQW PDWULFHV WKDW UHVXOW ZKHQ VROYLQJ WKH 3'(V E\ ILQLWHGLIIHUHQFH

7KH ZRUN ZDV FDUULHG RXW LQ & $OO QXPHULFDO PHWKRGV XVHG DQG WKH YDULRXV FDVHV RI

3'(V HQFRXQWHUHG DUH OLVWHG LQ FKDSWHU  7KH WKHRU\ EHKLQG WKH ZRUN FDUULHG RXW LV

SUHVHQWHG LQ FKDSWHUV   DQG  $ OLVWLQJ RI WKH VRIWZDUH ZULWWHQ LV SURYLGHG LQ

$SSHQGL[ %

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


VI

STATEMENT
The work described in this project has been carried out entirely by the author under the
supervision of Dr. Souheil Odeh in the department of Electrical Engineering, University
of Jordan. Except where reference is made to other authors, the work presented is
original.

......................................
Yousof H. Kutkut

......................................
Dr. Souheil F. Odeh

Date ..................................

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


VII

7$%/(2)
&217(176
&KDSWHU  ,QWURGXFWLRQ 

 3DUWLDO'LIIHUHQWLDO (TXDWLRQV 

 (OOLSWLF (TXDWLRQV 


 3DUDEROLF (TXDWLRQV
 +\SHUEROLF (TXDWLRQV

 0HWKRGV 2I 6ROXWLRQ 


 :K\ ,WHUDWLYH 1XPHULFDO 0HWKRGV" 
 :KDW 0DNHV 7KLV 3DFNDJH 'LIIHUHQW"
,Q :KDW $VSHFWV ,V 7KLV 3DFNDJH 8VHU)ULHQGO\ (GXFDWLRQDO" 

,Q ZKDW VHQVH LV WKLV SDFNDJH (GXFDWLRQDO" 


,V WKH SDFNDJH UHDOO\ XVHUIULHQGO\" 

 &DVHV 2I 3'(V 3UHVHQWHG %\ 7KH 3DFNDJH 7KH 1XPHULFDO 0HWKRGV 8VHG )RU
6ROYLQJ 7KHP 

 7\SHV RI (OOLSWLF 3DUWLDO'LIIHUHQWLDO (TXDWLRQV 

,  &DVHV RI WKH (OOLSWLF 3'(  'LULFKOHW 3UREOHP ZLWK 5HJXODU


%RXQGDULHV 
,,  1XPHULFDO ,WHUDWLYH 0HWKRGV 8VHG IRU VROYLQJ WKH (OOLSWLF 3'(
ZLWK 'LULFKOHW &RQGLWLRQV 5HJXODU %RXQGDULHV  )RU HDFK RI WKH
SUHYLRXV FDVHV 
,,,  &DVHV RI WKH (OOLSWLF 3'(  'LULFKOHW 3UREOHP ZLWK ,UUHJXODU
%RXQGDULHV 1RQUHFWDQJXODU JULGV WKH 1XPHULFDO ,WHUDWLYH
0HWKRGV 8VHG IRU VROYLQJ WKHP 
,9  &DVHV RI WKH (OOLSWLF 3'(  1HXPDQQ 3UREOHP ZLWK 5HJXODU
%RXQGDULHV 
9  1XPHULFDO ,WHUDWLYH 0HWKRGV 8VHG IRU VROYLQJ WKH (OOLSWLF 3'(
ZLWK 1HXPDQQ &RQGLWLRQV 5HJXODU %RXQGDULHV  )RU HDFK RI
WKH SUHYLRXV FDVHV 
9,  &DVHV RI WKH (OOLSWLF 3'(  0L[HG 3UREOHP ZLWK 5HJXODU
%RXQGDULHV 
9,,  1XPHULFDO ,WHUDWLYH 0HWKRGV 8VHG IRU VROYLQJ WKH (OOLSWLF 3'(
ZLWK 0L[HG &RQGLWLRQV 5HJXODU %RXQGDULHV  )RU HDFK RI WKH
SUHYLRXV FDVHV 

 &DVHV RI WKH 3DUDEROLF 3'(  ZLWK 5HJXODU %RXQGDULHV WKH


1XPHULFDO ,WHUDWLYH 0HWKRGV 8VHG IRU VROYLQJ WKHP 

 &DVHV RI WKH +\SHUEROLF 3'(  ZLWK 5HJXODU %RXQGDULHV WKH


1XPHULFDO ,WHUDWLYH 0HWKRGV 8VHG IRU VROYLQJ WKHP 

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


TABLE OF CONTENTS VIII

&KDSWHU  1XPHULFDO 0HWKRGV )RU 6ROYLQJ (OOLSWLF 3DUWLDO'LIIHUHQWLDO (TXDWLRQV 

 5HSUHVHQWDWLRQ $V $ 'LIIHUHQFH (TXDWLRQ  5HJXODU %RXQGDULHV 


 ,WHUDWLYH 0HWKRGV )RU 6ROYLQJ 7KH (TXDWLRQV 
 7KH $', 0HWKRG 

 ([DPSOHV 2Q 7KH (OOLSWLF 3'(  5HJXODU ERXQGDULHV 


 &RQVLGHULQJ D 'LULFKOHW SUREOHP  
 &RQVLGHULQJ D 0L[HG SUREOHP 

6ROXWLRQV IRU WKH 'LULFKOHW SUREOHP  


à *DXVV6HLGHO SRLQW DSSUR[LPDWLRQ )RU K  FP  
à *DXVV6HLGHO SRLQW DSSUR[LPDWLRQ )RU K  FP 
à *DXVV6HLGHO SRLQW DSSUR[LPDWLRQ )RU K  FP  
à *DXVV6HLGHO SRLQW DSSUR[LPDWLRQ )RU K  FP 
à 625 XVLQJ DQ RSWLPXP DFFHOHUDWLQJ IDFWRU SRLQW
DSSUR[LPDWLRQ )RU K  FP 
à 625 XVLQJ DQ RSWLPXP DFFHOHUDWLQJ IDFWRU SRLQW
DSSUR[LPDWLRQ )RU K  FP 
à *DXVV6HLGHO SRLQW DSSUR[LPDWLRQ )RU K  FP 
à 625 XVLQJ DQ RSWLPXP DFFHOHUDWLQJ IDFWRU SRLQW
DSSUR[LPDWLRQ )RU K  FP 
à $', ZLWKRXW S IDFWRU )RU K  FP 
à $', ZLWK RSWLPXP S IDFWRU )RU K  FP 
à $', ZLWK S IDFWRU  )RU K  FP 
à $', ZLWK S IDFWRU  )RU K  FP 

6ROXWLRQV IRU WKH 0L[HG SUREOHP 


à -DFREL SRLQW DSSUR[LPDWLRQ )RU K  FP 
à *DXVV6HLGHO SRLQW DSSUR[LPDWLRQ )RU K  FP 
à 625 XVLQJ DQ RSWLPXP DFFHOHUDWLQJ IDFWRU SRLQW
DSSUR[LPDWLRQ )RU K  FP  

 7KH (OOLSWLF 'LULFKOHW 3'(  ,UUHJXODU %RXQGDULHV 


 ([DPSOHV 2Q 7KH (OOLSWLF 'LULFKOHW 3'(  ,UUHJXODU %RXQGDULHV
 &RQVLGHULQJ D VHPLFLUFXODU ERXQGDU\
 &RQVLGHULQJ D FLUFXODU ERXQGDU\  

6ROXWLRQV IRU WKH 'LULFKOHW VHPLFLUFXODU SUREOHP 


à -DFREL 5DGLXV LQFUHPHQW  DQG DQJOH LQFUHPHQW  
à *DXVV6HLGHO 5DGLXV LQFUHPHQW  DQG DQJOH LQFUHPHQW   

6ROXWLRQV IRU WKH 'LULFKOHW FLUFXODU SUREOHP 


à -DFREL 5DGLXV LQFUHPHQW  DQG DQJOH LQFUHPHQW 
à *DXVV6HLGHO 5DGLXV LQFUHPHQW  DQG DQJOH LQFUHPHQW  

&KDSWHU  1XPHULFDO 0HWKRGV )RU 6ROYLQJ 3DUDEROLF 3DUWLDO'LIIHUHQWLDO (TXDWLRQV 

 7KH ([SOLFLW 0HWKRG 

([DPSOH RQ WKH ([SOLFLW PHWKRG 


à 6ROXWLRQ E\ WKH ([SOLFLW PHWKRG ZLWK U 
à 6ROXWLRQ E\ WKH ([SOLFLW PHWKRG ZLWK U 

 7KH &UDQN1LFROVRQ 0HWKRG 

([DPSOH RQ WKH &UDQN1LFROVRQ PHWKRG 

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


TABLE OF CONTENTS IX

à 6ROXWLRQ E\ WKH &UDQN1LFROVRQ PHWKRG ZLWK U 


à 6ROXWLRQ E\ WKH &UDQN1LFROVRQ PHWKRG ZLWK U  
à 6ROXWLRQ E\ WKH &UDQN1LFROVRQ PHWKRG ZLWK U  

 'HULYDWLYH %RXQGDU\ &RQGLWLRQV

([DPSOH RQ 'HULYDWLYH %RXQGDU\ &RQGLWLRQV 


à 6ROXWLRQ E\ WKH ([SOLFLW PHWKRG ZLWK U 
à 6ROXWLRQ E\ WKH &UDQN1LFROVRQ PHWKRG ZLWK U 

 7ZR'LPHQVLRQDO 3DUDEROLF (TXDWLRQV DQG 7KH $', 0HWKRG 

([DPSOH RQ WKH $', PHWKRG 


à 6ROXWLRQ E\ WKH $', PHWKRG ZLWK U  

&KDSWHU  1XPHULFDO 0HWKRGV )RU 6ROYLQJ +\SHUEROLF 3DUWLDO'LIIHUHQWLDO (TXDWLRQV 

 6ROYLQJ 7KH :DYH (TXDWLRQ %\ )LQLWH'LIIHUHQFHV 


 ([DPSOH 2Q 7KH 2QH'LPHQVLRQDO :DYH HTXDWLRQ

3UREOHP VWDWHPHQW 


à 6ROXWLRQ E\ ILQLWHGLIIHUHQFHV ZLWK K  FP 
à 6ROXWLRQ E\ ILQLWHGLIIHUHQFHV ZLWK K  FP 

 7KH :DYH (TXDWLRQ ,Q 7ZR'LPHQVLRQV 


 ([DPSOH 2Q 7KH 7ZR'LPHQVLRQDO ZDYH HTXDWLRQ

3UREOHP VWDWHPHQW 


à 6ROXWLRQ E\ ILQLWHGLIIHUHQFHV ZLWK K  FP U  

$SSHQGL[ $  5HIHUHQFHV 

$SSHQGL[ %  7DEOH RI %ULHI )LOH 'HVFULSWLRQ 6RXUFH &RGH RI $OO 3URJUDP )LOHV

à 7DEOH VKRZLQJ WKH SDJHV WKDW OLVW WKH VRXUFH FRGH IRU HDFK ILOH PHQWLRQHG 
3ODLQ OLVWLQJ RI WKH VRXUFH FRGH RI DOO ILOHV XVHG LQ .XWNXW
V 1XPHULFDO 3'( 6ROYHU 

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


PAGE 1


 &+$37(5 

,1752'8&7,21
7KH QXPHULFDO WUHDWPHQW RI SDUWLDOGLIIHUHQWLDO HTXDWLRQV LV D YDVW VXEMHFW 3DUWLDO

GLIIHUHQWLDO HTXDWLRQV DUH DW WKH KHDUW RI PDQ\ LI QRW PRVW FRPSXWHU DQDO\VHV RU

VLPXODWLRQV RI FRQWLQXRXV SK\VLFDO V\VWHPV VXFK DV IOXLGV HOHFWURPDJQHWLF ILHOGV WKH

KXPDQ ERG\ $SSOLFDWLRQV DUH DOVR IRXQG LQ VWHDG\VWDWH KHDW IORZ HOHFWULFDO SRWHQWLDO

GLVWULEXWLRQV DQG VR RQ

7KH LQWHQW RI WKLV FKDSWHU LV WR JLYH WKH EULHIHVW SRVVLEOH XVHIXO LQWURGXFWLRQ WR SDUWLDO

GLIIHUHQWLDO HTXDWLRQV DQG WR WKH JRDO RI WKLV SURMHFW ZKLFK LV WKH VRIWZDUH SDFNDJH

GHYHORSHG WR VROYH WKHP

 3$57,$/',))(5(17,$/(48$7,216

7KH PDWKHPDWLFDO IRUPXODWLRQ RI PRVW SUREOHPV LQ VFLHQFH LQYROYLQJ UDWHV RI FKDQJH

ZLWK UHVSHFW WR WZR RU PRUH LQGHSHQGHQW YDULDEOHV XVXDOO\ UHSUHVHQWLQJ WLPH OHQJWK RU

DQJOH OHDGV HLWKHU WR D SDUWLDOGLIIHUHQWLDO HTXDWLRQ RU WR D VHW RI VXFK HTXDWLRQV ,Q PRVW

PDWKHPDWLFV ERRNV 3DUWLDO'LIIHUHQWLDO (TXDWLRQV 3'(V DUH FODVVLILHG LQWR WKUHH

FDWHJRULHV +\SHUEROLF 3DUDEROLF DQG (OOLSWLF RQ WKH EDVLF RI WKHLU FKDUDFWHULVWLFV RU

FXUYHV RI LQIRUPDWLRQ SURSDJDWLRQ

+HQFH D VHFRQG RUGHU TXDVLOLQLHU HTXDWLRQ OLQHDU LQ WKH KLJKHVW GHULYDWLYHV LQ WZR

 &KDUDFWHULVWLFV LV DERYH WKH VFRSH RI WKLV SURMHFW DFFRUGLQJ WR >@ S  ,I WDNLQJ D VHFRQG RUGHU
∂ X ∂ X ∂ X
TXDVLOLQHDU 3'( D + E + F + H =   ZKHUH D E F DQG H PD\ EH IXQFWLRQV RI [ \
∂ [ ∂[∂\ ∂ \
∂X ∂X ∂ X ∂  X ∂ X
X DQG EXW QRW  DQG  LH WKH VHFRQGRUGHU GHULYDWLYHV RFFXU RQO\ WR WKH ILUVW
∂[ ∂\ ∂[ ∂\
 
∂ [∂ \
GHJUHH 7KHQ DW HYHU\ SRLQW LQ WKH [\ SODQH WKHUH DUH WZR GLUHFWLRQV LQ ZKLFK WKH LQWHJUDWLRQ RI WKH
3'( UHGXFHV WR WKH LQWHJUDWLRQ RI DQ HTXDWLRQ LQYROYLQJ WRWDO GLIIHUHQWLDOV RQO\ LQ RWKHU ZRUGV LQ
WKHVH GLUHFWLRQV WKH HTXDWLRQ WR EH LQWHJUDWHG LV QRW FRPSOLFDWHG E\ WKH SUHVHQFH RI SDUWLDO GHULYDWLYHV
LQ RWKHU GLUHFWLRQV )XUWKHUPRUH LW ZLOO EH VHHQ WKDW WKLV OHDGV WR D QDWXUDO FODVVLILFDWLRQ RI 3'(V )RU
IXUWKHU UHIHUHQFH FRQVXOW >@

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


INTRODUCTION PAGE 2

LQGHSHQGHQW YDULDEOHV [ \ FDQ EH ZULWWHQ


DX[[    EX[\ FX\\ ) [ \ X X[ X\ 
X LV WKH XQNQRZQ IXQFWLRQ 7KLV HTXDWLRQ LV VDLG WR EH RI
(OOLSWLF W\SH LI E  DF   H[DPSOH /DSODFH HTXDWLRQ
3DUDEROLF W\SH LI E  DF  H[DPSOH +HDW HTXDWLRQ
+\SHUEROLF W\SH LI E  DF !  H[DPSOH :DYH HTXDWLRQ
ZKHUH LQ WKH ZDYH DQG KHDW HTXDWLRQV \ LV WLPH W
1RZ JHQHUDO SURSHUWLHV DQG DSSOLFDWLRQV RI WKHVH W\SHV ZLOO EH GLVFXVVHG WR VKRZ KRZ
WKH\ FDQ EH HPSOR\HG LQ GLIIHUHQW SK\VLFDO FRQWH[WV

 (//,37,&
(48$7,216
(OOLSWLF HTXDWLRQV DUH W\SLFDOO\ XVHG WR FKDUDFWHUL]H VWHDG\VWDWH V\VWHPV 7KLV LV
LQGLFDWHG E\ WKH DEVHQFH RI D WLPH GHULYDWLYH 7KXV WKHVH HTXDWLRQV DUH W\SLFDOO\
HPSOR\HG WR GHWHUPLQH WKH VWHDG\VWDWH GLVWULEXWLRQ RI DQ XQNQRZQ LQ WZR VSDWLDO
GLPHQVLRQV
7KHVH HTXDWLRQV RI ZKLFK WKH EHVW NQRZQ DUH 3RLVVRQ
V HTXDWLRQ
 
∂ X ∂ X
+ + H = 
∂ ∂\
[
 

ZKHUH H FRXOG EH D IXQFWLRQ RI WKH LQGHSHQGHQW YDULDEOHV [ \


$QG /DSODFH
V HTXDWLRQ
 
∂ X ∂ X
+ = 
∂ [∂\  

([DPSOHV RQ WKH (OOLSWLF HTXDWLRQ


$ KHDWHG SODWH ZLWK ERXQGDULHV KHOG DW GLIIHUHQW WHPSHUDWXUHV %HFDXVH KHDW IORZV
IURP UHJLRQV RI KLJK WR ORZ WHPSHUDWXUH WKH ERXQGDU\ FRQGLWLRQV VHW XS D SRWHQWLDO
WKDW OHDGV WR KHDW IORZ IURP WKH KRW WR WKH FROG ERXQGDULHV ,I VXIILFLHQW WLPH HODSVHV
VXFK D V\VWHP ZLOO HYHQWXDOO\ UHDFK WKH VWDEOH RU VWHDG\VWDWH GLVWULEXWLRQ RI
WHPSHUDWXUH 7KH /DSODFH HTXDWLRQ DORQJ ZLWK DSSURSULDWH ERXQGDU\ FRQGLWLRQV
SURYLGHV D PHDQV WR GHWHUPLQH WKLV GLVWULEXWLRQ ,I WKHUH ZDV D KHDW VRXUFH HPEHGGHG
LQ WKH SODWH WKHQ WKH 3RLVVRQ HTXDWLRQ ZRXOG EH XVHG
%\ DQDORJ\ RWKHU SUREOHPV LQYROYLQJ SRWHQWLDOV FRXOG EH KDQGOHG LQ WKH VDPH ZD\
KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE
INTRODUCTION PAGE 3

VXFK DV WKH HOHFWULF SRWHQWLDO Y DVVRFLDWHG ZLWK D WZRGLPHQVLRQDO HOHFWURQ


GLVWULEXWLRQ RI FKDUJH GHQVLW\ ρ VDWLVILHV 3RLVVRQ
V HTXDWLRQ ∂ Y + ∂ Y + ρ = 
 

∂ [ ∂ \ ε
ZKHUH ε LV WKH GLHOHFWULF FRQVWDQW
$SSOLFDWLRQV LQYROYLQJ (OOLSWLF HTXDWLRQV XVXDOO\ OHDG WR ERXQGDU\ YDOXH SUREOHPV LQ D
UHJLRQ 5 FDOOHG D ILUVW ERXQGDU\ YDOXH SUREOHP RU 'LULFKOHW SUREOHP LI X WKH XQNQRZQ
LV SUHVFULEHG RQ WKH ERXQGDU\ FXUYH & RI 5 D VHFRQG ERXQGDU\ YDOXH SUREOHP RU
1HXPDQQ SUREOHP LI X ∂∂XQ QRUPDO GHULYDWLYH RI X LV SUHVFULEHG RQ & DQG D WKLUG RU
Q =

∂X
PL[HG SUREOHP LI X LV SUHVFULEHG RQ D SDUW RI & DQG X Q =
∂Q
RQ WKH UHPDLQLQJ SDUW & LV
XVXDOO\ D FORVHG FXUYH
 3$5$%2/,& (48$7,216
3DUDEROLF HTXDWLRQV GHWHUPLQH KRZ DQ XQNQRZQ YDULHV LQ ERWK VSDFH DQG WLPH 7KLV LV
PDQLIHVWHG E\ WKH SUHVHQFH RI ERWK VSDWLDO DQG WHPSRUDO GHULYDWLYHV
7KH SUREOHP RI XQVWHDG\VWDWH IORZ RI KHDW LV D SK\VLFDO VLWXDWLRQ WKDW FDQ EH
UHSUHVHQWHG E\ D 3DUDEROLF 3'( 7KH VLPSOHVW VLWXDWLRQ LV IRU IORZ RI KHDW LQ RQH
GLUHFWLRQ DV WKH FDVH RI D URG WKDW LV XQLIRUP LQ FURVV VHFWLRQ DQG LQVXODWHG DURXQG LWV
SHULPHWHU VR WKDW KHDW IORZV RQO\ ORQJLWXGLQDOO\  OHWWLQJ X UHSUHVHQW WKH WHPSHUDWXUH DW
DQ\ SRLQW LQ WKH URG ZKRVH GLVWDQFH IURP WKH OHIW HQG LV [
+HDW LV IORZLQJ IURP OHIW WR ULJKW XQGHU WKH LQIOXHQFH RI WKH WHPSHUDWXUH JUDGLHQW ∂X 
∂[
N UHSUHVHQWV WKHUPDO FRQGXFWLYLW\ FDOJFP &FP  ZKLFK ZH DVVXPH LV FRQVWDQW F
 R

LV WKH KHDW FDSDFLW\ FDOJFP DQG ρ LV WKH GHQVLW\ VFP ZLWK W IRU WLPH ZH KDYH

∂ X ∂X
N = FU 
∂[ ∂W


7KLV LV WKH EDVLF PDWKHPDWLFDO PRGHO IRU XQVWHDG\VWDWH IORZ :H KDYH XVHG LW IRU KHDW
IORZ EXW LW DSSOLHV HTXDOO\ WR GLIIXVLRQ RI PDWHULDO IORZ RI IOXLGV IORZ RI HOHFWULFLW\ LQ
FDEOHV WKH WHOHJUDSK HTXDWLRQV  DQG VR RQ
,Q WZR VSDFH GLPHQVLRQV LW ZLOO ORRN OLNH WKLV

∂ X ∂ X ∂X

N + = FU 
∂[ ∂\ 
∂W 

7KH IXQFWLRQ WKDW ZH ZLOO FDOO WKH VROXWLRQ WR WKH SUREOHP QRW RQO\ PXVW REH\ WKH
GLIIHUHQWLDO HTXDWLRQ JLYHQ DERYH EXW DOVR PXVW VDWLVI\ DQ LQLWLDO FRQGLWLRQ DQG D VHW RI
ERXQGDU\ FRQGLWLRQV

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


INTRODUCTION PAGE 4

)RU WKH RQH GLPHQVLRQDO KHDW IORZ SUREOHP WDNHQ DV DQ H[DPSOH WKH LQLWLDO FRQGLWLRQ ZLOO
EH WKH LQLWLDO WHPSHUDWXUHV DW DOO SRLQWV DORQJ WKH URG  =  =  WKH
X [ W W =
X [ I [

ERXQGDU\ FRQGLWLRQV ZLOO GHVFULEH WKH WHPSHUDWXUH DW HDFK HQG RI WKH URG DV D IXQFWLRQ
RI WLPH D PRUH JHQHUDO ERXQGDU\ FRQGLWLRQ ZLOO LQYROYH QRW RQO\ WKH WHPSHUDWXUH EXW
DOVR WHPSHUDWXUH JUDGLHQWV 
 +<3(5%2/,& (48$7,216
7KH WKLUG FODVVLILFDWLRQ RI 3'(V K\SHUEROLF GLIIHUHQWLDO HTXDWLRQV LQFOXGHV WKH
ZDYH
HTXDWLRQ
WKDW LV IXQGDPHQWDO WR WKH VWXG\ RI YLEUDWLQJ V\VWHPV $ YDULHW\ RI HQJLQHHULQJ
V\VWHPV VXFK DV YLEUDWLRQV RI URGV DQG EHDPV PRWLRQ RI IOXLG ZDYHV DQG WUDQVPLVVLRQ
RI VRXQG DQG HOHFWULFDO VLJQDOV FDQ EH FKDUDFWHUL]HG E\ WKLV PRGHO
7KH\ DUH DOVR LQYROYHG LQ WUDQVSRUW V\VWHPV GLIIXVLRQ RI PDWWHU QHXWURQ GLIIXVLRQ DQG
UDGLDWLRQ WUDQVIHU  ZDYH PHFKDQLFV JDV G\QDPLFV VXSHUVRQLF IORZ DQG RWKHU
LPSRUWDQW DUHDV 7KH WHFKQRORJ\ LQ PRVW RI WKHVH DSSOLFDWLRQV LV FRPSOH[ DQG DUH
EH\RQG RXU VFRSH
:H ZLOO VHWWOH IRU D VLPSOH H[DPSOH VXFK DV WKH YLEUDWLRQV RI D VWULQJ KHOG WDXW E\ IL[HG
HQGV DV LQ D YLROLQ VWULQJ WKLV JLYHV WKH RQH GLPHQVLRQDO ZDYH HTXDWLRQ LQ RQH
 
GLPHQVLRQ ZKLFK FDQ EH H[SUHVVHG DV ∂∂ X F ∂∂ X  JLYLQJ IRU H[DPSOH WKH



W [

GLVSODFHPHQW X DW D GLVWDQFH [ RI RQH HQG RI WKH YLEUDWLQJ VWULQJ RI OHQJWK / DIWHU D WLPH
W $V WKH YDOXHV RI X DW WKH HQGV RI WKH VWULQJ DUH XVXDOO\ NQRZQ IRU DOO WLPH WKH

ERXQGDU\ FRQGLWLRQV DQG WKH VKDSH DQG YHORFLW\ RI WKH VWULQJ DUH SUHVFULEHG DW ]HUR WLPH
WKH LQLWLDO FRQGLWLRQV 
7KH WZRGLPHQVLRQDO UHSUHVHQWDWLRQ RI WKH K\SHUEROLF HTXDWLRQ LV XVHIXO ZKHQ VROYLQJ D
SUREOHP RI D YLEUDWLQJ PHPEUDQH VWUHWFKHG RYHU D UHFWDQJXODU IUDPH DQG VHW WR YLEUDWH
  
,Q WZR VSDFH GLPHQVLRQV LW ZLOO ORRN OLNH WKLV ∂∂ X F ∂∂ X + ∂∂ \X


 

W [


 0(7+2'62)62/87,21
3ULRU WR WKH DGYHQW RI GLJLWDO FRPSXWHUV HQJLQHHUV UHOLHG RQ DQDO\WLFDO RU H[DFW VROXWLRQV

RI SDUWLDOGLIIHUHQWLDO HTXDWLRQV $VLGH IURP WKH VLPSOHVW FDVHV WKHVH VROXWLRQV RIWHQ

UHTXLUHG D JUHDW GHDO RI HIIRUW DQG PDWKHPDWLFDO VRSKLVWLFDWLRQ ,Q DGGLWLRQ PDQ\

SK\VLFDO V\VWHPV FRXOG QRW EH VROYHG GLUHFWO\ EXW KDG WR EH VLPSOLILHG XVLQJ

OLQHDUL]DWLRQV VLPSOH JHRPHWULF UHSUHVHQWDWLRQV DQG RWKHU LGHDOL]DWLRQV

$OWKRXJK WKHVH VROXWLRQV DUH HOHJDQW DQG \LHOG LQVLJKW WKH\ DUH OLPLWHG ZLWK UHVSHFW WR

KRZ IDLWKIXOO\ WKH\ UHSUHVHQW UHDO V\VWHPV

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


INTRODUCTION PAGE 5

7DNLQJ WKH (OOLSWLF HTXDWLRQ DV D FDVH VWXG\ RQO\ D OLPLWHG QXPEHU RI VSHFLDO W\SHV RI

(OOLSWLF HTXDWLRQV KDYH EHHQ VROYHG DQDO\WLFDOO\ DQG WKH XVHIXOQHVV RI WKHVH VROXWLRQV LV

IXUWKHU UHVWULFWHG WR SUREOHPV LQYROYLQJ VKDSHV IRU ZKLFK WKH ERXQGDU\ FRQGLWLRQV FDQ

EH VDWLVILHG 7KLV QRW RQO\ HOLPLQDWHV DOO SUREOHPV ZLWK ERXQGDU\ FXUYHV WKDW DUH

XQGHILQHG LQ WHUPV RI HTXDWLRQV EXW DOVR PDQ\ IRU ZKLFK WKH ERXQGDU\ FRQGLWLRQV DUH

WRR GLIILFXOW WR VDWLVI\ DOWKRXJK WKH HTXDWLRQV IRU WKH ERXQGDU\ FXUYHV DUH NQRZQ ,Q

VXFK FDVHV DSSUR[LPDWLRQ PHWKRGV ZKHWKHU DQDO\WLFDO RU QXPHULFDO LQ FKDUDFWHU DUH

WKH RQO\ PHDQV RI VROXWLRQ DSDUW IURP WKH XVH RI DQDORJ GHYLFHV $QDO\WLFDO

DSSUR[LPDWLRQ PHWKRGV RIWHQ SURYLGH H[WUHPHO\ XVHIXO LQIRUPDWLRQ FRQFHUQLQJ WKH

FKDUDFWHU RI WKH VROXWLRQ IRU FULWLFDO YDOXHV RI WKH GHSHQGHQW YDULDEOHV EXW WHQG WR EH

PRUH GLIILFXOW WR DSSO\ WKDQ WKH QXPHULFDO PHWKRGV DQG ZLOO QRW EH GLVFXVVHG IXUWKHU

2I WKH QXPHULFDO DSSUR[LPDWLRQ PHWKRGV DYDLODEOH IRU VROYLQJ 3'(V WKRVH HPSOR\LQJ

ILQLWHGLIIHUHQFHV DUH PRUH IUHTXHQWO\ XVHG DQG PRUH XQLYHUVDOO\ DSSOLHG WKDQ DQ\ RWKHU 7KH

ZRUG DSSUR[LPDWH VKRXOG EH FODULILHG ILQLWHGLIIHUHQFH PHWKRGV DUH DSSUR[LPDWH LQ WKH

VHQVH WKDW GHULYDWLYHV DW D SRLQW DUH DSSUR[LPDWHG E\ GLIIHUHQFH TXRWLHQWV RYHU D VPDOO
∂X δX
LQWHUYDO LH LV UHSODFHG E\ ZKHUH δ[ LV VPDOO EXW WKH VROXWLRQV DUH QRW
∂[ δ[
DSSUR[LPDWH LQ WKH VHQVH RI EHLQJ FUXGH HVWLPDWHV 7KH GDWD RI SUREOHPV RI WHFKQRORJ\

DUH LQYDULDEO\ VXEMHFW WR HUURUV RI PHDVXUHPHQW EHVLGHV ZKLFK DOO DULWKPHWLFDO ZRUN LV

OLPLWHG WR D ILQLWH QXPEHU RI VLJQLILFDQW ILJXUHV DQG FRQWDLQV URXQGLQJ HUURUV VR HYHQ

DQDO\WLFDO VROXWLRQV SURYLGH RQO\ DSSUR[LPDWH QXPHULFDO DQVZHUV )LQLWHGLIIHUHQFH

PHWKRGV JHQHUDOO\ JLYH VROXWLRQV WKDW DUH HLWKHU DV DFFXUDWH DV WKH GDWD ZDUUDQW RU DV

DFFXUDWH DV LV QHFHVVDU\ IRU WKH WHFKQLFDO SXUSRVHV IRU ZKLFK WKH VROXWLRQV DUH UHTXLUHG

,Q ERWK FDVHV WKH VROXWLRQ JLYHQ E\ D ILQLWHGLIIHUHQFH PHWKRG LV DV VDWLVIDFWRU\ DV RQH

FDOFXODWHG IURP DQ DQDO\WLFDO IRUPXOD 7KH\ DUH QRW RI FRXUVH UHVWULFWHG WR SUREOHPV IRU

ZKLFK QR DQDO\WLFDO VROXWLRQV FDQ EH IRXQG

,Q QXPHULFDO PHWKRGV XVLQJ ILQLWHGLIIHUHQFH WKH DUHD RI LQWHJUDWLRQ RI WKH 3'( 6

ERXQGHG E\ D FXUYH & LV RYHUODLG E\ D V\VWHP RI UHFWDQJXODU PHVKHV IRUPHG E\ WZR

VHWV RI HTXDOO\ VSDFHG OLQHV RQH VHW SDUDOOHO WR WKH [D[LV WKH RWKHU SDUDOOHO WR WKH \D[LV

DQG DQ DSSUR[LPDWH VROXWLRQ WR WKH GLIIHUHQWLDO HTXDWLRQ LV IRXQG DW WKH SRLQWV RI

LQWHUVHFWLRQ 3 3  3LM  RI WKH SDUDOOHO OLQHV ZKLFK DUH FDOOHG PHVK SRLQWV

RWKHU WHUPV LQ FRPPRQ XVH DUH SLYRWDO QRGDO JULG RU ODWWLFH SRLQWV 7KLV VROXWLRQ LV

REWDLQHG E\ DSSUR[LPDWLQJ WKH 3'( RYHU WKH DUHD 6 E\ Q DOJHEUDLF HTXDWLRQV LQYROYLQJ

WKH YDOXHV RI X DW WKH Q PHVK SRLQWV LQWHUQDO WR & 7KH DSSUR[LPDWLRQ FRQVLVWV RI

UHSODFLQJ HDFK GHULYDWLYH RI WKH 3'( DW WKH SRLQW 3LM E\ D ILQLWHGLIIHUHQFH

DSSUR[LPDWLRQ LQ WHUPV RI YDOXHV RI X DW 3LM DQG DW QHLJKERULQJ SRLQWV DQG ERXQGDU\

SRLQWV DQG LQ ZULWLQJ GRZQ IRU HDFK RI WKH Q LQWHUQDO PHVK SRLQWV WKH DOJHEUDLF HTXDWLRQ

DSSUR[LPDWLQJ WKH GLIIHUHQWLDO HTXDWLRQ

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


INTRODUCTION PAGE 6

7KLV SURFHVV FOHDUO\ JLYHV Q DOJHEUDLF HTXDWLRQV IRU WKH Q XQNQRZQV ZKLFK LQ WKLV

SURMHFW DUH WR EH VROYHG E\ LWHUDWLYH PHWKRGV IRU UHDVRQV WR EH JLYHQ LQ WKH QH[W VHFWLRQ

$FFXUDF\ FDQ XVXDOO\ EH LPSURYHG HLWKHU E\ LQFUHDVLQJ WKH QXPEHU RI PHVK SRLQWV RU E\

LQFUHDVLQJ WKH QXPEHU RI QHLJKERULQJ SRLQWV DQG ERXQGDU\ SRLQWV XVHG LQ ZULWLQJ GRZQ

WKH DOJHEUDLF HTXDWLRQ DSSUR[LPDWLQJ WKH GLIIHUHQWLDO HTXDWLRQ

%HVLGHV ILQLWHGLIIHUHQFLQJ WKHUH DUH RWKHU PHWKRGV IRU VROYLQJ 3'(V 0RVW LPSRUWDQW

DUH ILQLWH HOHPHQW LPSRUWDQW ZKHQ GHDOLQJ ZLWK KLJKO\ LUUHJXODU JHRPHWULHV 0RQWH

&DUOR YDULDWLRQDO DQG VSHFWUDO PHWKRGV

 :+<,7(5$7,9(180(5,&$/0(7+2'6"
$IWHU DSSUR[LPDWLQJ D 3'( E\ LWV DSSURSULDWH ILQLWHGLIIHUHQFH DSSUR[LPDWLRQ DW D VHW RI

JULG SRLQWV D VHW RI VLPXOWDQHRXV OLQHDU HTXDWLRQV UHVXOW 3URSHU RUGHULQJ RI WKHVH

HTXDWLRQV JLYHV D GLDJRQDOO\GRPLQDQW V\VWHP GLDJRQDO GRPLQDQFH PHDQV WKDW WKH

PDJQLWXGH RI WKH FRHIILFLHQW DW WKH GLDJRQDO LV QRW OHVV WKDQ WKH VXP RI WKH PDJQLWXGHV RI

WKH RWKHU FRHIILFLHQWV LQ WKH VDPH URZ 

7KH UHVXOWLQJ HTXDWLRQV FRQWDLQ D ODUJH QXPEHU RI ]HUR WHUPV WKH VPDOOHU WKH PHVK VL]H

FKRVHQ IRU WKH JULG WKH ODUJHU WKH QXPEHU RI ]HURV ZLWK PRUH LQWHUQDO PHVK SRLQWV WKH

QXPEHU RI QRQ]HUR PHVK SRLQWV DUH UHGXFHG GUDPDWLFDOO\ 

7DNLQJ D W\SLFDO VWHDG\VWDWH KHDWIORZ

SUREOHP LQ ZKLFK D WKLQ VWHHO SODWH LV  E\ 

FP UHFWDQJOH LI RQH RI WKH  FP HGJHV LV KHOG

DW  GHJUHHV &HOVLXV DQG WKH RWKHUV DUH KHOG

DW  ZKDW DUH WKH VWHDG\VWDWH WHPSHUDWXUHV DW

LQWHULRU SRLQWV"

7DNLQJ WKH PHVK VL]H K  FP 7KH SK\VLFDO SURSHUWLHV RI WKH PDWHULDO GR QRW HQWHU

WKH ILQLWH GLIIHUHQW UHSUHVHQWDWLRQ FKDSWHU  ZLOO FODULI\ WKLV SRLQW

 )RU IXUWKHU UHIHUHQFH FRQVXOW >@ DQG >@

7KLV LV D SUREOHP WKDW LV VROYHG E\ /DSODFH


V HTXDWLRQ ∂ + ∂ =   WKH QH[W FKDSWHU
 
X X

∂ ∂ [

\


ZLOO GHDO ZLWK VXFK SUREOHPV )RU WKH PHDQ WLPH ZH DUH LQWHUHVWHG LQ WKH QXPEHU RI
LQWHUQDO PHVK SRLQWV IRU WKLV FDVH ZH RQO\ KDYH  DV WKH ILJXUH VKRZV

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


INTRODUCTION PAGE 7

)RU EHWWHU DFFXUDF\ RQH ZRXOG UHGXFH ,Q SUDFWLFH KRZHYHU WKLV SURFHGXUH UXQV LQWR
K

VHYHUH GLIILFXOWLHV ZLWK  ZH ZRXOG KDYH  GLVFUHWH LQWHULRU SRLQWV ZLWK
K

K  ZH
G KDYH  DQG VR RQ 6WRULQJ D PDWUL[ ZLWK  URZV DQG  FROXPQV
ZRXOG UHTXLUH  RU DERXW  ZRUGV RI FRPSXWHU PHPRU\  E\WHV LI


YDULDEOHV ZHUH LQ &  :LWK  HTXDWLRQV ZH ZRXOG QHHG  ZRUGV )HZ
GRXEOH

FRPSXWHU V\VWHPV DOORZ VXFK D JHQHURXV SDUWLWLRQ DQG RYHUOD\LQJ PHPRU\ VSDFH IURP
GLVN VWRUDJH ZRXOG EH H[WUHPHO\ WLPHFRQVXPLQJ 6R WKH UHPHG\ WR WKLV SUREOHP RI
RYHUODUJH PDWULFHV XQNQRZQV SXW LQ D PDWUL[ LV WR PDNH XVH RI WKH VSDUVHQHVV
H[KLELWHG ZKHQ XVLQJ WKH ILQLWHGLIIHUHQFH UHSUHVHQWDWLRQ
)RU  ZH KDYH  HTXDWLRQV 7KLV V\VWHP KDV QRQ]HUR WHUPV LQ RQO\  RXW RI 
K

HOHPHQWV RU  7KH ODUJHU PDWULFHV WKDW UHVXOW ZKHQ LV VPDOOHU KDYH DQ HYHQ
K

VPDOOHU SURSRUWLRQ RI QRQ]HUR WHUPV  DQG  ZLWK  DQG  HTXDWLRQV
UHVSHFWLYHO\
:KHQ VROYLQJ WKHVH HTXDWLRQV LWHUDWLYHO\ WKH EHWWHU WKH LQLWLDO DSSUR[LPDWLRQV IRU WKH
LQWHUQDO PHVK SRLQWV WKH OHVV LV WKH QXPEHU RI LWHUDWLRQV QHHGHG WKH IDVWHU WKH
FRQYHUJHQFH  EXW EHFDXVH WKH V\VWHP LV GLDJRQDOO\ GRPLQDQW FRQYHUJHQFH ZLOO DOZD\V
RFFXU ,WHUDWLRQV DUH WHUPLQDWHG ZKHQ DOO YDOXHV RI XQNQRZQV DUH OHVV WKDQ VRPH SUH
GHILQHG WROHUDQFH 7KH WROHUDQFH VKRXOG EH FKRVHQ ZLWK FRQVLGHUDWLRQ IRU WKH LPSRUWDQFH
RI SUHFLVLRQ LQ WKH ILQDO DQVZHU PDQ\ HQJLQHHULQJ DSSOLFDWLRQV GR QRW QHHG H[WUHPH
DFFXUDF\ DQG RQO\ DIWHU GHWHUPLQLQJ ZKHWKHU WKH SDUDPHWHUV RI WKH SUREOHP ERXQGDU\
FRQGLWLRQV GLPHQVLRQV PDWHULDO SURSHUWLHV DQG VR RQ DUH WKHPVHOYHV NQRZQ ZLWK
JUHDW DFFXUDF\
)RU ODUJH V\VWHPV WKHUH LV DQ REYLRXV DGYDQWDJH RI LWHUDWLYH PHWKRGV RYHU GLUHFW
PHWKRGV OLNH HOLPLQDWLRQ ZKLFK LV WKH JUHDWO\ UHGXFHG GHPDQG IRU FRPSXWHU PHPRU\
VSDFH ,Q RXU H[DPSOH LI  FP WKHUH DUH  LQWHULRU PHVK SRLQWV DW JULG
K

LQWHUVHFWLRQV 7R VWRUH WKH IXOO  E\  PDWUL[ ZH QHHG  E\WHV QRW HYHQ
WDNLQJ LQWR DFFRXQW WKH ULJKW KDQG VLGHV DQG WKH VROXWLRQ YHFWRU ZKHQ XVLQJ /LHEPDQ
V
PHWKRG  ZH QHHG WR VWRUH RQO\  YDOXHV RI X SOXV  ERXQGDU\ YDOXHV WKLV UHTXLUHV

LM

 :KHQ WKH *DXVV6HLGHO LWHUDWLYH PHWKRG LV DSSOLHG WR /DSODFH


V HTXDWLRQ LW LV FDOOHG /LHEPDQ
V

PHWKRG 7KLV PHWKRG DQG RWKHU LWHUDWLYH PHWKRGV XVHG IRU (OOLSWLF 3'(V DUH WKH VXEMHFW RI &KDSWHU 

DERXW  E\WHV 7KH GLIIHUHQFH LQ VWRUDJH UHTXLUHPHQWV LV HYHQ PRUH VWULNLQJ ZKHQ

K  FP 7KH  E\WHV IRU D IXOO PDWUL[ LV UHGXFHG WR D YHU\ PRGHUDWH 

E\WHV :LWK ODUJH V\VWHPV WKHUH LV DOVR D YHU\ VLJQLILFDQW UHGXFWLRQ LQ H[HFXWLRQ WLPH DV

ZHOO

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


INTRODUCTION PAGE 8

 :+$70$.(67+,63$&.$*(',))(5(17"
 ,1:+$7$63(&76,67+,63$&.$*(86(5)5,(1'/< ('8&$7,21$/"

:KLOH SURJUDPPLQJ , WULHG WR PDNH WKH SDFNDJH DV JHQHUDO DV SRVVLEOH LQ D VHQVH WKDW LW

FRXOG EH XVHG WR VROYH D ODUJH QXPEHU RI 3'( FDVHV ZLWK GLIIHUHQW RSWLRQV RI VROXWLRQV

IRU HDFK VSHFLILF FDVH $QG WKLV , WKLQN VDWLVILHV WKH QHHGV RI ERWK W\SHV RI XVHUV WKRVH

ZKR PHUHO\ ZDQW WR VROYH D VSHFLILF 3'( DQG WKRVH LQWHUHVWHG LQ QXPHULFDO PHWKRGV

, DOVR WULHG WR PDNH HDFK ILOH WKH IXQFWLRQ LW SHUIRUPV DOVR DV JHQHUDO DV SRVVLEOH VR

WKDW LW FRXOG EH FDOOHG E\ RWKHU ILOHV ZLWKRXW ORVV RI JHQHUDOLW\ DQG QHHG IRU XQQHFHVVDU\

UHSHWLWLRQV 6RPHWLPHV D VSHFLILF FDVH QHHGHG D ILOH RI LWV RZQ 7KH UHDVRQ IRU WKDW LV

WKDW , GLG QRW ZDQW WR ERUH WKH XVHU ZLWK ULJJHUV WKDW KHVKH ZRXOG KDYH KDG WR DQVZHU

LI WKDW FDVH ZHUH WR XVH D PRUH JHQHUDO DSSURDFK HYHQ WKRXJK WKH JHQHUDO ILOH ZDV

SUHVHQW DQG FRXOG KDYH VROYHG WKH SUREOHP  7KLV RI FRXUVH VDYHV WLPH LQ HQWHULQJ WKH

QHHGHG GDWD E\ WKH SURJUDP DQG OHVV H[HFXWLRQ WLPH LV UHTXLUHG WR VROYH WKH SUREOHP

,Q ZKDW VHQVH LV WKLV SDFNDJH (GXFDWLRQDO"


• 3URYLGLQJ VHYHUDO QXPHULFDO PHWKRGV IRU WKH XVHU WR FKRRVH IURP IRU VROYLQJ

KLVKHU 3'( LV E\ LWVHOI FRQVLGHUHG DQ HGXFDWLRQDO DSSURDFK 7KH XVHU FDQ

FRPSDUH WKH GLIIHUHQW VROXWLRQV SUHVHQWHG E\ WKH GLIIHUHQW QXPHULFDO PHWKRGV

WKH H[HFXWLRQ WLPH QHHGHG E\ HDFK WKH QXPEHU RI LWHUDWLRQV UHTXLUHG WKH HIIHFW

RI WKH HQWHUHG WROHUDQFH RQ WKH QXPEHU RI LWHUDWLRQV DQG UHVXOWV DQG WKH DFFXUDF\

JDLQHG E\ FKDQJLQJ WKH PHVK VL]H RI WKH SUREOHP LQ VWDNH

• 7KH SURJUDP GLVSOD\V WKH HVVHQWLDO LQIRUPDWLRQ WKDW WKH XVHU VKRXOG NQRZ ZKHQ

KHVKH LV VROYLQJ D 3'( ZLWK D QXPHULFDO PHWKRG E\ ILQLWHGLIIHUHQFH DOVR

VWRUHV WKHP RQ DQ RXWSXW ILOH ZLWK WKH UHVXOWV  OLNH WKH QXPEHU RI LQWHUQDO PHVK

SRLQWV WKDW UHVXOWV IURP FKRRVLQJ D SDUWLFXODU PHVK VL]H WKH WRWDO QXPEHU RI

PHVK SRLQWV QHHGHG LQ FDOFXODWLRQV ZKLFK GHSHQGV RQ WKH QXPHULFDO PHWKRG

XVHG DQG KRZ LQLWLDOL]DWLRQ IRU WKH XQNQRZQV LV PDGH WKH SURJUDP WDNHV WKH

 6HH IRRWHU

 7KH SURJUDP LQ WKH HOOLSWLF FDVH VROYHV IRU DERXW  PHVK SRLQWV IRU WKH SDUDEROLF DQG

K\SHUEROLF W\SHV WKH RQO\ OLPLWDWLRQ LV WKH DYDLODEOH FRPSXWHU PHPRU\

DYHUDJH RI DOO WKH ERXQGDU\ SRLQWV VLQFH WKH LQWHUQDO SRLQWV ZLOO KDYH YDOXHV

FORVH WR WKHLUV 6R WKDW WKH QXPEHU RI QHHGHG LWHUDWLRQV LV KHQFH PLQLPDO 

• $FFHOHUDWLRQ IDFWRUV DUH XVHG ZLWK VRPH QXPHULFDO PHWKRGV :KHQ DQ RSWLPXP

DFFHOHUDWLRQ IDFWRU LV XVHG ZLWK D QXPHULFDO PHWKRG WKH SURJUDP FDOFXODWHV LW

DQG GLVSOD\V LWV YDOXH WKH QXPEHU RI LWHUDWLRQV QHHGHG WR DUULYH DW WKH UHTXLUHG

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


INTRODUCTION PAGE 9

WROHUDQFH UHGXFHV WR QHDUO\ KDOI 6RPH RSWLRQV SHUPLW WKH XVHU WR HQWHU KLVKHU

RZQ DFFHOHUDWLRQ IDFWRU LW LV H[SODLQHG WR KLPKHU WKH HIIHFW RI WKHVH IDFWRUV RQ

FRQYHUJHQFH DQG UHFRPPHQGHG YDOXHV DUH DOVR GLVSOD\HG &KRRVLQJ D QRQ

RSWLPXP DFFHOHUDWLQJ IDFWRU PD\ UHGXFH WKH QXPEHU RI LWHUDWLRQV QHHGHG EXW LW

DOVR PD\ LQFUHDVH WKHP %\ WU\LQJ RXW GLIIHUHQW YDOXHV RI DFFHOHUDWLRQ IDFWRUV

WKH XVHU FDQ IXOO\ XQGHUVWDQG WKH HIIHFW RI DFFHOHUDWLRQ IDFWRUV RQ FRQYHUJHQFH

• :KHQ WKH XVHU FKRRVHV WR VROYH D VSHFLILF FDVH KHVKH LV WKHQ DVNHG WR HQWHU WKH

ERXQGDU\ FRQGLWLRQV LQ UHODWLRQ WR KLVKHU FKRLFH ,I WKH ERXQGDU\ FRQGLWLRQV

HQWHUHG DUH QRW IRU WKDW FDVH IRU H[DPSOH HQWHULQJ 1HXPDQQ ERXQGDU\

FRQGLWLRQV ZKHQ WKH UHTXHVW ZDV WR VROYH D 0L[HG SUREOHP  7KH XVHU LV

SURPSWHG WKDW KHVKH KDV D 352%/(0 ZLWK QRPHQFODWXUH D EULHI H[SODQDWLRQ RI

WKH FRUUHFW QRPHQFODWXUH LV GLVSOD\HG VKRZLQJ KLPKHU ZKDW ZHQW ZURQJ

,V WKH SDFNDJH UHDOO\ XVHU IULHQGO\"


7KH IROORZLQJ SRLQWV DQVZHU WKLV TXHVWLRQ

• $OO QHFHVVDU\ GDWD QHHGHG WR LGHQWLI\ WKH 3'( FKRVHQ DOO EDVLF GLVWLQFWLRQV RI

WKDW QXPHULFDO PHWKRG FKRVHQ IRU VROYLQJ WKH SUREOHP DQG UHVXOWV REWDLQHG DIWHU

VROYLQJ WKH SUREOHP DUH VWRUHG RQ DQ RXWSXW ILOH XQGHU WKH QDPH
3'(),/(287


• $V PHQWLRQHG SUHYLRXVO\ LQLWLDOL]DWLRQ RI DOO PHVK SRLQWV LV GRQH E\ WKH SURJUDP

LI ERXQGDU\ FRQGLWLRQV SHUPLW LQ RUGHU WR PLQLPL]H WKH QXPEHU RI LWHUDWLRQV

QHHGHG

• :KHQ GHDOLQJ ZLWK 3DUDEROLF DQG +\SHUEROLF 3'(V WKH WLPH LQWHUYDO QHHGHG E\

WKH VROXWLRQ PLJKW EH YHU\ VPDOO DQG WKH XVHU PD\ ZDQW WKH UHVXOWV GLVSOD\HG

DIWHU ODUJH PXOWLSOHV RI WKLV WLPH LQWHUYDO 7KHUHIRUH WKH XVHU MXVW HQWHUV DIWHU

KRZ PDQ\ PXOWLSOHV RI WKH WLPH LQWHUYDO GRHV KHVKH ZDQW WKH UHVXOWV GLVSOD\HG

DQG WKH SURJUDP GLVSOD\V WKHP DFFRUGLQJ WR WKH UHTXHVW

 &DVHV PHDQW DUH WKRVH RI WKH (OOLSWLF 3'(

 7KLV ILOH LV FUHDWHG LQ WKH GLUHFWRU\ LQ ZKLFK WKH H[HFXWLRQ ILOH LV SUHVHQW ,I WKH ILOH LV DOUHDG\ SUHVHQW

WKHQ WKH RXWSXW LV DSSHQGHG WR LW ,I D IORSS\ GLVN LV XVHG DQG KDSSHQV WR EH ZULWH SURWHFWHG WKH XVHU LV

SURPSWHG WR XQSURWHFW WKH GLVN DQG WKH SURJUDP WKHQ UHVXPHV H[HFXWLRQ

 7KLV LV PRVWO\ LQ WKH (OOLSWLF 3'(V ZLWK 'LULFKOHW ERXQGDU\ FRQGLWLRQV

• $ QRWH ZRUWK PHQWLRQLQJ ZKHQ GHDOLQJ ZLWK (OOLSWLF 3'(V :KHQ KDYLQJ D
352%/(0 ZLWK QRPHQFODWXUH WKH SURJUDP GRHV QRW HQG DIWHU GLVSOD\LQJ WKH
FRUUHFW QRPHQFODWXUH EXW LW FRQWLQXHV LQ VROYLQJ WKH SUREOHP DFFRUGLQJ WR WKH
ERXQGDU\ FRQGLWLRQV HQWHUHG E\ WKH XVHU HYHQ WKRXJK KHVKH KDG D 352%/(0
ZLWK QRPHQFODWXUH DQG FKRVH WKH ZURQJ FDVH 

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


INTRODUCTION PAGE 11

 &$6(6 2) 3'(6 35(6(17(' %< 7+( 3$&.$*(  7+(


 180(5,&$/0(7+2'686(')2562/9,1*7+(0
7KH IROORZLQJ WDEOHV JLYH D IXOO UHSUHVHQWDWLRQ LQ WKH SDFNDJH WKHVH WDEOHV DFWXDOO\ DSSHDU DV
PHQXV IRU WKH XVHU WR FKRRVH IURP 

8VLQJWKH)LQLWH'LIIHUHQFH0HWKRGIRUVROYLQJ3DUWLDO'LIIHUHQWLDO(TXDWLRQV
• (OOLSWLF 3DUWLDO'LIIHUHQWLDO (TXDWLRQ
• 3DUDEROLF 3DUWLDO'LIIHUHQWLDO (TXDWLRQ
• +\SHUEROLF 3DUWLDO'LIIHUHQWLDO (TXDWLRQ

 7\SHVRI(OOLSWLF3DUWLDO'LIIHUHQWLDO(TXDWLRQV

 'LULFKOHW 3UREOHP )LUVW %RXQGDU\ 9DOXH 3UREOHP


5HJXODU ,UUHJXODU ERXQGDULHV
 1HXPDQQ 3UREOHP 6HFRQG %RXQGDU\ 9DOXH 3UREOHP
5HJXODU ERXQGDULHV
 0L[HG 3UREOHP 5HJXODU ERXQGDULHV

,  &DVHVRIWKH(OOLSWLF3'('LULFKOHW3UREOHPZLWK5HJXODU%RXQGDULHV

 /DSODFH HTXDWLRQ FRQVWDQW ERXQGDULHV


 3RLVVRQ HTXDWLRQ FRQVWDQW IXQFWLRQ I [\
FRQVWDQW ERXQGDULHV
 /DSODFH HTXDWLRQ ERXQGDULHV H[SUHVVHG DV SRO\QRPLDO IXQFWLRQV
 3RLVVRQ HTXDWLRQ FRQVWDQW IXQFWLRQ I [\
ERXQGDULHV H[SUHVVHG DV SRO\QRPLDO IXQFWLRQV
 3RLVVRQ HTXDWLRQ SRO\QRPLDO IXQFWLRQ I [\
FRQVWDQW ERXQGDULHV
 3RLVVRQ HTXDWLRQ SRO\QRPLDO IXQFWLRQ I [\
ERXQGDULHV H[SUHVVHG DV SRO\QRPLDO IXQFWLRQV
 /DSODFH HTXDWLRQ ERXQGDULHV H[SUHVVHG DV SRLQWV HQWHUHG E\ WKH XVHU
 3RLVVRQ HTXDWLRQ FRQVWDQW IXQFWLRQ I [\
ERXQGDULHV H[SUHVVHG DV SRLQWV HQWHUHG E\ WKH XVHU
 3RLVVRQ HTXDWLRQ SRO\QRPLDO IXQFWLRQ I [\
ERXQGDULHV H[SUHVVHG DV SRLQWV HQWHUHG E\ WKH XVHU
 5HFWDQJXODU VKDSHV LV PHDQW E\ WKH ZRUG
UHJXODU


KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


INTRODUCTION PAGE 12

  3RLVVRQ HTXDWLRQ IXQFWLRQ I [\  H[SUHVVHG DV SRLQWV HQWHUHG E\ WKH XVHU


ERXQGDULHV H[SUHVVHG DV SRLQWV HQWHUHG E\ WKH XVHU

,,  1XPHULFDO,WHUDWLYH0HWKRGV8VHGIRUVROYLQJWKH(OOLSWLF3'(ZLWK
   'LULFKOHW&RQGLWLRQV 5HJXODU%RXQGDULHV )RU HDFK RI WKH SUHYLRXV FDVHV

  -DFREL LWHUDWLYH PHWKRG IRU VROYLQJ V\VWHPV RI HTXDWLRQV XVLQJ SRLQW


DSSUR[LPDWLRQ

  *DXVV6HLGHO LWHUDWLYH PHWKRG IRU VROYLQJ V\VWHPV RI HTXDWLRQV  /LHEPDQQ


V
PHWKRG XVLQJ SRLQW DSSUR[LPDWLRQ

  -DFREL LWHUDWLYH PHWKRG IRU VROYLQJ V\VWHPV RI HTXDWLRQV XVLQJ SRLQW


DSSUR[LPDWLRQ

  *DXVV6HLGHO LWHUDWLYH PHWKRG IRU VROYLQJ V\VWHPV RI HTXDWLRQV /LHEPDQQ


V
PHWKRG XVLQJ SRLQW DSSUR[LPDWLRQ

  6XFFHVVLYH 2YHUUHOD[DWLRQ PHWKRG WKH XVHU HQWHULQJ KLVKHU 625 IDFWRU XVLQJ
SRLQW DSSUR[LPDWLRQ

  6XFFHVVLYH 2YHUUHOD[DWLRQ PHWKRG XVLQJ DQ RSWLPXP 625 IDFWRU XVLQJ 


SRLQW DSSUR[LPDWLRQ

  6XFFHVVLYH 2YHUUHOD[DWLRQ PHWKRG WKH XVHU HQWHULQJ KLVKHU 625 IDFWRU XVLQJ
SRLQW DSSUR[LPDWLRQ

  6XFFHVVLYH 2YHUUHOD[DWLRQ PHWKRG XVLQJ DQ RSWLPXP 625 IDFWRU XVLQJ 


SRLQW DSSUR[LPDWLRQ

  8VLQJ WKH $OWHUQDWLQJ'LUHFWLRQ ,PSOLFLW $', PHWKRG ZLWKRXW S IDFWRU

  8VLQJ WKH $', PHWKRG ZLWK WKH XVHU HQWHULQJ KLVKHU S IDFWRU

  8VLQJ WKH $', PHWKRG ZLWK DQ RSWLPXP S IDFWRU

,,,  &DVHV RI WKH (OOLSWLF 3'(  'LULFKOHW 3UREOHP ZLWK ,UUHJXODU
   %RXQGDULHV 1RQUHFWDQJXODU JULGV    WKH  1XPHULFDO ,WHUDWLYH
   0HWKRGV8VHGIRUVROYLQJWKHP

  /DSODFH HTXDWLRQ VHPLFLUFOH LUUHJXODU ERXQGDU\


FRQVWDQW ERXQGDULHV
XVLQJ *DXVV6HLGHO

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


INTRODUCTION PAGE 13

  /DSODFH HTXDWLRQ VHPLFLUFOH LUUHJXODU ERXQGDU\


FRQVWDQW ERXQGDULHV
XVLQJ -DFREL

  /DSODFH HTXDWLRQ FLUFOH LUUHJXODU ERXQGDU\


FRQVWDQW ERXQGDULHV
XVLQJ *DXVV6HLGHO

  /DSODFH HTXDWLRQ FLUFOH LUUHJXODU ERXQGDU\


FRQVWDQW ERXQGDULHV
XVLQJ -DFREL

  /DSODFH HTXDWLRQ VHPLFLUFOH LUUHJXODU ERXQGDU\


XVHU HQWHULQJ ERXQGDULHV
XVLQJ *DXVV6HLGHO

  /DSODFH HTXDWLRQ VHPLFLUFOH LUUHJXODU ERXQGDU\


XVHU HQWHULQJ ERXQGDULHV
XVLQJ -DFREL

  /DSODFH HTXDWLRQ FLUFOH LUUHJXODU ERXQGDU\


XVHU HQWHULQJ ERXQGDULHV
XVLQJ *DXVV6HLGHO

  /DSODFH HTXDWLRQ FLUFOH LUUHJXODU ERXQGDU\


XVHU HQWHULQJ ERXQGDULHV
XVLQJ -DFREL

,9  &DVHVRIWKH(OOLSWLF3'(1HXPDQQ3UREOHPZLWK5HJXODU%RXQGDULHV

  /DSODFH HTXDWLRQ 1HXPDQQ 3UREOHP

  3RLVVRQ HTXDWLRQ SRO\QRPLDO IXQFWLRQ I [\ 1HXPDQQ 3UREOHP

  3RLVVRQ HTXDWLRQ 1HXPDQQ 3UREOHP


)XQFWLRQ I [\  H[SUHVVHG DV SRLQWV HQWHUHG E\ WKH XVHU

9  1XPHULFDO,WHUDWLYH0HWKRGV8VHGIRUVROYLQJWKH(OOLSWLF3'(ZLWK
  1HXPDQQ&RQGLWLRQV 5HJXODU%RXQGDULHV )RU HDFK RI WKH SUHYLRXV FDVHV

  -DFREL LWHUDWLYH PHWKRG IRU VROYLQJ V\VWHPV RI HTXDWLRQV XVLQJ SRLQW


DSSUR[LPDWLRQ

  *DXVV6HLGHO LWHUDWLYH PHWKRG IRU VROYLQJ V\VWHPV RI HTXDWLRQV /LHEPDQQ


V
PHWKRG XVLQJ SRLQW DSSUR[LPDWLRQ

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


INTRODUCTION PAGE 14

  6XFFHVVLYH 2YHUUHOD[DWLRQ PHWKRG XVLQJ DQ RSWLPXP 625 IDFWRU XVLQJ 


SRLQW DSSUR[LPDWLRQ

9,  &DVHVRIWKH(OOLSWLF3'(0L[HG3UREOHPZLWK5HJXODU%RXQGDULHV

  /DSODFH HTXDWLRQ 0L[HG 3UREOHP

  3RLVVRQ HTXDWLRQ SRO\QRPLDO IXQFWLRQ I [\ 0L[HG 3UREOHP

  3RLVVRQ HTXDWLRQ 0L[HG 3UREOHP


)XQFWLRQ I [\  H[SUHVVHG DV SRLQWV HQWHUHG E\ WKH XVHU

9,, 1XPHULFDO,WHUDWLYH0HWKRGV8VHGIRUVROYLQJWKH(OOLSWLF3'(ZLWK
  0L[HG&RQGLWLRQV 5HJXODU%RXQGDULHV )RU HDFK RI WKH SUHYLRXV FDVHV

 -DFREL LWHUDWLYH PHWKRG IRU VROYLQJ V\VWHPV RI HTXDWLRQV XVLQJ SRLQW


DSSUR[LPDWLRQ

  *DXVV6HLGHO LWHUDWLYH PHWKRG IRU VROYLQJ V\VWHPV RI HTXDWLRQV /LHEPDQQ


V
PHWKRG XVLQJ SRLQW DSSUR[LPDWLRQ

  6XFFHVVLYH 2YHUUHOD[DWLRQ PHWKRG XVLQJ DQ RSWLPXP 625 IDFWRU XVLQJ 


SRLQW DSSUR[LPDWLRQ

 &DVHV RI WKH 3DUDEROLF 3'(  ZLWK 5HJXODU %RXQGDULHV    WKH
 1XPHULFDO,WHUDWLYH0HWKRGV8VHGIRUVROYLQJWKHP

  2QHGLPHQVLRQDO KHDW HTXDWLRQ ([SOLFLW PHWKRG


ERXQGDULHV H[SUHVVHG DV FRQVWDQWV
LQLWLDO FRQGLWLRQV H[SUHVVHG DV SRLQWV HQWHUHG E\ WKH XVHU

  2QHGLPHQVLRQDO KHDW HTXDWLRQ ([SOLFLW PHWKRG


ERXQGDULHV H[SUHVVHG DV FRQVWDQWV
LQLWLDO FRQGLWLRQV H[SUHVVHG DV D SRO\QRPLDO IXQFWLRQ

  2QHGLPHQVLRQDO KHDW HTXDWLRQ &UDQN1LFROVRQ PHWKRG


ERXQGDULHV H[SUHVVHG DV FRQVWDQWV
LQLWLDO FRQGLWLRQV H[SUHVVHG DV SRLQWV HQWHUHG E\ WKH XVHU

  2QHGLPHQVLRQDO KHDW HTXDWLRQ &UDQN1LFROVRQ PHWKRG


ERXQGDULHV H[SUHVVHG DV FRQVWDQWV
LQLWLDO FRQGLWLRQV H[SUHVVHG DV D SRO\QRPLDO IXQFWLRQ

  2QHGLPHQVLRQDO KHDW HTXDWLRQ ([SOLFLW PHWKRG


ERXQGDULHV H[SUHVVHG DV GHULYDWLYHV
LQLWLDO FRQGLWLRQV H[SUHVVHG DV SRLQWV HQWHUHG E\ WKH XVHU

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


INTRODUCTION PAGE 15

  2QHGLPHQVLRQDO KHDW HTXDWLRQ ([SOLFLW PHWKRG


ERXQGDULHV H[SUHVVHG DV GHULYDWLYHV
LQLWLDO FRQGLWLRQV H[SUHVVHG DV D SRO\QRPLDO IXQFWLRQ

  2QHGLPHQVLRQDO KHDW HTXDWLRQ &UDQN1LFROVRQ PHWKRG


ERXQGDULHV H[SUHVVHG DV GHULYDWLYHV
LQLWLDO FRQGLWLRQV H[SUHVVHG DV SRLQWV HQWHUHG E\ WKH XVHU

  2QHGLPHQVLRQDO KHDW HTXDWLRQ &UDQN1LFROVRQ PHWKRG


ERXQGDULHV H[SUHVVHG DV GHULYDWLYHV
LQLWLDO FRQGLWLRQV H[SUHVVHG DV D SRO\QRPLDO IXQFWLRQ

  7ZRGLPHQVLRQDO KHDW HTXDWLRQ $', PHWKRG


ERXQGDULHV H[SUHVVHG DV FRQVWDQW SRLQWV HQWHUHG E\ XVHU
LQLWLDO FRQGLWLRQV H[SUHVVHG DV SRLQWV HQWHUHG E\ WKH XVHU

 &DVHVRIWKH+\SHUEROLF3'(ZLWK5HJXODU%RXQGDULHV WKH


 1XPHULFDO,WHUDWLYH0HWKRGV8VHGIRUVROYLQJWKHP

  2QHGLPHQVLRQDO ZDYH HTXDWLRQ E\ )LQLWH 'LIIHUHQFHV


ERXQGDULHV H[SUHVVHG DV FRQVWDQWV
LQLWLDO FRQGLWLRQV H[SUHVVHG DV SRLQWV HQWHUHG E\ XVHU
WLPH GHULYDWLYH H[SUHVVHG DV D SRO\QRPLDO IXQFWLRQ

  2QHGLPHQVLRQDO ZDYH HTXDWLRQ E\ )LQLWH 'LIIHUHQFHV


ERXQGDULHV H[SUHVVHG DV FRQVWDQWV
LQLWLDO FRQGLWLRQV H[SUHVVHG DV D SRO\QRPLDO IXQFWLRQ
WLPH GHULYDWLYH H[SUHVVHG DV D SRO\QRPLDO IXQFWLRQ

  2QHGLPHQVLRQDO ZDYH HTXDWLRQ E\ )LQLWH 'LIIHUHQFHV


ERXQGDULHV H[SUHVVHG DV FRQVWDQWV
LQLWLDO FRQGLWLRQV H[SUHVVHG DV SRLQWV HQWHUHG E\ XVHU
WLPH GHULYDWLYH H[SUHVVHG DV SRLQWV HQWHUHG E\ XVHU

  2QHGLPHQVLRQDO ZDYH HTXDWLRQ E\ )LQLWH 'LIIHUHQFHV


ERXQGDULHV H[SUHVVHG DV FRQVWDQWV
LQLWLDO FRQGLWLRQV H[SUHVVHG DV D SRO\QRPLDO IXQFWLRQ
WLPH GHULYDWLYH H[SUHVVHG DV SRLQWV HQWHUHG E\ XVHU

  7ZRGLPHQVLRQDO ZDYH HTXDWLRQ E\ )LQLWH 'LIIHUHQFHV


ERXQGDULHV H[SUHVVHG DV FRQVWDQWV
LQLWLDO FRQGLWLRQV H[SUHVVHG DV SRLQWV HQWHUHG E\ XVHU
WLPH GHULYDWLYH H[SUHVVHG DV SRLQWV HQWHUHG E\ XVHU

127( 7+( 86(5 +$6  2 37,216 72 &+226( )520 )25 62/9,1* +,6+(5 3'(

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


3$*( 

&+$37(5 
180(5,&$/0(7+2'6)2562/9,1*
(//,37,&3$57,$/',))(5(17,$/(48$7,216

7KLV FKDSWHU GHDOV ZLWK WKH QXPHULFDO PHWKRGV XVHG IRU VROYLQJ (OOLSWLF SDUWLDO

GLIIHUHQWLDO HTXDWLRQV 3'(V E\ ILQLWHGLIIHUHQFH )LUVW VKRZLQJ KRZ WKH (OOLSWLF 3'( LV

UHSUHVHQWHG E\ ILQLWHGLIIHUHQFH 7KHQ WKH QXPHULFDO PHWKRGV XVHG IRU VROYLQJ WKLV W\SH

RI 3'(V DUH GLVFXVVHG JLYLQJ D EULHI YLHZ RI WKH LPSRUWDQW SRLQWV LQ UHJDUG WR HDFK RI

WKH PHWKRGV 3UREOHPV UHODWHG WR WKLV W\SH RI 3'(V DUH DOVR SUHVHQWHG (DFK LV VROYHG

XVLQJ WKH SDFNDJH WKH RXWSXW ILOH SURGXFHG E\ WKH SDFNDJH


3'(),/(287
LV VKRZQ

IRU HDFK SUREOHP

∂ X ∂ X ∂ X
$V PHQWLRQHG LQ FKDSWHU  WKH 3'( D + E + F +H= LV FRQVLGHUHG (OOLSWLF
∂ [ ∂[∂\ ∂ \
LI E  DF   ,I WKH FRHIILFLHQWV D E DQG F DUH IXQFWLRQV RI [ \ DQGRU X WKH

IXQFWLRQ PD\ FKDQJH IURP RQH FODVVLILFDWLRQ WR DQRWKHU (OOLSWLF 3DUDEROLF +\SHUEROLF
∂ X ∂  X
DW YDULRXV SRLQWV LQ WKH GRPDLQ )RU /DSODFH
V + = DQG 3RLVVRQ
V HTXDWLRQV
∂ [  ∂ \
∂ X ∂  X
+ + H =  E  D F  VR WKHVH DUH DOZD\V (OOLSWLF 7KHVH HTXDWLRQV
∂ [  ∂ \
/DSODFH DQG 3RLVVRQ GHVFULEH KRZ X YDULHV WLPH LQGHSHQGHQW ZLWKLQ WKH LQWHULRU RI D

FORVHG UHJLRQ 7KH IXQFWLRQ X LV GHWHUPLQHG RQ WKH ERXQGDULHV RI WKH UHJLRQ E\

ERXQGDU\ FRQGLWLRQV 7KH ERXQGDU\ FRQGLWLRQV PD\ VSHFLI\ WKH YDOXH RI X 'LULFKOHW

FRQGLWLRQV  WKH\ PD\ VSHFLI\ WKH QRUPDO GHULYDWLYH 1HXPDQQ FRQGLWLRQV  RU VRPH

FRPELQDWLRQ RI X DQG WKH QRUPDO GHULYDWLYH 0L[HG FRQGLWLRQV DW DOO SRLQWV RQ WKH

ERXQGDU\

 5(35(6(17$7,21$6$',))(5(1&((48$7,215(*8/$5%281'$5,(6
2QH VFKHPH IRU VROYLQJ DOO NLQGV RI 3'(V LV WR UHSODFH WKH GHULYDWLYHV E\ GLIIHUHQFH

TXRWLHQWV FRQYHUWLQJ WKH HTXDWLRQ WR D GLIIHUHQFH HTXDWLRQ :H WKHQ ZULWH WKH GLIIHUHQFH

HTXDWLRQ FRUUHVSRQGLQJ WR HDFK SRLQW DW WKH LQWHUVHFWLRQV QRGHV RI D JULGZRUN WKDW

VXEGLYLGHV WKH UHJLRQ RI LQWHUHVW DW ZKLFK WKH IXQFWLRQ YDOXHV DUH XQNQRZQ 6ROYLQJ

WKHVH HTXDWLRQV VLPXOWDQHRXVO\ JLYHV YDOXHV IRU WKH IXQFWLRQ DW HDFK QRGH WKDW

DSSUR[LPDWH WKH WUXH YDOXHV

 )URP QRZ RQ ZKHQ UHIHUULQJ WR


QXPHULFDO PHWKRGV
ZKDW
V PHDQW DUH WKRVH XVHG LQ WKH SDFNDJH

.87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 17

7KH ILQLWHGLIIHUHQFH UHSUHVHQWDWLRQ RI /DSODFH


V HTXDWLRQ LQ WZR GLPHQVLRQV LV

∇ X =

X + X + X + X − X =   LW LV FRPPRQ WR WDNH ∆ [ = ∆ \ = K 
L M
K  L + M L − M L M +  L M − L M

)LYH SRLQWV DUH LQYROYHG LQ WKH UHODWLRQVKLS SRLQWV WR WKH ULJKW OHIW DERYH DQG EHORZ
WKH FHQWUDO SRLQW [  \  7KLV IRUPXOD LV UHIHUUHG WR DV WKH ILYHSRLQW DSSUR[LPDWLRQ RU
L M

ILYHSRLQW VWDU IRUPXOD ,Q DGGLWLRQ WR WKH ILYHSRLQW VWDU IRUPXOD MXVW JLYHQ WKHUH
V DOVR

WKH QLQHSRLQW VWDU IRUPXOD IRU /DSODFH


V (TXDWLRQ ZKLFK JLYHV WKH FORVHVW UHVXOWV WR WKH

DQDO\WLFDO VROXWLRQ RI DOO PHWKRGV GLVFXVVHG  DQG KDV WKH IROORZLQJ IRUP

∇ X 
L M
=  XL + M +  X − + X L  M L M + 
+ X L M − +X − L  M − +X− L  M + +X +  M − 
+X+ L  M + −  X L M = 
K
 L

)RU 3RLVVRQ
V HTXDWLRQ D VLPLODU UHSUHVHQWDWLRQV DSSOLHV 7KH ILYHSRLQW DSSUR[LPDWLRQ

ZRXOG EH

∇X = X+ +X− +X +X − X I

+ = 
L M
K  L  M L  M L M +  L M − L M

7KH QLQHSRLQW DSSUR[LPDWLRQ LV



∇ 
X L M = 
 XL + M +  X − + X L  M L M + 
+ X L M − +X − L  M − +X− L  M + +X L +  M − 
+X+ L  M + −  X L M + I = 
K

SURYLGHG WKDW I LV D IXQFWLRQ RI [ DQG \ RQO\


 ,7(5$7,9( 0(7+2'6 )25 62/9,1* 7+( (48$7,216
:KHQ DSSUR[LPDWLQJ WKH /DSODFH RU 3RLVVRQ HTXDWLRQV LQ WZR GLPHQVLRQV E\ WKHLU ILQLWH
GLIIHUHQFH UHSUHVHQWDWLRQV DW D VHW RI JULG SRLQWV [  \ 
L L
D VHW RI VLPXOWDQHRXV OLQHDU

HTXDWLRQV UHVXOW 3URSHU RUGHULQJ RI WKH HTXDWLRQV JLYHV D GLDJRQDOO\ GRPLQDQW V\VWHP

$W WKLV VWDJH RI WKH JDPH ZH FRXOG VD\ WKDW VXFK V\VWHPV FDQ EH VROYHG E\ *DXVV6HLGHO

LWHUDWLRQ :KHQ DSSOLHG WR /DSODFH


V HTXDWLRQ WKH LWHUDWLYH PHWKRG LV FDOOHG /LHEPDQQ
V

PHWKRG $VVXPLQJ DOO YDOXHV RI WKH XQNQRZQ X DUH NQRZQ DW WKH ERXQGDULHV WKHQ ZH
VD\ WKDW ZH KDYH 'LULFKOHW ERXQGDU\ FRQGLWLRQV
7DNLQJ WKH /DSODFH HTXDWLRQ DV DQ H[DPSOH 7KH ILUVW VWHS LQ VROYLQJ WKH /DSODFH

HTXDWLRQ LV WR UHDUUDQJH WKH GLIIHUHQFH HTXDWLRQV LQWR D QHZ IRUP E\ VROYLQJ HDFK

HTXDWLRQ IRU WKH YDULDEOH RQ WKH GLDJRQDO JLYLQJ

X LM =
X+L  M +X− +X L  M L M + +X L M −
 IRU HDFK LQWHUQDO SRLQW

:H VROYH VXFK D VHW RI HTXDWLRQV E\ EHJLQQLQJ ZLWK VRPH LQLWLDO DSSUR[LPDWLRQ X WR X

 )RU IXUWKHU UHIHUHQFH FRQVXOW >@ S 

 1RWH WKDW WKH SK\VLFDO SURSHUWLHV RI WKH PDWHULDO VWXGLHG GR QRW HQWHU WKH UHODWLRQ

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 18

WKH VROXWLRQ YHFWRU VXEVWLWXWLQJ YDOXHV IURP WKLV DSSUR[LPDWLRQ LQWR WKH ULJKWKDQG VLGHV

RI WKH HTXDWLRQV DQG JHQHUDWLQJ QHZ FRPSRQHQWV RI X WKDW FRQYHUJH WR WKH VROXWLRQ

&RQYHUJHQFH LV XVXDOO\ IDVWHU LI HDFK QHZ FRPSRQHQW RI X LV XVHG DV VRRQ DV LW LV

DYDLODEOH 7KH IRUPHU SURFHGXUH LV FDOOHG WKH -DFREL PHWKRG DQG WKH ODWWHU LV FDOOHG WKH

*DXVV6HLGHO 

7KH EHWWHU WKH EHJLQQLQJ DSSUR[LPDWLRQ WKH PRUH UDSLG WKH FRQYHUJHQFH EXW EHFDXVH

WKH V\VWHP LV GLDJRQDOO\ GRPLQDQW HYHQ D SRRU LQLWLDO YHFWRU ZLOO HYHQWXDOO\ FRQYHUJH

7KH LWHUDWLRQV DUH WHUPLQDWHG ZKHQ WKH PD[LPXP FKDQJH LQ DQ\ FRPSRQHQW RI X LV OHVV

WKDQ D SUHGHILQHG WROHUDQFH

7KH FKLHI GUDZEDFN LQ /LHEPDQQ


V PHWKRG LV LWV VORZ FRQYHUJHQFH ZKLFK LV HVSHFLDOO\

DFXWH ZKHQ WKHUH LV D ODUJH QXPEHU RI LQWHUQDO PHVK SRLQWV EHFDXVH WKHQ HDFK LWHUDWLRQ

LV OHQJWK\ DQG LQ DGGLWLRQ PRUH LWHUDWLRQV DUH UHTXLUHG WR UHDFK D JLYHQ WROHUDQFH

8VLQJ DQ RYHUUHOD[DWLRQ IDFWRU FDQ JLYH VLJQLILFDQWO\ IDVWHU FRQYHUJHQFH KRZHYHU VLQFH

HDFK HTXDWLRQ LV KDQGOHG LQ D VWDQGDUG DQG UHSHWLWLYH RUGHU WKLV PHWKRG LV FDOOHG

VXFFHVVLYH RYHUUHOD[DWLRQ IUHTXHQWO\ DEEUHYLDWHG DV 625

7KH IROORZLQJ HTXDWLRQ VKRZV KRZ VXFFHVVLYH RYHUUHOD[DWLRQ FDQ EH DSSOLHG WR

/DSODFH
V HTXDWLRQ
+ +
X +X− +X +X − X
N N N N N

+ + + −
=X + ω
 M L M L M L M
X
N N L  M L

L M L M 


PD[LPXP DFFHOHUDWLRQ LV REWDLQHG IRU VRPH RSWLPXP YDOXH RI ω 7KLV RSWLPXP YDOXH

ZLOO DOZD\V OLH EHWZHHQ  DQG  7KH RSWLPXP YDOXH RI ω LV QRW DOZD\V SUHGLFWDEOH

LQ DGYDQFH )RU D UHFWDQJXODU UHJLRQ KDYLQJ FRQVWDQW ERXQGDU\ FRQGLWLRQV 'LULFKOHW


FRQGLWLRQV  D UHDVRQDEOH HVWLPDWH RI WKH RSWLPXP ω FDQ EH GHWHUPLQHG IURP

ω RSW =

F F= π
S + FRV
π
T
F
 ZKHUH LV JLYHQ E\ FRV 
 +  − 

S= JULG OHQJWK
DQG T= JULG ZLGWK

PHVK VL]H PHVK VL]H
9DOXH RI S T ω RSW
 
7KH IROORZLQJ WDEOH VKRZV YDOXHV RI ω RSW WKDW DUH
 
FXVWRPDU\ LQ VWHDG\VWDWH SUREOHPV
 

 
$OO WKH PHWKRGV GLVFXVVHG SUHYLRXVO\ IRU VROYLQJ WKH
/DSODFH HTXDWLRQ DUH UHDGLO\ DSSOLFDEOH WR 3RLVVRQ
V  

HTXDWLRQ $QRWKHU PHWKRG XVHG LQ WKH SDFNDJH IRU  

∞ 

 )RU GHWDLOHG LQIRUPDWLRQ FRQVXOW >@ S  >@ S 

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 19

VROYLQJ WKH (OOLSWLF 'LULFKOHW 3'( ZLWK UHJXODU ERXQGDULHV ERWK /DSODFH DQG 3RLVVRQ LV

WKH $OWHUQDWLQJ'LUHFWLRQ,PSOLFLW $', PHWKRG ZKLFK LV WKH VXEMHFW RI WKH IROORZLQJ

VHFWLRQ

6R IDU ZH KDYH DVVXPHG WKDW X WHPSHUDWXUH IRU H[DPSOH LV VSHFLILHG DW WKH ERXQGDULHV

,Q PDQ\ SUREOHPV LQVWHDG RI NQRZLQJ WKH ERXQGDU\ WHPSHUDWXUHV ZH NQRZ WKH


∂ X
WHPSHUDWXUH JUDGLHQW LQ WKH GLUHFWLRQ QRUPDO WR WKH ERXQGDU\
∂ Q  DV IRU H[DPSOH ZKHQ

KHDW LV EHLQJ ORVW IURP WKH VXUIDFH E\ UDGLDWLRQ DQG FRQGXFWLRQ 7KH SURFHGXUH IRU

VROXWLRQ LV WKH VDPH ZKHWKHU IRU 1HXPDQQ 0L[HG RU SUREOHPV WKHUHIRUH WKH IROORZLQJ

GLVFXVVLRQ DSSOLHV WR ERWK

:H ZULWH X = X +X +X +X
LM
L + M L − M


L M + L M −


DW HDFK XQNQRZQ SRLQW ZKLFK LV RXU JHQHUDO SURFHGXUH IRU (OOLSWLF 3'(V H[FHSW DW WKH

ERXQGDULHV ZKHUH QRUPDO GHULYDWLYHV DUH SUHVHQW ZH FDQQRW IRUP WKH ILYHSRLQW

FRPELQDWLRQWKHUH DUH QRW HQRXJK SRLQWV WR IRUP WKH VWDU :H JHW DURXQG WKLV E\ WKH

GHYLFH RI H[WHQGLQJ RXU QHWZRUN WR D URZ RU D FROXPQ RI H[WHULRU SRLQWV DW HDFK VLGH
∂ X
ZKHUH
∂ Q LV JLYHQ DW WKDW ERXQGDU\ :H XWLOL]H WKHVH ILFWLWLRXV H[WHULRU SRLQWV WR LQFOXGH

LQ WKH VHW RI HTXDWLRQV WKRVH ZKRVH FHQWUDO SRLQW LV RQ WKH QRUPDO GHULYDWLYH ERXQGDU\

$V IRU WKH QHZ SRLQWV WKDW FRPH XS GXH WR WKLV SURFHGXUH ZH KDYH WR PDNH XVH RI WKH

JLYHQ JUDGLHQW FRQGLWLRQV :H ZULWH WKH GHULYDWLYH FRQGLWLRQV DV FHQWUDOGLIIHUHQFH

TXRWLHQWV E\

X [\
[  ≈


 K X [+K \ −X [−K \
  

X [\
\  ≈



K X [ \+K −X [ \−K
  

7KHVH DSSUR[LPDWLRQV DUH ZULWWHQ IRU WKH JUDGLHQW FRQGLWLRQV (DFK RI WKH GLIIHUHQFH

TXRWLHQWV DOORZV XV WR ZULWH WKH ILFWLWLRXV WHPSHUDWXUH YDOXHV LQ WHUPV RI SRLQWV ZLWKLQ

WKH UHFWDQJOH

:H VROYH WKH IRUPHU VHW RI HTXDWLRQV DIWHU HOLPLQDWLQJ WKH ILFWLWLRXV SRLQWV E\ XVLQJ WKH

ODWWHU HTXDWLRQV 7KH SDFNDJH XVHG -DFREL /LHEPDQQ


V DQG 625 SRLQW

DSSUR[LPDWLRQ WR VROYH WKH UHVXOWLQJ HTXDWLRQV

 7KH SRLQW GLIIHUHQFH HTXDWLRQV IRU WKH LQWHUQDO PHVK SRLQWV DQG IRU WKH SRLQWV DW WKH VLGHV ZKHUH

ERXQGDULHV DUH H[SUHVVHG DV QRUPDO GHULYDWLYHV

 7KH FHQWUDO GLIIHUHQFH TXRWLHQWV WKDW DUH ZULWWHQ IRU WKH JUDGLHQW FRQGLWLRQV

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 20

 7+( $',0(7+2'


,WHUDWLYH PHWKRGV DUH XVXDOO\ SUHIHUUHG IRU VSDUVH PDWULFHV XQOHVV WKH PDWULFHV KDYH D

WULGLDJRQDO VWUXFWXUH D PDWUL[ LV FDOOHG WULGLDJRQDO LI LW KDV DOO LWV QRQ]HUR HQWULHV RQ WKH

PDLQ GLDJRQDO DQG LQ WKH SRVLWLRQV LPPHGLDWHO\ DGMDFHQW WR WKH PDLQ GLDJRQDO 

$ PHWKRG IRU WKH (OOLSWLF 3'( FDOOHG WKH $OWHUQDWLQJ'LUHFWLRQ,PSOLFLW $',

PHWKRG UHVXOWV LQ WULGLDJRQDO PDWULFHV IXUWKHU RQ LW


OO EH VKRZQ WKDW XVLQJ LW LQ RXU FDVH

LV QRW UHFRPPHQGHG  ,W ZDV LQLWLDOO\ GHYHORSHG IRU XQVWHDG\VWDWH SUREOHPV ZKLFK LV WKH

VXEMHFW RI &KDSWHU  ,Q WKH $', PHWKRG ZH QHHG WZR ILQLWHGLIIHUHQFH DSSUR[LPDWLRQ

IRUPXODV IRU /DSODFH


V HTXDWLRQ DQG WKH\ DUH ZULWWHQ LQ WKH IROORZLQJ IRUP XVLQJ DQ

DFFHOHUDWLQJ IDFWRU S 

X L M −
P +
−  + SX
L M
P +
+ X
L M +
P +
=− X − M
P
+  − S X −XL M
P
+ M
P
 

X SX X X S X −X
L L

+ + + + + +
L − M
P
−  + L M
P
+ L + M
P
=− L M
P
− +  −

L M
P
L M +
P
 

:KHQ WKH VDPH YDOXH RI S LV XVHG LQ HYHU\ LWHUDWLRQ WKH SURFHVV FRQYHUJHV IRU DOO

SRVLWLYH YDOXHV RI S S ,I  LV XVHG LQ WKH SUHYLRXV HTXDWLRQV WKHQ LW


V DV LI QR S IDFWRU

LV SUHVHQW 7KH RSWLPXP YDOXH RI S IRU PD[LPXP UDWH RI FRQYHUJHQFH LV JLYHQ E\

S=  VLQ
π
N  

ZKHUH N LV WKH ODUJHU RI 0 DQG 1 0 LV WKH QXPEHU RI LQWHUQDO PHVK SRLQWV SHU

URZ 1 LV WKH QXPEHU RI LQWHUQDO PHVK SRLQWV SHU FROXPQ  $ IDVWHU UDWH RI FRQYHUJHQFH

LV JLYHQ E\ YDU\LQJ S IRU HDFK LWHUDWLRQ :KHQ XVLQJ D FRQVWDQW RSWLPXP S IDFWRU DV

JLYHQ E\ HTXDWLRQ   LW


V DFWXDOO\ RSWLPXP RQO\ ZKHQ D ODUJH QXPEHU RI LQWHUQDO

PHVK SRLQWV DUH LQYROYHG

7KH UHODWLRQV DUH LPSOLFLW EXW SURSHUO\ RUGHULQJ WKH HTXDWLRQV ZH REWDLQ D WULGLDJRQDO

FRHIILFLHQW PDWUL[ 7KLV UHTXLUHV WKDW HTXDWLRQ  SURFHHGV GRZQ HDFK URZ RI SRLQWV

LQ WXUQ ZKLOH HTXDWLRQ  SURFHVVHV WKHP FROXPQZLVH WKLV LV ZK\ WKH PHWKRG LV

FDOOHG DOWHUQDWLQJGLUHFWLRQLPSOLFLW  7KH SURSHU FKRLFH RI WKH SDUDPHWHU S FDQ

DFFHOHUDWH WKH FRQYHUJHQFH

7KH LWHUDWLRQV EHJLQ ZLWK DQ LQLWLDO HVWLPDWH RI WKH X 


YHFWRU 7KH LWHUDWLRQV DUH

WHUPLQDWHG ZKHQ VXFFHVVLYH FDOFXODWLRQV DJUHH ZLWKLQ D JLYHQ WROHUDQFH (DFK VWHS RQ LWV

RZQ LV XQVWDEOH DQG XQLODWHUDO UHSHWLWLRQ OHDGV WR XQDFFHSWDEOH JURZWK RI HUURUV

 7R VHH ZK\ FRQVXOW >@ S 

 )RU H[DPSOH WKH WZRGLPHQVLRQDO KHDW HTXDWLRQ

 )RU IXUWKHU GHWDLOV FRQVXOW >@ S  >@ S  DQG >@ S 

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 21

8VLQJ WKH $', PHWKRG WR VROYH WKH (OOLSWLF SUREOHP LI XVLQJ D FRQVWDQW RSWLPXP

DFFHOHUDWLQJ IDFWRU LV QRW UHDOO\ ZRUWKZKLOH :KHQ XVLQJ WKH $', ZLWK D FRQVWDQW

RSWLPXP S IDFWRU WKH EHVW UHVXOWV \RX FDQ JHW LV KDYLQJ WKH VDPH QXPEHU RI LWHUDWLRQV
QHDU WR 625 EXW ZLWK PXFK PRUH WLPH QHHGHG IRU HDFK LWHUDWLRQ VWHS 6LQFH WKH

LQGLYLGXDO LWHUDWLRQ VWHSV LQ $', DUH PXFK PRUH FRPSOLFDWHG WKDQ LQ 625 WKH

$', PHWKRG ZRXOG DSSHDU WR EH LQIHULRU WKLV LV FHUWDLQO\ WUXH LI ZH FKRRVH WKH VDPH

SDUDPHWHU S LQ HYHU\ LWHUDWLRQ VWHS WKH WULFN LV WR FKRRVH D GLIIHUHQW S IRU HDFK VWHS WKLV
ZLOO QRW EH GRQH E\ WKH SDFNDJH  1RWLFH WKDW WKH LWHUDWLRQ QXPEHU WR EH LQGLFDWHG LV

DIWHU JRLQJ WKURXJK DOO URZV DQG DOO FROXPQV IRU WKDW LWHUDWLRQ VWHS

 (;$03/(6217+((//,37,&3'(5(*8/$5%281'$5,(6
$ SUREOHP ZLOO QRZ EH LQWURGXFHG DQG LW ZLOO EH VROYHG E\ GLIIHUHQW QXPHULFDO PHWKRGV

IRU GLIIHUHQW PHVK VL]HV DQG GLIIHUHQW ERXQGDU\ FRQGLWLRQV 6R WKDW WKH UHDGHU FRXOG EH

DEOH WR VHH WKH GLIIHUHQFH EHWZHHQ WKHVH PHWKRGV WKH DFFXUDF\ DQG WKH QXPEHU RI

LWHUDWLRQV QHHGHG E\ HDFK

 &RQVLGHULQJ LW DV D 'LULFKOHW SUREOHP DW ILUVW


$ W\SLFDO VWHDG\VWDWH KHDW IORZ SUREOHP LV WKH IROORZLQJ

$ WKLQ VWHHO SODWH LV  E\  FP UHFWDQJOH LI RQH RI WKH  FP HGJHV LV KHOG DW 

GHJUHHV &HOVLXV DQG WKH RWKHUV DUH KHOG DW  R& ZKDW DUH WKH VWHDG\VWDWH WHPSHUDWXUHV

DW WKH LQWHULRU SRLQWV"

)RU VWHHO N  FDOVHFFPR&FP

)LQG X [\ VXFK WKDW IRU WKH /DSODFH HTXDWLRQ

X [  R&

X [  R&

X \  R&

X \  R&

6ROYH XVLQJ WKH IROORZLQJ PHWKRGV ZLWK WROHUDQFH 

)RU K   FP

• *DXVV6HLGHO SRLQW DSSUR[LPDWLRQ S  S 

• *DXVV6HLGHO SRLQW DSSUR[LPDWLRQ S  S 

)RU K  FP

• 625 XVLQJ DQ RSWLPXP DFFHOHUDWLQJ IDFWRU SRLQW DSSUR[LPDWLRQ S 

• 625 XVLQJ DQ RSWLPXP DFFHOHUDWLQJ IDFWRU SRLQW DSSUR[LPDWLRQ S 

)RU K  FP

• *DXVV6HLGHO  SRLQW DSSUR[LPDWLRQ S 

• 625 XVLQJ DQ RSWLPXP DFFHOHUDWLQJ IDFWRU SRLQW DSSUR[LPDWLRQ S 

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 22

7KHQ VROYH XVLQJ WKHVH PHWKRGV ZLWK WROHUDQFH 

)RU K  FP

• $', ZLWKRXW S IDFWRU S 

• $', ZLWK RSWLPXP S IDFWRU S 

• $', ZLWK S IDFWRU  S 

• $', ZLWK S IDFWRU  S 

7KH DQDO\WLFDO DQVZHUV DUH X  X  X 

 &RQVLGHULQJ LW DV D 0L[HG SUREOHP

)RU K  FP ZLWK WKH ORZHU HGJH LQVXODWHG DQG WKH RWKHU ERXQGDU\

FRQGLWLRQV UHPDLQLQJ DV WKH\ DUH :LWK WROHUDQFH  DQG LQLWLDOL]LQJ WKH

LQWHUQDO PHVK SRLQWV WR 

• -DFREL SRLQW DSSUR[LPDWLRQ S 

• *DXVV6HLGHO SRLQW DSSUR[LPDWLRQ S 

• 625 XVLQJ DQ RSWLPXP DFFHOHUDWLQJ IDFWRU SRLQW DSSUR[LPDWLRQ S 

:KHQ UXQQLQJ WKH SURJUDP WKH IROORZLQJ SDJHV VKRZ WKH UHVXOWV REWDLQHG







 6HH JUDSK RQ SDJH 

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 23

6ROXWLRQ IRU WKH 'LULFKOHW SUREOHP ZLWK WROHUDQFH 

)RU K  FP

• *DXVV6HLGHO SRLQW DSSUR[LPDWLRQ

********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

1: Elliptic Partial Differential Equation

Your choice was

1: Dirichlet Problem - First Boundary Value Problem


- Regular boundaries

Your choice was

1 : Laplace eqn :constant boundaries

This program will use the average of the boundary values you enter as a guide
to the most appropriate value needed for initialization of the internal mesh
points, and the corner points of the grid will take the average values of the
boundaries that surround them - if you are not asked to enter them -

Grid dimensions -regular boundaries- as entered by user

Grid horizontal length is 20.00000


Grid vertical length is 10.00000
Mesh size -h- is 5.00000

The # of internal mesh points is 3

The # of mesh points that we'll be operating on


including the ones on the boundary is:
For 5 point approximations 11
For 9 point approximations 15

Your choice was

2 : Gauss-Seidel iterative method for solving systems of eqs


Liebmann's Method - using 5 point approximation

Number of iterations needed was 6 for 1.00000e-03 tolerance

The array will look like this


From the upper to the lower side

rows= 3
columns= 5

row # 3
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
5.00000e+01

row # 2
0.00000e+00 1.78560e+00 7.14280e+00 2.67857e+01
1.00000e+02

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 24

row # 1
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
5.00000e+01

Local time is: Wed Apr 20 07:06:20 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 25

6ROXWLRQ IRU WKH 'LULFKOHW SUREOHP ZLWK WROHUDQFH 

)RU K  FP

• *DXVV6HLGHO SRLQW DSSUR[LPDWLRQ

********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

1: Elliptic Partial Differential Equation

Your choice was

1: Dirichlet Problem - First Boundary Value Problem


- Regular boundaries

Your choice was

1 : Laplace eqn :constant boundaries

This program will use the average of the boundary values you enter as a guide
to the most appropriate value needed for initialization of the internal mesh
points, and the corner points of the grid will take the average values of the
boundaries that surround them - if you are not asked to enter them -

Grid dimensions -regular boundaries- as entered by user

Grid horizontal length is 20.00000


Grid vertical length is 10.00000
Mesh size -h- is 2.50000

The # of internal mesh points is 21

The # of mesh points that we'll be operating on


including the ones on the boundary is:
For 5 point approximations 41
For 9 point approximations 45

Your choice was

2 : Gauss-Seidel iterative method for solving systems of eqs


Liebmann's Method - using 5 point approximation

Number of iterations needed was 17 for 1.00000e-03 tolerance

The array will look like this


From the upper to the lower side

rows= 5
columns= 9

row # 5
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
5.00000e+01

row # 4
0.00000e+00 3.52813e-01 9.12724e-01 2.00965e+00
4.29499e+00 9.15254e+00 1.96628e+01 4.32100e+01
1.00000e+02

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 26

row # 3
0.00000e+00 4.98599e-01 1.28869e+00 2.83124e+00
6.01813e+00 1.26527e+01 2.62886e+01 5.31771e+01
1.00000e+02

row # 2
0.00000e+00 3.52873e-01 9.12653e-01 2.00939e+00
4.29463e+00 9.15219e+00 1.96625e+01 4.32098e+01
1.00000e+02

row # 1
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
5.00000e+01

Local time is: Wed Apr 20 07:07:07 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 27

6ROXWLRQ IRU WKH 'LULFKOHW SUREOHP ZLWK WROHUDQFH 

)RU K  FP

• *DXVV6HLGHO SRLQW DSSUR[LPDWLRQ

********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

1: Elliptic Partial Differential Equation

Your choice was

1: Dirichlet Problem - First Boundary Value Problem


- Regular boundaries

Your choice was

1 : Laplace eqn :constant boundaries

This program will use the average of the boundary values you enter as a guide
to the most appropriate value needed for initialization of the internal mesh
points, and the corner points of the grid will take the average values of the
boundaries that surround them - if you are not asked to enter them -

Grid dimensions -regular boundaries- as entered by user

Grid horizontal length is 20.00000


Grid vertical length is 10.00000
Mesh size -h- is 5.00000

The # of internal mesh points is 3

The # of mesh points that we'll be operating on


including the ones on the boundary is:
For 5 point approximations 11
For 9 point approximations 15

Your choice was

4 : Gauss-Seidel iterative method for solving systems of eqs


Liebmann's Method - using 9 point approximation

Number of iterations needed was 6 for 1.00000e-03 tolerance

The array will look like this


From the upper to the lower side

rows= 3
columns= 5

row # 3
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
5.00000e+01

row # 2
0.00000e+00 1.08694e+00 5.43478e+00 2.60870e+01
1.00000e+02

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 28

row # 1
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
5.00000e+01

Local time is: Wed Apr 20 07:07:50 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 29

6ROXWLRQ IRU WKH 'LULFKOHW SUREOHP ZLWK WROHUDQFH 

)RU K  FP

• *DXVV6HLGHO SRLQW DSSUR[LPDWLRQ

********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

1: Elliptic Partial Differential Equation

Your choice was

1: Dirichlet Problem - First Boundary Value Problem


- Regular boundaries

Your choice was

1 : Laplace eqn :constant boundaries

This program will use the average of the boundary values you enter as a guide
to the most appropriate value needed for initialization of the internal mesh
points, and the corner points of the grid will take the average values of the
boundaries that surround them - if you are not asked to enter them -

Grid dimensions -regular boundaries- as entered by user

Grid horizontal length is 20.00000


Grid vertical length is 10.00000
Mesh size -h- is 2.50000

The # of internal mesh points is 21

The # of mesh points that we'll be operating on


including the ones on the boundary is:
For 5 point approximations 41
For 9 point approximations 45

Your choice was

4 : Gauss-Seidel iterative method for solving systems of eqs


Liebmann's Method - using 9 point approximation

Number of iterations needed was 16 for 1.00000e-03 tolerance

The array will look like this


From the upper to the lower side

rows= 5
columns= 9

row # 5
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
5.00000e+01

row # 4
0.00000e+00 2.92290e-01 7.73947e-01 1.75778e+00
3.88428e+00 8.55107e+00 1.89555e+01 4.34986e+01
1.00000e+02

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 30

row # 3
0.00000e+00 4.13502e-01 1.09465e+00 2.48531e+00
5.48594e+00 1.20205e+01 2.60941e+01 5.45138e+01
1.00000e+02

row # 2
0.00000e+00 2.92540e-01 7.74283e-01 1.75809e+00
3.88450e+00 8.55121e+00 1.89555e+01 4.34986e+01
1.00000e+02

row # 1
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
5.00000e+01

Local time is: Wed Apr 20 07:08:33 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 31

6ROXWLRQ IRU WKH 'LULFKOHW SUREOHP ZLWK WROHUDQFH 

)RU K  FP

• 625 XVLQJ DQ RSWLPXP DFFHOHUDWLQJ IDFWRU SRLQW DSSUR[LPDWLRQ

********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

1: Elliptic Partial Differential Equation

Your choice was

1: Dirichlet Problem - First Boundary Value Problem


- Regular boundaries

Your choice was

1 : Laplace eqn :constant boundaries

This program will use the average of the boundary values you enter as a guide
to the most appropriate value needed for initialization of the internal mesh
points, and the corner points of the grid will take the average values of the
boundaries that surround them - if you are not asked to enter them -

Grid dimensions -regular boundaries- as entered by user

Grid horizontal length is 20.00000


Grid vertical length is 10.00000
Mesh size -h- is 2.50000

The # of internal mesh points is 21

The # of mesh points that we'll be operating on


including the ones on the boundary is:
For 5 point approximations 41
For 9 point approximations 45

Your choice was

6 : Successive Overrelaxation method using an optimum S.O.R. factor


using 5 point approximation

The optimum value of the S.O.R. factor used is, w = 1.266812

The number of iterations needed was 12 for 1.00000e-03 tolerance

The array will look like this


From the upper to the lower side

rows= 5
columns= 9

row # 5
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
5.00000e+01

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 32

row # 4
0.00000e+00 3.52871e-01 9.13036e-01 2.01022e+00
4.29567e+00 9.15315e+00 1.96632e+01 4.32101e+01
1.00000e+02

row # 3
0.00000e+00 4.98566e-01 1.28913e+00 2.83215e+00
6.01928e+00 1.26537e+01 2.62894e+01 5.31774e+01
1.00000e+02

row # 2
0.00000e+00 3.52633e-01 9.12706e-01 2.00998e+00
4.29554e+00 9.15309e+00 1.96631e+01 4.32101e+01
1.00000e+02

row # 1
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
5.00000e+01

Local time is: Wed Apr 20 07:09:31 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 33

6ROXWLRQ IRU WKH 'LULFKOHW SUREOHP ZLWK WROHUDQFH 

)RU K  FP

• 625 XVLQJ DQ RSWLPXP DFFHOHUDWLQJ IDFWRU SRLQW DSSUR[LPDWLRQ

********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

1: Elliptic Partial Differential Equation

Your choice was

1: Dirichlet Problem - First Boundary Value Problem


- Regular boundaries

Your choice was

1 : Laplace eqn :constant boundaries

This program will use the average of the boundary values you enter as a guide
to the most appropriate value needed for initialization of the internal mesh
points, and the corner points of the grid will take the average values of the
boundaries that surround them - if you are not asked to enter them -

Grid dimensions -regular boundaries- as entered by user

Grid horizontal length is 20.00000


Grid vertical length is 10.00000
Mesh size -h- is 2.50000

The # of internal mesh points is 21

The # of mesh points that we'll be operating on


including the ones on the boundary is:
For 5 point approximations 41
For 9 point approximations 45

Your choice was

8 : Successive Overrelaxation method using an optimum S.O.R. factor


using 9 point approximation

The optimum value of the S.O.R. factor used is, w = 1.266812

The number of iterations needed was 13 for 1.00000e-03 tolerance

The array will look like this


From the upper to the lower side

rows= 5
columns= 9

row # 5
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
5.00000e+01

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 34

row # 4
0.00000e+00 2.91966e-01 7.73503e-01 1.75734e+00
3.88392e+00 8.55082e+00 1.89553e+01 4.34985e+01
1.00000e+02

row # 3
0.00000e+00 4.12892e-01 1.09384e+00 2.48449e+00
5.48529e+00 1.20201e+01 2.60938e+01 5.45137e+01
1.00000e+02

row # 2
0.00000e+00 2.92088e-01 7.73512e-01 1.75733e+00
3.88392e+00 8.55081e+00 1.89553e+01 4.34985e+01
1.00000e+02

row # 1
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
5.00000e+01

Local time is: Wed Apr 20 07:10:15 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 35

6ROXWLRQ IRU WKH 'LULFKOHW SUREOHP ZLWK WROHUDQFH 

)RU K  FP

• *DXVV6HLGHO SRLQW DSSUR[LPDWLRQ

********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

1: Elliptic Partial Differential Equation

Your choice was

1: Dirichlet Problem - First Boundary Value Problem


- Regular boundaries

Your choice was

1 : Laplace eqn :constant boundaries

This program will use the average of the boundary values you enter as a guide
to the most appropriate value needed for initialization of the internal mesh
points, and the corner points of the grid will take the average values of the
boundaries that surround them - if you are not asked to enter them -

Grid dimensions -regular boundaries- as entered by user

Grid horizontal length is 20.00000


Grid vertical length is 10.00000
Mesh size -h- is 1.25000

The # of internal mesh points is 105

The # of mesh points that we'll be operating on


including the ones on the boundary is:
For 5 point approximations 149
For 9 point approximations 153

Your choice was

2 : Gauss-Seidel iterative method for solving systems of eqs


Liebmann's Method - using 5 point approximation

Number of iterations needed was 66 for 1.00000e-03 tolerance

The array will look like this


From the upper to the lower side

rows= 9
columns= 17

row # 9
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
5.00000e+01

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 36

row # 8
0.00000e+00 7.81643e-02 1.67963e-01 2.82941e-01
4.40534e-01 6.64752e-01 9.89926e-01 1.46619e+00
2.16786e+00 3.20706e+00 4.75745e+00 7.10101e+00
1.07334e+01 1.66385e+01 2.70972e+01 4.83363e+01
1.00000e+02

row # 7
0.00000e+00 1.44514e-01 3.10504e-01 5.22985e-01
8.14141e-01 1.22825e+00 1.82848e+00 2.70669e+00
3.99797e+00 5.90274e+00 8.72159e+00 1.29130e+01
1.91941e+01 2.87235e+01 4.34139e+01 6.62480e+01
1.00000e+02

row # 6
0.00000e+00 1.88934e-01 4.05900e-01 6.83563e-01
1.06393e+00 1.60474e+00 2.38819e+00 3.53334e+00
5.21390e+00 7.68371e+00 1.13127e+01 1.66349e+01
2.44062e+01 3.56472e+01 5.15869e+01 7.32418e+01
1.00000e+02

row # 5
0.00000e+00 2.04639e-01 4.39592e-01 7.40204e-01
1.15192e+00 1.73720e+00 2.58485e+00 3.82332e+00
5.63945e+00 8.30458e+00 1.22097e+01 1.79072e+01
2.61481e+01 3.78719e+01 5.40445e+01 7.51320e+01
1.00000e+02

row # 4
0.00000e+00 1.89202e-01 4.06389e-01 6.84216e-01
1.06469e+00 1.60555e+00 2.38899e+00 3.53411e+00
5.21459e+00 7.68432e+00 1.13132e+01 1.66353e+01
2.44065e+01 3.56474e+01 5.15871e+01 7.32418e+01
1.00000e+02

row # 3
0.00000e+00 1.44925e-01 3.11254e-01 5.23986e-01
8.15304e-01 1.22949e+00 1.82971e+00 2.70787e+00
3.99904e+00 5.90367e+00 8.72238e+00 1.29136e+01
1.91946e+01 2.87239e+01 4.34142e+01 6.62481e+01
1.00000e+02

row # 2
0.00000e+00 7.84994e-02 1.68573e-01 2.83756e-01
4.41480e-01 6.65759e-01 9.90932e-01 1.46714e+00
2.16873e+00 3.20782e+00 4.75809e+00 7.10152e+00
1.07338e+01 1.66388e+01 2.70974e+01 4.83364e+01
1.00000e+02

row # 1
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
5.00000e+01

Local time is: Thu Apr 21 02:10:52 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 37

6ROXWLRQ IRU WKH 'LULFKOHW SUREOHP ZLWK WROHUDQFH 

)RU K  FP

• 625 XVLQJ DQ RSWLPXP DFFHOHUDWLQJ IDFWRU SRLQW DSSUR[LPDWLRQ

*****************************************************************************
***
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

1: Elliptic Partial Differential Equation

Your choice was

1: Dirichlet Problem - First Boundary Value Problem


- Regular boundaries

Your choice was

1 : Laplace eqn :constant boundaries

This program will use the average of the boundary values you enter as a guide
to the most appropriate value needed for initialization of the internal mesh
points, and the corner points of the grid will take the average values of the
boundaries that surround them - if you are not asked to enter them -

Grid dimensions -regular boundaries- as entered by user

Grid horizontal length is 20.00000


Grid vertical length is 10.00000
Mesh size -h- is 1.25000

The # of internal mesh points is 105

The # of mesh points that we'll be operating on


including the ones on the boundary is:
For 5 point approximations 149
For 9 point approximations 153

Your choice was

6 : Successive Overrelaxation method using an optimum S.O.R. factor


using 5 point approximation

The optimum value of the S.O.R. factor used is, w = 1.532494

The number of iterations needed was 26 for 1.00000e-03 tolerance

The array will look like this


From the upper to the lower side

rows= 9
columns= 17

row # 9
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
5.00000e+01

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 38

row # 8
0.00000e+00 7.72686e-02 1.66318e-01 2.80749e-01
4.37961e-01 6.61973e-01 9.87100e-01 1.46344e+00
2.16530e+00 3.20476e+00 4.75545e+00 7.09934e+00
1.07321e+01 1.66376e+01 2.70966e+01 4.83360e+01
1.00000e+02

row # 7
0.00000e+00 1.42742e-01 3.07349e-01 5.18730e-01
8.09134e-01 1.22284e+00 1.82297e+00 2.70135e+00
3.99299e+00 5.89826e+00 8.71771e+00 1.29098e+01
1.91916e+01 2.87216e+01 4.34127e+01 6.62474e+01
1.00000e+02

row # 6
0.00000e+00 1.86509e-01 4.01455e-01 6.77614e-01
1.05697e+00 1.59723e+00 2.38057e+00 3.52596e+00
5.20703e+00 7.67756e+00 1.13074e+01 1.66305e+01
2.44027e+01 3.56447e+01 5.15853e+01 7.32410e+01
1.00000e+02

row # 5
0.00000e+00 2.01882e-01 4.34651e-01 7.33456e-01
1.14399e+00 1.72866e+00 2.57617e+00 3.81493e+00
5.63164e+00 8.29759e+00 1.22036e+01 1.79022e+01
2.61442e+01 3.78690e+01 5.40427e+01 7.51311e+01
1.00000e+02

row # 4
0.00000e+00 1.86414e-01 4.01325e-01 6.77508e-01
1.05687e+00 1.59711e+00 2.38047e+00 3.52589e+00
5.20697e+00 7.67751e+00 1.13073e+01 1.66305e+01
2.44027e+01 3.56447e+01 5.15853e+01 7.32410e+01
1.00000e+02

row # 3
0.00000e+00 1.42745e-01 3.07068e-01 5.18374e-01
8.08839e-01 1.22261e+00 1.82280e+00 2.70120e+00
3.99288e+00 5.89818e+00 8.71767e+00 1.29098e+01
1.91916e+01 2.87216e+01 4.34127e+01 6.62474e+01
1.00000e+02

row # 2
0.00000e+00 7.72452e-02 1.66160e-01 2.80531e-01
4.37678e-01 6.61763e-01 9.86971e-01 1.46334e+00
2.16522e+00 3.20469e+00 4.75542e+00 7.09933e+00
1.07321e+01 1.66376e+01 2.70966e+01 4.83360e+01
1.00000e+02

row # 1
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
5.00000e+01

Local time is: Thu Apr 21 02:12:59 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 39

6ROXWLRQ IRU WKH 'LULFKOHW SUREOHP ZLWK WROHUDQFH 

)RU K  FP

• $', ZLWKRXW S IDFWRU

*****************************************************************************
***
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

1: Elliptic Partial Differential Equation

Your choice was

1: Dirichlet Problem - First Boundary Value Problem


- Regular boundaries

Your choice was

1 : Laplace eqn :constant boundaries

This program will use the average of the boundary values you enter as a guide
to the most appropriate value needed for initialization of the internal mesh
points, and the corner points of the grid will take the average values of the
boundaries that surround them - if you are not asked to enter them -

Grid dimensions -regular boundaries- as entered by user

Grid horizontal length is 20.00000


Grid vertical length is 10.00000
Mesh size -h- is 1.25000

The # of internal mesh points is 105

The # of mesh points that we'll be operating on


including the ones on the boundary is:
For 5 point approximations 149
For 9 point approximations 153

Your choice was

9 : using the alternating-direction implicit method (A.D.I.) without P


factor

Number of iterations needed was 48 for 1.00000e-04 tolerance

The array will look like this


From the upper to the lower side

rows= 9
columns= 17

row # 9
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
5.00000e+01

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 40

row # 8
0.00000e+00 7.74228e-02 1.66612e-01 2.81131e-01
4.38422e-01 6.62489e-01 9.87644e-01 1.46400e+00
2.16586e+00 3.20530e+00 4.75596e+00 7.09980e+00
1.07325e+01 1.66379e+01 2.70968e+01 4.83361e+01
1.00000e+02

row # 7
0.00000e+00 1.43058e-01 3.07850e-01 5.19430e-01
8.09995e-01 1.22381e+00 1.82400e+00 2.70240e+00
3.99404e+00 5.89928e+00 8.71867e+00 1.29106e+01
1.91923e+01 2.87222e+01 4.34131e+01 6.62476e+01
1.00000e+02

row # 6
0.00000e+00 1.86909e-01 4.02210e-01 6.78621e-01
1.05817e+00 1.59856e+00 2.38197e+00 3.52738e+00
5.20844e+00 7.67891e+00 1.13086e+01 1.66317e+01
2.44037e+01 3.56454e+01 5.15858e+01 7.32412e+01
1.00000e+02

row # 5
0.00000e+00 2.02306e-01 4.35339e-01 7.34508e-01
1.14528e+00 1.73008e+00 2.57768e+00 3.81646e+00
5.63316e+00 8.29906e+00 1.22050e+01 1.79034e+01
2.61452e+01 3.78699e+01 5.40432e+01 7.51314e+01
1.00000e+02

row # 4
0.00000e+00 1.86914e-01 4.02219e-01 6.78633e-01
1.05818e+00 1.59858e+00 2.38198e+00 3.52740e+00
5.20845e+00 7.67893e+00 1.13086e+01 1.66317e+01
2.44037e+01 3.56454e+01 5.15858e+01 7.32412e+01
1.00000e+02

row # 3
0.00000e+00 1.43068e-01 3.07870e-01 5.19457e-01
8.10026e-01 1.22384e+00 1.82404e+00 2.70244e+00
3.99408e+00 5.89931e+00 8.71871e+00 1.29107e+01
1.91923e+01 2.87222e+01 4.34131e+01 6.62476e+01
1.00000e+02

row # 2
0.00000e+00 7.74334e-02 1.66631e-01 2.81156e-01
4.38452e-01 6.62522e-01 9.87678e-01 1.46403e+00
2.16589e+00 3.20533e+00 4.75600e+00 7.09983e+00
1.07325e+01 1.66379e+01 2.70968e+01 4.83361e+01
1.00000e+02

row # 1
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
5.00000e+01

Local time is: Sat Apr 23 01:47:11 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 41

6ROXWLRQ IRU WKH 'LULFKOHW SUREOHP ZLWK WROHUDQFH 

)RU K  FP

• $', ZLWK RSWLPXP S IDFWRU

*****************************************************************************
***
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

1: Elliptic Partial Differential Equation

Your choice was

1: Dirichlet Problem - First Boundary Value Problem


- Regular boundaries

Your choice was

1 : Laplace eqn :constant boundaries

This program will use the average of the boundary values you enter as a guide
to the most appropriate value needed for initialization of the internal mesh
points, and the corner points of the grid will take the average values of the
boundaries that surround them - if you are not asked to enter them -

Grid dimensions -regular boundaries- as entered by user

Grid horizontal length is 20.00000


Grid vertical length is 10.00000
Mesh size -h- is 1.25000

The # of internal mesh points is 105

The # of mesh points that we'll be operating on


including the ones on the boundary is:
For 5 point approximations 149
For 9 point approximations 153

Your choice was

11: using the alternating-direction implicit method (A.D.I.) with optimum


P factor

The optimum value of P for maximum rate of convergence is, p = 0.390181

The number of iterations needed was 25 for 1.00000e-04 tolerance

The array will look like this


From the upper to the lower side

rows= 9
columns= 17

row # 9
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
5.00000e+01

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 42

row # 8
0.00000e+00 7.73056e-02 1.66379e-01 2.80801e-01
4.38009e-01 6.62012e-01 9.87124e-01 1.46345e+00
2.16531e+00 3.20476e+00 4.75546e+00 7.09934e+00
1.07321e+01 1.66376e+01 2.70966e+01 4.83360e+01
1.00000e+02

row # 7
0.00000e+00 1.42831e-01 3.07423e-01 5.18811e-01
8.09226e-01 1.22292e+00 1.82303e+00 2.70139e+00
3.99302e+00 5.89827e+00 8.71772e+00 1.29098e+01
1.91916e+01 2.87216e+01 4.34127e+01 6.62474e+01
1.00000e+02

row # 6
0.00000e+00 1.86628e-01 4.01635e-01 6.77818e-01
1.05716e+00 1.59740e+00 2.38070e+00 3.52606e+00
5.20710e+00 7.67760e+00 1.13074e+01 1.66305e+01
2.44027e+01 3.56447e+01 5.15853e+01 7.32409e+01
1.00000e+02

row # 5
0.00000e+00 2.01982e-01 4.34737e-01 7.33644e-01
1.14419e+00 1.72883e+00 2.57632e+00 3.81504e+00
5.63172e+00 8.29764e+00 1.22037e+01 1.79022e+01
2.61442e+01 3.78690e+01 5.40427e+01 7.51312e+01
1.00000e+02

row # 4
0.00000e+00 1.86628e-01 4.01645e-01 6.77807e-01
1.05716e+00 1.59741e+00 2.38071e+00 3.52606e+00
5.20710e+00 7.67760e+00 1.13074e+01 1.66305e+01
2.44028e+01 3.56447e+01 5.15853e+01 7.32409e+01
1.00000e+02

row # 3
0.00000e+00 1.42830e-01 3.07418e-01 5.18821e-01
8.09231e-01 1.22292e+00 1.82304e+00 2.70139e+00
3.99302e+00 5.89828e+00 8.71773e+00 1.29098e+01
1.91916e+01 2.87217e+01 4.34127e+01 6.62474e+01
1.00000e+02

row # 2
0.00000e+00 7.73211e-02 1.66372e-01 2.80807e-01
4.38010e-01 6.62026e-01 9.87134e-01 1.46347e+00
2.16532e+00 3.20477e+00 4.75546e+00 7.09936e+00
1.07321e+01 1.66376e+01 2.70966e+01 4.83360e+01
1.00000e+02

row # 1
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
5.00000e+01

Local time is: Sat Apr 23 01:55:08 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 43

6ROXWLRQ IRU WKH 'LULFKOHW SUREOHP ZLWK WROHUDQFH 

)RU K  FP

• $', ZLWK S IDFWRU 

*****************************************************************************
***
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

1: Elliptic Partial Differential Equation

Your choice was

1: Dirichlet Problem - First Boundary Value Problem


- Regular boundaries

Your choice was

1 : Laplace eqn :constant boundaries

This program will use the average of the boundary values you enter as a guide
to the most appropriate value needed for initialization of the internal mesh
points, and the corner points of the grid will take the average values of the
boundaries that surround them - if you are not asked to enter them -

Grid dimensions -regular boundaries- as entered by user

Grid horizontal length is 20.00000


Grid vertical length is 10.00000
Mesh size -h- is 1.25000

The # of internal mesh points is 105

The # of mesh points that we'll be operating on


including the ones on the boundary is:
For 5 point approximations 149
For 9 point approximations 153

Your choice was

10: using the alternating-direction implicit method (A.D.I.) with the user
entering his/her P factor

The proper choice of the parameter P can accelerate the convergence

If your value of P is far from the optimum value then instead of having the
same number of iterations near to SOR they will be increased, since the
individual
iteration steps in ADI are much more complicated than in SOR, the ADI method
would appear to be inferior, this is certainly true if we choose the same
parameter P in every iteration step, the trick is to choose a different P for
each step-this will not be done by this program,the P you enter is the one that
will be used - also notice that the iteration number to be indicated is after
going through all rows and all columns for that iterational step

For the value of P entered, p = 1.500000

The number of iterations needed was 37 for 1.00000e-04 tolerance

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 44

The array will look like this


From the upper to the lower side
rows= 9
columns= 17

row # 9
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
5.00000e+01

row # 8
0.00000e+00 7.74051e-02 1.66577e-01 2.81082e-01
4.38359e-01 6.62414e-01 9.87563e-01 1.46391e+00
2.16577e+00 3.20521e+00 4.75588e+00 7.09973e+00
1.07325e+01 1.66378e+01 2.70968e+01 4.83361e+01
1.00000e+02

row # 7
0.00000e+00 1.43026e-01 3.07788e-01 5.19342e-01
8.09880e-01 1.22367e+00 1.82385e+00 2.70224e+00
3.99388e+00 5.89912e+00 8.71852e+00 1.29105e+01
1.91922e+01 2.87221e+01 4.34131e+01 6.62476e+01
1.00000e+02

row # 6
0.00000e+00 1.86869e-01 4.02131e-01 6.78507e-01
1.05802e+00 1.59839e+00 2.38178e+00 3.52718e+00
5.20823e+00 7.67871e+00 1.13084e+01 1.66315e+01
2.44036e+01 3.56453e+01 5.15857e+01 7.32412e+01
1.00000e+02

row # 5
0.00000e+00 2.02263e-01 4.35255e-01 7.34386e-01
1.14513e+00 1.72989e+00 2.57748e+00 3.81625e+00
5.63294e+00 8.29884e+00 1.22048e+01 1.79033e+01
2.61451e+01 3.78697e+01 5.40432e+01 7.51314e+01
1.00000e+02

row # 4
0.00000e+00 1.86875e-01 4.02142e-01 6.78521e-01
1.05804e+00 1.59841e+00 2.38180e+00 3.52720e+00
5.20825e+00 7.67873e+00 1.13084e+01 1.66315e+01
2.44036e+01 3.56453e+01 5.15857e+01 7.32412e+01
1.00000e+02

row # 3
0.00000e+00 1.43039e-01 3.07813e-01 5.19374e-01
8.09919e-01 1.22371e+00 1.82389e+00 2.70229e+00
3.99392e+00 5.89916e+00 8.71857e+00 1.29106e+01
1.91922e+01 2.87222e+01 4.34131e+01 6.62476e+01
1.00000e+02

row # 2
0.00000e+00 7.74175e-02 1.66600e-01 2.81111e-01
4.38394e-01 6.62452e-01 9.87600e-01 1.46395e+00
2.16581e+00 3.20525e+00 4.75592e+00 7.09977e+00
1.07325e+01 1.66379e+01 2.70968e+01 4.83361e+01
1.00000e+02

row # 1
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
5.00000e+01

Local time is: Sat Apr 23 02:02:48 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 45

6ROXWLRQ IRU WKH 'LULFKOHW SUREOHP ZLWK WROHUDQFH 

)RU K  FP

• $', ZLWK S IDFWRU 

*****************************************************************************
***
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

1: Elliptic Partial Differential Equation

Your choice was

1: Dirichlet Problem - First Boundary Value Problem


- Regular boundaries

Your choice was

1 : Laplace eqn :constant boundaries

This program will use the average of the boundary values you enter as a guide
to the most appropriate value needed for initialization of the internal mesh
points, and the corner points of the grid will take the average values of the
boundaries that surround them - if you are not asked to enter them -

Grid dimensions -regular boundaries- as entered by user

Grid horizontal length is 20.00000


Grid vertical length is 10.00000
Mesh size -h- is 1.25000

The # of internal mesh points is 105

The # of mesh points that we'll be operating on


including the ones on the boundary is:
For 5 point approximations 149
For 9 point approximations 153

Your choice was

10: using the alternating-direction implicit method (A.D.I.) with the user
entering his/her P factor

The proper choice of the parameter P can accelerate the convergence

If your value of P is far from the optimum value then instead of having the
same number of iterations near to SOR they will be increased, since the
individual
iteration steps in ADI are much more complicated than in SOR, the ADI method
would appear to be inferior, this is certainly true if we choose the same
parameter P in every iteration step, the trick is to choose a different P for
each step-this will not be done by this program,the P you enter is the one
that
will be used - also notice that the iteration number to be indicated is after
going through all rows and all columns for that iterational step

For the value of P entered, p = 1.100000


The number of iterations needed was 29 for 1.00000e-04 tolerance

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 46

The array will look like this


From the upper to the lower side
rows= 9
columns= 17

row # 9
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
5.00000e+01

row # 8
0.00000e+00 7.73736e-02 1.66516e-01 2.80994e-01
4.38249e-01 6.62285e-01 9.87419e-01 1.46376e+00
2.16562e+00 3.20506e+00 4.75574e+00 7.09960e+00
1.07323e+01 1.66378e+01 2.70967e+01 4.83361e+01
1.00000e+02

row # 7
0.00000e+00 1.42968e-01 3.07676e-01 5.19180e-01
8.09679e-01 1.22343e+00 1.82359e+00 2.70197e+00
3.99360e+00 5.89885e+00 8.71827e+00 1.29103e+01
1.91920e+01 2.87220e+01 4.34129e+01 6.62475e+01
1.00000e+02

row # 6
0.00000e+00 1.86795e-01 4.01987e-01 6.78298e-01
1.05776e+00 1.59808e+00 2.38144e+00 3.52682e+00
5.20787e+00 7.67836e+00 1.13081e+01 1.66312e+01
2.44033e+01 3.56451e+01 5.15856e+01 7.32411e+01
1.00000e+02

row # 5
0.00000e+00 2.02187e-01 4.35105e-01 7.34171e-01
1.14485e+00 1.72958e+00 2.57712e+00 3.81588e+00
5.63256e+00 8.29847e+00 1.22044e+01 1.79029e+01
2.61448e+01 3.78695e+01 5.40430e+01 7.51313e+01
1.00000e+02

row # 4
0.00000e+00 1.86801e-01 4.02000e-01 6.78314e-01
1.05778e+00 1.59811e+00 2.38146e+00 3.52684e+00
5.20789e+00 7.67838e+00 1.13081e+01 1.66312e+01
2.44033e+01 3.56451e+01 5.15856e+01 7.32411e+01
1.00000e+02

row # 3
0.00000e+00 1.42979e-01 3.07696e-01 5.19207e-01
8.09709e-01 1.22347e+00 1.82363e+00 2.70200e+00
3.99363e+00 5.89888e+00 8.71830e+00 1.29103e+01
1.91920e+01 2.87220e+01 4.34130e+01 6.62475e+01
1.00000e+02

row # 2
0.00000e+00 7.73845e-02 1.66535e-01 2.81019e-01
4.38278e-01 6.62318e-01 9.87451e-01 1.46379e+00
2.16565e+00 3.20510e+00 4.75578e+00 7.09963e+00
1.07324e+01 1.66378e+01 2.70967e+01 4.83361e+01
1.00000e+02

row # 1
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
5.00000e+01

Local time is: Sat Apr 23 02:09:14 1994


Thank you for using Kutkut's Numerical PDE Solver
February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 47

6ROXWLRQ IRU WKH 0L[HG SUREOHP ZLWK WROHUDQFH 

)RU K  FP ZLWK WKH ORZHU HGJH LQVXODWHG DQG WKH RWKHU ERXQGDU\ FRQGLWLRQV

UHPDLQLQJ DV WKH\ DUH ,QLWLDOL]LQJ WKH LQWHUQDO PHVK SRLQWV WR 

• -DFREL SRLQW DSSUR[LPDWLRQ

*****************************************************************************
***
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

1: Elliptic Partial Differential Equation

Your choice was

3: Neumann Problem - Second Boundary Value Problem

Your choice was

1: Laplace eqn :Neumann Problem

Grid dimensions -regular boundaries- as entered by user

Grid horizontal length is 20.00000


Grid vertical length is 10.00000
Mesh size -h- is 2.50000

Your choice was

1: Jacobi iterative method for solving systems of eqs


using 5 point approximation method

The four boundaries were not expressed as derivatives


And you selected ( solving a Neumann Problem ), when the four
boundaries are expressed as derivatives then the Elliptic eqn
is a Second Order Boundary Value Problem or a Neumann Problem
You have a Problem with Nomenclature, be careful !!!

I will continue solving your Mixed Problem

The number of internal mesh points is 28

The number of total mesh points used in calculatios including fictious


when present is 50

Number of iterations needed was 190 for 1.00000e-04 tolerance

The array will look like this


From the upper to the lower side

rows= 5
columns= 9

row # 5
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
1.00000e+02

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 48

row # 4
0.00000e+00 1.74148e+00 3.76863e+00 6.43772e+00
1.02945e+01 1.63571e+01 2.69305e+01 4.82588e+01
1.00000e+02

row # 3
0.00000e+00 3.19721e+00 6.89528e+00 1.16876e+01
1.83831e+01 2.82035e+01 4.31058e+01 6.61049e+01
1.00000e+02

row # 2
0.00000e+00 4.15196e+00 8.92745e+00 1.50341e+01
2.33466e+01 3.49678e+01 5.11843e+01 7.30547e+01
1.00000e+02

row # 1
0.00000e+00 4.48309e+00 9.62818e+00 1.61745e+01
2.50012e+01 3.71364e+01 5.36087e+01 7.49296e+01
1.00000e+02

Local time is: Sun Apr 24 04:28:32 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 49

6ROXWLRQ IRU WKH 0L[HG SUREOHP ZLWK WROHUDQFH 

)RU K  FP ZLWK WKH ORZHU HGJH LQVXODWHG DQG WKH RWKHU ERXQGDU\ FRQGLWLRQV

UHPDLQLQJ DV WKH\ DUH ,QLWLDOL]LQJ WKH LQWHUQDO PHVK SRLQWV WR 

• *DXVV6HLGHO SRLQW DSSUR[LPDWLRQ

********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

1: Elliptic Partial Differential Equation

Your choice was

4: Mixed Problem

Your choice was

1: Laplace eqn :Mixed Problem

Grid dimensions -regular boundaries- as entered by user

Grid horizontal length is 20.00000


Grid vertical length is 10.00000
Mesh size -h- is 2.50000

Your choice was

2: Gauss-Seidel iterative method for solving systems of eqs


Liebmann's Method - using 5 point approximation method

The number of internal mesh points is 28

The number of total mesh points used in calculatios including fictious


when present is 50

Number of iterations needed was 70 for 1.00000e-04 tolerance

The array will look like this


From the upper to the lower side

rows= 5
columns= 9

row # 5
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
1.00000e+02

row # 4
0.00000e+00 1.74138e+00 3.76846e+00 6.43749e+00
1.02943e+01 1.63569e+01 2.69303e+01 4.82587e+01
1.00000e+02

row # 3
0.00000e+00 3.19703e+00 6.89495e+00 1.16872e+01
1.83827e+01 2.82031e+01 4.31055e+01 6.61047e+01
1.00000e+02

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 50

row # 2
0.00000e+00 4.15175e+00 8.92704e+00 1.50336e+01
2.33460e+01 3.49672e+01 5.11839e+01 7.30545e+01
1.00000e+02

row # 1
0.00000e+00 4.48285e+00 9.62776e+00 1.61739e+01
2.50005e+01 3.71359e+01 5.36083e+01 7.49293e+01
1.00000e+02

Local time is: Sun Apr 24 03:38:58 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 51

6ROXWLRQ IRU WKH 0L[HG SUREOHP ZLWK WROHUDQFH 

)RU K  FP ZLWK WKH ORZHU HGJH LQVXODWHG DQG WKH RWKHU ERXQGDU\ FRQGLWLRQV

UHPDLQLQJ DV WKH\ DUH ,QLWLDOL]LQJ WKH LQWHUQDO PHVK SRLQWV WR 

• 625 XVLQJ DQ RSWLPXP DFFHOHUDWLQJ IDFWRU SRLQW DSSUR[LPDWLRQ

********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

1: Elliptic Partial Differential Equation

Your choice was

4: Mixed Problem

Your choice was

1: Laplace eqn :Mixed Problem

Grid dimensions -regular boundaries- as entered by user

Grid horizontal length is 20.00000


Grid vertical length is 10.00000
Mesh size -h- is 2.50000

Your choice was

3: Successive Overrelaxation method using an optimum S.O.R factor


using 5 point approximation method

The number of internal mesh points is 28

The number of total mesh points used in calculatios including fictious


when present is 50

The optimum value of the S.O.R. factor used is, w = 1.266812

The number of iterations needed was 41 for 1.00000e-04 tolerance

The array will look like this


From the upper to the lower side

rows= 5
columns= 9

row # 5
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
1.00000e+02

row # 4
0.00000e+00 1.74133e+00 3.76838e+00 6.43739e+00
1.02942e+01 1.63568e+01 2.69302e+01 4.82587e+01
1.00000e+02

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 52

row # 3
0.00000e+00 3.19695e+00 6.89480e+00 1.16870e+01
1.83825e+01 2.82029e+01 4.31054e+01 6.61046e+01
1.00000e+02

row # 2
0.00000e+00 4.15164e+00 8.92683e+00 1.50333e+01
2.33457e+01 3.49670e+01 5.11837e+01 7.30544e+01
1.00000e+02

row # 1
0.00000e+00 4.48273e+00 9.62754e+00 1.61736e+01
2.50002e+01 3.71356e+01 5.36081e+01 7.49292e+01
1.00000e+02

Local time is: Sun Apr 24 03:41:27 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman – Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 53

 7+((//,37,&',5,&+/(73'( ,55(*8/$5 %281'$5,(6


)LQLWHGLIIHUHQFH SUREOHPV LQYROYLQJ FLUFXODU DQG VHPLFLUFXODU ERXQGDULHV FDQ EH

VROYHG PRUH FRQYHQLHQWO\ LQ SRODU FRRUGLQDWHV WKDQ FDUWHVLDQ FRRUGLQDWHV EHFDXVH WKH\

DYRLG WKH XVH RI DZNZDUG GLIIHUHQWLDWLRQ IRUPXODH QHDU WKH FXUYHG ERXQGDULHV LI WKH

ERXQGDU\ FRQGLWLRQV LQYROYH QRUPDO GHULYDWLYHV JUHDW FRPSOLFDWLRQV DULVH LQ XVLQJ WKH

ILQLWHGLIIHUHQFH PHWKRG WKH ILQLWHHOHPHQW PHWKRG ZRXOG EH PRUH DSSURSULDWH WR XVH LQ

WKLV FDVH DQG IRU LUUHJXODU ERXQGDULHV LQ JHQHUDO 

$V DQ H[DPSOH FRQVLGHU WKH /DSODFH HTXDWLRQ


∂  X  ∂X  ∂ X
+ + = 
∂ U  U ∂U U

∂ θ

'HILQH WKH PHVK SRLQWV LQ WKH r −θ SODQH E\ WKH SRLQWV RI LQWHUVHFWLRQ RI WKH FLUFOHV

U LK L    DQG WKH VWUDLJKW OLQHV θ = Mδθ M      ZH FRXOG WKHQ ZULWH D

ILQLWHGLIIHUHQFH DSSUR[LPDWLRQ IRU /DSODFH


V HTXDWLRQ DW HDFK LQWHUQDO PHVK SRLQW LM 

5HRUGHULQJ IRU HDFK SRLQW LM ZH REWDLQ


1 1 1 1 1
(1 − )ui −1,j +(1 + )ui +1,j − 2 {1 + } +
2 ui,j 2 ui,j −1
+ ui,j +1 = 0 
2i 2i (iδθ) (iδθ) (iδθ)2

:ULWLQJ RXW WKHVH HTXDWLRQV LQ GHWDLO IRU L    Q DQG M    P DQG LI WKH

ERXQGDU\ YDOXHV DUH DVVXPHG WR EH NQRZQ WKHQ WKH HTXDWLRQV FDQ EH GLUHFWO\ VROYHG

*DXVV6HLGHO DQG -DFREL ZHUH XWLOLVHG WR VROYH WKHVH VHWV RI HTXDWLRQV

 (;$03/(6217+((//,37,&',5,&+/(73'(,55(*8/$5%281'$5,(6
$ SUREOHP ZLOO QRZ EH LQWURGXFHG DQG LW ZLOO EH VROYHG E\ WZR GLIIHUHQW QXPHULFDO

PHWKRGV IRU GLIIHUHQW PHVK VL]HV 6R WKH UHDGHU FRXOG EH DEOH WR VHH WKH GLIIHUHQFH

EHWZHHQ WKHVH PHWKRGV WKH DFFXUDF\ DQG WKH QXPEHU RI LWHUDWLRQV QHHGHG E\ HDFK

$ W\SLFDO VWHDG\ VWDWH KHDW IORZ SUREOHP LV WKH IROORZLQJ

$ VHPLFLUFXODU SODWH RI UDGLXV  FP KDV WKH WHPSHUDWXUH DW WKH EDVH WKH VWUDLJKW VLGH

KHOG DW  R& ZKLOH WKH FLUFXPIHUHQFH LV KHOG DW  R& :H GHVLUH WKH VWHDG\VWDWH

WHPSHUDWXUHV

6XSHULPSRVH D SRODUFRRUGLQDWH V\VWHP

6ROYH XVLQJ WKH IROORZLQJ PHWKRGV ZLWK WROHUDQFH 

 )RU D PRUH GHWDLOHG DSSURDFK FRQVXOW >@ S  DQG >@ S 

 'LVFXVVHG RQ S 

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 54

π
$QG ∆r = 0.2 DQG ∆θ = 
8
• -DFREL S 

• *DXVV6HLGHO S 

6ROYH LI WKH SODWH ZDV FLUFXODU


:LWK ERXQGDULHV

8SSHU OHIW  R&


/RZHU OHIW  R&
8SSHU ULJKW  R&
/RZHU ULJKW  R&

6ROYH XVLQJ WKH IROORZLQJ PHWKRGV ZLWK WROHUDQFH 


π
$QG ∆ U =   DQG ∆θ = 


• -DFREL S 

• *DXVV6HLGHO S 

:KHQ UXQQLQJ WKH SURJUDP WKH IROORZLQJ SDJHV VKRZ WKH UHVXOWV REWDLQHG

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 55

6ROXWLRQ IRU WKH 'LULFKOHW VHPLFLUFXODU SUREOHP ZLWK WROHUDQFH 


π
$QG ∆r = 0.2 DQG ∆θ = 
8
• -DFREL

********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

1: Elliptic Partial Differential Equation

Your choice was

2: Dirichlet Problem - First Boundary Value Problem


- Irregular boundaries

Your choice was

2: Laplace eqn, irregular boundary :using Jacobi


semi-circle :constant boundaries

This program will use the average of the boundary values you enter as a guide
to the most appropriate value needed for initialization of the internal mesh
points, and the corner points of the grid will take the average values of the
boundaries that surround them - if you are not asked to enter them -

Dimensions of semi-circle -irregular boundaries- as entered by user

Radius of semi-circle is 1.00000


The increment of the angle in degrees is 22.50000
The increment for r, that the program will use is 0.20000

The # of internal mesh points is: 28

The # of mesh points that we'll be operating on


including the ones on the boundaries is: 46

Number of iterations needed was 113 for 1.00000e-03 tolerance

The array will look like this


From the R = radius inwards for each angle at a time

6 cases were taken for R


9 cases were taken for the angle from 0 to 180

For angle= 0.00


5.00000e+01 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00

For angle= 22.50


1.00000e+02 6.36788e+01 3.91655e+01 2.23732e+01
1.01433e+01 0.00000e+00

For angle= 45.00


1.00000e+02 7.94592e+01 5.80587e+01 3.74563e+01
1.82384e+01 0.00000e+00

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 56

For angle= 67.50


1.00000e+02 8.44251e+01 6.61265e+01 4.55421e+01
2.32938e+01 0.00000e+00

For angle= 90.00


1.00000e+02 8.56617e+01 6.83719e+01 4.80465e+01
2.49965e+01 0.00000e+00

For angle= 112.50


1.00000e+02 8.44248e+01 6.61265e+01 4.55418e+01
2.32928e+01 0.00000e+00

For angle= 135.00


1.00000e+02 7.94591e+01 5.80581e+01 3.74555e+01
1.82381e+01 0.00000e+00

For angle= 157.50


1.00000e+02 6.36786e+01 3.91651e+01 2.23728e+01
1.01427e+01 0.00000e+00

For angle= 180.00


5.00000e+01 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00

Local time is: Sun Apr 24 16:00:11 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 57

6ROXWLRQ IRU WKH 'LULFKOHW VHPLFLUFXODU SUREOHP ZLWK WROHUDQFH 


π
$QG ∆r = 0.2 DQG ∆θ = 
8
• *DXVV6HLGHO

********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

1: Elliptic Partial Differential Equation

Your choice was

2: Dirichlet Problem - First Boundary Value Problem


- Irregular boundaries

Your choice was

1: Laplace eqn, irregular boundary :using Gauss-Seidel


semi-circle :constant boundaries

This program will use the average of the boundary values you enter as a guide
to the most appropriate value needed for initialization of the internal mesh
points, and the corner points of the grid will take the average values of the
boundaries that surround them - if you are not asked to enter them -

Dimensions of semi-circle -irregular boundaries- as entered by user

Radius of semi-circle is 1.00000


The increment of the angle in degrees is 22.50000
The increment for r, that the program will use is 0.20000

The # of internal mesh points is: 28

The # of mesh points that we'll be operating on


including the ones on the boundaries is: 46

Number of iterations needed was 41 for 1.00000e-03 tolerance

The array will look like this


From the R = radius inwards for each angle at a time

6 cases were taken for R


9 cases were taken for the angle from 0 to 180

For angle= 0.00


5.00000e+01 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00

For angle= 22.50


1.00000e+02 6.36783e+01 3.91646e+01 2.23722e+01
1.01421e+01 0.00000e+00

For angle= 45.00


1.00000e+02 7.94585e+01 5.80571e+01 3.74539e+01
1.82364e+01 0.00000e+00

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 58

For angle= 67.50


1.00000e+02 8.44239e+01 6.61245e+01 4.55390e+01
2.32905e+01 0.00000e+00

For angle= 90.00


1.00000e+02 8.56604e+01 6.83694e+01 4.80435e+01
2.49930e+01 0.00000e+00

For angle= 112.50


1.00000e+02 8.44237e+01 6.61242e+01 4.55385e+01
2.32899e+01 0.00000e+00

For angle= 135.00


1.00000e+02 7.94582e+01 5.80565e+01 3.74531e+01
1.82354e+01 0.00000e+00

For angle= 157.50


1.00000e+02 6.36781e+01 3.91641e+01 2.23716e+01
1.01413e+01 0.00000e+00

For angle= 180.00


5.00000e+01 0.00000e+00 0.00000e+00 0.00000e+00
0.00000e+00 0.00000e+00

Local time is: Sun Apr 24 16:01:24 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 59

6ROXWLRQ IRU WKH 'LULFKOHW FLUFXODU SUREOHP ZLWK WROHUDQFH 


π
$QG ∆ U =   DQG ∆θ = 


• -DFREL

********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

1: Elliptic Partial Differential Equation

Your choice was

2: Dirichlet Problem - First Boundary Value Problem


- Irregular boundaries

Your choice was

4: Laplace eqn, irregular boundary :using Jacobi


circle :constant boundaries

This program will use the average of the boundary values you enter as a guide
to the most appropriate value needed for initialization of the internal mesh
points, and the corner points of the grid will take the average values of the
boundaries that surround them - if you are not asked to enter them -

Dimensions of circle -irregular boundaries- as entered by user

Radius of semi-circle is 1.00000


The increment of the angle in degrees is 11.25000
The increment for r, that the program will use is 0.10000

The # of internal mesh points is: 289

The # of mesh points that we'll be operating on


including the ones on the boundaries is: 321

Number of iterations needed was 509 for 1.00000e-03 tolerance

The array will look like this


From the R = radius inwards for each angle at a time

11 cases were taken for R


33 cases were taken for the angle from 0 to 360

For angle= 0.00


5.00000e+01 4.99997e+01 4.99993e+01 4.99992e+01
4.99984e+01 4.99979e+01 4.99981e+01 4.99967e+01
4.99960e+01 4.99961e+01 4.99955e+01

For angle= 11.25


0.00000e+00 1.73638e+01 2.82904e+01 3.53777e+01
4.01664e+01 4.35410e+01 4.59923e+01 4.77762e+01
4.90112e+01 4.97475e+01 4.99955e+01

For angle= 22.50


0.00000e+00 9.73686e+00 1.88335e+01 2.67019e+01
3.32392e+01 3.85366e+01 4.27260e+01 4.59184e+01
4.81805e+01 4.95376e+01 4.99955e+01

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 60

For angle= 33.75


0.00000e+00 7.37748e+00 1.50216e+01 2.24856e+01
2.94028e+01 3.55122e+01 4.06450e+01 4.47001e+01
4.76267e+01 4.93985e+01 4.99955e+01

For angle= 45.00


0.00000e+00 6.79169e+00 1.39849e+01 2.12410e+01
2.81952e+01 3.45138e+01 3.99351e+01 4.42783e+01
4.74333e+01 4.93484e+01 4.99955e+01

For angle= 56.25


0.00000e+00 7.37748e+00 1.50218e+01 2.24853e+01
2.94028e+01 3.55127e+01 4.06443e+01 4.47001e+01
4.76277e+01 4.93975e+01 4.99955e+01

For angle= 67.50


0.00000e+00 9.73686e+00 1.88333e+01 2.67023e+01
3.32392e+01 3.85360e+01 4.27267e+01 4.59185e+01
4.81795e+01 4.95386e+01 4.99955e+01

For angle= 78.75


0.00000e+00 1.73638e+01 2.82904e+01 3.53777e+01
4.01664e+01 4.35410e+01 4.59923e+01 4.77762e+01
4.90112e+01 4.97475e+01 4.99955e+01

For angle= 90.00


5.00000e+01 4.99997e+01 4.99995e+01 4.99989e+01
4.99984e+01 4.99985e+01 4.99974e+01 4.99967e+01
4.99970e+01 4.99952e+01 4.99955e+01

For angle= 101.25


1.00000e+02 8.26357e+01 7.17082e+01 6.46204e+01
5.98309e+01 5.64549e+01 5.40032e+01 5.22181e+01
5.09808e+01 5.02439e+01 4.99955e+01

For angle= 112.50


1.00000e+02 9.02626e+01 8.11654e+01 7.32959e+01
6.67582e+01 6.14599e+01 5.72688e+01 5.40759e+01
5.18125e+01 5.04528e+01 4.99955e+01

For angle= 123.75


1.00000e+02 9.26219e+01 8.49772e+01 7.75125e+01
7.05941e+01 6.44843e+01 5.93504e+01 5.52934e+01
5.23663e+01 5.05929e+01 4.99955e+01

For angle= 135.00


1.00000e+02 9.32077e+01 8.60137e+01 7.87571e+01
7.18022e+01 6.54821e+01 6.00604e+01 5.57160e+01
5.25587e+01 5.06430e+01 4.99955e+01

For angle= 146.25


1.00000e+02 9.26220e+01 8.49770e+01 7.75125e+01
7.05946e+01 6.44837e+01 5.93504e+01 5.52942e+01
5.23653e+01 5.05929e+01 4.99955e+01

For angle= 157.50


1.00000e+02 9.02625e+01 8.11656e+01 7.32959e+01
6.67577e+01 6.14605e+01 5.72688e+01 5.40750e+01
5.18134e+01 5.04528e+01 4.99955e+01

For angle= 168.75


1.00000e+02 8.26357e+01 7.17082e+01 6.46204e+01
5.98309e+01 5.64549e+01 5.40032e+01 5.22181e+01
5.09808e+01 5.02439e+01 4.99955e+01

For angle= 180.00


5.00000e+01 4.99998e+01 4.99993e+01 4.99989e+01
4.99989e+01 4.99980e+01 4.99974e+01 4.99976e+01
4.99960e+01 4.99952e+01 4.99955e+01

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 61

For angle= 191.25


0.00000e+00 1.73637e+01 2.82906e+01 3.53777e+01
4.01660e+01 4.35416e+01 4.59923e+01 4.77754e+01
4.90122e+01 4.97475e+01 4.99955e+01

For angle= 202.50


0.00000e+00 9.73686e+00 1.88333e+01 2.67023e+01
3.32392e+01 3.85360e+01 4.27267e+01 4.59185e+01
4.81796e+01 4.95386e+01 4.99955e+01

For angle= 213.75


0.00000e+00 7.37758e+00 1.50216e+01 2.24853e+01
2.94032e+01 3.55122e+01 4.06443e+01 4.47010e+01
4.76267e+01 4.93976e+01 4.99955e+01

For angle= 225.00


0.00000e+00 6.79159e+00 1.39851e+01 2.12410e+01
2.81947e+01 3.45143e+01 3.99351e+01 4.42775e+01
4.74343e+01 4.93484e+01 4.99955e+01

For angle= 236.25


0.00000e+00 7.37748e+00 1.50216e+01 2.24856e+01
2.94028e+01 3.55122e+01 4.06450e+01 4.47001e+01
4.76267e+01 4.93985e+01 4.99955e+01

For angle= 247.50


0.00000e+00 9.73696e+00 1.88333e+01 2.67019e+01
3.32396e+01 3.85360e+01 4.27260e+01 4.59193e+01
4.81795e+01 4.95376e+01 4.99955e+01

For angle= 258.75


0.00000e+00 1.73637e+01 2.82906e+01 3.53777e+01
4.01660e+01 4.35416e+01 4.59923e+01 4.77754e+01
4.90122e+01 4.97475e+01 4.99955e+01

For angle= 270.00


5.00000e+01 4.99997e+01 4.99993e+01 4.99992e+01
4.99984e+01 4.99979e+01 4.99981e+01 4.99967e+01
4.99960e+01 4.99962e+01 4.99955e+01

For angle= 281.25


1.00000e+02 8.26358e+01 7.17082e+01 6.46201e+01
5.98314e+01 5.64549e+01 5.40024e+01 5.22190e+01
5.09808e+01 5.02429e+01 4.99955e+01

For angle= 292.50


1.00000e+02 9.02625e+01 8.11655e+01 7.32959e+01
6.67577e+01 6.14604e+01 5.72687e+01 5.40750e+01
5.18134e+01 5.04528e+01 4.99955e+01

For angle= 303.75


1.00000e+02 9.26219e+01 8.49770e+01 7.75128e+01
7.05941e+01 6.44837e+01 5.93511e+01 5.52933e+01
5.23653e+01 5.05938e+01 4.99955e+01

For angle= 315.00


1.00000e+02 9.32078e+01 8.60137e+01 7.87568e+01
7.18026e+01 6.54821e+01 6.00597e+01 5.57169e+01
5.25587e+01 5.06420e+01 4.99955e+01

For angle= 326.25


1.00000e+02 9.26219e+01 8.49772e+01 7.75125e+01
7.05941e+01 6.44843e+01 5.93504e+01 5.52933e+01
5.23662e+01 5.05928e+01 4.99955e+01

For angle= 337.50


1.00000e+02 9.02625e+01 8.11653e+01 7.32962e+01
6.67577e+01 6.14599e+01 5.72694e+01 5.40750e+01
5.18124e+01 5.04537e+01 4.99955e+01

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 62

For angle= 348.75


1.00000e+02 8.26358e+01 7.17082e+01 6.46201e+01
5.98313e+01 5.64549e+01 5.40024e+01 5.22190e+01
5.09808e+01 5.02429e+01 4.99955e+01

For angle= 360.00


5.00000e+01 4.99997e+01 4.99993e+01 4.99992e+01
4.99984e+01 4.99979e+01 4.99981e+01 4.99967e+01
4.99960e+01 4.99961e+01 4.99955e+01

Local time is: Sun Apr 24 16:20:03 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 63

6ROXWLRQ IRU WKH 'LULFKOHW FLUFXODU SUREOHP ZLWK WROHUDQFH 


π
$QG ∆ U =   DQG ∆θ = 


• *DXVV6HLGHO

********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

1: Elliptic Partial Differential Equation

Your choice was

2: Dirichlet Problem - First Boundary Value Problem


- Irregular boundaries

Your choice was

3: Laplace eqn, irregular boundary :using Gauss-Seidel


circle :constant boundaries

This program will use the average of the boundary values you enter as a guide
to the most appropriate value needed for initialization of the internal mesh
points, and the corner points of the grid will take the average values of the
boundaries that surround them - if you are not asked to enter them -

Dimensions of circle -irregular boundaries- as entered by user

Radius of semi-circle is 1.00000


The increment of the angle in degrees is 11.25000
The increment for r, that the program will use is 0.10000

The # of internal mesh points is: 289

The # of mesh points that we'll be operating on


including the ones on the boundaries is: 321

Number of iterations needed was 72 for 1.00000e-03 tolerance

The array will look like this


From the R = radius inwards for each angle at a time

11 cases were taken for R


33 cases were taken for the angle from 0 to 360

For angle= 0.00


5.00000e+01 4.99967e+01 4.99931e+01 4.99890e+01
4.99846e+01 4.99797e+01 4.99744e+01 4.99688e+01
4.99631e+01 4.99586e+01 4.99654e+01

For angle= 11.25


0.00000e+00 1.73607e+01 2.82842e+01 3.53679e+01
4.01522e+01 4.35229e+01 4.59695e+01 4.77475e+01
4.89785e+01 4.97111e+01 4.99654e+01

For angle= 22.50


0.00000e+00 9.73388e+00 1.88270e+01 2.66920e+01
3.32252e+01 3.85177e+01 4.27030e+01 4.58906e+01
4.81469e+01 4.95015e+01 4.99654e+01

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 64

For angle= 33.75


0.00000e+00 7.37443e+00 1.50151e+01 2.24751e+01
2.93886e+01 3.54936e+01 4.06212e+01 4.46723e+01
4.75943e+01 4.93618e+01 4.99654e+01

For angle= 45.00


0.00000e+00 6.78848e+00 1.39783e+01 2.12306e+01
2.81803e+01 3.44950e+01 3.99119e+01 4.42497e+01
4.74012e+01 4.93132e+01 4.99654e+01

For angle= 56.25


0.00000e+00 7.37435e+00 1.50150e+01 2.24748e+01
2.93883e+01 3.54935e+01 4.06213e+01 4.46728e+01
4.75954e+01 4.93633e+01 4.99654e+01

For angle= 67.50


0.00000e+00 9.73376e+00 1.88267e+01 2.66916e+01
3.32249e+01 3.85177e+01 4.27036e+01 4.58920e+01
4.81494e+01 4.95047e+01 4.99654e+01

For angle= 78.75


0.00000e+00 1.73607e+01 2.82842e+01 3.53678e+01
4.01524e+01 4.35235e+01 4.59710e+01 4.77503e+01
4.89827e+01 4.97162e+01 4.99654e+01

For angle= 90.00


5.00000e+01 4.99969e+01 4.99935e+01 4.99898e+01
4.99859e+01 4.99818e+01 4.99777e+01 4.99736e+01
4.99696e+01 4.99658e+01 4.99654e+01

For angle= 101.25


1.00000e+02 8.26333e+01 7.17030e+01 6.46121e+01
5.98198e+01 5.64406e+01 5.39849e+01 5.21974e+01
5.09568e+01 5.02156e+01 4.99654e+01

For angle= 112.50


1.00000e+02 9.02605e+01 8.11611e+01 7.32891e+01
6.67483e+01 6.14477e+01 5.72537e+01 5.40570e+01
5.17911e+01 5.04276e+01 4.99654e+01

For angle= 123.75


1.00000e+02 9.26202e+01 8.49736e+01 7.75071e+01
7.05866e+01 6.44738e+01 5.93380e+01 5.52780e+01
5.23465e+01 5.05698e+01 4.99654e+01

For angle= 135.00


1.00000e+02 9.32066e+01 8.60112e+01 7.87528e+01
7.17964e+01 6.54744e+01 6.00496e+01 5.57032e+01
5.25423e+01 5.06207e+01 4.99654e+01

For angle= 146.25


1.00000e+02 9.26210e+01 8.49753e+01 7.75097e+01
7.05899e+01 6.44779e+01 5.93425e+01 5.52826e+01
5.23507e+01 5.05729e+01 4.99654e+01

For angle= 157.50


1.00000e+02 9.02619e+01 8.11641e+01 7.32938e+01
6.67546e+01 6.14554e+01 5.72622e+01 5.40656e+01
5.17991e+01 5.04336e+01 4.99654e+01

For angle= 168.75


1.00000e+02 8.26352e+01 7.17072e+01 6.46185e+01
5.98284e+01 5.64509e+01 5.39965e+01 5.22093e+01
5.09678e+01 5.02239e+01 4.99654e+01

For angle= 180.00


5.00000e+01 4.99992e+01 4.99983e+01 4.99972e+01
4.99958e+01 4.99938e+01 4.99911e+01 4.99875e+01
4.99825e+01 4.99757e+01 4.99654e+01

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 65

For angle= 191.25


0.00000e+00 1.73630e+01 2.82891e+01 3.53755e+01
4.01626e+01 4.35359e+01 4.59849e+01 4.77648e+01
4.89964e+01 4.97269e+01 4.99654e+01

For angle= 202.50


0.00000e+00 9.73591e+00 1.88313e+01 2.66987e+01
3.32344e+01 3.85293e+01 4.27167e+01 4.59059e+01
4.81628e+01 4.95155e+01 4.99654e+01

For angle= 213.75


0.00000e+00 7.37613e+00 1.50187e+01 2.24807e+01
2.93963e+01 3.55033e+01 4.06326e+01 4.46849e+01
4.76074e+01 4.93734e+01 4.99654e+01

For angle= 225.00


0.00000e+00 6.78978e+00 1.39811e+01 2.12349e+01
2.81862e+01 3.45024e+01 3.99205e+01 4.42593e+01
4.74112e+01 4.93221e+01 4.99654e+01

For angle= 236.25


0.00000e+00 7.37520e+00 1.50168e+01 2.24777e+01
2.93921e+01 3.54983e+01 4.06269e+01 4.46790e+01
4.76018e+01 4.93690e+01 4.99654e+01

For angle= 247.50


0.00000e+00 9.73414e+00 1.88275e+01 2.66929e+01
3.32266e+01 3.85197e+01 4.27060e+01 4.58946e+01
4.81520e+01 4.95070e+01 4.99654e+01

For angle= 258.75


0.00000e+00 1.73606e+01 2.82839e+01 3.53675e+01
4.01518e+01 4.35228e+01 4.59700e+01 4.77492e+01
4.89814e+01 4.97151e+01 4.99654e+01

For angle= 270.00


5.00000e+01 4.99963e+01 4.99922e+01 4.99878e+01
4.99831e+01 4.99783e+01 4.99735e+01 4.99688e+01
4.99645e+01 4.99613e+01 4.99654e+01

For angle= 281.25


1.00000e+02 8.26322e+01 7.17008e+01 6.46085e+01
5.98149e+01 5.64344e+01 5.39775e+01 5.21890e+01
5.09480e+01 5.02079e+01 4.99654e+01

For angle= 292.50


1.00000e+02 9.02589e+01 8.11579e+01 7.32841e+01
6.67415e+01 6.14391e+01 5.72434e+01 5.40454e+01
5.17790e+01 5.04170e+01 4.99654e+01

For angle= 303.75


1.00000e+02 9.26184e+01 8.49696e+01 7.75009e+01
7.05781e+01 6.44631e+01 5.93252e+01 5.52637e+01
5.23316e+01 5.05566e+01 4.99654e+01

For angle= 315.00


1.00000e+02 9.32044e+01 8.60066e+01 7.87456e+01
7.17866e+01 6.54620e+01 6.00349e+01 5.56867e+01
5.25251e+01 5.06056e+01 4.99654e+01

For angle= 326.25


1.00000e+02 9.26186e+01 8.49702e+01 7.75017e+01
7.05791e+01 6.44642e+01 5.93263e+01 5.52645e+01
5.23320e+01 5.05564e+01 4.99654e+01

For angle= 337.50


1.00000e+02 9.02594e+01 8.11588e+01 7.32855e+01
6.67433e+01 6.14410e+01 5.72452e+01 5.40467e+01
5.17795e+01 5.04163e+01 4.99654e+01

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 66

For angle= 348.75


1.00000e+02 8.26327e+01 7.17018e+01 6.46101e+01
5.98169e+01 5.64365e+01 5.39794e+01 5.21902e+01
5.09481e+01 5.02066e+01 4.99654e+01

For angle= 360.00


5.00000e+01 4.99967e+01 4.99931e+01 4.99890e+01
4.99846e+01 4.99797e+01 4.99744e+01 4.99688e+01
4.99631e+01 4.99586e+01 4.99654e+01

Local time is: Sun Apr 24 16:23:23 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


PAGE 67

&+$37(5 
180(5,&$/0(7+2'6)2562/9,1*
3$5$%2/,&3$57,$/',))(5(17,$/(48$7,216

7KH SUHYLRXV FKDSWHU GLVFXVVHG WKH VROXWLRQ RI 3DUWLDO'LIIHUHQWLDO (TXDWLRQV 3'(V

WKDW ZHUH WLPHLQGHSHQGHQW 6XFK VWHDG\VWDWH SUREOHPV ZHUH GHVFULEHG E\ (OOLSWLF

HTXDWLRQV 8QVWHDG\VWDWH SUREOHPV LQ ZKLFK WKH IXQFWLRQ LV GHSHQGHQW RQ WLPH DUH RI

JUHDW LPSRUWDQFH :H VWXG\ WKHVH LQ WKLV DQG WKH IROORZLQJ FKDSWHU

,Q WKLV FKDSWHU WKH QXPHULFDO VROXWLRQ RI 3DUDEROLF 3'(V LV FRQVLGHUHG WDNLQJ DV D

SURWRW\SH WKH KHDW HTXDWLRQ 7KH RQHGLPHQVLRQDO UHSUHVHQWDWLRQ RI VXFK DQ HTXDWLRQ LV
∂X ∂ X 
N =  ZKHUH N LV D FRQVWDQW 
∂W ∂ [ 

7KH VROXWLRQ RI ZKLFK JLYHV WKH WHPSHUDWXUH X DW D GLVWDQFH [ IURP RQH HQG VD\ WKH OHIW

HQG RI D WKLQ XQLIRUP LQ FURVV VHFWLRQ URG DIWHU D WLPH W 7KLV DVVXPHV WKH URG WR EH

KHDWLQVXODWHG DORQJ LWV OHQJWK VR WKDW WHPSHUDWXUH FKDQJHV RFFXU WKURXJK KHDW

FRQGXFWLRQ DORQJ LWV OHQJWK DQG KHDW WUDQVIHU DW LWV HQGV

(TXDWLRQ  LV WKH EDVLF PDWKHPDWLFDO PRGHO IRU XQVWHDG\VWDWH IORZ ,W ZDV XVHG WR

H[SUHVV KHDWIORZ EXW LW DSSOLHV HTXDOO\ WR GLIIXVLRQ RI PDWHULDO IORZ RI IOXLGV XQGHU

FRQGLWLRQV RI ODPLQDU IORZ  IORZ RI HOHFWULFLW\ LQ FDEOHV WKH WHOHJUDSK HTXDWLRQV  DQG

VR RQ 7KLV HTXDWLRQ ZDV FODVVLILHG DV 3DUDEROLF EHFDXVH FRPSDUHG ZLWK WKH VWDQGDUG

IRUP RI D 3'( LQ WZR LQGHSHQGHQW YDULDEOHV [ DQG W

DX[[  EX[W  FXWW  ) [ W X X[ XW 

ZH ILQG WKDW E  DF 

7KH WZRGLPHQVLRQDO UHSUHVHQWDWLRQ RI WKH KHDW HTXDWLRQ LV


∂X ∂ X  ∂ X 
N = +  
∂W ∂ [  ∂ \ 

7KH IXQFWLRQ WKDW ZH FDOO WKH VROXWLRQ WR WKH SUREOHP QRW RQO\ PXVW REH\ WKH GLIIHUHQWLDO

HTXDWLRQV JLYHQ DERYH EXW DOVR PXVW VDWLVI\ DQ LQLWLDO FRQGLWLRQ DQG D VHW RI ERXQGDU\

FRQGLWLRQV )RU WKH RQHGLPHQVLRQDO KHDW IORZ SUREOHP WKDW ZH ILUVW FRQVLGHU WKH LQLWLDO

FRQGLWLRQ ZLOO EH WKH LQLWLDO WHPSHUDWXUHV DW DOO SRLQWV DORQJ WKH URG

X [W W  X [ I [ 

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 68

7KH ERXQGDU\ FRQGLWLRQV ZLOO GHVFULEH WKH WHPSHUDWXUH DW HDFK HQG RI WKH URG DV D

IXQFWLRQ RI WLPH $W ILUVW ZH ZLOO FRQVLGHU WKH FDVH ZKHUH WKHVH WHPSHUDWXUHV DUH KHOG

FRQVWDQW

X W F

X /W F

0RUH JHQHUDO DQG PRUH SUDFWLFDO ERXQGDU\ FRQGLWLRQV ZLOO LQYROYH QRW RQO\ WKH

WHPSHUDWXUH EXW WKH WHPSHUDWXUH JUDGLHQWV DQG WKHVH PD\ YDU\ ZLWK WLPH

7KUHH PDLQ QXPHULFDO PHWKRGV WKDW DUH FXVWRPDULO\ XVHG WR QXPHULFDOO\ VROYH WKLV W\SH

RI 3'(V ZLOO EH GLVFXVVHG 7KH ([SOLFLW PHWKRG WKH &UDQN1LFROVRQ PHWKRG DQG WKH

$OWHUQDWLQJ 'LUHFWLRQ ,PSOLFLW PHWKRG $', 

 7+((;3/,&,70(7+2'
7KLV PHWKRG GLYLGHV VSDFH DQG WLPH LQWR GLVFUHWH XQLIRUP VXELQWHUYDOV DQG UHSODFHV ERWK

WLPH DQG VSDFH GHULYDWLYHV E\ ILQLWHGLIIHUHQFH DSSUR[LPDWLRQV SHUPLWWLQJ RQH WR HDVLO\

FRPSXWH YDOXHV RI D IXQFWLRQ DW D WLPH ∆W DIWHU WKH LQLWLDO WLPH 7KHVH YDOXHV DUH WKHQ

XVHG WR FRPSXWH D VHFRQG VHW RI YDOXHV DQG WKH SURFHVV LV UHSHDWHG

5HSODFLQJ WKH SDUWLDO GHULYDWLYHV E\ WKHLU ILQLWHGLIIHUHQFH DSSUR[LPDWLRQV ZH REWDLQ


∆W ∆W
M
XL
+
=
 X +
M
+ X − +  − 
M

 X
M
 
F ∆[ F ∆[
L L L

ZKHUH L UHSUHVHQWV WKH SRVLWLRQ RQ WKH [ D[LV DQG M UHSUHVHQWV WKH WLPH GLPHQVLRQ

M +
:H WKHUHIRUH KDYH VROYHG IRU XL LQ WHUPV RI WKH WHPSHUDWXUHV DW WLPH WM LQ YLHZ RI WKH

QRUPDOO\ NQRZQ FRQGLWLRQV IRU D SDUDEROLF 3'( :H VXEGLYLGH WKH OHQJWK LQWR XQLIRUP

VXELQWHUYDOV DQG DSSO\ RXU ILQLWHGLIIHUHQFH DSSUR[LPDWLRQ DW HDFK SRLQW ZKHUH X LV QRW

NQRZQ (TXDWLRQ  WKHQ JLYHV WKH YDOXHV RI X DW HDFK LQWHUQDO SRLQW DW W W VLQFH WKH

YDOXHV DW W WR DUH JLYHQ E\ WKH LQLWLDO FRQGLWLRQV ,W WKHQ FDQ EH XVHG WR JHW YDOXHV DW W

XVLQJ WKH YDOXHV DW W DV LQLWLDO FRQGLWLRQV VR ZH FDQ VWHS WKH VROXWLRQ IRUZDUG LQ WLPH

$W WKH HQGSRLQWV WKH ERXQGDU\ FRQGLWLRQV ZLOO GHWHUPLQH X

7KH UHODWLYH VL]H RI WKH WLPH DQG GLVWDQFH VWHSV ∆W DQG ∆[ DIIHFWV HTXDWLRQ   ,I WKH
∆W
UDWLR LV FKRVHQ WR EH OHVV WKDQ RQHKDOI WKHUH ZLOO EH LPSURYHG DFFXUDF\ ,I WKH
F ∆[


YDOXH LV FKRVHQ JUHDWHU WKDQ RQH KDOI ZKLFK ZRXOG UHGXFH WKH QXPEHU RI FDOFXODWLRQV

UHTXLUHG WR DGYDQFH WKH VROXWLRQ WKURXJK D JLYHQ LQWHUYDO RI WLPH WKH SKHQRPHQRQ RI

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 69

∆W
LQVWDELOLW\ VHWV LQ WKHUHIRUH WKH XVHU LV DVNHG WR GHWHUPLQH WKH YDOXH RI U
F ∆[


DQG KHVKH LV VKRZQ LWV HIIHFW RQ ∆W DV ∆W F U ∆[  7KH VPDOOHU WKH VL]H ∆[ WKH

PRUH DFFXUDWH WKH VROXWLRQV IRU D IL[HG ∆[  5HGXFLQJ U UHGXFHV ∆W DQG WKXV PRUH

FDOFXODWLRQV DUH QHHGHG WR UHDFK D JLYHQ WLPH DIWHU WKH VWDUW RI KHDW IORZ

)RU WKH DQVZHUV WR EH PRUH DFFXUDWH LW LV VXJJHVWHG WKDW RQH XVHV D VPDOO ∆W LI KHVKH

ZDQWV D IL[HG ∆[ ,I GLVFRQWLQXLWLHV DW WKH ERXQGDULHV DUH SUHVHQW WKH DQVZHUV DW WKH

EHJLQQLQJ ZRXOG EH WKH SRRUHVW LQ UHJDUG WR DFFXUDF\ DQG WKLV LV D UHVXOW RI WKH

GLVFRQWLQXLWLHV LQ WKH ERXQGDU\ FRQGLWLRQV SUHVHQW WKHUHIRUH RQH VKRXOG XVH D VPDOOHU ∆W WR
RYHUFRPH WKLV REVWDFOH

7KH PHWKRG LV LOOXVWUDWHG E\ D VLPSOH H[DPSOH

$ ODUJH IODW VWHHO SODWH LV  FP WKLFN ,I WKH LQLWLDO WHPSHUDWXUHV R& ZLWKLQ WKH SODWH DUH

JLYHQ DW HDFK ∆[  IURP [  WLOO [  FP DV

        

)RU VWHHO WKH FRQVWDQW F 

)LQG WKH WHPSHUDWXUHV DV D IXQFWLRQ RI [ DQG W LI ERWK IDFHV DUH PDLQWDLQHG DW  R&

• 8VLQJ U  S 

• 8VLQJ U  S 

:KHQ UXQQLQJ WKH SURJUDP WKH IROORZLQJ SDJHV VKRZ WKH UHVXOWV REWDLQHG

1RWH 7KH PHWKRG SUHVHQWHG LQ WKLV VHFWLRQ LV FDOOHG WKH H[SOLFLW PHWKRG EHFDXVH HDFK

QHZ YDOXH FDQ EH LPPHGLDWHO\ FDOFXODWHG IURP TXDQWLWLHV WKDW DUH DOUHDG\ NQRZQ

,W LV VLPSOH DQG HFRQRPLFDO LQ UHJDUG WR FDOFXODWLRQ HIIRUW EXW KDV D VHYHUHO\


∆W
OLPLWHG XSSHU YDOXH IRU WKH UDWLR  :H FDQ UHPRYH WKLV OLPLWDWLRQ E\
F ∆[


JRLQJ WR DQ LPSOLFLW PHWKRG

 )RU IXUWKHU UHIHUHQFH FRQVXOW >@ S 

 ZKHQ UXQQLQJ WKH SDFNDJH

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 70

6ROXWLRQ IRU WKH 3DUDEROLF SUREOHP ZLWK

∆[  F  DQG U 

• ([SOLFLW PHWKRG

********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

2: Parabolic Partial Differential Equation

The following menu uses the heat eqn as a prototype for parabolic PDEs
but the methods listed apply equally to diffusion of materials, flow of
fluids (under conditions of laminar flow), flow of electricity in cables
(the telegraph equations) and so on

Your choice was

1 : One dimensional heat eqn :Explicit method


boundaries expressed as constants
initial conditions expressed as points entered by the user

The data related to this problem is as follows

Length of the space dimension is 2.00000


Value of increment in the space dimension is 0.25000
The constant of your eqn reffered to the time side of the eqn is 6.60000
r factor to be used is 0.50000

The increment in time will be governed by the following equation


change time = CONSTANT * r * (change space)^2

Your time increment will be 2.06250e-01

The # of internal mesh points used is 7

The output at t= 0.00000

0.00000e+00 2.50000e+01 5.00000e+01 7.50000e+01


1.00000e+02 7.50000e+01 5.00000e+01 2.50000e+01
0.00000e+00

The output at t= 0.41250

0.00000e+00 2.50000e+01 5.00000e+01 6.25000e+01


7.50000e+01 6.25000e+01 5.00000e+01 2.50000e+01
0.00000e+00

The output at t= 0.82500

0.00000e+00 2.18750e+01 4.37500e+01 5.31250e+01


6.25000e+01 5.31250e+01 4.37500e+01 2.18750e+01
0.00000e+00

The output at t= 1.23750

0.00000e+00 1.87500e+01 3.75000e+01 4.53125e+01


5.31250e+01 4.53125e+01 3.75000e+01 1.87500e+01
0.00000e+00

The output at t= 1.65000

0.00000e+00 1.60156e+01 3.20312e+01 3.86719e+01


4.53125e+01 3.86719e+01 3.20312e+01 1.60156e+01
0.00000e+00

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 71

The output at t= 2.06250

0.00000e+00 1.36719e+01 2.73438e+01 3.30078e+01


3.86719e+01 3.30078e+01 2.73438e+01 1.36719e+01
0.00000e+00

The output at t= 2.47500

0.00000e+00 1.16699e+01 2.33398e+01 2.81738e+01


3.30078e+01 2.81738e+01 2.33398e+01 1.16699e+01
0.00000e+00

The output at t= 2.88750

0.00000e+00 9.96094e+00 1.99219e+01 2.40479e+01


2.81738e+01 2.40479e+01 1.99219e+01 9.96094e+00
0.00000e+00

The output at t= 3.30000

0.00000e+00 8.50220e+00 1.70044e+01 2.05261e+01


2.40479e+01 2.05261e+01 1.70044e+01 8.50220e+00
0.00000e+00

The output at t= 3.71250

0.00000e+00 7.25708e+00 1.45142e+01 1.75201e+01


2.05261e+01 1.75201e+01 1.45142e+01 7.25708e+00
0.00000e+00

The output at t= 4.12500

0.00000e+00 6.19431e+00 1.23886e+01 1.49544e+01


1.75201e+01 1.49544e+01 1.23886e+01 6.19431e+00
0.00000e+00

Local time is: Tue May 03 15:16:41 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 72

6ROXWLRQ IRU WKH 3DUDEROLF SUREOHP ZLWK

∆[  F  DQG U 

• ([SOLFLW PHWKRG

********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

2: Parabolic Partial Differential Equation

The following menu uses the heat eqn as a prototype for parabolic PDEs
but the methods listed apply equally to diffusion of materials, flow of
fluids (under conditions of laminar flow), flow of electricity in cables
(the telegraph equations) and so on

Your choice was

1 : One dimensional heat eqn :Explicit method


boundaries expressed as constants
initial conditions expressed as points entered by the user

The data related to this problem is as follows

Length of the space dimension is 2.00000


Value of increment in the space dimension is 0.25000
The constant of your eqn reffered to the time side of the eqn is 6.60000
r factor to be used is 0.10000

The increment in time will be governed by the following equation


change time = CONSTANT * r * (change space)^2

Your time increment will be 4.12500e-02

The # of internal mesh points used is 7

The output at t= 0.00000

0.00000e+00 2.50000e+01 5.00000e+01 7.50000e+01


1.00000e+02 7.50000e+01 5.00000e+01 2.50000e+01
0.00000e+00

The output at t= 0.41250

0.00000e+00 2.46022e+01 4.77765e+01 6.60141e+01


7.33426e+01 6.60141e+01 4.77765e+01 2.46022e+01
0.00000e+00

The output at t= 0.82500

0.00000e+00 2.24547e+01 4.22001e+01 5.60888e+01


6.11454e+01 5.60888e+01 4.22001e+01 2.24547e+01
0.00000e+00

The output at t= 1.23750

0.00000e+00 1.96516e+01 3.65050e+01 4.79501e+01


5.20150e+01 4.79501e+01 3.65050e+01 1.96516e+01
0.00000e+00

The output at t= 1.65000

0.00000e+00 1.69624e+01 3.13943e+01 4.10867e+01


4.45024e+01 4.10867e+01 3.13943e+01 1.69624e+01
0.00000e+00

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 73

The output at t= 2.06250

0.00000e+00 1.45783e+01 2.69510e+01 3.52314e+01


3.81424e+01 3.52314e+01 2.69510e+01 1.45783e+01
0.00000e+00

The output at t= 2.47500

0.00000e+00 1.25125e+01 2.31238e+01 3.02176e+01


3.27094e+01 3.02176e+01 2.31238e+01 1.25125e+01
0.00000e+00

The output at t= 2.88750

0.00000e+00 1.07349e+01 1.98366e+01 2.59191e+01


2.80552e+01 2.59191e+01 1.98366e+01 1.07349e+01
0.00000e+00

The output at t= 3.30000

0.00000e+00 9.20873e+00 1.70158e+01 2.22325e+01


2.40645e+01 2.22325e+01 1.70158e+01 9.20873e+00
0.00000e+00

The output at t= 3.71250

0.00000e+00 7.89918e+00 1.45958e+01 1.90705e+01


2.06418e+01 1.90705e+01 1.45958e+01 7.89918e+00
0.00000e+00

The output at t= 4.12500

0.00000e+00 6.77577e+00 1.25200e+01 1.63582e+01


1.77060e+01 1.63582e+01 1.25200e+01 6.77577e+00
0.00000e+00

Local time is: Tue May 03 15:26:42 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 74

 7+(&5$1.1,&2/6210(7+2'
7KLV PHWKRG RYHUFRPHV WKH OLPLWDWLRQV WKDW WKH H[SOLFLW PHWKRG SODFHV RQ WKH VL]H RI ∆W
DQG JLYHV LPSURYHG DFFXUDF\ DW WKH H[SHQVH RI KDYLQJ WR VROYH D VHW RI HTXDWLRQV DW HDFK

WLPH VWHS
∆W
,I ZH OHW U  WKHQ WKH ILQLWHGLIIHUHQFH UHSUHVHQWDWLRQ LV
F ∆[


− U X −+ +  +  U X + − U X ++ = U X − +  −  U X + U X + 
M
L
M
L
M
L
M
L L
M M
L

7KH &UDQN1LFROVRQ PHWKRG LV VWDEOH IRU DQ\ YDOXH RI U DOWKRXJK VPDOO YDOXHV DUH

PRUH DFFXUDWH

+
7KH QHZ WHPSHUDWXUH X M
L
LV QRW JLYHQ GLUHFWO\ LQ WHUPV RI NQRZQ WHPSHUDWXUHV RQH WLPH

VWHS HDUOLHU EXW LV D IXQFWLRQ RI DGMDFHQW SRLQWV DV ZHOO ,W LV WKHUHIRUH WHUPHG DQ

LPSOLFLW PHWKRG LQ FRQWUDVW WR WKH H[SOLFLW PHWKRG RI WKH SUHYLRXV VHFWLRQ 7KLV UHTXLUHV

XV WR VROYH D VHW RI VLPXOWDQHRXV HTXDWLRQV DW HDFK WLPH VWHS 7KH *DXVV6HLGHO

LWHUDWLYH PHWKRG ZDV XVHG LQ WKH SDFNDJH WR VROYH WKH UHVXOWLQJ HTXDWLRQV ,WHUDWLYH

PHWKRGV IRU VROYLQJ OLQHDU DOJHEUDLF HTXDWLRQV DUH JHQHUDOO\ XVHG ZKHQ WKH QXPEHU RI

XQNQRZQV LV ODUJH EXW HDFK HTXDWLRQ LQYROYHV RQO\ D IHZ RI WKHP LH ZKHQ WKH PDWUL[

RI FRHIILFLHQWV FRQVLVWV PDLQO\ RI ]HURV 7KLV LV EHFDXVH LWHUDWLYH PHWKRGV WDNH

DGYDQWDJH RI WKH ]HURV ZKHUHDV D JUHDW GHDO RI ZRUN RI GLUHFW HOLPLQDWLRQ PHWKRGV LV

FRQFHUQHG ZLWK LQWURGXFLQJ ]HURV ZKLFK IRU WKH HTXDWLRQV ZH KDYH LQ PLQG H[LVW WR VWDUW

ZLWK ,W VKRXOG EH PHQWLRQHG WKDW WKH ILQLWHGLIIHUHQFH HTXDWLRQV DVVRFLDWHG ZLWK 3'(V

DUH RI WKH W\SH PHQWLRQHG DERYH 7KH DFFXUDF\ RI WKLV LPSOLFLW PHWKRG RYHU WKH WLPH

UDQJH WDNHQ LV DERXW WKH VDPH DV IRU WKH H[SOLFLW PHWKRG ZKLFK XVHV WHQ WLPHV DV PDQ\

WLPH VWHSV

$V DQ H[DPSOH ZH ZLOO VROYH WKH VDPH SUREOHP SUHVHQWHG LQ WKH SUHYLRXV VHFWLRQ S 

EXW WKLV WLPH E\ WKH &UDQN1LFROVRQ PHWKRG

6ROYH IRU

• U  S 

• U  S 

• U  S 

:KHQ UXQQLQJ WKH SURJUDP WKH IROORZLQJ SDJHV VKRZ WKH UHVXOWV REWDLQHG

 )RU IXUWKHU UHIHUHQFH FRQVXOW >@ S 

 7KLV PHWKRG ZDV GLVFXVVHG LQ &KDSWHU  S 

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 75

6ROXWLRQ IRU WKH 3DUDEROLF SUREOHP ZLWK

∆[  F  DQG U 

• &UDQN1LFROVRQ PHWKRG

********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

2: Parabolic Partial Differential Equation

The following menu uses the heat eqn as a prototype for parabolic PDEs
but the methods listed apply equally to diffusion of materials, flow of
fluids (under conditions of laminar flow), flow of electricity in cables
(the telegraph equations) and so on

Your choice was

3 : One dimensional heat eqn :Crank-Nicolson method


boundaries expressed as constants
initial conditions expressed as points entered by the user

The data related to this problem is as follows

Length of the space dimension is 2.00000


Value of increment in the space dimension is 0.25000
The constant of your eqn reffered to the time side of the eqn is 6.60000
r factor to be used is 1.00000

The increment in time will be governed by the following equation


change time = CONSTANT * r * (change space)^2

Your time increment will be 4.12500e-01

The # of internal mesh points used is 7

The output at t= 0.00000

0.00000e+00 2.50000e+01 5.00000e+01 7.50000e+01


1.00000e+02 7.50000e+01 5.00000e+01 2.50000e+01
0.00000e+00

The output at t= 0.41250

0.00000e+00 2.44845e+01 4.79381e+01 6.72680e+01


7.11340e+01 6.72680e+01 4.79381e+01 2.44845e+01
0.00000e+00

The output at t= 0.82500

0.00000e+00 2.26193e+01 4.25391e+01 5.57844e+01


6.15262e+01 5.57844e+01 4.25391e+01 2.26193e+01
0.00000e+00

The output at t= 1.23750

0.00000e+00 1.97810e+01 3.65849e+01 4.81550e+01


5.19697e+01 4.81550e+01 3.65849e+01 1.97810e+01
0.00000e+00

The output at t= 1.65000

0.00000e+00 1.70312e+01 3.15398e+01 4.11919e+01


4.46734e+01 4.11919e+01 3.15398e+01 1.70312e+01
0.00000e+00

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 76

The output at t= 2.06250

0.00000e+00 1.46517e+01 2.70670e+01 3.53932e+01


3.82926e+01 3.53932e+01 2.70670e+01 1.46517e+01
0.00000e+00

The output at t= 2.47500

0.00000e+00 1.25791e+01 2.32492e+01 3.03730e+01


3.28831e+01 3.03730e+01 2.32492e+01 1.25791e+01
0.00000e+00

The output at t= 2.88750

0.00000e+00 1.08019e+01 1.99583e+01 2.60792e+01


2.82261e+01 2.60792e+01 1.99583e+01 1.08019e+01
0.00000e+00

The output at t= 3.30000

0.00000e+00 9.27350e+00 1.71358e+01 2.23885e+01


2.42338e+01 2.23885e+01 1.71358e+01 9.27350e+00
0.00000e+00

The output at t= 3.71250

0.00000e+00 7.96176e+00 1.47113e+01 1.92215e+01


2.08050e+01 1.92215e+01 1.47113e+01 7.96176e+00
0.00000e+00

The output at t= 4.12500

0.00000e+00 6.83536e+00 1.26302e+01 1.65020e+01


1.78618e+01 1.65020e+01 1.26302e+01 6.83536e+00
0.00000e+00

The output at t= 4.53750

0.00000e+00 5.86837e+00 1.08433e+01 1.41675e+01


1.53348e+01 1.41675e+01 1.08433e+01 5.86837e+00
0.00000e+00

The output at t= 4.95000

0.00000e+00 5.03816e+00 9.30930e+00 1.21632e+01


1.31653e+01 1.21632e+01 9.30930e+00 5.03816e+00
0.00000e+00

The output at t= 5.36250

0.00000e+00 4.32540e+00 7.99229e+00 1.04424e+01


1.13028e+01 1.04424e+01 7.99229e+00 4.32540e+00
0.00000e+00

The output at t= 5.77500

0.00000e+00 3.71348e+00 6.86161e+00 8.96512e+00


9.70378e+00 8.96512e+00 6.86161e+00 3.71348e+00
0.00000e+00

The output at t= 6.18750

0.00000e+00 3.18812e+00 5.89088e+00 7.69681e+00


8.33097e+00 7.69681e+00 5.89088e+00 3.18812e+00
0.00000e+00

The output at t= 6.60000

0.00000e+00 2.73709e+00 5.05749e+00 6.60793e+00


7.15237e+00 6.60793e+00 5.05749e+00 2.73709e+00
0.00000e+00

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 77

The output at t= 7.01250

0.00000e+00 2.34987e+00 4.34200e+00 5.67309e+00


6.14051e+00 5.67309e+00 4.34199e+00 2.34987e+00
0.00000e+00

The output at t= 7.42500

0.00000e+00 2.01743e+00 3.72772e+00 4.87051e+00


5.27180e+00 4.87051e+00 3.72772e+00 2.01743e+00
0.00000e+00

The output at t= 7.83750

0.00000e+00 1.73202e+00 3.20036e+00 4.18147e+00


4.52599e+00 4.18147e+00 3.20036e+00 1.73202e+00
0.00000e+00

The output at t= 8.25000

0.00000e+00 1.48699e+00 2.74760e+00 3.58991e+00


3.88569e+00 3.58991e+00 2.74759e+00 1.48699e+00
0.00000e+00

Local time is: Tue May 03 17:19:58 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 78

6ROXWLRQ IRU WKH 3DUDEROLF SUREOHP ZLWK

∆[  F  DQG U 

• &UDQN1LFROVRQ PHWKRG

********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

2: Parabolic Partial Differential Equation

The following menu uses the heat eqn as a prototype for parabolic PDEs
but the methods listed apply equally to diffusion of materials, flow of
fluids (under conditions of laminar flow), flow of electricity in cables
(the telegraph equations) and so on

Your choice was

3 : One dimensional heat eqn :Crank-Nicolson method


boundaries expressed as constants
initial conditions expressed as points entered by the user

The data related to this problem is as follows

Length of the space dimension is 2.00000


Value of increment in the space dimension is 0.25000
The constant of your eqn reffered to the time side of the eqn is 6.60000
r factor to be used is 0.50000

The increment in time will be governed by the following equation


change time = CONSTANT * r * (change space)^2

Your time increment will be 2.06250e-01

The # of internal mesh points used is 7

The output at t= 0.00000

0.00000e+00 2.50000e+01 5.00000e+01 7.50000e+01


1.00000e+02 7.50000e+01 5.00000e+01 2.50000e+01
0.00000e+00

The output at t= 0.41250

0.00000e+00 2.45098e+01 4.77521e+01 6.61621e+01


7.34838e+01 6.61621e+01 4.77521e+01 2.45098e+01
0.00000e+00

The output at t= 0.82500

0.00000e+00 2.24457e+01 4.22508e+01 5.62363e+01


6.13388e+01 5.62363e+01 4.22508e+01 2.24457e+01
0.00000e+00

The output at t= 1.23750

0.00000e+00 1.96930e+01 3.66077e+01 4.81178e+01


5.22115e+01 4.81178e+01 3.66077e+01 1.96930e+01
0.00000e+00

The output at t= 1.65000

0.00000e+00 1.70285e+01 3.15260e+01 4.12709e+01


4.47073e+01 4.12709e+01 3.15260e+01 1.70285e+01
0.00000e+00

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 79

The output at t= 2.06250

0.00000e+00 1.46556e+01 2.70971e+01 3.54264e+01


3.83553e+01 3.54264e+01 2.70971e+01 1.46556e+01
0.00000e+00

The output at t= 2.47500

0.00000e+00 1.25942e+01 2.32758e+01 3.04175e+01


3.29265e+01 3.04175e+01 2.32758e+01 1.25942e+01
0.00000e+00

The output at t= 2.88750

0.00000e+00 1.08174e+01 1.99893e+01 2.61190e+01


2.82718e+01 2.61190e+01 1.99893e+01 1.08174e+01
0.00000e+00

The output at t= 3.30000

0.00000e+00 9.28982e+00 1.71657e+01 2.24286e+01


2.42767e+01 2.24286e+01 1.71657e+01 9.28982e+00
0.00000e+00

The output at t= 3.71250

0.00000e+00 7.97754e+00 1.47407e+01 1.92598e+01


2.08467e+01 1.92598e+01 1.47407e+01 7.97754e+00
0.00000e+00

The output at t= 4.12500

0.00000e+00 6.85051e+00 1.26581e+01 1.65387e+01


1.79013e+01 1.65387e+01 1.26581e+01 6.85051e+00
0.00000e+00

Local time is: Tue May 03 17:21:03 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 80

6ROXWLRQ IRU WKH 3DUDEROLF SUREOHP ZLWK

∆[  F  DQG U 

• &UDQN1LFROVRQ PHWKRG

********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

2: Parabolic Partial Differential Equation

The following menu uses the heat eqn as a prototype for parabolic PDEs
but the methods listed apply equally to diffusion of materials, flow of
fluids (under conditions of laminar flow), flow of electricity in cables
(the telegraph equations) and so on

Your choice was

3 : One dimensional heat eqn :Crank-Nicolson method


boundaries expressed as constants
initial conditions expressed as points entered by the user

The data related to this problem is as follows

Length of the space dimension is 2.00000


Value of increment in the space dimension is 0.25000
The constant of your eqn reffered to the time side of the eqn is 6.60000
r factor to be used is 0.10000

The increment in time will be governed by the following equation


change time = CONSTANT * r * (change space)^2

Your time increment will be 4.12500e-02

The # of internal mesh points used is 7

The output at t= 0.00000

0.00000e+00 2.50000e+01 5.00000e+01 7.50000e+01


1.00000e+02 7.50000e+01 5.00000e+01 2.50000e+01
0.00000e+00

The output at t= 0.41250

0.00000e+00 2.44994e+01 4.76286e+01 6.61016e+01


7.37980e+01 6.61016e+01 4.76286e+01 2.44994e+01
0.00000e+00

The output at t= 0.82500

0.00000e+00 2.23991e+01 4.22026e+01 5.62635e+01


6.14267e+01 5.62635e+01 4.22026e+01 2.23991e+01
0.00000e+00

The output at t= 1.23750

0.00000e+00 1.96721e+01 3.65950e+01 4.81384e+01


5.22516e+01 4.81384e+01 3.65950e+01 1.96721e+01
0.00000e+00

The output at t= 1.65000

0.00000e+00 1.70235e+01 3.15273e+01 4.12866e+01


4.47306e+01 4.12866e+01 3.15273e+01 1.70235e+01
0.00000e+00

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 81

The output at t= 2.06250

0.00000e+00 1.46572e+01 2.71040e+01 3.54404e+01


3.83727e+01 3.54404e+01 2.71040e+01 1.46572e+01
0.00000e+00

The output at t= 2.47500

0.00000e+00 1.25983e+01 2.32847e+01 3.04309e+01


3.29418e+01 3.04309e+01 2.32847e+01 1.25983e+01
0.00000e+00

The output at t= 2.88750

0.00000e+00 1.08224e+01 1.99989e+01 2.61321e+01


2.82862e+01 2.61321e+01 1.99989e+01 1.08224e+01
0.00000e+00

The output at t= 3.30000

0.00000e+00 9.29494e+00 1.71753e+01 2.24413e+01


2.42906e+01 2.24413e+01 1.71753e+01 9.29494e+00
0.00000e+00

The output at t= 3.71250

0.00000e+00 7.98257e+00 1.47500e+01 1.92720e+01


2.08600e+01 1.92720e+01 1.47500e+01 7.98257e+00
0.00000e+00

The output at t= 4.12500

0.00000e+00 6.85534e+00 1.26671e+01 1.65504e+01


1.79140e+01 1.65504e+01 1.26671e+01 6.85534e+00
0.00000e+00

Local time is: Tue May 03 17:22:03 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 82

 '(5,9$7,9(%281'$5<&21',7,216
5HDOO\ LPSRVH QR QHZ GLIILFXOWLHV EHFDXVH ZH FDQ H[WHQG WKH UHJLRQ DUWLILFLDOO\ DQG

UHSODFH WKH GHULYDWLYHV DW WKH ERXQGDULHV DOVR E\ ILQLWHGLIIHUHQFHV

,Q KHDWFRQGXFWLRQ SUREOHPV WKH PRVW XVXDO VLWXDWLRQ DW WKH HQGSRLQWV LV QRW WKDW WKH\

DUH KHOG DW D FRQVWDQW WHPSHUDWXUH EXW WKDW KHDW LV ORVW E\ FRQGXFWLRQ RU UDGLDWLRQ DW D

UDWH SURSRUWLRQDO WR VRPH SRZHU RI WKH WHPSHUDWXUH GLIIHUHQFH EHWZHHQ WKH VXUIDFH RI

WKH ERG\ DQG LWV VXUURXQGLQJV 7KLV OHDGV WR D UHODWLRQVKLS LQYROYLQJ WKH VSDFH

GHULYDWLYH RI WHPSHUDWXUH DW WKH VXUIDFH

:KHQ ZULWLQJ WKH ILQLWHGLIIHUHQFH UHSUHVHQWDWLRQ IRU DOO SRLQWV RQ WKH URG ZH ILQG WKDW

IRU SRLQWV RQ WKH ERXQGDULHV OHIW DQG ULJKW WZR QHZ SRLQWV DULVH X/ DQG X5 7R JR

DURXQG WKLV VLWXDWLRQ D ILQLWHGLIIHUHQFH UHSUHVHQWDWLRQ IRU WKHVH SRLQWV ILFWLWLRXV LV
∂X M
X ),567 ,17(51$/ 32,17 − X /M
= 
∂[ [ = K
M M
GX X5 − X (1' ,17(51$/ 32,17
= 
G[ [ = / K

:H XVH WKH ERXQGDU\ FRQGLWLRQV JLYHQ WR HOLPLQDWH WKHVH ILFWLWLRXV SRLQWV VXEVWLWXWLQJ

WKHLU YDOXHV LQ WKH UHSUHVHQWDWLRQ RI WKH LQWHUQDO SOXV ERXQGDU\ SRLQWV WKH VROXWLRQ LV

WKHQ UHDGLO\ REWDLQHG


∆W
:KHQ XVLQJ WKH H[SOLFLW PHWKRG U ZKHUH U  PXVW EH   WR JLYH VWDELOLW\
F ∆[


ZLWK WKH GHULYDWLYH HQG FRQGLWLRQV 7KHUH LV QR OLPLW RQ U ZKHQ ZRUNLQJ ZLWK WKH

LPSOLFLW PHWKRG EXW DV ZDV PHQWLRQHG EHIRUH WKH VPDOOHU WKH U WKH PRUH DFFXUDWH WKH

UHVXOWV

7R PDNH WKLQJV FOHDUHU DQ H[DPSOH LV FRQVLGHUHG

6ROYH WKH HTXDWLRQ


∂ X ∂X 
=  ≤ [ ≤  
∂W ∂[ 

VDWLVI\LQJ WKH LQLWLDO FRQGLWLRQ

X  IRU  ≤ [ ≤  ZKHQ W 

 )RU IXUWKHU UHIHUHQFH FRQVXOW >@ S 

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 83

DQG WKH ERXQGDU\ FRQGLWLRQV


∂X
=X DW [  IRU DOO W
∂[
∂X
= −X DW [ / IRU DOO W
∂[

/HW ∆[ 

• 8VLQJ WKH H[SOLFLW PHWKRG ZLWK U  S 

• 8VLQJ WKH &UDQN1LFROVRQ PHWKRG ZLWK U  S 

7KH DQDO\WLFDO VROXWLRQ DW [  LV DV IROORZV

W [ 

 

 

 

 

 

 

:KHQ UXQQLQJ WKH SURJUDP WKH IROORZLQJ SDJHV VKRZ WKH UHVXOWV REWDLQHG

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 84

6ROXWLRQ IRU WKH 3DUDEROLF SUREOHP ZLWK

∆[  F  DQG U 

• ([SOLFLW PHWKRG

********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

2: Parabolic Partial Differential Equation

The following menu uses the heat eqn as a prototype for parabolic PDEs
but the methods listed apply equally to diffusion of materials, flow of
fluids (under conditions of laminar flow), flow of electricity in cables
(the telegraph equations) and so on

Your choice was

5 : One dimensional heat eqn :Explicit method


boundaries expressed as derivatives
initial conditions expressed as points entered by the user

The data related to this problem is as follows

Length of the space dimension is 1.00000


Value of increment in the space dimension is 0.10000
The constant of your eqn reffered to the time side of the eqn is 1.00000
r factor to be used is 0.25000

The increment in time will be governed by the following equation


change time = CONSTANT * r * (change space)^2

Your time increment will be 2.50000e-03

The # of internal mesh points used is 11

The # of total mesh points used including fictious is 13

The output at t= 0.00000

1.00000e+00 1.00000e+00 1.00000e+00 1.00000e+00


1.00000e+00 1.00000e+00 1.00000e+00 1.00000e+00
1.00000e+00 1.00000e+00 1.00000e+00

The output at t= 0.06250

7.69483e-01 8.38741e-01 8.91683e-01 9.28485e-01


9.49980e-01 9.57027e-01 9.49980e-01 9.28485e-01
8.91683e-01 8.38741e-01 7.69483e-01

The output at t= 0.12500

6.86760e-01 7.49499e-01 7.99308e-01 8.35402e-01


8.57256e-01 8.64573e-01 8.57256e-01 8.35402e-01
7.99308e-01 7.49499e-01 6.86760e-01

The output at t= 0.18750

6.16768e-01 6.73171e-01 7.18064e-01 7.50683e-01


7.70476e-01 7.77112e-01 7.70476e-01 7.50683e-01
7.18064e-01 6.73171e-01 6.16768e-01

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 85

The output at t= 0.25000

5.54150e-01 6.04830e-01 6.45174e-01 6.74494e-01


6.92289e-01 6.98254e-01 6.92289e-01 6.74494e-01
6.45174e-01 6.04830e-01 5.54150e-01

The output at t= 0.31250

4.97904e-01 5.43440e-01 5.79690e-01 6.06035e-01


6.22024e-01 6.27384e-01 6.22024e-01 6.06035e-01
5.79690e-01 5.43440e-01 4.97904e-01

The output at t= 0.37500

4.47367e-01 4.88282e-01 5.20853e-01 5.44524e-01


5.58890e-01 5.63706e-01 5.58890e-01 5.44524e-01
5.20853e-01 4.88282e-01 4.47367e-01

The output at t= 0.43750

4.01961e-01 4.38722e-01 4.67987e-01 4.89256e-01


5.02164e-01 5.06491e-01 5.02164e-01 4.89256e-01
4.67987e-01 4.38722e-01 4.01961e-01

The output at t= 0.50000

3.61162e-01 3.94193e-01 4.20488e-01 4.39597e-01


4.51195e-01 4.55084e-01 4.51195e-01 4.39597e-01
4.20488e-01 3.94193e-01 3.61162e-01

The output at t= 0.56250

3.24505e-01 3.54183e-01 3.77809e-01 3.94979e-01


4.05400e-01 4.08894e-01 4.05400e-01 3.94979e-01
3.77809e-01 3.54183e-01 3.24505e-01

The output at t= 0.62500

2.91569e-01 3.18234e-01 3.39462e-01 3.54890e-01


3.64253e-01 3.67392e-01 3.64253e-01 3.54890e-01
3.39462e-01 3.18234e-01 2.91569e-01

The output at t= 0.68750

2.61975e-01 2.85934e-01 3.05008e-01 3.18869e-01


3.27282e-01 3.30102e-01 3.27282e-01 3.18869e-01
3.05008e-01 2.85934e-01 2.61975e-01

The output at t= 0.75000

2.35385e-01 2.56913e-01 2.74050e-01 2.86505e-01


2.94064e-01 2.96598e-01 2.94064e-01 2.86505e-01
2.74050e-01 2.56913e-01 2.35385e-01

The output at t= 0.81250

2.11494e-01 2.30837e-01 2.46235e-01 2.57425e-01


2.64217e-01 2.66494e-01 2.64217e-01 2.57425e-01
2.46235e-01 2.30837e-01 2.11494e-01

The output at t= 0.87500

1.90028e-01 2.07407e-01 2.21242e-01 2.31297e-01


2.37399e-01 2.39445e-01 2.37399e-01 2.31297e-01
2.21242e-01 2.07407e-01 1.90028e-01

The output at t= 0.93750

1.70741e-01 1.86356e-01 1.98787e-01 2.07821e-01


2.13304e-01 2.15142e-01 2.13304e-01 2.07821e-01
1.98787e-01 1.86356e-01 1.70741e-01

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 86

The output at t= 1.00000

1.53411e-01 1.67441e-01 1.78610e-01 1.86727e-01


1.91654e-01 1.93306e-01 1.91654e-01 1.86727e-01
1.78610e-01 1.67441e-01 1.53411e-01

Local time is: Tue May 03 23:25:33 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 87

6ROXWLRQ IRU WKH 3DUDEROLF SUREOHP ZLWK

∆[  F  DQG U 

• &UDQN1LFROVRQ PHWKRG

********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

2: Parabolic Partial Differential Equation

The following menu uses the heat eqn as a prototype for parabolic PDEs
but the methods listed apply equally to diffusion of materials, flow of
fluids (under conditions of laminar flow), flow of electricity in cables
(the telegraph equations) and so on

Your choice was

7 : One dimensional heat eqn :Crank-Nicolson method


bo
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

2: Parabolic Partial Differential Equation

The following menu uses the heat eqn as a prototype for parabolic PDEs
but the methods listed apply equally to diffusion of materials, flow of
fluids (under conditions of laminar flow), flow of electricity in cables
(the telegraph equations) and so on

Your choice was

7 : One dimensional heat eqn :Crank-Nicolson method


boundaries expressed as derivatives
initial conditions expressed as points entered by the user

The data related to this problem is as follows

Length of the space dimension is 1.00000


Value of increment in the space dimension is 0.10000
The constant of your eqn reffered to the time side of the eqn is 1.00000
r factor to be used is 1.00000

The increment in time will be governed by the following equation


change time = CONSTANT * r * (change space)^2

Your time increment will be 1.00000e-02

The # of internal mesh points used is 11

The # of total mesh points used including fictious is 13

The output at t= 0.00000

1.00000e+00 1.00000e+00 1.00000e+00 1.00000e+00


1.00000e+00 1.00000e+00 1.00000e+00 1.00000e+00
1.00000e+00 1.00000e+00 1.00000e+00

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 88

The output at t= 0.05000

7.91088e-01 8.61418e-01 9.13079e-01 9.47540e-01


9.66816e-01 9.72984e-01 9.66816e-01 9.47539e-01
9.13077e-01 8.61417e-01 7.91087e-01

The output at t= 0.10000

7.17944e-01 7.83353e-01 8.34931e-01 8.72039e-01


8.94371e-01 9.01822e-01 8.94371e-01 8.72038e-01
8.34930e-01 7.83351e-01 7.17942e-01

The output at t= 0.15000

6.58157e-01 7.18320e-01 7.66156e-01 8.00876e-01


8.21925e-01 8.28977e-01 8.21924e-01 8.00874e-01
7.66154e-01 7.18318e-01 6.58155e-01

The output at t= 0.20000

6.04143e-01 6.59392e-01 7.03367e-01 7.35320e-01


7.54711e-01 7.61210e-01 7.54710e-01 7.35319e-01
7.03365e-01 6.59390e-01 6.04141e-01

The output at t= 0.25000

5.54655e-01 6.05381e-01 6.45762e-01 6.75108e-01


6.92918e-01 6.98888e-01 6.92917e-01 6.75106e-01
6.45760e-01 6.05379e-01 5.54653e-01

The output at t= 0.30000

5.09232e-01 5.55804e-01 5.92879e-01 6.19823e-01


6.36175e-01 6.41657e-01 6.36175e-01 6.19822e-01
5.92878e-01 5.55803e-01 5.09230e-01

The output at t= 0.35000

4.67530e-01 5.10289e-01 5.44327e-01 5.69065e-01


5.84078e-01 5.89111e-01 5.84078e-01 5.69064e-01
5.44326e-01 5.10287e-01 4.67529e-01

The output at t= 0.40000

4.29244e-01 4.68501e-01 4.99752e-01 5.22464e-01


5.36247e-01 5.40868e-01 5.36247e-01 5.22463e-01
4.99751e-01 4.68499e-01 4.29242e-01

The output at t= 0.45000

3.94093e-01 4.30135e-01 4.58827e-01 4.79678e-01


4.92334e-01 4.96576e-01 4.92333e-01 4.79677e-01
4.58825e-01 4.30133e-01 3.94091e-01

The output at t= 0.50000

3.61820e-01 3.94910e-01 4.21253e-01 4.40397e-01


4.52016e-01 4.55911e-01 4.52015e-01 4.40396e-01
4.21252e-01 3.94909e-01 3.61819e-01

The output at t= 0.55000

3.32190e-01 3.62571e-01 3.86756e-01 4.04332e-01


4.15000e-01 4.18576e-01 4.14999e-01 4.04332e-01
3.86755e-01 3.62570e-01 3.32189e-01

The output at t= 0.60000

3.04987e-01 3.32879e-01 3.55084e-01 3.71221e-01


3.81015e-01 3.84298e-01 3.81015e-01 3.71220e-01
3.55083e-01 3.32878e-01 3.04985e-01

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 89

The output at t= 0.65000

2.80011e-01 3.05620e-01 3.26006e-01 3.40821e-01


3.49813e-01 3.52828e-01 3.49813e-01 3.40821e-01
3.26005e-01 3.05619e-01 2.80010e-01

The output at t= 0.70000

2.57081e-01 2.80592e-01 2.99309e-01 3.12911e-01


3.21167e-01 3.23934e-01 3.21166e-01 3.12911e-01
2.99308e-01 2.80591e-01 2.57080e-01

The output at t= 0.75000

2.36029e-01 2.57615e-01 2.74799e-01 2.87287e-01


2.94867e-01 2.97407e-01 2.94866e-01 2.87286e-01
2.74798e-01 2.57613e-01 2.36027e-01

The output at t= 0.80000

2.16701e-01 2.36519e-01 2.52296e-01 2.63762e-01


2.70720e-01 2.73053e-01 2.70719e-01 2.63760e-01
2.52294e-01 2.36517e-01 2.16699e-01

The output at t= 0.85000

1.98955e-01 2.17151e-01 2.31636e-01 2.42162e-01


2.48551e-01 2.50693e-01 2.48550e-01 2.42161e-01
2.31634e-01 2.17149e-01 1.98953e-01

The output at t= 0.90000

1.82663e-01 1.99369e-01 2.12667e-01 2.22332e-01


2.28197e-01 2.30163e-01 2.28197e-01 2.22331e-01
2.12666e-01 1.99367e-01 1.82661e-01

The output at t= 0.95000

1.67705e-01 1.83042e-01 1.95252e-01 2.04125e-01


2.09510e-01 2.11315e-01 2.09510e-01 2.04124e-01
1.95250e-01 1.83041e-01 1.67703e-01

The output at t= 1.00000

1.53972e-01 1.68053e-01 1.79263e-01 1.87410e-01


1.92354e-01 1.94011e-01 1.92353e-01 1.87408e-01
1.79261e-01 1.68051e-01 1.53970e-01

Local time is: Tue May 03 23:32:40 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 90

 7:2',0(16,21$/3$5$%2/,&(48$7,216
 $1'7+($/7(51$7,1*',5(&7,21,03/,&,70(7+2'
7KLV VHFWLRQ LV FRQFHUQHG ZLWK WKH QXPHULFDO VROXWLRQ RI WKH HTXDWLRQ
∂X ∂ X  ∂ X 
N = + 
∂W ∂ [  ∂ \ 

RYHU WKH UHFWDQJXODU UHJLRQ  ≤ [ ≤ D  ≤ \ ≤ E ZKHUH X LV NQRZQ LQLWLDOO\ DW DOO SRLQWV

ZLWKLQ DQG RQ WKH ERXQGDU\ RI WKH UHFWDQJOH DQG LV NQRZQ VXEVHTXHQWO\ RQ DOO SRLQWV RQ

WKH ERXQGDU\

'HILQH WKH FRRUGLQDWHV [\W  RI WKH PHVK SRLQWV RI WKH VROXWLRQ GRPDLQ E\

[ L∆[ \ M∆\ W Q∆W

ZKHUH L M Q DUH SRVLWLYH LQWHJHUV DQG GHQRWH WKH YDOXHV RI X DW WKHVH PHVK SRLQWV E\

X L∆[ M∆\ Q∆W XLMQ

7KH H[SOLFLW ILQLWHGLIIHUHQFH UHSUHVHQWDWLRQ RI WKLV WZRGLPHQVLRQDO 3'( LV


−X
XL  M Q + XL − M Q − X + X + XL  M −Q − X + X +Q
= +
L  M Q L  M Q L  M Q L  M Q L M
N 
∆W ∆ [ ∆ \
 

DSSHDUV DWWUDFWLYHO\ VLPSOH EXW LV FRPSXWDWLRQDOO\ ODERULRXV EHFDXVH WKH FRQGLWLRQ IRU

LWV YDOLGLW\ ZKLFK LV


  
^ + `∆W ≤   
∆[ ∆\
 
N

QHFHVVDWHV H[WUHPHO\ VPDOO YDOXHV RI ∆W )RU PRVW SUREOHPV LW LV DQ LPSUDFWLFDO PHWKRG

7KH &UDQN1LFROVRQ PHWKRG QDPHO\


XL M Q + −X ∂ X ∂ X
 
∂ X ∂ X
 

+ +

=  ^ +
L  M Q
N `
∆W ∂[ ∂\
 
L  M Q
∂[ ∂\
 
L  M Q +

LV YDOLG IRU DOO YDOXHV RI ∆[ ∆\ DQG ∆W EXW UHTXLUHV WKH VROXWLRQ RI 0 × 1

VLPXOWDQHRXV DOJHEUDLF HTXDWLRQV IRU HDFK VWHS IRUZDUG LQ WLPH ZKHUH 1∆[ D 0∆\ E

,I WKH\ ZHUH WR EH VROYHG WKHQ WKH\ DUH WR EH VROYHG LWHUDWLYHO\

7KH PRVW HIILFLHQW PHWKRG IRU UHFWDQJXODU UHJLRQV LV WKH $OWHUQDWLQJ 'LUHFWLRQ ,PSOLFLW

$', PHWKRG ZKHQ ILUVW SUHVHQWHG E\ 3HDFHPDQ DQG 5DFKIRUG LQ  WKH\

VKRZHG ZLWK D W\SLFDO SUREOHP WKDW LW LQYROYHG DERXW WZHQW\ILYH WLPHV OHVV ZRUN WKDQ

WKH H[SOLFLW PHWKRG DQG VHYHQ WLPHV OHVV ZRUN WKDQ WKH &UDQN1LFROVRQ PHWKRG

 )RU D GHWDLOHG VWXG\ FRQVXOW >@ S  >@ S  DQG >@ S 

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 91

7KH ILQLWHGLIIHUHQFH UHSUHVHQWDWLRQ IRU WKH WZRGLPHQVLRQDO 3'( YLD WKLV PHWKRG LV
XL  M Q + −X XL − M Q + − X + + X +  M Q + XL  M −Q − X + X +
= +
L  M Q L  M Q  L L  M Q L M Q
 
∆W N ∆ [

N ∆ \


XL  M Q + − X + XL − M Q + − X + + X+  M Q + XL  M − + − X + + X +Q + 
= +
 L  M Q  L  M Q  L Q  L  M Q  L M
 
∆W N ∆ [

N ∆ \


$SSOLFDWLRQ RI  WR HDFK RI WKH 1 PHVK SRLQWV DORQJ D URZ SDUDOOHO WR WKH [D[LV

WKHQ JLYHV 1 HTXDWLRQV IRU WKH 1 XQNQRZQ YDOXHV RI X DW WKHVH PHVK SRLQWV IRU

WLPH W Q ∆W :KHQ WKHUH DUH 0 URZV SDUDOOHO WR WKH [D[LV WKH DGYDQFHPHQW

RI WKH VROXWLRQ RYHU WKH ZKROH UHFWDQJOH WR WKH Q WK WLPH VWHS LQYROYHV WKH VROXWLRQ RI

0 LQGHSHQGHQW V\VWHPV RI HTXDWLRQV HDFK V\VWHP FRQWDLQLQJ 1 XQNQRZQV 7KH

VROXWLRQ RI WKHVH V\VWHPV LV PXFK HDVLHU WKDQ WKH VROXWLRQ RI WKH 0 × 1 HTXDWLRQV

DVVRFLDWHG ZLWK WKH &UDQN1LFROVRQ PHWKRG

7KH DGYDQFHPHQW RI WKH VROXWLRQ WR WKH Q WK WLPH OHYHO LV DFKLHYHG E\ DSSO\LQJ

HTXDWLRQ  WR HDFK PHVK SRLQW DORQJ FROXPQV SDUDOOHO WR WKH \D[LV 7KLV JLYHV 1

V\VWHPV RI HTXDWLRQV HDFK V\VWHP LQYROYLQJ 0 XQNQRZQV 7KH WLPH LQWHUYDO ∆W
PXVW EH WKH VDPH IRU HDFK DGYDQFHPHQW

3URYLGHG WKH VROXWLRQ IRU VXFFHVVLYH WLPH VWHSV LV GHULYHG E\ DOWHUQDWLQJ EHWZHHQ URZV

DQG FROXPQV DV GHVFULEHG DERYH WKH PHWKRG LV YDOLG IRU DOO UDWLRV RI ∆W ∆[  DQG ∆W ∆\ 
(DFK VWHS RQ LWV RZQ LV XQVWDEOH DQG XQLODWHUDO UHSHWLWLRQ OHDGV WR DQ XQDFFHSWDEOH JURZWK RI

HUURUV

,Q WKH SDFNDJH WKH $', PHWKRG ZDV XVHG WR VROYH WKH WZRGLPHQVLRQDO SDUDEROLF

HTXDWLRQV 7KH IROORZLQJ H[DPSOH ZLOO SUHVHQW VXFK D SUREOHP

([DPSOH

8VH WKH $', PHWKRG WR ILQG WKH WHPSHUDWXUHV RI D SODWH RI   FP K  FP $W

W  V DVVXPH WKDW WKH WHPSHUDWXUH RI WKH SODWH LV ]HUR DQG WKH ERXQGDU\ WHPSHUDWXUHV

DUH LQVWDQWDQHRXVO\ EURXJKW WR

XSSHU  R&


R
ORZHU  &
R
OHIW  &

ULJKW  R&

(PSOR\ D WLPH VWHS RI  V DQG VROYH WLOO W  V

7KH FRQVWDQW F  VFP

:KHQ UXQQLQJ WKH SURJUDP WKH IROORZLQJ SDJHV VKRZ WKH UHVXOWV REWDLQHG

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 92

6ROXWLRQ IRU WKH 3DUDEROLF SUREOHP ZLWK


∆[  FP F  VFP DQG U 

• $', PHWKRG

********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

2: Parabolic Partial Differential Equation

The following menu uses the heat eqn as a prototype for parabolic PDEs
but the methods listed apply equally to diffusion of materials, flow of
fluids (under conditions of laminar flow), flow of electricity in cables
(the telegraph equations) and so on

Your choice was

9 : Two dimensional heat eqn :ADI method


boundaries expressed as constant points entered by user
initial conditions expressed as points entered by the user

The data related to this problem is as follows

Length of the X space dimension is 40.00000


Length of the Y space dimension is 40.00000
Value of increment in the space dimension is 10.00000
The constant of your eqn reffered to the time side of the eqn is 1.19760
r factor to be used is 0.08350

The increment in time will be governed by the following equation


change time = CONSTANT * r * (change space)^2
Your time increment will be 1.00000e+01

The # of internal mesh points used is 9


The output at t= 0.00000 proceeding from highest to lowest row

For row 5

0.00000 0.00000 0.00000 0.00000


0.00000

For row 4

0.00000 0.00000 0.00000 0.00000


0.00000

For row 3

0.00000 0.00000 0.00000 0.00000


0.00000

For row 2

0.00000 0.00000 0.00000 0.00000


0.00000

For row 1

0.00000 0.00000 0.00000 0.00000


0.00000

The output at t= 50.00000 proceeding from highest to lowest row

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 93

For row 5

1.00000e+02 1.00000e+02 1.00000e+02 1.00000e+02


1.00000e+02

For row 4

7.50000e+01 4.39999e+01 3.40293e+01 3.81935e+01


5.00000e+01

For row 3

7.50000e+01 2.58350e+01 1.17112e+01 1.91189e+01


5.00000e+01

For row 2

7.50000e+01 1.94288e+01 6.12315e+00 1.34526e+01


5.00000e+01

For row 1

0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00


0.00000e+00

The output at t= 100.00000 proceeding from highest to lowest row

For row 5

1.00000e+02 1.00000e+02 1.00000e+02 1.00000e+02


1.00000e+02

For row 4

7.50000e+01 6.07625e+01 5.25735e+01 5.30248e+01


5.00000e+01

For row 3

7.50000e+01 4.10890e+01 2.71999e+01 3.19463e+01


5.00000e+01

For row 2

7.50000e+01 2.85577e+01 1.45709e+01 2.07317e+01


5.00000e+01

For row 1

0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00


0.00000e+00

The output at t= 150.00000 proceeding from highest to lowest row

For row 5

1.00000e+02 1.00000e+02 1.00000e+02 1.00000e+02


1.00000e+02

For row 4

7.50000e+01 6.86491e+01 6.25796e+01 6.02151e+01


5.00000e+01

For row 3

7.50000e+01 4.99912e+01 3.82904e+01 3.99453e+01


5.00000e+01

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 94

For row 2

7.50000e+01 3.39974e+01 2.12029e+01 2.55314e+01


5.00000e+01

For row 1

0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00


0.00000e+00

The output at t= 200.00000 proceeding from highest to lowest row

For row 5

1.00000e+02 1.00000e+02 1.00000e+02 1.00000e+02


1.00000e+02

For row 4

7.50000e+01 7.28240e+01 6.81744e+01 6.41202e+01


5.00000e+01

For row 3

7.50000e+01 5.52607e+01 4.53239e+01 4.48567e+01


5.00000e+01

For row 2

7.50000e+01 3.73986e+01 2.57205e+01 2.86859e+01


5.00000e+01

For row 1

0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00


0.00000e+00

The output at t= 250.00000 proceeding from highest to lowest row

For row 5

1.00000e+02 1.00000e+02 1.00000e+02 1.00000e+02


1.00000e+02

For row 4

7.50000e+01 7.51761e+01 7.13982e+01 6.63587e+01


5.00000e+01

For row 3

7.50000e+01 5.84090e+01 4.96356e+01 4.78510e+01


5.00000e+01

For row 2

7.50000e+01 3.95180e+01 2.86201e+01 3.06995e+01


5.00000e+01

For row 1

0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00


0.00000e+00

The output at t= 300.00000 proceeding from highest to lowest row

For row 5

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING PARABOLIC PDES PAGE 95

1.00000e+02 1.00000e+02 1.00000e+02 1.00000e+02


1.00000e+02

For row 4

7.50000e+01 7.65449e+01 7.32929e+01 6.76753e+01


5.00000e+01

For row 3

7.50000e+01 6.02995e+01 5.22519e+01 4.96692e+01


5.00000e+01

For row 2

7.50000e+01 4.08250e+01 3.04284e+01 3.19562e+01


5.00000e+01

For row 1

0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00


0.00000e+00

Local time is: Wed May 04 02:23:44 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


PAGE 96

&+$37(5 
180(5,&$/0(7+2'6)2562/9,1*
+<3(5%2/,&3$57,$/',))(5(17,$/(48$7,216

7KH WKLUG FODVVLILFDWLRQ RI SDUWLDOGLIIHUHQWLDO HTXDWLRQV K\SHUEROLF 3DUWLDO'LIIHUHQWLDO


(TXDWLRQV 3'(V  LQFOXGHV WKH ZDYH HTXDWLRQ WKDW LV IXQGDPHQWDO WR WKH VWXG\ RI
YLEUDWLQJ V\VWHPV 7KH\ DUH DOVR LQYROYHG LQ WUDQVSRUW SUREOHPV GLIIXVLRQ RI PDWWHU
QHXWURQ GLIIXVLRQ DQG UDGLDWLRQ WUDQVIHU  ZDYH PHFKDQLFV JDV G\QDPLFV VXSHUVRQLF
IORZ DQG RWKHU LPSRUWDQW DUHDV 7KH WHFKQRORJ\ LQ PRVW RI WKHVH DSSOLFDWLRQV LV VR
FRPSOLFDWHG WKDW WKHLU VWXG\ LV EH\RQG RXU VFRSH :H VHWWOH IRU VLPSOH H[DPSOHV VXFK DV
D YLEUDWLQJ VWULQJ DV LQ D YLROLQ VWULQJ DQG D YLEUDWLQJ PHPEUDQH LQ ZKLFK WKH HQGV DUH
KHOG IL[HG LQ ERWK FDVHV

7KH RQHGLPHQVLRQDO UHSUHVHQWDWLRQ RI WKH ZDYH HTXDWLRQ LV


∂ \ ∂ \
= F 
∂W  ∂[ 

7KLV HTXDWLRQ ZDV FODVVLILHG DV +\SHUEROLF EHFDXVH FRPSDULQJ WR WKH VWDQGDUG IRUP RI D
3'( LQ WZR LQGHSHQGHQW YDULDEOHV [ DQG W

DX[[  EX[W  FXWW  ) [ W X X[ XW 


ZH ILQG WKDW E
 DF ! 

:H DUH LQWHUHVWHG LQ KRZ \ WKH ODWHUDO GLVSODFHPHQW YDULHV ZLWK WLPH W DQG ZLWK
GLVWDQFH [ DORQJ WKH VWULQJ 7KH FRQGLWLRQV LPSRVHG RQ WKH VROXWLRQ DUH WKH HQG
FRQGLWLRQV DW [  DQG [ / DQG WKH LQLWLDO FRQGLWLRQV DW W  ,QLWLDO FRQGLWLRQV
∂\
ZKLFK VSHFLI\ ERWK \ I [ DQG WKH YHORFLW\ = J [ DUH XVXDO IRU WKLV SUREOHP $
∂W
QXPEHU RI VLPSOLILFDWLRQV DUH WDNHQ IRU RXU VWULQJ SUREOHP VXFK DV WKH VWULQJ LV
SHUIHFWO\ HODVWLF DQG ZH QHJOHFW JUDYLWDWLRQDO IRUFHV VR WKH RQO\ IRUFH LV WKH WHQVLRQ
IRUFH LQ WKH GLUHFWLRQ RI WKH VWULQJ WKH VWULQJ LV XQLIRUP LQ GHQVLW\ DQG WKLFNQHVV

7KH WZRGLPHQVLRQDO UHSUHVHQWDWLRQ RI WKH ZDYH HTXDWLRQ LV


∂ X ∂ X ∂ X
= F +  
∂W  ∂[  ∂\

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING HYPERBOLIC PDES PAGE 97

$ W\SLFDO SUREOHP LV WKH YLEUDWLQJ PHPEUDQH LQ ZKLFK D WKLQ IOH[LEOH PHPEUDQH LV


VWUHWFKHG RYHU D UHFWDQJXODU IUDPH DQG VHW WR YLEUDWH :KHUH X LV WKH GLVSODFHPHQW W LV
WKH WLPH [ DQG \ DUH WKH VSDFH FRRUGLQDWHV

 62/9,1*7+(:$9((48$7,21%<),1,7(',))(5(1&(6
:H DWWDFN WKH SUREOHP IRU VROYLQJ WKH RQHGLPHQVLRQDO ZDYH HTXDWLRQ LQ WKH XVXDO ZD\
E\ UHSODFLQJ GHULYDWLYHV E\ GLIIHUHQFH TXRWLHQWV 6XSHUVFULSWV DUH XVHG WR GHQRWH WLPH
DQG VXEVFULSWV IRU SRVLWLRQ 7KHUHIRUH IRU
∂ \ ∂ \
= F 
∂W  ∂[ 

WKH ILQLWHGLIIHUHQFH UHSUHVHQWDWLRQ ZLOO EH


+ − ∆[
\L
M
= M
\ L + + M
\L − − \L
M
 ∆W =  
F

(TXDWLRQ  LV WKH XVXDO ZD\ WKDW WKH RQHGLPHQVLRQDO KHDW HTXDWLRQ LV VROYHG
QXPHULFDOO\ 7DNLQJ WKLV UHSUHVHQWDWLRQ ZH REWDLQ H[DFW DQDO\WLFDO UHVXOWV

7KHUH LV VWLOO D SUREOHP LQ DSSO\LQJ (T  ZH NQRZ \ DW W WR  IURP WKH LQLWLDO
FRQGLWLRQ EXW WR FRPSXWH \ DW W ∆W W ZH QHHG YDOXHV DW W W :H PD\ DW ILUVW EH
ERWKHUHG E\ D QHHG WR NQRZ GLVSODFHPHQWV EHIRUH WKH VWDUW RI WKH SUREOHP EXW LI ZH
LPDJLQH WKH IXQFWLRQ \ \ [W WR EH H[WHQGHG EDFNZDUG LQ WLPH WKH WHUP W PDNHV
JRRG VHQVH 6LQFH ZH ZLOO RUGLQDULO\ JHW SHULRGLF IXQFWLRQV IRU \ YHUVXV W DW D JLYHQ
SRLQW ZH FDQ FRQVLGHU ]HUR WLPH DV DQ DUELWUDU\ SRLQW DW ZKLFK ZH NQRZ WKH
GLVSODFHPHQW DQG YHORFLW\ ZLWKLQ WKH GXUDWLRQ RI DQ RQJRLQJ SURFHVV

2QH FRPPRQO\ XVHG ZD\ WR JHW YDOXHV IRU WKH ILFWLWLRXV SRLQW DW W W LV E\ HPSOR\LQJ
WKH VSHFLILFDWLRQ IRU WKH LQLWLDO YHORFLW\ ∂\∂W J [ DW W  8VLQJ D FHQWUDOGLIIHUHQFH
DSSUR[LPDWLRQ ZH KDYH
∂\ 
\L − \− 
[  = L
= J [  
∂W  ∆W
L L

−
\L = 
\L −  J [ ∆WL RQO\ DW W =  

(TXDWLRQ  LV YDOLG RQO\ DW W  VXEVWLWXWLQJ LQWR (T  JLYHV XV IRU W W

\ =   \ + + \ − + J [ ∆ W 
  
L L L L 

 6WXG\ RI FKDUDFWHULVWLFV FODULILHV WKLV VLWXDWLRQ )RU IXUWKHU UHIHUHQFH FRQVXOW >@ S 

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING HYPERBOLIC PDES PAGE 98

$IWHU FRPSXWLQJ WKH ILUVW OLQH ZLWK (T   ZH XVH (T  WKHUHDIWHU

 (;$03/(217+(21(',0(16,21$/:$9((48$7,21
$ SUREOHP ZLOO QRZ EH LQWURGXFHG DQG LW ZLOO EH VROYHG E\ )LQLWHGLIIHUHQFHV IRU WZR

GLIIHUHQW PHVK VL]HV

$ EDQMR VWULQJ LV  FP ORQJ DQG ZHLJKV  J ,W LV VWUHWFKHG ZLWK D WHQVLRQ RI J

$W D SRLQW  FP IURP RQH HQG LW LV SXOOHG  FP IURP WKH HTXLOLEULXP SRVLWLRQ DQG

WKHQ UHOHDVHG )LQG WKH GLVSODFHPHQW RI SRLQWV DORQJ WKH VWULQJ DV D IXQFWLRQ RI WLPH

+RZ ORQJ GRHV LW WDNH IRU RQH FRPSOHWH F\FOH RI PRWLRQ" )URP WKLV FRPSXWH WKH

IUHTXHQF\ ZLWK ZKLFK LW RVFLOODWHV

 /HW ∆[  FP S 

 /HW ∆[  FP S 

F 7JZ

7KH IROORZLQJ GLVFXVVLRQ LV IRU WKH ∆[  FP FDVH D VLPLODU RQH DSSOLHV IRU ∆[  FP

%HFDXVH WKH VWULQJ LV MXVW UHOHDVHG IURP LWV LQLWLDOO\ GLVSODFHG SRVLWLRQ WKH LQLWLDO SRVLWLRQ DW

DOO SRLQWV LV ]HUR DQG (T  EHFRPHV VLPSO\

\L

=   \ + + 
L 

\L − 

7KH LQLWLDO FRQGLWLRQV LPSO\ WKDW \ LV OLQHDU LQ [ IURP \  DW [  WR \  DW [ 

DQG DOVR OLQHDU WR [  7KH VL]H RI WKH WLPH VWHSV LV JLYHQ E\
∆[
∆W =  VHF
F

1RWLFH RQ SDJH  DIWHU FRPSOHWLQJ FDOFXODWLRQV IRU HLJKW WLPH VWHSV ZH REVHUYH WKDW

WKH \YDOXHV DUH UHSURGXFLQJ WKH RULJLQDO VWHSV EXW ZLWK QHJDWLYH VLJQV DQG WKH HQG RI WKH

VWULQJ UHYHUVHG WKDW LV KDOI D F\FOH KDV EHHQ FRPSOHWHG LQ HLJKW VWHSV )RU D FRPSOHWH

F\FOH  ∆W
V DUH QHHGHG 7KH IUHTXHQF\ RI YLEUDWLRQ LV WKHQ

I = =  F\FOHV  VHF
   

:KHQ UXQQLQJ WKH SURJUDP WKH IROORZLQJ SDJHV VKRZ WKH UHVXOWV REWDLQHG

 $V LQ >@ S 

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


PAGE 99

2QHGLPHQVLRQDO ZDYH HTXDWLRQ


∆[  FP

********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

3: Hyperbolic Partial Differential Equation

The following menu uses the wave eqn as a prototype for Hyperbolic PDEs
the wave eqn is fundamental to the study of vibrating systems
Hyperbolic PDEs are also involved in transport problems (diffusion of matter,
neutron diffusion, and radiation transfer), wave mechanics, gas dynamics, super-sonic
flow, and other important areas

Your choice was

1 : One dimensional wave eqn :by Finite Differences


boundaries expressed as constants
initial conditions expressed as a polynomial function
time derivative expressed as a polynomial function

The data related to this problem is as follows

Length of the space dimension is 80.00000


The constant of your eqn reffered to the space side of the PDE is 3136000000.00000
Value of increment in the space dimension is 10.00000

The increment in time will be governed by the following equation


(change time)^2 * CONSTANT = (change space)^2
Your time increment will be 1.78571e-04

The # of internal mesh points used is 7

The output at t= 0.000000

0.00000e+00 3.00000e-01 6.00000e-01 5.00000e-01


4.00000e-01 3.00000e-01 2.00000e-01 1.00000e-01
0.00000e+00

The output at t= 0.000179

0.00000e+00 3.00000e-01 4.00000e-01 5.00000e-01


4.00000e-01 3.00000e-01 2.00000e-01 1.00000e-01
0.00000e+00

The output at t= 0.000357

0.00000e+00 1.00000e-01 2.00000e-01 3.00000e-01


4.00000e-01 3.00000e-01 2.00000e-01 1.00000e-01
0.00000e+00

The output at t= 0.000536

0.00000e+00 -1.00000e-01 5.55112e-17 1.00000e-01


2.00000e-01 3.00000e-01 2.00000e-01 1.00000e-01
0.00000e+00

The output at t= 0.000714

0.00000e+00 -1.00000e-01 -2.00000e-01 -1.00000e-01


5.55112e-17 1.00000e-01 2.00000e-01 1.00000e-01
0.00000e+00

The output at t= 0.000893

0.00000e+00 -1.00000e-01 -2.00000e-01 -3.00000e-01


-2.00000e-01 -1.00000e-01 5.55112e-17 1.00000e-01
0.00000e+00

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING HYPERBOLIC PDES PAGE 100

The output at t= 0.001071

0.00000e+00 -1.00000e-01 -2.00000e-01 -3.00000e-01


-4.00000e-01 -3.00000e-01 -2.00000e-01 -1.00000e-01
0.00000e+00

The output at t= 0.001250

0.00000e+00 -1.00000e-01 -2.00000e-01 -3.00000e-01


-4.00000e-01 -5.00000e-01 -4.00000e-01 -3.00000e-01
0.00000e+00

The output at t= 0.001429

0.00000e+00 -1.00000e-01 -2.00000e-01 -3.00000e-01


-4.00000e-01 -5.00000e-01 -6.00000e-01 -3.00000e-01
0.00000e+00

The output at t= 0.001607

0.00000e+00 -1.00000e-01 -2.00000e-01 -3.00000e-01


-4.00000e-01 -5.00000e-01 -4.00000e-01 -3.00000e-01
0.00000e+00

The output at t= 0.001786

0.00000e+00 -1.00000e-01 -2.00000e-01 -3.00000e-01


-4.00000e-01 -3.00000e-01 -2.00000e-01 -1.00000e-01
0.00000e+00

The output at t= 0.001964

0.00000e+00 -1.00000e-01 -2.00000e-01 -3.00000e-01


-2.00000e-01 -1.00000e-01 0.00000e+00 1.00000e-01
0.00000e+00

The output at t= 0.002143

0.00000e+00 -1.00000e-01 -2.00000e-01 -1.00000e-01


-5.55112e-17 1.00000e-01 2.00000e-01 1.00000e-01
0.00000e+00

The output at t= 0.002321

0.00000e+00 -1.00000e-01 -5.55112e-17 1.00000e-01


2.00000e-01 3.00000e-01 2.00000e-01 1.00000e-01
0.00000e+00

The output at t= 0.002500

0.00000e+00 1.00000e-01 2.00000e-01 3.00000e-01


4.00000e-01 3.00000e-01 2.00000e-01 1.00000e-01
0.00000e+00

The output at t= 0.002679

0.00000e+00 3.00000e-01 4.00000e-01 5.00000e-01


4.00000e-01 3.00000e-01 2.00000e-01 1.00000e-01
0.00000e+00

The output at t= 0.002857

0.00000e+00 3.00000e-01 6.00000e-01 5.00000e-01


4.00000e-01 3.00000e-01 2.00000e-01 1.00000e-01
0.00000e+00

Local time is: Mon May 09 16:18:54 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING HYPERBOLIC PDES PAGE 101

2QHGLPHQVLRQDO ZDYH HTXDWLRQ

• )RU ∆[  FP

********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

3: Hyperbolic Partial Differential Equation

The following menu uses the wave eqn as a prototype for Hyperbolic PDEs
the wave eqn is fundamental to the study of vibrating systems
Hyperbolic PDEs are also involved in transport problems (diffusion of matter,
neutron diffusion, and radiation transfer), wave mechanics, gas dynamics, super-sonic
flow, and other important areas

Your choice was

1 : One dimensional wave eqn :by Finite Differences


boundaries expressed as constants
initial conditions expressed as a polynomial function
time derivative expressed as a polynomial function

The data related to this problem is as follows

Length of the space dimension is 80.00000


The constant of your eqn reffered to the space side of the PDE is 3136000000.00000
Value of increment in the space dimension is 5.00000

The increment in time will be governed by the following equation


(change time)^2 * CONSTANT = (change space)^2
Your time increment will be 8.92857e-05

The # of internal mesh points used is 15

The output at t= 0.000000

0.00000e+00 1.50000e-01 3.00000e-01 4.50000e-01


6.00000e-01 5.50000e-01 5.00000e-01 4.50000e-01
4.00000e-01 3.50000e-01 3.00000e-01 2.50000e-01
2.00000e-01 1.50000e-01 1.00000e-01 5.00000e-02
0.00000e+00

The output at t= 0.000089

0.00000e+00 1.50000e-01 3.00000e-01 4.50000e-01


5.00000e-01 5.50000e-01 5.00000e-01 4.50000e-01
4.00000e-01 3.50000e-01 3.00000e-01 2.50000e-01
2.00000e-01 1.50000e-01 1.00000e-01 5.00000e-02
0.00000e+00

The output at t= 0.000179

0.00000e+00 1.50000e-01 3.00000e-01 3.50000e-01


4.00000e-01 4.50000e-01 5.00000e-01 4.50000e-01
4.00000e-01 3.50000e-01 3.00000e-01 2.50000e-01
2.00000e-01 1.50000e-01 1.00000e-01 5.00000e-02
0.00000e+00

The output at t= 0.000268

0.00000e+00 1.50000e-01 2.00000e-01 2.50000e-01


3.00000e-01 3.50000e-01 4.00000e-01 4.50000e-01
4.00000e-01 3.50000e-01 3.00000e-01 2.50000e-01
2.00000e-01 1.50000e-01 1.00000e-01 5.00000e-02
0.00000e+00

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING HYPERBOLIC PDES PAGE 102

The output at t= 0.000357

0.00000e+00 5.00000e-02 1.00000e-01 1.50000e-01


2.00000e-01 2.50000e-01 3.00000e-01 3.50000e-01
4.00000e-01 3.50000e-01 3.00000e-01 2.50000e-01
2.00000e-01 1.50000e-01 1.00000e-01 5.00000e-02
0.00000e+00

The output at t= 0.000446

0.00000e+00 -5.00000e-02 -5.55112e-17 5.00000e-02


1.00000e-01 1.50000e-01 2.00000e-01 2.50000e-01
3.00000e-01 3.50000e-01 3.00000e-01 2.50000e-01
2.00000e-01 1.50000e-01 1.00000e-01 5.00000e-02
0.00000e+00

The output at t= 0.000536

0.00000e+00 -5.00000e-02 -1.00000e-01 -5.00000e-02


-8.32667e-17 5.00000e-02 1.00000e-01 1.50000e-01
2.00000e-01 2.50000e-01 3.00000e-01 2.50000e-01
2.00000e-01 1.50000e-01 1.00000e-01 5.00000e-02
0.00000e+00

The output at t= 0.000625

0.00000e+00 -5.00000e-02 -1.00000e-01 -1.50000e-01


-1.00000e-01 -5.00000e-02 -2.77556e-17 5.00000e-02
1.00000e-01 1.50000e-01 2.00000e-01 2.50000e-01
2.00000e-01 1.50000e-01 1.00000e-01 5.00000e-02
0.00000e+00

The output at t= 0.000714

0.00000e+00 -5.00000e-02 -1.00000e-01 -1.50000e-01


-2.00000e-01 -1.50000e-01 -1.00000e-01 -5.00000e-02
-5.55112e-17 5.00000e-02 1.00000e-01 1.50000e-01
2.00000e-01 1.50000e-01 1.00000e-01 5.00000e-02
0.00000e+00

The output at t= 0.000804

0.00000e+00 -5.00000e-02 -1.00000e-01 -1.50000e-01


-2.00000e-01 -2.50000e-01 -2.00000e-01 -1.50000e-01
-1.00000e-01 -5.00000e-02 0.00000e+00 5.00000e-02
1.00000e-01 1.50000e-01 1.00000e-01 5.00000e-02
0.00000e+00

The output at t= 0.000893

0.00000e+00 -5.00000e-02 -1.00000e-01 -1.50000e-01


-2.00000e-01 -2.50000e-01 -3.00000e-01 -2.50000e-01
-2.00000e-01 -1.50000e-01 -1.00000e-01 -5.00000e-02
-5.55112e-17 5.00000e-02 1.00000e-01 5.00000e-02
0.00000e+00

The output at t= 0.000982

0.00000e+00 -5.00000e-02 -1.00000e-01 -1.50000e-01


-2.00000e-01 -2.50000e-01 -3.00000e-01 -3.50000e-01
-3.00000e-01 -2.50000e-01 -2.00000e-01 -1.50000e-01
-1.00000e-01 -5.00000e-02 -5.55112e-17 5.00000e-02
0.00000e+00

The output at t= 0.001071

0.00000e+00 -5.00000e-02 -1.00000e-01 -1.50000e-01


-2.00000e-01 -2.50000e-01 -3.00000e-01 -3.50000e-01
-4.00000e-01 -3.50000e-01 -3.00000e-01 -2.50000e-01
-2.00000e-01 -1.50000e-01 -1.00000e-01 -5.00000e-02
0.00000e+00

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING HYPERBOLIC PDES PAGE 103

The output at t= 0.001161

0.00000e+00 -5.00000e-02 -1.00000e-01 -1.50000e-01


-2.00000e-01 -2.50000e-01 -3.00000e-01 -3.50000e-01
-4.00000e-01 -4.50000e-01 -4.00000e-01 -3.50000e-01
-3.00000e-01 -2.50000e-01 -2.00000e-01 -1.50000e-01
0.00000e+00

The output at t= 0.001250

0.00000e+00 -5.00000e-02 -1.00000e-01 -1.50000e-01


-2.00000e-01 -2.50000e-01 -3.00000e-01 -3.50000e-01
-4.00000e-01 -4.50000e-01 -5.00000e-01 -4.50000e-01
-4.00000e-01 -3.50000e-01 -3.00000e-01 -1.50000e-01
0.00000e+00

The output at t= 0.001339

0.00000e+00 -5.00000e-02 -1.00000e-01 -1.50000e-01


-2.00000e-01 -2.50000e-01 -3.00000e-01 -3.50000e-01
-4.00000e-01 -4.50000e-01 -5.00000e-01 -5.50000e-01
-5.00000e-01 -4.50000e-01 -3.00000e-01 -1.50000e-01
0.00000e+00

The output at t= 0.001429

0.00000e+00 -5.00000e-02 -1.00000e-01 -1.50000e-01


-2.00000e-01 -2.50000e-01 -3.00000e-01 -3.50000e-01
-4.00000e-01 -4.50000e-01 -5.00000e-01 -5.50000e-01
-6.00000e-01 -4.50000e-01 -3.00000e-01 -1.50000e-01
0.00000e+00

The output at t= 0.001518

0.00000e+00 -5.00000e-02 -1.00000e-01 -1.50000e-01


-2.00000e-01 -2.50000e-01 -3.00000e-01 -3.50000e-01
-4.00000e-01 -4.50000e-01 -5.00000e-01 -5.50000e-01
-5.00000e-01 -4.50000e-01 -3.00000e-01 -1.50000e-01
0.00000e+00

The output at t= 0.001607

0.00000e+00 -5.00000e-02 -1.00000e-01 -1.50000e-01


-2.00000e-01 -2.50000e-01 -3.00000e-01 -3.50000e-01
-4.00000e-01 -4.50000e-01 -5.00000e-01 -4.50000e-01
-4.00000e-01 -3.50000e-01 -3.00000e-01 -1.50000e-01
0.00000e+00

The output at t= 0.001696

0.00000e+00 -5.00000e-02 -1.00000e-01 -1.50000e-01


-2.00000e-01 -2.50000e-01 -3.00000e-01 -3.50000e-01
-4.00000e-01 -4.50000e-01 -4.00000e-01 -3.50000e-01
-3.00000e-01 -2.50000e-01 -2.00000e-01 -1.50000e-01
0.00000e+00

The output at t= 0.001786

0.00000e+00 -5.00000e-02 -1.00000e-01 -1.50000e-01


-2.00000e-01 -2.50000e-01 -3.00000e-01 -3.50000e-01
-4.00000e-01 -3.50000e-01 -3.00000e-01 -2.50000e-01
-2.00000e-01 -1.50000e-01 -1.00000e-01 -5.00000e-02
0.00000e+00

The output at t= 0.001875

0.00000e+00 -5.00000e-02 -1.00000e-01 -1.50000e-01


-2.00000e-01 -2.50000e-01 -3.00000e-01 -3.50000e-01
-3.00000e-01 -2.50000e-01 -2.00000e-01 -1.50000e-01
-1.00000e-01 -5.00000e-02 0.00000e+00 5.00000e-02
0.00000e+00

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING HYPERBOLIC PDES PAGE 104

The output at t= 0.001964

0.00000e+00 -5.00000e-02 -1.00000e-01 -1.50000e-01


-2.00000e-01 -2.50000e-01 -3.00000e-01 -2.50000e-01
-2.00000e-01 -1.50000e-01 -1.00000e-01 -5.00000e-02
-5.55112e-17 5.00000e-02 1.00000e-01 5.00000e-02
0.00000e+00

The output at t= 0.002054

0.00000e+00 -5.00000e-02 -1.00000e-01 -1.50000e-01


-2.00000e-01 -2.50000e-01 -2.00000e-01 -1.50000e-01
-1.00000e-01 -5.00000e-02 0.00000e+00 5.00000e-02
1.00000e-01 1.50000e-01 1.00000e-01 5.00000e-02
0.00000e+00

The output at t= 0.002143

0.00000e+00 -5.00000e-02 -1.00000e-01 -1.50000e-01


-2.00000e-01 -1.50000e-01 -1.00000e-01 -5.00000e-02
-5.55112e-17 5.00000e-02 1.00000e-01 1.50000e-01
2.00000e-01 1.50000e-01 1.00000e-01 5.00000e-02
0.00000e+00

The output at t= 0.002232

0.00000e+00 -5.00000e-02 -1.00000e-01 -1.50000e-01


-1.00000e-01 -5.00000e-02 0.00000e+00 5.00000e-02
1.00000e-01 1.50000e-01 2.00000e-01 2.50000e-01
2.00000e-01 1.50000e-01 1.00000e-01 5.00000e-02
0.00000e+00

The output at t= 0.002321

0.00000e+00 -5.00000e-02 -1.00000e-01 -5.00000e-02


-5.55112e-17 5.00000e-02 1.00000e-01 1.50000e-01
2.00000e-01 2.50000e-01 3.00000e-01 2.50000e-01
2.00000e-01 1.50000e-01 1.00000e-01 5.00000e-02
0.00000e+00

The output at t= 0.002411

0.00000e+00 -5.00000e-02 0.00000e+00 5.00000e-02


1.00000e-01 1.50000e-01 2.00000e-01 2.50000e-01
3.00000e-01 3.50000e-01 3.00000e-01 2.50000e-01
2.00000e-01 1.50000e-01 1.00000e-01 5.00000e-02
0.00000e+00

The output at t= 0.002500

0.00000e+00 5.00000e-02 1.00000e-01 1.50000e-01


2.00000e-01 2.50000e-01 3.00000e-01 3.50000e-01
4.00000e-01 3.50000e-01 3.00000e-01 2.50000e-01
2.00000e-01 1.50000e-01 1.00000e-01 5.00000e-02
0.00000e+00

The output at t= 0.002589

0.00000e+00 1.50000e-01 2.00000e-01 2.50000e-01


3.00000e-01 3.50000e-01 4.00000e-01 4.50000e-01
4.00000e-01 3.50000e-01 3.00000e-01 2.50000e-01
2.00000e-01 1.50000e-01 1.00000e-01 5.00000e-02
0.00000e+00

The output at t= 0.002679

0.00000e+00 1.50000e-01 3.00000e-01 3.50000e-01


4.00000e-01 4.50000e-01 5.00000e-01 4.50000e-01
4.00000e-01 3.50000e-01 3.00000e-01 2.50000e-01
2.00000e-01 1.50000e-01 1.00000e-01 5.00000e-02
0.00000e+00

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING HYPERBOLIC PDES PAGE 105

The output at t= 0.002768

0.00000e+00 1.50000e-01 3.00000e-01 4.50000e-01


5.00000e-01 5.50000e-01 5.00000e-01 4.50000e-01
4.00000e-01 3.50000e-01 3.00000e-01 2.50000e-01
2.00000e-01 1.50000e-01 1.00000e-01 5.00000e-02
0.00000e+00

The output at t= 0.002857

0.00000e+00 1.50000e-01 3.00000e-01 4.50000e-01


6.00000e-01 5.50000e-01 5.00000e-01 4.50000e-01
4.00000e-01 3.50000e-01 3.00000e-01 2.50000e-01
2.00000e-01 1.50000e-01 1.00000e-01 5.00000e-02
0.00000e+00

Local time is: Mon May 09 16:30:36 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


PAGE 106

 7+(:$9((48$7,21,17:2',0(16,216
7KH ILQLWHGLIIHUHQFH PHWKRG FDQ EH DSSOLHG WR +\SHUEROLF 3'(V LQ WZR GLPHQVLRQV $

W\SLFDO SUREOHP LV WKH YLEUDWLQJ PHPEUDQH :KHUH D WKLQ IOH[LEOH PHPEUDQH LV VWUHWFKHG

RYHU D UHFWDQJXODU IUDPH DQG VHW WR YLEUDWH D FDVH RI ZKLFK FDQ EH UHSUHVHQWHG E\
∂ X
∂ X ∂ X  

= F + 
∂W ∂[

∂\  

:KHUH X LV WKH GLVSODFHPHQW W LV WKH WLPH [ DQG \ DUH WKH VSDFH FRRUGLQDWHV F LV D

FRQVWDQW WKDW GHSHQGV RQ WKH XQLIRUP WHQVLRQ SHU XQLW OHQJWK DFFHOHUDWLRQ RI JUDYLW\

DQG ZHLJKW SHU XQLW DUHD 5HSODFLQJ HDFK GHULYDWLYH E\ LWV FHQWUDOGLIIHUHQFH

DSSUR[LPDWLRQ DQG XVLQJ K ∆[ ∆\ JLYHV


F ∆W F ∆W
 
N
XL  M
+
= 
N
XL − M +X+ +X
N
L  M
N
L M − +X N
L M + −X N
L M
−
+  −  
N
X L M  
K K

6XSHUVFULSWV DUH XVHG LQ (T  WR GHQRWH WLPH )RU WKH ILUVW WLPH VWHS ZH JHW

GLVSODFHPHQWV IURP (T  EHORZ ZKLFK LV REWDLQHG E\ DSSUR[LPDWLQJ ∂\∂W DW W 


 − 
E\ D FHQWUDOGLIIHUHQFH DSSUR[LPDWLRQ LQYROYLQJ X L M DQG XL M 


XL  M = 
XL − M +X+ +X 
L  M

L M − +X 
L M + + ∆W J [ L  \ M  


,Q (T  J [ LV WKH LQLWLDO YHORFLW\

F ∆W


7KH UDWLR

=   LV WKH PD[LPXP YDOXH IRU VWDELOLW\ +RZHYHU LQ FRQWUDVW ZLWK
K

WKH ZDYH HTXDWLRQ LQ RQH VSDFH GLPHQVLRQ ZH GR QRW JHW H[DFW DQVZHUV IURP WKH

QXPHULFDO SURFHGXUH RI (T   DQG ZH IXUWKHU REVHUYH WKDW ZH PXVW XVH VPDOOHU WLPH

VWHSV LQ UHODWLRQ WR WKH VL]H RI WKH VSDFH LQWHUYDO 7KHUHIRUH ZH DGYDQFH LQ WLPH PRUH

VORZO\ +RZHYHU WKH QXPHULFDO PHWKRG LV VWUDLJKWIRUZDUG DV WKH IROORZLQJ H[DPSOH LQ

WKH QH[W VHFWLRQ ZLOO VKRZ

 (;$03/(217+(7:2',0(16,21$/:$9((48$7,21
$ SUREOHP ZLOO QRZ EH LQWURGXFHG DQG LW ZLOO EH VROYHG E\ )LQLWHGLIIHUHQFHV IRU WZR

GLIIHUHQW PHVK VL]HV

 )RU IXUWKHU UHIHUHQFH FRQVXOW >@ S 

 6HH H[DPSOH LQ >@ S 

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING HYPERBOLIC PDES PAGE 107

$ PHPEUDQH IRU ZKLFK F  LV VWUHWFKHG RYHU D VTXDUH IUDPH WKDW RFFXSLHV WKH UHJLRQ

 ≤ [ ≤ ≤ \ ≤   LQ
 WKH [ \ SODQH ,W LV JLYHQ DQ LQLWLDO GLVSODFHPHQW GHVFULEHG E\

X = [  − [ \  − \ 

DQG KDV DQ LQLWLDO YHORFLW\ RI ]HUR )LQG KRZ WKH GLVSODFHPHQW YDULHV ZLWK WLPH

• )RU K  U  S 


F ∆W

7R JHW DFFXUDWH UHVXOWV GHFUHDVLQJ WKH UDWLR RI DQG XVLQJ (T  JLYHV OLWWOH

K

RU QR LPSURYHPHQW LQ WKH DYHUDJH DFFXUDF\ WR DSSURDFK FORVHO\ WR WKH DQDO\WLFDO

UHVXOWV K PXVW EH PDGH VPDOOHU :KHQ WKLV LV GRQH ∆W ZLOO QHHG WR GHFUHDVH LQ

SURSRUWLRQ UHTXLULQJ PDQ\ WLPH VWHSV DQG OHDGLQJ WR PDQ\ UHSHWLWLRQV RI WKH DOJRULWKP

DQG H[WUDYDJDQW XVH RI FRPSXWHU WLPH

:KHQ UXQQLQJ WKH SURJUDP WKH IROORZLQJ SDJHV VKRZ WKH UHVXOWV REWDLQHG

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


PAGE 108

7ZRGLPHQVLRQDO ZDYH HTXDWLRQ

• )RU K  U 

********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs

Your choice was

3: Hyperbolic Partial Differential Equation

The following menu uses the wave eqn as a prototype for Hyperbolic PDEs
the wave eqn is fundamental to the study of vibrating systems
Hyperbolic PDEs are also involved in transport problems (diffusion of matter,
neutron diffusion, and radiation transfer), wave mechanics, gas dynamics, super-sonic
flow, and other important areas

Your choice was

5 : Two dimensional wave eqn :by Finite Differences


boundaries expressed as constants
initial conditions expressed as points entered by user
time derivative expressed as points entered by user

The data related to this problem is as follows

length of the X space dimension is 2.00000


length of the Y space dimension is 2.00000
value of increment in the space dimension is 0.50000
the constant of your eqn reffered to the space side of the eqn is 3.00000
r factor to be used is 0.50000

The increment in time will be governed by the following equation


(change time)^2 = (r * (change space)^2) / CONSTANT
Your time increment will be 2.04124e-01

The # of internal mesh points used is 9


The output at t= 0.00000 proceeding from highest to lowest row

For row 5

0.00000 0.00000 0.00000 0.00000 0.00000

For row 4

0.00000 0.56250 0.75000 0.56250 0.00000

For row 3

0.00000 0.75000 1.00000 0.75000 0.00000

For row 2

0.00000 0.56250 0.75000 0.56250 0.00000

For row 1

0.00000 0.00000 0.00000 0.00000 0.00000

The output at t= 0.20412 proceeding from highest to lowest row

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING HYPERBOLIC PDES PAGE 109

For row 5

0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00


0.00000e+00

For row 4

0.00000e+00 3.75000e-01 5.31250e-01 3.75000e-01


0.00000e+00

For row 3

0.00000e+00 5.31250e-01 7.50000e-01 5.31250e-01


0.00000e+00

For row 2

0.00000e+00 3.75000e-01 5.31250e-01 3.75000e-01


0.00000e+00

For row 1

0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00


0.00000e+00

The output at t= 0.40825 proceeding from highest to lowest row

For row 5

0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00


0.00000e+00

For row 4

0.00000e+00 -3.12500e-02 0.00000e+00 -3.12500e-02


0.00000e+00

For row 3

0.00000e+00 0.00000e+00 6.25000e-02 0.00000e+00


0.00000e+00

For row 2

0.00000e+00 -3.12500e-02 0.00000e+00 -3.12500e-02


0.00000e+00

For row 1

0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00


0.00000e+00

The output at t= 0.61237 proceeding from highest to lowest row

For row 5

0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00


0.00000e+00

For row 4

0.00000e+00 -3.75000e-01 -5.31250e-01 -3.75000e-01


0.00000e+00

For row 3

0.00000e+00 -5.31250e-01 -7.50000e-01 -5.31250e-01


0.00000e+00

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING HYPERBOLIC PDES PAGE 110

For row 2

0.00000e+00 -3.75000e-01 -5.31250e-01 -3.75000e-01


0.00000e+00

For row 1

0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00


0.00000e+00

The output at t= 0.81650 proceeding from highest to lowest row

For row 5

0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00


0.00000e+00

For row 4

0.00000e+00 -5.00000e-01 -7.50000e-01 -5.00000e-01


0.00000e+00

For row 3

0.00000e+00 -7.50000e-01 -1.12500e+00 -7.50000e-01


0.00000e+00

For row 2

0.00000e+00 -5.00000e-01 -7.50000e-01 -5.00000e-01


0.00000e+00

For row 1

0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00


0.00000e+00

The output at t= 1.02062 proceeding from highest to lowest row

For row 5

0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00


0.00000e+00

For row 4

0.00000e+00 -3.75000e-01 -5.31250e-01 -3.75000e-01


0.00000e+00

For row 3

0.00000e+00 -5.31250e-01 -7.50000e-01 -5.31250e-01


0.00000e+00

For row 2

0.00000e+00 -3.75000e-01 -5.31250e-01 -3.75000e-01


0.00000e+00

For row 1

0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00


0.00000e+00

The output at t= 1.22474 proceeding from highest to lowest row

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING HYPERBOLIC PDES PAGE 111

For row 5

0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00


0.00000e+00

For row 4

0.00000e+00 -3.12500e-02 -0.00000e+00 -3.12500e-02


0.00000e+00

For row 3

0.00000e+00 -0.00000e+00 6.25000e-02 -0.00000e+00


0.00000e+00

For row 2

0.00000e+00 -3.12500e-02 -0.00000e+00 -3.12500e-02


0.00000e+00

For row 1

0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00


0.00000e+00

The output at t= 1.42887 proceeding from highest to lowest row

For row 5

0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00


0.00000e+00

For row 4

0.00000e+00 3.75000e-01 5.31250e-01 3.75000e-01


0.00000e+00

For row 3

0.00000e+00 5.31250e-01 7.50000e-01 5.31250e-01


0.00000e+00

For row 2

0.00000e+00 3.75000e-01 5.31250e-01 3.75000e-01


0.00000e+00

For row 1

0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00


0.00000e+00

The output at t= 1.63299 proceeding from highest to lowest row

For row 5

0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00


0.00000e+00

For row 4

0.00000e+00 5.62500e-01 7.50000e-01 5.62500e-01


0.00000e+00

For row 3

0.00000e+00 7.50000e-01 1.00000e+00 7.50000e-01


0.00000e+00

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


NUMERICAL METHODS FOR SOLVING HYPERBOLIC PDES PAGE 112

For row 2

0.00000e+00 5.62500e-01 7.50000e-01 5.62500e-01


0.00000e+00

For row 1

0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00


0.00000e+00

Local time is: Mon May 09 23:46:44 1994

Thank you for using Kutkut's Numerical PDE Solver


February, 1994 Amman - Jordan

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


PAGE 113

$33(1',;$  5()(5(1&(6
>@ &KDSUD 6WHYHQ DQG &DQDOH 5D\PRQG 1XPHULFDO 0HWKRGV IRU (QJLQHHUV QG
HG 0F*UDZ+LOO 
>@ &RQVWDQWLQDGHV $ONLV $SSOLHG 1XPHULFDO 0HWKRGV :LWK 3HUVRQDO &RPSXWHUV
0F*UDZ+LOO 
>@ *HUDOG &XUWLV DQG :KHDWOH\ 3DWULFN $SSOLHG 1XPHULFDO $QDO\VLV WK HG
$GGLVRQ :HVOH\ 
>@ +ROPDQ -3 +HDW 7UDQVIHU 0F*UDZ+LOO 
>@ .UH\V]LJ (UZLQ $GYDQFHG (QJLQHHULQJ 0DWKHPDWLFV WK HG -RKQ :LOH\
6RQV 
>@ 2
1HLO 3HWHU $GYDQFHG (QJLQHHULQJ 0DWKHPDWLFV QG HG :DGVZRUWK
3XEOLVKLQJ &RPSDQ\ 
>@ 3DSSDV &KULV DQG 0XUUD\ :LOOLDP %RUODQG & +DQGERRN UG HG
2VERUQH 0F*UDZ+LOO 
>@ 6FKZDUW] (XJHQH 0 +RZ 7R 'RXEOH <RXU 3RZHU 7R /HDUQ &DVWOH %RRNV
1HZ <RUN 
>@ 6KLOGW +HUEHUW 8VLQJ 7XUER & 0F*UDZ+LOO 
>@ 6PLWK *' 1XPHULFDO 6ROXWLRQ RI 3DUWLDO 'LIIHUHQWLDO (TXDWLRQV 2[IRUG
8QLYHUVLW\ 3UHVV 
>@ %RUODQG & YHUVLRQ  0DQXDOV %RUODQG ,QWHUQDWLRQDO 

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


APPENDIX B PAGE 114

$33(1',;% 7$%/(2)%5,()),/('(6&5,37,21 
  6285&(&2'(2)$//352*5$0),/(6
7KH IROORZLQJ WDEOH JLYHV LQ DOSKDEHWLFDO RUGHU D EULHI GHVFULSWLRQ RI DOO ILOHV
XVHG LQ .XWNXW
V 1XPHULFDO 3'( 6ROYHU

$GLF  8VHG LQ (OOLSWLF 3'(V ZLWK 'LULFKOHW FRQGLWLRQV VROYHV WKH HQWHUHG DUUD\
XVLQJ WKH $OWHUQDWLQJ 'LUHFWLRQ ,PSOLFLW $', PHWKRG DFFRUGLQJ WR WKH
S IDFWRU (QWHUHG E\ WKH XVHU

$GLF  8VHG LQ (OOLSWLF 3'(V ZLWK 'LULFKOHW FRQGLWLRQV VROYHV WKH HQWHUHG DUUD\
XVLQJ WKH $', PHWKRG ZLWKRXW DQ\ S IDFWRU RU ZLWK S  
$GLF  8VHG LQ (OOLSWLF 3'(V ZLWK 'LULFKOHW FRQGLWLRQV VROYHV WKH HQWHUHG DUUD\
XVLQJ WKH $', PHWKRG XVLQJ DQ RSWLPXP S IDFWRU JHQHUDWHG IURP
ZLWKLQ WKH SURJUDP
$GLJRRGF  8VHG LQ WKH WZRGLPHQVLRQDO 3DUDEROLF 3'( VROYHV E\ XVLQJ WKH
$', PHWKRG ZLWKRXW DQ\ S IDFWRU
%QGU\F  8VHG LQ (OOLSWLF 3'(V HQWHUV ERXQGDU\ FRQGLWLRQV RI WKH IRXU VLGHV RI
WKH UHFWDQJXODU UHJLRQ DV SRO\QRPLDO IXQFWLRQV RI ; DQG <
&LUFOHF  8VHG LQ (OOLSWLF 3'(V ZLWK FLUFXODU ERXQGDULHV VROYHV YLD WKH *DXVV
6HLGHO LWHUDWLYH PHWKRG
&LUFOHF  8VHG LQ (OOLSWLF 3'(V ZLWK FLUFXODU ERXQGDULHV VROYHV YLD WKH -DFREL
LWHUDWLYH PHWKRG
&UDQNF  8VHG LQ WKH RQHGLPHQVLRQDO 3DUDEROLF 3'(V VROYHV IRU FRQVWDQW
ERXQGDULHV XVLQJ WKH LPSOLFLW &UDQN1LFROVRQ PHWKRG
&UDQNF  8VHG LQ WKH RQHGLPHQVLRQDO 3DUDEROLF 3'(V VROYHV IRU ERXQGDULHV
ZKHQ H[SUHVVHG DV GHULYDWLYHV XVLQJ WKH LPSOLFLW &UDQN1LFROVRQ PHWKRG
'HFLGHF  8VHG LQ (OOLSWLF 3'(V PHQX IRU FKRRVLQJ WKH W\SH RI (OOLSWLF 3'( ZLWK
'LULFKOHW FRQGLWLRQV UHJXODU ERXQGDULHV WKH XVHU ZDQWV WR VROYH
'HFLGHF  8VHG LQ (OOLSWLF 3'(V PHQX IRU FKRRVLQJ WKH W\SH RI (OOLSWLF 3'( ZLWK
'LULFKOHW FRQGLWLRQV LUUHJXODU ERXQGDULHV WKH XVHU ZDQWV WR VROYH
'HFLGHKF  8VHG LQ +\SHUEROLF 3'(V PHQX IRU FKRRVLQJ WKH W\SH RI +\SHUEROLF
3'( WKH XVHU ZDQWV WR VROYH
'HFLGHSF  8VHG LQ 3DUDEROLF 3'(V PHQX IRU FKRRVLQJ WKH W\SH RI 3DUDEROLF 3'(
WKH XVHU ZDQWV WR VROYH

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


APPENDIX B PAGE 115

'PQVQF  8VHG LQ (OOLSWLF 3'(V HQWHUV WKH GLPHQVLRQV RI WKH UHFWDQJXODU UHJLRQ
DQG WKH PHVK VL]H WKDW WKH XVHU ZDQWV WR XVH
(OOLSWLFF  8VHG LQ (OOLSWLF 3'(V PHQX IRU VHOHFWLQJ WKH W\SH RI ERXQGDU\
FRQGLWLRQV RI WKH (OOLSWLF 3'(
(QWHUF  8VHG LQ RQHGLPHQVLRQDO 3DUDEROLF 3'(V XVHG IRU HQWHULQJ GDWD RI WKH
SUREOHP LQ VWDNH
(QWHUF  8VHG LQ WZRGLPHQVLRQDO 3DUDEROLF 3'(V XVHG IRU HQWHULQJ GDWD RI WKH
SUREOHP LQ VWDNH
(QWHUKF  8VHG LQ RQHGLPHQVLRQDO +\SHUEROLF 3'(V XVHG IRU HQWHULQJ GDWD RI WKH
SUREOHP LQ VWDNH
(QWHUKF  8VHG LQ WZRGLPHQVLRQDO +\SHUEROLF 3'(V XVHG IRU HQWHULQJ GDWD RI WKH
SUREOHP LQ VWDNH
([F  *LYHV  URZV RI FRORUHG
&
V
([F  *LYHV  URZV RI FRORUHG
&
V
([SOFWF  8VHG LQ RQHGLPHQVLRQDO 3DUDEROLF 3'(V VROYHV ZKHQ ERXQGDULHV DUH
H[SUHVVHG DV FRQVWDQWV XVLQJ WKH H[SOLFLW PHWKRG
([SOFWF  8VHG LQ RQHGLPHQVLRQDO 3DUDEROLF 3'(V VROYHV ZKHQ ERXQGDULHV DUH
H[SUHVVHG DV GHULYDWLYHV XVLQJ WKH H[SOLFLW PHWKRG
*DXVVSF  8VHG LQ (OOLSWLF 3'(V ZLWK 'LULFKOHW FRQGLWLRQV VROYHV XVLQJ *DXVV
6HLGHO LWHUDWLYH PHWKRG XVLQJ SRLQW DSSUR[LPDWLRQ
*DXVVSF  8VHG LQ (OOLSWLF 3'(V ZLWK 'LULFKOHW FRQGLWLRQV VROYHV XVLQJ *DXVV
6HLGHO LWHUDWLYH PHWKRG XVLQJ SRLQW DSSUR[LPDWLRQ
*UDSKF  8VHG WR GLVSOD\ D UHFWDQJXODU JULG WR UHPLQG WKH XVHU WKDW KHVKH LV
ZRUNLQJ RQ D UHJXODU ERXQGDU\ QHHGV WKH SUHVHQFH RI WKH ILOH HJDYJDEJL
*UDSKF  8VHG WR GLVSOD\ D 6HPLFLUFXODU JULG WR UHPLQG WKH XVHU WKDW KHVKH LV
ZRUNLQJ RQ DQ LUUHJXODU ERXQGDU\ QHHGV WKH SUHVHQFH RI WKH ILOH
HJDYJDEJL
*UDSKF  8VHG WR GLVSOD\ D &LUFXODU JULG WR UHPLQG WKH XVHU WKDW KHVKH LV ZRUNLQJ
RQ DQ LUUHJXODU ERXQGDU\ QHHGV WKH SUHVHQFH RI WKH ILOH HJDYJDEJL
*UGEQGF  8VHG LQ (OOLSWLF 3'(V ZLWK 'LULFKOHW FRQGLWLRQV HQWHUV ERXQGDU\
FRQGLWLRQV RI WKH IRXU VLGHV RI WKH UHFWDQJXODU UHJLRQ LQ VWDNH

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


APPENDIX B PAGE 116

*UGGLPF  8VHG LQ (OOLSWLF 3'(V ZLWK 'LULFKOHW FRQGLWLRQV HQWHUV GLPHQVLRQV RI


WKH IRXU VLGHV RI WKH UHFWDQJXODU UHJLRQ LQ VWDNH DQG WKH PHVK VL]H WKDW WKH
XVHU ZDQWV WR XVH
+HDGHUK  0DLQ KHDGHU ILOH QHHGHG E\ DOO ILOHV
+HDGHUK  +HDGHU ILOH QHHGHG E\ ILOHV WKDW VROYH WKH (OOLSWLF 3'( RI W\SH 3RLVVRQ
+LVKHDGK  +HDGHU ILOH QHHGHG PRVWO\ E\ DOO ILOHV WKDW VROYH (OOLSWLF 3'(V DQG WKRVH
WKDW VROYH WZRGLPHQVLRQDO 3DUDEROLF DQG +\SHUEROLF 3'(V
+SEOFGPF  8VHG WR VROYH WKH WZRGLPHQVLRQDO +\SHUEROLF 3'(
+\SHUF  8VHG WR VROYH DOO FDVHV RI WKH RQHGLPHQVLRQDO +\SHUEROLF 3'(
,QLWLDOF  8VHG LQ (OOLSWLF 3'(V ZLWK 'LULFKOHW FRQGLWLRQV FDOFXODWHV WKH SURSHU
LQLWLDOL]DWLRQ RI DOO LQWHUQDO PHVK SRLQWV RI WKH JULG LQ VWDNH WDNLQJ WKH
DYHUDJH RI DOO ERXQGDU\ SRLQWV VR DV WR PLQLPL]H WKH QXPEHU RI
LWHUDWLRQV QHHGHG E\ DOO QXPHULFDO PHWKRGV
-DFRELSF  8VHG LQ (OOLSWLF 3'(V ZLWK 'LULFKOHW FRQGLWLRQV VROYHV XVLQJ -DFREL
LWHUDWLYH PHWKRG XVLQJ SRLQW DSSUR[LPDWLRQ
-DFRELSF  8VHG LQ (OOLSWLF 3'(V ZLWK 'LULFKOHW FRQGLWLRQV VROYHV XVLQJ -DFREL
LWHUDWLYH PHWKRG XVLQJ SRLQW DSSUR[LPDWLRQ
0DLQF  )LOH WKDW FRQWDLQV WKH PDLQ IXQFWLRQ RI WKH SURJUDP DQG WKDW FDOOV DOO
RWKHU PDLQ"F ILOHV
0DLQF  )LOH WKDW FDOOV DOO QHHGHG ILOHV IRU VROYLQJ WKH (OOLSWLF 3'( ZLWK 1HXPDQQ
DQG 0L[HG ERXQGDU\ FRQGLWLRQV
0DLQF  )LOH WKDW FDOOV DOO QHHGHG ILOHV IRU VROYLQJ WKH (OOLSWLF 3'( ZLWK 'LULFKOHW
ERXQGDU\ FRQGLWLRQV
0DLQF  )LOH WKDW FDOOV DOO QHHGHG ILOHV IRU VROYLQJ WKH 3DUDEROLF 3'(
0DLQF  )LOH WKDW FDOOV DOO QHHGHG ILOHV IRU VROYLQJ WKH +\SHUEROLF 3'(
0HWKRGF  8VHG LQ (OOLSWLF 3'(V ZLWK 'LULFKOHW FRQGLWLRQV XVHG WR GLVSOD\ D PHQX
VR WKDW WKH XVHU FDQ SLFN WKH DSSURSULDWH LWHUDWLYH PHWKRG QHHGHG IRU
VROYLQJ KLVKHU SUREOHP
0HWKRGF  8VHG LQ (OOLSWLF 3'(V ZLWK 1HXPDQQ RU 0L[HG FRQGLWLRQV XVHG WR
GLVSOD\ D PHQX IRU WKH XVHU IRU KLPKHU WR SLFN WKH LWHUDWLYH PHWKRG
QHHGHG IRU VROYLQJ WKH SUREOHP LQ VWDNH

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


APPENDIX B PAGE 117

0L[HGF  8VHG LQ (OOLSWLF 3'(V ZLWK 1HXPDQQ RU 0L[HG FRQGLWLRQV VROYHV WKH
SUREOHP LQ VWDNH XVLQJ *DXVV6HLGHO LWHUDWLYH PHWKRG
0L[HGF  8VHG LQ (OOLSWLF 3'(V ZLWK 1HXPDQQ RU 0L[HG FRQGLWLRQV VROYHV WKH
SUREOHP LQ VWDNH XVLQJ -DFREL LWHUDWLYH PHWKRG
0L[HGF  8VHG LQ (OOLSWLF 3'(V ZLWK 1HXPDQQ RU 0L[HG FRQGLWLRQV VROYHV WKH
SUREOHP LQ VWDNH XVLQJ 6XFFHVVLYH 2YHUUHOD[DWLRQ 625 
0\KHDGK  +HDGHU ILOH XVHG E\ PDLQF ILOH FRQWDLQV DOO QHHGHG SURWRW\SHV DQG
LQLWLDOL]DWLRQV
1RWHF  )LOH WKDW GLVSOD\V LQIRUPDWLRQ RQ KRZ WKH SURJUDP LQLWLDOL]HV WKH LQWHUQDO
PHVK SRLQWV
1RWHF  )LOH WKDW GLVSOD\V D EULHI LQWURGXFWLRQ WR WKH 3DUDEROLF 3'(V DQG LQIRUPV
WKH XVHU WKDW WKH IROORZLQJ PHQX ZLOO XVH WKH RQHGLPHQVLRQDO +HDW
(TXDWLRQ DV D SURWRW\SH
1RWHF  )LOH WKDW GLVSOD\V D EULHI LQWURGXFWLRQ WR WKH +\SHUEROLF 3'(V DQG
LQIRUPV WKH XVHU WKDW WKH IROORZLQJ PHQX ZLOO XVH WKH RQHGLPHQVLRQDO
:DYH (TXDWLRQ DV D SURWRW\SH
3DVVZRUGF  )LOH WKDW SURPSWV WKH XVHU WR HQWHU KLVKHU SDVVZRUG
3RLQWVF  8VHG LQ (OOLSWLF 3'(V ZLWK 'LULFKOHW FRQGLWLRQV DVNV WKH XVHU WR HQWHU
KLVKHU ERXQGDU\ FRQGLWLRQV DV SRLQWV DFFRUGLQJ WR WKH PHVK VL]H WKDW KHVKH
DOUHDG\ UHTXHVWHG
3RLVVRQF  8VHG ZLWK (OOLSWLF 3'(V RI 3RLVVRQ W\SH ZLWK 'LULFKOHW FRQGLWLRQV DVNV
WKH XVHU WR HQWHU KLVKHU FRQVWDQW YDOXH RI WKH IXQFWLRQ LQ KLVKHU
3RLVVRQ HTXDWLRQ
3RLVVRQF  8VHG LQ (OOLSWLF (TXDWLRQV RI 3RLVVRQ W\SH  'LULFKOHW FRQGLWLRQV IRU
HQWHULQJ WKH YDOXHV RI WKH 3RLVVRQ (TXDWLRQ DW HDFK SRLQW SURPSWHG
3RLVVRQF  8VHG LQ (OOLSWLF (TXDWLRQV RI 3RLVVRQ W\SH  1HXPDQQ 0L[HG
FRQGLWLRQV IRU HQWHULQJ WKH YDOXHV RI WKH 3RLVVRQ (TXDWLRQ DW HDFK SRLQW
SURPSWHG
3RLVVRQIF  8VHG LQ (OOLSWLF 3'(V RI 3RLVVRQ W\SH ZLWK 'LULFKOHW FRQGLWLRQV DVNV
WKH XVHU WR HQWHU KLVKHU SRO\QRPLDO IXQFWLRQ RI ; < RI WKH IXQFWLRQ
I [\ LQ KLVKHU 3RLVVRQ HTXDWLRQ DQG GLVSOD\V WKH IXQFWLRQ
V YDOXHV DW
HDFK SRLQW LQ WKH VHOHFWHG JULG
6HPLFNOF  8VHG LQ (OOLSWLF 3'(V ZLWK 'LULFKOHW FRQGLWLRQV ZKHQ WKH ERXQGDU\ LV
H[SUHVVHG DV D VHPLFLUFOH VROYHV WKH SUREOHP ZKHWKHU WKH ERXQGDULHV DUH

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


APPENDIX B PAGE 118

HQWHUHG DW WKH IRXU VLGHV RU LI HQWHUHG SRLQWE\SRLQW XVLQJ *DXVV6HLGHO


LWHUDWLYH PHWKRG
6HPLFNOF  8VHG LQ (OOLSWLF 3'(V ZLWK 'LULFKOHW FRQGLWLRQV ZKHQ WKH ERXQGDU\ LV
H[SUHVVHG DV D VHPLFLUFOH VROYHV WKH SUREOHP ZKHWKHU WKH ERXQGDULHV DUH
HQWHUHG DW WKH IRXU VLGHV RU LI HQWHUHG SRLQWE\SRLQW XVLQJ -DFREL LWHUDWLYH
PHWKRG
6RUSF  8VHG LQ (OOLSWLF 3'(V ZLWK 'LULFKOHW FRQGLWLRQV VROYHV WKH SUREOHP
XVLQJ 625 ZLWK SRLQW DSSUR[LPDWLRQ RSWLPXP 625 IDFWRU
XWLOL]HG
6RUSF  8VHG LQ (OOLSWLF 3'(V ZLWK 'LULFKOHW FRQGLWLRQV VROYHV WKH SUREOHP
XVLQJ 625 ZLWK SRLQW DSSUR[LPDWLRQ WKH XVHU HQWHULQJ WKH 625
IDFWRU
6RUSF  8VHG LQ (OOLSWLF 3'(V ZLWK 'LULFKOHW FRQGLWLRQV VROYHV WKH SUREOHP
XVLQJ 625 ZLWK SRLQW DSSUR[LPDWLRQ RSWLPXP 625 IDFWRU
XWLOL]HG
6RUSF  8VHG LQ (OOLSWLF 3'(V ZLWK 'LULFKOHW FRQGLWLRQV VROYHV WKH SUREOHP
XVLQJ 625 ZLWK SRLQW DSSUR[LPDWLRQ WKH XVHU HQWHULQJ WKH 625
IDFWRU
7LPHF  8VHG LQ WKH ILOH WKDW WKH SURJUDP FUHDWHV
3'(),/(287
 VWRUHV WKH
FXUUHQW WLPH DQG GDWH RI XVLQJ WKH SURJUDP LQ WKDW ILOH
7\SHF  8VHG LQ (OOLSWLF 3'(V RI 0L[HG W\SH GLVSOD\V D PHQX IRU WKH XVHU WR
FKRRVH IURP ZKLFK FDVH RI (OOLSWLF 3'( GRHV KHVKH ZDQW WR VROYH"
7\SHF  'LVSOD\V D PDLQ PHQX VR WKDW WKH XVHU FDQ GHWHUPLQH ZKDW W\SH RI 3'(
GRHV KHVKH ZDQW WR VROYH PDLQ W\SH  LW DOVR LQIRUPV WKH XVHU WKDW D
ILOH ZLOO EH FUHDWHG LI QRW DOUHDG\ SUHVHQW IRU VWRULQJ KLVKHU UHVXOWV LQ
7\SHF  8VHG LQ (OOLSWLF 3'(V RI 1HXPDQQ W\SH GLVSOD\V D PHQX IRU WKH XVHU WR
FKRRVH IURP ZKLFK FDVH RI (OOLSWLF 3'( GRHV KHVKH ZDQW WR VROYH"

7KH IROORZLQJ SDJHV JLYH D SODLQ OLVWLQJ RI WKH VRXUFH FRGH RI DOO ILOHV XVHG LQ .XWNXW
V
1XPHULFDO 3'( 6ROYHU

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


APPENDIX B PAGE 119

7KH IROORZLQJ WDEOH VKRZV WKH SDJHV WKDW OLVW WKH VRXUFH FRGH IRU HDFK ILOH PHQWLRQHG
 $',&  
 $',&  
 $',&  
 $',*22'&  
 %1'5<&  
 &,5&/(&  
 &,5&/(&  
 &5$1.&  
 &5$1.&  
 '(&,'(&  
 '(&,'(&  
 '(&,'(+&  
 '(&,'(3&  
 '0161&  
 (//,37,&& 
 (17(5&  
 (17(5&  
 (17(5+&  
 (17(5+&  
 (;&  
 (;&  
 (;3/&7&  
 (;3/&7&  
 *$8663& 
 *$8663& 
 *5$3+& 
 *5$3+& 
 *5$3+& 
 *5'%1'&  
 *5'',0&  
 +($'(5+  
 +($'(5+  
 +,6+($'+  
 +3%/&'0&  
 +<3(5&  
 ,1,7,$/&  
 -$&2%,3&  
 -$&2%,3&  
 0$,1& 
 0$,1&  
 0$,1&  
 0$,1&  
 0$,1&  
 0(7+2'&  
 0(7+2'&  
 0,;('&  
 0,;('&  
 0,;('&  
 0<+($'+  
 127(&  
 127(&  
 127(&  
 3$66:25'&  
 32,176&  

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


APPENDIX B PAGE 120

 32,6621&  


 32,6621&  
 32,6621&  
 32,6621)&  
 6(0,&./&  
 6(0,&./&  
 6253&  
 6253&  
 6253&  
 6253&  
 7,0(&  
 7<3(&  
 7<3(&  
 7<3(&  

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


$SSHQGL[ % 3DJH 

ADI1.C
#include "header.h"
#include "header1.h"

extern void adi1(double *s1, double tl, FILE *fp_adi1)


{
double row, column ;
double i, j , n , number, p, savior ;
char ch='\0';
double cde[ROWS][COLUMNS];

row=(s1[1]+2);
column=(s1[0]+2);

for(i=0 ; i<row ; ++i)


for(j=0 ; j<column ; ++j)cde[i][j]=array1[i][j];

ex2();
printf("\nThe proper choice of the parameter P can accelerate the convergence\n\n");

printf("If your value of P is far from the optimum value then instead of having the same");
printf("number of iterations near to SOR they will be increased, since the individual\n");
printf("iteration steps in ADI are much more complicated than in SOR, the ADI method\n");
printf("would appear to be inferior, this is certainly true if we choose the same \n");
printf("parameter P in every iteration step, the trick is to choose a different P for \n");
printf("each step-this will not be done by this program,the P you enter is the one that\n");
printf("will be used - also notice that the iteration number to be indicated is after \n");
printf("going through all rows and all columns for that iterational step\n\n");

printf("Enter your value of the P parameter, P = ");


scanf("%lf", &p);

fprintf(fp_adi1,"\nThe proper choice of the parameter P can accelerate the convergence\n\n");

fprintf(fp_adi1,"If your value of P is far from the optimum value then instead of having the same");
fprintf(fp_adi1,"number of iterations near to SOR they will be increased, since the individual\n");
fprintf(fp_adi1,"iteration steps in ADI are much more complicated than in SOR, the ADI method\n");
fprintf(fp_adi1,"would appear to be inferior, this is certainly true if we choose the same \n");
fprintf(fp_adi1,"parameter P in every iteration step, the trick is to choose a different P for \n");
fprintf(fp_adi1,"each step-this will not be done by this program,the P you enter is the one that\n");
fprintf(fp_adi1,"will be used - also notice that the iteration number to be indicated is after \n");
fprintf(fp_adi1,"going through all rows and all columns for that iterational step\n\n");

number=0;
do{
for(i=1 ; i<row-1 ; ++i){
do{
n=0;
for(j=1 ; j<column-1 ; ++j){
savior=array1[i][j];
array1[i][j]=(1.0/(2+p))*(cde[i-1][j]-((2-p)*cde[i][j])+cde[i+1][j]+array1[i][j-
1]+array1[i][j+1]+(cdef[i][j]*s1[2]*s1[2]));
if(fabs(array1[i][j] - savior) < tl ) ++n ;}
}while(n<(column-2));}

for(i=1 ; i<row-1 ; ++i)


for(j=1 ; j<column-1 ; ++j) cde[i][j]=array1[i][j];

for(j=1 ; j<column-1 ; ++j){


do{
n=0;
for(i=1 ; i<row-1 ; ++i) {
savior=array1[i][j];
array1[i][j]=(1.0/(2+p))*(cde[i][j-1]-((2-p)*cde[i][j])+cde[i][j+1]+array1[i-
1][j]+array1[i+1][j]+(cdef[i][j]*s1[2]*s1[2]));
if(fabs(array1[i][j] - savior) < tl ) ++n ; }
}while(n<(row-2));}

n=0;
for(i=1 ; i<row-1 ; ++i){
for(j=1 ; j<column-1 ; ++j){
if((tl!=0) && (fabs(cde[i][j]-array1[i][j]) < tl) ) ++n ;
else if((tl==0) && (cde[i][j]==array1[i][j] ) ) ++n; } }

for(i=1 ; i<row-1 ; ++i)


for(j=1 ; j<column-1 ; ++j) cde[i][j]=array1[i][j];
++number;
printf("\n# %-5.0lf\n",number);
}while(n!=(s1[0]*s1[1]));

ex2();

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

printf("\nFor the value of P entered, p = %-8.6f\n", p);


printf("\nThe number of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
fprintf(fp_adi1,"\nFor the value of P entered, p = %-8.6f\n", p);
fprintf(fp_adi1,"\nThe number of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
/* to print out our array1 */
printf("The array will look like this\n");
printf("From the upper to the lower side\n");
printf("\nrows= %-5.0lf",row);
printf("\ncolumns= %-5.0lf \n\n",column);
for(i=row-1 ; i>=0 ; --i){
printf("row # %-5.0lf\n",i+1);
for(j=0 ; j<column ; ++j)
printf("%-20.5e",array1[i][j]);
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
printf("\n\n");}

ADI2.C
#include "header.h"
#include "header1.h"

extern void adi2(double *s1, double tl, FILE *fp_adi2)


{
double row, column , i, j;
double n , number, savior ;
char ch='\0';
double cde[ROWS][COLUMNS];

row=(s1[1]+2);
column=(s1[0]+2);

for(i=0 ; i<row ; ++i)


for(j=0 ; j<column ; ++j)cde[i][j]=array1[i][j];

number=0;
do{
for(i=1 ; i<row-1 ; ++i){
do{
n=0;
for(j=1 ; j<column-1 ; ++j){
savior=array1[i][j];
array1[i][j]=.25*(cde[i-1][j]+cde[i+1][j]+array1[i][j-1]+array1[i][j+1]+(cdef[i][j]*s1[2]*s1[2]));
if(fabs(array1[i][j] - savior) < tl ) ++n ;}
}while(n<(column-2));}

for(i=1 ; i<row-1 ; ++i)


for(j=1 ; j<column-1 ; ++j) cde[i][j]=array1[i][j];

for(j=1 ; j<column-1 ; ++j){


do{
n=0;
for(i=1 ; i<row-1 ; ++i) {
savior=array1[i][j];
array1[i][j]=.25*(cde[i][j-1]+cde[i][j+1]+array1[i-1][j]+array1[i+1][j]+(cdef[i][j]*s1[2]*s1[2]));
if(fabs(array1[i][j] - savior) < tl ) ++n ; }
}while(n<(row-2));}

n=0;
for(i=1 ; i<row-1 ; ++i){
for(j=1 ; j<column-1 ; ++j){
if((tl!=0) && (fabs(cde[i][j]-array1[i][j]) < tl) ) ++n ;
else if((tl==0) && (cde[i][j]==array1[i][j] ) ) ++n; } }

for(i=1 ; i<row-1 ; ++i)


for(j=1 ; j<column-1 ; ++j) cde[i][j]=array1[i][j];

++number;
printf("\n# %-5.0lf\n",number);
}while(n!=(s1[0]*s1[1]));

ex2();
printf("\nNumber of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
fprintf(fp_adi2,"\nNumber of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
/* to print out our array1 */
printf("The array will look like this\n");
printf("From the upper to the lower side\n");
printf("\nrows= %-5.0lf",row);

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

printf("\ncolumns= %-5.0lf \n\n",column);


for(i=row-1 ; i>=0 ; --i){
printf("row # %-5.0lf\n",i+1);
for(j=0 ; j<column ; ++j)
printf("%-20.5e",array1[i][j]);
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
printf("\n\n");}

ADI3.C
#include "header.h"
#include "header1.h"

extern void adi3(double *s1, double tl, FILE *fp_adi3)


{
double row, column ;
double i, j , n , number, p , saver, max_number, savior ;
char ch='\0';
double cde[ROWS][COLUMNS];

row=(s1[1]+2);
column=(s1[0]+2);

for(i=0 ; i<row ; ++i)


for(j=0 ; j<column ; ++j)cde[i][j]=array1[i][j];

max_number=s1[0];
if(s1[1] > max_number)max_number=s1[1];
++max_number;
saver=M_PI/max_number;
p=2.0*sin(saver);

number=0;
do{
for(i=1 ; i<row-1 ; ++i){
do{
n=0;
for(j=1 ; j<column-1 ; ++j){
savior=array1[i][j];
array1[i][j]=(1.0/(2+p))*(cde[i-1][j]-((2-p)*cde[i][j])+cde[i+1][j]+array1[i][j-
1]+array1[i][j+1]+(cdef[i][j]*s1[2]*s1[2]));
if(fabs(array1[i][j] - savior) < tl ) ++n ;}
}while(n<(column-2));}

for(i=1 ; i<row-1 ; ++i)


for(j=1 ; j<column-1 ; ++j) cde[i][j]=array1[i][j];

for(j=1 ; j<column-1 ; ++j){


do{
n=0;
for(i=1 ; i<row-1 ; ++i) {
savior=array1[i][j];
array1[i][j]=(1.0/(2+p))*(cde[i][j-1]-((2-p)*cde[i][j])+cde[i][j+1]+array1[i-
1][j]+array1[i+1][j]+(cdef[i][j]*s1[2]*s1[2]));
if(fabs(array1[i][j] - savior) < tl ) ++n ; }
}while(n<(row-2));}

n=0;
for(i=1 ; i<row-1 ; ++i){
for(j=1 ; j<column-1 ; ++j){
if((tl!=0) && (fabs(cde[i][j]-array1[i][j]) < tl) ) ++n ;
else if((tl==0) && (cde[i][j]==array1[i][j] ) ) ++n; } }

for(i=1 ; i<row-1 ; ++i)


for(j=1 ; j<column-1 ; ++j) cde[i][j]=array1[i][j];
++number;
printf("\n# %-5.0lf\n",number);
}while(n!=(s1[0]*s1[1]));

ex2();
printf("\nThe optimum value of P for maximum rate of convergence is, p = %-8.6f\n", p);
printf("\nThe number of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
fprintf(fp_adi3,"\nThe optimum value of P for maximum rate of convergence is, p = %-8.6f\n", p);
fprintf(fp_adi3,"\nThe number of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
/* to print out our array1 */
printf("The array will look like this\n");
printf("From the upper to the lower side\n");

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

printf("\nrows= %-5.0lf",row);
printf("\ncolumns= %-5.0lf \n\n",column);
for(i=row-1 ; i>=0 ; --i){
printf("row # %-5.0lf\n",i+1);
for(j=0 ; j<column ; ++j)
printf("%-20.5e",array1[i][j]);
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
printf("\n\n");}

ADIGOOD2.C
#include "header.h"
#include "hishead.h"

extern void adip(double *s1, FILE *fp_adip)


{
double box=0.0, box1=0.0 ;
double row, column, bumb ;
double *output, savior, value, display, integer, fraction, integer1 ;
int i, j, k, n, s ;
int count ;
char ch='\0' ;

row=(s1[9]+2);
column=(s1[8]+2);
ex2();
printf("\nHow often do you want the results displayed\n");
printf("The total # of displays that you previously entered must be an integer\n");
printf("multiple of this value, or the program will see to it that it is\n\n");
scanf("%lf", &display);
value=s1[7]/display;
fraction=modf(value, &integer1);
s1[7]=integer1*display;

output=malloc(8*(s1[8]+2)*(s1[9]+2));
if(!output){
ex2();
printf("\nNot enough memory to allocate buffer\n");
/* terminate program if out of memory */
goto label33; }
count=(s1[8]+2);

box1=0.0;
printf("\nEnter initial values, u(x,y,0) as prompted\n");
for(i=0; i<=s1[9]+1 ;++i){
ex2();
box=0.0;
for(j=0; j<=s1[8]+1 ;++j){
printf("\nEnter initial value at X= %-20.5lf Y= %-20.5lf\n", box, box1);
scanf("%lf", &value);
array1[i][j]=value;
box=box+s1[1];}
box1=box1+s1[1];}

for(i=1 ; i<row-1 ; ++i)


for(j=1 ; j<column-1 ; ++j)*(output+(i*count)+j)=array1[i][j];

ex2();
box=s1[1];
box1=s1[1];
printf("\nEnter changes that occur at all boundaries as constants\n\n");
printf("Lower boundary\n");
i=0;
for(j=0; j<=s1[8]+1 ;++j){
printf("\nEnter boundary value at X= %-20.5lf Y= %-20.5lf\n", box*j, box1*i);
scanf("%lf", &value);
*(output+(i*count)+j)=value;}

ex2();
box=s1[1];
box1=s1[1];
i=s1[9]+1;
printf("\nUpper boundary\n");
for(j=0; j<=s1[8]+1 ;++j){
printf("\nEnter boundary value at X= %-20.5lf Y= %-20.5lf\n", box*j, box1*i);
scanf("%lf", &value);
*(output+(i*count)+j)=value;}

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

ex2();
box=s1[1];
box1=s1[1];
j=0;
printf("\nLeft boundary\n");
for(i=1; i<=s1[9] ;++i){
printf("\nEnter boundary value at X= %-20.5lf Y= %-20.5lf\n", box*j, box1*i);
scanf("%lf", &value);
*(output+(i*count)+j)=value;}

ex2();
box=s1[1];
box1=s1[1];
j=s1[8]+1;
printf("\nRight boundary\n");
for(i=1; i<=s1[9] ;++i){
printf("\nEnter boundary value at X= %-20.5lf Y= %-20.5lf\n", box*j, box1*i);
scanf("%lf", &value);
*(output+(i*count)+j)=value;}

ex2();
printf("\nThe # of internal mesh points used is %-20.0lf\n",s1[8]*s1[9]);
fprintf(fp_adip,"\nThe # of internal mesh points used is %-20.0lf\n",s1[8]*s1[9]);
printf("\n\nPress RETURN to continue\n");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

ex2();
box=0.0;
printf("The output at t= %-20.5lf proceeding from highest to lowest row\n",box);
for(i=s1[9]+1; i>=0 ;--i){
printf("\nFor row %-20d\n\n", i+1);
for(j=0; j<=s1[8]+1 ;++j){
printf("%-20.5lf",array1[i][j] ); }

box=0.0;
fprintf(fp_adip,"The output at t= %-20.5lf proceeding from highest to lowest row\n",box);
for(i=s1[9]+1; i>=0 ;--i){
fprintf(fp_adip,"\nFor row %-20d\n\n", i+1);
for(j=0; j<=s1[8]+1 ;++j){
fprintf(fp_adip,"%-20.5lf",array1[i][j] ); }
fprintf(fp_adip,"\n");}

printf("\n\nPress RETURN to continue\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }}

for(i=0 ; i<row ; ++i)


for(j=0 ; j<column ; ++j)array1[i][j]=*(output+(i*count)+j);

/* Now to use the ADI method to solve our problem */


for(k=1; k<=(2*s1[7]) ;++k){

if((k==1) || ((k%2)!=0)){
for(j=1 ; j<column-1 ; ++j){
do{
n=0;
for(i=1 ; i<row-1 ; ++i) {
savior=*(output+(i*count)+j);
bumb=( (2.0*(1.0-s1[2]))*array1[i][j] )+ s1[2]*(array1[i][j+1]+array1[i][j-1] +
*(output+((i+1)*count)+j) + *(output+((i-1)*count)+j) );
*(output+(i*count)+j)=bumb/(2.0*(1.0+s1[2]));
if(fabs(*(output+(i*count)+j) - savior) < .00001 ) ++n ; }
}while(n!=(row-2));
for(s=1 ; s<row-1 ; ++s) array1[s][j]= *(output+(s*count)+j);
for(s=1;s<=5;++s)printf(" ");
}}

else{
for(i=1 ; i<row-1 ; ++i){
do{
n=0;
for(j=1 ; j<column-1 ; ++j){
savior=*(output+(i*count)+j);
bumb=( (2.0*(1.0-s1[2]))*array1[i][j] )+ s1[2]*(array1[i+1][j]+array1[i-1][j] +
*(output+(i*count)+j+1) + *(output+(i*count)+j-1) );
*(output+(i*count)+j)= bumb/( 2.0*(1.0+s1[2]) );
if(fabs(*(output+(i*count)+j) - savior) < .00001 ) ++n ;}
}while(n!=(column-2));
for(s=1;s<=5;++s)printf(" ");

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

for(s=1 ; s<column-1 ; ++s) array1[i][s]= *(output+(i*count)+s); }

savior=(.5*k)/display;
fraction=modf(savior, &integer);
if(fraction==0.0){
ex2();
printf("The output at t= %-20.5lf proceeding from highest to lowest row\n",s1[4]*k/2.0);
fprintf(fp_adip,"\n\n\nThe output at t= %-20.5lf proceeding from highest to lowest row\n",s1[4]*k/2.0);
for(i=s1[9]+1; i>=0 ;--i){
printf("\n\nFor row %-20d\n\n", i+1);
fprintf(fp_adip,"\n\nFor row %-20d\n\n", i+1);
for(j=0; j<=s1[8]+1 ;++j){
printf("%-20.5e",*(output+(i*count)+j) );
fprintf(fp_adip,"%-20.5e",*(output+(i*count)+j) );}

printf("\n\nPress RETURN to continue\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; } } } }}

label33:
free(output);
}

BNDRY2.C
#include "header.h"
#include "hishead.h"

/* polynomial: x**3 - 2x**2 + 5x - 1 */


extern double bndry2(double *s1)
{
double aray1[10] = {0}, aray2[10] = {0};
double aray3[10] = {0}, aray4[10] = {0};
double row, column, i, j, average ;
char ch='\0';
double degree1, degree2, degree3, degree4, k, result=0, tl=.01;
char sure='p';

label1: printf("\nEnter left boundary as a function of Y\n");


printf("Enter degree of function\n");
scanf("%lf",&degree1);
if(degree1>9){
printf("\nDegree should be <= 9\n");
goto label1;}
printf("Enter coefficients of Y, proceeding from const to highest degree");
for(k=0 ; k<=degree1 ; ++k){
printf("\nEnter coeff # %-5.0lf\n",k+1);
scanf("%lf",&aray1[k]);}

printf("\nEnter right boundary as a function of Y\n");


printf("Enter degree of function\n");
scanf("%lf",&degree2);
if(degree2>9){
printf("\nDegree should be <= 9\n");
goto label1;}
printf("Enter coefficients of Y, proceeding from const to highest degree");
for(k=0 ; k<=degree2 ; ++k){
printf("\nEnter coeff # %-5.0lf\n",k+1);
scanf("%lf",&aray2[k]);}

printf("\nEnter upper boundary as a function of X\n");


printf("Enter degree of function\n");
scanf("%lf",&degree3);
if(degree3>9){
printf("\nDegree should be <= 9\n");
goto label1;}
printf("Enter coefficients of X, proceeding from const to highest degree");
for(k=0 ; k<=degree3 ; ++k){
printf("\nEnter coeff # %-5.0lf\n",k+1);
scanf("%lf",&aray3[k]);}

printf("\nEnter lower boundary as a function of X\n");


printf("Enter degree of function\n");
scanf("%lf",&degree4);
if(degree4>9){
printf("\nDegree should be <= 9\n");
goto label1;}
printf("Enter coefficients of X, proceeding from const to highest degree");
for(k=0 ; k<=degree4 ; ++k){
printf("\nEnter coeff # %-5.0lf\n",k+1);
scanf("%lf",&aray4[k]);}

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

ex2();
do{
printf("\n\nEnter tolerance of answer \n");
scanf("%lf",&tl);
if(tl==0){
printf("\nTolerance Zero might take a while\n");
printf("\nAre you sure y/n\n");
sure=getche();}
if(tl!=0)break;
}while(sure=='n');

tl=fabs(tl);

row=(s1[1]+2);
column=(s1[0]+2);

/* Evaluating the values of the boundaries at each point */


for(i=1 ; i<(row-1) ; ++i)
array1[i][0] =poly(s1[2]*i, degree1, aray1 );

for(i=1 ; i<(row-1) ; ++i)


array1[i][column-1]=poly(s1[2]*i, degree2, aray2 );

for(j=1 ; j<(column-1) ; ++j)


array1[row-1][j] = poly(s1[2]*j, degree3, aray3 );

for(j=1 ; j<(column-1) ; ++j)


array1[0][j] = poly(s1[2]*j, degree4, aray4);

array1[0][0]=(array1[1][0]+array1[0][1])/2 ;
array1[row-1][0]=(array1[row-2][0]+array1[row-1][1])/2 ;
array1[0][column-1]=(array1[0][column-2]+array1[1][column-1])/2 ;
array1[row-1][column-1]=(array1[row-1][column-2]+array1[row-2][column-1])/2 ;

/* In order to compute the average of the boundary points */


for(i=0 ; i<=(row-1) ; ++i)result=result+array1[i][0];
for(i=0 ; i<=(row-1) ; ++i)result=result+array1[i][column-1];
for(j=1 ; j<(column-1) ; ++j)result=result+array1[row-1][j];
for(j=1 ; j<(column-1) ; ++j)result=result+array1[0][j];

average=2*((row-2)+(column-2))+4;
average=result/average;

for(i=1 ; i<(row-1) ; ++i)


{for(j=1 ; j<(column-1) ; ++j) array1[i][j] = average ;}

ex2();
/* to print out our initialized array1 */
printf("\nThe initialization of the array will look like this\n");
printf("From the upper to the lower side\n");
printf("\nrows=%-5.0f\ncolumns=%-5.0f\n\n",row,column);
for(i=row-1 ; i>=0 ; --i){
printf("row # %-5.0f\n",i+1);
for(j=0 ; j<column ; ++j)
printf("%-20.5e",array1[i][j]);
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
printf("\n\n");}

return tl;
}

CIRCLE3.C
#include "header.h"
#include "hishead.h"
/* entring size of grid & mesh size */

extern void circle3(int choice1, FILE *fp_circle3)


{
double radius=1.0, angle, dangle=20.0, dradius=1.0, max=1.0, s1[2]={0}, s2[5]={0} ;
double integer1, integer2, fraction1, fraction2, number1, number2 ;
double arround1=0.0, bottom1=0.0,arround2=0.0, bottom2=0.0, tl=.1 ;
char sure='p';
double size, radians, constant, box ;
double i, j , n , number, remainder, integerr ;
char ch='\0';
double savior1, savior2, savior3 ;

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

do{
printf("\n\nEnter dimensions of circle -irregular boundaries-\n\n");
do{
printf("\nEnter radius of circle\n");
scanf("%lf",&radius);
if(radius==0.0)printf("\nYou must be joking, try again\n");
}while(radius==0.0);

do{
printf("\nEnter the increment of the angle in degrees, 360 must\n");
printf("be an integer multiple of this increment\n");
scanf("%lf",&dangle);
if(dangle==0.0)printf("\nYou must be joking, try again\n");
}while(dangle==0.0);

label5:
printf("\nEnter the increment for r, that the program will use\n\n");
printf("PS: The radius that you previously entered must be an integer\n");
printf(" multiple of this increment\n");
printf(" If you did not enter these increments as requested you will \n");
printf(" be prompted to re-enter the dimensions of the circle \n\n");
scanf("%lf",&dradius);
if(dradius==0.0){
printf("\nYou must be joking, try again\n");
goto label5;}

fprintf(fp_circle3,"\nDimensions of circle -irregular boundaries- as entered by user\n\n");


fprintf(fp_circle3,"Radius of semi-circle is %-20.5lf\n", radius);
fprintf(fp_circle3,"The increment of the angle in degrees is %-20.5lf\n", dangle);
fprintf(fp_circle3,"The increment for r, that the program will use is %-20.5lf\n\n", dradius);

number1=radius/dradius;
fraction1=modf(number1,&integer1);
number2=(double)360.0/dangle;
fraction2=modf(number2,&integer2);
max=(integer1+1)*(integer2);
}while(!(fraction1==0.0 && fraction2==0.0 && max<=2500));

/*to save # of mesh points & h */


s1[0]=integer1-1;
s1[1]=integer2;

if(choice1==7 || choice1==8){
ex2();
printf("\nEnter circle boundaries one at a time:\n");

angle=0.0;
printf("\nArround the circle, enter each point according to the angle indicated\n");
for(j=0; j<=s1[1]-1 ;++j){
printf("\nFor angle= %-6.2lf\n",angle);
scanf("%lf",&arround1);
array1[s1[0]+1][j]=arround1;
angle=angle+dangle;}

s2[4]=0.0;
for(j=0; j<=s1[1]-1 ;++j)s2[4]=s2[4]+array1[s1[0]+1][j];
s2[4]=s2[4]/s1[1];
}

else{
ex2();
/* entring grid boundaries */
printf("\nEnter circle boundaries one at a time, from four sides:\n\nArround the circle from the upper right
\n");
scanf("%lf",&arround1);
s2[0]=arround1 ;

printf("\nArround the circle from the upper left \n");


scanf("%lf",&arround2);
s2[1]=arround2 ;

printf("\nArround the circle from the bottom right\n");


scanf("%lf",&bottom1);
s2[2]=bottom1;

printf("\nArround the circle from the bottom left\n");


scanf("%lf",&bottom2);
s2[3]=bottom2;

/* giving the boundary points their boundary values */


remainder=.25*s1[1];
for(j=1 ; j<remainder ;++j )array1[s1[0]+1][j]=s2[0];

modf(remainder,&integerr);

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

for(j=integerr+1 ; j<.5*s1[1] ;++j)array1[s1[0]+1][j]=s2[1];

remainder=.5*s1[1];
modf(remainder,&integerr);
for(j=integerr+1 ; j<.75*s1[1] ;++j)array1[s1[0]+1][j]=s2[3];

remainder=.75*s1[1];
modf(remainder,&integerr);
for(j=integerr+1 ; j<s1[1] ;++j)array1[s1[0]+1][j]=s2[2];

array1[s1[0]+1][0]=.5*(s2[2]+s2[0]);
array1[s1[0]+1][s1[1]]=.5*(s2[2]+s2[0]);

remainder=.5*s1[1];
modf(remainder,&integerr);
if(remainder==integerr)array1[s1[0]+1][integerr]=.5*(s2[3]+s2[1]);

remainder=.25*s1[1];
modf(remainder,&integerr);
if(remainder==integerr)array1[s1[0]+1][integerr]=.5*(s2[0]+s2[1]);

remainder=.75*s1[1];
modf(remainder,&integerr);
if(remainder==integerr)array1[s1[0]+1][integerr]=.5*(s2[3]+s2[2]);

/*calculating initial conditions for intrnal mesh points*/

/* calculating the average value of boundaries */


s2[4]= radius * M_PI_2 * (s2[0] + s2[1]);
s2[4]= s2[4] + (radius*M_PI_2 * (s2[2] + s2[3]));
s2[4]= s2[4] / (2.0 * radius * M_PI);
}

/* end of entring grid boundaries */

ex2();
do{
printf("\n\nEnter tolerance of answer \n");
scanf("%lf",&tl);
if(tl==0){
printf("\nTolerance Zero might take a while\n");
printf("\nAre you sure y/n\n");
sure=tolower(getche());}
else break;

}while(sure!='y');

tl=fabs(tl);

/* giving all internal points in the array the average of the boundary values at first */
for(i=0 ; i<=s1[0] ; ++i)
for(j=0 ; j<=s1[1] ; ++j) array1[i][j] = s2[4] ;

size=s1[0]*s1[1];
size=size+s1[1]+1;

ex2();
printf("\nThe # of internal mesh points is: %-5.0f\n",s1[0]*s1[1]+1);
printf("\nThe # of mesh points that we'll be operating on\n");
printf("including the ones on the boundaries is: %-5.0f\n\n",size);

fprintf(fp_circle3,"\nThe # of internal mesh points is: %-5.0f\n",s1[0]*s1[1]+1);


fprintf(fp_circle3,"\nThe # of mesh points that we'll be operating on\n");
fprintf(fp_circle3,"including the ones on the boundaries is: %-5.0f\n\n",size);

printf("\nPress RETURN to continue");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
printf("\n\n");

radians=dangle*M_PI/180.0;

number=0;
do{
++number;
printf("\n# %-5.0lf\n",number);
n=0;
for(i=1;i<=s1[0];++i){
savior1=array1[i][0];
constant=(.5*i*i*radians*radians)/((i*i*radians*radians)+1);
array1[i][0]=constant*(((1-(.5/i))*array1[i-
1][0])+((1+(.5/i))*array1[i+1][0])+((1.0/(i*i*radians*radians))*array1[i][s1[1]-
1])+((1.0/(i*i*radians*radians))*array1[i][1]));

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

if((tl==0) && (array1[i][0] == savior1) ) ++n;


else if((tl!=0) && (fabs(array1[i][0] - savior1) < tl) ) ++n ;
array1[i][s1[1]]=array1[i][0];}

for(i=1 ; i<=s1[0] ; ++i){


for(j=1 ; j<s1[1] ; ++j){
savior2=array1[i][j];
constant=(.5*i*i*radians*radians)/((i*i*radians*radians)+1);
array1[i][j]=constant*(((1-(.5/i))*array1[i-
1][j])+((1+(.5/i))*array1[i+1][j])+((1.0/(i*i*radians*radians))*array1[i][j-
1])+((1.0/(i*i*radians*radians))*array1[i][j+1]));

if((tl==0) && (array1[i][j] == savior2) ) ++n;


else if((tl!=0) && (fabs(array1[i][j] - savior2) < tl) ) ++n ; }
}
savior3=array1[0][0];
box=0.0;
for(j=0;j<s1[1];++j) box=box+array1[1][j];
array1[0][0]=box/s1[1];
if((tl==0) && (array1[0][0] == savior3) ) ++n;
else if((tl!=0) && (fabs(array1[0][0] - savior3) < tl) ) ++n ;
for(j=1;j<=s1[1];++j)array1[0][j]=array1[0][0];

}while(n!=((s1[0]*s1[1])+1));

ex2();
angle=0.0;
printf("\nNumber of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
/* to print out our array1 */
printf("The array will look like this\n");
printf("From the R = radius inwards for each angle at a time\n");
printf("\n%-5.0lf cases were taken for R ",s1[0]+2);
printf("\n%-5.0lf cases were taken for the angle from 0 to 360\n\n",s1[1]+1);

for(j=0 ; j<=s1[1] ; ++j){


printf("For angle= %-6.2lf\n",angle);
for(i=s1[0]+1 ; i>=0 ; --i)
printf("%-20.5e",array1[i][j]);
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
printf("\n\n");
angle=angle+dangle;}

angle=0.0;
fprintf(fp_circle3,"\nNumber of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
/* to print out our array1 */
fprintf(fp_circle3,"The array will look like this\n");
fprintf(fp_circle3,"From the R = radius inwards for each angle at a time\n");
fprintf(fp_circle3,"\n%-5.0lf cases were taken for R ",s1[0]+2);
fprintf(fp_circle3,"\n%-5.0lf cases were taken for the angle from 0 to 360\n\n",s1[1]+1);

for(j=0 ; j<=s1[1] ; ++j){


fprintf(fp_circle3,"For angle= %-6.2lf\n",angle);
for(i=s1[0]+1 ; i>=0 ; --i)
fprintf(fp_circle3,"%-20.5e",array1[i][j]);
fprintf(fp_circle3,"\n\n");
angle=angle+dangle;}

CIRCLE4.C
#include "header.h"
#include "hishead.h"
/* entring size of grid & mesh size */

extern void circle4(int choice1, FILE *fp_circle4)


{
double radius=1.0, angle, dangle=20.0, dradius=1.0, max=1.0, s1[2]={0}, s2[5]={0} ;
double integer1, integer2, fraction1, fraction2, number1, number2 ;
double arround1=0.0, bottom1=0.0,arround2=0.0, bottom2=0.0, tl=.1 ;
char sure='p';
double size, radians, constant, box ;
double i, j , n , number, remainder, integerr ;
char ch='\0';
double cde[ROWS][COLUMNS] ;

do{
printf("\n\nEnter dimensions of circle -irregular boundaries-\n\n");

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

do{
printf("\nEnter radius of circle\n");
scanf("%lf",&radius);
if(radius==0.0)printf("\nYou must be joking, try again\n");
}while(radius==0.0);

do{
printf("\nEnter the increment of the angle in degrees, 360 must\n");
printf("be an integer multiple of this increment\n");
scanf("%lf",&dangle);
if(dangle==0.0)printf("\nYou must be joking, try again\n");
}while(dangle==0.0);

label5:
printf("\nEnter the increment for r, that the program will use\n\n");
printf("PS: The radius that you previously entered must be an integer\n");
printf(" multiple of this increment\n");
printf(" If you did not enter these increments as requested you will \n");
printf(" be prompted to re-enter the dimensions of the circle \n\n");
scanf("%lf",&dradius);
if(dradius==0.0){
printf("\nYou must be joking, try again\n");
goto label5;}

fprintf(fp_circle4,"\nDimensions of circle -irregular boundaries- as entered by user\n\n");


fprintf(fp_circle4,"Radius of semi-circle is %-20.5lf\n", radius);
fprintf(fp_circle4,"The increment of the angle in degrees is %-20.5lf\n", dangle);
fprintf(fp_circle4,"The increment for r, that the program will use is %-20.5lf\n\n", dradius);

number1=radius/dradius;
fraction1=modf(number1,&integer1);
number2=(double)360.0/dangle;
fraction2=modf(number2,&integer2);
max=(integer1+1)*(integer2);
}while(!(fraction1==0.0 && fraction2==0.0 && max<=2500));

/*to save # of mesh points & h */


s1[0]=integer1-1;
s1[1]=integer2;

if(choice1==7 || choice1==8){
ex2();
printf("\nEnter circle boundaries one at a time:\n");

angle=0.0;
printf("\nArround the circle, enter each point according to the angle indicated\n");
for(j=0; j<=s1[1]-1 ;++j){
printf("\nFor angle= %-6.2lf\n",angle);
scanf("%lf",&arround1);
array1[s1[0]+1][j]=arround1;
angle=angle+dangle;}

s2[4]=0.0;
for(j=0; j<=s1[1]-1 ;++j)s2[4]=s2[4]+array1[s1[0]+1][j];
s2[4]=s2[4]/s1[1];
}

else{
ex2();
/* entring grid boundaries */
printf("\nEnter circle boundaries one at a time:\n\nArround the circle from the upper right \n");
scanf("%lf",&arround1);
s2[0]=arround1 ;

printf("\nArround the circle from the upper left \n");


scanf("%lf",&arround2);
s2[1]=arround2 ;

printf("\nArround the circle from the bottom right\n");


scanf("%lf",&bottom1);
s2[2]=bottom1;

printf("\nArround the circle from the bottom left\n");


scanf("%lf",&bottom2);
s2[3]=bottom2;

/* end of entring grid boundaries */


/*calculating initial conditions for intrnal mesh points*/

/* calculating the average value of boundaries */


s2[4]= radius * M_PI_2 * (s2[0] + s2[1]);
s2[4]= s2[4] + (radius*M_PI_2 * (s2[2] + s2[3]));
s2[4]= s2[4] / (2.0 * radius * M_PI);

/* giving the boundary points their boundary values */

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

remainder=.25*s1[1];
for(j=1 ; j<remainder ;++j )array1[s1[0]+1][j]=s2[0];

modf(remainder,&integerr);
for(j=integerr+1 ; j<.5*s1[1] ;++j)array1[s1[0]+1][j]=s2[1];

remainder=.5*s1[1];
modf(remainder,&integerr);
for(j=integerr+1 ; j<.75*s1[1] ;++j)array1[s1[0]+1][j]=s2[3];

remainder=.75*s1[1];
modf(remainder,&integerr);
for(j=integerr+1 ; j<s1[1] ;++j)array1[s1[0]+1][j]=s2[2];

array1[s1[0]+1][0]=.5*(s2[2]+s2[0]);
array1[s1[0]+1][s1[1]]=.5*(s2[2]+s2[0]);

remainder=.5*s1[1];
modf(remainder,&integerr);
if(remainder==integerr)array1[s1[0]+1][integerr]=.5*(s2[3]+s2[1]);

remainder=.25*s1[1];
modf(remainder,&integerr);
if(remainder==integerr)array1[s1[0]+1][integerr]=.5*(s2[0]+s2[1]);

remainder=.75*s1[1];
modf(remainder,&integerr);
if(remainder==integerr)array1[s1[0]+1][integerr]=.5*(s2[3]+s2[2]);
}

ex2();
do{
printf("\n\nEnter tolerance of answer \n");
scanf("%lf",&tl);
if(tl==0){
printf("\nTolerance Zero might take a while\n");
printf("\nAre you sure y/n\n");
sure=tolower(getche()); }
else break;

}while(sure!='y');

tl=fabs(tl);

/* giving all internal points in the array the average of the boundary values at first */
for(i=0 ; i<=s1[0] ; ++i)
for(j=0 ; j<=s1[1] ; ++j) array1[i][j] = s2[4] ;

size=s1[0]*s1[1];
size=size+s1[1]+1;

ex2();
printf("\nThe # of internal mesh points is: %-5.0f\n",s1[0]*s1[1]+1);
printf("\nThe # of mesh points that we'll be operating on\n");
printf("including the ones on the boundaries is: %-5.0f\n\n",size);

fprintf(fp_circle4,"\nThe # of internal mesh points is: %-5.0f\n",s1[0]*s1[1]+1);


fprintf(fp_circle4,"\nThe # of mesh points that we'll be operating on\n");
fprintf(fp_circle4,"including the ones on the boundaries is: %-5.0f\n\n",size);

printf("\nPress RETURN to continue");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
printf("\n\n");

for(i=0 ; i<=s1[0]+1 ; ++i)


for(j=0 ; j<=s1[1] ; ++j) cde[i][j]=array1[i][j];

radians=dangle*M_PI/180.0;

number=0;
do{
++number;
printf("\n# %-5.0lf\n",number);
n=0;
for(i=1;i<=s1[0];++i){
cde[i][0]=array1[i][0];
cde[i][s1[1]]=array1[i][0];
constant=(.5*i*i*radians*radians)/((i*i*radians*radians)+1);
array1[i][0]=constant*(((1-(.5/i))*cde[i-
1][0])+((1+(.5/i))*cde[i+1][0])+((1.0/(i*i*radians*radians))*cde[i][s1[1]-
1])+((1.0/(i*i*radians*radians))*cde[i][1]));
if((tl==0) && (array1[i][0] == cde[i][0]) ) ++n;

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

else if((tl!=0) && (fabs(array1[i][0] - cde[i][0]) < tl) ) ++n ;


array1[i][s1[1]]=array1[i][0];}

for(i=1 ; i<=s1[0] ; ++i){


for(j=1 ; j<s1[1] ; ++j){
cde[i][j]=array1[i][j];
constant=(.5*i*i*radians*radians)/((i*i*radians*radians)+1);
array1[i][j]=constant*(((1-(.5/i))*cde[i-
1][j])+((1+(.5/i))*cde[i+1][j])+((1.0/(i*i*radians*radians))*cde[i][j-
1])+((1.0/(i*i*radians*radians))*cde[i][j+1]));

if((tl==0) && (array1[i][j] == cde[i][j]) ) ++n;


else if((tl!=0) && (fabs(array1[i][j] - cde[i][j]) < tl) ) ++n ; }
}
cde[0][0]=array1[0][0];
box=0.0;
for(j=0;j<s1[1];++j) box=box+array1[1][j];
array1[0][0]=box/s1[1];
if((tl==0) && (array1[0][0] == cde[0][0]) ) ++n;
else if((tl!=0) && (fabs(array1[0][0] - cde[0][0]) < tl) ) ++n ;
for(j=1;j<=s1[1];++j)array1[0][j]=array1[0][0];
for(j=1;j<=s1[1];++j)cde[0][j]=array1[0][0];
}while(n!=((s1[0]*s1[1])+1));

ex2();
angle=0.0;
printf("\nNumber of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
/* to print out our array1 */
printf("The array will look like this\n");
printf("From the R = radius inwards for each angle at a time\n");
printf("\n%-5.0lf cases were taken for R ",s1[0]+2);
printf("\n%-5.0lf cases were taken for the angle from 0 to 360\n\n",s1[1]+1);

for(j=0 ; j<=s1[1] ; ++j){


printf("For angle= %-6.2lf\n",angle);
for(i=s1[0]+1 ; i>=0 ; --i)
printf("%-20.5e",array1[i][j]);
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
printf("\n\n");
angle=angle+dangle;}

angle=0.0;
fprintf(fp_circle4,"\nNumber of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
/* to print out our array1 */
fprintf(fp_circle4,"The array will look like this\n");
fprintf(fp_circle4,"From the R = radius inwards for each angle at a time\n");
fprintf(fp_circle4,"\n%-5.0lf cases were taken for R ",s1[0]+2);
fprintf(fp_circle4,"\n%-5.0lf cases were taken for the angle from 0 to 360\n\n",s1[1]+1);

for(j=0 ; j<=s1[1] ; ++j){


fprintf(fp_circle4,"For angle= %-6.2lf\n",angle);
for(i=s1[0]+1 ; i>=0 ; --i)
fprintf(fp_circle4,"%-20.5e",array1[i][j]);
fprintf(fp_circle4,"\n\n");
angle=angle+dangle;}

CRANK2.C
#include "header.h"

extern void crank2(double *s1, int choice, FILE *fp_crank2)


{
double box=0.0, value, display, integer, fraction ;
double dummy, dummy1, integer1, fraction1 ;
double *output, savior ;
int i, j, k, l , m, n ;
int that, count ;
double aray[10] = {0}, degree;
char ch='\0' ;

output=malloc(8*2*(s1[8]+2));
if(!output){
ex2();
printf("\nNot enough memory to allocate buffer\n");
/* terminate program if out of memory */
goto label33; }
count=(s1[8]+2);

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

if(choice==4){
label1:
ex2();
box=s1[1];
printf("\nEnter function of initial values, u(x,0) as prompted\n");
printf("Enter degree of function\n");
scanf("%lf",&degree);
if(degree>9){
printf("\nDegree should be <= 9\n");
goto label1;}
printf("\nEnter coefficients of X, proceeding from const to highest degree");

for(k=0 ; k<=degree ; ++k){


printf("\nEnter coeff # %-5d\n",k+1);
scanf("%lf",&aray[k]);}

for(j=1 ; j<=s1[8] ; ++j) *(output+j)=poly(s1[1]*j, degree, aray); }

else{
ex2();
box=s1[1];
printf("\nEnter initial values, u(x,0) as prompted\n");
for(i=1; i<=s1[8] ;++i){
printf("\nEnter initial value at X= %-20.5lf\n", box);
scanf("%lf", &value);
*(output+i)=value;
box=box+s1[1];}}

that=s1[8];
*(output)=s1[5];
*(output+that+1)=s1[6];

do{
ex2();
printf("\nAfter how many time increments do you want the results to be continuously\n");
printf("displayed ( a multiple of the time increment ), the total number of time \n");
printf("increments that you previously entered must be an integer multiple of this \n");
printf("value, Ex: 1, 2(if your previous # is a multiple of 10) 5, 10, 55, 100, ....\n\n");
scanf("%lf", &value);
if(value==0.0 || value>s1[7])continue;
dummy=s1[7]/value;
fraction=modf(dummy, &integer);
dummy1=value/1.0;
fraction1=modf(dummy1, &integer1);
}while(fraction != 0.0 || fraction1!=0 || value==0.0 || value>s1[7]);

ex2();
printf("\nThe # of internal mesh points used is %-20.0lf\n",s1[8]);
fprintf(fp_crank2,"\nThe # of internal mesh points used is %-20.0lf\n",s1[8]);
printf("\n\n\nPress RETURN to continue\n");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

for(m=0; m<=that+1 ;++m)*(output+count+m)=*(output+m);

ex2();
box=0.0;
printf("\nThe output at t= %-20.5lf\n\n",box);
for(l=0; l<=s1[8]+1 ;++l)printf("%-20.5e",*(output+l));

box=0.0;
fprintf(fp_crank2,"\nThe output at t= %-20.5lf\n\n",box);
for(l=0; l<=s1[8]+1 ;++l)fprintf(fp_crank2,"%-20.5e",*(output+l));

printf("\n\nPress RETURN to continue\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

box=value*s1[4];
for(k=1; k<=integer ;++k){
for(i=1; i<=value ;++i){

do{
n=0;
for(j=1; j<=s1[8] ;++j){
savior=*(output+count+j) ;
*(output+count+j)=s1[2]*(*(output+j-1)+*(output+j+1))+((2.0-(2.0*s1[2])) *
*(output+j))+(s1[2]*(*(output+count+j+1)+*(output+count+j-1)));
*(output+count+j)=*(output+count+j)/(2.0+(2.0*s1[2]));
if(fabs(*(output+count+j) - savior) < .000001) ++n ; }

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

}while(n != s1[8]);

for(m=1; m<=that ;++m)*(output+m)=*(output+count+m);

if(i==value){
printf("\nThe output at t= %-20.5lf\n\n",box);
for(l=0; l<=s1[8]+1 ;++l)printf("%-20.5e",*(output+l));
fprintf(fp_crank2,"\n\nThe output at t= %-20.5lf\n\n",box);
for(l=0; l<=s1[8]+1 ;++l)fprintf(fp_crank2,"%-20.5e",*(output+l));

printf("\n\nPress RETURN to continue\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

box=(k+1)*value*s1[4]; }
}}

label33:
free(output);
}

CRANK3.C
#include "header.h"

extern void crank3(double *s1, int choice, double *dff1, FILE *fp_crank3)
{
double box=0.0, value, display, integer, fraction ;
double dummy, dummy1, integer1, fraction1 ;
double *output, savior ;
int i, j, k, l , m, n ;
int that, count ;
double aray[10] = {0}, degree;
char ch='\0' ;

output=malloc(8*2*(s1[8]+2));
if(!output){
ex2();
printf("\nNot enough memory to allocate buffer\n");
/* terminate program if out of memory */
goto label33; }
count=(s1[8]+2);

if(choice==8){
label1:
ex2();
box=s1[1];
printf("\nEnter function of initial values, u(x,0) as prompted\n");
printf("Enter degree of function\n");
scanf("%lf",&degree);
if(degree>9){
printf("\nDegree should be <= 9\n");
goto label1;}
printf("\nEnter coefficients of X, proceeding from const to highest degree");

for(k=0 ; k<=degree ; ++k){


printf("\nEnter coeff # %-5d\n",k+1);
scanf("%lf",&aray[k]);}

for(j=0 ; j<=s1[8]+1 ; ++j) *(output+j)=poly(s1[1]*j, degree, aray); }

else{
ex2();
box=0.0;
printf("\nEnter initial values, u(x,0) as prompted\n");
for(i=0; i<=s1[8]+1 ;++i){
printf("\nEnter initial value at X= %-20.5lf\n", box);
scanf("%lf", &value);
*(output+i)=value;
box=box+s1[1];}}

that=s1[8];

do{
ex2();
printf("\nAfter how many time increments do you want the results to be continuously\n");
printf("displayed ( a multiple of the time increment ), the total number of time \n");
printf("increments that you previously entered must be an integer multiple of this \n");
printf("value, Ex: 1, 2(if your previous # is a multiple of 10) 5, 10, 55, 100, ....\n\n");
scanf("%lf", &value);
if(value==0.0 || value>s1[7])continue;

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

dummy=s1[7]/value;
fraction=modf(dummy, &integer);
dummy1=value/1.0;
fraction1=modf(dummy1, &integer1);
}while(fraction != 0.0 || fraction1!=0 || value==0.0 || value>s1[7]);

ex2();
printf("\nThe # of internal mesh points used is %-20.0lf\n",s1[8]+2);
printf("\nThe # of total mesh points used including fictious is %-20.0lf\n",s1[8]+4);
fprintf(fp_crank3,"\nThe # of internal mesh points used is %-20.0lf\n",s1[8]+2);
fprintf(fp_crank3,"\nThe # of total mesh points used including fictious is %-20.0lf\n",s1[8]+4);

printf("\n\n\nPress RETURN to continue\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

for(m=0; m<=that+1 ;++m)*(output+count+m)=*(output+m);

ex2();
box=0.0;
printf("\nThe output at t= %-20.5lf\n\n",box);
for(l=0; l<=s1[8]+1 ;++l)printf("%-20.5e",*(output+l));

box=0.0;
fprintf(fp_crank3,"\nThe output at t= %-20.5lf\n\n",box);
for(l=0; l<=s1[8]+1 ;++l)fprintf(fp_crank3,"%-20.5e",*(output+l));

printf("\n\nPress RETURN to continue\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

box=value*s1[4];
for(k=1; k<=integer ;++k){
for(i=1; i<=value ;++i){

do{
n=0;
for(j=0; j<=s1[8]+1 ;++j){
savior=*(output+count+j) ;
if(j==0){
*(output+count+j)=(2.0*s1[2]* *(output+count+j+1))+(2.0-(2.0*s1[2])-(2.0*dff1[0]*s1[1]*s1[2])*
*(output+j))+(2.0*s1[2]* *(output+j+1))-(4.0*s1[2]*s1[1]*dff1[1]);
*(output+count+j)=*(output+count+j)/(2.0+(2.0*s1[2])+(2.0*s1[2]*dff1[0]*s1[1])) ; }

else if(j==s1[8]+1){
*(output+count+j)=(2.0*s1[2]* *(output+count+j-1))+(2.0-(2.0*s1[2])+(2.0*dff1[2]*s1[1]*s1[2])*
*(output+j))+(2.0*s1[2]* *(output+j-1))+(4.0*s1[2]*s1[1]*dff1[3]);
*(output+count+j)=*(output+count+j)/(2.0+(2.0*s1[2])-(2.0*s1[2]*dff1[2]*s1[1])) ; }

else{
*(output+count+j)=s1[2]*(*(output+j-1)+*(output+j+1))+((2.0-(2.0*s1[2])) *
*(output+j))+(s1[2]*(*(output+count+j+1)+*(output+count+j-1)));
*(output+count+j)=*(output+count+j)/(2.0+(2.0*s1[2]));}

if(fabs(*(output+count+j) - savior) < .000001) ++n ;}


}while(n != s1[8]+2);

for(m=0; m<=that+1 ;++m)*(output+m)=*(output+count+m);

if(i==value){
printf("\nThe output at t= %-20.5lf\n\n",box);
for(l=0; l<=s1[8]+1 ;++l)printf("%-20.5e",*(output+l));
fprintf(fp_crank3,"\n\nThe output at t= %-20.5lf\n\n",box);
for(l=0; l<=s1[8]+1 ;++l)fprintf(fp_crank3,"%-20.5e",*(output+l));

printf("\n\nPress RETURN to continue\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

box=(k+1)*value*s1[4]; }
}}

label33:
free(output);
}

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

DECIDE.C
#include "header.h"

extern int eqn(FILE *fp_eqn)


{
int choice, ch;

do{
printf("\n\nNumerical Solutions for the Elliptic eqn - Dirichlet Problem\n");
printf("Enter the # associated with the type of eqn you would like to solve\n\n\n");

printf("1 : Laplace eqn :constant boundaries\n\n\n");

printf("2 : Poisson eqn, constant function :constant boundaries\n\n\n");

printf("3 : Laplace eqn \n");


printf(" Boundaries expressed as polynomial functions \n\n\n");

printf("4 : Poisson eqn, constant function \n");


printf(" Boundaries expressed as polynomial functions \n\n\n");

printf("5 : Poisson eqn, function f(x,y) :constant boundaries\n\n\n");

printf("Press RETURN to show more options\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

clrscr();
printf("\nNumerical Solutions for the Elliptic eqn - Dirichlet Problem\n");
printf("Enter the # associated with the type of eqn you would like to solve\n\n\n");

printf("6 : Poisson eqn, function f(x,y) \n");


printf(" Boundaries expressed as polynomial functions \n\n\n");

printf("7 : Laplace eqn :boundaries expressed as\n");


printf(" points entered by the user\n\n\n");

printf("8 : Poisson eqn, constant function :boundaries expressed as\n");


printf(" points entered by the user\n\n\n");

printf("9 : Poisson eqn, function f(x,y) :boundaries expressed as\n");


printf(" points entered by the user\n\n\n");

printf("10: Poisson eqn, f(x,y) expressed as points entered by the user\n");


printf(" boundaries expressed as points entered by the user\n\n");

printf("Your choice ");


scanf("%d",&choice);
}while(choice<1 || choice>10);

ex2();
printf("\nYour choice was\n\n");
switch(choice){
case 1:
printf("1 : Laplace eqn :constant boundaries\n\n");
break;
case 2:
printf("2 : Poisson eqn, constant function :constant boundaries\n\n");
break;
case 3:
printf("3 : Laplace eqn \n");
printf(" Boundaries expressed as polynomial functions \n\n");
break;
case 4:
printf("4 : Poisson eqn, constant function \n");
printf(" Boundaries expressed as polynomial functions \n\n");
break;
case 5:
printf("5 : Poisson eqn, function f(x,y) :constant boundaries\n\n");
break;
case 6:
printf("6 : Poisson eqn, function f(x,y) \n");
printf(" Boundaries expressed as polynomial functions \n\n");
break;
case 7:
printf("7 : Laplace eqn :boundaries expressed as\n");
printf(" points entered by the user\n\n");
break;
case 8:
printf("8 : Poisson eqn, constant function :boundaries expressed as\n");
printf(" points entered by the user\n\n");
break;

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

case 9:
printf("9 : Poisson eqn, function f(x,y) :boundaries expressed as\n");
printf(" points entered by the user\n\n");
break;
case 10:
printf("10: Poisson eqn, f(x,y) expressed as points entered by the user\n");
printf(" boundaries expressed as points entered by the user\n\n");
break;}

fprintf(fp_eqn,"\nYour choice was\n\n");


switch(choice){
case 1:
fprintf(fp_eqn,"1 : Laplace eqn :constant boundaries\n\n");
break;
case 2:
fprintf(fp_eqn,"2 : Poisson eqn, constant function :constant boundaries\n\n");
break;
case 3:
fprintf(fp_eqn,"3 : Laplace eqn \n");
fprintf(fp_eqn," Boundaries expressed as polynomial functions \n\n");
break;
case 4:
fprintf(fp_eqn,"4 : Poisson eqn, constant function \n");
fprintf(fp_eqn," Boundaries expressed as polynomial functions \n\n");
break;
case 5:
fprintf(fp_eqn,"5 : Poisson eqn, function f(x,y) :constant boundaries\n\n");
break;
case 6:
fprintf(fp_eqn,"6 : Poisson eqn, function f(x,y) \n");
fprintf(fp_eqn," Boundaries expressed as polynomial functions \n\n");
break;
case 7:
fprintf(fp_eqn,"7 : Laplace eqn :boundaries expressed as\n");
fprintf(fp_eqn," points entered by the user\n\n");
break;
case 8:
fprintf(fp_eqn,"8 : Poisson eqn, constant function :boundaries expressed as\n");
fprintf(fp_eqn," points entered by the user\n\n");
break;
case 9:
fprintf(fp_eqn,"9 : Poisson eqn, function f(x,y) :boundaries expressed as\n");
fprintf(fp_eqn," points entered by the user\n\n");
break;
case 10:
fprintf(fp_eqn,"10: Poisson eqn, f(x,y) expressed as points entered by the user\n");
fprintf(fp_eqn," boundaries expressed as points entered by the user\n\n");
break;}

printf("Press RETURN to continue\n\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

return choice;
}

DECIDE1.C
#include "header.h"

extern int eqn1(FILE *fp_eqn1)


{
int choice, ch;

do{
clrscr();
printf("\n\nNumerical Solutions for the Elliptic eqn - Dirichlet Problem\n");
printf("Enter the # associated with the type of eqn you would like to solve\n\n\n");

printf("1: Laplace eqn, irregular boundary :using Gauss-Seidel\n");


printf(" semi-circle :constant boundaries\n\n");

printf("2: Laplace eqn, irregular boundary :using Jacobi\n");


printf(" semi-circle :constant boundaries\n\n");

printf("3: Laplace eqn, irregular boundary :using Gauss-Seidel\n");


printf(" circle :constant boundaries\n\n");

printf("4: Laplace eqn, irregular boundary :using Jacobi\n");


printf(" circle :constant boundaries\n\n");

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

printf("\n\nPress RETURN to show more options");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

clrscr();
printf("\n\nNumerical Solutions for the Elliptic eqn - Dirichlet Problem\n");
printf("Enter the # associated with the type of eqn you would like to solve\n\n\n");

printf("5: Laplace eqn, irregular boundary :using Gauss-Seidel\n");


printf(" semi-circle :user entering boundaries\n\n");

printf("6: Laplace eqn, irregular boundary :using Jacobi\n");


printf(" semi-circle :user entering boundaries\n\n");

printf("7: Laplace eqn, irregular boundary :using Gauss-Seidel\n");


printf(" circle :user entering boundaries\n\n");

printf("8: Laplace eqn, irregular boundary :using Jacobi\n");


printf(" circle :user entering boundaries\n\n");

printf("\nYour choice ");


scanf("%d",&choice);
}while(choice<1 || choice>8);

ex2();
printf("\nYour choice was\n\n");
switch(choice){
case 1:
printf("1: Laplace eqn, irregular boundary :using Gauss-Seidel\n");
printf(" semi-circle :constant boundaries\n\n");
break;
case 2:
printf("2: Laplace eqn, irregular boundary :using Jacobi\n");
printf(" semi-circle :constant boundaries\n\n");
break;
case 3:
printf("3: Laplace eqn, irregular boundary :using Gauss-Seidel\n");
printf(" circle :constant boundaries\n\n");
break;
case 4:
printf("4: Laplace eqn, irregular boundary :using Jacobi\n");
printf(" circle :constant boundaries\n\n");
break;
case 5:
printf("5: Laplace eqn, irregular boundary :using Gauss-Seidel\n");
printf(" semi-circle :user entering boundaries\n\n");
break;
case 6:
printf("6: Laplace eqn, irregular boundary :using Jacobi\n");
printf(" semi-circle :user entering boundaries\n\n");
break;
case 7:
printf("7: Laplace eqn, irregular boundary :using Gauss-Seidel\n");
printf(" circle :user entering boundaries\n\n");
break;
case 8:
printf("8: Laplace eqn, irregular boundary :using Jacobi\n");
printf(" circle :user entering boundaries\n\n");
break;}

fprintf(fp_eqn1,"\nYour choice was\n\n");


switch(choice){
case 1:
fprintf(fp_eqn1,"1: Laplace eqn, irregular boundary :using Gauss-Seidel\n");
fprintf(fp_eqn1," semi-circle :constant boundaries\n\n");
break;
case 2:
fprintf(fp_eqn1,"2: Laplace eqn, irregular boundary :using Jacobi\n");
fprintf(fp_eqn1," semi-circle :constant boundaries\n\n");
break;
case 3:
fprintf(fp_eqn1,"3: Laplace eqn, irregular boundary :using Gauss-Seidel\n");
fprintf(fp_eqn1," circle :constant boundaries\n\n");
break;
case 4:
fprintf(fp_eqn1,"4: Laplace eqn, irregular boundary :using Jacobi\n");
fprintf(fp_eqn1," circle :constant boundaries\n\n");
break;
case 5:
fprintf(fp_eqn1,"5: Laplace eqn, irregular boundary :using Gauss-Seidel\n");
fprintf(fp_eqn1," semi-circle :user entering boundaries\n\n");
break;

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

case 6:
fprintf(fp_eqn1,"6: Laplace eqn, irregular boundary :using Jacobi\n");
fprintf(fp_eqn1," semi-circle :user entering boundaries\n\n");
break;
case 7:
fprintf(fp_eqn1,"7: Laplace eqn, irregular boundary :using Gauss-Seidel\n");
fprintf(fp_eqn1," circle :user entering boundaries\n\n");
break;
case 8:
fprintf(fp_eqn1,"8: Laplace eqn, irregular boundary :using Jacobi\n");
fprintf(fp_eqn1," circle :user entering boundaries\n\n");
break;}

printf("Press RETURN to continue\n\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

return choice;
}

DECIDEH.C
#include "header.h"

extern int eqn_hyperbolic(FILE *fp_eqn_hyperbolic)


{
int choice, ch;

clrscr();
do{
printf("\n\nNumerical Solutions for the Hyperbolic PDE \n");
printf("Enter the # associated with the type of eqn you would like to solve\n\n\n");

printf("1 : One dimensional wave eqn :by Finite Differences\n");


printf(" boundaries expressed as constants\n");
printf(" initial conditions expressed as points entered by user\n");
printf(" time derivative expressed as a polynomial function\n\n");

printf("2 : One dimensional wave eqn :by Finite Differences\n");


printf(" boundaries expressed as constants\n");
printf(" initial conditions expressed as a polynomial function \n");
printf(" time derivative expressed as a polynomial function\n\n");

printf("3 : One dimensional wave eqn :by Finite Differences\n");


printf(" boundaries expressed as constants\n");
printf(" initial conditions expressed as points entered by user\n");
printf(" time derivative expressed as points entered by user\n\n");

printf("\nPress RETURN to show more options\n\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

clrscr();
printf("\n\n\nNumerical Solutions for the Hyperbolic PDE \n");
printf("Enter the # associated with the type of eqn you would like to solve\n\n\n");

printf("4 : One dimensional wave eqn :by Finite Differences\n");


printf(" boundaries expressed as constants\n");
printf(" initial conditions expressed as a polynomial function \n");
printf(" time derivative expressed as points entered by user\n\n\n");

printf("5 : Two dimensional wave eqn :by Finite Differences\n");


printf(" boundaries expressed as constants\n");
printf(" initial conditions expressed as points entered by user\n");
printf(" time derivative expressed as points entered by user\n\n");

printf("\n\n\nYour choice ");


scanf("%d",&choice);
}while(choice<1 || choice>5);

ex2();
printf("\nYour choice was\n\n");
switch(choice){
case 1:
printf("1 : One dimensional wave eqn :by Finite Differences\n");
printf(" boundaries expressed as constants\n");
printf(" initial conditions expressed as a polynomial function \n");
printf(" time derivative expressed as a polynomial function\n\n");
break;

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

case 2:
printf("2 : One dimensional wave eqn :by Finite Differences\n");
printf(" boundaries expressed as constants\n");
printf(" initial conditions expressed as a polynomial function \n");
printf(" time derivative expressed as a polynomial function\n\n");
break;
case 3:
printf("3 : One dimensional wave eqn :by Finite Differences\n");
printf(" boundaries expressed as constants\n");
printf(" initial conditions expressed as points entered by user\n");
printf(" time derivative expressed as points entered by user\n\n");
break;
case 4:
printf("4 : One dimensional wave eqn :by Finite Differences\n");
printf(" boundaries expressed as constants\n");
printf(" initial conditions expressed as a polynomial function \n");
printf(" time derivative expressed as points entered by user\n\n");
break;
case 5:
printf("5 : Two dimensional wave eqn :by Finite Differences\n");
printf(" boundaries expressed as constants\n");
printf(" initial conditions expressed as points entered by user\n");
printf(" time derivative expressed as points entered by user\n\n");
break;}

fprintf(fp_eqn_hyperbolic,"\nYour choice was\n\n");


switch(choice){
case 1:
fprintf(fp_eqn_hyperbolic,"1 : One dimensional wave eqn :by Finite
Differences\n");
fprintf(fp_eqn_hyperbolic," boundaries expressed as constants\n");
fprintf(fp_eqn_hyperbolic," initial conditions expressed as a polynomial function
\n");
fprintf(fp_eqn_hyperbolic," time derivative expressed as a polynomial
function\n\n");
break;
case 2:
fprintf(fp_eqn_hyperbolic,"2 : One dimensional wave eqn :by Finite
Differences\n");
fprintf(fp_eqn_hyperbolic," boundaries expressed as constants\n");
fprintf(fp_eqn_hyperbolic," initial conditions expressed as a polynomial function
\n");
fprintf(fp_eqn_hyperbolic," time derivative expressed as a polynomial
function\n\n");
break;
case 3:
fprintf(fp_eqn_hyperbolic,"3 : One dimensional wave eqn :by Finite
Differences\n");
fprintf(fp_eqn_hyperbolic," boundaries expressed as constants\n");
fprintf(fp_eqn_hyperbolic," initial conditions expressed as points entered by
user\n");
fprintf(fp_eqn_hyperbolic," time derivative expressed as points entered by
user\n\n");
break;
case 4:
fprintf(fp_eqn_hyperbolic,"4 : One dimensional wave eqn :by Finite
Differences\n");
fprintf(fp_eqn_hyperbolic," boundaries expressed as constants\n");
fprintf(fp_eqn_hyperbolic," initial conditions expressed as a polynomial function
\n");
fprintf(fp_eqn_hyperbolic," time derivative expressed as points entered by
user\n\n");
break;
case 5:
fprintf(fp_eqn_hyperbolic,"5 : Two dimensional wave eqn :by Finite
Differences\n");
fprintf(fp_eqn_hyperbolic," boundaries expressed as constants\n");
fprintf(fp_eqn_hyperbolic," initial conditions expressed as points entered by
user\n");
fprintf(fp_eqn_hyperbolic," time derivative expressed as points entered by
user\n\n");
break;}

printf("Press RETURN to continue\n\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

return choice;
}

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

DECIDEP.C
#include "header.h"

extern int eqn_parabolic(FILE *fp_eqn_parabolic)


{
int choice, ch;

clrscr();
do{
printf("\n\nNumerical Solutions for the Parabolic eqn \n");
printf("Enter the # associated with the type of eqn you would like to solve\n\n\n");

printf("1 : One dimensional heat eqn :Explicit method\n");


printf(" boundaries expressed as constants\n");
printf(" initial conditions expressed as points entered by the user\n\n");

printf("2 : One dimensional heat eqn :Explicit method\n");


printf(" boundaries expressed as constants\n");
printf(" initial conditions expressed as a polynomial function \n\n");

printf("3 : One dimensional heat eqn :Crank-Nicolson method\n");


printf(" boundaries expressed as constants\n");
printf(" initial conditions expressed as points entered by the user\n\n");

printf("4 : One dimensional heat eqn :Crank-Nicolson method\n");


printf(" boundaries expressed as constants\n");
printf(" initial conditions expressed as a polynomial function \n\n");

printf("\n\nPress RETURN to show more options");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

clrscr();
printf("\nNumerical Solutions for the Parabolic eqn \n");
printf("Enter the # associated with the type of eqn you would like to solve\n\n");

printf("5 : One dimensional heat eqn :Explicit method\n");


printf(" boundaries expressed as derivatives\n");
printf(" initial conditions expressed as points entered by the user\n\n");

printf("6 : One dimensional heat eqn :Explicit method\n");


printf(" boundaries expressed as derivatives\n");
printf(" initial conditions expressed as a polynomial function \n\n");

printf("7 : One dimensional heat eqn :Crank-Nicolson method\n");


printf(" boundaries expressed as derivatives\n");
printf(" initial conditions expressed as points entered by the user\n\n");

printf("8 : One dimensional heat eqn :Crank-Nicolson method\n");


printf(" boundaries expressed as derivatives\n");
printf(" initial conditions expressed as a polynomial function \n\n");

printf("9 : Two dimensional heat eqn :A.D.I. method\n");


printf(" boundaries expressed as constant points entered by user\n");
printf(" initial conditions expressed as points entered by the user\n\n");

printf("Your choice ");


scanf("%d",&choice);
}while(choice<1 || choice>9);

ex2();
printf("\nYour choice was\n\n");
switch(choice){

case 1:
printf("1 : One dimensional heat eqn :Explicit method\n");
printf(" boundaries expressed as constants\n");
printf(" initial conditions expressed as points entered by the user\n\n");
break;
case 2:
printf("2 : One dimensional heat eqn :Explicit method\n");
printf(" boundaries expressed as constants\n");
printf(" initial conditions expressed as a polynomial function \n\n");
break;
case 3:
printf("3 : One dimensional heat eqn :Crank-Nicolson method\n");
printf(" boundaries expressed as constants\n");
printf(" initial conditions expressed as points entered by the user\n\n");
break;
case 4:
printf("4 : One dimensional heat eqn :Crank-Nicolson method\n");
printf(" boundaries expressed as constants\n");

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

printf(" initial conditions expressed as a polynomial function \n\n");


break;
case 5:
printf("5 : One dimensional heat eqn :Explicit method\n");
printf(" boundaries expressed as derivatives\n");
printf(" initial conditions expressed as points entered by the user\n\n");
break;
case 6:
printf("6 : One dimensional heat eqn :Explicit method\n");
printf(" boundaries expressed as derivatives\n");
printf(" initial conditions expressed as a polynomial function \n\n");
break;
case 7:
printf("7 : One dimensional heat eqn :Crank-Nicolson method\n");
printf(" boundaries expressed as derivatives\n");
printf(" initial conditions expressed as points entered by the user\n\n");
break;
case 8:
printf("8 : One dimensional heat eqn :Crank-Nicolson method\n");
printf(" boundaries expressed as derivatives\n");
printf(" initial conditions expressed as a polynomial function \n\n");
break;
case 9:
printf("9 : Two dimensional heat eqn :ADI method\n");
printf(" boundaries expressed as constant points entered by user\n");
printf(" initial conditions expressed as points entered by the user\n\n");
break;}

fprintf(fp_eqn_parabolic,"\nYour choice was\n\n");


switch(choice){

case 1:
fprintf(fp_eqn_parabolic,"1 : One dimensional heat eqn :Explicit method\n");
fprintf(fp_eqn_parabolic," boundaries expressed as constants\n");
fprintf(fp_eqn_parabolic," initial conditions expressed as points entered by the
user\n\n");
break;
case 2:
fprintf(fp_eqn_parabolic,"2 : One dimensional heat eqn :Explicit method\n");
fprintf(fp_eqn_parabolic," boundaries expressed as constants\n");
fprintf(fp_eqn_parabolic," initial conditions expressed as a polynomial function \n\n");
break;
case 3:
fprintf(fp_eqn_parabolic,"3 : One dimensional heat eqn :Crank-Nicolson method\n");
fprintf(fp_eqn_parabolic," boundaries expressed as constants\n");
fprintf(fp_eqn_parabolic," initial conditions expressed as points entered by the
user\n\n");
break;
case 4:
fprintf(fp_eqn_parabolic,"4 : One dimensional heat eqn :Crank-Nicolson method\n");
fprintf(fp_eqn_parabolic," boundaries expressed as constants\n");
fprintf(fp_eqn_parabolic," initial conditions expressed as a polynomial function \n\n");
break;
case 5:
fprintf(fp_eqn_parabolic,"5 : One dimensional heat eqn :Explicit method\n");
fprintf(fp_eqn_parabolic," boundaries expressed as derivatives\n");
fprintf(fp_eqn_parabolic," initial conditions expressed as points entered by the
user\n\n");
break;
case 6:
fprintf(fp_eqn_parabolic,"6 : One dimensional heat eqn :Explicit method\n");
fprintf(fp_eqn_parabolic," boundaries expressed as derivatives\n");
fprintf(fp_eqn_parabolic," initial conditions expressed as a polynomial function \n\n");
break;
case 7:
fprintf(fp_eqn_parabolic,"7 : One dimensional heat eqn :Crank-Nicolson method\n");
fprintf(fp_eqn_parabolic," boundaries expressed as derivatives\n");
fprintf(fp_eqn_parabolic," initial conditions expressed as points entered by the
user\n\n");
break;
case 8:
fprintf(fp_eqn_parabolic,"8 : One dimensional heat eqn :Crank-Nicolson method\n");
fprintf(fp_eqn_parabolic," boundaries expressed as derivatives\n");
fprintf(fp_eqn_parabolic," initial conditions expressed as a polynomial function \n\n");
break;
case 9:
fprintf(fp_eqn_parabolic,"9 : Two dimensional heat eqn :ADI method\n");
fprintf(fp_eqn_parabolic," boundaries expressed as constant points entered by user\n");
fprintf(fp_eqn_parabolic," initial conditions expressed as points entered by the
user\n\n");
break;}

printf("Press RETURN to continue\n\n");


ch='\0';
for(;;)

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

{ ch=getche();
if(ch=='\r')break;}

return choice;

DMNSN.C
#include "header.h"
extern void dimension(double *s, FILE *fp_dimension)
{
auto double one=0,two=0;
auto double size=1, size1=1;
auto char ch='\0';

one=*s;
two=*(s+1);
size=((one * two)+(2*(one+two))) ;
size1=((one * two)) ;

/* displaying the # of mesh points the we will be operating on */


printf("\nThe # of internal mesh points is %-5.0f\n",size1);
printf("\nThe # of mesh points that we'll be operating on\n");
printf("including the ones on the boundary is:\n");
printf("For 5 point approximations %-5.0f\n",size);
printf("For 9 point approximations %-5.0f\n\n",size+4);

fprintf(fp_dimension,"\nThe # of internal mesh points is %-5.0f\n",size1);


fprintf(fp_dimension,"\nThe # of mesh points that we'll be operating on\n");
fprintf(fp_dimension,"including the ones on the boundary is:\n");
fprintf(fp_dimension,"For 5 point approximations %-5.0f\n",size);
fprintf(fp_dimension,"For 9 point approximations %-5.0f\n\n",size+4);

/* delay so you can see results */


printf("Press RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

printf("\n\n");

ELLIPTIC.C
#include "header.h"
extern void graph1(void);

extern int choice_dnm(FILE *fp_elliptic)


{
int choice, ch;

do{
printf("Numerical Solutions For Elliptic Partial Differential Equations\n\n");
printf("Enter the # associated with the Boundary value Problem you would like to use\n");
printf("to solve the Elliptic PDE for:\n\n");

printf("1: Dirichlet Problem - First Boundary Value Problem\n");


printf(" - Regular boundaries \n");
printf("2: Dirichlet Problem - First Boundary Value Problem\n");
printf(" - Irregular boundaries \n");
printf("3: Neumann Problem - Second Boundary Value Problem\n");
printf("4: Mixed Problem \n\n");

printf("Your choice ");


scanf("%d", &choice);
}while(choice<1 || choice>4);

ex2();
printf("\nYour choice was\n\n");
switch(choice){
case 1:
printf("1: Dirichlet Problem - First Boundary Value Problem\n");
printf(" - Regular boundaries \n\n");
break;
case 2:
printf("2: Dirichlet Problem - First Boundary Value Problem\n");
printf(" - Irregular boundaries \n\n");
break;
case 3:

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

printf("3: Neumann Problem - Second Boundary Value Problem\n\n");


break;
case 4:
printf("4: Mixed Problem \n\n");
break;
}

fprintf(fp_elliptic,"\nYour choice was\n\n");


switch(choice){
case 1:
fprintf(fp_elliptic,"1: Dirichlet Problem - First Boundary Value Problem\n");
fprintf(fp_elliptic," - Regular boundaries \n\n");
break;
case 2:
fprintf(fp_elliptic,"2: Dirichlet Problem - First Boundary Value Problem\n");
fprintf(fp_elliptic," - Irregular boundaries \n\n");
break;
case 3:
fprintf(fp_elliptic,"3: Neumann Problem - Second Boundary Value Problem\n\n");
break;
case 4:
fprintf(fp_elliptic,"4: Mixed Problem \n\n");
break;
}

printf("\nPress RETURN to continue\n\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
if(choice!=2)graph1();
return choice;
}

ENTER1.C
#include"header.h"

extern void enter1(double *s1, int choice, double *dff1, FILE *fp_enter1)
{
double space, incrementx, r, constant, left, right, span, fraction, integer;
double *output;
char ch;

label22:
do{
ex2();
printf("\nEnter length of the space dimension\n");
scanf("%lf",&space);
s1[0]=space;

printf("\nEnter value of increment in the space dimension to be used\n");


printf("The space length you entered must be an integer multiple of this increment\n");
scanf("%lf",&incrementx);
incrementx=fabs(incrementx);
s1[1]=incrementx;
space=space/incrementx;
s1[8]=space-1;

output=malloc(8*2*(s1[8]+2));
if(!output){
ex2();
printf("\nNot enough memory to allocate buffer\n");
printf("Re-enter arguments\n");

printf("\n\nPress RETURN to continue\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

/* terminate program if out of memory */


free(output);
goto label22 ;}
free(output);

fraction=modf(space, &integer);
}while( fraction != 0.0 );

ex2();
printf("\nEnter the constant of your eqn reffered to the time side of the eqn\n");
printf("It should be a positive constant\n");
scanf("%lf",&constant);

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

constant=fabs(constant);
s1[3]=constant;

if(choice==1 || choice==2){
do{
ex2();
printf("\nEnter ( r ) factor to be used, it should be <= 0.5 to assure convergence\n");
printf("and in order for the results to be accurate via this method\n");
printf("The increment in time will be governed by the following equation\n");
printf("change time = CONSTANT * r * (change space)^2\n");
printf("Where CONSTANT is the constant of your PDE that you previously entered\n\n");

scanf("%lf",&r);
s1[2]=r;
}while( r>.5 );}
else if (choice==5 || choice==6){
do{
ex2();
printf("\nEnter ( r ) factor to be used, it should be < 0.5 to assure convergence\n");
printf("and in order for the results to be accurate via this method\n");
printf("The increment in time will be governed by the following equation\n");
printf("change time = CONSTANT * r * (change space)^2\n");
printf("Where CONSTANT is the constant of your PDE that you previously entered\n\n");

scanf("%lf",&r);
s1[2]=r;
}while( r>=.5 );}
else{
ex2();
printf("\nEnter ( r ) factor to be used, the smaller the better in order for the \n");
printf("results to be more accurate\n");
printf("The increment in time will be governed by the following equation\n");
printf("change time = CONSTANT * r * (change space)^2\n");
printf("Where CONSTANT is the constant of your PDE that you previously entered\n\n");

scanf("%lf",&r);
s1[2]=r;}

s1[4]=(incrementx * incrementx * r)*constant;


ex2();
printf("\nYour time increment will be %-20.5e\n",s1[4]);
printf("\n\nPress RETURN to continue\n");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

fprintf(fp_enter1,"\nThe data related to this problem is as follows\n\n");


fprintf(fp_enter1,"Length of the space dimension is %-20.5lf\n", s1[0]);
fprintf(fp_enter1,"Value of increment in the space dimension is %-20.5lf\n", s1[1]);
fprintf(fp_enter1,"The constant of your eqn reffered to the time side of the eqn is %-20.5lf\n", s1[3]);
fprintf(fp_enter1,"r factor to be used is %-20.5lf\n\n", s1[2]);
fprintf(fp_enter1,"The increment in time will be governed by the following equation\n");
fprintf(fp_enter1,"change time = CONSTANT * r * (change space)^2\n");
fprintf(fp_enter1,"\nYour time increment will be %-20.5e\n\n",s1[4]);

do{
ex2();
printf("\nTill how many time increments do you want this program to show\n");
printf("Enter your answer as a factor of 5, Example: 10 , 200, 3615, ...\n\n");
scanf("%lf",&span);
s1[7]=span;
span=span/5.0;
fraction=modf(span, &integer);

}while(integer != span);

if(choice<=4){
ex2();
printf("\nEnter one side's constant boundary, u(0,t)\n");
scanf("%lf",&left);
s1[5]=left;

printf("\nEnter the other side's constant boundary, u(L,t)\n");


scanf("%lf",&right);
s1[6]=right;}

else {
ex2();
printf("\nBoundary of side u(0,t)\n");
printf("Enter the derivative at this side in the form ( aU + b ) \n");
printf("a= ");
scanf("%lf", &dff1[0]);
printf("\nb= ");
scanf("%lf", &dff1[1]);

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

ex2();
printf("\nBoundary of side u(L,t)\n");
printf("Enter the derivative at this side in the form ( aU + b ) \n");
printf("a= ");
scanf("%lf", &dff1[2]);
printf("\nb= ");
scanf("%lf", &dff1[3]); }

ENTER2.C
#include"header.h"

extern void enter2(double *s1, FILE *fp_enter2)


{
double space, incrementx, r, constant, span, fraction, integer;
double *output, max ;
double space1, integer1, fraction1;
char ch;

label22:
do{
ex2();
printf("\nEnter length of the X space dimension\n");
scanf("%lf", &space);
s1[0]=space;

printf("\nEnter length of the Y space dimension\n");


scanf("%lf", &space1);
s1[5]=space1;

ex2();
printf("\nEnter value of increment in the space dimension to be used\n");
printf("The space lengths you entered must integer multiples of this increment\n");
scanf("%lf",&incrementx);
incrementx=fabs(incrementx);
s1[1]=incrementx;
space=space/incrementx;
s1[8]=space-1;

space1=space1/incrementx;
s1[9]=space1-1;
max=(space1+1)*(space+1) ;

if(max > 2500){


ex2();
printf("\nSorry, this program only allows you to have no more than 2500\n");
printf("total mesh points, try again and modify your choice of increment in space\n\n");
printf("\n\nPress RETURN to continue\n");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }
continue;}

output=malloc(8*(s1[8]+2)*(s1[9]+2));
if(!output){
ex2();
printf("\nNot enough memory to allocate buffer\n");
printf("Re-enter arguments\n");

printf("\n\nPress RETURN to continue\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

/* terminate program if out of memory */


free(output);
goto label22 ;}
free(output);

fraction1=modf(space1, &integer1);
fraction=modf(space, &integer);
}while(fraction != 0.0 || fraction1 != 0.0 || max>2500);

ex2();
printf("\nEnter the constant of your eqn reffered to the time side of the eqn\n");
printf("It should be a positive constant\n");
scanf("%lf",&constant);
constant=fabs(constant);

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

s1[3]=constant;

ex2();
printf("\nEnter ( r ) factor to be used \n");
printf("the numerical method used here converges and is stable for all values of r\n");
printf("although accuracy requires that r not be too large\n");
printf("The increment in time will be governed by the following equation\n");
printf("change time = CONSTANT * r * (change space)^2\n");
printf("Where CONSTANT is the constant of your PDE that you previously entered\n\n");

scanf("%lf",&r);
s1[2]=r;

s1[4]=(incrementx * incrementx * r)*constant;


ex2();
printf("\nYour time increment will be %-20.5e\n",s1[4]);
printf("\n\nPress RETURN to continue\n");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

fprintf(fp_enter2,"\nThe data related to this problem is as follows\n\n");


fprintf(fp_enter2,"Length of the X space dimension is %-20.5lf\n",s1[0]);
fprintf(fp_enter2,"Length of the Y space dimension is %-20.5lf\n",s1[5]);
fprintf(fp_enter2,"Value of increment in the space dimension is %-20.5lf\n", s1[1]);
fprintf(fp_enter2,"The constant of your eqn reffered to the time side of the eqn is %-20.5lf\n", s1[3]);
fprintf(fp_enter2,"r factor to be used is %-20.5lf\n\n", s1[2]);
fprintf(fp_enter2,"The increment in time will be governed by the following equation\n");
fprintf(fp_enter2,"change time = CONSTANT * r * (change space)^2\n");
fprintf(fp_enter2,"Your time increment will be %-20.5e\n\n",s1[4]);

do{
ex2();
printf("\nTill how many time increments do you want this program to show\n\n");
scanf("%lf",&span);
s1[7]=span;
}while(span<=0);

ENTERH.C
#include"header.h"

extern void enterh(double *s1, FILE *fp_enterh)


{
double space, incrementx, constant, left, right, span, fraction, integer;
double *output;
char ch;

ex2();
printf("\nEnter the constant of your eqn reffered to the space side of the PDE\n");
printf("It should be a positive constant\n");
scanf("%lf",&constant);
constant=fabs(constant);
s1[3]=constant;

label22:
do{
ex2();
printf("\nEnter length of the space dimension\n");
scanf("%lf",&space);
s1[0]=space;

clrscr();
printf("\n\n\nEnter value of increment in the space dimension to be used\n\n");
printf("You will not be prompted to enter increment in time, it will depend on\n");
printf("this increment of X, if you want small changes in time, this increment\n");
printf("then should be small\n\n");
printf("This was done so that you can get the exact results of the analytical soln\n");
printf("The increment in time will be governed by the following equation\n");
printf("(change time)^2 * CONSTANT = (change space)^2\n");
printf("Where CONSTANT is the constant of your PDE that you previously entered\n\n");
printf("The space length you entered must be an integer multiple of this increment\n\n\n");
scanf("%lf",&incrementx);
incrementx=fabs(incrementx);
s1[1]=incrementx;
space=space/incrementx;
s1[8]=space-1;

output=malloc(8*3*(s1[8]+2));

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

if(!output){
ex2();
printf("\nNot enough memory to allocate buffer\n");
printf("Re-enter arguments\n");

printf("\n\nPress RETURN to continue\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

/* terminate program if out of memory */


free(output);
goto label22 ;}
free(output);

fraction=modf(space, &integer);
}while( fraction != 0.0 );

s1[4]= incrementx/sqrt(constant);
ex2();
printf("\nYour time increment will be %-20.5e\n",s1[4]);
printf("\n\nPress RETURN to continue\n");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

fprintf(fp_enterh,"\nThe data related to this problem is as follows\n\n");


fprintf(fp_enterh,"Length of the space dimension is %-20.5lf\n", s1[0]);
fprintf(fp_enterh,"The constant of your eqn reffered to the space side of the PDE is %-20.5lf\n", s1[3]);
fprintf(fp_enterh,"Value of increment in the space dimension is %-20.5lf\n\n", s1[1]);
fprintf(fp_enterh,"The increment in time will be governed by the following equation\n");
fprintf(fp_enterh,"(change time)^2 * CONSTANT = (change space)^2\n");
fprintf(fp_enterh,"Your time increment will be %-20.5e\n\n",s1[4]);

do{
ex2();
printf("\nTill how many time increments do you want this program to show\n\n");
scanf("%lf",&span);
s1[7]=span;
span=span/1.0;
fraction=modf(span, &integer);

}while(fraction != 0.0);

ex2();
printf("\nEnter one side's constant boundary, y(0,t)\n");
scanf("%lf",&left);
s1[5]=left;

printf("\nEnter the other side's constant boundary, y(L,t)\n");


scanf("%lf",&right);
s1[6]=right;

ENTERH1.C
#include"header.h"

extern void enter2_hyperbolic(double *s1, FILE *fp_enter2_hyperbolic)


{
double space, incrementx, r, constant, span, fraction, integer;
double *output;
double space1, integer1, fraction1, max ;
char ch;

label22:
do{
ex2();
printf("\nEnter length of the X space dimension\n");
scanf("%lf", &space);
s1[0]=space;

printf("\nEnter length of the Y space dimension\n");


scanf("%lf", &space1);
s1[5]=space1;

ex2();
printf("\nEnter value of increment in the space dimension to be used\n");
printf("The space lengths you entered must integer multiples of this increment\n");

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

scanf("%lf",&incrementx);
incrementx=fabs(incrementx);
s1[1]=incrementx;
space=space/incrementx;
s1[8]=space-1;

space1=space1/incrementx;
s1[9]=space1-1;
max=(space1+1)*(space+1) ;

if(max > 2500){


ex2();
printf("\nSorry, this program only allows you to have no more than 2500\n");
printf("total mesh points, try again and modify your choice of increment in space\n\n");
printf("\n\nPress RETURN to continue\n");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }
continue;}

output=malloc(8*2*(s1[8]+2)*(s1[9]+2));
if(!output){
ex2();
printf("\nNot enough memory to allocate buffer\n");
printf("Re-enter arguments\n");

printf("\n\nPress RETURN to continue\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

/* terminate program if out of memory */


free(output);
goto label22 ;}
free(output);

fraction1=modf(space1, &integer1);
fraction=modf(space, &integer);
}while(fraction != 0.0 || fraction1 != 0.0 || max>2500);

ex2();
printf("\nEnter the constant of your eqn reffered to the space side of the eqn\n");
printf("It should be a positive constant\n");
scanf("%lf",&constant);
constant=fabs(constant);
s1[3]=constant;

ex2();
printf("\nEnter ( r ) factor to be used \n");
printf("the numerical method used here converges and is stable for r <= .5\n");
printf("The increment in time will be governed by the following equation\n");
printf("(change time)^2 = (r * (change space)^2) / CONSTANT\n");
printf("Where CONSTANT is the constant of your PDE that you previously entered\n\n");

scanf("%lf",&r);
s1[2]=r;

s1[4]=sqrt((incrementx * incrementx * r)/constant);


ex2();
printf("\nYour time increment will be %-20.5e\n",s1[4]);
printf("\n\nPress RETURN to continue\n");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

fprintf(fp_enter2_hyperbolic,"\nThe data related to this problem is as follows\n\n");


fprintf(fp_enter2_hyperbolic,"length of the X space dimension is %-20.5lf\n", s1[0]);
fprintf(fp_enter2_hyperbolic,"length of the Y space dimension is %-20.5lf\n", s1[5]);
fprintf(fp_enter2_hyperbolic,"value of increment in the space dimension is %-20.5lf\n", s1[1]);
fprintf(fp_enter2_hyperbolic,"the constant of your eqn reffered to the space side of the eqn is %-20.5lf\n",
s1[3]);
fprintf(fp_enter2_hyperbolic,"r factor to be used is %-20.5lf\n\n", s1[2]);
fprintf(fp_enter2_hyperbolic,"The increment in time will be governed by the following equation\n");
fprintf(fp_enter2_hyperbolic,"(change time)^2 = (r * (change space)^2) / CONSTANT\n");
fprintf(fp_enter2_hyperbolic,"Your time increment will be %-20.5e\n\n",s1[4]);

do{
ex2();
printf("\nTill how many time increments do you want this program to show\n\n");
scanf("%lf",&span);
s1[7]=span;

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

}while(span<=0);

EX1.C
#include <conio.h>

extern void ex1(void)


{
int i, j;

clrscr();
for (i=0; i<9; i++)
{
for (j=0; j<80; j++)
cprintf("C");
cprintf("\r\n");
textcolor(i+1);
textbackground(i);
}
textcolor(7);
textbackground(0);

EX2.C
#include <conio.h>

extern void ex2(void)


{
int i, j;

clrscr();
for (i=3; i<9; i++)
{
for (j=0; j<80; j++)
cprintf("C");
cprintf("\r\n");
textcolor(i+1);
textbackground(i);
}
textcolor(7);
textbackground(0);

EXPLCT2.C
#include "header.h"

extern void explicit2(double *s1, int choice, FILE *fp_explicit2)


{
double box=0.0, value, display, integer, fraction;
double dummy, dummy1, integer1, fraction1;
double *output;
int i, j, k, l ,m;
int that, count;
double aray[10] = {0}, degree;
char ch='\0';

output=malloc(8*2*(s1[8]+2));
if(!output){
ex2();
printf("\nNot enough memory to allocate buffer\n");
/* terminate program if out of memory */
goto label33; }
count=(s1[8]+2);

if(choice==6){
label1:
ex2();
box=s1[1];
printf("\nEnter function of initial values, u(x,0) as prompted\n");
printf("Enter degree of function\n");
scanf("%lf",&degree);
if(degree>9){
printf("\nDegree should be <= 9\n");
goto label1;}
printf("\nEnter coefficients of X, proceeding from const to highest degree");

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

for(k=0 ; k<=degree ; ++k){


printf("\nEnter coeff # %-5d\n",k+1);
scanf("%lf",&aray[k]);}

for(j=1 ; j<=s1[8] ; ++j) *(output+j)=poly(s1[1]*j, degree, aray);}

else{
ex2();
box=s1[1];
printf("\nEnter initial values, u(x,0) as prompted\n");
for(i=1; i<=s1[8] ;++i){
printf("\nEnter initial value at X= %-20.5lf\n", box);
scanf("%lf", &value);
*(output+i)=value;
box=box+s1[1];}}

that=s1[8];
*(output)=s1[5];
*(output+that+1)=s1[6];
do{
ex2();
printf("\nAfter how many time increments do you want the results to be continuously\n");
printf("displayed ( a multiple of the time increment ), the total number of time \n");
printf("increments that you previously entered must be an integer multiple of this \n");
printf("value, Ex: 1, 2(if your previous # is a multiple of 10) 5, 10, 55, 100, ....\n\n");
scanf("%lf", &value);
if(value==0.0 || value>s1[7])continue;
dummy=s1[7]/value;
fraction=modf(dummy, &integer);
dummy1=value/1.0;
fraction1=modf(dummy1, &integer1);
}while(fraction != 0.0 || fraction1!=0 || value==0.0 || value>s1[7]);

ex2();
printf("\nThe # of internal mesh points used is %-20.0lf\n",s1[8]);
fprintf(fp_explicit2,"\nThe # of internal mesh points used is %-20.0lf\n",s1[8]);

printf("\n\n\nPress RETURN to continue\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

ex2();
box=0.0;
printf("\nThe output at t= %-20.5lf\n\n",box);
for(l=0; l<=s1[8]+1 ;++l)printf("%-20.5e",*(output+l));

box=0.0;
fprintf(fp_explicit2,"\nThe output at t= %-20.5lf\n\n",box);
for(l=0; l<=s1[8]+1 ;++l)fprintf(fp_explicit2,"%-20.5e",*(output+l));

printf("\n\nPress RETURN to continue\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

box=value*s1[4];
for(k=1; k<=integer ;++k){
for(i=1; i<=value ;++i){
for(j=1; j<=s1[8] ;++j)
*(output+count+j)=(s1[2]*(*(output+j-1)+*(output+j+1)))+((1-(2.0*s1[2]))**(output+j));

for(m=1; m<=that ;++m)*(output+m)=*(output+count+m);

if(i==value){
printf("\nThe output at t= %-20.5lf\n\n",box);
fprintf(fp_explicit2,"\n\nThe output at t= %-20.5lf\n\n",box);

for(l=0; l<=s1[8]+1 ;++l)printf("%-20.5e",*(output+l));


for(l=0; l<=s1[8]+1 ;++l)fprintf(fp_explicit2,"%-20.5e",*(output+l));

printf("\n\nPress RETURN to continue\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

box=(k+1)*value*s1[4]; }
}}

label33:
free(output);

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

EXPLCT3.C
#include "header.h"

extern void explicit3(double *s1, int choice, double *dff1, FILE *fp_explicit3)
{
double box=0.0, value, display, integer, fraction;
double dummy, dummy1, integer1, fraction1;
double *output;
int i, j, k, l ,m;
int that, count;
double aray[10] = {0}, degree;
char ch='\0';

output=malloc(8*2*(s1[8]+2));
if(!output){
ex2();
printf("\nNot enough memory to allocate buffer\n");
/* terminate program if out of memory */
goto label33; }
count=(s1[8]+2);

if(choice==6){
label1:
ex2();
box=s1[1];
printf("\nEnter function of initial values, u(x,0) as prompted\n");
printf("Enter degree of function\n");
scanf("%lf",&degree);
if(degree>9){
printf("\nDegree should be <= 9\n");
goto label1;}
printf("\nEnter coefficients of X, proceeding from const to highest degree");

for(k=0 ; k<=degree ; ++k){


printf("\nEnter coeff # %-5d\n",k+1);
scanf("%lf",&aray[k]);}

for(j=0 ; j<=s1[8]+1 ; ++j) *(output+j)=poly(s1[1]*j, degree, aray);}

else{
ex2();
box=0.0;
printf("\nEnter initial values, u(x,0) as prompted\n");
for(i=0; i<=s1[8]+1 ;++i){
printf("\nEnter initial value at X= %-20.5lf\n", box);
scanf("%lf", &value);
*(output+i)=value;
box=box+s1[1];}}

that=s1[8];

do{
ex2();
printf("\nAfter how many time increments do you want the results to be continuously\n");
printf("displayed ( a multiple of the time increment ), the total number of time \n");
printf("increments that you previously entered must be an integer multiple of this \n");
printf("value, Ex: 1, 2(if your previous # is a multiple of 10) 5, 10, 55, 100, ....\n\n");
scanf("%lf", &value);
if(value==0.0 || value>s1[7])continue;
dummy=s1[7]/value;
fraction=modf(dummy, &integer);
dummy1=value/1.0;
fraction1=modf(dummy1, &integer1);
}while(fraction != 0.0 || fraction1!=0 || value==0.0 || value>s1[7]);

ex2();
printf("\nThe # of internal mesh points used is %-20.0lf\n",s1[8]+2);
printf("\nThe # of total mesh points used including fictious is %-20.0lf\n",s1[8]+4);
fprintf(fp_explicit3,"\nThe # of internal mesh points used is %-20.0lf\n",s1[8]+2);
fprintf(fp_explicit3,"\nThe # of total mesh points used including fictious is %-20.0lf\n",s1[8]+4);

printf("\n\n\nPress RETURN to continue\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

ex2();
box=0.0;
printf("\nThe output at t= %-20.5lf\n\n",box);

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

for(l=0; l<=s1[8]+1 ;++l)printf("%-20.5e",*(output+l));

box=0.0;
fprintf(fp_explicit3,"\nThe output at t= %-20.5lf\n\n",box);
for(l=0; l<=s1[8]+1 ;++l)fprintf(fp_explicit3,"%-20.5e",*(output+l));

printf("\n\nPress RETURN to continue\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

box=value*s1[4];
for(k=1; k<=integer ;++k){
for(i=1; i<=value ;++i){
for(j=0; j<=s1[8]+1 ;++j){
if(j==0)
*(output+count+j)=((2.0*s1[2]) * *(output+j+1))+((1-(2.0*s1[2])-(2.0*s1[2]*dff1[0]*s1[1])) * *(output+j))-
(2.0*s1[2]*s1[1]*dff1[1]);

else if(j==s1[8]+1)
*(output+count+j)=((2.0*s1[2]) * *(output+j-1))+((1-(2.0*s1[2])+(2.0*s1[2]*dff1[2]*s1[1])) *
*(output+j))+(2.0*s1[2]*s1[1]*dff1[3]);

else
*(output+count+j)=(s1[2]*(*(output+j-1)+*(output+j+1)))+((1-(2.0*s1[2]))**(output+j));
}
for(m=0; m<=that+1 ;++m)*(output+m)=*(output+count+m);

if(i==value){
printf("\nThe output at t= %-20.5lf\n\n",box);
for(l=0; l<=s1[8]+1 ;++l)printf("%-20.5e",*(output+l));
fprintf(fp_explicit3,"\n\nThe output at t= %-20.5lf\n\n",box);
for(l=0; l<=s1[8]+1 ;++l)fprintf(fp_explicit3,"%-20.5e",*(output+l));

printf("\n\nPress RETURN to continue\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

box=(k+1)*value*s1[4]; }
}}

label33:
free(output);
}

GAUSS1P.C
#include "header.h"
#include "header1.h"

extern void gaus_seidel1p(double *s1, double tl, FILE *fp_gaus_seidel1p)


{
double row, column, savior ;
double i, j , n , number;
char ch='\0';

row=(s1[1]+2);
column=(s1[0]+2);

number=0;
do{
++number;
printf("\n# %-5.0lf\n",number);
n=0;
for(i=1 ; i<row-1 ; ++i){
for(j=1 ; j<column-1 ; ++j){
savior=array1[i][j];
array1[i][j]=.25*(array1[i+1][j]+array1[i-1][j]+array1[i][j+1]+array1[i][j-
1]+(cdef[i][j]*s1[2]*s1[2]));
if((tl==0) && (array1[i][j] == savior) ) ++n;
else if((tl!=0) && (fabs(array1[i][j] - savior) < tl) ) ++n ; }
}
}while(n!=((row-2)*(column-2)));

ex2();
printf("\nNumber of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
fprintf(fp_gaus_seidel1p,"\nNumber of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
/* to print out our array1 */
printf("The array will look like this\n");
printf("From the upper to the lower side\n");

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

printf("\nrows= %-5.0lf",row);
printf("\ncolumns= %-5.0lf \n\n",column);
for(i=row-1 ; i>=0 ; --i){
printf("row # %-5.0lf\n",i+1);
for(j=0 ; j<column ; ++j)
printf("%-20.5e",array1[i][j]);
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
printf("\n\n");}

GAUSS2P.C
#include "header.h"
#include "header1.h"

extern void gaus_seidel2p(double *s1, double tl, FILE *fp_gaus_seidel2p)


{
double row, column, savior ;
double i, j , n , number;
char ch='\0';

row=(s1[1]+2);
column=(s1[0]+2);

number=0;
do{
++number;
printf("\n# %-5.0f\n",number);
n=0;
for(i=1 ; i<row-1 ; ++i){
for(j=1 ; j<column-1 ; ++j){
savior=array1[i][j];
array1[i][j]=.05*4*(array1[i+1][j]+array1[i-1][j]+array1[i][j+1]+array1[i][j-1]);
array1[i][j]=array1[i][j]+(.05*(array1[i-1][j-1]+array1[i-1][j+1]+array1[i+1][j-
1]+array1[i+1][j+1]));
array1[i][j]=array1[i][j]+(.05*6*s1[2]*s1[2]*cdef[i][j]);
if((tl!=0.0) && (fabs(array1[i][j] - savior) < tl) ) ++n ;
else if((tl==0.0) && (array1[i][j] == savior) ) ++n; } }

}while(n!=((row-2)*(column-2)));

ex2();
printf("\nNumber of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
fprintf(fp_gaus_seidel2p,"\nNumber of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
/* to print out our array1 */
printf("The array will look like this\n");
printf("From the upper to the lower side\n");
printf("\nrows= %-5.0lf",row);
printf("\ncolumns= %-5.0lf \n\n",column);
for(i=row-1 ; i>=0 ; --i){
printf("row # %-5.0lf\n",i+1);
for(j=0 ; j<column ; ++j)
printf("%-20.5e",array1[i][j]);
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
printf("\n\n");}

GRAPH1.C
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

void graph1(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int i, maxx, maxy;

/* our polygon array */

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

int poly[8];

/* initialize graphics, local variables */


initgraph(&gdriver, &gmode, "");

/* read result of initialization */


errorcode = graphresult();
if (errorcode != grOk)
/* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
/* terminate with an error code */
}

maxx = getmaxx();
maxy = getmaxy();

poly[0] = 3.0 * maxx / 4;


poly[1] = 10;

poly[2] = maxx - 10; /* 2nd */


poly[3] = 10;

poly[4] = maxx - 10; /* 3rd */


poly[5] = maxy / 4;

/*
4th vertex. fillpoly automatically
closes the polygon.
*/
poly[6] = 3.0 * maxx / 4; /* 1st vertex */
poly[7] = maxy / 4;

/* set fill pattern */


setfillstyle(HATCH_FILL, getmaxcolor());

/* draw a filled polygon */


fillpoly(4, poly);

printf("\nRegular boundaries\n");
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nPress any key to continue\n");
getch();

/* clean up */
closegraph();

GRAPH2.C
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

void graph2(void)
{
/* request autodetection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy ;
int xradius = 100, yradius = 100;

/* initialize graphics and local variables */


initgraph(&gdriver, &gmode, "");

/* read result of initialization */


errorcode = graphresult();
if (errorcode != grOk) { /* an error occurred */
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}

midx = getmaxx() / 2;
midy = getmaxy() / 2;

/* set fill pattern */


setfillstyle(WIDE_DOT_FILL, getmaxcolor());

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

/* draw a filled ellipse */


fillellipse(3*midx/2, midy/2, xradius, yradius);
printf("\nIrregular boundaries, circle\n");
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nPress any key to continue\n");
getch();

/* clean up */
closegraph();

GRAPH3.C
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

void graph3(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
int stangle = 0, endangle = 180, radius = 100;

/* initialize graphics and local variables */


initgraph(&gdriver, &gmode, "");

/* read result of initialization */


errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}

midx = getmaxx() / 2;
midy = getmaxy() / 2;

/* set fill style and draw a pie slice */


setfillstyle(WIDE_DOT_FILL, getmaxcolor());
pieslice(3*midx/2, midy/2, stangle, endangle, radius);
printf("\nIrregular boundaries, semi-circle\n");
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nPress any key to continue\n");

/* clean up */
getch();
closegraph();

GRDBND.C
#include "header.h"

extern double grid_bound(double *s)


{
double upper=0, bottom=0, left=0, right=0 , tl=.1 ;
char sure='p';

/* entring grid boundaries */


printf("\nEnter grid boundaries one at a time:\n\nUpper boundary\n");
scanf("%lf",&upper);
s[0]=upper;

printf("\nBottom boundary\n");
scanf("%lf",&bottom);
s[1]=bottom;

printf("\nLeft boundary\n");
scanf("%lf",&left);
s[2]=left;

printf("\nRight boundary\n");
scanf("%lf",&right);
s[3]=right;

/* end of entring grid boundaries */

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

ex2();
do{
printf("\n\nEnter tolerance of answer \n");
scanf("%lf",&tl);

if(tl==0){
printf("\nTolerance Zero might take a while\n");
printf("\nAre you sure y/n\n");
sure='l';
sure=tolower(getche());}

else break;
}while(sure!='y');
tl=fabs(tl);

return tl;

GRDDIM.C
/* entring size of grid & mesh size */
#include "header.h"

extern void grid_dim(double *s, FILE *fp_grid_dim)


{
auto double horizontal=0, vertical=0, h=1, max=1;
auto double integer1, integer2, fraction1, fraction2, number1, number2 ;

do{
printf("\n\nEnter grid dimensions -regular boundaries-\n");
do{
printf("\nEnter grid horizontal length\n");
scanf("%lf",&horizontal);
if(horizontal==0)printf("\nYou must be joking, try again\n");
}while(horizontal==0);

do{
printf("\nEnter grid vertical length\n");
scanf("%lf",&vertical);
if(vertical==0)printf("\nYou must be joking, try again\n");
}while(vertical==0);

label5:
ex2();
printf("\nEnter mesh size -h-\n");
printf("PS: The grid dimensions must be an integer multiple of -h-\n");
printf(" The resulting # of mesh points that result should be <= 2500\n");
printf(" If not you will be prompted to re-enter grid dimensions\n");
scanf("%lf",&h);
if(h==0){
printf("\nYou must be joking, try again\n");
goto label5;}
number1=horizontal/h;
fraction1=modf(number1,&integer1);
number2=vertical/h;
fraction2=modf(number2,&integer2);
max=(integer1+1)*(integer2+1);
}while(!(fraction1==0 && fraction2==0 && max<=2500));

/*to save # of mesh points & h */


s[0]=integer1-1;
s[1]=integer2-1;
s[2]=h;

/* output grid dimensions to file */


fprintf(fp_grid_dim,"\nGrid dimensions -regular boundaries- as entered by user\n\n");
fprintf(fp_grid_dim,"Grid horizontal length is %-20.5lf\n", horizontal);
fprintf(fp_grid_dim,"Grid vertical length is %-20.5lf\n", vertical);
fprintf(fp_grid_dim,"Mesh size -h- is %-20.5lf\n\n", h);

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

HEADER.H
#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#include <graphics.h>
extern void ex2(void);

HEADER1.H
#define ROWS 50
#define COLUMNS 50
extern double array1[ROWS][COLUMNS];
extern double cdef[ROWS][COLUMNS];

HISHEAD.H
#define ROWS 50
#define COLUMNS 50
extern double array1[ROWS][COLUMNS];

HPBLC2DM.C
#include "header.h"
#include "hishead.h"

extern void hyperbolic_2dim(double *s1, FILE *fp_hyperbolic_2dim)


{
double box=0.0, box1=0.0 ;
double row, column ;
double *output, value, display, integer, fraction1, integer1 ;
int i, j, k, s, m, n ;
int count, count1 ;
char ch='\0' ;

row=(s1[9]+2);
column=(s1[8]+2);
count1=row*column;

do{
ex2();
printf("\nHow often do you want the results displayed (a multiple of the time increment)\n");
printf("The total # of displays that you previously entered must be an integer\n");
printf("multiple of this value, or the program will see to it that it is\n\n");

scanf("%lf", &display);
if(display==0.0 || display>s1[7])continue;
value=s1[7]/display;
modf(value, &integer);
s1[7]=integer*display;
value=display/1.0;
fraction1=modf(value, &integer1);
}while( fraction1!=0.0 || display==0.0 || display>s1[7]);

output=malloc(8*2*(s1[8]+2)*(s1[9]+2));
if(!output){
ex2();
printf("\nNot enough memory to allocate buffer\n");
/* terminate program if out of memory */
goto label33; }
count=(s1[8]+2);

box1=0.0;
printf("\nEnter initial values, u(x,y,0) as prompted\n");
printf("including values of boundary conditions at boundaries\n");
for(i=0; i<=s1[9]+1 ;++i){
ex2();
box=0.0;
for(j=0; j<=s1[8]+1 ;++j){
printf("\nEnter initial value at X= %-20.5lf Y= %-20.5lf\n", box, box1);
scanf("%lf", &value);
*(output+(i*count)+j)=value;
box=box+s1[1];}
box1=box1+s1[1];}

box1=0.0;
printf("\nEnter values of initial velocity, u'(x,y,0) as prompted\n");
for(i=0; i<=s1[9]+1 ;++i){
ex2();

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

box=0.0;
for(j=0; j<=s1[8]+1 ;++j){
printf("\nEnter initial velocity value at X= %-20.5lf Y= %-20.5lf\n", box, box1);
scanf("%lf", &value);
array1[i][j]=value;
box=box+s1[1];}
box1=box1+s1[1];}

ex2();
printf("\nThe # of internal mesh points used is %-20.0lf\n",s1[8]*s1[9]);
fprintf(fp_hyperbolic_2dim,"\nThe # of internal mesh points used is %-20.0lf\n",s1[8]*s1[9]);
printf("\n\nPress RETURN to continue\n");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

ex2();
box=0.0;
printf("The output at t= %-20.5lf proceeding from highest to lowest row\n",box);
for(i=s1[9]+1; i>=0 ;--i){
printf("\nFor row %-20d\n\n", i+1);
for(j=0; j<=s1[8]+1 ;++j){
printf("%-20.5lf",*(output+(i*count)+j) ); }

box=0.0;
fprintf(fp_hyperbolic_2dim,"The output at t= %-20.5lf proceeding from highest to lowest row\n",box);
for(i=s1[9]+1; i>=0 ;--i){
fprintf(fp_hyperbolic_2dim,"\nFor row %-20d\n\n", i+1);
for(j=0; j<=s1[8]+1 ;++j){
fprintf(fp_hyperbolic_2dim,"%-20.5lf",*(output+(i*count)+j) ); }
fprintf(fp_hyperbolic_2dim,"\n");}

printf("\n\nPress RETURN to continue\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }}

for(i=0 ; i<row ; ++i)


for(j=0 ; j<column ; ++j)*(output+count1+(i*count)+j)=*(output+(i*count)+j);

/* Now to use the Explicit method to solve our problem */


for(k=1; k<=integer ;++k){
for(s=1; s<=display ;++s){

for(i=1; i<row-1 ;++i){


for(j=1; j<column-1 ;++j){

if(k==1 && s==1 )


*(output+count1+(i*count)+j) = .25*( *(output+(i*count)+j-1) + *(output+(i*count)+j+1) +
*(output+((i+1)*count)+j) + *(output+((i-1)*count)+j) )+(s1[4]*array1[i][j]);

else
*(output+count1+(i*count)+j) = s1[2]*(*(output+(i*count)+j-
1)+*(output+(i*count)+j+1)+*(output+((i+1)*count)+j)+*(output+((i-1)*count)+j) ) - array1[i][j] + ((2-
(4*s1[2])) * *(output+(i*count)+j));
}}

for(m=1; m<row-1 ;++m)


for(n=1; n<column-1 ;++n) array1[m][n] = *(output+(m*count)+n);

for(m=1; m<row-1 ;++m)


for(n=1; n<column-1 ;++n) *(output+(m*count)+n) = *(output+count1+(m*count)+n);

if(s==display){
ex2();
printf("The output at t= %-20.5lf proceeding from highest to lowest row\n",s1[4]*k*display);
fprintf(fp_hyperbolic_2dim,"\n\n\nThe output at t= %-20.5lf proceeding from highest to lowest
row\n",s1[4]*k*display);
for(i=s1[9]+1; i>=0 ;--i){
printf("\n\nFor row %-20d\n\n", i+1);
fprintf(fp_hyperbolic_2dim,"\n\nFor row %-20d\n\n", i+1);
for(j=0; j<=s1[8]+1 ;++j){
printf("%-20.5e",*(output+(i*count)+j) );
fprintf(fp_hyperbolic_2dim,"%-20.5e",*(output+(i*count)+j) );}

printf("\n\nPress RETURN to continue\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; } } } }}

label33:
free(output);

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

HYPER1.C
#include "header.h"

extern void parabolic1(double *s1, int choice, FILE *fp_parabolic1)


{
double box=0.0, value, integer ;
double dummy, dummy1, integer1, fraction1 ;
double *output, savior ;
int i, j, k, l , m, n ;
int that, count ;
double aray[10] = {0}, aray1[10] = {0}, degree, degree1 ;
char ch='\0' ;

output=malloc(8*3*(s1[8]+2));
if(!output){
ex2();
printf("\nNot enough memory to allocate buffer\n");
/* terminate program if out of memory */
goto label33; }
count=s1[8]+2;

label7:
if(choice==1 || choice==2){
ex2();
printf("\nEnter function of initial velocity, G(x,0) as prompted\n");
printf("Enter degree of function\n");
scanf("%lf",&degree1);
if(degree1>9){
printf("\nDegree should be <= 9\n");
goto label7;}
printf("\nEnter coefficients of X, proceeding from const to highest degree");

for(k=0 ; k<=degree1 ; ++k){


printf("\nEnter coeff # %-5d\n",k+1);
scanf("%lf",&aray1[k]);}

for(j=1 ; j<=s1[8] ; ++j) *(output+j)=poly(s1[1]*j, degree1, aray1);}

else{
ex2();
box=s1[1];
printf("\nEnter values of initial velocity as prompted\n\n");
for(i=1; i<=s1[8] ;++i){
printf("\nEnter value at X= %-20.5lf\n", box);
scanf("%lf", &value);
*(output+i)=value;
box=box+s1[1];}}

if(choice==2 || choice==4){
label1:
ex2();
box=s1[1];
printf("\nEnter function of initial values, Y(x,0) as prompted\n");
printf("Enter degree of function\n");
scanf("%lf",&degree);
if(degree>9){
printf("\nDegree should be <= 9\n");
goto label1;}
printf("\nEnter coefficients of X, proceeding from const to highest degree");

for(k=0 ; k<=degree ; ++k){


printf("\nEnter coeff # %-5d\n",k+1);
scanf("%lf",&aray[k]);}

for(j=1 ; j<=s1[8] ; ++j) *(output+count+j)=poly(s1[1]*j, degree, aray);}

else{
ex2();
box=s1[1];
printf("\nEnter initial values, Y(x,0) as prompted\n");
for(i=1; i<=s1[8] ;++i){
printf("\nEnter initial value at X= %-20.5lf\n", box);
scanf("%lf", &value);
*(output+count+i)=value;
box=box+s1[1];}}

that=s1[8];
*(output+count)=s1[5];
*(output+count+that+1)=s1[6];

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

do{
ex2();
printf("\nAfter how many time increments do you want the results to be continuously\n");
printf("displayed ( a multiple of the time increment ), the total number of time \n");
printf("increments that you previously entered must be an integer multiple of this \n");
printf("value, otherwise the program will see to it that it is ....\n\n");
scanf("%lf", &value);
if(value==0.0 || value>s1[7])continue;
dummy=s1[7]/value;
modf(dummy, &integer);
s1[7]=integer*value;
dummy1=value/1.0;
fraction1=modf(dummy1, &integer1);
}while( fraction1!=0.0 || value==0.0 || value>s1[7]);

ex2();
printf("\nThe # of internal mesh points used is %-20.0lf\n",s1[8]);
fprintf(fp_parabolic1,"\nThe # of internal mesh points used is %-20.0lf\n",s1[8]);
printf("\n\n\nPress RETURN to continue\n");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

for(m=0; m<=that+1 ;++m) *(output+count+count+m)=*(output+count+m);

ex2();
box=0.0;
printf("\nThe output at t= %-20.6lf\n\n",box);
for(l=0; l<=s1[8]+1 ;++l)printf("%-20.5e",*(output+count+l));

box=0.0;
fprintf(fp_parabolic1,"\nThe output at t= %-20.6lf\n\n",box);
for(l=0; l<=s1[8]+1 ;++l)fprintf(fp_parabolic1,"%-20.5e",*(output+count+l));

printf("\n\nPress RETURN to continue\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

box=value*s1[4];
for(k=1; k<=integer ;++k){
for(i=1; i<=value ;++i){

for(j=1; j<=s1[8] ;++j){

if(i==1 && k==1)


*(output+count+count+j)= .5 * (*(output+count+j+1) + *(output+count+j-1)) + (*(output+j)*s1[4]);
else
*(output+count+count+j)= *(output+count+j+1) + *(output+count+j-1) - *(output+j); }

for(m=1; m<=that ;++m)*(output+m)=*(output+count+m);


for(m=1; m<=that ;++m)*(output+count+m)=*(output+count+count+m);

if(i==value){
printf("\nThe output at t= %-20.6lf\n\n",box);
for(l=0; l<=s1[8]+1 ;++l)printf("%-20.5e",*(output+count+l));
fprintf(fp_parabolic1,"\n\nThe output at t= %-20.6lf\n\n",box);
for(l=0; l<=s1[8]+1 ;++l)fprintf(fp_parabolic1,"%-20.5e",*(output+count+l));

printf("\n\nPress RETURN to continue\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

box=(k+1)*value*s1[4]; }
}}

label33:
free(output);
}

INITIAL.C
#include "header.h"
#include "hishead.h"

extern void initial(double *s1, double *s2)


{
double row, column, i, j ;
char ch='\0';

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

row=(s1[1]+2);
column=(s1[0]+2);
printf("rows=%-5.0f\ncolumns=%-5.0f\n",row,column);

/* calculating the average value of boundaries */


s2[4]=(s2[2]*s1[1]+s2[3]*s1[1]+s2[0]*s1[0]+s2[1]*s1[0]);
s2[4]=s2[4]+((s2[1]+s2[2])/2)+((s2[0]+s2[2])/2)+((s2[1]+s2[3])/2)+((s2[0]+s2[3])/2);
s2[4]=s2[4]/(2*(row+(column-2)));

/* giving all points in the array1 the average of the boundary value at first */
for(i=0 ; i<row ; ++i)
{for(j=0 ; j<column ; ++j) array1[i][j] = s2[4] ;}

/* fixing our initial conditions by entering the boundary values for


the boundary elements, but we will not use the 4 corner elements
in the five point app. */

for(i=0 ; i<row ; ++i) array1[i][0]=s2[2] ;


for(i=0 ; i<row ; ++i) array1[i][column-1]=s2[3] ;
for(j=0 ; j<column ; ++j) array1[0][j]=s2[1] ;
for(j=0 ; j<column ; ++j) array1[row-1][j]=s2[0] ;
array1[0][0]=(s2[1]+s2[2])/2 ;
array1[row-1][0]=(s2[0]+s2[2])/2 ;
array1[0][column-1]=(s2[1]+s2[3])/2 ;
array1[row-1][column-1]=(s2[0]+s2[3])/2 ;

/* to print out our initialized array1 */


printf("\nThe initialization of the array will look like this\n");
printf("From the upper to the lower side\n\n");
for(i=row-1 ; i>=0 ; --i){
printf("row # %-5.0f\n",i+1);
for(j=0 ; j<column ; ++j)
printf("%-20.5e",array1[i][j]);
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
printf("\n\n");}

JACOBI1P.C
#include "header.h"
#include "header1.h"

extern void jacobi1p(double *s1, double tl, FILE *fp_jacobi1p)


{
double row, column ;
double i, j , n , number;
char ch='\0';
double cde[ROWS][COLUMNS];

row=(s1[1]+2);
column=(s1[0]+2);

for(i=0 ; i<=row-1 ; ++i)


for(j=0 ; j<=column-1 ; ++j)
cde[i][j]=array1[i][j];

number=0;
do{
++number;
printf("\n# %-5.0f\n",number);
n=0;
for(i=1 ; i<row-1 ; ++i){
for(j=1 ; j<column-1 ; ++j){
cde[i][j]=array1[i][j];
array1[i][j]=.25*(cde[i+1][j]+cde[i-1][j]+cde[i][j+1]+cde[i][j-1]+(cdef[i][j]*s1[2]*s1[2]));
if((tl!=0.0) && (fabs(array1[i][j] - cde[i][j]) < tl) ) ++n ;
else if((tl==0.0) && (array1[i][j] == cde[i][j]) ) ++n; } }

}while(n!=((row-2)*(column-2)));

ex2();
printf("\nNumber of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
fprintf(fp_jacobi1p,"\nNumber of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
/* to print out our array1 */
printf("The array will look like this\n");
printf("From the upper to the lower side\n");

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

printf("\nrows= %-5.0lf",row);
printf("\ncolumns= %-5.0lf \n\n",column);
for(i=row-1 ; i>=0 ; --i){
printf("row # %-5.0lf\n",i+1);
for(j=0 ; j<column ; ++j)
printf("%-20.5e",array1[i][j]);
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
printf("\n\n");}

JACOBI2P.C
#include "header.h"
#include "header1.h"

extern void jacobi2p(double *s1, double tl, FILE *fp_jacobi2p)


{
double row, column ;
double i, j , n , number;
char ch='\0';
double cde[ROWS][COLUMNS];
row=(s1[1]+2);
column=(s1[0]+2);

for(i=0 ; i<=row-1 ; ++i)


for(j=0 ; j<=column-1 ; ++j)
cde[i][j]=array1[i][j];

number=0;
do{
++number;
printf("\n# %-5.0f\n",number);
n=0;
for(i=1 ; i<row-1 ; ++i){
for(j=1 ; j<column-1 ; ++j){
cde[i][j]=array1[i][j];
array1[i][j]=.05*4*(cde[i+1][j]+cde[i-1][j]+cde[i][j+1]+cde[i][j-1]);
array1[i][j]=array1[i][j]+(.05*(cde[i-1][j-1]+cde[i-1][j+1]+cde[i+1][j-1]+cde[i+1][j+1]));
array1[i][j]=array1[i][j]+(.05*6*s1[2]*s1[2]*cdef[i][j]);
if((tl!=0.0) && (fabs(array1[i][j] - cde[i][j]) < tl) ) ++n ;
else if((tl==0.0) && (array1[i][j] == cde[i][j]) ) ++n; }
}
}while(n!=((row-2)*(column-2)));

ex2();
printf("\nNumber of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
fprintf(fp_jacobi2p,"\nNumber of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
/* to print out our array1 */
printf("The array will look like this\n");
printf("From the upper to the lower side\n");
printf("\nrows= %-5.0lf",row);
printf("\ncolumns= %-5.0lf \n\n",column);
for(i=row-1 ; i>=0 ; --i){
printf("row # %-5.0lf\n",i+1);
for(j=0 ; j<column ; ++j)
printf("%-20.5e",array1[i][j]);
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
printf("\n\n");}

MAIN.C
#include "header.h"

extern void main2(FILE *fp2);


extern void main3(FILE *fp3);
extern void main4(FILE *fp4);
extern int type4(FILE *fp_type4);
extern void password(char *p1);
extern void ex1(void);
extern void time1(FILE *fp_time1);

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

int main(void)
{
char sure, answer ;
char password1[6] ;
int t, j1;
FILE *fp, *fp1;

ex1();
password(password1);
if(password1[0]!='8' || password1[1]!='3' || password1[2]!='0' || password1[3]!='0' || password1[4]!='7' ||
password1[5]!='5'){
printf("\nIncorrect Password\n");
printf("Get the Password right and try again");
goto label1;}
do{
if((fp=fopen("pdefile.out","a+t")) == NULL){
ex2();
puts("Cannot open a file to store your results in");
puts("Write protected disk or disk is full");
puts("\nSolve this problem and try again");
fprintf(stderr, "Cannot open input file.\n");
goto label1;}

if((fp1=fopen("test.out","w")) == NULL){
ex2();
puts("Cannot append to the open file to store your results in");
puts("Write protected disk or disk is full");
puts("\nSolve this problem and try again");
goto label1;}

fclose(fp1);
remove("test.out");

ex2();
t=type4(fp);
switch(t){
case 1:
main2(fp);
break;
case 2:
main3(fp);
break;
case 3:
main4(fp);
break;}
time1(fp);
fprintf(fp,"\nThank you for using Kutkut's Numerical PDE Solver\n");
fprintf(fp,"February, 1994 Amman - Jordan\n\n");
for (j1=0; j1<80; j1++)fprintf(fp,"*");
fclose(fp);

do{
printf("\n\nWould you like to Run this program once again y/n \n");
sure='p';
sure=tolower(getche());
if(sure=='n')break;
}while(sure!='y');

}while(sure=='y');

label1:

printf("\n\nThank you for using Kutkut's Numerical PDE Solver\n");


printf("February, 1994 Amman - Jordan\n\n");

return (0) ;

MAIN1.C
#include "header.h"

extern void mixed1(double *s1, int type5, FILE *fp_mixed1);


extern void mixed2(double *s1, int type5, FILE *fp_mixed2);
extern int type(FILE *fp_type);
extern int type5(FILE *fp_type5);
extern void mixed3(double *s1, int type5, FILE *fp_mixed3);
extern int method_soln(FILE *fp_method_soln);
extern void poissonf(double *s1);
extern void grid_dim(double *s, FILE *fp_grid_dim);
extern void poisson3(double *s1);

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

extern void main1(int choice_elliptic1, FILE *fp_main1) {

int type1, type2;


double grid_dimension[3];

ex2();
switch(choice_elliptic1){
case 3:
type1=type5(fp_main1);
break;
case 4:
type1=type(fp_main1);
break;}

ex2();
grid_dim(grid_dimension, fp_main1);

if(type1==5 || type1==6){
ex2();
poisson3(grid_dimension); }

switch(type1){
case 2:
case 4:
ex2();
poissonf(grid_dimension);

case 5:
case 6:
case 1:
case 3:
ex2();
type2=method_soln(fp_main1);
switch(type2){
case 1:
ex2();
mixed2(grid_dimension, type1, fp_main1);
break;
case 2:
ex2();
mixed1(grid_dimension, type1, fp_main1);
break;
case 3:
ex2();
mixed3(grid_dimension, type1, fp_main1);
break; }}

MAIN2.C
#include "header.h"
#include "myhead.h"

extern double grid_bound(double *s);


extern void grid_dim(double *s, FILE *fp_grid_dim);
extern void dimension(double *dimn, FILE *fp_dimension);
extern void initial(double *s1, double *s2);
extern int method(FILE *fp_method);
extern int eqn(FILE *fp_eqn);
extern int eqn1(FILE *fp_eqn1);
extern double poisson1(double *s1);
extern double bndry2(double *s1);
extern void poissonf(double *s1);
extern void jacobi1p(double *s1, double tl, FILE *fp_jacobi1p);
extern void jacobi2p(double *s1, double tl, FILE *fp_jacobi2p);
extern void gaus_seidel1p(double *s1, double tl, FILE *fp_gaus_seidel1p);
extern void gaus_seidel2p(double *s1, double tl, FILE *fp_gaus_seidel2p);
extern void sor1p(double *s1, double tl, FILE *fp_sor1p);
extern void sor2p(double *s1, double tl, FILE *fp_sor2p);
extern void sor3p(double *s1, double tl, FILE *fp_sor3p);
extern void sor4p(double *s1, double tl, FILE *fp_sor4p);
extern int choice_dnm(FILE *fp_elliptic);
extern void main1(int choice_elliptic1, FILE *fp_main1);
extern void adi2(double *s1, double tl, FILE *fp_adi2);
extern void adi1(double *s1, double tl, FILE *fp_adi1);
extern void semi_circle3(int choice1, FILE *fp_semi_circle3);
extern void semi_circle4(int choice1, FILE *fp_semi_circle4);
extern void circle3(int choice1, FILE *fp_circle3);
extern void circle4(int choice1, FILE *fp_circle4);
extern void note(FILE *fp_note);
extern double points(double *s1);
extern void adi3(double *s1, double tl, FILE *fp_adi3);

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

extern void graph2(void);


extern void graph3(void);
extern void poisson2(double *s1);

extern void main2(FILE *fp2)


{
double grid_boundary[5], grid_dimension[3], row, column ;
double tolerance, i, j ;
int choice, choice_elliptic , method1, choice2 ;

ex2();
choice_elliptic = choice_dnm(fp2) ;
switch(choice_elliptic){
case 1:
clrscr();
choice=eqn(fp2);
ex2();
note(fp2);
switch(choice){
case 1:
case 2:
case 3:
case 4:
ex2();
grid_dim(grid_dimension, fp2);
if(choice==2 || choice==4){ex2();
poisson1(grid_dimension);}
if(choice==1 || choice==2){
ex2();
tolerance=grid_bound(grid_boundary);
ex2();
dimension(grid_dimension, fp2);
ex2();
initial(grid_dimension, grid_boundary);}
else{
ex2();
tolerance=bndry2(grid_dimension);
ex2();
dimension(grid_dimension, fp2); }
break;
case 5:
case 6:
ex2();
grid_dim(grid_dimension, fp2);

if(choice==5){
ex2();
tolerance=grid_bound(grid_boundary);
ex2();
poissonf(grid_dimension);
ex2();
dimension(grid_dimension, fp2);
ex2();
initial(grid_dimension, grid_boundary);
break;}
else{
ex2();
tolerance=bndry2(grid_dimension);
ex2();
poissonf(grid_dimension);
ex2();
dimension(grid_dimension, fp2); }
break;
case 7:
ex2();
grid_dim(grid_dimension, fp2);
ex2();
tolerance=points(grid_dimension);
ex2();
dimension(grid_dimension, fp2);
break;
case 8:
case 9:
case 10:
ex2();
grid_dim(grid_dimension, fp2);
ex2();
if(choice==9)poissonf(grid_dimension);
else if(choice==10)poisson2(grid_dimension);
else poisson1(grid_dimension);
ex2();
tolerance=points(grid_dimension);
ex2();
dimension(grid_dimension, fp2);
break; }

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

clrscr();
method1=method(fp2);
switch(method1){

case 1:
jacobi1p(grid_dimension, tolerance, fp2);
break;
case 2:
gaus_seidel1p(grid_dimension, tolerance, fp2);
break;
case 3:
jacobi2p(grid_dimension, tolerance, fp2);
break;
case 4:
gaus_seidel2p(grid_dimension, tolerance, fp2);
break;
case 5:
sor2p(grid_dimension, tolerance, fp2);
break;
case 6:
sor1p(grid_dimension, tolerance, fp2);
break;
case 7:
sor4p(grid_dimension, tolerance, fp2);
break;
case 8:
sor3p(grid_dimension, tolerance, fp2);
break;
case 9:
adi2(grid_dimension, tolerance, fp2);
break;
case 10:
adi1(grid_dimension, tolerance, fp2);
break;
case 11:
adi3(grid_dimension, tolerance, fp2);
break;}

row=(grid_dimension[1]+2);
column=(grid_dimension[0]+2);

fprintf(fp2,"The array will look like this\n");


fprintf(fp2,"From the upper to the lower side\n");
fprintf(fp2,"\nrows= %-5.0lf",row);
fprintf(fp2,"\ncolumns= %-5.0lf \n\n",column);
for(i=row-1 ; i>=0 ; --i){
fprintf(fp2,"row # %-5.0lf\n",i+1);
for(j=0 ; j<column ; ++j)
fprintf(fp2,"%-20.5e",array1[i][j]);
fprintf(fp2,"\n\n");}
break;

case 2:
clrscr();
choice2=eqn1(fp2);

if(choice2==1 || choice2==5 || choice2==2 || choice2==6)graph3();


else graph2();

ex2();
note(fp2);
switch(choice2){
case 1:
case 5:
ex2();
semi_circle3(choice2, fp2);
break;
case 2:
case 6:
ex2();
semi_circle4(choice2, fp2);
break;
case 3:
case 7:
ex2();
circle3(choice2, fp2);
break;
case 4:
case 8:
ex2();
circle4(choice2, fp2);
break; }break;

case 3:

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

case 4: main1(choice_elliptic, fp2);


}

MAIN3.C
#include "header.h"

extern void enter1(double *s1, int choice, double *dff1, FILE *fp_enter1);
extern void explicit2(double *s1, int choice, FILE *fp_explicit2);
extern int eqn_parabolic(FILE *fp_eqn_parabolic);
extern void crank2(double *s1, int choice, FILE *fp_crank2);
extern void note1(FILE *fp_note1);
extern void explicit3(double *s1, int choice, double *dff1, FILE *fp_explicit3);
extern void crank3(double *s1, int choice, double *dff1, FILE *fp_crank3);
extern void enter2(double *s1, FILE *fp_enter2);
extern void adip(double *s1, FILE *fp_adip);
extern void graph1(void);

extern void main3(FILE *fp3)


{
double boundaries[10] , derivative[4];
int choicep;

note1(fp3);
choicep=eqn_parabolic(fp3);
if(choicep<=8)enter1(boundaries, choicep, derivative, fp3);
else graph1();

switch(choicep){
case 1:
explicit2(boundaries, choicep, fp3);
break;
case 2:
explicit2(boundaries, choicep, fp3);
break;
case 3:
crank2(boundaries, choicep, fp3);
break;
case 4:
crank2(boundaries, choicep, fp3);
break;
case 5:
explicit3(boundaries, choicep, derivative, fp3);
break;
case 6:
explicit3(boundaries, choicep, derivative, fp3);
break;
case 7:
crank3(boundaries, choicep, derivative, fp3);
break;
case 8:
crank3(boundaries, choicep, derivative, fp3);
break;
case 9:
enter2(boundaries, fp3);
adip(boundaries, fp3);
break;}

MAIN4.C
#include "header.h"

extern void enterh(double *s1, FILE *fp_enterh);


extern int eqn_hyperbolic(FILE *fp_eqn_hyperbolic);
extern void parabolic1(double *s1, int choice, FILE *fp_parabolic1);
extern void note2(FILE *fp_note2);
extern void hyperbolic_2dim(double *s1, FILE *fp_hyperbolic_2dim);
extern void enter2_hyperbolic(double *s1, FILE *fp_enter2_hyperbolic);
extern void graph1(void);

extern void main4(FILE *fp4)


{
double boundaries[10] , derivative[4];
int choicep;

note2(fp4);
choicep=eqn_hyperbolic(fp4);

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

if(choicep<=4)enterh(boundaries, fp4);
else {
graph1();
enter2_hyperbolic(boundaries, fp4);}

switch(choicep){
case 1:
case 2:
case 3:
case 4:
parabolic1(boundaries, choicep, fp4);
break;
case 5:
hyperbolic_2dim(boundaries, fp4);
break;}

METHOD.C
#include "header.h"

extern int method(FILE *fp_method)


{
int choice=0;
char ch='\0';

do{
printf("\n\nEnter the # associated with the method you would like to use\n");
printf("for solving the eqn with Dirichlet conditions\n\n\n\n");

printf("1 : Jacobi iterative method for solving systems of eqs\n");


printf(" using 5 point approximation \n\n");

printf("2 : Gauss-Seidel iterative method for solving systems of eqs\n");


printf(" Liebmann's Method - using 5 point approximation \n\n");

printf("3 : Jacobi iterative method for solving systems of eqs\n");


printf(" using 9 point approximation \n\n");

printf("4 : Gauss-Seidel iterative method for solving systems of eqs\n");


printf(" Liebmann's Method - using 9 point approximation \n\n");

printf("5 : Successive Overrelaxation method, the user entering his/her S.O.R. factor\n");
printf(" using 5 point approximation \n\n");

printf("\n\nPress RETURN to show more options");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

clrscr();
printf("\n\nEnter the # associated with the method you would like to use\n");
printf("for solving the eqn with Dirichlet conditions\n\n\n");

printf("6 : Successive Overrelaxation method using an optimum S.O.R. factor\n");


printf(" using 5 point approximation \n\n");

printf("7 : Successive Overrelaxation method, the user entering his/her S.O.R. factor\n");
printf(" using 9 point approximation \n\n");

printf("8 : Successive Overrelaxation method using an optimum S.O.R. factor\n");


printf(" using 9 point approximation \n\n");

printf("9 : using the alternating-direction implicit method (A.D.I.) without P factor\n\n");

printf("10: using the alternating-direction implicit method (A.D.I.) with the user \n");
printf(" entering his/her P factor\n\n");

printf("11: using the alternating-direction implicit method (A.D.I.) with optimum\n");


printf(" P factor\n\n\n");

printf("Your choice ");


scanf("%d", &choice);
}while(choice<1 || choice>11);

ex2();
printf("\nYour choice was\n\n");
switch(choice){
case 1:
printf("1 : Jacobi iterative method for solving systems of eqs\n");

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

printf(" using 5 point approximation \n\n");


break;
case 2:
printf("2 : Gauss-Seidel iterative method for solving systems of eqs\n");
printf(" Liebmann's Method - using 5 point approximation \n\n");
break;
case 3:
printf("3 : Jacobi iterative method for solving systems of eqs\n");
printf(" using 9 point approximation \n\n");
break;
case 4:
printf("4 : Gauss-Seidel iterative method for solving systems of eqs\n");
printf(" Liebmann's Method - using 9 point approximation \n\n");
break;
case 5:
printf("5 : Successive Overrelaxation method, the user entering his/her S.O.R.
factor\n");
printf(" using 5 point approximation \n\n");
break;
case 6:
printf("6 : Successive Overrelaxation method using an optimum S.O.R. factor\n");
printf(" using 5 point approximation \n\n");
break;
case 7:
printf("7 : Successive Overrelaxation method, the user entering his/her S.O.R.
factor\n");
printf(" using 9 point approximation \n\n");
break;
case 8:
printf("8 : Successive Overrelaxation method using an optimum S.O.R. factor\n");
printf(" using 9 point approximation \n\n");
break;
case 9:
printf("9 : using the alternating-direction implicit method (A.D.I.) without P
factor\n\n");
break;
case 10:
printf("10: using the alternating-direction implicit method (A.D.I.) with the user
\n");
printf(" entering his/her P factor\n\n");
break;
case 11:
printf("11: using the alternating-direction implicit method (A.D.I.) with optimum\n");
printf(" P factor\n\n");
break;}

fprintf(fp_method,"\nYour choice was\n\n");


switch(choice){
case 1:
fprintf(fp_method,"1 : Jacobi iterative method for solving systems of eqs\n");
fprintf(fp_method," using 5 point approximation \n\n");
break;
case 2:
fprintf(fp_method,"2 : Gauss-Seidel iterative method for solving systems of eqs\n");
fprintf(fp_method," Liebmann's Method - using 5 point approximation \n\n");
break;
case 3:
fprintf(fp_method,"3 : Jacobi iterative method for solving systems of eqs\n");
fprintf(fp_method," using 9 point approximation \n\n");
break;
case 4:
fprintf(fp_method,"4 : Gauss-Seidel iterative method for solving systems of eqs\n");
fprintf(fp_method," Liebmann's Method - using 9 point approximation \n\n");
break;
case 5:
fprintf(fp_method,"5 : Successive Overrelaxation method, the user entering his/her
S.O.R. factor\n");
fprintf(fp_method," using 5 point approximation \n\n");
break;
case 6:
fprintf(fp_method,"6 : Successive Overrelaxation method using an optimum S.O.R.
factor\n");
fprintf(fp_method," using 5 point approximation \n\n");
break;
case 7:
fprintf(fp_method,"7 : Successive Overrelaxation method, the user entering his/her
S.O.R. factor\n");
fprintf(fp_method," using 9 point approximation \n\n");
break;
case 8:
fprintf(fp_method,"8 : Successive Overrelaxation method using an optimum S.O.R.
factor\n");
fprintf(fp_method," using 9 point approximation \n\n");
break;
case 9:

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

fprintf(fp_method,"9 : using the alternating-direction implicit method (A.D.I.)


without P factor\n\n");
break;
case 10:
fprintf(fp_method,"10: using the alternating-direction implicit method (A.D.I.) with
the user \n");
fprintf(fp_method," entering his/her P factor\n\n");
break;
case 11:
fprintf(fp_method,"11: using the alternating-direction implicit method (A.D.I.) with
optimum\n");
fprintf(fp_method," P factor\n\n");
break;}

printf("Press RETURN to continue\n\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

return choice;
}

METHOD5.C
#include "header.h"

extern int method_soln(FILE *fp_method_soln)


{
int choice, ch ;

do{
printf("Enter the # associated with the method you would like to use\n");
printf("for solving your Problem\n\n");

printf("1: Jacobi iterative method for solving systems of eqs\n");


printf(" using 5 point approximation method\n\n");

printf("2: Gauss-Seidel iterative method for solving systems of eqs\n");


printf(" Liebmann's Method - using 5 point approximation method\n\n");

printf("3: Successive Overrelaxation method using an optimum S.O.R. factor\n");


printf(" using 5 point approximation method\n\n");

printf("Your choice ");


scanf("%d", &choice);
}while(choice<1 || choice>3);

ex2();
printf("\n\nYour choice was\n\n");
switch(choice){
case 1:
printf("1: Jacobi iterative method for solving systems of eqs\n");
printf(" using 5 point approximation method\n\n");
break;
case 2:
printf("2: Gauss-Seidel iterative method for solving systems of eqs\n");
printf(" Liebmann's Method - using 5 point approximation method\n\n");
break;
case 3:
printf("3: Successive Overrelaxation method using an optimum S.O.R factor\n");
printf(" using 5 point approximation method\n\n");
break;}

fprintf(fp_method_soln,"\n\nYour choice was\n\n");


switch(choice){
case 1:
fprintf(fp_method_soln,"1: Jacobi iterative method for solving systems of eqs\n");
fprintf(fp_method_soln," using 5 point approximation method\n\n");
break;
case 2:
fprintf(fp_method_soln,"2: Gauss-Seidel iterative method for solving systems of
eqs\n");
fprintf(fp_method_soln," Liebmann's Method - using 5 point approximation
method\n\n");
break;
case 3:
fprintf(fp_method_soln,"3: Successive Overrelaxation method using an optimum S.O.R
factor\n");
fprintf(fp_method_soln," using 5 point approximation method\n\n");
break;}

printf("Press RETURN to continue\n\n");

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

return choice;
}

MIXED1.C
#include "header.h"
#include "header1.h"

extern void mixed1(double *s1, int type5, FILE *fp_mixed1)


{
double aray1[10] = {0}, aray2[10] = {0}, dff1[4] = {0};
double aray3[10] = {0}, aray4[10] = {0};
double bd1[2][51] = {0}, bd2[2][51] = {0};
double row, column, i, j, total_size ;
char ch='\0';
double degree1, degree2, degree3, degree4, k, tl=.01;
char sure='p', answer='l' ;
double mesh_points=0;
double value=0 ,number, n, initial1, initial2, end1, end2, savior ;

label1:
do {
printf("Left boundary\n\n");
printf("will this boundary be expressed as a normal derivative y/n \n");
answer=getche();
if(answer=='y')dff1[0]=1;
}while(!(answer=='y' || answer=='n'));

printf("\n\nEnter left boundary as a function of Y\n");


printf("Enter degree of function\n");
scanf("%lf",&degree1);
if(degree1>9){
printf("\nDegree should be <= 9\n");
goto label1;}
printf("\nEnter coefficients of Y, proceeding from const to highest degree");
for(k=0 ; k<=degree1 ; ++k){
printf("\nEnter coeff # %-5.0lf\n",k+1);
scanf("%lf",&aray1[k]);}

ex2();
answer='l';
do {
printf("Right boundary\n\n");
printf("will this boundary be expressed as a normal derivative y/n \n");
answer=getche();
if(answer=='y')dff1[1]=1;
}while(!(answer=='y' || answer=='n'));

printf("\n\nEnter right boundary as a function of Y\n");


printf("Enter degree of function\n");
scanf("%lf",&degree2);
if(degree2>9){
printf("\nDegree should be <= 9\n");
goto label1;}
printf("\nEnter coefficients of Y, proceeding from const to highest degree");
for(k=0 ; k<=degree2 ; ++k){
printf("\nEnter coeff # %-5.0lf\n",k+1);
scanf("%lf",&aray2[k]);}

ex2();
answer='l';
do {
printf("Upper boundary\n\n");
printf("will this boundary be expressed as a normal derivative y/n \n");
answer=getche();
if(answer=='y')dff1[2]=1;
}while(!(answer=='y' || answer=='n'));

printf("\n\nEnter upper boundary as a function of X\n");


printf("Enter degree of function\n");
scanf("%lf",&degree3);
if(degree3>9){
printf("\nDegree should be <= 9\n");
goto label1;}
printf("\nEnter coefficients of X, proceeding from const to highest degree");
for(k=0 ; k<=degree3 ; ++k){
printf("\nEnter coeff # %-5.0lf\n",k+1);
scanf("%lf",&aray3[k]);}

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

ex2();
answer='l';
do {
printf("Lower boundary\n\n");
printf("will this boundary be expressed as a normal derivative y/n \n");
answer=getche();
if(answer=='y')dff1[3]=1;
}while(!(answer=='y' || answer=='n'));

printf("\n\nEnter lower boundary as a function of X\n");


printf("Enter degree of function\n");
scanf("%lf",&degree4);
if(degree4>9){
printf("\nDegree should be <= 9\n");
goto label1;}
printf("\nEnter coefficients of X, proceeding from const to highest degree");
for(k=0 ; k<=degree4 ; ++k){
printf("\nEnter coeff # %-5.0lf\n",k+1);
scanf("%lf",&aray4[k]);}

if((dff1[0]+dff1[1]+dff1[2]+dff1[3]!=4)&&(type5==1||type5==2)){
ex2();
printf("\nThe four boundaries were not expressed as derivatives\n");
printf("And you selected ( solving a Neumann Problem ), when the four\n");
printf("boundaries are expressed as derivatives then the Elliptic eqn\n");
printf("is a Second Order Boundary Value Problem or a Neumann Problem\n");
printf("You have a Problem with Nomenclature, be careful !!!\n\n");
printf("I will continue solving your Mixed Problem \n\n");
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

fprintf(fp_mixed1,"\nThe four boundaries were not expressed as derivatives\n");


fprintf(fp_mixed1,"And you selected ( solving a Neumann Problem ), when the four\n");
fprintf(fp_mixed1,"boundaries are expressed as derivatives then the Elliptic eqn\n");
fprintf(fp_mixed1,"is a Second Order Boundary Value Problem or a Neumann Problem\n");
fprintf(fp_mixed1,"You have a Problem with Nomenclature, be careful !!!\n\n");
fprintf(fp_mixed1,"I will continue solving your Mixed Problem \n\n");}

else if((dff1[0]+dff1[1]+dff1[2]+dff1[3]==4)&&(type5==3||type5==4)){
ex2();
printf("\nThe four boundaries were expressed as derivatives\n");
printf("And you selected ( solving a Mixed Problem ), when the four\n");
printf("boundaries are expressed as derivatives then the Elliptic eqn\n");
printf("is a Second Order Boundary Value Problem or a Neumann Problem\n");
printf("You have a Problem with Nomenclature, be careful !!!\n\n");
printf("I will continue solving your four derivative bounded Problem (Neumann)\n\n");
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

fprintf(fp_mixed1,"\nThe four boundaries were expressed as derivatives\n");


fprintf(fp_mixed1,"And you selected ( solving a Mixed Problem ), when the four\n");
fprintf(fp_mixed1,"boundaries are expressed as derivatives then the Elliptic eqn\n");
fprintf(fp_mixed1,"is a Second Order Boundary Value Problem or a Neumann Problem\n");
fprintf(fp_mixed1,"You have a Problem with Nomenclature, be careful !!!\n\n");
fprintf(fp_mixed1,"I will continue solving your four derivative bounded Problem (Neumann)\n\n");}

else if(dff1[0]+dff1[1]+dff1[2]+dff1[3]==0){
ex2();
printf("\nNone of The four boundaries were expressed as normal derivatives\n");
printf("When none of the boundaries are expressed as normal deivatives then\n");
printf("The Elliptic eqn\n");
printf("is a First Order Boundary Value Problem or a Dirichlet Problem\n");
printf("You have a Problem with Nomenclature, be careful !!!\n\n");
printf("I will continue solving your ( Dirichlet Problem )\n\n");
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

fprintf(fp_mixed1,"\nNone of The four boundaries were expressed as normal derivatives\n");


fprintf(fp_mixed1,"When none of the boundaries are expressed as normal deivatives then\n");
fprintf(fp_mixed1,"The Elliptic eqn\n");
fprintf(fp_mixed1,"is a First Order Boundary Value Problem or a Dirichlet Problem\n");
fprintf(fp_mixed1,"You have a Problem with Nomenclature, be careful !!!\n\n");
fprintf(fp_mixed1,"I will continue solving your ( Dirichlet Problem )\n\n");}

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

ex2();
do{
printf("\n\nEnter tolerance of answer \n");
scanf("%lf",&tl);
if(tl==0){
printf("\nTolerance Zero might take a while\n");
printf("\nAre you sure y/n\n");
sure=tolower(getche());}
else break;

}while(sure!='y');

tl=fabs(tl);

row=(s1[1]+2);
column=(s1[0]+2);

ex2();
printf("\nNow you should enter the boundary values at the corners of the shape\n\n");
printf("Be careful and enter them accurately, they affect the results\n\n");
printf("\nLower left corner\n");
scanf("%lf",&array1[0][0]);
printf("\nUpper left corner\n");
scanf("%lf",&array1[row-1][0]);
printf("\nLower right corner\n");
scanf("%lf",&array1[0][column-1]);
printf("\nUpper right corner\n");
scanf("%lf",&array1[row-1][column-1]);

/* Evaluating the values of the boundaries at each point */


/* Note that the loop always starts from zero since the corner */
/* points are not included in the main loop */
if(dff1[0]==0){
for(i=1 ; i<(row-1) ; ++i)
array1[i][0] =poly(s1[2]*i, degree1, aray1 );}
else{
for(i=1 ; i<(row-1) ; ++i)
bd1[0][i] =poly(s1[2]*i, degree1, aray1 );}

if(dff1[1]==0){
for(i=1 ; i<(row-1) ; ++i)
array1[i][column-1]= poly(s1[2]*i, degree2, aray2 );}
else{
for(i=1 ; i<(row-1) ; ++i)
bd1[1][i] = poly(s1[2]*i, degree2, aray2 );}

if(dff1[2]==0){
for(j=1 ; j<(column-1) ; ++j)
array1[row-1][j] = poly(s1[2]*j, degree3, aray3 );}
else{
for(j=1 ; j<(column-1) ; ++j)
bd2[0][j] = poly(s1[2]*j, degree3, aray3 );}

if(dff1[3]==0){
for(j=1 ; j<(column-1) ; ++j)
array1[0][j] = poly(s1[2]*j, degree4, aray4);}
else{
for(j=1 ; j<(column-1) ; ++j)
bd2[1][j] = poly(s1[2]*j, degree4, aray4);}

ex2();
printf("\nTo what value would you like to initialize the internal mesh points\n");
printf("\nEnter the value\n");
scanf("%lf",&value);

/* initializing the internal mesh points with the given value */


for(i=1 ; i<(row-1) ; ++i)
{for(j=1 ; j<(column-1) ; ++j) array1[i][j] = value ;}

/* Internal # of mesh points */


mesh_points=s1[0]*s1[1]+dff1[0]*s1[1]+dff1[1]*s1[1]+dff1[2]*s1[0]+dff1[3]*s1[0];

/* Total mesh points used in calculations */


total_size=(2*(s1[0]+s1[1]))+(s1[0]*s1[1])+(dff1[0]*s1[1]+dff1[1]*s1[1]+dff1[2]*s1[0]+dff1[3]*s1[0]);

if(dff1[0]+dff1[1]+dff1[2]+dff1[3]==0)total_size=total_size;
else if(dff1[0]+dff1[1]+dff1[2]+dff1[3]==1)total_size=total_size+2;
else if(dff1[0]+dff1[1]+dff1[2]+dff1[3]>=3)total_size=total_size+4;
else if(dff1[0]==1&&dff1[3]==1&&dff1[2]==0&&dff1[1]==0)total_size=total_size+3;
else if(dff1[0]==1&&dff1[2]==1&&dff1[3]==0&&dff1[1]==0)total_size=total_size+3;
else if(dff1[1]==1&&dff1[3]==1&&dff1[2]==0&&dff1[0]==0)total_size=total_size+3;
else if(dff1[1]==1&&dff1[2]==1&&dff1[0]==0&&dff1[3]==0)total_size=total_size+3;
else if(dff1[0]+dff1[1]+dff1[2]+dff1[3]>=2)total_size=total_size+4;

ex2();

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

printf("\nThe number of internal mesh points is %-10.0lf\n",mesh_points);


printf("\nThe number of total mesh points used in calculatios including fictious\n");
printf("when present is %-10.0lf\n\n",total_size);

fprintf(fp_mixed1,"\nThe number of internal mesh points is %-10.0lf\n",mesh_points);


fprintf(fp_mixed1,"\nThe number of total mesh points used in calculatios including fictious\n");
fprintf(fp_mixed1,"when present is %-10.0lf\n\n",total_size);

printf("\nPress RETURN to continue");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

if(dff1[0]==1)initial2=0;
else initial2=1;
if(dff1[1]==1)end2=column;
else end2=column-1;
if(dff1[2]==1)end1=row;
else end1=row-1;
if(dff1[3]==1)initial1=0;
else initial1=1;

number=0;
do{
++number;
printf("\n# %-5.0lf\n",number);
n=0;
for(i=initial1 ; i<end1 ; ++i){
for(j=initial2 ; j<end2 ; ++j){
if((i==0&&j==0)||(i==row-1&&j==0)||(i==0&&j==column-1)||(i==row-1&&j==column-1))
continue;
savior=array1[i][j];
if(j==0){
array1[i][j]=.25*(array1[i+1][j]+array1[i-1][j]+(2*array1[i][j+1])-
(2*s1[2]*bd1[0][i])+(cdef[i][j]*s1[2]*s1[2]));}
else if(j==(column-1)){
array1[i][j]=.25*(array1[i+1][j]+array1[i-1][j]+(2*array1[i][j-
1])+(2*s1[2]*bd1[1][i])+(cdef[i][j]*s1[2]*s1[2]));}
else if(i==(row-1)){
array1[i][j]=.25*((2*array1[i-1][j])+array1[i][j+1]+array1[i][j-
1]+(2*s1[2]*bd2[0][j])+(cdef[i][j]*s1[2]*s1[2]));}
else if(i==0){
array1[i][j]=.25*((2*array1[i+1][j])+array1[i][j+1]+array1[i][j-1]-
(2*s1[2]*bd2[1][j])+(cdef[i][j]*s1[2]*s1[2]));}
else
array1[i][j]=.25*(array1[i+1][j]+array1[i-1][j]+array1[i][j+1]+array1[i][j-
1]+(cdef[i][j]*s1[2]*s1[2]));
if((tl==0) && (array1[i][j] == savior) ) ++n;
else if((tl!=0) && (fabs(array1[i][j] - savior) < tl) ) ++n ; }
}
}while(n!=(mesh_points));

ex2();
printf("\nNumber of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
/* to print out our array1 */
printf("The array will look like this\n");
printf("From the upper to the lower side\n");
printf("\nrows= %-5.0lf",row);
printf("\ncolumns= %-5.0lf \n\n",column);
for(i=row-1 ; i>=0 ; --i){
printf("row # %-5.0lf\n",i+1);
for(j=0 ; j<column ; ++j)
printf("%-20.5e",array1[i][j]);
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
printf("\n\n");}

fprintf(fp_mixed1,"\nNumber of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);


/* to print out our array1 */
fprintf(fp_mixed1,"The array will look like this\n");
fprintf(fp_mixed1,"From the upper to the lower side\n");
fprintf(fp_mixed1,"\nrows= %-5.0lf",row);
fprintf(fp_mixed1,"\ncolumns= %-5.0lf \n\n",column);
for(i=row-1 ; i>=0 ; --i){
fprintf(fp_mixed1,"row # %-5.0lf\n",i+1);
for(j=0 ; j<column ; ++j)
fprintf(fp_mixed1,"%-20.5e",array1[i][j]);
fprintf(fp_mixed1,"\n\n");}

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

MIXED2.C
#include "header.h"
#include "header1.h"

extern void mixed2(double *s1, int type5, FILE *fp_mixed2)


{
double aray1[10] = {0}, aray2[10] = {0}, dff1[4] = {0};
double aray3[10] = {0}, aray4[10] = {0};
double bd1[2][51] = {0}, bd2[2][51] = {0};
double row, column, i, j, total_size ;
char ch='\0';
double degree1, degree2, degree3, degree4, k, tl=.01;
char sure='p', answer='l' ;
double mesh_points=0;
double value=0 ,number, n, initial1, initial2, end1, end2 ;
double cde[ROWS][COLUMNS];

label1:
do {
printf("Left boundary\n\n");
printf("will this boundary be expressed as a normal derivative y/n \n");
answer=getche();
if(answer=='y')dff1[0]=1;
}while(!(answer=='y' || answer=='n'));

printf("\n\nEnter left boundary as a function of Y\n");


printf("Enter degree of function\n");
scanf("%lf",&degree1);
if(degree1>9){
printf("\nDegree should be <= 9\n");
goto label1;}
printf("\nEnter coefficients of Y, proceeding from const to highest degree");
for(k=0 ; k<=degree1 ; ++k){
printf("\nEnter coeff # %-5.0lf\n",k+1);
scanf("%lf",&aray1[k]);}

ex2();
answer='l';
do {
printf("Right boundary\n\n");
printf("will this boundary be expressed as a normal derivative y/n \n");
answer=getche();
if(answer=='y')dff1[1]=1;
}while(!(answer=='y' || answer=='n'));

printf("\n\nEnter right boundary as a function of Y\n");


printf("Enter degree of function\n");
scanf("%lf",&degree2);
if(degree2>9){
printf("\nDegree should be <= 9\n");
goto label1;}
printf("\nEnter coefficients of Y, proceeding from const to highest degree");
for(k=0 ; k<=degree2 ; ++k){
printf("\nEnter coeff # %-5.0lf\n",k+1);
scanf("%lf",&aray2[k]);}

ex2();
answer='l';
do {
printf("Upper boundary\n\n");
printf("will this boundary be expressed as a normal derivative y/n \n");
answer=getche();
if(answer=='y')dff1[2]=1;
}while(!(answer=='y' || answer=='n'));

printf("\n\nEnter upper boundary as a function of X\n");


printf("Enter degree of function\n");
scanf("%lf",&degree3);
if(degree3>9){
printf("\nDegree should be <= 9\n");
goto label1;}
printf("\nEnter coefficients of X, proceeding from const to highest degree");
for(k=0 ; k<=degree3 ; ++k){
printf("\nEnter coeff # %-5.0lf\n",k+1);
scanf("%lf",&aray3[k]);}

ex2();
answer='l';
do {
printf("\nLower boundary\n\n");
printf("will this boundary be expressed as a normal derivative y/n \n");
answer=getche();
if(answer=='y')dff1[3]=1;
}while(!(answer=='y' || answer=='n'));

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

printf("\n\nEnter lower boundary as a function of X\n");


printf("Enter degree of function\n");
scanf("%lf",&degree4);
if(degree4>9){
printf("\nDegree should be <= 9\n");
goto label1;}
printf("\nEnter coefficients of X, proceeding from const to highest degree");
for(k=0 ; k<=degree4 ; ++k){
printf("\nEnter coeff # %-5.0lf\n",k+1);
scanf("%lf",&aray4[k]);}

if((dff1[0]+dff1[1]+dff1[2]+dff1[3]!=4)&&(type5==1||type5==2)){
ex2();
printf("\nThe four boundaries were not expressed as derivatives\n");
printf("And you selected ( solving a Neumann Problem ), when the four\n");
printf("boundaries are expressed as derivatives then the Elliptic eqn\n");
printf("is a Second Order Boundary Value Problem or a Neumann Problem\n");
printf("You have a Problem with Nomenclature, be careful !!!\n\n");
printf("I will continue solving your Mixed Problem \n\n");
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

fprintf(fp_mixed2,"\nThe four boundaries were not expressed as derivatives\n");


fprintf(fp_mixed2,"And you selected ( solving a Neumann Problem ), when the four\n");
fprintf(fp_mixed2,"boundaries are expressed as derivatives then the Elliptic eqn\n");
fprintf(fp_mixed2,"is a Second Order Boundary Value Problem or a Neumann Problem\n");
fprintf(fp_mixed2,"You have a Problem with Nomenclature, be careful !!!\n\n");
fprintf(fp_mixed2,"I will continue solving your Mixed Problem \n\n");}

else if((dff1[0]+dff1[1]+dff1[2]+dff1[3]==4)&&(type5==3||type5==4)){
ex2();
printf("\nThe four boundaries were expressed as derivatives\n");
printf("And you selected ( solving a Mixed Problem ), when the four\n");
printf("boundaries are expressed as derivatives then the Elliptic eqn\n");
printf("is a Second Order Boundary Value Problem or a Neumann Problem\n");
printf("You have a Problem with Nomenclature, be careful !!!\n\n");
printf("I will continue solving your four derivative bounded Problem (Neumann)\n\n");
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

fprintf(fp_mixed2,"\nThe four boundaries were expressed as derivatives\n");


fprintf(fp_mixed2,"And you selected ( solving a Mixed Problem ), when the four\n");
fprintf(fp_mixed2,"boundaries are expressed as derivatives then the Elliptic eqn\n");
fprintf(fp_mixed2,"is a Second Order Boundary Value Problem or a Neumann Problem\n");
fprintf(fp_mixed2,"You have a Problem with Nomenclature, be careful !!!\n\n");
fprintf(fp_mixed2,"I will continue solving your four derivative bounded Problem (Neumann)\n\n");}

else if(dff1[0]+dff1[1]+dff1[2]+dff1[3]==0){
ex2();
printf("\nNone of The four boundaries were expressed as normal derivatives\n");
printf("When none of the boundaries are expressed as normal deivatives then\n");
printf("The Elliptic eqn\n");
printf("is a First Order Boundary Value Problem or a Dirichlet Problem\n");
printf("You have a Problem with Nomenclature, be careful !!!\n\n");
printf("I will continue solving your ( Dirichlet Problem )\n\n");
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

fprintf(fp_mixed2,"\nNone of The four boundaries were expressed as normal derivatives\n");


fprintf(fp_mixed2,"When none of the boundaries are expressed as normal deivatives then\n");
fprintf(fp_mixed2,"The Elliptic eqn\n");
fprintf(fp_mixed2,"is a First Order Boundary Value Problem or a Dirichlet Problem\n");
fprintf(fp_mixed2,"You have a Problem with Nomenclature, be careful !!!\n\n");
fprintf(fp_mixed2,"I will continue solving your ( Dirichlet Problem )\n\n");}

ex2();
do{
printf("\n\nEnter tolerance of answer \n");
scanf("%lf",&tl);
if(tl==0){
printf("\nTolerance Zero might take a while\n");
printf("\nAre you sure y/n\n");
sure=tolower(getche());}

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

else break;

}while(sure!='y');

tl=fabs(tl);

row=(s1[1]+2);
column=(s1[0]+2);

ex2();
printf("\nNow you should enter the boundary values at the corners of the shape\n\n");
printf("Be careful and enter them accurately, they affect the results\n\n");
printf("\nLower left corner\n");
scanf("%lf",&array1[0][0]);
printf("\nUpper left corner\n");
scanf("%lf",&array1[row-1][0]);
printf("\nLower right corner\n");
scanf("%lf",&array1[0][column-1]);
printf("\nUpper right corner\n");
scanf("%lf",&array1[row-1][column-1]);

/* Evaluating the values of the boundaries at each point */


/* Note that the loop always starts from zero since the corner */
/* points are not included in the main loop */
if(dff1[0]==0){
for(i=1 ; i<(row-1) ; ++i)
array1[i][0] =poly(s1[2]*i, degree1, aray1 );}
else{
for(i=1 ; i<(row-1) ; ++i)
bd1[0][i] =poly(s1[2]*i, degree1, aray1 );}

if(dff1[1]==0){
for(i=1 ; i<(row-1) ; ++i)
array1[i][column-1]= poly(s1[2]*i, degree2, aray2 );}
else{
for(i=1 ; i<(row-1) ; ++i)
bd1[1][i] = poly(s1[2]*i, degree2, aray2 );}

if(dff1[2]==0){
for(j=1 ; j<(column-1) ; ++j)
array1[row-1][j] = poly(s1[2]*j, degree3, aray3 );}
else{
for(j=1 ; j<(column-1) ; ++j)
bd2[0][j] = poly(s1[2]*j, degree3, aray3 );}

if(dff1[3]==0){
for(j=1 ; j<(column-1) ; ++j)
array1[0][j] = poly(s1[2]*j, degree4, aray4);}
else{
for(j=1 ; j<(column-1) ; ++j)
bd2[1][j] = poly(s1[2]*j, degree4, aray4);}

ex2();
printf("\nTo what value would you like to initialize the internal mesh points\n");
printf("\nEnter the value\n");
scanf("%lf",&value);

/* initializing the internal mesh points with the given value */


for(i=1 ; i<(row-1) ; ++i)
{for(j=1 ; j<(column-1) ; ++j) array1[i][j] = value ;}

/* Internal # of mesh points */


mesh_points=s1[0]*s1[1]+dff1[0]*s1[1]+dff1[1]*s1[1]+dff1[2]*s1[0]+dff1[3]*s1[0];

/* Total mesh points used in calculations */


total_size=(2*(s1[0]+s1[1]))+(s1[0]*s1[1])+(dff1[0]*s1[1]+dff1[1]*s1[1]+dff1[2]*s1[0]+dff1[3]*s1[0]);

if(dff1[0]+dff1[1]+dff1[2]+dff1[3]==0)total_size=total_size;
else if(dff1[0]+dff1[1]+dff1[2]+dff1[3]==1)total_size=total_size+2;
else if(dff1[0]+dff1[1]+dff1[2]+dff1[3]>=3)total_size=total_size+4;
else if(dff1[0]==1&&dff1[3]==1&&dff1[2]==0&&dff1[1]==0)total_size=total_size+3;
else if(dff1[0]==1&&dff1[2]==1&&dff1[3]==0&&dff1[1]==0)total_size=total_size+3;
else if(dff1[1]==1&&dff1[3]==1&&dff1[2]==0&&dff1[0]==0)total_size=total_size+3;
else if(dff1[1]==1&&dff1[2]==1&&dff1[0]==0&&dff1[3]==0)total_size=total_size+3;
else if(dff1[0]+dff1[1]+dff1[2]+dff1[3]>=2)total_size=total_size+4;

ex2();
printf("\nThe number of internal mesh points is %-10.0lf\n",mesh_points);
printf("\nThe number of total mesh points used in calculatios including fictious\n");
printf("when present is %-10.0lf\n\n",total_size);

fprintf(fp_mixed2,"\nThe number of internal mesh points is %-10.0lf\n",mesh_points);


fprintf(fp_mixed2,"\nThe number of total mesh points used in calculatios including fictious\n");
fprintf(fp_mixed2,"when present is %-10.0lf\n\n",total_size);

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

printf("\nPress RETURN to continue");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

for(i=0 ; i<row ; ++i)


for(j=0 ; j<column ; ++j)
cde[i][j]=array1[i][j];

if(dff1[0]==1)initial2=0;
else initial2=1;
if(dff1[1]==1)end2=column;
else end2=column-1;
if(dff1[2]==1)end1=row;
else end1=row-1;
if(dff1[3]==1)initial1=0;
else initial1=1;

number=0;
do{
++number;
printf("\n# %-5.0lf\n",number);
n=0;
for(i=initial1 ; i<end1 ; ++i){
for(j=initial2 ; j<end2 ; ++j){
if((i==0&&j==0)||(i==row-1&&j==0)||(i==0&&j==column-1)||(i==row-1&&j==column-1))
continue;
cde[i][j]=array1[i][j];
if(j==0){
array1[i][j]=.25*(cde[i+1][j]+cde[i-1][j]+(2*cde[i][j+1])-
(2*s1[2]*bd1[0][i])+(cdef[i][j]*s1[2]*s1[2]));}
else if(j==(column-1)){
array1[i][j]=.25*(cde[i+1][j]+cde[i-1][j]+(2*cde[i][j-
1])+(2*s1[2]*bd1[1][i])+(cdef[i][j]*s1[2]*s1[2]));}
else if(i==(row-1)){
array1[i][j]=.25*((2*cde[i-1][j])+cde[i][j+1]+cde[i][j-
1]+(2*s1[2]*bd2[0][j])+(cdef[i][j]*s1[2]*s1[2]));}
else if(i==0){
array1[i][j]=.25*((2*cde[i+1][j])+cde[i][j+1]+cde[i][j-1]-
(2*s1[2]*bd2[1][j])+(cdef[i][j]*s1[2]*s1[2]));}
else
array1[i][j]=.25*(cde[i+1][j]+cde[i-1][j]+cde[i][j+1]+cde[i][j-1]+(cdef[i][j]*s1[2]*s1[2]));
if((tl==0) && (array1[i][j] == cde[i][j]) ) ++n;
else if((tl!=0) && (fabs(array1[i][j] - cde[i][j]) < tl) ) ++n ; }
}
}while(n!=(mesh_points));

ex2();
printf("\nNumber of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
/* to print out our array1 */
printf("The array will look like this\n");
printf("From the upper to the lower side\n");
printf("\nrows= %-5.0lf",row);
printf("\ncolumns= %-5.0lf \n\n",column);
for(i=row-1 ; i>=0 ; --i){
printf("row # %-5.0lf\n",i+1);
for(j=0 ; j<column ; ++j)
printf("%-20.5e",array1[i][j]);
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
printf("\n\n");}

fprintf(fp_mixed2,"\nNumber of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);


/* to print out our array1 */
fprintf(fp_mixed2,"The array will look like this\n");
fprintf(fp_mixed2,"From the upper to the lower side\n");
fprintf(fp_mixed2,"\nrows= %-5.0lf",row);
fprintf(fp_mixed2,"\ncolumns= %-5.0lf \n\n",column);
for(i=row-1 ; i>=0 ; --i){
fprintf(fp_mixed2,"row # %-5.0lf\n",i+1);
for(j=0 ; j<column ; ++j)
fprintf(fp_mixed2,"%-20.5e",array1[i][j]);
fprintf(fp_mixed2,"\n\n");}

MIXED3.C
#include "header.h"

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

#include "header1.h"

extern void mixed3(double *s1, int type5, FILE *fp_mixed3)


{
double aray1[10] = {0}, aray2[10] = {0}, dff1[4] = {0};
double aray3[10] = {0}, aray4[10] = {0};
double bd1[2][51] = {0}, bd2[2][51] = {0};
double row, column, i, j, total_size , c, wopt ;
char ch='\0';
double degree1, degree2, degree3, degree4, k, tl=.01;
char sure='p', answer='l' ;
double mesh_points=0;
double value=0 ,number, n, initial1, initial2, end1, end2, savior ;

label1:
do {
printf("Left boundary\n\n");
printf("will this boundary be expressed as a normal derivative y/n \n");
answer=getche();
if(answer=='y')dff1[0]=1;
}while(!(answer=='y' || answer=='n'));

printf("\n\nEnter left boundary as a function of Y\n");


printf("Enter degree of function\n");
scanf("%lf",&degree1);
if(degree1>9){
printf("\nDegree should be <= 9\n");
goto label1;}
printf("\nEnter coefficients of Y, proceeding from const to highest degree");
for(k=0 ; k<=degree1 ; ++k){
printf("\nEnter coeff # %-5.0lf\n",k+1);
scanf("%lf",&aray1[k]);}

ex2();
answer='l';
do {
printf("Right boundary\n\n");
printf("will this boundary be expressed as a normal derivative y/n \n");
answer=getche();
if(answer=='y')dff1[1]=1;
}while(!(answer=='y' || answer=='n'));

printf("\n\nEnter right boundary as a function of Y\n");


printf("Enter degree of function\n");
scanf("%lf",&degree2);
if(degree2>9){
printf("\nDegree should be <= 9\n");
goto label1;}
printf("\nEnter coefficients of Y, proceeding from const to highest degree");
for(k=0 ; k<=degree2 ; ++k){
printf("\nEnter coeff # %-5.0lf\n",k+1);
scanf("%lf",&aray2[k]);}

ex2();
answer='l';
do {
printf("Upper boundary\n\n");
printf("will this boundary be expressed as a normal derivative y/n \n");
answer=getche();
if(answer=='y')dff1[2]=1;
}while(!(answer=='y' || answer=='n'));

printf("\n\nEnter upper boundary as a function of X\n");


printf("Enter degree of function\n");
scanf("%lf",&degree3);
if(degree3>9){
printf("\nDegree should be <= 9\n");
goto label1;}
printf("\nEnter coefficients of X, proceeding from const to highest degree");
for(k=0 ; k<=degree3 ; ++k){
printf("\nEnter coeff # %-5.0lf\n",k+1);
scanf("%lf",&aray3[k]);}

ex2();
answer='l';
do {
printf("Lower boundary\n\n");
printf("will this boundary be expressed as a normal derivative y/n \n");
answer=getche();
if(answer=='y')dff1[3]=1;
}while(!(answer=='y' || answer=='n'));

printf("\n\nEnter lower boundary as a function of X\n");


printf("Enter degree of function\n");
scanf("%lf",&degree4);

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

if(degree4>9){
printf("\nDegree should be <= 9\n");
goto label1;}
printf("\nEnter coefficients of X, proceeding from const to highest degree");
for(k=0 ; k<=degree4 ; ++k){
printf("\nEnter coeff # %-5.0lf\n",k+1);
scanf("%lf",&aray4[k]);}

if((dff1[0]+dff1[1]+dff1[2]+dff1[3]!=4)&&(type5==1||type5==2)){
ex2();
printf("\nThe four boundaries were not expressed as derivatives\n");
printf("And you selected ( solving a Neumann Problem ), when the four\n");
printf("boundaries are expressed as derivatives then the Elliptic eqn\n");
printf("is a Second Order Boundary Value Problem or a Neumann Problem\n");
printf("You have a Problem with Nomenclature, be careful !!!\n\n");
printf("I will continue solving your Mixed Problem \n\n");
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

fprintf(fp_mixed3,"\nThe four boundaries were not expressed as derivatives\n");


fprintf(fp_mixed3,"And you selected ( solving a Neumann Problem ), when the four\n");
fprintf(fp_mixed3,"boundaries are expressed as derivatives then the Elliptic eqn\n");
fprintf(fp_mixed3,"is a Second Order Boundary Value Problem or a Neumann Problem\n");
fprintf(fp_mixed3,"You have a Problem with Nomenclature, be careful !!!\n\n");
fprintf(fp_mixed3,"I will continue solving your Mixed Problem \n\n");}

else if((dff1[0]+dff1[1]+dff1[2]+dff1[3]==4)&&(type5==3||type5==4)){
ex2();
printf("\nThe four boundaries were expressed as derivatives\n");
printf("And you selected ( solving a Mixed Problem ), when the four\n");
printf("boundaries are expressed as derivatives then the Elliptic eqn\n");
printf("is a Second Order Boundary Value Problem or a Neumann Problem\n");
printf("You have a Problem with Nomenclature, be careful !!!\n\n");
printf("I will continue solving your four derivative bounded Problem (Neumann)\n\n");
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

fprintf(fp_mixed3,"\nThe four boundaries were expressed as derivatives\n");


fprintf(fp_mixed3,"And you selected ( solving a Mixed Problem ), when the four\n");
fprintf(fp_mixed3,"boundaries are expressed as derivatives then the Elliptic eqn\n");
fprintf(fp_mixed3,"is a Second Order Boundary Value Problem or a Neumann Problem\n");
fprintf(fp_mixed3,"You have a Problem with Nomenclature, be careful !!!\n\n");
fprintf(fp_mixed3,"I will continue solving your four derivative bounded Problem (Neumann)\n\n");}

else if(dff1[0]+dff1[1]+dff1[2]+dff1[3]==0){
ex2();
printf("\nNone of The four boundaries were expressed as normal derivatives\n");
printf("When none of the boundaries are expressed as normal deivatives then\n");
printf("The Elliptic eqn\n");
printf("is a First Order Boundary Value Problem or a Dirichlet Problem\n");
printf("You have a Problem with Nomenclature, be careful !!!\n\n");
printf("I will continue solving your ( Dirichlet Problem )\n\n");
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

fprintf(fp_mixed3,"\nNone of The four boundaries were expressed as normal derivatives\n");


fprintf(fp_mixed3,"When none of the boundaries are expressed as normal deivatives then\n");
fprintf(fp_mixed3,"The Elliptic eqn\n");
fprintf(fp_mixed3,"is a First Order Boundary Value Problem or a Dirichlet Problem\n");
fprintf(fp_mixed3,"You have a Problem with Nomenclature, be careful !!!\n\n");
fprintf(fp_mixed3,"I will continue solving your ( Dirichlet Problem )\n\n");}

ex2();
do{
printf("\n\nEnter tolerance of answer \n");
scanf("%lf",&tl);
if(tl==0){
printf("\nTolerance Zero might take a while\n");
printf("\nAre you sure y/n\n");
sure=tolower(getche());}
else break;

}while(sure!='y');

tl=fabs(tl);

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

row=(s1[1]+2);
column=(s1[0]+2);

ex2();
printf("\nNow you should enter the boundary values at the corners of the shape\n\n");
printf("Be careful and enter them accurately, they affect the results\n\n");
printf("\nLower left corner\n");
scanf("%lf",&array1[0][0]);
printf("\nUpper left corner\n");
scanf("%lf",&array1[row-1][0]);
printf("\nLower right corner\n");
scanf("%lf",&array1[0][column-1]);
printf("\nUpper right corner\n");
scanf("%lf",&array1[row-1][column-1]);

/* Evaluating the values of the boundaries at each point */


/* Note that the loop always starts from zero since the corner */
/* points are not included in the main loop */
if(dff1[0]==0){
for(i=1 ; i<(row-1) ; ++i)
array1[i][0] =poly(s1[2]*i, degree1, aray1 );}
else{
for(i=1 ; i<(row-1) ; ++i)
bd1[0][i] =poly(s1[2]*i, degree1, aray1 );}

if(dff1[1]==0){
for(i=1 ; i<(row-1) ; ++i)
array1[i][column-1]= poly(s1[2]*i, degree2, aray2 );}
else{
for(i=1 ; i<(row-1) ; ++i)
bd1[1][i] = poly(s1[2]*i, degree2, aray2 );}

if(dff1[2]==0){
for(j=1 ; j<(column-1) ; ++j)
array1[row-1][j] = poly(s1[2]*j, degree3, aray3 );}
else{
for(j=1 ; j<(column-1) ; ++j)
bd2[0][j] = poly(s1[2]*j, degree3, aray3 );}

if(dff1[3]==0){
for(j=1 ; j<(column-1) ; ++j)
array1[0][j] = poly(s1[2]*j, degree4, aray4);}
else{
for(j=1 ; j<(column-1) ; ++j)
bd2[1][j] = poly(s1[2]*j, degree4, aray4);}

ex2();
printf("\nTo what value would you like to initialize the internal mesh points\n");
printf("\nEnter the value\n");
scanf("%lf",&value);

/* initializing the internal mesh points with the given value */


for(i=1 ; i<(row-1) ; ++i)
{for(j=1 ; j<(column-1) ; ++j) array1[i][j] = value ;}

/* Internal # of mesh points */


mesh_points=s1[0]*s1[1]+dff1[0]*s1[1]+dff1[1]*s1[1]+dff1[2]*s1[0]+dff1[3]*s1[0];

/* Total mesh points used in calculations */


total_size=(2*(s1[0]+s1[1]))+(s1[0]*s1[1])+(dff1[0]*s1[1]+dff1[1]*s1[1]+dff1[2]*s1[0]+dff1[3]*s1[0]);

if(dff1[0]+dff1[1]+dff1[2]+dff1[3]==0)total_size=total_size;
else if(dff1[0]+dff1[1]+dff1[2]+dff1[3]==1)total_size=total_size+2;
else if(dff1[0]+dff1[1]+dff1[2]+dff1[3]>=3)total_size=total_size+4;
else if(dff1[0]==1&&dff1[3]==1&&dff1[2]==0&&dff1[1]==0)total_size=total_size+3;
else if(dff1[0]==1&&dff1[2]==1&&dff1[3]==0&&dff1[1]==0)total_size=total_size+3;
else if(dff1[1]==1&&dff1[3]==1&&dff1[2]==0&&dff1[0]==0)total_size=total_size+3;
else if(dff1[1]==1&&dff1[2]==1&&dff1[0]==0&&dff1[3]==0)total_size=total_size+3;
else if(dff1[0]+dff1[1]+dff1[2]+dff1[3]>=2)total_size=total_size+4;

ex2();
printf("\nThe number of internal mesh points is %-10.0lf\n",mesh_points);
printf("\nThe number of total mesh points used in calculatios including fictious\n");
printf("when present is %-10.0lf\n\n",total_size);

fprintf(fp_mixed3,"\nThe number of internal mesh points is %-10.0lf\n",mesh_points);


fprintf(fp_mixed3,"\nThe number of total mesh points used in calculatios including fictious\n");
fprintf(fp_mixed3,"when present is %-10.0lf\n\n",total_size);

printf("\nPress RETURN to continue");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

if(dff1[0]==1)initial2=0;
else initial2=1;
if(dff1[1]==1)end2=column;
else end2=column-1;
if(dff1[2]==1)end1=row;
else end1=row-1;
if(dff1[3]==1)initial1=0;
else initial1=1;

c=cos(M_PI/(s1[1]+1))+cos(M_PI/(s1[0]+1));
wopt=(4/(2+sqrt(4-(c*c))));

number=0;
do{
++number;
printf("\n# %-5.0lf\n",number);
n=0;
for(i=initial1 ; i<end1 ; ++i){
for(j=initial2 ; j<end2 ; ++j){
if((i==0&&j==0)||(i==row-1&&j==0)||(i==0&&j==column-1)||(i==row-1&&j==column-1))
continue;
savior=array1[i][j];
if(j==0){
array1[i][j]=array1[i][j]+(wopt*.25*(array1[i+1][j]+array1[i-1][j]+(2*array1[i][j+1])-
(2*s1[2]*bd1[0][i])-(4*array1[i][j])+(cdef[i][j]*s1[2]*s1[2])));}
else if(j==(column-1)){
array1[i][j]=array1[i][j]+(wopt*.25*(array1[i+1][j]+array1[i-1][j]+(2*array1[i][j-
1])+(2*s1[2]*bd1[1][i])-(4*array1[i][j])+(cdef[i][j]*s1[2]*s1[2])));}
else if(i==(row-1)){
array1[i][j]=array1[i][j]+(wopt*.25*((2*array1[i-1][j])+array1[i][j+1]+array1[i][j-
1]+(2*s1[2]*bd2[0][j])-(4*array1[i][j])+(cdef[i][j]*s1[2]*s1[2])));}
else if(i==0){
array1[i][j]=array1[i][j]+(wopt*.25*((2*array1[i+1][j])+array1[i][j+1]+array1[i][j-1]-
(2*s1[2]*bd2[1][j])-(4*array1[i][j])+(cdef[i][j]*s1[2]*s1[2])));}
else
array1[i][j]=array1[i][j]+(wopt*.25*(array1[i+1][j]+array1[i-1][j]+array1[i][j+1]+array1[i][j-1]-
(4*array1[i][j])+(cdef[i][j]*s1[2]*s1[2])));
if((tl!=0.0) && (fabs(array1[i][j] - savior) < tl) ) ++n ;
else if((tl==0.0) && (array1[i][j] == savior) ) ++n; } }

}while(n!=(mesh_points));

ex2();
printf("\nThe optimum value of the S.O.R. factor used is, w = %-8.6f\n", wopt);
printf("\nThe number of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
/* to print out our array1 */
printf("The array will look like this\n");
printf("From the upper to the lower side\n");
printf("\nrows= %-5.0lf",row);
printf("\ncolumns= %-5.0lf \n\n",column);
for(i=row-1 ; i>=0 ; --i){
printf("row # %-5.0lf\n",i+1);
for(j=0 ; j<column ; ++j)
printf("%-20.5e",array1[i][j]);
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
printf("\n\n");}

fprintf(fp_mixed3,"\nThe optimum value of the S.O.R. factor used is, w = %-8.6f\n", wopt);
fprintf(fp_mixed3,"\nThe number of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
/* to print out our array1 */
fprintf(fp_mixed3,"The array will look like this\n");
fprintf(fp_mixed3,"From the upper to the lower side\n");
fprintf(fp_mixed3,"\nrows= %-5.0lf",row);
fprintf(fp_mixed3,"\ncolumns= %-5.0lf \n\n",column);
for(i=row-1 ; i>=0 ; --i){
fprintf(fp_mixed3,"row # %-5.0lf\n",i+1);
for(j=0 ; j<column ; ++j)
fprintf(fp_mixed3,"%-20.5e",array1[i][j]);
fprintf(fp_mixed3,"\n\n");}

MYHEAD.H
#define ROWS 50
#define COLUMNS 50
extern double array1[ROWS][COLUMNS]={0.0};
extern double cdef[ROWS][COLUMNS]={0.0};

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

NOTE.C
#include "header.h"

extern void note(FILE *fp_note)


{
char ch;

printf("\nThis program will use the average of the boundary values you enter as a guide\n");
printf("to the most appropriate value needed for initialization of the internal mesh\n");
printf("points, and the corner points of the grid will take the average values of the\n");
printf("boundaries that surround them - if you are not asked to enter them -\n\n");

fprintf(fp_note,"\nThis program will use the average of the boundary values you enter as a guide\n");
fprintf(fp_note,"to the most appropriate value needed for initialization of the internal mesh\n");
fprintf(fp_note,"points, and the corner points of the grid will take the average values of the\n");
fprintf(fp_note,"boundaries that surround them - if you are not asked to enter them -\n\n");

printf("Press RETURN to continue");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

printf("\n");

NOTE1.C
#include "header.h"
extern void note1(FILE *fp_note1)
{
char ch;

ex2();
printf("\nThe following menu uses the heat eqn as a prototype for parabolic PDEs\n");
printf("but the methods listed apply equally to diffusion of materials, flow of \n");
printf("fluids (under conditions of laminar flow), flow of electricity in cables \n");
printf("(the telegraph equations) and so on\n");

fprintf(fp_note1,"\nThe following menu uses the heat eqn as a prototype for parabolic PDEs\n");
fprintf(fp_note1,"but the methods listed apply equally to diffusion of materials, flow of \n");
fprintf(fp_note1,"fluids (under conditions of laminar flow), flow of electricity in cables \n");
fprintf(fp_note1,"(the telegraph equations) and so on\n");

printf("\nPress RETURN to continue\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

NOTE2.C
#include "header.h"
extern void note2(FILE *fp_note2)
{
char ch;

ex2();
printf("\nThe following menu uses the wave eqn as a prototype for Hyperbolic PDEs\n");
printf("the wave eqn is fundamental to the study of vibrating systems\n");
printf("Hyperbolic PDEs are also involved in transport problems (diffusion of matter,\n");
printf("neutron diffusion, and radiation transfer), wave mechanics, gas dynamics, super-");
printf("sonic flow, and other important areas\n");

fprintf(fp_note2,"\nThe following menu uses the wave eqn as a prototype for Hyperbolic PDEs\n");
fprintf(fp_note2,"the wave eqn is fundamental to the study of vibrating systems\n");
fprintf(fp_note2,"Hyperbolic PDEs are also involved in transport problems (diffusion of matter,\n");
fprintf(fp_note2,"neutron diffusion, and radiation transfer), wave mechanics, gas dynamics, super-");
fprintf(fp_note2,"sonic flow, and other important areas\n");

printf("\nPress RETURN to continue\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break; }

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

PASSWORD.C
#include "header.h"

extern void password(char *p1)


{
char i ;

printf("\n\nEnter Password\n\n");
for(i=0; i<6 ; ++i) *(p1+i)=getch();

POINTS.C
#include "header.h"
#include "hishead.h"

extern double points(double *s1)


{
double upper=0, bottom=0, left=0, right=0 , tl=.1 , i, j ,box , row, column;
char sure='p';
char ch='\0';
double *s2;

row=(s1[1]+2);
column=(s1[0]+2);

/* entering corners of grid one at a time*/


printf("\nEnter corner values of boundaries\n");
printf("\nUpper left corner\n");
scanf("%lf",&upper);
array1[row-1][0]=upper;

printf("\nBottom left corner\n");


scanf("%lf",&bottom);
array1[0][0]=bottom;

printf("\nUpper right corner\n");


scanf("%lf",&left);
array1[row-1][column-1]=left;

printf("\nBottom right corner\n");


scanf("%lf",&right);
array1[0][column-1]=right;

/* end of entring grid boundaries */

/* entring grid boundaries */


ex2();
printf("\nEnter grid boundaries one at a time:\n\nUpper boundary, starting from left to right\n");
for(i=1; i<column-1 ;++i){
scanf("%lf",&upper);
array1[row-1][i]=upper;}

printf("\nBottom boundary, starting from left to right\n");


for(i=1; i<column-1 ;++i){
scanf("%lf",&bottom);
array1[0][i]=bottom;}

printf("\nLeft boundary, starting from upper to lower\n");


for(i=row-2; i>0 ;--i){
scanf("%lf",&left);
array1[i][0]=left;}

printf("\nRight boundary, starting from upper to lower\n");


for(i=row-2; i>0 ;--i){
scanf("%lf",&right);
array1[i][column-1]=right;}

/* end of entring grid boundaries */

ex2();
do{
printf("\n\nEnter tolerance of answer \n");
scanf("%lf",&tl);
if(tl==0){
printf("\nTolerance Zero might take a while\n");
printf("\nAre you sure y/n\n");
sure=getche();
tolower(sure);}
if(tl!=0)break;
sure='l';

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

}while(sure=='n');

tl=fabs(tl);

ex2();
printf("rows=%-5.0f\ncolumns=%-5.0f\n", row, column);

/* calculating the average value of boundaries */


box=0.0;
for(i=1; i<column-1 ;++i)box=box+array1[row-1][i];
for(i=1; i<column-1 ;++i)box=box+array1[0][i];
for(i=1; i<row-1 ; ++i)box=box+array1[i][0];
for(i=1; i<row-1 ; ++i)box=box+array1[i][column-1];
box=box+array1[0][0]+array1[row-1][0]+array1[0][column-1]+array1[row-1][column-1];
s2[4]=box/(2.0*(row+(column-2)));

/* giving all points in the array1 the average of the boundary value at first */
for(i=1 ; i<row-1 ; ++i)
{for(j=1 ; j<column-1 ; ++j) array1[i][j] = s2[4] ;}

/* to print out our initialized array1 */


printf("\nThe initialization of the array will look like this\n");
printf("From the upper to the lower side\n\n");
for(i=row-1 ; i>=0 ; --i){
printf("row # %-5.0f\n",i+1);
for(j=0 ; j<column ; ++j)
printf("%-20.5e",array1[i][j]);
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
printf("\n\n");}

return tl;
}

POISSON1.C
#include "header.h"
#include "header1.h"

extern void poisson1(double *s1)


{
double constant , i, j , row, column ;
char ch='\0';

printf("\nEnter the constant value of the function in the Poisson eqn\n");


printf("referred to the left hand side, so that the right hand side \n");
printf("equals zero\n\n");
scanf("%lf",&constant);

if(constant==0){
ex2();
printf("\nYou selected solving a Poisson Equation, where as entering a Laplace eqn!\n");
printf("\nYou have a Problem with Nomenclature, be careful !!!\n");
printf("I will continue solving your Laplace eqn\n\n");
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}}

row=(s1[1]+2);
column=(s1[0]+2);

for(i=0 ; i<row ; i++)


for(j=0 ; j<column ; j++)
cdef[i][j]=constant;
}

POISSON2.C
#include "header.h"
#include "header1.h"

extern void poisson2(double *s1)


{
double constant , i, j , row, column, value, box, box1, boxx ;
char ch='\0';

printf("\nEnter values of the function in the Poisson eqn\n");

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

printf("referred to the left hand side, so that the right hand side \n");
printf("of the poisson eqn equals zero\n\n");

printf("\nPress RETURN to continue");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

row=(s1[1]+2);
column=(s1[0]+2);

boxx=0.0;
box1=s1[2];
printf("\nEnter values, f(x,y) as prompted\n");
for(i=1; i<row-1 ;++i){
ex2();
box=s1[2];
for(j=1; j<column-1 ;++j){
printf("\nEnter value at X= %-20.5lf Y= %-20.5lf\n", box, box1);
scanf("%lf", &value);
cdef[i][j]=value;
box=box+s1[2];
boxx=boxx+cdef[i][j];}
box1=box1+s1[2];}

if(boxx==0.0){
ex2();
printf("\nYou selected solving a Poisson Equation, where as entering a Laplace eqn!\n");
printf("\nYou have a Problem with Nomenclature, be careful !!!\n");
printf("I will continue solving your Laplace eqn\n\n");
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}}

POISSON3.C
#include "header.h"
#include "header1.h"

extern void poisson3(double *s1)


{
double constant , i, j , row, column, value, box, box1, boxx ;
char ch='\0';

printf("\nEnter values of the function in the Poisson eqn\n");


printf("referred to the left hand side, so that the right hand side \n");
printf("of the poisson eqn equals zero\n\n");

printf("\nPress RETURN to continue");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

row=(s1[1]+2);
column=(s1[0]+2);

boxx=0.0;
box1=0.0;
printf("\nEnter values, f(x,y) as prompted\n");
for(i=0; i<row ;++i){
ex2();
box=0.0;
for(j=0; j<column ;++j){
printf("\nEnter value at X= %-20.5lf Y= %-20.5lf\n", box, box1);
scanf("%lf", &value);
cdef[i][j]=value;
box=box+s1[2];
boxx=boxx+cdef[i][j];}
box1=box1+s1[2];}

if(boxx==0.0){
ex2();
printf("\nYou selected solving a Poisson Equation, where as entering a Laplace eqn!\n");
printf("\nYou have a Problem with Nomenclature, be careful !!!\n");
printf("I will continue solving your Laplace eqn\n\n");
printf("\nPress RETURN to continue");

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}}

POISSONF.C
#include "header.h"
#include "header1.h"

extern void poissonf(double *s1)


{
double aray1[10] = {0}, aray2[10] = {0};
double row, column, i, j, saver ;
double degree1, degree2, k, box=0 ;

char ch='\0';

/* Entering function f(x,y)*/


printf("\nEnter the function f(x,y) of the Poisson eqn\n");
printf("As if consisting of two parts, part 1: X part & part 2: Y part\n");
printf("Enter each part seperately as prompted\n");
printf("Enter the constant if present to either part (X or Y), not to both\n\n");

printf("\nPress RETURN to continue");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

label1:
ex2();
printf("Enter function of Y\n");
printf("Enter degree of function\n");
scanf("%lf",&degree1);
if(degree1>9){
printf("\nDegree should be <= 9\n");
goto label1;}
printf("Enter coefficients of Y, proceeding from const to highest degree");
for(k=0 ; k<=degree1 ; ++k){
printf("\nEnter coeff # %-5.0lf\n",k+1);
scanf("%lf",&aray1[k]);}

label2:
ex2();
printf("\nEnter function of X\n");
printf("Enter degree of function\n");
scanf("%lf",&degree2);
if(degree2>9){
printf("\nDegree should be <= 9\n");
goto label2;}
printf("Enter coefficients of X, proceeding from const to highest degree");
for(k=0 ; k<=degree2 ; ++k){
printf("\nEnter coeff # %-5.0lf\n",k+1);
scanf("%lf",&aray2[k]);}

row=(s1[1]+2);
column=(s1[0]+2);

/* Evaluating the values of the function f(x,y) at each point */


for(i=0 ; i<row ; ++i)
for(j=0 ; j<column ; ++j){
saver =poly(s1[2]*j, degree2, aray2 ) ;
cdef[i][j] =poly(s1[2]*i, degree1, aray1 ) + saver ;
box=box+cdef[i][j]; }

if(box==0){
ex2();
printf("\nYou selected solving a Poisson Equation, where as entering a Laplace eqn!\n");
printf("\nYou have a Problem with Nomenclature, be careful !!!\n");
printf("I will continue solving your Laplace eqn\n\n");
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}}

/* to print out the values of the function f(x,y) at each point*/


ex2();
printf("\nThe function f(x,y) will look like this\n");

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

printf("From the upper to the lower side \n\n");


printf("Remember that all values at boundaries will not be used\n");
printf("since they are not internal mesh points\n");
printf("\nrows=%-5.0f\ncolumns=%-5.0f\n\n",row,column);
for(i=row-1 ; i>=0 ; --i){
printf("row # %-5.0f\n",i+1);
for(j=0 ; j<column ; ++j)
printf("%-20.5e",cdef[i][j]);
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
printf("\n\n");}

SEMICKL3.C
#include "header.h"
#include "hishead.h"
/* entring size of grid & mesh size */

extern void semi_circle3(int choice1, FILE *fp_semi_circle3)


{
double radius=1.0, angle, dangle=20.0, dradius=1.0, max=1.0, s1[2]={0}, s2[5]={0} ;
double integer1, integer2, fraction1, fraction2, number1, number2 ;
double arround1=0.0, bottom1=0.0,arround2=0.0, bottom2=0.0, tl=.1 ;
char sure='p';
double size, radians, constant, origin ;
double i, j , n , number, remainder, integerr, savior ;
char ch='\0';

do{
printf("\n\nEnter dimensions of semi-circle -irregular boundaries-\n\n");
do{
printf("\nEnter radius of semi-circle\n");
scanf("%lf",&radius);
if(radius==0.0)printf("\nYou must be joking, try again\n");
}while(radius==0.0);

do{
printf("\nEnter the increment of the angle in degrees, 180 must\n");
printf("be an integer multiple of this increment\n");
scanf("%lf",&dangle);
if(dangle==0.0)printf("\nYou must be joking, try again\n");
}while(dangle==0.0);

label5:
ex2();
printf("\nEnter the increment for r, that the program will use\n\n");
printf("PS: The radius that you previously entered must be an integer\n");
printf(" multiple of this increment\n");
printf(" If you did not enter these increments as requested you will \n");
printf(" be prompted to re-enter the dimensions of the semi-circle \n\n");
scanf("%lf",&dradius);
if(dradius==0.0){
printf("\nYou must be joking, try again\n");
goto label5;}

fprintf(fp_semi_circle3,"\nDimensions of semi-circle -irregular boundaries- as entered by user\n\n");


fprintf(fp_semi_circle3,"Radius of semi-circle is %-20.5lf\n", radius);
fprintf(fp_semi_circle3,"The increment of the angle in degrees is %-20.5lf\n", dangle);
fprintf(fp_semi_circle3,"The increment for r, that the program will use is %-20.5lf\n\n", dradius);

number1=radius/dradius;
fraction1=modf(number1,&integer1);
number2=(double)180.0/dangle;
fraction2=modf(number2,&integer2);
max=(integer1+1)*(integer2+1);
}while(!(fraction1==0.0 && fraction2==0.0 && max<=2500));

/*to save # of mesh points & h */


s1[0]=integer1-1;
s1[1]=integer2-1;

if(choice1==5 || choice1==6){
ex2();
printf("\nEnter semi-circle boundaries one at a time:\n");
printf("\nOrigin value, the center from which the s-circle is drawn\n");
scanf("%lf",&origin);
for(j=0; j<=s1[1]+1 ;++j)array1[0][j]=origin;

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

ex2();
angle=0.0;
printf("\n\nArround the s-circle, enter each point according to the angle indicated\n");
for(j=0; j<=s1[1]+1 ;++j){
printf("\nFor angle= %-6.2lf\n",angle);
scanf("%lf",&arround1);
array1[s1[0]+1][j]=arround1;
angle=angle+dangle;}

ex2();
angle=dradius;
printf("\n\nBottom boundary from the right\n");
for(i=1; i<=s1[0] ;++i){
printf("\nFor radius= %-10.3lf\n",angle);
scanf("%lf",&bottom1);
array1[i][0]=bottom1;
angle=angle+dradius;
}

ex2();
angle=dradius;
printf("\n\nBottom boundary from the left\n");
for(i=1; i<=s1[0] ;++i){
printf("\nFor radius= %-10.3lf\n",angle);
scanf("%lf",&bottom2);
array1[i][s1[1]+1]=bottom2;
angle=angle+dradius;}

angle=0.0;
for(j=0; j<=s1[1]+1 ;++j)angle=angle+array1[s1[0]+1][j];
s2[4]=angle;
angle=0.0;
for(i=1; i<=s1[0] ;++i)angle=angle+array1[i][0];
s2[4]=s2[4]+angle;
angle=0.0;
for(i=1; i<=s1[0] ;++i)angle=angle+array1[i][s1[1]+1];
s2[4]=s2[4]+angle;
s2[4]=s2[4]+array1[0][0];

angle=s1[1]+(2.0*s1[0])+3;
s2[4]=s2[4]/angle;
}

else{
ex2();
/* entring grid boundaries */
printf("\nEnter semi-circle boundaries one at a time:\n\nArround the s-circle from the right boundary\n");
scanf("%lf",&arround1);
s2[0]=arround1 ;

printf("\nArround the s-circle from the left boundary\n");


scanf("%lf",&arround2);
s2[1]=arround2 ;

printf("\nBottom boundary from the right\n");


scanf("%lf",&bottom1);
s2[2]=bottom1;

printf("\nBottom boundary from the left\n");


scanf("%lf",&bottom2);
s2[3]=bottom2;

/*calculating initial conditions for intrnal mesh points*/

/* calculating the average value of boundaries */


s2[4]=radius*M_PI_2*(s2[0]+s2[1]);
s2[4]=s2[4]+(radius*(s2[3]+s2[2]));
s2[4]=s2[4]/(radius*(M_PI+2.0));
remainder=.5*s1[1];

/* giving the boundary points their boundary values */


for(j=1 ; j<remainder ;++j )array1[s1[0]+1][j]=s2[0];

modf(remainder,&integerr);
if(remainder==integerr){
for(j=integerr+1 ; j<s1[1]+1 ;++j)array1[s1[0]+1][j]=s2[1];}
else{
for(j=integerr+2 ; j<s1[1]+1 ;++j)array1[s1[0]+1][j]=s2[1];}

for(i=1 ; i<=s1[0] ;++i)array1[i][0]=s2[2];


for(i=1 ; i<=s1[0] ;++i)array1[i][s1[1]+1]=s2[3];

array1[s1[0]+1][0]=.5*(s2[2]+s2[0]);
array1[s1[0]+1][s1[1]+1]=.5*(s2[3]+s2[1]);
array1[0][0]=.5*(s2[3]+s2[2]);

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

if(remainder!=integerr)array1[s1[0]+1][integerr+1]=.5*(s2[0]+s2[1]);
for(j=0 ; j<=s1[1]+1 ;++j)array1[0][j]=array1[0][0];
}

/* end of entring grid boundaries */


ex2();
do{
printf("\n\nEnter tolerance of answer \n");
scanf("%lf",&tl);
if(tl==0){
printf("\nTolerance Zero might take a while\n");
printf("\nAre you sure y/n\n");
sure=tolower(getche());}
else break;

}while(sure!='y');

tl=fabs(tl);

/* giving all points in the array1 the average of the boundary value at first */
for(i=1 ; i<=s1[0] ; ++i)
for(j=1 ; j<=s1[1] ; ++j) array1[i][j] = s2[4] ;

size=s1[0]*s1[1];
size=size+s1[1]+2+(2*s1[0])+1;

ex2();
printf("\nThe # of internal mesh points is: %-5.0f\n",s1[0]*s1[1]);
printf("\nThe # of mesh points that we'll be operating on\n");
printf("including the ones on the boundaries is: %-5.0f\n\n",size);

fprintf(fp_semi_circle3,"\nThe # of internal mesh points is: %-5.0f\n",s1[0]*s1[1]);


fprintf(fp_semi_circle3,"\nThe # of mesh points that we'll be operating on\n");
fprintf(fp_semi_circle3,"including the ones on the boundaries is: %-5.0f\n\n",size);

printf("\nPress RETURN to continue");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
printf("\n\n");

radians=dangle*M_PI/180.0;

number=0;
do{
++number;
printf("\n# %-5.0lf\n",number);
n=0;
for(i=1 ; i<=s1[0] ; ++i){
for(j=1 ; j<=s1[1] ; ++j){
savior=array1[i][j];
constant=(.5*i*i*radians*radians)/((i*i*radians*radians)+1);
array1[i][j]=constant*(((1-(.5/i))*array1[i-
1][j])+((1+(.5/i))*array1[i+1][j])+((1.0/(i*i*radians*radians))*array1[i][j-
1])+((1.0/(i*i*radians*radians))*array1[i][j+1]));
if((tl==0) && (array1[i][j] == savior) ) ++n;
else if((tl!=0) && (fabs(array1[i][j] - savior) < tl) ) ++n ; }
}
}while(n!=(s1[0]*s1[1]));

ex2();
angle=0.0;
printf("\nNumber of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
/* to print out our array1 */
printf("The array will look like this\n");
printf("From the R = radius inwards for each angle at a time\n");
printf("\n%-5.0lf cases were taken for R ",s1[0]+2);
printf("\n%-5.0lf cases were taken for the angle from 0 to 180\n\n",s1[1]+2);

for(j=0 ; j<=s1[1]+1 ; ++j){


printf("For angle= %-6.2lf\n",angle);
for(i=s1[0]+1 ; i>=0 ; --i)
printf("%-20.5e",array1[i][j]);
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
printf("\n\n");
angle=angle+dangle;}

angle=0.0;
fprintf(fp_semi_circle3,"\nNumber of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
/* to print out our array1 */

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

fprintf(fp_semi_circle3,"The array will look like this\n");


fprintf(fp_semi_circle3,"From the R = radius inwards for each angle at a time\n");
fprintf(fp_semi_circle3,"\n%-5.0lf cases were taken for R ",s1[0]+2);
fprintf(fp_semi_circle3,"\n%-5.0lf cases were taken for the angle from 0 to 180\n\n",s1[1]+2);

for(j=0 ; j<=s1[1]+1 ; ++j){


fprintf(fp_semi_circle3,"For angle= %-6.2lf\n",angle);
for(i=s1[0]+1 ; i>=0 ; --i)
fprintf(fp_semi_circle3,"%-20.5e",array1[i][j]);
fprintf(fp_semi_circle3,"\n\n");
angle=angle+dangle;}

SEMICKL4.C
#include "header.h"
#include "hishead.h"
/* entring size of grid & mesh size */

extern void semi_circle4(int choice1, FILE *fp_semi_circle4)


{
double radius=1.0, angle, dangle=20.0, dradius=1.0, max=1.0, s1[2]={0}, s2[5]={0} ;
double integer1, integer2, fraction1, fraction2, number1, number2 ;
double arround1=0.0, bottom1=0.0,arround2=0.0, bottom2=0.0, tl=.1 ;
char sure='p';
double size, radians, constant, origin ;
double i, j , n , number, remainder, integerr ;
char ch='\0';
double cde[ROWS][COLUMNS] ;

do{
printf("\n\nEnter dimensions of semi-circle -irregular boundaries-\n\n");
do{
printf("\nEnter radius of semi-circle\n");
scanf("%lf",&radius);
if(radius==0.0)printf("\nYou must be joking, try again\n");
}while(radius==0.0);

do{
printf("\nEnter the increment of the angle in degrees, 180 must\n");
printf("be an integer multiple of this increment\n");
scanf("%lf",&dangle);
if(dangle==0.0)printf("\nYou must be joking, try again\n");
}while(dangle==0.0);

label5:
ex2();
printf("\nEnter the increment for r, that the program will use\n\n");
printf("PS: The radius that you previously entered must be an integer\n");
printf(" multiple of this increment\n");
printf(" If you did not enter these increments as requested you will \n");
printf(" be prompted to re-enter the dimensions of the semi-circle \n\n");
scanf("%lf",&dradius);
if(dradius==0.0){
printf("\nYou must be joking, try again\n");
goto label5;}

fprintf(fp_semi_circle4,"\nDimensions of semi-circle -irregular boundaries- as entered by user\n\n");


fprintf(fp_semi_circle4,"Radius of semi-circle is %-20.5lf\n", radius);
fprintf(fp_semi_circle4,"The increment of the angle in degrees is %-20.5lf\n", dangle);
fprintf(fp_semi_circle4,"The increment for r, that the program will use is %-20.5lf\n\n", dradius);

number1=radius/dradius;
fraction1=modf(number1,&integer1);
number2=(double)180.0/dangle;
fraction2=modf(number2,&integer2);
max=(integer1+1)*(integer2+1);
}while(!(fraction1==0.0 && fraction2==0.0 && max<=2500));

/*to save # of mesh points & h */


s1[0]=integer1-1;
s1[1]=integer2-1;

if(choice1==5 || choice1==6){
ex2();
printf("\nEnter semi-circle boundaries one at a time:\n");
printf("\nOrigin value, the center from which the s-circle is drawn\n");
scanf("%lf",&origin);
for(j=0; j<=s1[1]+1 ;++j)array1[0][j]=origin;

ex2();

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

angle=0.0;
printf("\n\nArround the s-circle, enter each point according to the angle indicated \n");
for(j=0; j<=s1[1]+1 ;++j){
printf("\nFor angle= %-6.2lf\n",angle);
scanf("%lf",&arround1);
array1[s1[0]+1][j]=arround1;
angle=angle+dangle;}

ex2();
angle=dradius;
printf("\n\nBottom boundary from the right\n");
for(i=1; i<=s1[0] ;++i){
printf("\nFor radius= %-10.3lf\n",angle);
scanf("%lf",&bottom1);
array1[i][0]=bottom1;
angle=angle+dradius; }

ex2();
angle=dradius;
printf("\n\nBottom boundary from the left\n");
for(i=1; i<=s1[0] ;++i){
printf("\nFor radius= %-10.3lf\n",angle);
scanf("%lf",&bottom2);
array1[i][s1[1]+1]=bottom2;
angle=angle+dradius;}

angle=0.0;
for(j=0; j<=s1[1]+1 ;++j)angle=angle+array1[s1[0]+1][j];
s2[4]=angle;
angle=0.0;
for(i=1; i<=s1[0] ;++i)angle=angle+array1[i][0];
s2[4]=s2[4]+angle;
angle=0.0;
for(i=1; i<=s1[0] ;++i)angle=angle+array1[i][s1[1]+1];
s2[4]=s2[4]+angle;
s2[4]=s2[4]+array1[0][0];

angle=s1[1]+(2.0*s1[0])+3;
s2[4]=s2[4]/angle;
}

else{
ex2();
/* entring grid boundaries */
printf("\nEnter semi-circle boundaries one at a time:\n\nArround the s-circle from the right boundary\n");
scanf("%lf",&arround1);
s2[0]=arround1 ;

printf("\nArround the s-circle from the left boundary\n");


scanf("%lf",&arround2);
s2[1]=arround2 ;

printf("\nBottom boundary from the right\n");


scanf("%lf",&bottom1);
s2[2]=bottom1;

printf("\nBottom boundary from the left\n");


scanf("%lf",&bottom2);
s2[3]=bottom2;

/*calculating initial conditions for intrnal mesh points*/

/* calculating the average value of boundaries */


s2[4]=radius*M_PI_2*(s2[0]+s2[1]);
s2[4]=s2[4]+(radius*(s2[3]+s2[2]));
s2[4]=s2[4]/(radius*(M_PI+2.0));
remainder=.5*s1[1];

/* giving the boundary points their boundary values */


for(j=1 ; j<remainder ;++j )array1[s1[0]+1][j]=s2[0];

modf(remainder,&integerr);
if(remainder==integerr){
for(j=integerr+1 ; j<s1[1]+1 ;++j)array1[s1[0]+1][j]=s2[1];}
else{
for(j=integerr+2 ; j<s1[1]+1 ;++j)array1[s1[0]+1][j]=s2[1];}

for(i=1 ; i<=s1[0] ;++i)array1[i][0]=s2[2];


for(i=1 ; i<=s1[0] ;++i)array1[i][s1[1]+1]=s2[3];

array1[s1[0]+1][0]=.5*(s2[2]+s2[0]);
array1[s1[0]+1][s1[1]+1]=.5*(s2[3]+s2[1]);
array1[0][0]=.5*(s2[3]+s2[2]);
if(remainder!=integerr)array1[s1[0]+1][integerr+1]=.5*(s2[0]+s2[1]);
for(j=0 ; j<=s1[1]+1 ;++j)array1[0][j]=array1[0][0];

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

/* end of entring grid boundaries */


ex2();
do{
printf("\n\nEnter tolerance of answer \n");
scanf("%lf",&tl);
if(tl==0){
printf("\nTolerance Zero might take a while\n");
printf("\nAre you sure y/n\n");
sure=tolower(getche());}
else break;

}while(sure!='y');

tl=fabs(tl);

/* giving all points in the array1 the average of the boundary value at first */
for(i=1 ; i<=s1[0] ; ++i)
for(j=1 ; j<=s1[1] ; ++j) array1[i][j] = s2[4] ;

size=s1[0]*s1[1];
size=size+s1[1]+2+(2*s1[0])+1;

ex2();
printf("\nThe # of internal mesh points is: %-5.0f\n",s1[0]*s1[1]);
printf("\nThe # of mesh points that we'll be operating on\n");
printf("including the ones on the boundaries is: %-5.0f\n\n",size);

fprintf(fp_semi_circle4,"\nThe # of internal mesh points is: %-5.0f\n",s1[0]*s1[1]);


fprintf(fp_semi_circle4,"\nThe # of mesh points that we'll be operating on\n");
fprintf(fp_semi_circle4,"including the ones on the boundaries is: %-5.0f\n\n",size);

printf("\nPress RETURN to continue");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
printf("\n\n");

for(i=1 ; i<=s1[0]+1 ; ++i)


for(j=0 ; j<=s1[1]+1 ; ++j) cde[i][j]=array1[i][j];
for(j=0 ; j<=s1[1]+1 ; ++j)cde[0][j]=array1[0][0];

radians=dangle*M_PI/180.0;

number=0;
do{
++number;
printf("\n# %-5.0lf\n",number);
n=0;
for(i=1 ; i<=s1[0] ; ++i){
for(j=1 ; j<=s1[1] ; ++j){
cde[i][j]=array1[i][j];
constant=(.5*i*i*radians*radians)/((i*i*radians*radians)+1);
array1[i][j]=constant*(((1-(.5/i))*cde[i-
1][j])+((1+(.5/i))*cde[i+1][j])+((1.0/(i*i*radians*radians))*cde[i][j-
1])+((1.0/(i*i*radians*radians))*cde[i][j+1]));
if((tl==0) && (array1[i][j] == cde[i][j]) ) ++n;
else if((tl!=0) && (fabs(array1[i][j] - cde[i][j]) < tl) ) ++n ; }
}
}while(n!=(s1[0]*s1[1]));

ex2();
angle=0.0;
printf("\nNumber of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
/* to print out our array1 */
printf("The array will look like this\n");
printf("From the R = radius inwards for each angle at a time\n");
printf("\n%-5.0lf cases were taken for R ",s1[0]+2);
printf("\n%-5.0lf cases were taken for the angle from 0 to 180\n\n",s1[1]+2);

for(j=0 ; j<=s1[1]+1 ; ++j){


printf("For angle= %-6.2lf\n",angle);
for(i=s1[0]+1 ; i>=0 ; --i)
printf("%-20.5e",array1[i][j]);
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
printf("\n\n");
angle=angle+dangle;}

angle=0.0;

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

fprintf(fp_semi_circle4,"\nNumber of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);


/* to print out our array1 */
fprintf(fp_semi_circle4,"The array will look like this\n");
fprintf(fp_semi_circle4,"From the R = radius inwards for each angle at a time\n");
fprintf(fp_semi_circle4,"\n%-5.0lf cases were taken for R ",s1[0]+2);
fprintf(fp_semi_circle4,"\n%-5.0lf cases were taken for the angle from 0 to 180\n\n",s1[1]+2);

for(j=0 ; j<=s1[1]+1 ; ++j){


fprintf(fp_semi_circle4,"For angle= %-6.2lf\n",angle);
for(i=s1[0]+1 ; i>=0 ; --i)
fprintf(fp_semi_circle4,"%-20.5e",array1[i][j]);
fprintf(fp_semi_circle4,"\n\n");
angle=angle+dangle;}

SOR1P.C
#include "header.h"
#include "header1.h"

extern void sor1p(double *s1, double tl, FILE *fp_sor1p)


{
double c, wopt ;
double row, column, savior ;
double i, j , n , number;
char ch='\0';

row=(s1[1]+2);
column=(s1[0]+2);

c=cos(M_PI/(s1[1]+1))+cos(M_PI/(s1[0]+1));
wopt=(4.0/(2+sqrt(4-(c*c))));

number=0;
do{
++number;
printf("\n# %-5.0lf\n",number);
n=0;
for(i=1 ; i<row-1 ; ++i){
for(j=1 ; j<column-1 ; ++j){
savior=array1[i][j];
array1[i][j]=array1[i][j]+(wopt*.25*(array1[i+1][j]+array1[i-1][j]+array1[i][j+1]+array1[i][j-1]-
(4*array1[i][j])+(cdef[i][j]*s1[2]*s1[2])));
if((tl==0) && (array1[i][j] == savior) ) ++n;
else if( (tl!=0) && (fabs(array1[i][j] - savior) < tl) ) ++n ; }
}
}while(n!=((row-2)*(column-2)));

ex2();
printf("\nThe optimum value of the S.O.R. factor used is, w = %-8.6f\n", wopt);
printf("\nThe number of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
fprintf(fp_sor1p,"\nThe optimum value of the S.O.R. factor used is, w = %-8.6f\n", wopt);
fprintf(fp_sor1p,"\nThe number of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
/* to print out our array1 */
printf("The array will look like this\n");
printf("From the upper to the lower side\n");
printf("\nrows= %-5.0lf",row);
printf("\ncolumns= %-5.0lf \n\n",column);
for(i=row-1 ; i>=0 ; --i){
printf("row # %-5.0lf\n",i+1);
for(j=0 ; j<column ; ++j)
printf("%-20.5e",array1[i][j]);
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
printf("\n\n");}

SOR2P.C
#include "header.h"
#include "header1.h"

extern void sor2p(double *s1, double tl, FILE *fp_sor2p)


{
double wopt ;
double row, column, savior ;
double i, j , n , number;

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

char ch='\0';
row=(s1[1]+2);
column=(s1[0]+2);

printf("\n\nMaximum acceleration is obtained for some optimum value of W\n");


printf("This optimum value will always lie between 1.0 and 2.0 \n");
printf("The following table shows the range of values for Wopt \n");
printf("that are customary in steady-state problems for several values \n");
printf("of p and q, where p=q - a square region - \n");
printf("p=vertical length divided by h q=horizontal length divided by h \n\n");
printf("p=q Wopt \n\n");
printf("2 1.000 \n");
printf("3 1.072 \n");
printf("5 1.260 \n");
printf("10 1.528 \n");
printf("20 1.729 \n");
printf("100 1.939 \n");
printf("infinity 2.000 \n\n");
printf("If your value is far from the optimum value then instead of decreasing\n");
printf("the number of iterations they will be increased, so be careful\n\n ");
printf("Enter your value of the S.O.R factor, w = \n");
scanf("%lf", &wopt);

number=0;
do{
++number;
printf("\n# %-5.0f\n",number);
n=0;
for(i=1 ; i<row-1 ; ++i){
for(j=1 ; j<column-1 ; ++j){
savior=array1[i][j];
array1[i][j]=array1[i][j]+(wopt*.25*(array1[i+1][j]+array1[i-1][j]+array1[i][j+1]+array1[i][j-1]-
(4*array1[i][j])+(cdef[i][j]*s1[2]*s1[2])));
if((tl==0) && (array1[i][j] == savior) ) ++n;
else if( (tl!=0) && (fabs(array1[i][j] - savior) < tl) ) ++n ; }
}
}while(n!=((row-2)*(column-2)));

ex2();
printf("\nFor the value of the S.O.R. factor given, w = %-8.6f\n", wopt);
printf("\nThe number of iterations needed was %-5.0f for %-10.5e tolerance\n\n", number,tl);
fprintf(fp_sor2p,"\nFor the value of the S.O.R. factor given, w = %-8.6f\n", wopt);
fprintf(fp_sor2p,"\nThe number of iterations needed was %-5.0f for %-10.5e tolerance\n\n", number,tl);
/* to print out our array1 */
printf("The array will look like this\n");
printf("From the upper to the lower side\n");
printf("\nrows= %-5.0f",row);
printf("\ncolumns= %-5.0f \n\n",column);

for(i=row-1 ; i>=0 ; --i){


printf("row # %-5.0f\n",i+1);
for(j=0 ; j<column ; ++j)
printf("%-20.5e",array1[i][j]);
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
printf("\n\n");}

SOR3P.C
#include "header.h"
#include "header1.h"

extern void sor3p(double *s1, double tl, FILE *fp_sor3p)


{
double row, column, wopt, c, savior ;
double i, j , n , number, saver;
char ch='\0';

row=(s1[1]+2);
column=(s1[0]+2);

c=cos(M_PI/(s1[1]+1))+cos(M_PI/(s1[0]+1));
wopt=(4.0/(2+sqrt(4-(c*c))));

number=0;
do{
++number;
printf("\n# %-5.0f\n",number);

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

n=0;
for(i=1 ; i<row-1 ; ++i){
for(j=1 ; j<column-1 ; ++j){
savior=array1[i][j];
saver=array1[i][j];
array1[i][j]=saver+.05*4*wopt*(array1[i+1][j]+array1[i-1][j]+array1[i][j+1]+array1[i][j-1]);
array1[i][j]=array1[i][j]+(.05*wopt*(array1[i-1][j-1]+array1[i-1][j+1]+array1[i+1][j-
1]+array1[i+1][j+1]));
array1[i][j]=array1[i][j]-(wopt*saver)+(.05*6*wopt*s1[2]*s1[2]*cdef[i][j]);
if((tl!=0.0) && (fabs(array1[i][j] - savior) < tl) ) ++n ;
else if((tl==0.0) && (array1[i][j] == savior) ) ++n; } }

}while(n!=((row-2)*(column-2)));

ex2();
printf("\nThe optimum value of the S.O.R. factor used is, w = %-8.6f\n", wopt);
printf("\nThe number of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
fprintf(fp_sor3p,"\nThe optimum value of the S.O.R. factor used is, w = %-8.6f\n", wopt);
fprintf(fp_sor3p,"\nThe number of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
/* to print out our array1 */
printf("The array will look like this\n");
printf("From the upper to the lower side\n");
printf("\nrows= %-5.0lf",row);
printf("\ncolumns= %-5.0lf \n\n",column);
for(i=row-1 ; i>=0 ; --i){
printf("row # %-5.0lf\n",i+1);
for(j=0 ; j<column ; ++j)
printf("%-20.5e",array1[i][j]);
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
printf("\n\n");}

SOR4P.C
#include "header.h"
#include "header1.h"

extern void sor4p(double *s1, double tl, FILE *fp_sor4p)


{
double row, column, wopt, savior ;
double i, j , n , number, saver;
char ch='\0';

row=(s1[1]+2);
column=(s1[0]+2);
printf("\n\nMaximum acceleration is obtained for some optimum value of W\n");
printf("This optimum value will always lie between 1.0 and 2.0 \n");
printf("The following table shows the range of values for Wopt \n");
printf("that are customary in steady-state problems for several values \n");
printf("of p and q, where p=q - a square region - \n");
printf("p=vertical length divided by h q=horizontal length divided by h \n\n");
printf("p=q Wopt \n\n");
printf("2 1.000 \n");
printf("3 1.072 \n");
printf("5 1.260 \n");
printf("10 1.528 \n");
printf("20 1.729 \n");
printf("100 1.939 \n");
printf("infinity 2.000 \n\n");
printf("If your value is far from the optimum value then instead of decreasing\n");
printf("the number of iterations they will be increased, so be careful\n\n ");
printf("Enter your value of the S.O.R factor, w = \n");
scanf("%lf", &wopt);

number=0;
do{
++number;
printf("\n# %-5.0f\n",number);
n=0;
for(i=1 ; i<row-1 ; ++i){
for(j=1 ; j<column-1 ; ++j){
savior=array1[i][j];
saver=array1[i][j];
array1[i][j]=saver+.05*4*wopt*(array1[i+1][j]+array1[i-1][j]+array1[i][j+1]+array1[i][j-1]);
array1[i][j]=array1[i][j]+(.05*wopt*(array1[i-1][j-1]+array1[i-1][j+1]+array1[i+1][j-
1]+array1[i+1][j+1]));
array1[i][j]=array1[i][j]-(wopt*saver)+(.05*6*wopt*s1[2]*s1[2]*cdef[i][j]);
if((tl==0) && (array1[i][j] == savior) ) ++n;

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

else if((tl!=0) && (fabs(array1[i][j] - savior) < tl) ) ++n ; }


}
}while(n!=((row-2)*(column-2)));

ex2();
printf("\nFor the value of the S.O.R. factor given, w = %-8.6f\n", wopt);
printf("\nThe number of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
fprintf(fp_sor4p,"\nFor the value of the S.O.R. factor given, w = %-8.6f\n", wopt);
fprintf(fp_sor4p,"\nThe number of iterations needed was %-5.0lf for %-10.5e tolerance\n\n",number,tl);
/* to print out our array1 */
printf("The array will look like this\n");
printf("From the upper to the lower side\n");
printf("\nrows= %-5.0lf",row);
printf("\ncolumns= %-5.0lf \n\n",column);
for(i=row-1 ; i>=0 ; --i){
printf("row # %-5.0lf\n",i+1);
for(j=0 ; j<column ; ++j)
printf("%-20.5e",array1[i][j]);
printf("\nPress RETURN to continue");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}
printf("\n\n");}

TIME.C
#include <time.h>
#include <stdio.h>
#include <dos.h>

void time1(FILE *fp_time1)


{
time_t timer;
struct tm *tblock;

/* gets time of day */


timer = time(NULL);

/* converts date/time to a structure */


tblock = localtime(&timer);

fprintf(fp_time1,"\n\nLocal time is: %s", asctime(tblock));

TYPE.C
#include "header.h"

extern int type(FILE *fp_type)


{
int choice, ch ;

do{
printf("\nNumerical Solutions for the Mixed Boundary Problems\n\n");
printf("Enter the # associated with the type of problem you would like to solve\n\n");

printf("1: Laplace eqn :Mixed Problem\n\n");

printf("2: Poisson eqn, function f(x,y) :Mixed Problem\n\n");

printf("3: Poisson eqn :Mixed Problem\n");


printf(" function f(x,y), entered as points by user\n\n");

printf("Your choice ");


scanf("%d",&choice);
}while(choice<1 || choice>3);

ex2();
printf("\n\nYour choice was\n\n");
switch(choice){
case 1:
printf("1: Laplace eqn :Mixed Problem\n\n");
break;
case 2:
printf("2: Poisson eqn, function f(x,y) :Mixed Problem\n\n");
break;
case 3:
printf("3: Poisson eqn :Mixed Problem\n");

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

printf(" function f(x,y), entered as points by user\n\n");


break;}

fprintf(fp_type,"\n\nYour choice was\n\n");


switch(choice){
case 1:
fprintf(fp_type,"1: Laplace eqn :Mixed Problem\n\n");
break;
case 2:
fprintf(fp_type,"2: Poisson eqn, function f(x,y) :Mixed Problem\n\n");
break;
case 3:
fprintf(fp_type,"3: Poisson eqn :Mixed Problem\n");
fprintf(fp_type," function f(x,y), entered as points by user\n\n");
break;}

if(choice==1)choice=3;
else if(choice==2)choice=4;
else choice=6;

printf("Press RETURN to continue\n\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

return choice;
}

TYPE4.C
#include "header.h"

extern int type4(FILE *fp_type4)


{
int choice, ch ;

do{
printf("Wellcome to Y. H. Kutkut's Numerical PDE Solver\n");
printf("Using the Finite Difference Method for solving PDEs\n\n");
fprintf(fp_type4,"\nWellcome to Y. H. Kutkut's Numerical PDE Solver\n");
fprintf(fp_type4,"Using the Finite Difference Method for solving PDEs\n\n");
printf("Enter the # associated with the type of PDE you would like to solve\n\n");

printf("1: Elliptic Partial Differential Equation\n");

printf("2: Parabolic Partial Differential Equation\n");

printf("3: Hyperbolic Partial Differential Equation\n\n\n");

printf("Your choice ");


scanf("%d",&choice);
}while(choice<1 || choice>3);

ex2();
printf("\nYour choice was\n\n");
switch(choice){
case 1:
printf("1: Elliptic Partial Differential Equation\n\n");
break;
case 2:
printf("2: Parabolic Partial Differential Equation\n\n");
break;
case 3:
printf("3: Hyperbolic Partial Differential Equation\n\n");
break;}

fprintf(fp_type4,"\nYour choice was\n\n");


switch(choice){
case 1:
fprintf(fp_type4,"1: Elliptic Partial Differential Equation\n\n");
break;
case 2:
fprintf(fp_type4,"2: Parabolic Partial Differential Equation\n\n");
break;
case 3:
fprintf(fp_type4,"3: Hyperbolic Partial Differential Equation\n\n");
break;}

printf("Press RETURN to continue\n\n");


ch='\0';
for(;;)
{ ch=getche();

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH 

if(ch=='\r')break;}

ex2();
printf("\nYour results will be stored in a file named PDEFILE.OUT\n\n");
printf("If no such file exists then it'll be created\n");
printf("If such a file already does exist then the results will be appended to it\n\n");
printf("Press RETURN to continue\n\n");
ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

return choice;
}

TYPE5.C
#include "header.h"

extern int type5(FILE *fp_type5)


{
int choice, ch ;

do{
printf("Numerical Solutions for the Neumann Problems\n\n");
printf("Enter the # associated with the type of problem you would like to solve\n\n");

printf("1: Laplace eqn :Neumann Problem\n\n");

printf("2: Poisson eqn, function f(x,y) :Neumann Problem\n\n");

printf("3: Poisson eqn :Neumann Problem\n");


printf(" function f(x,y), entered as points by user\n\n");

printf("Your choice ");


scanf("%d",&choice);
}while(choice<1 || choice>3);

ex2();
printf("\n\nYour choice was\n\n");
switch(choice){
case 1:
printf("1: Laplace eqn :Neumann Problem\n\n");
break;
case 2:
printf("2: Poisson eqn, function f(x,y) :Neumann Problem\n\n");
break;
case 3:
printf("3: Poisson eqn :Neumann Problem\n");
printf(" function f(x,y), entered as points by user\n\n");
break;}

fprintf(fp_type5,"\n\nYour choice was\n\n");


switch(choice){
case 1:
fprintf(fp_type5,"1: Laplace eqn :Neumann Problem\n\n");
break;
case 2:
fprintf(fp_type5,"2: Poisson eqn, function f(x,y) :Neumann Problem\n\n");
break;
case 3:
fprintf(fp_type5,"3: Poisson eqn :Neumann Problem\n");
fprintf(fp_type5," function f(x,y), entered as points by user\n\n");
break;}

printf("Press RETURN to continue\n\n");


ch='\0';
for(;;)
{ ch=getche();
if(ch=='\r')break;}

if(choice==3)choice=5;

return choice;
}

. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
7+((1'

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE


ERRATA
No matter how hard one tries, errors are inevitable. After printing of the project and
handing it in, the following typing mistakes were detected:

 P. IX, 7th line from the top.

 Solution by the explixit method with r=1.0 ....................................... 84

 Solution by the explixit method with r=0.25 ....................................... 84

 P. 1, 6th line from the bottom.

 u u 2 u  u 2 u
2
u, and but not , and .
x y  x 2  u2 xy

 u,
u
x
and
u
y
but not
2 u 2 u
x y
2
, 2
and
2 u
xy
.

 P. 84, second line from the top.

 x =0.10, c = 1.0, and r = 1.0.

 x =0.10, c = 1.0, and r = 0.25.

Yousof H. Kutkut
May, 18th 1994

KUTKUT'S NUMERICAL PDE SOLVER BY FINITE-DIFFERENCE

You might also like