100% found this document useful (2 votes)
62 views

(Ebook) Doing Math with Python by Amit Saha ISBN 9781593277192, 1593277199pdf download

The document provides information about the ebook 'Doing Math with Python' by Amit Saha, which uses Python programming to explore various mathematical concepts such as algebra, statistics, and calculus. It includes details about the book's content, structure, and ISBN numbers, as well as links to download the ebook. Additionally, it mentions other related ebooks available on the same platform.

Uploaded by

carekrenali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
62 views

(Ebook) Doing Math with Python by Amit Saha ISBN 9781593277192, 1593277199pdf download

The document provides information about the ebook 'Doing Math with Python' by Amit Saha, which uses Python programming to explore various mathematical concepts such as algebra, statistics, and calculus. It includes details about the book's content, structure, and ISBN numbers, as well as links to download the ebook. Additionally, it mentions other related ebooks available on the same platform.

Uploaded by

carekrenali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 56

(Ebook) Doing Math with Python by Amit Saha ISBN

9781593277192, 1593277199 download

https://ebooknice.com/product/doing-math-with-python-58614158

Explore and download more ebooks at ebooknice.com


We have selected some products that you may be interested in
Click the link to download now or visit ebooknice.com
for more options!.

(Ebook) Doing Math with Python: Use Programming to Explore


Algebra, Statistics, Calculus, and More! by Amit Saha ISBN
9781593276409, 1593276400

https://ebooknice.com/product/doing-math-with-python-use-programming-to-
explore-algebra-statistics-calculus-and-more-5209546

(Ebook) Doing Math with Python: Use Programming to Explore


Algebra, Statistics, Calculus, and More! by Amit Saha ISBN
9781593276409, 1593276400

https://ebooknice.com/product/doing-math-with-python-use-programming-to-
explore-algebra-statistics-calculus-and-more-55421412

(Ebook) doing math with python doing math with python by kan

https://ebooknice.com/product/doing-math-with-python-doing-math-with-
python-50196050

(Ebook) Math Adventures with Python: An Illustrated Guide to


Exploring Math with Code by Peter Farrell ISBN 9781593278670,
1593278675

https://ebooknice.com/product/math-adventures-with-python-an-illustrated-
guide-to-exploring-math-with-code-36151058
(Ebook) Math Adventures with Python: An Illustrated Guide to
Exploring Math with Code by Peter Farrell ISBN 9781593278670,
1593278675

https://ebooknice.com/product/math-adventures-with-python-an-illustrated-
guide-to-exploring-math-with-code-10674096

(Ebook) Master SAT II Math 1c and 2c 4th ed (Arco Master the SAT
Subject Test: Math Levels 1 & 2) by Arco ISBN 9780768923049,
0768923042

https://ebooknice.com/product/master-sat-ii-math-1c-and-2c-4th-ed-arco-
master-the-sat-subject-test-math-levels-1-2-2326094

(Ebook) SAT II Success MATH 1C and 2C 2002 (Peterson's SAT II


Success) by Peterson's ISBN 9780768906677, 0768906679

https://ebooknice.com/product/sat-ii-success-math-1c-and-2c-2002-peterson-
s-sat-ii-success-1722018

(Ebook) Practical Weak Supervision: Doing More with Less Data by


Wee Hyong Tok, Amit Bahree, Senja Filipi ISBN 9781492077060,
1492077062

https://ebooknice.com/product/practical-weak-supervision-doing-more-with-
less-data-54661408

(Ebook) Practical Weak Supervision: Doing More with Less Data by


Tok, Wee Hyong, Bahree, Amit, Filipi, Senja ISBN 9781492077060,
1492077062

https://ebooknice.com/product/practical-weak-supervision-doing-more-with-
less-data-55298530
DOING MATH WITH PYTHON
DO ING M A T H
W IT H P Y T H O N
U s e P r o g r a m m i n g t o
Ex p l o r e A l g e b r a , S t a t i s t i c s ,
C a l c u l u s , a n d M o r e !

b y Amit Sa ha

San Franc isc o


DOING MATH WITH PYTHON. Copyright © 2015 by Amit Saha.

All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording, or by any information storage or retrieval
system, without the prior written permission of the copyright owner and the publisher.

Eighth printing

27 26 25 24 23 8 9 10 11 12
ISBN-13: 978-1-59327-640-9 (print)
ISBN-13: 978-1-59327-719-2 (ebook)
®
® Published by No Starch Press , Inc.
245 8th Street, San Francisco, CA 94103
phone: +1.415.863.9900
www.nostarch.com; info@nostarch.com

Publisher: William Pollock


Production Editor: Riley Hoffman
Cover Illustration: Josh Ellingson
Interior Design: Octopod Studios
Developmental Editors: Seph Kramer and Tyler Ortman
Technical Reviewer: Jeremy Kun
Copyeditor: Julianne Jigour
Compositor: Riley Hoffman
Proofreader: Paula L. Fleming

Library of Congress Cataloging-in-Publication Data

Saha, Amit, author.


Doing math with Python : use programming to explore algebra, statistics, calculus, and more! / by
Amit Saha.
pages cm
Summary: "Uses the Python programming language as a tool to explore high school-level mathematics
like statistics, geometry, probability, and calculus by writing programs to find derivatives, solve
equations graphically, manipulate algebraic expressions, and examine projectile motion. Covers
programming concepts including using functions, handling user input, and reading and manipulating
data"-- Provided by publisher.
Includes index.
ISBN 978-1-59327-640-9 -- ISBN 1-59327-640-0
1. Mathematics--Study and teaching--Data processing. 2. Python (Computer program language) 3.
Computer programming. I. Title.
QA20.C65S24 2015
510.285'5133--dc23
2015009186

For customer service inquiries, please contact info@nostarch.com. For information on distribution,
bulk sales, corporate sales, or translations: sales@nostarch.com. For permission to translate this work:
rights@nostarch.com. To report counterfeit copies or piracy: counterfeit@nostarch.com.

No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc. Other
product and company names mentioned herein may be the trademarks of their respective owners. Rather
than use a trademark symbol with every occurrence of a trademarked name, we are using the names only
in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.

The information in this book is distributed on an “As Is” basis, without warranty. While every precaution
has been taken in the preparation of this work, neither the author nor No Starch Press, Inc. shall have any
liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or
indirectly by the information contained in it.
To Protyusha, for never giving up on me
BRIEF CONTENTS

Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv

Chapter 1: Working with Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Chapter 2: Visualizing Data with Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

Chapter 3: Describing Data with Statistics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

Chapter 4: Algebra and Symbolic Math with SymPy . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

Chapter 5: Playing with Sets and Probability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121

Chapter 6: Drawing Geometric Shapes and Fractals . . . . . . . . . . . . . . . . . . . . . . . . . . . 149

Chapter 7: Solving Calculus Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177

Afterword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209

Appendix A: Software Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213

Appendix B: Overview of Python Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
CONTE NT S IN DE TA IL

ACKNOWLEDGMENTS xiii

INTRODUCTION xv
Who Should Read This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi
What’s in This Book? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi
Scripts, Solutions, and Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii

