Some More Tinkering

After yesterday’s discussion of springs and sine graphs, I remembered a post from 2012, “Daydreams, Lectures, and Helices.” I decided to figure out how to graph a helix in R.

Well, after installing the rgl package and experimenting a bit, I got it to work.

helix

Here’s the code:

require(rgl)
x=seq(0.01,6.29,0.01)
y=seq(0.01,6.29,0.01)
z=seq(0.01,40,0.01)
plot3d(cos(x), sin(y), z, col=”red”, size=3)

I then rotated it into a good view. As my Latin teacher used to say, that’s all there is to it!

Next up (at some point): an animation of a spring.

The Springs of Creativity

chas-fischer-spring-co

I am talking about literal metal springs here, the things that bounce. What do springs (those metal bouncy things) have to do with creativity?

As I mentioned a little while ago, my great-granduncle Charles Fischer founded the Chas. Fischer Spring Co. in 1906. He invented and manufactured many parts and devices, including a delightful book prop that clasps onto the leg. (I don’t know whether Charles Fischer himself invented it—it could have been one of his sons—but his company patented and manufactured it.) I just received a comment about that very book prop! (Thank you, Joe Simpson, for writing!)

Before he founded his company,  he worked as a spring-maker. I imagine him tinkering with the springs and thinking of new uses to which they could be put. My argument here is that creativity–at least a certain kind–comes out of playing and experimenting with an actual subject or medium. You don’t teach or learn creativity in the abstract. People have been wringing their hands over the need to teach creativity in schools–but that’s a waste of hand muscle. Get the hands going with something, and then start tweaking it. Before you know it, you just might have something new in the works.

I’ll take a look at one of Charles Fischer’s inventions, the take-up spring, then apply this notion of “tweaking” to some simple R code.

I  imagine him making spring after spring while his wife was at home ironing and cursing the cord that always got in the way. (The retractable cord,  like the one in today’s vacuum cleaners, wasn’t invented for another few decades.) “What if,” they may have discussed one day over dinner (who knows–maybe they talked about these things, maybe not), “What  if a spring could actually keep the cord suspended up above, in the air, so that when you needed it, you could draw it in, but when you didn’t need it, your ironing could proceed unimpeded?” Lo and behold, he found that a spring could do just that:

take-up-spring-figures

You can read the description here.  He explains: “The invention is especially useful in taking up the cord of an electric iron, thus doing away with the inconvenience and annoyance of having the cord in the way of the iron when the latter is in use and permitting free use of the iron by the operator.”

So there you go–the daily work with springs, I imagine, allowed him to think of other things that could be done with them.

That, I believe, is often how creativity works. You’re doing something repetitive and routine, but within that repetition, you start thinking about other things that can be done. You try them out with your materials. You learn about what works and what doesn’t; you gain knowledge not only of the practicalities, but of the principles and possibilities. You try new things from there.

Now I’ll give a simple example of this from computer programming–something easy enough for anyone to try. I won’t do anything groundbreaking here; my point is that by starting to tinker with code, you can learn what’s going on and experiment with new things.

I got this code from “R by example.” It’s the first one under Graphs. (You can download R itself from The R Project for Statistical Computing.)

# Goal: To make a panel of pictures.

par(mfrow=c(3,2))                       # 3 rows, 2 columns.

# Now the next 6 pictures will be placed on these 6 regions. 🙂

# Let me take some pains on the 1st
plot(density(runif(100)), lwd=2)
text(x=0, y=0.2, "100 uniforms")        # Showing you how to place text at will
abline(h=0, v=0)
              # All these statements effect the 1st plot.

x=seq(0.01,1,0.01)
par(col="blue")                         # default colour to blue.

# 2 --
plot(x, sin(x), type="l")
lines(x, cos(x), type="l", col="red")

# 3 --
plot(x, exp(x), type="l", col="green")
lines(x, log(x), type="l", col="orange")

# 4 --
plot(x, tan(x), type="l", lwd=3, col="yellow")

# 5 --
plot(x, exp(-x), lwd=2)
lines(x, exp(x), col="green", lwd=3)

# 6 --
plot(x, sin(x*x), type="l")
lines(x, sin(1/x), col="pink")


Now, when you run it, you get this nifty series of graphs:

graphs

Now, let’s say I don’t know R (which is true). I’m looking at this and thinking, “Let’s say I want to show the same function throughout, let’s say sin(x), but over a different interval each time.” So I look for the line of code that seems to indicate the interval. That would be:

x=seq(0.01,1,0.01)

But I see that that’s also the default, and I want it to change each time. So I’m going to have it repeat for each graph, but I will change the middle number with each iteration. The adjusted code looks like this (I’m omitting the “lines” function since it isn’t needed now, and I’m making all the graphs blue):

# Goal: To make a panel of pictures of sin(x) at increasing intervals.

par(mfrow=c(3,2)) # 3 rows, 2 columns.

# Now the next 6 pictures will be placed on these 6 regions.

par(col=”blue”) # default colour to blue.

# 1 —
x=seq(0.01,1,0.01)
plot(x, sin(x), type=”l”)

# 2 —
x=seq(0.01,2,0.01)
plot(x, sin(x), type=”l”)

# 3 —
x=seq(0.01,3,0.01)
plot(x, sin(x), type=”l”)

# 4 —
x=seq(0.01,4,0.01)
plot(x, sin(x), type=”l”)

# 5 —
x=seq(0.01,5,0.01)
plot(x, sin(x), type=”l”)

# 6 —
x=seq(0.01,6,0.01)
plot(x, sin(x), type=”l”)

And here are the resulting graphs (how pretty):graph2

The tinkering, you see, has just begun. I can fiddle with the colors, bring in a second function, and do all sorts of other things. Even at this basic level, as I do this, I’m learning code while at the same time thinking up new possibilities.

In short, creativity is not elusive or amorphous. It has to do with fiddling around within forms and structures and then pushing outward to something new.

Happy New Year to all!

Image credits: The ad at the top is my own copy, which I purchased on Ebay. The patent figures (Pat. No. 1,578,817) are from the United  States Patent and Trademark Office. The graphs were generated in R.

Note: I made a few minor revisions to this piece after posting it.