PiWords (Magic Squares in Pi)

Tags

, ,

A “PiWord” is a sort of crossword puzzle/magic square where you can find the across and down digits in the digits of Pi. Because Pi is transcendental, if you go out long enough you’ll be able to find any number you like, so you can obviously create a PiWord that is as large as you like and containing any numbers you like.

But if you constrain the number of digits of Pi you’re allowed to explore, it get’s a LOT harder.¬†For example, here’s one that is entirely within the first 1000 digits of Pi:

Screen Shot 2019-10-11 at 9.34.10 AM

The numbers along the right and left are the locations in Pi where each of these across or down 4-digit sequence is found (where the leading 3 is at location 1).

There are many non-trivial (i.e., not repeating the same sequence) 4×4 PiWords within the first 1000 digits.

If you go down to a 3×3 PiWord you can find 2 within the first 50 digits of Pi.

Here’s one:

Screen Shot 2019-10-11 at 9.43.00 AM

I’ll leave it as a challenge to the reader to find the other! (Hint: It uses some, but not all of the same 3-digit sequences as above.)

(Note: Of course, every PiWord solution has another using the same numbers just flipped across the main diagonal. That’s obviously cheating, and doesn’t count as a separate solution!)

Another interesting challenge is to write the program needed to find these. Finding 3×3 PiWords in the first handful of digits, like the challenge just above, can be (barely) done by inspection, but anything larger pretty much requires a computer! (I, of course, wrote a version to get the 4×4 above. I would share it with you…but where’s the fun in that!? ūüôā )



 

I Like Math (a poem)

Tags

,

(Leo had to write an essay introducing himself to his math teacher. We were reading “The Friendly Book”, by Margaret Wise Brown, to Ada, and got the idea to do a math poem in that style. Leo mostly wrote this himself, although I made some suggestions about rhyming and meter.)

I Like Math
   By Leo Armel
       (In the style of Margaret Wise Brown)

I like math

I like numbers
Big numbers
Little numbers
Rational and irrational numbers
Negative and positive numbers
Simple and complex numbers
Integers and reals
I like numbers

I like Pi
2pi
Root pi
e to the i pi
Pi r squared
Blueberry pie
I like pi

I like logs
Log base 2
Log base 3
Log base 10
Log base e
I like logs

I like shapes
Circles, squares and right triangles
1D 2D 3D shapes
Regular and irregular shapes
Fractals and monster shapes
Concave and convex shapes
I like shapes

I like graphs
Line graphs
Bar charts
Pie charts
Error bars
I like graphs

I like operators
Plus minus times divide
Roots and powers
Integrals and derivatives
Factorials and combinations
I like operators

I like functions
Linear functions
Exponential functions
Quadratic functions
Trig functions
I like functions

I like angles
Acute angles
Right angles
Obtuse angles
Straight angles
Reflex angles
I like angles

I like calculators
Programmable calculators
Graphing calculators
Wolfram Alpha and online calculators
Human brains
I like calculators

I like math



 

Physics Camp

Tags

, ,

After the moderately positive experience of Chem Camp, we decided to do a somewhat more abbreviated home Physics Camp, with Leo’s same friend, Connor in the two days before school started this week.

This didn’t go nearly as well as Chem Camp, mostly, I think, because Leo and Connor were significantly more distracted by one another, and so much less on task, mostly spinning off into MineCraft micro-conversations. (For some reason that I just don’t get at all, Minecrafters, and esp. Leo, are fascinated by the version history of MineCraft — what features/bugs got added/fixed in each version. Leo watches videos about this all the time, and for some reason loves bringing up old versions and re-living the bugs. Speaking as someone who spends a very large amount of my time squashing bugs in complex programs, intentionally reliving old bugs is about the farthest thing from fun that I can think of, short of self-inflicted physical pain! This said, Leo has learned a great deal about common causes of bugs from this fascination, esp. regarding floating point arithmetic problems.)

So, Physics camp included these topics:

  • Gyroscopic phenomena (via¬†this terrific gyroscope kit)
  • Sound waves (via an electronic keyboard and oscilloscopic iPad app)
  • Minimal bubble surfaces (using shapes created with zoomtool; pic below)
  • Energy transfer (via Rube Goldberg Machines)
  • Dynamics (via normal and chaotic [double] pendula; pic below)
  • Optics (via lasers and lenses)
  • Work and Mechanical Advantage (via complex pulley arrangements)
  • Magnetic fields (via strong microwave oven magnets; pic below)
  • Electricity and magnetism (moving magnets creating current and v.v.)