1
WORKING WITH NUMBERS 1
Basic Mathematical Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Labels: Attaching Names to Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Different Kinds of Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Working with Fractions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Complex Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Getting User Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Handling Exceptions and Invalid Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Fractions and Complex Numbers as Input . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Writing Programs That Do the Math for You . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Calculating the Factors of an Integer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Generating Multiplication Tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Converting Units of Measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Finding the Roots of a Quadratic Equation . . . . . . . . . . . . . . . . . . . . . . . . . . 20
What You Learned . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Programming Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
#1: Even-Odd Vending Machine. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
#2: Enhanced Multiplication Table Generator. . . . . . . . . . . . . . . . . . . . . . . . 23
#3: Enhanced Unit Converter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
#4: Fraction Calculator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
#5: Give Exit Power to the User . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

2
VISUALIZING DATA WITH GRAPHS 27
Understanding the Cartesian Coordinate Plane . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Working with Lists and Tuples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Iterating over a List or Tuple . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Creating Graphs with Matplotlib . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Marking Points on Your Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Graphing the Average Annual Temperature in New York City . . . . . . . . . . . . 35
Comparing the Monthly Temperature Trends of New York City . . . . . . . . . . . . 38
Customizing Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Saving the Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Plotting with Formulas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Newton’s Law of Universal Gravitation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Projectile Motion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
What You Learned . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Programming Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
#1: How Does the Temperature Vary During the Day?. . . . . . . . . . . . . . . . . . 55
#2: Exploring a Quadratic Function Visually. . . . . . . . . . . . . . . . . . . . . . . . . 55
#3: Enhanced Projectile Trajectory Comparison Program . . . . . . . . . . . . . . . . 56
#4: Visualizing Your Expenses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
#5: Exploring the Relationship Between
the Fibonacci Sequence and the Golden Ratio . . . . . . . . . . . . . . . . . . . . 59

3
DESCRIBING DATA WITH STATISTICS 61
Finding the Mean. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Finding the Median . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Finding the Mode and Creating a Frequency Table . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Finding the Most Common Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Finding the Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Creating a Frequency Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Measuring the Dispersion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Finding the Range of a Set of Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Finding the Variance and Standard Deviation. . . . . . . . . . . . . . . . . . . . . . . . 72
Calculating the Correlation Between Two Data Sets . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Calculating the Correlation Coefficient. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
High School Grades and Performance on College Admission Tests . . . . . . . . . 78
Scatter Plots. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Reading Data from Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Reading Data from a Text File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Reading Data from a CSV File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
What You Learned . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Programming Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
#1: Better Correlation Coefficient–Finding Program . . . . . . . . . . . . . . . . . . . . 89
#2: Statistics Calculator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
#3: Experiment with Other CSV Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
#4: Finding the Percentile. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
#5: Creating a Grouped Frequency Table . . . . . . . . . . . . . . . . . . . . . . . . . . 90

4
ALGEBRA AND SYMBOLIC MATH WITH SYMPY 93
Defining Symbols and Symbolic Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Working with Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Factorizing and Expanding Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Pretty Printing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Substituting in Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Converting Strings to Mathematical Expressions . . . . . . . . . . . . . . . . . . . . . 103
Solving Equations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Solving Quadratic Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Solving for One Variable in Terms of Others . . . . . . . . . . . . . . . . . . . . . . . 106
Solving a System of Linear Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Plotting Using SymPy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Plotting Expressions Input by the User . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Plotting Multiple Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
What You Learned . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Programming Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
#1: Factor Finder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
#2: Graphical Equation Solver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
#3: Summing a Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
#4: Solving Single-Variable Inequalities . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

x Contents in Detail
5
PLAYING WITH SETS AND PROBABILITY 121
What’s a Set? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
Set Construction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
Subsets, Supersets, and Power Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Set Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Probability. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
Probability of Event A or Event B . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Probability of Event A and Event B . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
Generating Random Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
Nonuniform Random Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
What You Learned . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Programming Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
#1: Using Venn Diagrams to Visualize Relationships Between Sets . . . . . . . . 140
#2: Law of Large Numbers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
#3: How Many Tosses Before You Run Out of Money? . . . . . . . . . . . . . . . . 144
#4: Shuffling a Deck of Cards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
#5: Estimating the Area of a Circle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

6
DRAWING GEOMETRIC SHAPES AND FRACTALS 149
Drawing Geometric Shapes with Matplotlib’s Patches. . . . . . . . . . . . . . . . . . . . . . . . 150
Drawing a Circle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Creating Animated Figures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
Animating a Projectile’s Trajectory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
Drawing Fractals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
Transformations of Points in a Plane. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
Drawing the Barnsley Fern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
What You Learned . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
Programming Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
#1: Packing Circles into a Square . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
#2: Drawing the Sierpiński Triangle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
#3: Exploring Hénon’s Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
#4: Drawing the Mandelbrot Set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172

7
SOLVING CALCULUS PROBLEMS 177
What Is a Function? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
Domain and Range of a Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
An Overview of Common Mathematical Functions. . . . . . . . . . . . . . . . . . . . 178
Assumptions in SymPy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
Finding the Limit of Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Continuous Compound Interest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Instantaneous Rate of Change. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
Finding the Derivative of Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
A Derivative Calculator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
Calculating Partial Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Higher-Order Derivatives and Finding the Maxima and Minima . . . . . . . . . . . . . . . . 188
Finding the Global Maximum Using Gradient Ascent . . . . . . . . . . . . . . . . . . . . . . . . 191
A Generic Program for Gradient Ascent. . . . . . . . . . . . . . . . . . . . . . . . . . . 195
A Word of Warning About the Initial Value . . . . . . . . . . . . . . . . . . . . . . . . 196
The Role of the Step Size and Epsilon . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197

Contents in Detail xi
Finding the Integrals of Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
Probability Density Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
What You Learned . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
Programming Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
#1: Verify the Continuity of a Function at a Point. . . . . . . . . . . . . . . . . . . . . 205
#2: Implement the Gradient Descent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
#3: Area Between Two Curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
#4: Finding the Length of a Curve . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207

AFTERWORD 209
Things to Explore Next . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
Project Euler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
Python Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
Books . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211

A
SOFTWARE INSTALLATION 213
Microsoft Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
Updating SymPy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Installing matplotlib-venn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Starting the Python Shell. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
Updating SymPy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
Installing matplotlib-venn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
Starting the Python Shell. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
Mac OS X. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
Updating SymPy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
Installing matplotlib-venn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
Starting the Python Shell. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220

B
OVERVIEW OF PYTHON TOPICS 221
if __name__ == '__main__' . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
List Comprehensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
Dictionary Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
Multiple Return Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
Specifying Multiple Exception Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
The else Block. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
Reading Files in Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
Reading All the Lines at Once. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
Specifying the Filename as Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
Handling Errors When Reading Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
Reusing Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235

INDEX 237

xii Contents in Detail


ACKNOWLEDGMENTS

