<<

Session Outline: Oct. 14, 2017 Coding for the Love of Mathematics Richard A. Clausi

**cartoon IMAGES are courtesy of New Vision Technologies Task Force ClipArt © 1995 (wannapik.com) Other images are acknowledged in the Resource list and in context.

17/10/2017 Slides (c) 2017 Richard A. Clausi 1 • Session 3 • Title: Coding, For the Love of Mathematics Presenter: Richard Clausi, OCT – Elmira District S.S. (retired 2012) • Currently: Instructor, EU420D, Faculty of , Wilfrid Laurier University • : Owner, RC Software and Data (registered 1981) • Slides will be available at: http://www.kw.igs.net/~raclausi/coding.pdf

Session Description: Coding, a new player in the elementary school curriculum, offers teachers and students a new way to explore mathematics. This session is a light overview of entry‐level programming (code.org, scratch and LOGO) as a way to engage and nurture mathematical thinking. This new tool for problem solving allows us to use simple programming to understand and apply “tough” concepts such as , modularity and multi‐tasking to ARDUINO programming and Mouse Mazes, calculating TT, Newton’s Method for Square Roots, Fractals and . • I hope that you will leave with inspiration and ideas that you can use to explore your own personal mathematical adventures.

• ** This slide will be the last slide in my presentation so you can copy down the web address, later, if you wish.

17/10/2017 Slides (c) 2017 Richard A. Clausi 2 Warnings…

• An intelligent, silicon‐based life‐form…..

• And of Websites that evaporate…

17/10/2017 Slides (c) 2017 Richard A. Clausi 3 A code….

“In a code, a word or phrase is replaced with a word, number or symbol. For example, secret agents have codenames, words that are used instead of their real names in order to mask their identities. Similarly, the phrase ‘Attack at Dawn’ could be replaced by the codeword ‘Jupiter’ and this word would be sent to the commander in the field” from: The Code Book by Simon Singh, page xvi ISBN 0‐385‐49532‐3

17/10/2017 Slides (c) 2017 Richard A. Clausi 4 17/10/2017 Slides (c) 2017 Richard A. Clausi 5 • From a fund‐raising letter, June 2017:

• Richard. Look at this: • You're looking at the Pong inspired game that Justin Trudeau created at Code.org's "Hour of Code" event back in December. Built using a beginner‐friendly block based approach, this technique is commonly used to teach new programmers (youth and university students alike) how to write code. • It may look simple, but the reality is that, by 2021, the Information and Communications Technology Council forecasts that over 200,000 digital jobs could go unfilled by Canadian talent –and that's something we need to fix, because the global economy is becoming increasingly digital. • From buying groceries, and managing our kid's sports teams, to the computer programs and technology used in workplaces across Canada, more and more aspects of our lives are touched by technology on a daily basis. • It is important that Canadians of all walks of life have the skills needed to navigate this new economy, so they are prepared for the jobs of today, and tomorrow.

17/10/2017 Slides (c) 2017 Richard A. Clausi 6 Session Description:

Coding, a new player in the elementary school curriculum, offers teachers and students a new way to explore mathematics. This session is a light overview of entry‐ level programming code.org Or http://code.org

Scratch and LOGO as a way to engage and nurture mathematical thinking.

• So, let us start with code.org and the “Hour of Code” • ( that is, just tap on the code.org address, above)

17/10/2017 Slides (c) 2017 Richard A. Clausi 7 • https://studio.code.org/projects/playlab/G4by 28DEj‐Yqhe_Z06tSU1aOZU5NjeVsN4‐ EDNX7FNc/view

17/10/2017 Slides (c) 2017 Richard A. Clausi 8 • What about “Scratch”?

17/10/2017 Slides (c) 2017 Richard A. Clausi 9 • Getting‐Started‐Guide‐Scratch2.pdf

• http://scratch.mit.edu

Address: • http://scratch.mit.edu

17/10/2017 Slides (c) 2017 Richard A. Clausi 10 • Getting in the mood…..

17/10/2017 Slides (c) 2017 Richard A. Clausi 11 The Beaver Computer Contest for grades 7,8,9,10 sponsored by University of Waterloo, CEMC

http://www.cemc.uwaterloo.ca/contests/bcc.html

