±`·L¤Àµ{¨D¸Ñ¡G¨B´T½Õ¾A±±¨îªº¶©¥¨¡X®w¶ðªk
¥iÅܤƪº¨B´T±±¨î¤§¤èªkºKn
R-K ¤èªk¦b«e¤@ӳ椸¤v¸g¤¶²Ð¹L¡A¨Ï¥Î·L¨B°Æµ{¦¡ rk4¡A¥¦·f°t rkdumb ³oÓ¨C¤@Ó·L¨B³£µ¥¶¡¹jªº¿n¤ÀÅX°Ê¾¹°Æµ{¦¡¡A´£¨Ñ¤Fª½±µ¦³®Äªº¨D¸Ñ¤è®×¡C
µM¦Ó¡A§Ṳ́£Ãø·Q¹³¡A¦b±À¶i·L¨Bªº¨D¸Ñ¹Lµ{¤¤¡A¦U¶¥±×²v¨ç¼ÆªºÅܤƧֺC¦b¦U³B¤£ºÉ¬Û¦P¡AY¥H¦P¼Ëªº¨B´T¼e«×¨Ó±À¶i¡A«h¥i¯à¦³¨Ç¦a¤èºë½T«×¤£¨¬¡A¦Ó¦³¨Ç¦a¤è«h¤S²Ó¤À¤F¤Ó¦h¤£¥²nªº°Ï¶¡¡A³o¨Ã¤£¬O®Ä²v³Ì°ªªº¤èªk¡C
¦pªG¿n¤ÀÅX°Ê¾¹°Æµ{¦¡¯àºÊ±±¨C¤@¨Bªº»~®t¡A¨Ã§@§´µ½ªº½Õ¾A¥H²Å¦X¨Ï¥ÎªÌ©Ò³]©wªº³]®t®e§Ô«×¡A«h¨ç¼ÆÅܤư_¥ñ¶V¤jªº¦a¤è¤~·|¥Î¨ì¶V¤p¨B´Tªº¡A¦³§U©ó¾ãÅé®Ä²vªº¤j´T´£ª@¡C³oºØ¤èªk¡A§Ú̺٤§¬°¨ã¨B´T½Õ¾A±±¨î¥\¯à¡]Adapted Step-size Control¡^ªº¤èªk¡C
¦b¥»¸`¡]NR 16.2) ¤¤½Ò¥»¤¶²Ð¦³»~®t±±¨îªº R-K ºtºâªk¡A¨Ã±ÀÂˬ°¥i¥Î©ó¦hºØ¤£¦PÃþ«¬±`·L¤À¤èµ{¦¡ªº¨D¸Ñªºªx¥Î¤u¨ã¡A¤×¨ä¬O¦b¤U¤@³¹¤¶²Ð¨âÂIÃä¬ÉÈ°ÝÃD¡]NR 17.1¡B17.2¡^®É¤]·|¥Î¨ì¡A¦]¦¹§ä§Ṳ́´n»{ÃѨým²ß¨Ï¥Î³oÓ¤èªk¡C
¨B´T½Õ¾Aªº°ò¥»Æ[©À¡A¦b©ó (1) ¯àºÊ±±»~®t¤j¤p (2) ¯à¨Ì»~®t¤j¤p½Õ¾ã¥X³Ì¾A¤Áªº¨B´T¡C
¦b¦¹ºtºâªk³]pªº§Þ¥©°ª©ó°ò¥»ªº¼Æ¾ÇÆ[©À¡A¥»³æ¤¸§Ú¤]´N¤£n¨D¤j®a¤@©wn¼ô±x¨ä¤½¦¡±À¾É¤Wªº²Ó¸`¡A¶È¹ªÀy¦³¿³½ì¤§¦P¾Ç¦Û¦æ²`¤J¾\Ū¤U¦CÁ¿¸q¤Îì½Ò¤å¡C¦Ü©ó°Æµ{¦¡ªº¨Ï¥Î§ÚÌ«hn¨D¦P¾Ç̳£ÁÙ¬On·|¡A¦]¦¹·|§@¸Ô²Óªº¤ÀªR»¡©ú¡C
¤£ºÞ¦p¦ó¡A¦b¦¹±Nºtºâªk³]pªºnÂI¡]±µ½Ò¤å¶¶§Ç¡^¸Ôz¦p¤U¡G
(1) »~®t¦ôºâªº¤è¦¡
¤@ºØ±`¥Îªº¤èªk¡]¦ý¤£¬O¥»¸`°Æµ{¦¡©Ò±Ä¥Îªº¡^¡A¬O¦bìºtºâªkªº±À¾É¦¡¤¤§â¨B¼Æ¥[¿¡]§Y¨B´T´î¥b¡^¡A¦Ó¨B¼Æ¥[¿±¡ªp¤U¨«¨â¨Bµ¥®Ä©óìºtºâªk¨«¤@¨B¡A¦ý¥¦Ìªº®õ°Ç®i¶}§Î¦¡¨Ã¤£¥þ¦P¦]¦¹¦³©Ò®t²§¡A
§Q¥Î¦¹¤@®t²§¥i¦¸±o¥Xìºtºâªk¤º¦bªº»~®t¦æ¬°¡]¥H¥¿¤ñ©ó¨B´T¤j¤pªº´X¦¸¤è³oºØ¤è¦¡§e²{¡^¡C
½Ò¤å¤½¦¡ (16.2.1) ¦Ü (16.2.3) ´N¬O¦b»¡©ú±À¾É²Ó¸`¡A¬OÆZ´¶¹Mªº§@ªk¡C¦³¥[¨«¨B¼Æ¿¼W¤§¤èªkªº¨ç¼Æ¨DȰʧ@ùØ¡A¦³¨Ç¬O¥ý«e¨«¤@¨B´N°µ¹Lªº¡A¨£¹Ï
¦]¦¹Á`¦@¬O 11 ¦¸¡A¤ñ°_¤@¶}©l´N¥Î¤@¥b¨B´T¤j¤pªº 8 ¦¸¡]¦b¬Û¦P¥ß¨¬ÂI¤W¨Ó¤ñ¡An¨â¦¸¥b¨B¤~¬Û·í©ó±À¨B¤@¨Bªº½d³ò¡^¡A¥N»ù¬O 1.375 ¿¡A¤£ºâ¤Ó¦h¡A¦Ó©Ò´«±oªº¬O¦ôpªº»~®t¸ê°T¡A¨Æ¹ê¤W·|Àò±o¬Û·í¤jªº®Ä¯à´£ª@¡C
¥H¤Wªº§@ªk¡A¬Ý°_¨ÓÁöµM¥i¥HÄ~Äò¦A¶i¤@¨B²Õ¦X¥X§ó°ª¶¥ªººtºâªk¡A
¦ý¤w¦³¬Û·í°ª¶¥¤èªk¥i¥Îªº±¡ªp¤U¡A³o¥¼¥²¬O¸Ñ¨M°ÝÃD©Ò³Ì»Ýnªº¡]§ó°ª¶¥¤£¤@©w¥Nªí§óºë±K¡^¡A³o¼Ë§@¨Ã¤£¯àµ¹¥X§Ú̳̻Ýnªº¡A´N¬O»~®t¦ôp¡C
½Ò¥»ùر¤]¶¶«K´£¨ì¬°¤°»ò 4 ¶¥ R-K ¤èªk¬O³Ì³Q¼s¬°±Ä¥Îªº¡A§ó°ª¶¥ªº R-K ¤èªk¤]¦³³Q±À¾É¥X¨Ó¡A¤j®aµo²{¥un¬O¶¥¼Æ M ¤j©ó 4 ªº¡A³£»Ýn¦h©ó M ¦¸ªº±×²v¨ç¼Æ¨DÈ¡]¦ý¤£·|¦h©ó M+2 ¦¸¡^¡A¦]¦¹¡A¹ï©ó¶È»Ý¨DÈ 4 ¦¸ªº 4 ¶¥ R-K ¤èªk¦ü¥G¬O¤ñ¨ä¥L¶¥¼Æ§ó¦Eºâ¡]½Ò¤å§@ªÌ¦A¦¸´£¿ô¤j®a¶V°ª¶¥¥¼¥²¶Vºë·Ç¡^¡C
¦b¥»¸`°Æµ{¦¡©Òn¥Î¨ìªº¡A«h¬O°w¹ï R-K¡A¦³¥t¤@ºØ¥i¦æªº¤è¦¡¡A¥¦¬O±q¤@ӻݧ@¤»¦¸¨ç¼Æ¨DȪº¤¶¥ªº R-K ¤èªk¥Xµo¡A
¥¦¦³¥t¤@¦¡¯S®í²Õ¦X¥i§Î¦¨¥|¶¥¤èªk¡A
³o¨âªÌªº®t²§¤]´N´£¨Ñ¤F»~®tªº©w¸q¡]´«¥y¸Ü»¡¡A´N¬Oªí¥Ü¥X¨B´T¤j¤p¡]x ªº»~®t¡^»P¨ç¼Æ»~®t¡]y ªº»~®t¡^¶¡ªºÃö«Y¡A¦p¤U¦¡¡G
³o¨ä¤¤ªº«Y¼Æ³£¤w¸g¬O¦³¤H±À¾É§¹¦¨ªº½T©wÈ¡A¦p¤Uªí
(2) ½Õ¾ã¨B´Tªºµ¦²¤
«e±¤w´£¨ì¡A»~®t¦ôp«Ü«nªº¤@ÂI¬O¡A«Ý¨D¸Ñ¨ç¼Æ y ªº»~®t D »P¨B´T¤j¤p h ªºÃö«Y¬O«ç»ò¼Ë¡H
«e±ªº±À¾É¬Ý±o¥X D ¬O»P h5 ¦¨¥¿¤ñ¡A¦ý³s±µ¨âªÌªº¤ñ¨Ò±`¼Æ§ÚÌ·íµM¬O¤£ª¾¹D¡C ²{¦bÅý§ÚÌ·Q¹³¨Ï¥Î¤F h1 ¦Ó¾ÉP¤F»~®t¥¿¤ñ©ó D1¡A ¦Ó§ÚÌ쥻Y¬O¨ú¤F h0 ¦Ó³y¦¨¤F D0¡A«h h1 »P h0 ªºÃö«Y´N·|¬O
§Ú̲ߺD¤W±N D0·í§@¬O¨Ï¥ÎªÌ¹w¥ý³]©w¦nªº»~®t®e§Ô«×¡A«h¤W±³oÓÃö«Y¦¡¦³¨âºØ¥Îªk¡G¨ä¤@¡B·í§Ú̲{¦b³o¤@¨B¥Îªº h1 Àò±oªº D1 ¤ñ D0 ¤j¡A§Ú̪¾¹D§â¤ñ¨Ò¶}¤¦¸¤è¼¤Wì¨Ó¨Ï¥Îªº¨B´T¨Ó«¶]¡F¨ä¤G¡B¦pªG³o¤@¨B h1 ¦ô¥X¨Óªº D1 ¤ñ D0 ¤p¡A«h¤W¦¡§i¶D§Ṳ́U¤@¨Bªº h2 ¤j·§¥i¥H©ñ¤j¨ì¦h¤j¤´¬O¦w¥þªº¡C
±µ¤U¨Óªº°ÝÃD¡A¬O D0 ¥»¨À³¸Ó«ç»ò³]©w¡H¡]½Ðª`·N¡A D0 ¬O¤@Ó¦V¶q¡Aµø°ÝÃDªº»Ýn¡A¥¦¹ï©ó¨C¤@Ó yi ³£¥i¥H¦³¿W¥ßªºÈªº¡C¡^ §ÚÌ«e±»¡n§â¥¦·í§@¬O»~®t®e§ÔÈ¡Aµ¹¤@Óµ´¹ï¼Æ·íµM¬O¤@ºØ¤èªk¡A¦ý¬O«Ü¦h®ÉÔ¡A§Ú̹ï°ÝÃDºë½T«×ªºn¨D¬O¬Û¹ï©ó¨ç¼Æ·í®ÉªºÈ¡A¦]¦¹Y³]¦¨¬O¬Yӫܤpªº¼Æ¼¤W yi ªº¤j¤p eyi¡A¤]¬O«Ü¦X²z¡CµM¦Ó¡A¦pªG³oÓ¨ç¼Æ¬O·|®¶ÀúÅܤƦӳq¹L¹s¡A§Ṳ́]¥i¯à§Æ±æ¥¦¬O³]©w¬°¬O e ¼¤W y ¤§³Ì¤jȪºµ´¹ïÈ¡A¤]¬O¦X²zªº¦Ò¶q¡C¹ê»Ú¤W¼g¦¨µ{¦¡®É¡A¥i¥H¦³¤@¦æ¬O³]¦¨
D0 = eps * yscal(i)
¦pªG y ¬Û¹ïªº¬Û¹ï¤j¤p¬O«nªº¡A´N§â¨C¤@·L¨Bªºªì©l y ȶǤJ¦¨ yscal¡AY¬On¥Îµ´¹ï®e§ÔÈ¡A«h§ï¶Ç¤J©Òn©wªº¼ÆÈ¡C¦b½Ò¥»©Òªþªº°Æµ{¦¡¤¤¡A¬Æ¦Ü¦h¥[¤F»P±×²v¼¤W¨B´T¦³Ãöªº¶µ¡A¦Ó§â yscal(x) ³]¦¨¬° |y(x)| + |h*dydx(x)|¡A¤§©Ò¥H·|¦³²Ä¤G¶µªº§Î¦¡¡A¬O¦]¬°§Úªù¤]·|·QºÊ±±¨C¤@·L¨B¤U¨ç¼ÆªºÅܤƶq¡C¡]³o¨ä¤¤ªº½Ñ¦h¦Ò¶q¡A¥i°Ñ¨£½Ò¤åªº¶i¤@¨B²Ó¸`¡C¡^
¦ý¬O¡AD0 ¥X²{¤F h ªº¤@¦¸¥¿¤ñÃö«Y·|¼vÅT¨ì«e±¶}¤¦¸¤èªº¤ÀªR¡A©Ò©¯¥|¦¸¤è©Î¤¦¸¤è¨Ã¤£¬O¨º»ò¤£¦P¡A½Ò¥»§@ªÌ°ò©ó¹ê§@¸gÅç«Øij¤F¤U¦¸³q¥Îªº§PÂ_¾÷¨î¡A°ò¥»¤Wªº·Qªk´N¬O¡A·í¨B´T»Ýn©ñ¤j¡]²{¦³¨B´T¤Ó«O¦u¡^¡A¥Î¤p¤@ÂIªº¶}¤èÈ¡F·í¨B´T»ÝnÁY¤p¡]²{¦³¨B´T¤Ó¿E¶i¡^¡A¥Î¤j¤@ÂIªº¦¸¤èÈ
¨ä¤¤ S ¬O¤@Ó²¤¤p©ó 1 ªº±`¼Æ¡C
°Æµ{¦¡ªº¨Ï¥Î
½Õ¾A¨B´T±±¨îªº R-K ¤èªk¥Ñ¤U¦C¤@²Õ¤TӰƵ{¦¡¹F¦¨¡A¨ä¥\¯à²¤z¦p¤U¡]¦A¦¸±j½Õ¡A¤j®an¾Ç·|¦Û¦æ¾\Ū°Æµ{¦¡ªº^¤å¨Ï¥Î»¡©ú¡A§A¦Û¤wn¯à¬Ý±o¥X¤U¦CnÂI¾ã²z©Ò¦CÁ|ªº¨Æ¶µ¡^¡A
odeint¡GÅX°Ê¾¹¡]driver¡^°Æµ{¦¡¡A·|°Ý¦ÛÅܼƽd³ò¡Bªì©lÈ¡Bºë«×±±¨î¬ÛÃö±ø¥ó¡A¥H¤Î´£¨Ñ common block Åý¥Dµ{¦¡¦³©ñµª®×ªº¦a¤è¡C
rkqs¡G"«~½èºÞ¨î"¡CºÊ±±¨CÓ·L¨BªººIÂ_»~®t¡]trancation error¡^¨Ã¥B½Õ¾ã¨B´T ¡C³Q odeint ©I¥s¡A¦Û¤w¦A©I¥s rkck¡C
rkck¡G¯à¶i¦æ¤¶¥ R-K ¹Bºâªº·L¨Bªº±À¶i¡A¨Ã¥]§t¤º´O¡]embeded¡^4 ¶¥ R-K ¥H¨Ñ§@»~®tºÊ±±¡C
¨Ï¥ÎªÌ¦Û¦æ¶·´£¨Ñªº derivs °Æµ{¦¡·|³Q odeint ¡]¬°¤F§@¨B´T±±¨î¡^ ¥H¤Î³Q rkck ¡]¬°¤F±À¶i¤@·L¨B¡^¨âӰƵ{¦¡©Ò©I¥s¡C
¥H¤U¬O¥¦Ì¦U¦Ûªº²Ó¸`¡G
rkqs
»Ýn¨Ï¥ÎªÌ´£¨Ñªº derivs »P¤U±ªº rkck ¡A¥¦¬O³Q odeint ©I¥s¡A¦Û¤w¦A©I¥s rkck¡A¥Dµ{¦¡»Ý§@«Å§iªºªF¦è¨S¦³¥²¶·°Ñ¦Ò³oùتº¡A¥i·í§@¶Â²°¤l¡C
rkck
³o¬O³Ì©³¼hªº·L¨B°Æµ{¦¡¡A¨ã³Æºâ¥X»~®t¦ôpªº¥\¯à¡AÁöµM¦³ª½±µ¥s¥Î¨ì derivs¡A¦ý³o¥Îªk»P odeint ³B¤@¼Ë¡A¨Ï¥ÎªÌ¼gªº¥Dµ{¦¡¨Ã¤£»Ýn»P³oÓ rkck »Î±µ¡A¤]¤£»Ýn°Ñ¦Ò³oùØÀYªºÅܼƫŧi¡A¥i·í§@¶Â²°¤l¡C
odeint
¨Ï¥ÎªÌ©Ò¼gªº¥Dµ{¦¡¡A¥²¶·ª½±µ¥s¥Î odeint¡A ¦]¦¹¦³¦h³B«Å§i¤Wªº²Ó¸`¥²¶·°Ñ¦Ò¡A¤~¯à§â¥D°Æµ{¦¡»Î±µ°_¨Ó¡C¦Ü©ó derivs «h¬O¬Û·í¼Ð·Ç³æ¯Â¡A»P¤Wӳ椸¦b rkdumb ªº§@ªk§¹¥þ¤@¼Ë¡C
³oÓ odeint ¬O rkqs ªº driver µ{¦¡¡A·|§â x1 ~ x2 ½d³ò¤ºªº¨ç¼Æ y(x) °µ¥X¨Ó¡Axn »P yn ªº¼Æȵª®×¬O©ñ¦b¤½¦@°Ï¶ô /path/ ªº xp »P yp ¤¤¡A¦]¦¹¥Dµ{¦¡¤]»Ýn§@¹ïÀ³ªº«Å§i¤~¯à§â¥¦®³¥X¨Ó¡C
¾\Ū odeint ªº»¡©ú°Ï¶ô¡A§ÚÌ¥i¥Hª¾¹D¬°¤F¨Ï¥Î³oӰƵ{¦¡¡A¨Ï¥ÎªÌ¥²¶·¦b¥Dµ{¦¡¤¤¥H parameter ¤è¦¡©w¸q nvar¡A¨Ã¥Bn¿é¤J ystart(i)¡Bx1¡Bx2¡Beps¡Bh1¡Bhmin ³o¨Ç¶q¶Çµ¹ odeint¡C
¨Ï¥Î odeint ¦³¥t¤@Óȱoª`·NªºÂI¡A´N¬O¥¦¬O³]p¬°±o¨ì³Ì²×È y(x2) ¬°¥D¡A¦¹°Æµ{¦¡ÁöµM¦³´£¨Ñ¤¤¶¡¹Lµ{ªºÈ¡A¦ý¥Ñ©ó¨B´T¤j¤p¤£©T©w¡A¦]¦¹¤¤¶¡¹Lµ{ªºÂI¤£¬O«Ü¾A¦X§@¹Ï¥Î¡]¤£¹³¬O rkdumb ¨º¼Ë¡^¡C¥¦¤º³¡¤´µM¦³³]¸m¤½¦@°Ï¶ô¨Ó½Ñ¦s¤¤¶¡¹Lµ{¡AÁ`¦@¦s¦h¤ÖÂI¬O¥Ñ kmax »P dxsav ¨Ó¨M©w¡A¨Ï¥ÎªÌn¦Û¦ó³]©w´N¨âÓÈ¡A¦p¦P¤W±¸`¿ý¤§µ{¦¡»¡©ú©Ò¥Ü¡C
¦pªG§ÚÌ·Q±q odeint ªºµ²ªG¨ú±o¨ä¤½¦@°Ï¶ôùتº¤¤¶¡¹Lµ{¨Ó§@¹Ï©Î¬Ý¨B´TÅܤƪºª¬ªp¡A«hµ½¥Î common block ¤¤¤§ kount ¬O«Ü«nªº¡A¥¦¥Nªí¤F¤¤¶¡ÈªºÂI¼Æ¡C¡]xp(i) ¦b i ¤j©ó kount ¤§«á³£¬O³Q³]¦¨¹s¡A½Ð¤p¤ß¡C¡^
kmax »P dxsav ¨ãÅ骺·N¸q¡A«h¬O¦b½Ò¤å¤¤¥æ«Ý¡]ÁÙ¬O§Æ±æ¤j®an¸ÕµÛ¾Ç·|¬ÝÀ´¥¦¡^¡C°ò¥»¤W¬O»¡¡A¶¡¹j¨B´T¤j©ó dxsav ªº¤~·|¦s¤U¨Ó¡A¨Ã¥B¥ý¦s¨ì kmax ¥Îº¡¬°¤î¡A¨âªÌ©TµM³£¬O¨Ï¥ÎªÌ¦Û¦æ³]©w¡A¦ý kmax ³Ì¦h¤£¯à¤j¹L«Å§iªº°}¦C¤j¤p KMAXX ¡C
¦A¦¸¥mÀ{
¦b¥»¾Ç´Áªº¦U³æ¤¸°Æµ{¦¡¤¤¡Aodeint + rkqs + rkck ºâ¬O¤ñ¸û½ÆÂøªº¤@²Õ¡A¦ý¸Ñ±`·L¤À¤èµ{¦¡¬O«nªº°ÝÃD¡A¥B³o²Õ°Æµ{¦¡¬O·¥¦³«Â¤Oªx¥Î«¬µ{¦¡¡A¤j®a¤@©wn½T¹ê½m²ß¡C
½d¨Ò¥Dµ{¦¡
c
c This program is written by Prof. Ming-Hsien Lee for demonstrating the use
c of Numerical Recie subroutine ODEINT, RKQS, and RKCK to perform Adaptive
c Step-size Control Runge-Kutta algorithm for solving ordinary differential
c equations. Provided to year 2007 Numerical Methods class.
cprogram odeint_main
implicit none
integer nvar,i,nok,nbad
parameter (nvar=2)
real ystart(nvar),x1,x2,eps,h1,hminc For common block
integer KMAXX,NMAX,kmax,kount
parameter (KMAXX=200,NMAX=50)
real xp(KMAXX),yp(NMAX,KMAXX),dxsav
common /path/ kmax,kount,dxsav,xp,ypc For pgplot
integer pgopen,icount,j
real y_min(nvar),y_max(nvar),yy(KMAXX),y_extraexternal rkqs,derivs
kmax = KMAXX
dxsav = 0.001write(*,*) 'What is the beginning and endding of x, x1 ; x2 ?'
read (*,*) x1,x2
write(*,*) 'Input inital vector of yi at x1:'
read (*,*) (ystart(i),i=1,nvar)
write(*,*) 'What is the accuracy eps and first setp size h1 ?'
read (*,*) eps, h1
write(*,*) 'Minimum allowed step size (can be zero) hmin is:'
read (*,*) hmincall odeint(ystart,nvar,x1,x2,eps,h1,hmin,nok,nbad,derivs,rkqs)
write(*,*) 'Subroutine odeint completed.'
write(*,*) 'Final value of y_i are:'
write(*,*) (ystart(i),i=1,nvar)
write(*,*) 'nok is',nok,' nbad is',nbad
write(*,*) 'The total number of points for plotting is :',kountc Find Max and min values of yi(x), but here we will use only y1(x).
do i=1,nvar
y_max(i)= yp(i,1)
y_min(i)= yp(i,1)
end do
do i=1,nvar
do j=1,kount
if (yp(i,j).gt.y_max(i)) y_max(i)=yp(i,j)
if (yp(i,j).lt.y_min(i)) y_min(i)=yp(i,j)
end do
end doc Copy y(1,1:nstep) to yy(1:nstep) for PGLINE plotting
do i=1,kount
yy(i) = yp(1,i)
end doc ¡@¡@Intermidiate reult check
c¡@¡@¡@do i=1,kount
c¡@¡@¡@write(*,200) i,xp(i),i, yy(i)
c 200 format(1x,'x(',i3,') is ',f5.2,' y(',i3,') is ',f5.2)
c¡@¡@¡@end doc Start plotting
y_extra = 0.1*(y_max(1)-y_min(1))
if (pgopen('/xwin').le.0) stop
call pgpap(6.0,0.75)
call pgenv (x1,x2,y_min(1)-y_extra,y_max(1)+y_extra,0,0)
call pgline(kount,xp,yy)
call pgsci(2)
call pgpt(kount,xp,yy,9)
call pgclosend
subroutine derivs(x,y,dydx)
real x,y(2),dydx(2)
dydx(1) = y(2)
dydx(2) = -y(1)
endc ¡@¡@subroutine derivs(x,y,dydx)
c ¡@¡@real x,y,dydx
c ¡@¡@dydx = 2*x
c ¡@¡@end
µù¡G¤W¨ÒªºÃD¥Ø¬O y"(x) + y(x) = 0¡A¦Ó comment ±¼ªº¥t¤@Ó¨ÒÃD«h¬O y'(x) = 2x¡C