I would like to thank everyone at No Starch Press for making this book
possible. From the first emails discussing the book idea with Bill Pollock
and Tyler Ortman, through the rest of the process, everyone there has
been an absolute pleasure to work with. Seph Kramer was amazing with his
technical insights and suggestions and Riley Hoffman was meticulous in
checking and re-checking that everything was correct. It is only fair to say
that without these two fine people, this book wouldn’t have been close to
what it is. Thanks to Jeremy Kun and Otis Chodosh for their insights and
making sure all the math made sense. I would also like to thank the copy-
editor, Julianne Jigour, for her thoroughness.
SymPy forms a core part of many chapters in this book and I would
like to thank everyone on the SymPy mailing list for answering my queries
patiently and reviewing my patches with promptness. I would also like to
thank the matplotlib community for answering and clearing up my doubts.
I would like to thank David Ash for lending me his Macbook, which
helped me when writing the software installation instructions.
I also must thank every writer and thinker who inspired me to write,
from humble web pages to my favorite books.
INTRODUCTION

This book’s goal is to bring together three


topics near to my heart—programming,
math, and science. What does that mean
exactly? Within these pages, we’ll programmati-
cally explore high school–level topics, like manipulating
units of measurement; examining projectile motion;
calculating mean, median, and mode; determining linear correlation;
solving algebraic equations; describing the motion of a simple pendulum;
simulating dice games; creating geometric shapes; and finding the limits,
derivatives, and integrals of functions. These are familiar topics for many,
but instead of using pen and paper, we’ll use our computer to explore them.
We’ll write programs that will take numbers and formulas as input, do
the tedious calculations needed, and then spit out the solution or draw a
graph. Some of these programs are powerful calculators for solving math
problems. They find the solutions to equations, calculate the correlation
between sets of data, and determine the maximum value of a function,
among other tasks. In other programs, we’ll simulate real-life events, such
as projectile motion, a coin toss, or a die roll. Using programs to simulate
such events gives us an easy way to analyze and learn more about them.
You’ll also find topics that would be extremely difficult to explore with-
out programs. For example, drawing fractals by hand is tedious at best and
close to impossible at worst. With a program, all we need to do is run a for
loop with the relevant operation in the body of the loop.
I think you’ll find that this new context for “doing math” makes learn-
ing both programming and math more exciting, fun, and rewarding.

Who Should Read This Book


If you yourself are learning programming, you’ll appreciate how this book
demonstrates ways to solve problems with computers. Likewise, if you teach
such learners, I hope you find this book useful to demonstrate the applica-
tion of programming skills beyond the sometimes abstract world of com-
puter science.
This book assumes the reader knows the absolute basics of Python
programming using Python 3—specifically, what a function is, function
arguments, the concept of a Python class and class objects, and loops.
Appendix B covers some of the other Python topics that are used by the
programs, but this book doesn’t assume knowledge of these additional
topics. If you find yourself needing more background, I recommend
reading Python for Kids by Jason Briggs (No Starch Press, 2013).

What’s in This Book?


This book consists of seven chapters and two appendices. Each chapter
ends with challenges for the reader. I recommend giving these a try, as
there’s much to learn from trying to write your own original programs.
Some of these challenges will ask you to explore new topics, which is a
great way to enhance your learning.

• Chapter 1, Working with Numbers, starts off with basic mathematical


operations and gradually moves on to topics requiring a higher level of
math know-how.
• Chapter 2, Visualizing Data with Graphs, discusses creating graphs
from data sets using the matplotlib library.
• Chapter 3, Describing Data with Statistics, continues the theme of
processing data sets, covering basic statistical concepts—mean, median,
mode, and the linear correlation of variables in a data set. You’ll also
learn to handle data from CSV files, a popular file format for distribut-
ing data sets.

xvi Introduction
• Chapter 4, Algebra and Symbolic Math with SymPy, introduces sym-
bolic math using the SymPy library. It begins with the basics of repre-
senting and manipulating algebraic expressions before introducing
more complicated matters, such as solving equations.
• Chapter 5, Playing with Sets and Probability, discusses the representa-
tion of mathematical sets and moves on to basic discrete probability.
You’ll also learn to simulate uniform and nonuniform random events.
• Chapter 6, Drawing Geometric Shapes and Fractals, discusses using
matplotlib to draw geometric shapes and fractals and create animated
figures.
• Chapter 7, Solving Calculus Problems, discusses some of the math-
ematical functions available in the Python standard library and SymPy
and then introduces you to solving calculus problems.
• Appendix A, Software Installation, covers installation of Python 3,
matplotlib, and SymPy on Microsoft Windows, Linux, and Mac OS X.
• Appendix B, Overview of Python Topics, discusses several Python
topics that may be helpful for beginners.

Scripts, Solutions, and Hints


This book’s companion site is http://www.nostarch.com/doingmathwithpython/.
Here, you can download all the programs in this book as well as hints
and solutions for the challenges. You’ll also find links to additional math,
science, and Python resources I find useful as well as any corrections or
updates to the book itself.
Software is always changing; a new release of Python, SymPy, or
matplotlib may cause a certain functionality demonstrated in this book to
behave differently. You’ll find any of these changes noted on the website.
I hope this book makes your journey into computer programming
more fun and immediately relevant. Let’s do some math!

Introduction xvii
Random documents with unrelated
content Scribd suggests to you:
CHAPTER VIII
THE TRADITIONAL CURRICULUM AND ITS
REORGANIZATION

Importance of a Study of the Curriculum


The last chapter failed of its purpose if it did not concentrate the
attention of the reader on the school curriculum. The organized body
of materials of instruction constitutes one of the most important
factors which enter into the life of the school system. Along with the
board of education, with the grading system, and with the staff of
teachers and supervisory officers stands the curriculum as a kind of
dominating personality always exercising a leading influence in the
determination of every educational policy. It will be the business of
this chapter to open the discussion of the curriculum by commenting
on the history of courses of study and by pointing out some of the
changes which recent years have wrought.

The Specialized Curriculum of Higher Schools


If one goes back to the beginnings of any school system, it will
always be found that the original courses of study grow directly out
of the intellectual ideals of the times. For example, if one goes back
to the beginnings of medieval universities, he finds that these
institutions grew up because there was an interest in certain well-
defined bodies of ideas. At Bologna one Irnerius had made himself
acquainted with the laws of the northern Italian cities, and students
came from all Europe to hear him expound these laws. The course
of study was directly related to a specific demand.
A professional theological curriculum was organized at the time of
the founding of the early American universities. Harvard was at first
a school for the training of clergymen. At that time there was no
demand for lawyers trained in the New World. The law came from
England, and from the same source came the lawyers. Medicine had
hardly developed into a profession. Preaching and listening to
sermons were, on the other hand, among the most absorbing
occupations of the colonists, and Harvard was established to provide
those who could preach. The courses of study were arranged
according to the traditions of the single profession towards which the
graduates were aiming.

Problems of Generalizing a Specialized Curriculum


