This notebook contains the Mathematica commands from Chapter 18 of Introduction to Scientific Programming by Joseph L. Zachary.

The expressions below create the animation produced by Example 18.1.

\(ListPlot[{{0, 100}, {2, 0}, {4, 0}, {6, 0}, {8, 0}, {10, 50}}, \ 
      PlotJoined -> True, \ PlotRange -> {0, 100}]
\)\(ListPlot[{{0, 100}, {2, 50}, {4, 0}, {6, 0}, {8, 25}, {10, 50}}, \ 
      PlotJoined -> True, \ PlotRange -> {0, 100}]
\)\(ListPlot[{{0, 100}, {2, 50}, {4, 25}, {6, 12.5}, {8, 25}, {10, 50}}, \ 
      PlotJoined -> True, \ PlotRange -> {0, 100}]
\)\(ListPlot[{{0, 100}, {2, 62.5}, {4, 31.25}, {6, 25}, {8, 31.25}, {10, 
          50}}, \ PlotJoined -> True, \ PlotRange -> {0, 100}]
\)\(ListPlot[{{0, 100}, {2, 65.625}, {4, 43.75}, {6, 31.25}, {8, 37.5}, {
          10, 50}}, \ PlotJoined -> True, \ PlotRange -> {0, 100}]
\)ListPlot[{{0, 100}, {2, 71.875}, {4, 48.4375}, {6, 40.625}, {8, 
          40.625}, {10, 50}},  PlotJoined -> True,  PlotRange -> {0, 100}]

(18.1)  If you use the C program "heat11" with the appropriate input file, or if you copy the expressions from above and put them into a file called "heat-output.txt", you can create the animation from above by evaluating this.

Get["heat-output.txt"]

The expresions below create the animation produced by Example 18.2.

