1st Edition

Discrete Mathematics with Coding

By Hugo D Junghenn Copyright 2024
547 Pages 145 Color & 55 B/W Illustrations
by Chapman & Hall

547 Pages 145 Color & 55 B/W Illustrations
by Chapman & Hall

This book, for a first undergraduate course in Discrete Mathematics, systematically exploits the relationship between discrete mathematics and computer programming. Unlike most discrete mathematics texts focusing on one of the other, the book explores the rich and important connection between these two disciplines and shows how each discipline reinforces and enhances the other. The mathematics... Read more

 

I

Essentials of VBA

1

Introduction

1.1 Modules, Subs, and Functions

      1. Data Output and Input. OutputExample,InputExample
      2. Cell Characteristics. CellAttributes
      3. Number Formats. NumberFormat
      4. Passing Arguments. SwitchIntegers
      5. User Defined Data Types
      6. Command Buttons
      7. Spin Buttons. MixColors
      8. Exercises

    1. VBA Operators
      1. Arithmetic Operators
      2. Comparison Operators
      3. Logical Operators
      4. Exercises

    2. Conditional Statements

3.1

The If Then Else Statement. Grade

3.2

The Select Case Statement. CycleEdges

3.3

Exercises

4 Loops

4.1

The For Next Statement

 

4.2

The Do While Loop. ReduceFraction, NumberOfTerms

4.3

The Do Until Loop

4.4

Exit Statements

4.5

Finding the Zeros of a Function. FindZero, FunctionVal

4.6

Exercises

5 Arrays

5.1

Declaring Arrays

5.2

First and Last Indices of an Array

5.3

Passing and Returning Arrays

 

 

      1. Variants and the Array Function
      2. Sorting Numeric Data. NumericSort
      3. Finding Nearest Numbers. NearestNumbers
      4. Stacks. Push, Pop
      5. Exercises

    1. String Functions
      1. The VBA Concatenation Operator &
      2. Duplicating Strings. DupString

      3. The VBA Extraction Function Mid
      4. Matching Symbols. IsMatch

        Inserting, Replacing a String. RemoveInsertString

        A Variation of Mid. Midd

      5. The VBA ASCII Functions Asc and Chr
      6. Boolean ASCII Functions. IsUpper,IsLower,IsLetter,IsDigit

      7. VBA Data Conversion Functions CStr, CInt, CLng, CDbl
      8. The VBA Function Replace
      9. Removing Spaces From a String. RemoveWhiteSpace

        Removing Duplicate Characters. RemoveDupChar

      10. The VBA Function InStr
      11. The VBA Operator Like
      12. The VBA Functions Join and Split
      13. Deleting Duplicate Strings. DeleteDupStr

      14. Exercises

    2. Grids
      1. Setting Up a Grid. MakeGrid
      2. The Grid As a Torus. TorusPoint
      3. Installing Coordinates in a Grid. InstallCoord
      4. Sieve of Erastothenes. Sieve
      5. A Changing Rectangle. CollapseExpandRectangle, Delay
      6. Table Sum Game. TableSum
      7. Finding the Nearest Cells. NearestCells
      8. A Growing Spiral. Spiral
      9. Billiard Ball. BilliardBall
      10. Exercises

    3. Recursion
      1. The Factorial Function. FactRecursive
      2. Binary Trees. Binarytree
      3. The Tower of Hanoi. HanoiTower

      *8.4 A Complex Arithmetic Calculator. ComplexCalc

      *8.5 A Polynomial Calculator. PolyCalc

      8.6 Exercises

    4. Charts and Graphs

      1. Frequency Charts. LetterFreqency
      2. Drawing Lines. GraphPoly
      3. Intersection of Two Lines. LineIntersect
      4. Projection of a Point onto a Line. Point2Line
      5. The Incenter of a Triangle. Incenter
      6. Function Graphs. GraphFunction
      7. Fitting a Line to Data. Least Squares
      8. Graphing Parametric Curves. GraphCurve
      9. A Fractal Game. ChaosTriangleGame
      10. Overlaying Graphs. PredatorPrey
      11. Bezier Curves. Bezier
      12. Exercises

  1. Random Numbers
      1. The VBA Function Rnd
      2. Random Decimals. RndDec

        Random Integers. RndInt

        Random Permutations. RndPerm

        Random Position. NextRndPos

        Probability Distributions. RndOut

      3. A Nonsense Generator. Nonsense
      4. Area Under a Curve. AreaUnderCurve
      5. A Simple Random Walk. Random Walk
      6. Spreading Disease. SpreadOfDisease
      7. Particle Swarm Optimization. ParticleSwarmOpt
      8. A Randomly Sprouting Plant. SproutWither
      9. Random Walk of a Rotating Pattern. RotateAndMove
      10. Random Tessellations. RandomTess
      11. Maxwell’s Entropy Demon. MaxwellsDemon
      12. Multi-Random Walk. RandomWalks
      13. A Shedding Organism. RandomWalkShed
      14. A Splitting Organism. RandomWalkSplit
      15. Random Mazes. Maze
      16. Exercises

    II Linear Analysis

  2. Linear Equations
      1. Matrix Arrays. MatrixIn, MatrixOut
      2. Systems of Linear Equations
      3. The Gauss Jordan Method
      4. Row Operations with VBA. RowOperations
      5. Row Echelon Form with VBA. RowEchelon
      6. Exercises

 

 

 