I regret that I didn’t get to much formal computations, and also that I didn’t take as many pictures as I should have, but here are a few:

Building, and then running, the chaotic pendulum:

A great “hypercube” minimal bubble in a cube:

IMG_1692

Best invention of the week was microwave magnets on a PVC pipe separated by electrical tape:

IMG_1751

(Trying to demonstrate the Left Hand Rule for electromagnetism on our high power magnet apparatus.)

The tape and pipe keep the magnets from snapping together and breaking, or pinching fingers!



 

PyCraft Alpha 1.4.0_01

Tags

, , , ,

I think python camp ended up being pretty educational, even if we didn’t meet all of our goals. The curses version of Leo’s MineCraft-In-Python (aka. PythonCraft) actually ended up pretty well, and we did some actual pretty interesting algorithm coding, and even a little computational complexity. Unfortunately, we wasted pretty much a whole day trying to translate the game into pygame, which would have provided way better graphics. But that ended up being beyond Leo’s capabilities, and although I could have done it for him, that would have defeated the purpose, so we just fell back to the curses version.

Previous version (Alpha 1.3) had the basic world and player, and some pretty good terrain generation, and at some point we added survival mode as well. 1.4 introduced water and npcs (mobs, in Minecraft parlance). Each of these actually involved interesting new algorithm design. In the case of water, the blocks had to “flow”, so that would fill space “gravitationally”. How to do this is actually non-trivial, but after lots of experimenting we more-or-less got it to work. Here’s an image of how water ends up¬† sort of filling a valley. The waters are = signs, and the player is the *. All the water blocks in the valley were originally dropped in the same column, but moved to fill the valley. Notice that there’s room for improvement in the algorithm as it made a sort of pyramid:

Screen Shot 2019-08-16 at 2.06.18 PM

Mobs were also very interesting. Leo invented a nice mob placement algorithm so that the would end up mostly in caves (although sometimes on the surface as well), and then we did a nice mob movement algorithm that would make them move toward the player. Of course, there were failures along the way to this as well. Some shots of the results of various “approximations” (aka. major bugs! :-):

 

 

But the thing did work out in the end (here the player is being chased through the air by 2 zombies and a creeper — yeah, they can fly … minor bug!):

Screen Shot 2019-08-18 at 3.56.22 PM

As before, all the code is in the github repo.


2019-10-11: After much thought, we improved the water flow algorithm in a rather simple way, which ended up greatly improving it. Now water not only tries to flow downward, which is what was causing the pyramids, but also randomly left- or rightward, so that it’s always in a sort of random walk, eventually finding its lowest possible level. As you can see, this has greatly improved things; the water now seeks the lowest space and spreads out, filling space at the bottom, just as normal water does:

Screen Shot 2019-10-11 at 10.06.30 PM

This still lacks a bit of reality, in that it won’t hydraulically flow upward through a hole, as there’s no actual water pressure. But at least it doesn’t create weird waster pyramids!


 

Pycraft Alpha 1.3.0

Tags

, , , , , , ,

We ran out of camps this summer, so I decided to keep Leo home this week and do intensive programming “camp” (sort of like Chem Camp, but just with Leo.)¬† Also, I’m finally making good on my theory that kids should only be allowed to play computer games that they program themselves.

The rest of this post (with the exception of the * footnote and related content), is Leo’s own words:

Pycraft is a project I (Leo) have been working on with daddy. We started this about 2 weeks ago and it has gone very well! Here is a link to the github repo(*) with the code. Feel free to post issues, it would be useful! Known issues: If you click while moving it crashes, and you can erase the text at the top.

What I learned so far: Python programming, git-based version control(*), curses based graphics(*).

Coolest hack: Pythagorean theorem distance calculations(*)

Next steps: Survival, and eventually going to more sophisticated graphics(*), probably via pygame. 

Here’s a screenshot:

Screen Shot 2019-08-13 at 4.36.32 PM


(* Indicates were I (daddy) had to provide the correct name for something, so this is my (daddy’s) words, not Leo’s)


 

Saint-Saens, Python*, Bach

Tags

, , ,