\(ListPlot[{{0, 100}, {0.1, 0}, {0.2, 0}, {0.3, 0}, {0.4, 0}, {0.5, 0}, {
          0.6, 0}, {0.7, 0}, {0.8, 0}, {0.9, 0}, {1, 0}, {1.1, 0}, {1.2, 0}, {
          1.3, 0}, {1.4, 0}, {1.5, 0}, {1.6, 0}, {1.7, 0}, {1.8, 0}, {1.9, 
          0}, {2, 0}, {2.1, 0}, {2.2, 0}, {2.3, 0}, {2.4, 0}, {2.5, 0}, {2.6, 
          0}, {2.7, 0}, {2.8, 0}, {2.9, 0}, {3, 0}, {3.1, 0}, {3.2, 0}, {3.3, 
          0}, {3.4, 0}, {3.5, 0}, {3.6, 0}, {3.7, 0}, {3.8, 0}, {3.9, 0}, {4, 
          0}, {4.1, 0}, {4.2, 0}, {4.3, 0}, {4.4, 0}, {4.5, 0}, {4.6, 0}, {
          4.7, 0}, {4.8, 0}, {4.9, 0}, {5, 0}, {5.1, 0}, {5.2, 0}, {5.3, 0}, {
          5.4, 0}, {5.5, 0}, {5.6, 0}, {5.7, 0}, {5.8, 0}, {5.9, 0}, {6, 0}, {
          6.1, 0}, {6.2, 0}, {6.3, 0}, {6.4, 0}, {6.5, 0}, {6.6, 0}, {6.7, 
          0}, {6.8, 0}, {6.9, 0}, {7, 0}, {7.1, 0}, {7.2, 0}, {7.3, 0}, {7.4, 
          0}, {7.5, 0}, {7.6, 0}, {7.7, 0}, {7.8, 0}, {7.9, 0}, {8, 0}, {8.1, 
          0}, {8.2, 0}, {8.3, 0}, {8.4, 0}, {8.5, 0}, {8.6, 0}, {8.7, 0}, {
          8.8, 0}, {8.9, 0}, {9, 0}, {9.1, 0}, {9.2, 0}, {9.3, 0}, {9.4, 0}, {
          9.5, 0}, {9.6, 0}, {9.7, 0}, {9.8, 0}, {9.9, 0}, {10, 50}}, \ 
      PlotJoined -> True, \ PlotRange -> {0, 100}]
\)\(ListPlot[{{0, 100}, {0.1, 95.7382}, {0.2, 91.5006}, {0.3, 87.263}, {
          0.4, 83.0972}, {0.5, 78.9314}, {0.6, 74.8826}, {0.7, 70.8339}, {
          0.8, 66.9434}, {0.9, 63.053}, {1, 59.3571}, {1.1, 55.6612}, {1.2, 
          52.1899}, {1.3, 48.7187}, {1.4, 45.4953}, {1.5, 42.272}, {1.6, 
          39.313}, {1.7, 36.3539}, {1.8, 33.6683}, {1.9, 30.9827}, {2, 
          28.573}, {2.1, 26.1633}, {2.2, 24.0258}, {2.3, 21.8883}, {2.4, 
          20.014}, {2.5, 18.1396}, {2.6, 16.5149}, {2.7, 14.8902}, {2.8, 
          13.4981}, {2.9, 12.106}, {3, 10.9272}, {3.1, 9.74842}, {3.2, 
          8.76219}, {3.3, 7.77597}, {3.4, 6.96106}, {3.5, 6.14615}, {3.6, 
          5.48166}, {3.7, 4.81717}, {3.8, 4.2832}, {3.9, 3.74923}, {4, 
          3.32744}, {4.1, 2.90564}, {4.2, 2.57963}, {4.3, 2.25362}, {4.4, 
          2.00925}, {4.5, 1.76488}, {4.6, 1.59042}, {4.7, 1.41596}, {4.8, 
          1.30219}, {4.9, 1.18842}, {5, 1.12862}, {5.1, 1.06883}, {5.2, 
          1.05878}, {5.3, 1.04873}, {5.4, 1.08659}, {5.5, 1.12445}, {5.6, 
          1.21064}, {5.7, 1.29682}, {5.8, 1.43389}, {5.9, 1.57096}, {6, 
          1.76338}, {6.1, 1.95581}, {6.2, 2.20979}, {6.3, 2.46377}, {6.4, 
          2.78697}, {6.5, 3.11017}, {6.6, 3.5114}, {6.7, 3.91264}, {6.8, 
          4.40153}, {6.9, 4.89042}, {7, 5.47697}, {7.1, 6.06353}, {7.2, 
          6.75769}, {7.3, 7.45185}, {7.4, 8.26298}, {7.5, 9.07412}, {7.6, 
          10.0105}, {7.7, 10.9469}, {7.8, 12.0151}, {7.9, 13.0833}, {8, 
          14.2879}, {8.1, 15.4924}, {8.2, 16.835}, {8.3, 18.1776}, {8.4, 
          19.657}, {8.5, 21.1364}, {8.6, 22.748}, {8.7, 24.3595}, {8.8, 
          26.0951}, {8.9, 27.8307}, {9, 29.6787}, {9.1, 31.5266}, {9.2, 
          33.4718}, {9.3, 35.417}, {9.4, 37.4413}, {9.5, 39.4657}, {9.6, 
          41.5486}, {9.7, 43.6315}, {9.8, 45.7503}, {9.9, 47.8691}, {10, 
          50}}, \ PlotJoined -> True, \ PlotRange -> {0, 100}]
\)\(ListPlot[{{0, 100}, {0.1, 96.992}, {0.2, 93.9841}, {0.3, 90.9934}, {
          0.4, 88.0028}, {0.5, 85.0464}, {0.6, 82.09}, {0.7, 79.1844}, {0.8, 
          76.2788}, {0.9, 73.4395}, {1, 70.6003}, {1.1, 67.842}, {1.2, 
          65.0838}, {1.3, 62.4199}, {1.4, 59.756}, {1.5, 57.1984}, {1.6, 
          54.6408}, {1.7, 52.1999}, {1.8, 49.7589}, {1.9, 47.4435}, {2, 
          45.1281}, {2.1, 42.9453}, {2.2, 40.7625}, {2.3, 38.7178}, {2.4, 
          36.6731}, {2.5, 34.7703}, {2.6, 32.8675}, {2.7, 31.109}, {2.8, 
          29.3505}, {2.9, 27.7371}, {3, 26.1238}, {3.1, 24.6552}, {3.2, 
          23.1866}, {3.3, 21.8613}, {3.4, 20.536}, {3.5, 19.3515}, {3.6, 
          18.167}, {3.7, 17.1202}, {3.8, 16.0733}, {3.9, 15.1603}, {4, 
          14.2472}, {4.1, 13.4639}, {4.2, 12.6806}, {4.3, 12.0226}, {4.4, 
          11.3645}, {4.5, 10.8274}, {4.6, 10.2903}, {4.7, 9.86972}, {4.8, 
          9.44913}, {4.9, 9.14094}, {5, 8.83275}, {5.1, 8.63308}, {5.2, 
          8.4334}, {5.3, 8.33872}, {5.4, 8.24404}, {5.5, 8.25119}, {5.6, 
          8.25835}, {5.7, 8.36457}, {5.8, 8.4708}, {5.9, 8.67368}, {6, 
          8.87657}, {6.1, 9.17403}, {6.2, 9.47149}, {6.3, 9.86169}, {6.4, 
          10.2519}, {6.5, 10.7332}, {6.6, 11.2144}, {6.7, 11.7852}, {6.8, 
          12.3559}, {6.9, 13.0145}, {7, 13.6732}, {7.1, 14.4179}, {7.2, 
          15.1626}, {7.3, 15.9914}, {7.4, 16.8202}, {7.5, 17.7308}, {7.6, 
          18.6413}, {7.7, 19.6308}, {7.8, 20.6203}, {7.9, 21.6853}, {8, 
          22.7504}, {8.1, 23.8872}, {8.2, 25.0239}, {8.3, 26.2277}, {8.4, 
          27.4315}, {8.5, 28.6971}, {8.6, 29.9628}, {8.7, 31.2843}, {8.8, 
          32.6059}, {8.9, 33.9768}, {9, 35.3477}, {9.1, 36.7607}, {9.2, 
          38.1738}, {9.3, 39.6213}, {9.4, 41.0688}, {9.5, 42.5425}, {9.6, 
          44.0163}, {9.7, 45.5078}, {9.8, 46.9992}, {9.9, 48.4996}, {10, 
          50}}, \ PlotJoined -> True, \ PlotRange -> {0, 100}]
\)\(ListPlot[{{0, 100}, {0.1, 97.5618}, {0.2, 95.1235}, {0.3, 92.6953}, {
          0.4, 90.2671}, {0.5, 87.8588}, {0.6, 85.4506}, {0.7, 83.072}, {0.8, 
          80.6934}, {0.9, 78.354}, {1, 76.0145}, {1.1, 73.7233}, {1.2, 
          71.4322}, {1.3, 69.1979}, {1.4, 66.9636}, {1.5, 64.7944}, {1.6, 
          62.6252}, {1.7, 60.5286}, {1.8, 58.4321}, {1.9, 56.4152}, {2, 
          54.3983}, {2.1, 52.4673}, {2.2, 50.5364}, {2.3, 48.6971}, {2.4, 
          46.8578}, {2.5, 45.115}, {2.6, 43.3723}, {2.7, 41.7304}, {2.8, 
          40.0885}, {2.9, 38.5511}, {3, 37.0136}, {3.1, 35.5835}, {3.2, 
          34.1534}, {3.3, 32.8329}, {3.4, 31.5123}, {3.5, 30.303}, {3.6, 
          29.0937}, {3.7, 27.9967}, {3.8, 26.8997}, {3.9, 25.9154}, {4, 
          24.9312}, {4.1, 24.0597}, {4.2, 23.1883}, {4.3, 22.4292}, {4.4, 
          21.6702}, {4.5, 21.0226}, {4.6, 20.375}, {4.7, 19.8378}, {4.8, 
          19.3005}, {4.9, 18.872}, {5, 18.4435}, {5.1, 18.1219}, {5.2, 
          17.8003}, {5.3, 17.5835}, {5.4, 17.3668}, {5.5, 17.2525}, {5.6, 
          17.1383}, {5.7, 17.1241}, {5.8, 17.1098}, {5.9, 17.1929}, {6, 
          17.2759}, {6.1, 17.4534}, {6.2, 17.6308}, {6.3, 17.8996}, {6.4, 
          18.1684}, {6.5, 18.5253}, {6.6, 18.8822}, {6.7, 19.3239}, {6.8, 
          19.7655}, {6.9, 20.2884}, {7, 20.8112}, {7.1, 21.4115}, {7.2, 
          22.0117}, {7.3, 22.6855}, {7.4, 23.3593}, {7.5, 24.1025}, {7.6, 
          24.8458}, {7.7, 25.6541}, {7.8, 26.4625}, {7.9, 27.3314}, {8, 
          28.2004}, {8.1, 29.1253}, {8.2, 30.0502}, {8.3, 31.0262}, {8.4, 
          32.0021}, {8.5, 33.024}, {8.6, 34.0459}, {8.7, 35.1085}, {8.8, 
          36.1711}, {8.9, 37.2689}, {9, 38.3666}, {9.1, 39.4941}, {9.2, 
          40.6215}, {9.3, 41.7727}, {9.4, 42.924}, {9.5, 44.0933}, {9.6, 
          45.2626}, {9.7, 46.4439}, {9.8, 47.6252}, {9.9, 48.8126}, {10, 
          50}}, \ PlotJoined -> True, \ PlotRange -> {0, 100}]
\)\(ListPlot[{{0, 100}, {0.1, 97.9296}, {0.2, 95.8628}, {0.3, 93.796}, {
          0.4, 91.7399}, {0.5, 89.6838}, {0.6, 87.6453}, {0.7, 85.6069}, {
          0.8, 83.5931}, {0.9, 81.5793}, {1, 79.5968}, {1.1, 77.6144}, {1.2, 
          75.6698}, {1.3, 73.7253}, {1.4, 71.8251}, {1.5, 69.9248}, {1.6, 
          68.0748}, {1.7, 66.2249}, {1.8, 64.4309}, {1.9, 62.637}, {2, 
          60.9045}, {2.1, 59.172}, {2.2, 57.506}, {2.3, 55.8399}, {2.4, 
          54.245}, {2.5, 52.6501}, {2.6, 51.1305}, {2.7, 49.611}, {2.8, 
          48.1706}, {2.9, 46.7303}, {3, 45.3726}, {3.1, 44.0148}, {3.2, 
          42.7427}, {3.3, 41.4705}, {3.4, 40.2865}, {3.5, 39.1025}, {3.6, 
          38.0088}, {3.7, 36.915}, {3.8, 35.9132}, {3.9, 34.9114}, {4, 
          34.0028}, {4.1, 33.0942}, {4.2, 32.2797}, {4.3, 31.4652}, {4.4, 
          30.7452}, {4.5, 30.0253}, {4.6, 29.3999}, {4.7, 28.7746}, {4.8, 
          28.2436}, {4.9, 27.7126}, {5, 27.2753}, {5.1, 26.838}, {5.2, 
          26.4934}, {5.3, 26.1488}, {5.4, 25.8956}, {5.5, 25.6423}, {5.6, 
          25.4789}, {5.7, 25.3154}, {5.8, 25.2398}, {5.9, 25.1642}, {6, 
          25.1743}, {6.1, 25.1843}, {6.2, 25.2776}, {6.3, 25.3708}, {6.4, 
          25.5445}, {6.5, 25.7182}, {6.6, 25.9694}, {6.7, 26.2206}, {6.8, 
          26.5462}, {6.9, 26.8718}, {7, 27.2683}, {7.1, 27.6648}, {7.2, 
          28.1287}, {7.3, 28.5926}, {7.4, 29.12}, {7.5, 29.6475}, {7.6, 
          30.2345}, {7.7, 30.8216}, {7.8, 31.4642}, {7.9, 32.1067}, {8, 
          32.8005}, {8.1, 33.4943}, {8.2, 34.2348}, {8.3, 34.9754}, {8.4, 
          35.7582}, {8.5, 36.5409}, {8.6, 37.3613}, {8.7, 38.1816}, {8.8, 
          39.0347}, {8.9, 39.8878}, {9, 40.7688}, {9.1, 41.6497}, {9.2, 
          42.5536}, {9.3, 43.4575}, {9.4, 44.3793}, {9.5, 45.3012}, {9.6, 
          46.2358}, {9.7, 47.1704}, {9.8, 48.1127}, {9.9, 49.0551}, {10, 
          50}}, \ PlotJoined -> True, \ PlotRange -> {0, 100}]
\)ListPlot[{{0, 100}, {0.1, 98.2038}, {0.2, 96.4104}, {0.3, 94.617}, {
          0.4, 92.8319}, {0.5, 91.0468}, {0.6, 89.2754}, {0.7, 87.504}, {0.8, 
          85.7518}, {0.9, 83.9996}, {1, 82.2717}, {1.1, 80.5439}, {1.2, 
          78.8457}, {1.3, 77.1475}, {1.4, 75.4839}, {1.5, 73.8204}, {1.6, 
          72.1962}, {1.7, 70.5721}, {1.8, 68.9921}, {1.9, 67.412}, {2, 
          65.8805}, {2.1, 64.349}, {2.2, 62.8701}, {2.3, 61.3913}, {2.4, 
          59.9691}, {2.5, 58.5468}, {2.6, 57.1848}, {2.7, 55.8228}, {2.8, 
          54.5244}, {2.9, 53.226}, {3, 51.9942}, {3.1, 50.7624}, {3.2, 
          49.6}, {3.3, 48.4376}, {3.4, 47.3469}, {3.5, 46.2563}, {3.6, 
          45.2395}, {3.7, 44.2228}, {3.8, 43.2817}, {3.9, 42.3406}, {4, 
          41.4765}, {4.1, 40.6125}, {4.2, 39.8267}, {4.3, 39.0408}, {4.4, 
          38.3339}, {4.5, 37.627}, {4.6, 36.9995}, {4.7, 36.3721}, {4.8, 
          35.8241}, {4.9, 35.2762}, {5, 34.8076}, {5.1, 34.339}, {5.2, 
          33.9493}, {5.3, 33.5595}, {5.4, 33.2479}, {5.5, 32.9362}, {5.6, 
          32.7015}, {5.7, 32.4668}, {5.8, 32.3077}, {5.9, 32.1486}, {6, 
          32.0634}, {6.1, 31.9783}, {6.2, 31.9652}, {6.3, 31.9521}, {6.4, 
          32.0089}, {6.5, 32.0657}, {6.6, 32.19}, {6.7, 32.3143}, {6.8, 
          32.5035}, {6.9, 32.6926}, {7, 32.9438}, {7.1, 33.195}, {7.2, 
          33.5052}, {7.3, 33.8154}, {7.4, 34.1814}, {7.5, 34.5473}, {7.6, 
          34.9656}, {7.7, 35.3839}, {7.8, 35.851}, {7.9, 36.3181}, {8, 
          36.8302}, {8.1, 37.3423}, {8.2, 37.8956}, {8.3, 38.4489}, {8.4, 
          39.0393}, {8.5, 39.6298}, {8.6, 40.2533}, {8.7, 40.8769}, {8.8, 
          41.5293}, {8.9, 42.1817}, {9, 42.8587}, {9.1, 43.5357}, {9.2, 
          44.2329}, {9.3, 44.9301}, {9.4, 45.643}, {9.5, 46.356}, {9.6, 
          47.0803}, {9.7, 47.8045}, {9.8, 48.5356}, {9.9, 49.2667}, {10, 
          50}},  PlotJoined -> True,  PlotRange -> {0, 100}]

(18.2)  If you use the C program "heat11" with the appropriate input file, or if you copy the expressions from above and put them into a file called "heat-output.txt", you can create the animation from above by evaluating this.

Get["heat-output.txt"]