We may pursue this example further as typical of the
complications which ultimately grow up around any course of study.
The original purpose of Harvard was expanded with the passing
years. A demand arose for lawyers and doctors; in the effort to meet
this demand the institution was divided into separate schools. Still
later students came to college seeking a general training not leading
to any profession. Through all these changes in the demands of the
student body the original courses of study have persistently battled
their way down to the present. No clearer evidence can be found
than this, that courses of study once created become vital factors in
all the later life of the school. The college courses of study were in
the first place the product of a particular professional demand. While
satisfying this particular demand they became strong enough so that
at a later period they have often dominated educational policies.
It is too flippant a remark to say that the classical education of the
clerical period became the fashion and that later generations were
afraid to be out of fashion, but something of this sort is what really
happened. The traditions of a generation are hard to break. The
father who took Greek as a part of his education hesitates to see his
son enter upon life without the same equipment. Courses of study
thus come to have an intellectual sanction which it is extraordinarily
difficult to break down.
Traditional Character of Mathematics Courses in
High Schools
Another example of no less impressive a type can be drawn from
the high-school curriculum of the present time. There is hardly a
tradition of high schools which is more fixed than that of requiring
algebra in the first year and geometry later. This practice persists
even though it is a well-known fact that in many schools failures in
high-school algebra are more numerous than in any other high-
school course. Also, there is a clear recognition of the fact that by
being required of all students in the first year algebra is in effect
made the prerequisite of admission to the courses in science and
literature which are open only to students who have reached the
later years of the high school. The question which the student of
education must raise is this: How did algebra secure this position of
commanding importance, and how does it hold this position when
experience shows that so many students cannot take it with
success? The answer to these questions throws a strong light on the
nature of the curriculum.
Mathematics in general gained a preëminent position in the
educational scheme of the Western World as far back as the fifth
century before Christ, in the days of Pythagoras. The branches of
mathematics which were chiefly cultivated in those days were
geometry and arithmetic. Geometry flourished as an experimental
science, and arithmetic consisted in the most elaborate speculations
about prime numbers and the properties of odd and even numbers.
After these sciences had reached a certain maturity they were
transferred to the University of Alexandria, where, in the third
century before Christ, Euclid formulated the principles of geometry
into the logical form which has persisted to our own time. If one
asks why the same service was not rendered for arithmetic at the
University of Alexandria, the answer is to be found in the fact that
the Greeks had no adequate method of expressing number. They
used a system of letters even more clumsy than the system
employed by the Romans after them. If one needs further
demonstration of the reason why arithmetic did not develop in the
classical world, let him try to multiply DCCLXXVII by XCIX. Arithmetic
was very little cultivated, therefore, while geometry was put into
perfect logical form. Since arithmetic was so little developed in the
ancient world, algebra never succeeded in getting a real start.
Geometry, thus launched as a systematized branch of learning
superior to arithmetic, has held its place through all generations. In
the medieval institutions the perfect logical form of geometry was
fully recognized. Geometry was used to sharpen the logic of many a
mind. Arithmetic developed only so far as it was needed for the
practical purposes of daily life.
In due time there came into Europe oriental scholars who brought
with them that marvelous invention—the Arabic numerals. They
brought also the science of algebra with its profound abstractions.
The Arabic numerals soon superseded the clumsy Roman numerals,
and the common man found that he could easily deal with the
practical matters of life by means of this number system which
rendered all calculations simple. With arithmetic of the new type
came algebra. The scientists of Europe found that the algebraic
methods opened up possibilities of mathematical reasoning which
were of the first importance to science. Algebra and arithmetic
flourished. But did these two newcomers in any degree disturb the
position of geometry? Not at all. Algebra may be as abstract as any
subject in the curriculum, but its historical relations were from the
first with arithmetic, while geometry was related to logic and the
higher subjects. Geometry has continued since 300 B.C. to be a
higher course. The situation in the high schools of to-day is in no
sense due to a careful study of the degree of abstraction involved in
geometry and algebra. It is in no sense a recognition of the fact that
geometry was the first of the two subjects to develop. The present
situation can be understood only by recognizing the strength of
tradition and the persistence of a practice when once it gets itself
established.
The situation is the more impressive because even a superficial
study of the intellectual needs of pupils shows that there ought to be
instruction in the lower grades in the discrimination of forms and
designs. One does not master the forms even of common things
until his attention has been turned to them again and again. The
consequences to the curriculum of the elevation of geometry to the
upper school are far-reaching in a negative as well as in a positive
way. Space study has been kept out of the lower schools because
the only orthodox form of space study is the geometry of the higher
schools. Space study ought to have a place in the curriculum of
every grade.
In the case of algebra, on the other hand, tradition has operated
to keep the subject in the lower classes of the high school. That it
would be better to change this situation appears in the fact that
textbooks in algebra have in recent years been made much easier in
the effort to fit the subject to pupils’ needs, in the fact that some
high schools have made it elective, and in the fact that some high
schools have rearranged the whole subject-matter of mathematics,
breaking up the historical lines of division.

Suggestions of New Subjects


Other evidences that the curriculum is in need of radical reform
appear when one notes that schools are curiously blind in the
subjects which they omit. A recent writer has pointed out in a very
interesting way the weakness of the ordinary school in its failure to
give children any training in the use of money. A quotation from his
introductory chapter will show the force of his criticism.

Most people if suddenly asked, “What financial training did


you have as a child?” would probably say, “None.” If asked,
“What financial training are you giving your own children?”
many parents would give the same answer. All parents,
however, do incidentally give lessons in finance and a few give
definite instruction with regard to money.
The teacher, if thus questioned, would usually say something
about arithmetic or perhaps refer to some system of money-
saving that is being operated by the school. Much has really
been done that educates children financially, but probably not
one person in ten has ever seriously studied the problem of the
need of financial training of children and of how that need at
each age may best be met.
A moment’s reflection tells one that many adults do not know
how to spend their money wisely and that still fewer know how
to keep it safely or invest it successfully. Every day we see
people spending money in ways that bring little satisfaction.
Others are tortured by the fear of losing what they have, while
still others are investing in schemes that promise much and
yield little or nothing.
Charity workers are especially impressed with the inability of
poor people to spend wisely the little money they get. One
woman whose family was in a starving condition spent all of the
dollar that was given her for canned lobster, and another in a
similar situation had a picture taken.
Rich sons and daughters often spend the money accumulated
by their fathers in even more foolish ways. In general it is only
the common people who have had much experience in saving
and spending money, who spend it wisely and many of these
have paid a high price for their knowledge. If carefully planned
financial training were given, the number spending wisely would
doubtless be greatly increased.41

Present-Day Social Demands


Other suggestions are being made these days for a change in the
course of study. Sometimes the suggestions take the form of social
movements. Such social movements often come in the form of
violent criticisms of existing practices. These criticisms will be
understood only when it is recognized that back of them there is
often a social pressure which has not been understood and is now
finding voice in a demand that requires immediate attention. It will
be well for us to seek some examples of this type in order that we
may come to understand that the school system is answerable at all
times not merely to earlier social ideals which were incorporated into
courses of study but also to the new ideals which arise with the later
developments of community life.
An example of the type we are seeking appears in a study which
was made in 1913 in the city of Minneapolis. The following extracts
from an article published on March 10 in the Morning Tribune of that
city state the case fully:

A year ago a group of men and women interested in the