Leo and I have started into some fairly concentrated programming practice. We’ve done some light programming before, but it’s time to get into it for real.

Because you only have a kid’s attention for a few minutes at a time, you need to take maximum advantage of that obvious truism of learning:¬†practice makes perfect (“How do you get to Carnegie Hall? Practice practice practice”, “The power law of practice”, etc.)

When Leo plays piano, he does a few a warmup exercises. (A better way to say this might be: “…I make him do a few warmup exercise.”) His go-to pieces for warm up are Saint-Saen’s Danse Macabre and Bach’s “Little Fugue” in G-minor.

He also does (…I also make him…) do a couple of programming warmups, specifically, factorial written iteratively, and recursively.

(The actual program we’re working on is a learning version of the animals game,¬†which is nicely recursive. I’ve blogged about this before, but this time Leo is writing all the code.)

It dawned on me this morning — during a discussion of how stack overflow differs from numerical overflow — that there is a beautiful, if accidental, alignment between his piano practice and his programming practice. To wit, the central motif of the Danse Macabre is the rapidly played dance theme, which is very repetitive. On the other hand, The Little Fugue is more complex and, as described in great detail by Douglas Hofstadter, in Godel Escher Bach, is fundamentally recursive (or more generally, self-referential, where recursion is a particular version of self-reference.)


* I hate python; Unfortunately, it’s more useful than Lisp, these days, and we do a little Lisp too, when the moment affords.


 

Conning the Con Men

Tags

While doing something more-or-less mindless the other day I got a call from one of those scams that tries to sell you, or refund you some kind of computer services. They claimed to be from Microsoft or Dell, I think.

Because the thing I was doing was pretty boring, I decided I would endeavor to keep the scammer on the phone as long as possible, as I feel that it’s my moral obligation to save other people who might not realize these are scams from them, even if just for a while.

This turned out to be quite fun and took extensive improvisational creativity.

The first thing he tried to get me to do is to open a desktop sharing application, which I obviously was not going to do, but I let him give me the URL anyway. He was reading from a script and carefully said (in paraphrase): “Type in w- w- w- dot- T- as in tomato, H- as in the house, etc.” (I’m changing all the URLs so as not to accidentally point you, dear reader, to anything bad — and I don’t actually remember them.) Of course I wasn’t typing in anything anywhere, but I diligently repeated back everything, but then told him that I was getting “no server found” errors.

He asked me to repeat back what I had typed in (I hadn’t!), so I repeated it exactly: “w- w- w- dot- T- as in tomato, H- as in the house,…” After several minutes of his trying to talk me through fruitless debugging I tried to give him a hint by asking whether “tomato” had an “e” in or not, because I might have spelled it incorrectly. It took my repeating this question a couple of time before he got that I had typed in (or pretended to type in) “www.tasintomatohasinhouse…” ūüôā

Of course, he angrily corrected me on this, and we started again. And at about 15 minutes in, he realized (after my dropping multiple hints) that I was also (supposedly) actually typing out “d-o-t” instead of using a period!

Fun!

Having got all that figured, I was still getting “no sever found” errors (or so I claimed), and he finally devolved to asking me whether my internet was working.

“I don’t have internet,” I replied.
He was incredulous. “You don’t have internet, then how were you going to use our service?!” (or something to that effect)
“You asked me to open the web browser. I’ve never used it before.”

At this point, maybe 20 minutes of time saved from other poor souls, the call devolved into absurdity, as he first tried to talk me into turning on my internet (“But I don’t have internet at all.”) and then, amazingly — I guess not wanting to drop one of the only hot leads he probably ever had — he tried to talk me into going to a store and paying $500 for an LTE internet card to get internet so that he could continue the scam! “But why would I want internet?” .. and so no.

Okay, okay, so he gave up on the internet, and simply tried to talk me into going to a store and buying him a $500 Google Play gift certificate and he’d call back and I’d give him the number. (Yeah, right!)

It took a bit more creativity to get out of this. (Note that we’re up to at least 1/2 hour of saving other people from this scam!)

