440 likes | 564 Views
Using Computer Programming to Teach Mathematics Norm Krumpe Miami University norm.krumpe@muohio.edu http://mathandcomputing.com/ octm. OCTM 2011. Problem:. I have two prime numbers. Their product is 91. What are the numbers? I have two prime numbers. Their product is 1829.
E N D
Using Computer Programming to Teach MathematicsNorm KrumpeMiami Universitynorm.krumpe@muohio.eduhttp://mathandcomputing.com/octm OCTM 2011
Problem: • I have two prime numbers. Their product is 91. • What are the numbers? • I have two prime numbers. Their product is 1829. • What are the numbers? • How long would it take you to figure this out? • I have two prime numbers. Their product is 4309597. • What are the numbers? • How long would it take you to figure it out? • How long would it take a computer to figure it out?
One more...factor this: • 245246644900278211976517663573088018467026787678332759743414451715061600830038587216952208399332071549103626827191679864079776723243005600592035631246561218465817904100131859299619933817012149335034875870551067 • Question: How long would it take a computer to factor this? • Answer: It has never been accomplished. • See the wikipedia article "RSA Numbers"
why does it matter? • It is very easy to generate numbers like these. • It is very very difficult to factor numbers like these. • This mathematics is the basis for encryption and decryption: • Encrypt by multiplying big prime numbers together. • Decryption is difficult because it requires being able to factor those big prime numbers. (It's only easy for the person who already knows the prime numbers that were used.)
computer science:Did you know… • That 0, 150, 0 means "dark blue"? • That 209.85.225.104 is Google? • That "random" numbers on your calculator are not random at all? They are generated from mathematical formulas. • Many programming languages will give the incorrect result for 0.1 + 0.1 + 0.1?
math and computing • Computer science and computer programming are deeply connected. • Computer science can help us solve problems in mathematics. • Mathematics can help us solve problems in computing.
computer science vs.computer programming • Computer science is a broad subject including: • Computer programming • Architecture • Networks and communication • Algorithms • Artificial Intelligence • Operating systems • Databases • Graphics • Computer programming is a tool that is used to solve problems in these areas. • Computer programming is a tool that is used to solve problems in other areas as well.
computer science unplugged • http://csunplugged.org
our focus: computer programming • In 50 minutes, I want to convince you that: • Programming belongs in mathematics classrooms • It is easy to get set up • It is easy to write your first program • Programming is fun
my focus will be on computers: • But…TI graphing calculators offer a rich environment as well.
why programmingis worthwhile: • "Computer Software Engineer" is near the top of nearly every list of "promising careers" • The recently introduced "Computer Science Education Act" seeks to " Ensure computer science offerings are an integral part of the [K-12] curriculum"
but why in a math class? • Computer programming is the right tool to solve problems in the mathematics you already teach. • Computer programming lets you get at other mathematics that maybe you should teach.
Mathematics you already teach: • Precalculus • trigonometric functions • exponential functions • logarithmic functions • functions in general • Calculus • differentiation • integration • sequences and series • Other topics • logic • mathematical induction • matrices • complex numbers • prime numbers • Algebra • variables • functions • recursion • iteration • Geometry • 2-D and 3-D shapes and properties • analytic geometry • Probability and statistics • Analyzing data • Random numbers • Simulation
computer concepts related to math you might one day teach: • Data abstraction and data structures • trees • graphs • algorithm efficiency • Graphics • raster graphics • vector graphics • 2-D and 3-D coordinate systems • color • animation • Programming • logic • loops • limitations • Computer fundamentals • binary numbers • bits and bytes • data storage • data representation • central processing unit (CPU) • Moore's law • Networks • privacy and security • data compression • encryption/decryption • IP addresses • topology
background • As early as 1967, people were asking the question, How can kids learn to program? • Logo was invented by Seymour Papert and others at MIT.
my own math teaching experiences with programming: • Logo in algebra, precalculus • "Write a program which will take any two side lengths and included angle and draw the corresponding triangle." • POV-Ray (3D graphics) in precalculus, calculus • "Write a program that computes the 3-D coordinates of a tetrahedron with sides of length 10, and draws it." • TI Graphing Calculator Programming in algebra, precalculus, calculus, discrete mathematics • "Write a program that asks the user to enter the current time in hours and minutes, and draw the corresponding clock, with hour hand and minute hand." • Processing for inservice secondary mathematics teachers
programming is not just for hobbyists: • Programming is a powerful tool for solving problems.
A problem from your math class: • How many boxes of cereal to you need to buy in order to collect all six randomly distributed playing cards? This short program performs the experiment 500 times and stores the data in a list.
Programming resources: • Processing • http://processing.org • Logo • http://fmslogo.org • http://www.alancsmith.co.uk/logo/ • POV-Ray • http://povray.org • Graphing calculators • TI-82/83/84/85/86/89/92 and on and on
processing: • My new go-to language for teaching beginning programming • Super easy to get started with graphics • Super powerful for data visualization • Excellent way to be artistic and mathematical, all at once • Miami uses it for their "Aesthetics and Computation" course
my favorite aspect of processing: • Students start a lot of sentences with the phrase: • "I wonder how you would…" • And that never happened in my calculus class
how to get started in processing: • Download Processing (free) from http://processing.org • Get inspired using the many built-in examples • Do some tutorials at http://processing.org • Find a good book on Processing. I recommend "Learning Processing". • Let your students get started and some will run with it!
challenge#1: • Write a program that draws a yellow circle of radius 25 at the center of the left edge of the screen. • How does the coordinate system work? • How does the color system work?
color system: RGB • Color can be expressed as a combination of red, green, and blue light: • Red light can range from integers 0 through 255 • Green light can range from integers 0 through 255 • Blue light can range from integers 0 through 255 • So, what are each of these colors? • 255, 0, 0 • 120, 0, 0 • 0, 0, 200 • 255, 255, 255 • 0, 0, 0 • 130, 130, 130 • 255, 255, 0 • Answers: red, darker red, blue, white, black, grey, yellow
color system: RGB • How many colors are possible using this system? • 256^3 • Is it possible to show all of these colors at once on the screen? • This computer screen has a resolution of 1280 x 800 pixels = roughly 1 million pixels = 1 megapixel • But 256^3 is 16,777,216
challenge #2: • Make an infinite number of random circles on the screen. • How do random numbers work? • How do you make an infinite number of circles?
challenge #3: • Make the original yellow circle animate from left to right. • How do the numbers in the ellipse() function need to change?
challenge #4: • Make the circle reappear on the left side once it leaves the right side.
challenge #5: • Put a mouth on this Pac-Man • Make it open and close
The Circle game • Inscribe a circle in the screen • Randomly mark points on the screen • Count how many of those points are inside the circle • Use that count to estimate Pi.
the result: 3.1648
new problem:the midpoint game • Begin with: • 3 triangle vertices, numbered 1 to 3 • 1 random point • Pick a random number from 1 to 3 • Move halfway to that vertex • Repeat
midpoint problem: • Main part of the solution, and the final result:
easy to program on a calculator: • This was made on a calculator in roughly 5 minutes of programming:
find all of today's presentation at: • http://mathandcomputing.com/octm