welfare of boys and girls, and somewhat acquainted with
conditions that confront them upon their entrance into industrial
life, decided that it was time to make a survey of the city. There
had been much talk of training for the trades in the public
schools, and apparently there was reasonable ground for this
advocacy....
Was there a real demand, or was this a new educational fad
sweeping across the country, to be lost in the great abyss of
educational nostrums, along with vertical writing and basketry?
That was to be determined.

Educators are usually learned men; but this world generally does
not ascribe to them an abundance of sound sense. These learned
men have charge of the greatest plant in the world—our schools. A
half million employees are at work at an annual expense to the
nation of $450,000,000. The product of this institution should be
manhood and womanhood, efficient to take its place in the world of
workers, and firmly established in habits of right thinking and noble
action. Yet who is accounted efficient for the work of to-day?
Certainly not the armorer, no matter how skilled—for what need
have we of him? Possibly not the bootmaker; for the best and latest
in boots come from big factories. And so rapidly do industries
change that confusion awaits the man still using methods of ten
years ago. No system of education can be efficient until the
conditions of life to which pupils go are thoroughly known. No
manufacturer would think of setting his machines to make “what-
nots” or muzzle-loading guns; they were all right in their day but
that day is now yesterday. The first thing for the man of business is
to know what the market demands. And the managers of the
schools must explore their market to know what is demanded of the
education factory. That is the reason for this survey.
The commission was made up of persons well known in the city
and representative of differing interests....
Ten months were spent in gathering the information, and a month
in studying it and getting it into shape for presentation. The tables
have been arranged in the following order: First, a set of three
tables, showing the sources of the material studied, by school, by
age, by grade, and by nationality, and the causes of retardation;
second, a table showing upon whom the responsibility should be
placed for the child’s leaving school; third, four tables setting forth
the reasons for leaving school, and the economic status of the
family; fourth, a table indicating the education of the children after
leaving the public school; and fifth, five tables showing the industrial
history of each child, his wages, the number of jobs, the kind of
work, and his advancement.
In the discussion comparisons are frequently made with similar
reports from other cities, and following these are the conclusions
reached by the committee and recommendations for further work.
It will not be possible to give in detail all the results thus obtained.
It must suffice to repeat here the figures which summarize the table
of causes for leaving school. The percentages of pupils leaving for
each cause are given with the statement of the cause.
Ill health 5.7 per cent
Had to go to work 35.5 per cent
Child’s desire to earn money 8.2 per cent
Kept vacation work 2.6 per cent
Disliked or not interested in school 29.6 per cent
Trouble with teacher 3.1 per cent
Failure to pass 1.1 per cent
Further public school not worth while 14.2 per cent

The number of pupils who leave because they do not like school
or do not believe it worth while is disturbingly large. That there
should be so pronounced an adverse judgment on the part of pupils
is perhaps to be explained in a measure by their immaturity and
restlessness; but part of the school’s problem is to meet this
immaturity and restlessness and to train the pupils with full regard to
all that goes to make up their individual tastes and abilities.
It is especially important that a careful study be made of all
available recommendations for improving the situation. We turn,
therefore, to some of the leading recommendations of the
Minneapolis commission:

That as rapidly as would be economical, the schools be


organized on the “six-three-and-three” plan, beginning
differentiated courses in the B seventh grade. These courses
should follow three broad lines: (1) Leading toward the
academic courses in high schools. (2) Toward the commercial
courses, or directly to business. (3) Toward manual training in
high school, or directly to manufacturing and mechanical
pursuits.
That preparation for the trades can be best and most
economically closely related to working conditions, while the
necessary skill shall be gained in actual work under the usual
commercial conditions.
That the membership of the Thomas Arnold school be
enlarged to include all boys who have reached the age of fifteen
and have not yet reached the seventh grade. And that a similar
school be organized for girls.
That a department of vocational guidance be organized.
That, as an adjunct to the board of education, an advisory
commission of 15 members, composed of employees, employers
and educators, be established, whose duty it shall be to report
changes in the demands of business and industry, and to advise
modifications of the course of study to meet these new
demands.
That a law should be enacted, making it mandatory that a
boy shall be either in school or at work up to his eighteenth
year, and that the department of vocational guidance be
charged with the duty of enforcing such a provision.

This report has been reproduced at length because it furnishes a


concrete example of the kind of demand which is being made on
many sides for a complete remaking of the curriculum. The
comments about school officers are also typical of much that is
being laid at the door of the present-day pedagogue. Better than
any theoretical answer to these critics is a careful study of the whole
problem of reorganizing the curriculum.

Traditional Neglect of Industrial Education on the


Part of the Public
The reasonableness of the demand that the schools prepare boys
and girls for their work in the world raises at once the question: Why
have the schools ever neglected this need? The answer to this
question is supplied in part by the remoter history of schools which
was touched on in an earlier chapter and in the early paragraphs of
this chapter. European and American schools first dealt with
professional and theological problems and have accordingly always
had a strong leaning toward the literary subjects.
The early history of the American educational system throws light
on this particular matter in a way which will help the reader to
understand the present situation with regard to industrial education
and traditional education.
At the same time that the New England colonies were passing
laws establishing schools where children were to learn to read the
Bible, they provided in such laws as the following for training in
industrial lines. The Connecticut law of 1650 provides that “all
parents and masters do breed and bring up their children and
apprentices in some honest lawful labor, or employment, either in
husbandry or some other trade profitable for themselves and the
commonwealth, if they will not nor cannot train them up in learning,
to fit them for higher employments, and if any of the selectmen,
after admonition by them given to such masters of families, shall
find them still negligent of their duty, ... the said selectmen, with the
help of two magistrates, shall take such children or apprentices from
them, and place them with some masters for years, boys until they
come to be twenty-one, and girls to eighteen years of age
complete.”
The conception of responsibility which lies back of this law is
wholly different from that expressed in the legislation providing for
reading-schools. A public officer was put in charge of reading. He
was stimulated to carry on his work by the rewards which he
received in the way of compensation for his services. The control of
industrial education by the public was very slight. We can imagine
some selectman whose attention was by chance drawn to a
neglected child, debating with himself the wisdom of setting in
motion the magistrates and his fellow selectmen in enforcing this
somewhat vague law. The fact is that the law was not enforced. It
became a dead letter, and public attention to vocational education
has no history in this country until recent years, when the pressure
of industrial competition has forced its recognition.
In the early days of the nation’s life the absence of any definite
plan for public vocational education of young people was not a
serious matter. Industrial life was relatively simple, and the family
lived close to its sources of supplies. The family was able to take
care of the children’s preparation for industrial life without aid or
interference from the state. But social and industrial conditions have
changed. With the development of factories, of elaborate systems of
transportation, and of urban life it is no longer possible for the family
to train the children, and the demand begins to be urgently felt that
some agency give adequate preparation for the practical later life of
the children, and that more especially where families are not well-to-
do.
For a long period after this demand was felt the school went on
with its specialized task, and the public was complacent to see the
school neglect vocational training. The specialized task of the school,
as thought of in those days, was to teach reading and the other
subjects which naturally attached themselves to the literary
tendencies that grew up in a reading-school. Private institutions,
such as business colleges, sprang up as agencies for satisfying the
demand for special vocational training. These were tuition schools
and secured their students in many cases by criticizing the public
school as incompetent and wasteful. In some cases employers,
realizing the necessity of training their workers, made it a part of
their industrial organization to teach certain branches of the trades.
In other cases, a boy going into an occupation which had no regular
training-school, either in a private institution or in the industrial
plant, got his training as best he could by accepting a low wage and
blundering along until he learned his trade. Even to-day the private
training of young people for industry is conducted on a scale that
shows how new is the idea that the public school is responsible in
any degree for such training.