17/10/2017 Slides (c) 2017 Richard A. Clausi 12 Frog Jump A frog gets exercise by jumping around a pond. It jumps from lily pad to lily pad in the sequence shown in the picture below. It starts at the lily pad labelled S. It ends on the lily pad as shown (i.e., the frog shown has finished jumping). Each black dot marks a lily pad on which the frog has landed. The legend below labels each of the 8 possible directions of a jump with an integer from 0 to 7.

Which sequence describes the frog's path?

17/10/2017 Slides (c) 2017 Richard A. Clausi 13 Samplers....

http://www.cemc.uwaterloo.ca/contests/computing/bcc_sample_problems/frogjump.html

17/10/2017 Slides (c) 2017 Richard A. Clausi 14 • The thinking is “algorithmic” and “sequence” thinking… Like creating a recipe that a mindless (??) machine can follow.

• PS: This aligns nicely with the problem‐solving frame of mind we want students to acquire.

17/10/2017 Slides (c) 2017 Richard A. Clausi 15 • This session is a light overview of • entry‐level programming (code.org, scratch and LOGO) • as a way to engage and nurture mathematical thinking.

• This new tool for problem solving allows us to use simple programming to understand and apply “tough” concepts such as recursion, modularity and • multi‐tasking to ARDUINO programming and Mouse Mazes, • calculating TT, Newton’s Method for Square Roots, Fractals and Mandelbrot Set

17/10/2017 Slides (c) 2017 Richard A. Clausi 16 • http://www.alexshen.ca/maze‐bot/

This web access is courtesy of Alex Shen, a finalist in the Canadian Competition Contest Round 2, May 2017

17/10/2017 Slides (c) 2017 Richard A. Clausi 17 17/10/2017 Slides (c) 2017 Richard A. Clausi 18 • Putin reveals fears that with will one day 'eat us' and asks head of Russia's largest tech firm how soon it will happen • Russian president was speaking to Arkady Volozh, chief of internet firm Yandex • He baffled Volozh by asking how long it will be till artificial intelligence 'eats us' • Volozh said he hopes 'never' and sounded optimistic note but Putin unconvinced • Earlier this month, Putin said whoever becomes master of AI will rule the world • By Iain Burns For Mailonline • PUBLISHED: 09:12 BST, 22 September 2017 | UPDATED: 11:40 BST, 22 September 2017

• From the Daily Mail, UK • The Russian president was speaking to Arkady Volozh, chief of internet firm Yandex, during a tour at the company's Moscow HQ. It comes after Putin said whoever masters AI will rule the world. •

http://www.dailymail.co.uk/news/article‐4909172/Putin‐reveals‐fears‐robots‐one‐day‐eat‐us.html

17/10/2017 Slides (c) 2017 Richard A. Clausi 19 • Milton Bradley was cranking out the electronic toys in the late 70s and Big Trak hit the shelves in early 1979. This was the latest and most advanced toy ever released in mass to date and it was an instant hit. You could enter up to 99 commands ranging from simple movements like forward, back, turn left, turn right to more complicated things like a kind of "stealth mode" where it would delay commands, fire it's weapons or navigate an obstacle avoidance.

17/10/2017 Slides (c) 2017 Richard A. Clausi 20 Approx. 2 feet long…$60

Source: Wikipedia

17/10/2017 Slides (c) 2017 Richard A. Clausi 21 17/10/2017 Slides (c) 2017 Richard A. Clausi 22 17/10/2017 Slides (c) 2017 Richard A. Clausi 23 17/10/2017 Slides (c) 2017 Richard A. Clausi 24 17/10/2017 Slides (c) 2017 Richard A. Clausi 25 Arduino– Physical Computing

• “Tinkering is what happens when you try something you don’ quite know how to do, guided by whim, imagination and curiousity. When you tinker, there are no instructions‐ but there are also no failures, no right or wrong ways of doing things. It’s about figuring out how things work and reworking them.” (Getting Started with Arduino, Massimo Banzi, preface: vi)

17/10/2017 Slides (c) 2017 Richard A. Clausi 26 • // provided ARDUINO sample program from the downloadabe and free IDE

• /* • Blink • Turns on an LED on for one second, then off for one second, repeatedly. • • This example code is in the public domain. • */ • • // Pin 13 has an LED connected on most Arduino boards. • // give it a name: • int led = 13;

• // the setup routine runs once when you press reset: • void setup() { • // initialize the digital pin as an output. • pinMode(led, OUTPUT); • }