Me: “Okay, I can get that in about 2 weeks.”
Him: “2 weeks, how could it take 2 weeks?!”
Me: “I live in the middle of nowhere, I get to a store where I could do that about every couple weeks.”
Him: “You don’t have a gas station, or something nearby? Give me your zip code I’ll look where you can go.”
Me: “Okay, hold on, I have to look it up online.”
Him: “Okay” (Note that it didn’t occur to him that my looking this up online means that have internet! Nor was it enough of a clue for him that I don’t know my own zip code! What I was really doing was mapping some random zip code in the middle of Nevada.)
Me: “Okay, here it is….”
Him: “Okay, so do you know where <some random town> is?”
Me: “Sure (I don’t!), but it’s 100 miles away, so I get there about every two weeks.”
Him: “It takes you two weeks to go 100 miles? Why don’t you just go and come back later today and I’ll call you back.” (He was really pushing hard at this point!)
Me: “The¬†tractor¬†only goes 10 miles per hour, so it takes all day just to get there.”
Him: “Tractor?! What do you do?”

We’re up to, like 45 minutes now, and I’m getting so tired carrying on with the “Yes, and…” improv anti-scam bit that at this point I made a critical error, and, as they say in the con game, “cracked out of turn” What I should have said was something like: “I’m a miner.” (or a farmer), but I blew it:

Me: “I’m a computer scientist.”
Him: …. long silence …. then (screaming at me): “You are trying to waste my time!”
And he hung up on me.

But I feel like I saved some other poor sucker from being scammed…probably more than one, and it was fun!


(Ps. Bizarrely, he, or someone else from his “office”, called me back several days later and tried the same con. The reason I know it’s the same office is that at some point I gave a false name to the first caller, and the person who called me back used that same false name. They must not be very good at notating which phone numbers are cold leads. This time I just hung up on him.)


 

Chem Camp

Tags

, , , ,

Carrie and I decided (beyond all reason!) to run a home-spun chemistry camp for Leo and one of his MineCrafting school friends, Connor. We decided to do this because Leo is in this difficult age where all the camps we can find are either too old for him or too young for him. And also because I like playing with chemicals; I had a home lab when I was in high school that had (beyond all reason!) all sorts of scary stuff, some of which you can’t even get now, including all three concentrated acids (Nitric, Sulfuric, and Hydrochloric), and a pound of metallic sodium!!

The camp went for three days, over the short 4th of July week. Each day was approximately dedicated to a different topic: Day 1 was approximately simple reactions and acids and bases, day 2 was polymers, and day 3 was energy. We had planned many experiments (realizing that we weren’t going to get to all of them), and the boys kept a lab notebook (of sorts).

By the way, Ada was out of day care this week too, and participated quite a bit, as you’ll see!

Here’s an approximate list of what we did, and some commentary about what worked and what didn’t. A bunch of pictures follow, and at the end I’ve listed experiments that we planned but never got around to for one reason or another. Carrie and I shared leading the experiments.