The Demand for Revision of the Curriculum


The historical sketch given above illustrates, as do the earlier
examples presented in this chapter, the natural conservatism of the
school curriculum on the one hand and the inevitableness of an
expansion of the school on the other. Historically, the common
school had no duties in the direction of vocational training. But we
are beginning to realize that it is not profitable to try to throw off
responsibility. To-day the school must cope with an urgent social
problem. The curriculum was and is literary in its major content. The
problem of the future is to expand it so that it shall combine with its
literary content a new and productive body of vocational training.
SUMMARY
Our study of the curriculum has established, first, the important
fact that courses of study are real factors to be dealt with in any
school situation; second, the motives which give rise to particular
forms of instruction are superseded in the course of school history
by new social needs. Nevertheless, the curriculum tends to persist,
and often because of its conservatism becomes a menace to
progress. Suggestions for innovations come through the insights of
individuals or through the formulation of social demands. Whatever
the source of suggestions for change, the student of education will
find his problem in the fact that the curriculum is undergoing change
as is every other phase of modern life. How to understand the
changes that are imminent and how to direct them into productive
channels is a major problem of the science of education.
EXERCISES AND READINGS
Find new subjects other than those mentioned in the text which
have been introduced into either the high-school curriculum or into
the curriculum of the grades. Within the older courses find some
new topics which have been introduced. New subjects in general are
not looked on as entirely respectable. Why is this? What should be
done to make them respectable?
Why does training for vocation seem less respectable than
conventional school work? What is to be done to meet this situation?
Do people in general know what changes ought to be made in the
curriculum? Note that the Minneapolis study found difficulties. For
these it had clear scientific evidence. Did it have equally clear
grounds for its recommendations? Should it have had? How could it
secure evidence of this latter type?
Relating this discussion to the first paragraphs of Chapter I, let us
inquire what steps with regard to informing the community are
necessary to the success of a new program of studies.
Whose duty is it to plan new courses—that of the board of
education, the superintendent, or the teacher who is a specialist in
some subject?

Bobbitt, J. F. What the Schools Teach and Might Teach.


Published by the Survey Committee of the Cleveland
Foundation. (Copies may be secured from the Russell Sage
Foundation.)
Koos, L. V. The Administration of Secondary-School Units.
Supplementary Educational Monograph No. 3, Vol. I, of the
School Review and the Elementary School Journal. The
University of Chicago Press. Contains a summary of the
practices of the approved schools of the North Central
Association.
Minimum Essentials in Elementary-School Subjects.
Fourteenth Yearbook of the National Society for the Study of
Education, Part I, 1915. Public School Publishing Company,
Bloomington, Illinois. This is an effort to bring together a
statement of the essential requirements for the elementary
curriculum.
Report of the Committee of Ten on Secondary Education.
National Education Association. American Book Company. The
most important report ever prepared in relation to the
organization and courses of study of the high school. Its
appearance marked the beginnings of the present era of high-
school expansion.
CHAPTER IX
SPECIALIZED EDUCATION VERSUS GENERAL
EDUCATION

Present-Day Wavering between Specialized and


General Training
Because there is an urgent social demand for the reorganization of
the curriculum and because the principles which should underlie a
sound curriculum are as yet not clear, there is much running back
and forth in the educational world and much controversy that at
times grows very bitter and even personal. Experiments are set up
and lauded or assailed. Optimists are hopeful that out of this
experimentation will come much good. Pessimists see in it the failure
of a democratic educational system.
The recent controversies have revived the ancient dispute
between a general education which makes the “all-round man” and
specialized education which serves some particular purpose. This
controversy can be illustrated by two kinds of examples. First, let us
listen to those who are interested in higher education for the classes
of students who are going to high school and college. Later we shall
find that there is another level at which the same kind of controversy
is going forward.
The following statements and counter-statements illustrate the
extent to which the dispute is carried:

I suggest, that, in the first place, a man educated in the


modern sense, has mastered the fundamental tools of
knowledge: he can read and write; he can spell the words he is
in the habit of using; he can express himself clearly orally or in
writing; he can figure correctly and with moderate facility within
the limits of practical need; he knows something about the
globe on which he lives. So far there is no difference between a
man educated in the modern sense and a man educated in any
other sense.
There is, however, a marked divergence at the next step. The
education which we are criticizing is overwhelmingly formal and
traditional. If objection is made to this or that study on the
ground that it is useless or unsuitable, the answer comes that it
“trains the mind” or has been valued for centuries. “Training the
mind” in the sense in which the claim is thus made for algebra
or ancient languages is an assumption none too well founded;
traditional esteem is an insufficient offset to present and future
uselessness. A man educated in the modern sense will forego
the somewhat doubtful mental discipline received from formal
studies; he will be contentedly ignorant of things for learning
which no better reason than tradition can be assigned. Instead,
his education will be obtained from studies that serve real
purposes. Its content, spirit and aim will be realistic and
genuine, not formal or traditional. Thus, the man educated in
the modern sense will be trained to know, to care about and to
understand the world he lives in, both the physical world and
the social world. A firm grasp of the physical world means the
capacity to note and to interpret phenomena; a firm grasp of
the social world means a comprehension of and sympathy with
current industry, current science and current politics. The extent
to which the history and literature of the past are utilized
depends, not on what we call the historic value of this or that
performance or classic, but on its actual pertinency to genuine
need, interest or capacity. In any case, the object in view would
be to give children the knowledge they need, and to develop in
them the power to handle themselves in our own world. Neither
historic nor what are called purely cultural claims would alone
be regarded as compelling.
Even the progressive curricula of the present time are far
from accepting the principle above formulated. For, though they
include things that serve purposes, their eliminations are
altogether too timid. They have occasionally dropped,
occasionally curtailed, what experience shows to be either
unnecessary or hopelessly unsuitable. But they retain the bulk
of the traditional course of study, and present it in traditional
fashion, because an overwhelming case has not—so it is judged
—yet been made against it. If, however, the standpoint which I
have urged were adopted, the curriculum would contain only
what can be shown to serve a purpose. The burden of proof
would be on the subject, not on those who stand ready to
eliminate it. If the subject serves a purpose, it is eligible to the
curriculum; otherwise not. I need not stop at this juncture to
show that “serving a purpose,” “useful,” “genuine,” “realistic,”
and other descriptive terms are not synonymous with
“utilitarian,” “materialistic,” “commercial,” etc., for intellectual
and spiritual purposes are genuine and valid, precisely as are
physical, physiological, and industrial purposes.42