• // the loop routine runs over and over again forever: • void loop() { • digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) • delay(1000); // wait for a second • digitalWrite(led, LOW); // turn the LED off by making the voltage LOW • delay(1000); // wait for a second • }

17/10/2017 Slides (c) 2017 Richard A. Clausi 27 Other possibilities (to Google)…

• These are very powerful, hands‐on platforms: • Raspberry Pi

• Parallax Propeller (especially neat with 8 parallel cores running in tandem… multi‐ processing and parallel processing)

• Beaglebone Black

17/10/2017 Slides (c) 2017 Richard A. Clausi 28 • Session Description: Coding, a new player in the elementary school curriculum, offers teachers and students a new way to explore mathematics. This session is a light overview of entry‐level programming (code.org, scratch • and LOGO) • as a way to engage and nurture mathematical thinking. This new tool for problem solving allows us to use simple programming to understand and apply • “tough” concepts such as recursion, modularity and multi‐tasking • to ARDUINO programming and Mouse Mazes, calculating TT, Newton’s Method for Square Roots, Fractals and Mandelbrot Set

17/10/2017 Slides (c) 2017 Richard A. Clausi 29 17/10/2017 Slides (c) 2017 Richard A. Clausi 30 • LOGO is a philosophy of education.

• It embodies the insights of and .

17/10/2017 Slides (c) 2017 Richard A. Clausi 31 Logo from Wikipedia Papert used Piaget's work in his development of the Logo while at MIT. He created Logo as a tool to improve the way children think and solve problems. A small mobile called the "Logo Turtle" was developed, and children were shown how to use it to solve simple problems in an environment of play.

17/10/2017 Slides (c) 2017 Richard A. Clausi 32 17/10/2017 Slides (c) 2017 Richard A. Clausi 33 Jean Piaget: born 1896

• He theorized that intelligence is a form of evolutionary adaptation‐ humans adapt to their environment through strategies that he called assimilation and accommodation. • Children actively construct knowledge as they explore and manipulate the world around them.

17/10/2017 Slides (c) 2017 Richard A. Clausi 34 • Seymour Aubrey Papert (February 29, 1928 – July 31, 2016) was a South African‐born American mathematician, computer scientist, and educator, who spent most of his career teaching and researching at MIT.

• He was one of the pioneers of artificial intelligence, and of the constructionist movement in education.

• He was co‐inventor, with , of the Logo programming language.

Source: Wikipedia

17/10/2017 Slides (c) 2017 Richard A. Clausi 35 Seymour Papert (1928‐2016)

• Using computers,students can explore and assimilate/personalize their environment.

• Papert uses the image of a “Mathland” where mathematics becomes a natural vocabulary to develop Turtle Geometry: A Mathematics made for (Mindstorms: chapter 3)

17/10/2017 Slides (c) 2017 Richard A. Clausi 36 • Constructionism (learning theory) Seymour Papert From Wikipedia, the free encyclopedia

• Constructionist learning is inspired by the constructivist theory that individual learners construct mental models in order to understand the world around them.

• Papert's ideas became well known through the publication of his seminal book Mindstorms: Children, Computers, and Powerful Ideas (Basic Books, 1980).