Day 1: Basic Chemistry:

  • Safety First: 1. Never eat anything; 2. Always wear safety goggles!
  • Properties of matter: Figure out which white powder is sugar and which is salt (without tasting them — see safety rule #1 above!); This worked quite well; we looked at the crystal structure under the microscope, dissolved them, burned them (or tried — salt melts at something like 1500C!), and observed how they changed the conductivity of water.
  • Carrie showed crystal structures, including minerals and rock candy. (The rock candy was a hit with Connor and Ada!)
  • Carrie also led a series of experiments on yeast production of CO2 that worked well, including varying the amount of sugar and temperature of the water.
  • I then did a demo of the difference between CO2 and O2 production from yeast (and other sources — tried to use the yeast-produced CO2, but didn’t work, so devolved to good old baking soda and vinegar!). This is led to our discussion of reactions and catalysis, showing the NaOH+Acetic Acid<->NaAc + H2O + CO2 [we didn’t end up balancing the equations, although I had intended to!], vs. H2O2 + Yeast -> O2 via catalase.
  • Finally we extracted the indicator from red cabbage and explored acids and bases, comparing (I would like to say “calibrating”, but we didn’t get too detailed about it!) the cabbage-based indicator against PH paper.
  • At the end of each day, Leo and Connor worked with the Education Edition of MineCraft, which has a chemistry mode. They supposedly built a laboratory, although mostly they just played MineCraft with one another — which is fine.

Day 2: Polymers

  • Slime the good old fashioned way, via Elmer’s glue (vinyl acetate) cross-linked by borax. (One of the important distinctions about this Chem Camp is that in addition to doing the experiments, we study the molecular structures and reaction equations. This is particularly interesting in the case of polymerization reactions.)
  • Carrie found a cool experiment where you put a certain sort of potato chip bag (Sunchips) in the microwave for just a couple seconds and it shrivels up due to the polymer being woven with metal; The microwave heats it, and causes the polymer to basically collapse.
  • Next we did the classic strawberry DNA extraction. (DNA being a polymer! Polymers also come back later in comparing cell membranes to bubbles.)
  • By far the most successful experiment was Carrie’s muffin baking series where they varied the amount of baking soda, baking powder, yeast, and sugar in a series of muffins. (This actually only has slightly to do with polymers — gluten a bit — more like a continuation of Day 1’s experiments with yeast, acids, and bases.) The muffins all came out, and were mostly edible, and it was completely clear that there were huge differences in rising and taste. (Ada, by the way, had great fun covering herself, Carrie, and the entire kitchen, with batter; See pics below!)
  • The rest of the day (up to the required MineCraft “work”) was spent making bubbles with dry ice. I had intended to actually do experiments on the amount of soap vs. various additives, esp. mineral oil, glycerol, and PEG (see below), and we did do a bit of this. Similarly, I had intended the polymer conceptual thread to run through the whole day — from basic polymers, to DNA, and finally to comparing “air” bubbles and “water” bubbles, in the form of cells (which we lysed earlier to get at the DNA). We did do a bit of discussion around this, but mostly the afternoon was bubble madness. (Shout out to my friend Edward Spiegel, moderator of the fandom Soap Bubble Wiki for guidance here!)

Day 3: Energy (this is the day we blow things up!)

  • We started out with a hold-over from yesterday’s polymer day. I ordered some J-Lube, which is high molecular weight PEG, so we played with that a bit, which was very icky (in a fun way), and it self-siphons, which is really mind-blowing!
  • Then to the topic of the day: Chemical Energy! I had a brain storm to explain reaction energy profiles (coordinate diagrams) using block towers: Build a tall stable structure, and then put in a little energy to knock them down and get back all that potential energy in the form of (mostly) noise! This was fun, but I don’t think they got the point.
  • Next we started burning things: Matches then magnesium then potassium permanganate and glycerine reactions. The idea was to demonstrate that when you cross the activation energy barrier, all hell breaks lose…and I think that they got that, after seeing ten incarnations. Also I wanted to demonstrate lots of examples of chemical potential energy. (I wanted to do the Sodium Acetate “warm ice” experiment, but I lost my pre-made sodium acetate hand warmers, and I know from experience that it’s very difficult to make these from a baking soda and vinegar reaction — it just never quite works out!)
  • We used infrared thermometers on various things, esp. the stove coils, and observed that at about 1000dF the coil starts visibly glowing. The boys liked that! (I had intended to get into the physics of black body radiation here, and then derive the Schrodinger equation…but we didn’t get that far … yes, I’m kidding!)
  • Carrie showed how ‘flavors’ in gums, candies, and other foods are created – in the case of gum, from sugar, citric acid (for a bit of zing), and esters to add smell. Everyone held their noses while they chewed the gum and could barely tell differences between the different gum flavors (except the fruit ones had citric acid and mint didn’t), but they were much closer to guessing once they uncovered their noses (still some ambiguity in which type of berry, but they correctly distinguished berry from orange and from mint gum flavors). The kids also noticed after uncovering their eyes at the end that the gum color helped provide a clue or ‘prime’ people as to the flavor.
  • Carrie also did a whole series over lunch on color, which sort of fit with a light and color theme. (I had purchased some high density diffraction grating paper with the idea that we would look at a lot of different examples and compare the spectral lines, but this didn’t work out too well. Everything pretty much just looked like a rainbow because there was too much ambient light.) Anyway, they prepared paints from fruits and veggies, and did some art with them, and Carrie tried to do some paper chromatography, which was supposed to go with my optical chromatography, but the paper chromatography was about as successful as the optical was. (Basically the red paint came out red on the paper, and the green came out green. I don’t think that these plant-based dyes are a mixture of colors as much as artificial colors, like pen ink, are.)
  • The last thing we did was chemiluminescence, using light sticks. I had intended to actually do this manually (that is, to use luminol, and mix it with H2O2 or chlorox) but it seemed un-necessary, given that I had a bunch of light sticks, and they do the same thing. I also had some really cool birthday candles that actually burn in colors; again, the idea was to get into atomic (or at least elemental) spectra, but again we didn’t get around to getting down to that level of detail.
  • The day ended in a water fight in the front yard, and, of course, the required MineCrafting.

We survived, although I’m somewhat surprised that things went as well as they did. I learned that 10-year-old-boys are … well, a major handful! I guess I kinda knew that from how difficult it is to get Leo to focus for more than 30 seconds on anything that isn’t what he happens to want to focus on (which is usually MineCraft!), but it was sort of shocking how it seemed like Ada had the most attention span of anyone in the room! ūüôā

Carrie created a google drive folder with some of her cooking and color materials. Here’s a link to it.

As promised, pictures!

Some apparatus, safety goggles, and the red cabbage indicator:

 

 

Lab notebook scribbles:

 

 

Remains of burning things:

IMG_0509

 

Yeast-produced CO2:

 

 

Ada experimenting (with dirt, of course):

IMG_0569

 

Muffins (the results, and recording them):

 

 

Muffins (the preparatory stages):

 

 

Looking at the results of DNA extraction:

 

 

This is Science! (Standing, for some reason, in the remains of bubble play)

 

 

Coordinate (Reaction Energy) Diagram, and the block analog:

 

 

Preparing natural pigments:

 

Natural paint art and (mostly failed) chromatography:

What 10-year-olds do instead of being on task:

IMG_0782

 

Chemiluminescence:

 

 

Chem Craft:

 

 

Experiments we never got around to:

  • Precipitating casein from milk (polymers and state changes)
  • Lemon battery (energy)
  • Making Nylon-66 (polymers and state changes — decided this was too dangerous to do with 10-year-olds who were only partly on-task the whole time)
  • Cooking eggs (energy, polymers, and state changes)
  • Various dry ice experiments (state changes)
  • Electrolysis of water, and re-making the water (basic chemistry, energy)
  • Metal from soda cans – if you scratch it, the plastic lining on the inside of the can is scratched and the soda acid rusts the metal can. Electrolysis might speed that up.
  • Making polymer ice cream with konjac that you need to cut with a knife and fork.


 

Towards a (toy) Quantum Computer

Tags

, , , , , ,

Leo’s FLG (Focused Learning Goal) for this year* is to build a real quantum computing mod in MineCraft. (Note that the kids set these goals for themselves at the beginning of the year, and although I might have slightly influenced his choice of project, the “in MinceCraft” setting¬†was all Leo!) This came from several sources, aside from just the obvious entanglement of his interest in quantum computers with MineCraft. The main influence is that there are two quite cool MineCraft mods, one, called qCraft, that adds a sort of quasi-quantum mechanics, and another, called Mekanism, that adds all sorts of advanced devices, esp. lasers. The qCraft mod actually has quantum computer components, but they are not very elegantly done; We wanted to make it a little more like a real quantum computer by using the Mekanism lasers as the qubit sources, and then add optical components for the gates.

If you don’t know what I’m talking about, there are innumerable videos on quantum computation on youtube, but if you REALLY want to understand it, I strongly recommend this excellent set of short lectures by Michael Nielsen, which not only nicely demystifies quantum computers, but at the same time demystifies quantum mechanics!

Anyway, so we needed to get our feet a tiny bit wet toward this pretty massively complex FLG. Unfortunately, direct MineCraft modding is done either in Java or Python. (There are a few little experiments in modding in scratch-like languages, but, much as they are nice tries, they have issues, so I decided not to bother with them, at least for the moment.)

To get our feet wet using a programming paradigm that Leo already knows, we chose HopScotch. Together we created a highly simplified quantum computer game in HopScotch. We only have one gate, a Hadamard gate, and the quantum state is highly simplified, having only the possibilities of being 1 or 0 or 50/50, no complex numbers nor normalizations.

But it’s kinda cool, none-the-less:

 

The circle represents a qubit that might be a photon, for example, and¬†its color represents its quantum state: green is definite 1, and red is definite 0.¬†It travels¬†a continuous loop from left to right, and then re-appears on the left again, as though it’s on a quantum wire that’s looped around from the end to the start.

When the program starts, the photon’s quantum state is definite 1 (1.0|1>+0.0|0>), and so the photon is green. The M box on the right measures the quantum state, “collapsing” it to 1 or 0. If you just let the program¬†run from the start without doing anything, the measurement gate will just keep reading 1, and incrementing the 1 count. The photon will just stay green.

The hex is a Hadamard gate (H gate), which splits the quantum state in half ((0.5|1>+0.5|0> — remember that we’re simplifying here, so there are no complex values or normalizations). If you drag the hex into the photon’s path (righthand screencap), the state becomes a mixture of 1 and 0 (and a mixture of red and green). When a qubit in that 50/50 state gets measured, there’s a 50/50 chance of collapsing into a 1 or a 0, and if you

You can try it out yourself on HopScotch on your iPad. (I’m told that HopScotch now allows you to run code in your browser, so you don’t need to actually have HopScotch on an iPad, although I highly recommend HopScotch on an iPad!)


* This post was actually written when Leo was in 3rd grade, so over a year ago. I apparently forgot to publish it, and it has been lingering in the drafts folder! Better late than never.


 

Algebra is Magic (part 1 of many)

Tags

, , , ,

I’ve been doing Algebra with Leo for some time, and every once in a while I actually amaze myself at just how cool Algebra is. Leo and I have in mind writing a book called “Algebra is Magic” which would just be a bunch of short solutions to what look like difficult problems, but which just “magically” drop out through Algebra.

Whenever we do any math, I’ve been trying to engrain that the first question is always “What’s the model?”, that is, what is the formal ‘equational’/’mathematical’/’algebraic’ form of whatever problem we’re doing?

Now, usually I know where we’re going, because I can do most of the things that a K-12 student would ever encounter more-or-less in my head, or at least I can tell right away what the algebraic form is going to be. So, together we write down the model (which I already know … or am able to work out without thinking too hard, so I lead him through this), and then we push through the algebra, and “voila!” the answer. (We always, of course, check the answer, at least for making sense, and usually for being correct by pushing it back through the original equation.)

Now, usually, the “voila!” moment is unsurprising to me, because I knew it was going to work, because I could see that we did it right, and where it was going. But, as I said at the outset, sometimes the problem is hard enough that even I’m not sure whether we’re right, and even I am surprised when it works!

There have been many of these, and our plan is to write these up, first in this blog, and eventually in a book.

Here’s just the latest one, as an example:

We’re starting on Calculus, and the book that I’m using (Stewart’s Calculus [8th ed.] from Engage Learning) has a¬† diagnostic test in the preface. For the most part these are pretty simple high school Algebra problems, and even Leo can do most of them … maybe with a little guidance from me … and I can, of course, do all of them. But there are a couple that are even tricky for me.

One such is this:

Prove:

\tan(\theta)\sin(\theta)+\cos(\theta)=\sec(\theta)

So, first off, we know “SOHCAHTOA”, and have used it a lot, but I had to recall what secant was. (I know its either inverse sine or cosine, but the way I remember which one is that I remember that it’s as confusing as possible, so to be as confusing as possible secant is inverse cosine, and cosecant is inverse sine!)

Okay, fine, but on the face of it I had no sense that this was going to be anything but a mess to prove. But we decided to use the “Algebra is Magic” mantra:

“Get a model and just push it through!”

Okay, so even I don’t know where this was going, but went with it, but here goes:

(I’m using ‘p’ here instead of ‘o’ to mean ‘opposite’, to avoid confusion with zero)

\sin = p/h, \cos=a/h, \tan=p/a

Blindly substitute into:

\tan(\theta)\sin(\theta)+\cos(\theta)=\sec(\theta)

to get:

(p/a) * (p/h) + a/h =h/a

Next, blindly push through the algebra, not really knowing where this is going:

Multiply:

(p^2/ah) + a/h =h/a

Multiply through by a:

p^2/h + a^2/h =h

Multiply through by h:

p^2 + a^2 =h^2

And then … Whoa! What The…. That’s The Pythagorean Theorem!

We weren’t headed there at all; we didn’t actually know where we were headed; Algebra brought us to The Pythagorean Theorem … by Magic!

And if we take The Pythagorean Theorem as axiomatic (which, of course we do!), then we just proved the target expression!

QEfingD … MAGIC … BANG!

(This, of course, led into into long discussions of the difference between theorems and axioms, including studying a bunch of proofs of The Pythagorean Theorem itself. But none of that was as magical as running headlong into it without knowing where we were headed!)