The answer in florid and perfervid terms offered by a champion of


the classics is as follows:

I have left myself only a few words to sum up and define the
main issue raised by the so-called modernist reform of
education. It is not the place of physical science in our
civilization and in our universities: that is secure. It is not the
opportunity of industrial or vocational training for the masses:
we all welcome that. It is not the conversion of the American
high school into the old Latin-verse-writing English public
school: nobody ever proposed that. It is not the prescription of
a universal requirement of Greek or the maintenance of a
disproportionate predominance of Latin in our high schools and
colleges: there is not the slightest danger of that. It is the
survival or the total suppression, in the comparatively small
class of educated leaders who graduate from high schools and
colleges, of the very conception of linguistic, literary, and critical
discipline; of culture, taste, and standards; of the historic sense
itself; of some trained faculty of appreciation and enjoyment of
our rich heritage from the civilized past; of some
counterbalancing familiarity with the actual evolution of the
human man, to soften the rigidities of physical science, and to
check and control by the touchstones of humor and common
sense the a priori deductions of pseudo-science from conjectural
reconstructions of the evolution of the physical and animal man.

It is in vain that they rejoin that they too care for these
things, and merely repudiate our exclusive definitions of them.
That is, in the main, only oratorical precaution and the tactics of
debate, as, if space permitted, I could show by hundreds of
citations from their books. The things which, for lack of better
names, we try to suggest by culture, discipline, taste, standards,
criticism, and the historic sense, they hate. Or, if you prefer,
they are completely insensitive to them and wish to impose their
own insensibility upon the coming generation. They are
genuinely skeptical of intellectual discriminations which they do
not perceive, and æsthetic values which they do not feel. They
are fiercely resentful of what they deem the supercilious
arrogance of those who possess or strive for some far-off touch
or faint tincture of the culture and discipline which they
denounce as shibboleths, taboos, and the arbitrary conventions
of pedants.
From their own point of view it is natural that they should
deprecate with sullen jealousy the inoculation of the adolescent
mind with standards and tastes that would render it immune to
what one of them has commended in print as the “science” of
Elsie Clews Parsons. The purpose, or, at any rate, the tendency
of their policies is to stamp out and eradicate these things and
inculcate exclusively their own tastes and ideals by controlling
American education with the political efficiency of Prussian
autocracy and in the fanatical intolerance of the French
anticlericalists. Greek and Latin have become mere symbols and
pretexts. They are as contemptuous of Dante, Shakespeare,
Milton, Racine, Burke, John Stuart Mill, Tennyson, Alexander
Hamilton, or Lowell, as of Homer, Sophocles, Virgil, or Horace.
They will wipe the slate clean of everything that antedates
Darwin’s Descent of Man, Mr. Wells’s Research Magnificent, and
the familiar pathos of James Whitcomb Riley’s vernacular verse.
These are the policies that mask as compassion for the child
bored by literature which, they say, it cannot be expected to
appreciate and understand, or behind the postulate that we
should develop æsthetic and literary sensibilities only by means
of the literature that expresses the spirit of modern science, not
that which preserves in amber the husks of the dead past.43

The Theory of Separate Schools for Different


Classes of People
Both writers above quoted are speaking of those learners who are
to have large opportunities of higher education. What is to happen
to the common masses, to whom the last writer grants the
“opportunity of industrial or vocational training,” is still in doubt.
There are, however, disputants who are trying to settle this question
also. To illustrate we may borrow from a pamphlet issued by a great
commercial organization in its campaign for legislation which should
transform the school system of the city of Chicago and the state of
Illinois.
STATEMENT OF PRINCIPLES

Definition: Vocational education includes all forms of


specialized education, the controlling purposes of which are to
fit for useful occupations, whether in agriculture, commerce,
industry or the household arts.
1. State aid is necessary to stimulate and encourage
communities to carry on work in vocational education, but local
communities should be permitted to initiate and should partly
maintain such courses or schools.
2. The vocational schools should not compete or interfere
with the present public school system, but should supplement it
by providing practical instruction in vocational lines for youth
between fourteen and eighteen who have left the present
schools. To guard against any competition with the public
schools as now organized, a special tax should be levied for the
support of vocational schools, which, with the State grant for
their support, should not be taken from the funds now provided
by law for the support of the public school system.
3. The proper expenditure of State moneys for vocational
schools should be fully safeguarded, while at the same time the
initiative in adapting measures to local conditions should be left
with the local authorities. To secure these ends the general
management and approval of these courses and schools should
be left to a State commission, while the local initiative and direct
control should be exercised by a local board composed of
employers, skilled employees and local superintendents of
schools.
4. An efficient system of vocational education requires
different methods of administration, different courses of study,
different qualifications of teachers, different equipment,
different ways of meeting the needs of pupils and much greater
flexibility in adapting means to ends than is possible under the
ordinary system of public school administration. For these
reasons these schools should be under a separate board of
control, whether carried on in a separate building or under the
same roof with a general school, so that they may be free to
realize their dominant purpose of fitting for useful
employment.44
If the last two quotations are stripped of their decorations, they
reveal a demand for a distinct class system of education. Broad
education is for the few. Specialized education is another matter,—let
it be developed for the masses.

Public Demand for a New Curriculum


It is interesting to note that the masses, so far as they can
express themselves, are asking for a change in the traditional
curriculum and are likely to get it. The masses are expressing their
demands through the courses sought by their children.
Our problem will perhaps be clearer if we turn from the writings of
those who discuss these matters to the changes which are actually
going on in the schools of the country.

Commercial Courses in High Schools


High schools in all parts of the country are giving commercial
courses in increasing degree. The first type of industrial education to
be extensively cultivated in the United States was commercial
education. This consisted in training for clerical positions and was
carried on for the most part in private “business colleges.” The
reason for the early demand for this particular kind of training is to
be sought in the fact that America has for years been a country
devoted on a vast scale to exporting raw materials. Commercial
training, which has to do with the shipping of goods, was
accordingly the first to grow here. The extent of the demand for
commercial training is vividly set forth in a report of the City Club of
Chicago published in 1912, which contains the following chart:
ENROLLMENT IN PRIVATE VOCATIONAL SCHOOLS AND IN
PUBLIC HIGH SCHOOLS OF CHICAGO45
There are at least There are only
19,000 STUDENTS 17,781 STUDENTS
in in all
Private Commercial Schools Public High Schools
and 800 in
Private Industrial Schools in Chicago
in Chicago, and at least and only
$1,485,000 $1,114,526
is paid for is expended for
TUITION MAINTENANCE

Fig. 12

The high schools of the country entered into competition with the
private commercial schools, and for some years the competition has
been running high. The private schools solicit and get a large
patronage on the ground that they do not teach anything that is
useless. They give short, compact courses fitted to pupils’ needs.
The high schools point out that the short courses leave the
stenographer with a meager vocabulary and the clerk with no
outlook on life.
The public schools are gradually pulling ahead of their competitors
because they are employing a higher grade of teachers than
formerly and are doing the work in a fashion which is technically
more complete. In the meantime the commercial courses are
becoming more “respectable” and are being taken by a better grade
of students. The effect of the election of commercial courses by a
better grade of students is such as to modify the whole program of
the school in the direction of more attention to the needs and
practices of business life.