12 Linear Programming

12.1 Linear Inequalities and Feasible Regions

12.2 Formulation of the General LP Problem

The Standard LP Max Problem

The Standard LP Min Problem

Nonstandard LP Problems

      1. Graphic Solution for Two Dimensions
      2. The Simplex Method
      3. Standard Max Problem with VBA. Simplex
      4. Duality and the Standard LP Min Problem
      5. Solving Nonstandard LP Problems
      6. Exercises

    1. Matrix Algebra

    13.1

    Matrix Scalar Multiplication. ScalarMult

    13.2

    Matrix Addition and Substraction. AddSubMat

    13.3

    Matrix Multiplication. MultMat

    13.4

    Inverse of a Matrix. MatrixInversion

    13.5

    Matrix Powers. PowerMat

    13.6

    Input-Output Models. IOModel

    13.7

    Polynomial of Best Fit. PolyFitData

    *13.8

    The Barnsley Fern. AffineIterations

    *13.9

    A Matrix Calculator. MatrixCalculator

    13.10

    Exercises

     

  1. Determinants
      1. Definition and Properties
      2. Determinants Using VBA. DetEchelon, DetRecursive
      3. Cramer’s Rule. CramersRule
      4. Collinear and Coplanar Points Using Determinants
      5. Areas and Volumes Using Determinants
      6. Circumscribing a Triangle. Circumcenter
      7. Exercises

 

 

III

Logic

15 Propositional Logic

 

15.1 Compound Statements

      1. Equivalent Statements and Laws of Logic
      2. Truth Tables with VBA. Stmt2TruthTable
      3. Statement from a Truth Table. TruthTable2DisjNormal
      4. Valid Arguments
      5. Exercises

    1. Switching Circuits

      1. Introduction
      2. Series and Parallel Circuits
      3. Equivalent Circuits
      4. Circuit Expressions With VBA. SwitchCircuitExpr
      5. Exercises

  1. Gates and Logic Circuits
      1. The Gates NOT, AND, OR
      2. The Gates XOR, NAND, NOR
      3. Logic Circuit Expressions with VBA. LogicCircuitExpr
      4. Half Adders
      5. VBA Simulation of a Half Adder
      6. Full Adders
      7. VBA Simulation of a 4-bit Adder. FullAdder4
      8. Exercises

    1. Combinatorics

    1. Sets
      1. Introduction
      2. The Union of Two Sets. Union
      3. The Intersection of Two Sets. Intersection, Card
      4. The Complement of a Set. Complement
      5. Extensions to Three or More Sets
      6. Calculating Sets with VBA. SetCalculator
      7. Venn Diagram Components with VBA. VennParts
      8. Laws of Set Equality
      9. Laws of Set Inclusion
      10. Cartesian Products, Relations, and Functions
      11. Exercises

19 Counting

19.1

The Addition Principle

*19.2

Venn Solutions with VBA. Venn3Solver

19.3

The Multiplication Principle

19.4

Permutations

19.5

Generating Permutations with VBA. Permutations

19.6

Combinations

19.7

Generating Combinations with VBA. Combinations

19.8

Traveling Salesman Problem. TravelSales

