ELEMENTS OF NUMERICAL MATHEMATICAL ECONOMICS WITH EXCEL This page intentionally left blank ELEMENTS OF NUMERICAL MATHEMATICAL ECONOMICS WITH EXCEL STATIC AND DYNAMIC OPTIMIZATION G R IOVANNI OMEO IndependentFinancial Advisor Academic PressisanimprintofElsevier 125 LondonWall,LondonEC2Y5AS,UnitedKingdom 525BStreet,Suite1650,SanDiego,CA92101,UnitedStates 50HampshireStreet,5thFloor,Cambridge,MA02139,UnitedStates TheBoulevard,Langford Lane,Kidlington,OxfordOX5 1GB,UnitedKingdom Copyright©2020ElsevierInc.Allrightsreserved. Nopart ofthispublicationmay bereproduced ortransmitted inany formorbyanymeans, electronicor mechanical, includingphotocopying, recording,orany informationstorageandretrieval system,without permissioninwritingfromthepublisher.Details onhowtoseekpermission, further informationaboutthe Publisher’spermissions policiesandourarrangementswithorganizations suchastheCopyrightClearance CenterandtheCopyrightLicensingAgency,canbefoundatourwebsite:www.elsevier.com/permissions. Thisbookandtheindividual contributionscontainedinitareprotected undercopyrightbythePublisher (otherthanasmaybenotedherein). Notices Knowledgeandbestpracticeinthisfieldareconstantlychanging. As newresearchandexperiencebroaden ourunderstanding, changesinresearch methods,professional practices,ormedical treatmentmay become necessary. Practitionersandresearchers mustalwaysrelyontheirownexperience andknowledgeinevaluatingandus- ingany information,methods,compounds,orexperiments describedherein. Inusingsuchinformation or methodstheyshould bemindfuloftheirown safetyandthesafetyofothers,including partiesforwhom theyhave aprofessionalresponsibility. Tothefullestextentofthelaw,neither thePublishernortheauthors,contributors, oreditors, assumeany li- abilityforany injuryand/ordamagetopersonsorproperty asamatterofproductsliability,negligenceor otherwise,or fromanyuseor operationofany methods,products,instructions, orideascontainedinthe materialherein. LibraryofCongressCataloging-in-Publication Data Acatalogrecord forthisbook isavailablefromtheLibraryofCongress BritishLibraryCataloguing-in-Publication Data Acataloguerecord forthis bookisavailablefromtheBritishLibrary ISBN:978-0-12-817648-1 Forinformation onallAcademic Presspublications visitourwebsite at https://www.elsevier.com/books-and-journals Publisher: BrianRomer AcquisitionEditor: BrianRomer EditorialProjectManager:DevlinPerson ProductionProjectManager:Paul Prasad Chandramohan CoverDesigner: Mark Rogers TypesetbyTNQTechnologies Contents I 4. Mathematics for dynamic economic models Excel and fundamental mathematics for economics 4.1 Ordinarydifferential equationsandnumerical methods:EulerandRunge-Kutta 140 1. Excel VBA, solver, and other advanced 4.2 Forceofinterest, Walrasian stability, utility worksheet tools functions,andcapitalformation withordinary differentialequation 147 4.3 Differenceequationsandphasediagrams 159 1.1 VBAintroductionandmainstatements 3 4.4 Cobwebmodelof priceadjustment andother 1.2 TheExcelSolver:simplexLP,Generalized economicmodels withdifference ReducedGradient,andevolutionary 21 equations 170 1.3 What-ifanalysis: scenariomanager,GoalSeek, 4.5 Systemsof lineardifferentialequations 181 DataTable,andcontourlines 29 4.6 Tourismfightbetween twocompeting 1.4 Scatterchartsandtrendlines 40 regions 202 4.7 Walrasian adjustmentwithentry 206 2. Univariate and multivariate calculus Exercises 209 2.1 Numericalmethodsforunivariate differentiation 45 II 2.2 Numericalmethodsforunivariate integration 58 Static optimization 2.3 Numericalpartialdifferentiation 66 2.4 Applicationsin economics 75 5. Classical static nonlinear optimization Exercises 83 theory 3. Elements of linear algebra 5.1 Classical unconstrainedoptimization ofa 3.1 Built-inExcelmatrixfunctionsandbasic univariate function 220 operations 88 5.2 Classical unconstrainedoptimization ofa 3.2 Linearsystemsandresolution methodsinExcel: multivariatefunction 232 Cramer,Solver, Inverse 95 5.3 Someeconomicapplications ofthenonlinear 3.3 Eigenvaluesandeigenvectorssearch: analytical unconstrainedoptimization 247 andgraphicalapproach 107 5.4 Numericalsteepestdescentmethodappliedto 3.4 Quadraticformsanddefinitenessofasymmetric theunconstrained optimization matrix 115 withVBA 256 3.5 Leontiefopenmodel 121 5.5 Nonlinearproblems inRnwithequality 3.6 Equilibriuminnmarkets 124 constraints:Lagrangemultipliers and 3.7 Economicpolicymodeling:objectives and Solver 264 instruments 129 5.6 Nonlinearproblems inR2withequality Exercises 134 constraints:contourlines 272 v vi Contents 5.7 Nonlinearproblems withinequality 8. Nonlinear optimization applied to the constraints 285 portfolio theory Exercises 288 8.1 Portfolio modelingandtheefficientfrontier 6. Microeconomic theory in a static construction 417 environment 8.2 Investor’sutilityandtheoptimalportfolio choice 427 6.1 Theconsumerproblem:cardinalversus ordinal Exercises 432 utilityapproach 296 6.2 Consumeroptimizationandderivation of thedemandcurveinthecardinal III approach 297 6.3 Consumeroptimizationandderivation ofthe Dynamic optimization demandcurvein theordinal approach 307 6.4 Thefirmproblem 319 9. Calculus of variations 6.5 One-inputclassicalproductionfunction 320 6.6 Two-inputsproductionfunctions 322 9.1 The fundamentalproblemoftheCalculusof 6.7 Isoquantsandtheconstrained production Variations 438 optimizationwithtwoinputs 331 9.2 Discrete approximate CalculusofVariations: 6.8 ProductionEdgeworthbox,contract Lagrangemultipliers andcontourlines curve,andthepossibility frontier solutions 442 construction 335 9.3 SetupoftheExcelworksheet forCalculusof 6.9 Short-run,long-runcostsandtheenvelope Variations problems:theSolversolution 451 averagetotalcosts derivation 340 9.4 General casesdevelopedinExcelwithfixedand 6.10 Perfectcompetitive markets:short-run, long-run variable terminal points 453 supply curvesandmarket equilibrium 350 9.5 Dynamic optimizationforamonopolist 469 6.11 Monopolistic market equilibrium:the 9.6 Unemploymentandinflation 471 Chamberlin model 356 9.7 The EisnereStrotzmodel 475 6.12 Markets withhigh-entry barriers:monopolyand 9.8 The optimalconsumptionRamseymodel 479 theCournot duopolymodel 360 9.9 Inventory dynamicoptimization 481 6.13 Game theory.Zero-sumgames and 9.10 Optimalcapital structure andthefirmcost of minimax criterion:matrixandgraphical capital 482 resolutions 370 9.11 Contour linessolution forCalculusofVariations Exercises 376 usingtheVBAcode 487 9.12 CalculusofVariations withfunctionals 7. Linear programming involving twoindependent functions 494 7.1 Standardformulationofalinearprogram and 9.13 CalculusofVariationsconstrainedproblems 497 resolutionmethods 383 9.14 CheckingtheSecond-OrderConditions in 7.2 Applicationstothestatic productionplanning Excel 505 andcapital budgeting 389 Exercises 511 Exercises 408 vii Contents 10. Theory of optimal control IV Special topics 10.1 Theoptimalcontrolproblemandthe Pontryagin’smaximumprinciple 522 10.2 Nonlinear HamiltonianandlinearHamiltonian 12. Dynamic production planning and (bang-bangcontrol) 523 inventory modeling 10.3 SetupoftheExcelworksheet foroptimal controlproblems 525 12.1 Multiperiodproductionmodelswithlinear 10.4 Bang-bangcontrolproblems 542 programming 661 10.5 Consumptionmodel 547 12.2 WagnereWhitinalgorithmfor inventory 10.6 Investmentmodel 554 dynamicmodeling 669 10.7 Inventoryoptimization 561 12.3 EliezerNaddor stochasticsingle-period 10.8 Twostate variablescontrol inventorymodels 677 problems 563 Exercises 687 10.9 Current-value Hamiltonian 571 10.10 Constraintsonthestatevariable:alinearcase 13. Data analysis for business and withaninventoryapplication withVBA 576 economics 10.11 Steepestdescentnumerical approachfor optimalcontrolproblems usingVBA 587 13.1 Asimplewaytoorganizeaspreadsheet using 10.12 Checkingthesufficientconditionsin theVBA codeandbookmarks 696 Excel 593 13.2 Pivottables,Pivotcharts,anddynamic Exercises 600 dashboardsformanagerial dataanalysis 697 11. Discrete dynamic programming 13.3 Basicdescriptivestatistics 711 13.4 Somenumerical calculus appliedtocontinuous densities 721 11.1 Bellman’sprinciple,discrete shortestpath 13.5 Univariate,multivariateregressionanalysis and problems,andtheExcelMINIFS theANOVA tables 727 function 612 Exercises 756 11.2 Discretedynamicsystems:tabular method, Exceldatatable,andSolver 619 14. Essential Monte Carlo analysis 11.3 Cargoloadingallocationproblems:tabular methodandtheExcelSolver 629 14.1 TheMonteCarlomethodandthegeneration 11.4 Multistageallocation problemsusingtheExcel ofrandomnumbers 764 Solver 632 14.2 TheMonteCarlomethodforbusiness 11.5 Equalityconstrained optimizationproblems decisions 773 usingtherecursive Bellman’s approach 636 14.3 Numericalintegration 788 11.6 Dynamiceconomicproblemssolved with Exercises 792 DiscreteDynamic Programming 639 11.7 DiscreteDynamic Programming,Optimal Controltheory, andCalculusofVariations: a synthesis 649 Index 797 Exercises 652 This page intentionally left blank P A R T I Excel and fundamental mathematics for economics Part I of this book aims at giving to the reader the fundamental tools of some important advanced worksheet capabilities, including the Excel VBA, as well as the fundamental tools of the mathematical economics applied within a spreadsheet. These are all tools that will be needed within the courseofthewholebookandtoolsthatanyeconomistanalystshouldmaster within a computer language framework. Chapter1willreviewsomeVBAcodes,whosepriorknowledgewouldbe somehow required from the reader, in order to optimally utilize the work- sheets that will be implemented within the book. The Excel macros used within the book are not at a very advanced level, but still, they will require (besidethemathematicalknowledge)acertaindegreeofVBAprogramming language mastery. Otheradvancedfeatures,liketheExcelSolver,thewhat-ifdatatableanalysis (thesetwowillbeusedalotinthebook),contourdiagrams,scattercharts,and trendlines will be introduced and then developed in detail within the book. Chapters2e4willinsteadgivetheessentialelementsofthemathematical economics applied with Excel. Three important areas of the mathematical economics are covered here. Chapter 2 will cover the essential elements of the standard calculus (numerical differentiation and integration) applied within a spreadsheet. Chapter 3 is dedicated to the essential elements of the linear algebra. Chapter 4 is instead devoted to the dynamical mathematics (ordinary differential and difference equations, as well as the systems of differential equations). This is a chapter of paramount importance as many of the tech- niqueswewilldevelopinthischapterwillbeusedwithinthedynamicopti- mization section and also because the differential and difference equations represent the key constituent area of the economic dynamic modeling. Inallthesethreechapters,someeconomicapplicationsarealsoproposed.