Agricultural High Schools


A second type of vocational course appears in the high schools of
rural communities where much attention is being devoted to
agriculture. Indeed, the increase in the number of high schools in
the country in recent years has been very largely due to the fact that
rural communities have taken an interest in carrying the training of
pupils beyond the rudimentary subjects of the elementary
curriculum.
This movement relates itself to the development of a department
of agriculture in the Federal government and to the generous
subsidy through that department for agricultural experiments in
centers of education in all the states. Three years ago a large
Federal subsidy was set aside for the further promotion of
agricultural demonstrations and schools, and the recently enacted
Federal legislation for industrial education includes provision for
more agriculture.

Part-Time Courses
A third movement which has recently attracted a great deal of
attention and favorable comment was started in the engineering
school of the University of Cincinnati and is known as the part-time
plan. Classes are organized in such a way that their members spend
one week or one month in the shop of some manufacturing plant
and the next period in school. A second group alternates in the
reverse order, so that the shop and the school are at all times
engaged in regular work. Where this plan is well organized, there is
a special school officer, called a correlator, who sees to it that there
is some direct connection between the shop work and the courses
taken up in the schools.
The part-time plan aims to supply that mixture of practical
opportunity and training in science, mathematics, and the academic
subjects which will lead to both vocational efficiency and a general
education.
Various Types of Trade Schools
Fourth, there are all kinds of schools for young people in the
trades. Some of these hold their sessions at night, when the working
day is over, and others are organized to take the young worker out
of the shop or store for a limited number of hours during the
working day. In the matter of instruction some give only special
training intended to make the worker more skillful; others give
general courses in civics, or history, or even in literary subjects.
Some of these schools for workers are organized by the
corporations which employ the workers. Thus, telephone companies
and dry-goods stores find that it is economical to train their
employees. Some of the schools are conducted by the school system
and are provided with pupils either through the voluntary demand
on the part of learners or through the operation of state laws or
municipal ordinances compelling children to attend such schools until
they are of a certain age.
Fifth, trade training is provided not merely for those in the trades
but also for those who are preparing to enter them. Trade schools
are sometimes supported out of the public purse, sometimes by
private endowments. The method of instruction is that of requiring
the learner to go through a definite series of exercises which will
give him skill in the trade. The strictly technical training is usually
supplemented by some “general” training.
The following quotation gives a brief summary by one specialist in
vocational education of the writings of another specialist in the same
field:
THE MANHATTAN TRADE SCHOOL, NEW YORK CITY

This trade school for girls is now a part of the public-school


system of New York City. Its early history as a privately
supported institution is of absorbing interest, and has been
tersely written by Mrs. Mary Schenck Woolman, in her book
entitled “The Making of a Trade School.” In this volume she
gives an interesting account of the first experiment in the United
States to deal in an adequate way with the problem of
furnishing vocational training and guidance to children destined
to enter industrial life, otherwise wholly unprepared, at the
earliest possible age.
The aim of the school is frankly stated to be the giving of help
to the youngest wage earners, but its ideals are of considerable
breadth. They are to demonstrate to the community what
education is needed for “the lowest rank of women workers” in
order that a girl may become self-supporting and adaptable,
“understand her relation to her employer, to her fellow workers,
and to her product,” and value health and moral and intellectual
development.
The necessity for this effort was found in the unfortunate
social and economic conditions, and especially in the lack of
opportunity for progressive work. “After several years spent in
the market” the girl was found to be little better off than on her
entrance into industrial life.
After investigation, trades were selected in which are used the
sewing machine (foot and electric power), the paint brush,
paste brush, and needle. In organizing instruction all
unnecessary waste was eliminated; short, intensive courses
were planned to give knowledge and skill in the technical
aspects of the selected trade, and to develop mental alertness
on the part of the worker. It has been observed that “the
academic dullness which is shown at entrance comes frequently
from lack of motive in former studies.” The fundamental
importance of health and the value of trade art as a help to
progress are given special emphasis.
The supreme value of the school’s trade-order business, as an
educational asset, is shown in the following quotation:
It provides the student with adequate experience on
classes of material used in the best workrooms; these girls
could not purchase such materials and the school could not
afford to buy them for practice. The ordinary conditions in
both the wholesale and the custom trade are thus made a
fundamental part of instruction. Reality of this kind helps
the supervisor to judge the product from its trade value,
and the teaching from the kind of workers turned out.
Through the business relation the student quickly feels the
necessity of good finish, rapid work, and responsibility to
deliver on time. The businesslike appearance of the shop at
work on the orders, and the experience trade has had with
the product, have increased the confidence of employers of
labor in the ability of the school to train practical workers
for the trades.... The business organization and
management required in the adequate conduct of a large
order department can itself be utilized for educational
purposes.

A chapter devoted to representative problems makes an


illuminating analysis of the difficulties which must be met and
solved by those organizing schools for workers in the lower
grades of industry. While the instruction must be direct and
specific, some preliminary general training is needed, and work
intended to awaken vocational interests should also be
provided. Mrs. Woolman believes that all this might and should
be given in the public elementary school. Other difficulties are
the keeping of the school organization flexible and sensitive to
ever-changing trade conditions, and in “close contact with
industrial and social organizations of workers in settlements,
clubs, societies, and unions, that all phases of the wage earner’s
life—pleasures, aims, and needs—may be appreciated.” There is
the difficulty of securing suitable teachers, and of working in
harmony with the ideals of organized labor.46
Practical Applications as Parts of Academic Courses
The effect of these experiments in vocational education is clearly
discernible in the traditional courses. Reading books are beginning to
include extracts which deal with practical matters. Mathematics
textbooks are presenting more than ever before practical problems
drawn from commercial, trade, and agricultural life. Science, both in
elementary and advanced forms, is turning to practical applications.
In short, there is going on a kind of intellectual compromise which
will eventually make training in skill an accepted part of a general
training.
General training has until recently been so proud of itself that it
has not willingly accepted association with courses designed to
cultivate skill. The result is that the common man has gained the
impression that there is a wide gulf fixed between general education
and practical life. One hopeful symptom of the present situation is
that discussions of general education are becoming very much more
democratic. To be sure, there are examples of the proud
exclusiveness of former days still to be found in the writings of those
who do not understand the reach of modern reforms in the
curriculum, but these cases are likely to become fewer as the years
pass. In the meantime the practical world is making long strides in
the direction of an appreciation of the value of a general education.
The shop mechanic should read. He should be independent in his
cultivation of contact with the most recent movements in his trade.
The teacher who teaches reading is coming to recognize this as
clearly as does the employer, and very shortly the idea that reading
is an artificial somewhat, cultivated exclusively for purely intellectual
reasons, will give way to the broader view that even the artisan
gains in efficiency by reading.
When that time comes there will be no room for the theory that
there should be a different school for the tradesman and the
professional class. There will be differentiation within the courses.
There will be an elective opportunity for each pupil which will adapt
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebooknice.com

You might also like