*19.9

Permutation Algebra. MultPerm, InvPerm, PowerPerm

*19.10

Permutation Cycles. PermCycles

19.11

Exercises

 

 

    1. Probability

    1. Probability
      1. Sample Spaces, Probabilities, and Events
      2. Throwing a Pair of Fair Dice. DiceRelativFreq
      3. Poker Hands. PokerHands
      4. Drawing Balls from an Urn
      5. Simulation of the Binomial Distribution. GaltonsBoard
      6. Conditional Probability
      7. Bayes’ Theorem
      8. Disease Testing. TruePosTrueNeg
      9. Independence
      10. Exercises

    2. Random Variables
      1. Examples of Random Variables
      2. Expected Value of a Random Variable
      3. Properties of Expectation
      4. Variance and Standard Deviation of a Random Variable
      5. The Law of Large Numbers
      6. Mean Time For Two Heads. MeanTimeForFirstHH

        Bernoulli-Laplace model. BernoulliLaplaceMeanTime

      7. Central Limit Theorem
      8. Exercises

    3. Markov Chains
      1. First Order Transition Probabilities
      2. Higher Order Transition Probabilities
      3. The Initial Distribution of a Markov Chain
      4. The Steady State Vector
      5. Position Dependent Random Walk. PositionRandWalk
      6. Polya Urn Model. PolyaUrn
      7. Ehrenfest Diffusion Model. EhrenfestUrns
      8. Stepping Stone Model. SteppingStone
      9. Exercises

    1. Properties of Numbers

    1. Divisibility and Prime Numbers
      1. The Division Algorithm
      2. Number Bases. BaseToBase

*23.3 Wolfram’s Binary Rules. WolframRules

      1. Greatest Common Divisor. GCD
      2. Prime Divisibility Property
      3. The Fundamental Theorem of Arithmetic

    1. Prime Decomposition with VBA. PrimeDecomposition
    2. Exercises

    1. Congruence
      1. Definition and Basic Properties
      2. Congruence Arithmetic
      3. Fermat’s Little Theorem
      4. Remainder of a Product. ProductRmdr
      5. Remainder of a Power. PowerRmdr
      6. Solving Congruence Equations. CongruenceSolver

*24.7 Modular Arithmetic. CongruenceTables

    1. 24.8 ExercisesCryptography

      1. Encoding the Alphabet
      2. Caesar’s Shift Cipher
      3. Zigzag Cipher
      4. Spiral Cipher. SpiralCipher
      5. Affine Cipher. AffCipher
      6. Permutation Cipher. PermCipher
      7. Vigen`ere Cipher. VCipher
      8. Four Square Cipher. FourSquare
      9. Matrix Cipher. MatrixCipher
      10. The RSA Algorithm. RSACipher
      11. Exercises

    1. The Enigma Machine
      1. Description
      2. Implementation in VBA. EnigmaCipher
      3. A Closer Look at the Mathematics

    2. Large Numbers
      1. Arithmetic of Large Positive Integers
      2. Formatting. AddLeadingZeros, RemoveLeadingZeros

        Addition of Positive Integers. AddPosInt

        Subtraction of Positive Integers. SubtractPosInt

        Multiplication of Positive Integers. MultPosInt

        Division Algorithm for Positive Integers. DivAlgPos

      3. Arithmetic of Large Signed Integers
      4. Negative Signs. IsNeg, AbsVal, Neg

        Addition and Subtraction of Integers. AddInt, SubtractInt

        Multiplication of Integers. MultInt, PowerInt

        Division Algorithm for Integers. LargeDivAlg

      5. Arithmetic of Large Decimals

Decimal Points. SplitDec, AddTrailingZeros, RestoreDecPt, RemoveTrailingZeros

Decimal Addition and Subtraction. AddDec, SubtractDec

Decimal Multiplication. MultDec

Decimal Division. DivDec, LargeRound

Decimal Exponentiation. PowerDec

*27.4 A Large Scale Calculator. LargeCalc

27.5 Exercises

Index

Biography

Hugo D. Junghenn is Professor of Mathematics at The George Washington University. He has published numerous journal articles and is the author of several books, including A Course in Real Analysis and Principles of Analysis: Measure, Integration, Functional Analysis, and Applications. His research interests include functional analysis, semigroups, and probability.