An Educational Numerical Methods Package PDF
An Educational Numerical Methods Package PDF
An Educational Numerical Methods Package PDF
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.
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.
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.
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
$%#%
7KLV SURMHFW UHSRUWV RQ WKH ZRUN GRQH WR SURJUDP D XVHU IULHQGO\ HGXFDWLRQDO QXPHULFDO
$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
$SSHQGL[ %
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 ..................................
7$%/(2)
&217(176
&KDSWHU ,QWURGXFWLRQ
&DVHV 2I 3'(V 3UHVHQWHG %\ 7KH 3DFNDJH 7KH 1XPHULFDO 0HWKRGV 8VHG )RU
6ROYLQJ 7KHP
$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
&+$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
KXPDQ ERG\ $SSOLFDWLRQV DUH DOVR IRXQG LQ VWHDG\VWDWH KHDW IORZ HOHFWULFDO SRWHQWLDO
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
3$57,$/',))(5(17,$/(48$7,216
ZLWK UHVSHFW WR WZR RU PRUH LQGHSHQGHQW YDULDEOHV XVXDOO\ UHSUHVHQWLQJ WLPH OHQJWK RU
+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 >@
(//,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 =
∂ ∂\
[
∂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
)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
SK\VLFDO V\VWHPV FRXOG QRW EH VROYHG GLUHFWO\ EXW KDG WR EH VLPSOLILHG XVLQJ
$OWKRXJK WKHVH VROXWLRQV DUH HOHJDQW DQG \LHOG LQVLJKW WKH\ DUH OLPLWHG ZLWK UHVSHFW WR
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
WKH RQO\ PHDQV RI VROXWLRQ DSDUW IURP WKH XVH RI DQDORJ GHYLFHV $QDO\WLFDO
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
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
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
FDOFXODWHG IURP DQ DQDO\WLFDO IRUPXOD 7KH\ DUH QRW RI FRXUVH UHVWULFWHG WR SUREOHPV IRU
VHWV RI HTXDOO\ VSDFHG OLQHV RQH VHW SDUDOOHO WR WKH [D[LV WKH RWKHU SDUDOOHO WR WKH \D[LV
LQWHUVHFWLRQ 3 3 3LM RI WKH SDUDOOHO OLQHV ZKLFK DUH FDOOHG PHVK SRLQWV
RWKHU WHUPV LQ FRPPRQ XVH DUH SLYRWDO QRGDO JULG RU ODWWLFH SRLQWV7KLV 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
SRLQWV DQG LQ ZULWLQJ GRZQ IRU HDFK RI WKH Q LQWHUQDO PHVK SRLQWV WKH DOJHEUDLF HTXDWLRQ
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
%HVLGHV ILQLWHGLIIHUHQFLQJ WKHUH DUH RWKHU PHWKRGV IRU VROYLQJ 3'(V 0RVW LPSRUWDQW
DUH ILQLWH HOHPHQW LPSRUWDQW ZKHQ GHDOLQJ ZLWK KLJKO\ LUUHJXODU JHRPHWULHV 0RQWH
:+<,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
PDJQLWXGH RI WKH FRHIILFLHQW DW WKH GLDJRQDO LV QRW OHVV WKDQ WKH VXP RI WKH PDJQLWXGHV RI
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
LQWHULRU SRLQWV"
7DNLQJ WKH PHVK VL]H K FP 7KH SK\VLFDO SURSHUWLHV RI WKH PDWHULDO GR QRW HQWHU
∂ ∂ [
\
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
)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
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
:+$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
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\
• 7KH SURJUDP GLVSOD\V WKH HVVHQWLDO LQIRUPDWLRQ WKDW WKH XVHU VKRXOG NQRZ ZKHQ
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
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
DYHUDJH RI DOO WKH ERXQGDU\ SRLQWV VLQFH WKH LQWHUQDO SRLQWV ZLOO KDYH YDOXHV
• $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
WROHUDQFH UHGXFHV WR QHDUO\ KDOI 6RPH RSWLRQV SHUPLW WKH XVHU WR HQWHU KLVKHU
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
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
• $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
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
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
• $ 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
8VLQJWKH)LQLWH'LIIHUHQFH0HWKRGIRUVROYLQJ3DUWLDO'LIIHUHQWLDO(TXDWLRQV
• (OOLSWLF 3DUWLDO'LIIHUHQWLDO (TXDWLRQ
• 3DUDEROLF 3DUWLDO'LIIHUHQWLDO (TXDWLRQ
• +\SHUEROLF 3DUWLDO'LIIHUHQWLDO (TXDWLRQ
7\SHVRI(OOLSWLF3DUWLDO'LIIHUHQWLDO(TXDWLRQV
, &DVHVRIWKH(OOLSWLF3'('LULFKOHW3UREOHPZLWK5HJXODU%RXQGDULHV
,, 1XPHULFDO,WHUDWLYH0HWKRGV8VHGIRUVROYLQJWKH(OOLSWLF3'(ZLWK
'LULFKOHW&RQGLWLRQV5HJXODU%RXQGDULHV)RU HDFK RI WKH SUHYLRXV FDVHV
6XFFHVVLYH 2YHUUHOD[DWLRQ PHWKRG WKH XVHU HQWHULQJ KLVKHU 625 IDFWRU XVLQJ
SRLQW DSSUR[LPDWLRQ
6XFFHVVLYH 2YHUUHOD[DWLRQ PHWKRG WKH XVHU HQWHULQJ KLVKHU 625 IDFWRU XVLQJ
SRLQW DSSUR[LPDWLRQ
8VLQJ WKH $', PHWKRG ZLWK WKH XVHU HQWHULQJ KLVKHU S IDFWRU
,,, &DVHV RI WKH (OOLSWLF 3'( 'LULFKOHW 3UREOHP ZLWK ,UUHJXODU
%RXQGDULHV 1RQUHFWDQJXODU JULGV WKH 1XPHULFDO ,WHUDWLYH
0HWKRGV8VHGIRUVROYLQJWKHP
,9 &DVHVRIWKH(OOLSWLF3'(1HXPDQQ3UREOHPZLWK5HJXODU%RXQGDULHV
/DSODFH HTXDWLRQ 1HXPDQQ 3UREOHP
9 1XPHULFDO,WHUDWLYH0HWKRGV8VHGIRUVROYLQJWKH(OOLSWLF3'(ZLWK
1HXPDQQ&RQGLWLRQV5HJXODU%RXQGDULHV)RU HDFK RI WKH SUHYLRXV FDVHV
9, &DVHVRIWKH(OOLSWLF3'(0L[HG3UREOHPZLWK5HJXODU%RXQGDULHV
9,, 1XPHULFDO,WHUDWLYH0HWKRGV8VHGIRUVROYLQJWKH(OOLSWLF3'(ZLWK
0L[HG&RQGLWLRQV5HJXODU%RXQGDULHV)RU HDFK RI WKH SUHYLRXV FDVHV
&DVHV RI WKH 3DUDEROLF 3'( ZLWK 5HJXODU %RXQGDULHV WKH
1XPHULFDO,WHUDWLYH0HWKRGV8VHGIRUVROYLQJWKHP
127( 7+( 86(5 +$6 2 37,216 72 &+226( )520 )25 62/9,1* +,6+(5 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
∂ 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
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
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
.87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
NUMERICAL METHODS FOR SOLVING ELLIPTIC PDES PAGE 17
∇ 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
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
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
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
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
1RWH WKDW WKH SK\VLFDO SURSHUWLHV RI WKH PDWHULDO VWXGLHG GR QRW HQWHU WKH UHODWLRQ
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
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
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
/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
ω 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
∞
VROYLQJ WKH (OOLSWLF 'LULFKOHW 3'( ZLWK UHJXODU ERXQGDULHV ERWK /DSODFH DQG 3RLVVRQ LV
VHFWLRQ
6R IDU ZH KDYH DVVXPHG WKDW X WHPSHUDWXUH IRU H[DPSOH LV VSHFLILHG DW WKH ERXQGDULHV
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
: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
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
7KH SRLQW GLIIHUHQFH HTXDWLRQV IRU WKH LQWHUQDO PHVK SRLQWV DQG IRU WKH SRLQWV DW WKH VLGHV ZKHUH
7KH FHQWUDO GLIIHUHQFH TXRWLHQWV WKDW DUH ZULWWHQ IRU WKH JUDGLHQW FRQGLWLRQV
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
LV QRW UHFRPPHQGHG ,W ZDV LQLWLDOO\ GHYHORSHG IRU XQVWHDG\VWDWH SUREOHPV ZKLFK LV WKH
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
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
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
WHUPLQDWHG ZKHQ VXFFHVVLYH FDOFXODWLRQV DJUHH ZLWKLQ D JLYHQ WROHUDQFH (DFK VWHS RQ LWV
)RU IXUWKHU GHWDLOV FRQVXOW >@ S >@ S DQG >@ S
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
GHJUHHV &HOVLXV DQG WKH RWKHUV DUH KHOG DW R& ZKDW DUH WKH VWHDG\VWDWH WHPSHUDWXUHV
X[ R&
X[ R&
X\ R&
)RU K FP ZLWK WKH ORZHU HGJH LQVXODWHG DQG WKH RWKHU ERXQGDU\
FRQGLWLRQV UHPDLQLQJ DV WKH\ DUH :LWK WROHUDQFH DQG LQLWLDOL]LQJ WKH
:KHQ UXQQLQJ WKH SURJUDP WKH IROORZLQJ SDJHV VKRZ WKH UHVXOWV REWDLQHG
6HH JUDSK RQ SDJH
)RU K FP
********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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 -
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
row # 1
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
5.00000e+01
********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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 -
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
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
)RU K FP
********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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 -
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
row # 1
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00
5.00000e+01
********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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 -
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
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
********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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 -
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.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
********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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 -
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.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
********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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 -
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.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
*****************************************************************************
***
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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 -
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.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
*****************************************************************************
***
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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 -
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.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
*****************************************************************************
***
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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 -
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.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
*****************************************************************************
***
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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 -
10: using the alternating-direction implicit method (A.D.I.) with the user
entering his/her P factor
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
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
*****************************************************************************
***
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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 -
10: using the alternating-direction implicit method (A.D.I.) with the user
entering his/her P factor
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
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
)RU K FP ZLWK WKH ORZHU HGJH LQVXODWHG DQG WKH RWKHU ERXQGDU\ FRQGLWLRQV
*****************************************************************************
***
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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.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
)RU K FP ZLWK WKH ORZHU HGJH LQVXODWHG DQG WKH RWKHU ERXQGDU\ FRQGLWLRQV
********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
4: Mixed Problem
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
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
)RU K FP ZLWK WKH ORZHU HGJH LQVXODWHG DQG WKH RWKHU ERXQGDU\ FRQGLWLRQV
********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
4: Mixed Problem
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
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
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
'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
: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
(;$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
$ 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
)RU D PRUH GHWDLOHG DSSURDFK FRQVXOW >@ S DQG >@ S
'LVFXVVHG RQ S
π
$QG ∆r = 0.2 DQG ∆θ =
8
• -DFREL S
• *DXVV6HLGHO S
• -DFREL S
• *DXVV6HLGHO S
:KHQ UXQQLQJ WKH SURJUDP WKH IROORZLQJ SDJHV VKRZ WKH UHVXOWV REWDLQHG
********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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 -
********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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 -
• -DFREL
********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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 -
• *DXVV6HLGHO
********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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 -
&+$37(5
180(5,&$/0(7+2'6)2562/9,1*
3$5$%2/,&3$57,$/',))(5(17,$/(48$7,216
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
(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
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[WW X[ I[
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
XW 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
7+((;3/,&,70(7+2'
7KLV PHWKRG GLYLGHV VSDFH DQG WLPH LQWR GLVFUHWH XQLIRUP VXELQWHUYDOV DQG UHSODFHV ERWK
FRPSXWH YDOXHV RI D IXQFWLRQ DW D WLPH ∆W DIWHU WKH LQLWLDO WLPH 7KHVH YDOXHV DUH WKHQ
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
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
∆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
$ ODUJH IODW VWHHO SODWH LV FP WKLFN ,I WKH LQLWLDO WHPSHUDWXUHV R& ZLWKLQ WKH SODWH DUH
)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
• ([SOLFLW PHWKRG
********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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
• ([SOLFLW PHWKRG
********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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
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
LPSOLFLW PHWKRG LQ FRQWUDVW WR WKH H[SOLFLW PHWKRG RI WKH SUHYLRXV VHFWLRQ 7KLV UHTXLUHV
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[
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
6ROYH IRU
• U S
• U S
• U S
:KHQ UXQQLQJ WKH SURJUDP WKH IROORZLQJ SDJHV VKRZ WKH UHVXOWV REWDLQHG
• &UDQN1LFROVRQ PHWKRG
********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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
• &UDQN1LFROVRQ PHWKRG
********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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
• &UDQN1LFROVRQ PHWKRG
********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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
'(5,9$7,9(%281'$5<&21',7,216
5HDOO\ LPSRVH QR QHZ GLIILFXOWLHV EHFDXVH ZH FDQ H[WHQG WKH UHJLRQ DUWLILFLDOO\ DQG
,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
: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
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
X IRU ≤ [ ≤ ZKHQ W
/HW ∆[
W [
:KHQ UXQQLQJ WKH SURJUDP WKH IROORZLQJ SDJHV VKRZ WKH UHVXOWV REWDLQHG
• ([SOLFLW PHWKRG
********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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
• &UDQN1LFROVRQ PHWKRG
********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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
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
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 ∂ [ ∂ \
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\
ZKHUH L M Q DUH SRVLWLYH LQWHJHUV DQG GHQRWH WKH YDOXHV RI X DW WKHVH PHVK SRLQWV E\
DSSHDUV DWWUDFWLYHO\ VLPSOH EXW LV FRPSXWDWLRQDOO\ ODERULRXV EHFDXVH WKH FRQGLWLRQ IRU
QHFHVVDWHV H[WUHPHO\ VPDOO YDOXHV RI ∆W )RU PRVW SUREOHPV LW LV DQ LPSUDFWLFDO PHWKRG
+ +
= ^ +
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
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
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 QWK 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
7KH DGYDQFHPHQW RI WKH VROXWLRQ WR WKH QWK 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
([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
ULJKW R&
:KHQ UXQQLQJ WKH SURJUDP WKH IROORZLQJ SDJHV VKRZ WKH UHVXOWV REWDLQHG
• $', PHWKRG
********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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
For row 5
For row 4
For row 3
For row 2
For row 1
For row 5
For row 4
For row 3
For row 2
For row 1
For row 5
For row 4
For row 3
For row 2
For row 1
For row 5
For row 4
For row 3
For row 2
For row 1
For row 5
For row 4
For row 3
For row 2
For row 1
For row 5
For row 4
For row 3
For row 2
For row 1
For row 5
For row 4
For row 3
For row 2
For row 1
&+$37(5
180(5,&$/0(7+2'6)2562/9,1*
+<3(5%2/,&3$57,$/',))(5(17,$/(48$7,216
7KLV HTXDWLRQ ZDV FODVVLILHG DV +\SHUEROLF EHFDXVH FRPSDULQJ WR WKH VWDQGDUG IRUP RI D
3'( LQ WZR LQGHSHQGHQW YDULDEOHV [ DQG W
: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
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 ∂[
(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
$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
$ 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
/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
\L
= \ + +
L
\L −
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
********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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
• )RU ∆[ FP
********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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
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
6XSHUVFULSWV DUH XVHG LQ (T WR GHQRWH WLPH )RU WKH ILUVW WLPH VWHS ZH JHW
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
(;$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
$ 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
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
:KHQ UXQQLQJ WKH SURJUDP WKH IROORZLQJ SDJHV VKRZ WKH UHVXOWV REWDLQHG
********************************************************************************
Wellcome to Y. H. Kutkut's Numerical PDE Solver
Using the Finite Difference Method for solving PDEs
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
For row 5
For row 4
For row 3
For row 2
For row 1
For row 5
For row 4
For row 3
For row 2
For row 1
For row 5
For row 4
For row 3
For row 2
For row 1
For row 5
For row 4
For row 3
For row 2
For row 1
For row 5
For row 4
For row 3
For row 2
For row 1
For row 5
For row 4
For row 3
For row 2
For row 1
For row 5
For row 4
For row 3
For row 2
For row 1
For row 5
For row 4
For row 3
For row 2
For row 1
For row 5
For row 4
For row 3
For row 2
For row 1
$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
$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
'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
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
7KH IROORZLQJ SDJHV JLYH D SODLQ OLVWLQJ RI WKH VRXUFH FRGH RI DOO ILOHV XVHG LQ .XWNXW
V
1XPHULFDO 3'( 6ROYHU
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&
ADI1.C
#include "header.h"
#include "header1.h"
row=(s1[1]+2);
column=(s1[0]+2);
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");
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));}
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; } }
ex2();
. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH
ADI2.C
#include "header.h"
#include "header1.h"
row=(s1[1]+2);
column=(s1[0]+2);
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));}
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; } }
++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
ADI3.C
#include "header.h"
#include "header1.h"
row=(s1[1]+2);
column=(s1[0]+2);
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));}
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; } }
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"
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];}
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");}
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
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) );}
label33:
free(output);
}
BNDRY2.C
#include "header.h"
#include "hishead.h"
. 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);
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 ;
average=2*((row-2)+(column-2))+4;
average=result/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 */
. 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;}
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));
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 ;
modf(remainder,&integerr);
. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH
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);
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
}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);
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);
CIRCLE4.C
#include "header.h"
#include "hishead.h"
/* entring size of grid & mesh size */
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;}
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));
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 ;
. 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);
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
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);
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);
CRANK2.C
#include "header.h"
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",°ree);
if(degree>9){
printf("\nDegree should be <= 9\n");
goto label1;}
printf("\nEnter coefficients of X, proceeding from const to highest degree");
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; }
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));
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]);
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));
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",°ree);
if(degree>9){
printf("\nDegree should be <= 9\n");
goto label1;}
printf("\nEnter coefficients of X, proceeding from const to highest degree");
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);
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));
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(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));
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"
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");
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");
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;}
return choice;
}
DECIDE1.C
#include "header.h"
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");
. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH
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");
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;}
. 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;}
return choice;
}
DECIDEH.C
#include "header.h"
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");
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");
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;}
return choice;
}
. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH
DECIDEP.C
#include "header.h"
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");
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");
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
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;}
. 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)) ;
printf("\n\n");
ELLIPTIC.C
#include "header.h"
extern void graph1(void);
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");
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
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;
output=malloc(8*2*(s1[8]+2));
if(!output){
ex2();
printf("\nNot enough memory to allocate buffer\n");
printf("Re-enter arguments\n");
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;}
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;
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"
label22:
do{
ex2();
printf("\nEnter length of the X space dimension\n");
scanf("%lf", &space);
s1[0]=space;
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) ;
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");
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;
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"
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");
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; }
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;
ENTERH1.C
#include"header.h"
label22:
do{
ex2();
printf("\nEnter length of the X space dimension\n");
scanf("%lf", &space);
s1[0]=space;
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) ;
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");
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;
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>
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>
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"
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",°ree);
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
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]);
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));
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));
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);
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",°ree);
if(degree>9){
printf("\nDegree should be <= 9\n");
goto label1;}
printf("\nEnter coefficients of X, proceeding from const to highest degree");
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);
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
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));
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));
box=(k+1)*value*s1[4]; }
}}
label33:
free(output);
}
GAUSS1P.C
#include "header.h"
#include "header1.h"
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"
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;
. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH
int poly[8];
maxx = getmaxx();
maxy = getmaxy();
/*
4th vertex. fillpoly automatically
closes the polygon.
*/
poly[6] = 3.0 * maxx / 4; /* 1st vertex */
poly[7] = maxy / 4;
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;
midx = getmaxx() / 2;
midy = getmaxy() / 2;
. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH
/* 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;
midx = getmaxx() / 2;
midy = getmaxy() / 2;
/* clean up */
getch();
closegraph();
GRDBND.C
#include "header.h"
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;
. 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"
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));
. 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"
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");}
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));
}}
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) );}
label33:
free(output);
. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH
HYPER1.C
#include "header.h"
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",°ree1);
if(degree1>9){
printf("\nDegree should be <= 9\n");
goto label7;}
printf("\nEnter coefficients of X, proceeding from const to highest degree");
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",°ree);
if(degree>9){
printf("\nDegree should be <= 9\n");
goto label1;}
printf("\nEnter coefficients of X, proceeding from const to highest degree");
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; }
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));
box=value*s1[4];
for(k=1; k<=integer ;++k){
for(i=1; i<=value ;++i){
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));
box=(k+1)*value*s1[4]; }
}}
label33:
free(output);
}
INITIAL.C
#include "header.h"
#include "hishead.h"
. 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);
/* 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] ;}
JACOBI1P.C
#include "header.h"
#include "header1.h"
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){
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"
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"
. 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:
return (0) ;
MAIN1.C
#include "header.h"
. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH
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"
. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH
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);
case 2:
clrscr();
choice2=eqn1(fp2);
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
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);
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"
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"
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("5 : Successive Overrelaxation method, the user entering his/her S.O.R. factor\n");
printf(" using 5 point approximation \n\n");
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("7 : Successive Overrelaxation method, the user entering his/her S.O.R. factor\n");
printf(" using 9 point approximation \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");
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
. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH
return choice;
}
METHOD5.C
#include "header.h"
do{
printf("Enter the # associated with the method you would like to use\n");
printf("for solving your Problem\n\n");
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;}
. 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"
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'));
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'));
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'));
. 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'));
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;}
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;}
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;}
. 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]);
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);
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
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");}
. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH
MIXED2.C
#include "header.h"
#include "header1.h"
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'));
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'));
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'));
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
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;}
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;}
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;}
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]);
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);
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);
. 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;
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");}
MIXED3.C
#include "header.h"
. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH
#include "header1.h"
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'));
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'));
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'));
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'));
. 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;}
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;}
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;}
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]);
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);
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);
. 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"
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("\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");
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");
. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH
PASSWORD.C
#include "header.h"
printf("\n\nEnter Password\n\n");
for(i=0; i<6 ; ++i) *(p1+i)=getch();
POINTS.C
#include "header.h"
#include "hishead.h"
row=(s1[1]+2);
column=(s1[0]+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=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);
/* 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] ;}
return tl;
}
POISSON1.C
#include "header.h"
#include "header1.h"
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);
POISSON2.C
#include "header.h"
#include "header1.h"
. 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");
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"
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"
char ch='\0';
label1:
ex2();
printf("Enter function of Y\n");
printf("Enter degree of function\n");
scanf("%lf",°ree1);
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",°ree2);
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);
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;}}
. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH
SEMICKL3.C
#include "header.h"
#include "hishead.h"
/* entring size of grid & mesh size */
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;}
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));
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 ;
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];}
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];
}
}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);
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);
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
SEMICKL4.C
#include "header.h"
#include "hishead.h"
/* entring size of grid & mesh size */
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;}
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));
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 ;
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];}
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
}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);
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);
angle=0.0;
. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
$SSHQGL[ % 3DJH
SOR1P.C
#include "header.h"
#include "header1.h"
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"
. 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);
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);
SOR3P.C
#include "header.h"
#include "header1.h"
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"
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
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>
TYPE.C
#include "header.h"
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");
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
if(choice==1)choice=3;
else if(choice==2)choice=4;
else choice=6;
return choice;
}
TYPE4.C
#include "header.h"
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");
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;}
. 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"
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");
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;}
if(choice==3)choice=5;
return choice;
}
. 87.87
6 180(5,&$/ 3'( 62/9(5 %< ),1,7(',))(5(1&(
7+((1'
u u 2 u u 2 u
2
u, and but not , and .
x y x 2 u2 xy
u,
u
x
and
u
y
but not
2 u 2 u
x y
2
, 2
and
2 u
xy
.
Yousof H. Kutkut
May, 18th 1994