• Papert described children creating programs in the Logo educational programming language. He likened their learning to living in a "mathland" where learning mathematical ideas is as natural as learning French while living in France.[

17/10/2017 Slides (c) 2017 Richard A. Clausi 37 • Euclid’s geometry is a logical style

• Descartes’ is an algebraic style.

• Turtle geometry is a computational style. ( from MindStorms page 55)

17/10/2017 Slides (c) 2017 Richard A. Clausi 38 • Let us look at a few examples: • NOTE: sample source code is included in the resources section of this slide set; • but, the compiled programs are not included in the package.

17/10/2017 Slides (c) 2017 Richard A. Clausi 39 • MSWLogo2\logo32.exe

17/10/2017 Slides (c) 2017 Richard A. Clausi 40 Running MSWlogo

• Running the Program: you need to download a copy of the program ‐> ie MSWLOGO • Recall The Demo: • The Square Spin, The triangle, Procedures, • Recursion, Multi‐tasking, Use of Parameters • Fractals: a shape recursively similar to itself • PS: Several versions of the LOGO program are referenced in the Resources list at the end.

17/10/2017 Slides (c) 2017 Richard A. Clausi 41 17/10/2017 Slides (c) 2017 Richard A. Clausi 42 Things to remember…. • The Essentials of Recursion: • ‐it “calls” itself or repeats itself • ‐it changes something along the way • ‐it knows when to stop

• Modules tackle each building block of the problem • Multi‐tasking means many processes are at work at once or they run in parallel

17/10/2017 Slides (c) 2017 Richard A. Clausi 43 A drawing exercise for pupils….

• Draw an equilateral triangle. • Build an equilateral triangle on the middle third of each side. • Repeat infinitely……

• What do you get…?????

Images Courtesy of Wikipedia

17/10/2017 Slides (c) 2017 Richard A. Clausi 44 17/10/2017 Slides (c) 2017 Richard A. Clausi 45 The Koch Snowflake

This is a Fractal– a shape that is self‐similar at every level.

17/10/2017 Slides (c) 2017 Richard A. Clausi 46 • A fractal is an object or quantity that displays self‐similarity, in a somewhat technical sense, on all scales.

17/10/2017 Slides (c) 2017 Richard A. Clausi 47 • A fractal is an object or quantity that displays self‐similarity, in a somewhat technical sense, on all scales. The object need not exhibit exactly the same structure at all scales, but the same "type" of structures must appear on all scales.

• The prototypical example for a fractal is the length of a coastline measured with different length rulers. The shorter the ruler, the longer the length measured, a paradox known as the coastline paradox.

17/10/2017 Slides (c) 2017 Richard A. Clausi 48 • Illustrated are the fractals known as the Gosper island, Koch snowflake, box fractal, Sierpinski sieve/gasket,Barnsley's fern, and Mandelbrot set.

17/10/2017 Slides (c) 2017 Richard A. Clausi 49 Each “ornament” is similar to the larger shape it is a part of.

17/10/2017 Slides (c) 2017 Richard A. Clausi 50 The Gosper island (Mandelbrot 1977), also known as a flowsnake (Gardner 1989, p. 41), is a fractal that is modification of the Koch snowflake. The term "Gosper island" was used by Mandelbrot (1977) because this curve bounds the space filled by the Peano‐Gosper curve.

17/10/2017 Slides (c) 2017 Richard A. Clausi 51 Worth pinning up….

• Math Mandelbrot pin‐up Calendars!!!!!

( see 1991 Fractals Calendar R.F. Voss—June)

17/10/2017 Slides (c) 2017 Richard A. Clausi 52 17/10/2017 Slides (c) 2017 Richard A. Clausi 53 17/10/2017 Slides (c) 2017 Richard A. Clausi 54 17/10/2017 Slides (c) 2017 Richard A. Clausi 55 • Code snippets are attached at the end of this slide sequence for your reference.

17/10/2017 Slides (c) 2017 Richard A. Clausi 56 • Session Description: Coding, a new player in the elementary school curriculum, offers teachers and students a new way to explore mathematics. This session is a light overview • of entry‐level programming (code.org, scratch and LOGO) as a way to engage and nurture mathematical thinking. This new tool for problem solving allows us to use simple programming to understand and apply “tough” concepts such as recursion, modularity and multi‐tasking to ARDUINO programming and Mouse Mazes, • calculating TT, • Newton’s Method for Square Roots, • Fractals and • Mandelbrot Set

17/10/2017 Slides (c) 2017 Richard A. Clausi 57 Stephan Hawking • “No matter how many times the results of experiments agree with some theory, you can never be sure that the next time the result will not contradict the theory. On the other hand, you can disprove a theory by finding even a single observation that disagrees with the predictions of the theory”* * Hawking, Stephan ,”A Brief History of Time”, Updated and Expanded Tenth Anniversary Ed. (ISBN: 0‐553‐10953‐7) page 10

17/10/2017 Slides (c) 2017 Richard A. Clausi 58 • You cannot prove a rule by example; however, you can disprove it with a counter example.

• That means that interation through many numeric examples, no matter how many, cannot “prove” anything, but it may provide an insight or starting point for investigation.

17/10/2017 Slides (c) 2017 Richard A. Clausi 59 Mathematics is our way of “touching” the Universe ‐‐ attempting to understand who “we” are! Are we Unique among the species?

Source: Wonderful World of Mathematics: Hogben, Lancelot

17/10/2017 Slides (c) 2017 Richard A. Clausi 60 Imagine the awe of looking into the sky and seeing the sun and the moon

Source: Wonderful World of Mathematics: Hogben, Lancelot 17/10/2017 Slides (c) 2017 Richard A. Clausi 61 • This book is out of print, dated 1957, but it is still a great way to appreciate the development of Mathematics to the twentieth century… Ideal for elementary students…Get it here… accurate to 1957!!!!!!!

• Wonderful World of Mathematics: Hogben, Lancelot. Read online or purchase (62 pages) https: //www.scribd.com/doc/249657660/Lancelot‐Hogben‐The‐Wonderful‐World‐of‐ Mathematics‐1955

• Also consider this related great resource: Mathematics for the Million by Lancelot Hogben for a more advanced examination of Mathematics from its’ beginnings to the (almost) present. This is appropriate to secondary school and beyond.

17/10/2017 Slides (c) 2017 Richard A. Clausi 62 • And recording “stuff” by counting … with stones, sticks, a counting stick with notches, a number line….

• PS: the number line is a “model” for the continuity of numbers and is meant to be a visual representation… it does not “exist” and it has gaps and inconsistencies in it.. • Perhaps, we are on the wrong track???

17/10/2017 Slides (c) 2017 Richard A. Clausi 63 Progress is driven by curiousity

Source: Wonderful World of Mathematics: Hogben, Lancelot 17/10/2017 Slides (c) 2017 Richard A. Clausi 64 Where is the zero…?

17/10/2017 Slides (c) 2017 Richard A. Clausi 65 Enigma Encryption Machine Lorentz Encryption Machine

Source: Wikipedia

17/10/2017 Slides (c) 2017 Richard A. Clausi 66 • Programming arithmetic to explore and gain insights…….

17/10/2017 Slides (c) 2017 Richard A. Clausi 67 • Calculation of TT using …..

17/10/2017 Slides (c) 2017 Richard A. Clausi 68 • PIE.exe

17/10/2017 Slides (c) 2017 Richard A. Clausi 69 “Numeric Fractals” by Iteration….

2 x = 2 x

17/10/2017 Slides (c) 2017 Richard A. Clausi 70 • Newton’s Method for the calculation of Square Roots

17/10/2017 Slides (c) 2017 Richard A. Clausi 71 17/10/2017 Slides (c) 2017 Richard A. Clausi 72 Running newton.bas under Watcom Basic (wbas) that is, back to 1984….

• DOS\DOSBox‐0.74\DOSBox.exe

Under this “DOS” emulator, you need to Mount c: g:\dos C: Cd dos Wbas newton.bas

17/10/2017 Slides (c) 2017 Richard A. Clausi 73 • Here is a bare‐bones version of the Newton program written for Watcom Basic. Surprisingly, it even converges to the correct answer if you guess ZERO as your bad guess for the square root of 25

10 input "your number ", sq 20 input "your first bad guess ",g 30 35 loop 40 newguess = .5 *( sq / g + g ) 45 print newguess 50 if (newguess = g ) then stop 55 g = newguess 60 endloop

17/10/2017 Slides (c) 2017 Richard A. Clausi 74 • How about

• 2 • X + 1 = 0

• Or……..

17/10/2017 Slides (c) 2017 Richard A. Clausi 75 ..on an imaginery grid with coordinates (x,y)

• The Argand Plane with a Real Axis (x) and an Imaginery Axis (y)

17/10/2017 Slides (c) 2017 Richard A. Clausi 76 • Can we add, subtract and multiply complex numbers…… • ‐collect like terms ? • ‐just use F O I L ?

17/10/2017 Slides (c) 2017 Richard A. Clausi 77 • Let’s check in on our running mandel3.bas and, look, it is still working hard and slow!!

17/10/2017 Slides (c) 2017 Richard A. Clausi 78 Executing mandel1.c

• See Sample program mandel1.c

• Input coordinates (‐2, 2) ;that is, The complex number, ‐2 + 2 I

P.S. for coders‐ you will have to add your own video calls to plot the point in the sample code

17/10/2017 Slides (c) 2017 Richard A. Clausi 79 This program is compiled in C++

• mandelcpp.exe A challenge: Translate it to LOGO

• The key elements in the calculation are:

• 2 2 X ‐ Z 2 2 And 2 X Y giving coordinates (x –z, 2xy) A keen student could program this into LOGO! PS: Research continues on the Mandelbrot Set

17/10/2017 Slides (c) 2017 Richard A. Clausi 81 • FIRST, a reminder of what we have looked at today…….

• Title: Coding, For the Love of Mathematics • Slides for this talk and with additional pages of reference resources are at: http://www.kw.igs.net/~raclausi/coding.pdf

Session Description: Coding, a new player in the elementary school curriculum, offers teachers and students a new way to explore mathematics. This session is a light overview of entry‐level programming (code.org, scratch and LOGO) as a way to engage and nurture mathematical thinking. This new tool for problem solving allows us to use simple programming to understand and apply “tough” concepts such as recursion, modularity and multi‐tasking to ARDUINO programming and Mouse Mazes, calculating TT, Newton’s Method for Square Roots, Fractals and Mandelbrot Set.

• I hope that you will leave with inspiration and ideas that you can use to explore your own personal mathematical adventures • Now…. Here are references and acknowledgements…….

17/10/2017 Slides (c) 2017 Richard A. Clausi 82 Acknowledgements and Resources

17/10/2017 Slides (c) 2017 Richard A. Clausi 83 LOGO and Seymour Papert

• The Children's Machine: Rethinking School In The Age Of The Computer Paperback –Seymour Papert Apr 29 1994 A recommended reference for TECs • • Mindstorms: Children, Computers, And Powerful Ideas Paperback –Aug 4 1993 by Seymour A. Papert A recommended reference for TECs

• Access MSWlogo for Windows at: http://mswlogo.en.softonic.com/ • Here is a link to download xLOGO for Mac users in the class who can't run MSWlogo: • https://sourceforge.net/projects/xlogo/?source=typ_redirect

17/10/2017 Slides (c) 2017 Richard A. Clausi 84 Another version of LOGO

• For more information on Berkeley LOGO go to WIKIPEDIA and look at UCBlogo • Or • Google “Berkeley Logo commands” and watch the videos

17/10/2017 Slides (c) 2017 Richard A. Clausi 85 • UCBLogo, also known as Berkeley Logo, is closest to a de facto • standard Logo programming language with its facilities for handling • lists, files, I/O, and recursion in scripts,[2] and can be used to teach • most concepts, as UC Berkeley lecturer Brian • Harvey did in his Computer Science Logo Style trilogy.[3] For tertiary • level teaching, however, Logo has been superseded by Scheme, and • scripting languages.

• GUI • UCBLogo has only a rudimentary graphical user interface, so several • projects exist that provide a better interface. MSWLogo and its • successor FMSLogo, for , are commonly used in • schools in the United Kingdom and Australia

17/10/2017 Slides (c) 2017 Richard A. Clausi 86 • // originally from pp550 of The Waite Group's Microsoft C NOTE: video calls are for older DOS C units and so may not compile under C++ • // programming for the PC ISBN 0‐672‐22738‐X • // by Robert Lafore (SAMS publishing) /* mandel.c */ • /* generates the mandelbrot set */ • #include Sample C Code for WATCOM 10.0 • #define XMAX 1000 • #define YMAX 1000 • #define MAXCOUNT 16 • main () • { • int x, y; float xscale, yscale; float left, top; float xside, yside; float zx, zy; float cx, cy; float tempx; int count;

• left = ‐2.0; printf("\n type in the left value \n"); scanf("%f",&left);

printf("\n type in the top value \n"); scanf("%f",&top);

• xside = 20.0; yside = ‐20.0; xscale = xside / XMAX; yscale = yside / YMAX; • if(_setvideomode(_ERESCOLOR)==0) { printf ("can't set mode"); exit(1); } • _rectangle(_GBORDER, 0, 0, XMAX+1, YMAX+1);

• for(y=1; y<=YMAX; y++) • { • for(x=1; x<=XMAX; x++) • { • cx = x*xscale+left; cy = y*yscale+top; zx = zy = 0; count = 0;

• while( zx*zx ‐ zy*zy<4 && count

17/10/2017 Slides (c) 2017 Richard A. Clausi 87 • 10 REM Mandelbrot Program IN QBASIC…. • 20 SIDE = 3 • 30 ACORNER = ‐2 • 40 BCORNER = 2 • 60 REM INITIALIZE THE SCREEN • 70 SCREEN 1 • 80 COLOR 0, 0 • 100 DELTAY = SIDE / 200 • 110 DELTAX = SIDE / 240 This program is written for Qbasic. While it may • 120 REM SCANNING ROUTINE • 130 FOR M = 1 TO 200 not run on your computer, the code is easy • 140 FOR N = 1 TO 320 • 150 AC = (N * DELTAX) + ACORNER enough to follow so you can adapt it to your • 160 BC = ‐(M * DELTAY) + BCORNER • 170 COUNT = ‐1 machine or language. • 180 WHILE SIZESQ < 4 AND COUNT < 100 • 190 AX = AZ ^ 2 ‐ BZ ^ 2 + AC • 200 BX = 2 * AZ * BZ + BC • 210 AZ = AX • 220 BZ = BX • 230 REM FINDS Z^2 • 240 SIZESQ = AX ^ 2 + BX ^ 2 • 250 COUNT = COUNT + 1 • 260 WEND • 280 REM ASSIGN COLOR CYCLE • 290 IF COUNT < 64 THEN V = 0 • 300 IF COUNT < 32 THEN V = 1 • 310 IF COUNT < 16 THEN V = 2 • 320 IF COUNT < 8 THEN V = 3 • 330 IF COUNT < 4 THEN V = 4 • 340 IF COUNT < 3 THEN V = 1 • 350 IF COUNT < 2 THEN V = 2 • 360 IF COUNT = 1 THEN V = 3 • 390 IF SIZESQ >= 4 THEN PSET (N, M), V • 400 AZ = 0 • 410 BZ = 0 • 420 ZZ$ = INKEY$ • 430 REM CHECK FOR THE QUIT SIGNAL • 440 IF ZZ$ = "Q$" OR ZZ$ = "q" THEN END • 460 AC = 0 • 470 BC = 0 • 480 SIZESQ = 0 • 490 NEXT • 500 NEXT • 510 REM THE PLOT IS FINISHED • 520 LOCATE 1, 1, 1 • 530 END

17/10/2017 Slides (c) 2017 Richard A. Clausi 88 • // CALCULATION OF TT USING TT/4 = 1‐1/3+1/5‐1/7+1/9 … using C++ • #include • #include • #include • #include

• double TT,n,p,sub,term;

• main() Here is a TT program with a delay in the • { loop so you can watch the values as they struggle to emerge. • long int tim=0; Note: each additional fraction is so small • n=1.0; as to not affect earlier digits, and it takes • p= 1.0; • TT=0; 10 times as much effort to stabilize each • sub=0.0; succeeding decimal place. COOL! • term=1/n; • // generate each term and put it in the subtotal x 4 • while (1) • { • sub = sub + (1.0/n)*p; • TT=4*(sub); • printf("\n RC: shhhhh I am calculating TT= %19.16f using Gregory's method.",TT); • // update sign and denominators • p=p*(‐1); n+=2; • // Slow down the display by counting to 2 million • while(tim++ <20000000); tim=0; • };

• }

17/10/2017 Slides (c) 2017 Richard A. Clausi 89 • LOGO SNIPPETS of CODE: 01square.lgo will draw a square with sides that grow and rotate • • to aaa • ! this is a test • end • ======Here are samples of LOGO code that • to square :side you can use to build your own • repeat 4 [fd :side rt 90] program and explore. • • rt 10 • if :side > 500 [stop] • square :side + 1 • end • • 02triang.lgo will draw a triangle with side angle a twist and an ang3 • • to triangular :side :angle :twist :ang3 • • ht • cs • fd :side • rt 180 ‐ :angle • • fd :side • rt 180 ‐ :twist • • fd :side • • end •

17/10/2017 Slides (c) 2017 Richard A. Clausi 90 • 03spiral.lgo with do a spiral • • to spiral :num :side :angle :twist :count • repeat :num [fd :side rt :angle] • rt :twist • if :count >100 [stop] • spiral :num :side :angle :twist :count + 1 • • end • • 06recur01.lgo will demonstrate recursion • to recur :side • repeat 4[fd :side rt 90] • rt 2 • recur :side + 1 • • end • • • 08recustop • to pass2 :side :angle • ht • repeat 4 [fd :side rt :angle] • repeat 10000[ rt 360] • if :side >100 [stop] • pass2 :side + 10 :angle • end • • to passage :side :angle • ht • repeat 4 [fd :side rt :angle] • repeat 10000[ rt 360] • passage :side + 10 :angle • end

17/10/2017 Slides (c) 2017 Richard A. Clausi 91 • 10waiter01.lgo will demonstrate multitask • • to aa • ; set resolution to zoom out • ; run waiter to see multitasks • end • • to multitask • • setturtle 1 • setpc 3 • fd 100 • • setturtle 2 • setpc 5 • fd 50 • • setturtle 3 • setpc 6 • fd 60 • • setturtle 1 • rt 90 • • setturtle 2 • rt 120 • • setturtle 3 • rt 60 • • setturtle 1 • rt 2 • • setturtle 2 • rt 5 • • setturtle 3 • rt 10 • • slowmedown • multitask • end 17/10/2017 Slides (c) 2017 Richard A. Clausi 92 • to slowmedown • repeat 5000 [st ht] • end • • to waiter • cs • setturtle 1 • setpc 3 • pu • fd 100 • pd • ht • • setturtle 2 • setpc 5 • pu • bk 100 • pd • ht • • setturtle 3 • setpc 6 • pu • bk 100 • rt 90 • fd 100 • pd • ht • • • multitask • end

17/10/2017 Slides (c) 2017 Richard A. Clausi 93 • 12sierpi.lgo demonstrates the sierpinski……………………….. • • to push • ; try push followed by • ; sierpinski 25 then 50, 100, 200 800 • cs • pu • bk 300 • rt 90 • bk 400 • lt 90 • pd • end • • to sierpinski :size • if :size < 10 [stop] • repeat 3 [ sierpinski :size / 2 • fd :size • rt 120 • ] • End • • • 14sieslow.lgo • • to push • ; try push followed by • ; sierpinski 25 then 50, 100, 200 800 • cs • pu • bk 300 • rt 90 • bk 400 • lt 90 • pd • end • • to sierpinski :size • if :size < 10 [stop] • repeat 3 [ sierpinski :size / 2 • fd :size • rt 120 • • repeat 1000 [st ht ] • ] • End

17/10/2017 Slides (c) 2017 Richard A. Clausi 94 • 16face01.lgo DRAW a face to demonstrate modules • • to aface • head • eyes • nose • mouth • cigar • end • • to cigar • pu • bk 20 • rt 90 • fd 20 • rt 90 • pd • fd 30 • lt 90 • fd 20 • lt 90 • fd 30 • bk 20 • lt 90 • fd 20 • end • • to eyes • ETC. To complete the eyes, nose, mouth etc.

17/10/2017 Slides (c) 2017 Richard A. Clausi 95 • 20arith01.lgo demonstrates arithmetic • • to assign • Make "foo [hello] LOGO is built on other powerful languages • show :foo such as LISP. LOGO can do arithmetic and list • make "x 3+4*2 processing as well as graphics. FUN!!!! • show :x • • end • • to darith :x :y • repeat 4 [ make "x :x + :y] • show :x • end

17/10/2017 Slides (c) 2017 Richard A. Clausi 96 • "Education provides one of the greatest hopes for repairing cultural attitudes, redressing the legacy of Indian Residential Schools, and advancing the process of reconciliation." – Senator Murray Sinclair, Chair of the Truth and Reconciliation Commission of Canada

• ”Those who do not remember history are condemned to repeat it”‐George Santayama, American Philosopher and Poet

17/10/2017 Slides (c) 2017 Richard A. Clausi 97 • Session 3 • Title: Coding, For the Love of Mathematics • Slides for this talk and with additional pages of reference resources are at: http://www.kw.igs.net/~raclausi/coding.pdf

Session Description: Coding, a new player in the elementary school curriculum, offers teachers and students a new way to explore mathematics. This session is a light overview of entry‐level programming (code.org, scratch and LOGO) as a way to engage and nurture mathematical thinking. This new tool for problem solving allows us to use simple programming to understand and apply “tough” concepts such as recursion, modularity and multi‐tasking to ARDUINO programming and Mouse Mazes, calculating TT, Newton’s Method for Square Roots, Fractals and Mandelbrot Set.

• I hope that you will leave with inspiration and ideas that you can use to explore your own personal mathematical adventures.

• ** This slide is the last slide in my presentation so you can copy down the web address. The Additional slides in my web site contain additional Resource slides.

17/10/2017 Slides (c) 2017 Richard A. Clausi 98