## Matlab: Lorenz Attractor

I’m a big fan of the Lorenz Attractor, which, when plotted, resembles the half open wings of a butterfly. This attractor was derived from a simplified model of convection in the earth’s atmosphere. One simple version of the Lorenz attractor is pictured below:

The Lorentz system is a set of ordinary differential equations notable for its chaotic solutions (see below). Here $$x$$, $$y$$ and $$z$$ make up the system state, $$t$$ is time, and $$\rho, \sigma, \beta$$ are the system parameters.

The Lorentz attractor is a chaotic solution to this system found when $$\rho = 28, \sigma = 10, \beta = 8/3$$.

The series does not form limit cycles nor does it ever reach a steady state.

We can calculate and render the aforementioned chaotic solution to this ODE as follows:

function loren3
clear;clf
global A B R
A = 10;
B = 8/3;
R = 28;
u0 = 100*(rand(3,1) - 0.5);
[t,u] = ode45(@lor2,[0,100],u0);
N = find(t>10); v = u(N,:);
x = v(:,1);
y = v(:,2);
z = v(:,3);
plot3(x,y,z);
view(158, 14)
function uprime = lor2(t,u)
global A B R
uprime = zeros(3,1);
uprime(1) = -A*u(1) + A*u(2);
uprime(2) = R*u(1) - u(2) - u(1)*u(3);
uprime(3) = -B*u(3) + u(1)*u(2);

This results in the figure:

To create a surface/mesh from this line plot, we proceed…

## Matlab: Create Mesh or Surface From Line Plot

This is a continuation of Matlab: Lorentz Attractor, however, these methods can be applied to any line plot or collection of points.

A slightly more aesthetically pleasing representation of the Lorentz Attractor can be achieved by adding axis off. And altering the view’s azimuth and elevation: view(15, 48).

Now we’re talking. Let’s say I want to make a surface or mesh from this dandy line plot. Using surf or mesh will throw an error, since x, y, and z are all 1D vectors! Whatever shall we do!

Never fear, mathematicians will save the day.

Delaunay created a sweet method of triangulating points. If we treat this line plot as a collection of points, we can triangulate to find an approximate surface.

tri = delaunay(x,y);
plot(x,y,'.')
%determine amount of triangles
[r,c] = size(tri);
disp(r)
%plot with trisurf
h = trimesh(tri, x, y, z, 'FaceAlpha', 0.6);
alpha = 0.4
view(15, 48)
axis vis3d
axis off
l = light('Position',[-50 -15 29])
lighting phong
shading interp

What if we’d like a surface instead of the mesh? Then we’ll change trimesh to trisurf add transparency (alpha = 0.7) and find:

## Matlab: Coaxial Cylinders (Polar Coordinates)

Let’s say we want to create an aesthetically pleasing visualization of 2 coaxial cylinders.

To do this, we’ll be adjusting the lighting, proportions, and transparency of the figure.

The code to create this figure utilizes the coordinate transformation from Cartesian to 3D-Polar coordinates. Recall that the transformation between coordinate systems is as follows.

Instead of using Matlab’s built in cart2pol method, we will manually convert each Cartesian (x, y, z) coordinate to it’s equivalent polar coordinate (r, phi, z) .

Side note:
I used phi above in the transformation equations and theta below in the code to make a point. The angular coordinate in the cylindrical (a.k.a polar) coordinate system is generally represented as either phi or theta.
These are equivalent, and the variable chosen is purely a matter of notation.

Y=-5:5;
theta=linspace(0,2*pi,40);
[Y,theta]=meshgrid(Y,theta);
r = 1.5
% calculate x and z
X=r*cos(theta);
Z=r*sin(theta);
hs = surf(X,Y,Z)
set(hs,'EdgeColor','None', ...
'FaceColor', [0.5 0.5 0.5], 'FaceLighting', 'phong');
alpha(0.7);
hold on
camlight right;
r = 0.5
% recalculate x and z
X=r*cos(theta);
Z=r*sin(theta);
hs = surf(X,Y,Z)
axis equal
set(hs,'EdgeColor','None', ...
'FaceColor', [0.5 0.5 0.5], 'FaceLighting', 'phong');
alpha(0.7);
axis off
camlight right;
lighting gouraud
view(140, 24)
% white background
set(gcf,'color','white')

## An Essay: Why Doctor Who is Awesome

Doctor Who depicts the adventures of a humanoid alien, the Doctor, who roams the universe on a sentient spaceship. This spaceship is referred to as the TARDIS which is an acronym for Time and Relative Dimension(s) in Space. As a Time Lord, the Doctor is able to regenerate his body when he is near death. Each of his incarnations has their own quirks but otherwise share the memories and basic personality of the previous incarnations. The Doctor often brings human companions to accompany him on his quests through parallel universes and different dimensions. On these adventures he saves civilizations and rights wrongs. The Doctor regularly gains new companions and loses old ones. The companions provide a surrogate with whom the audience can identify, and they serve to further the story by manufacturing peril for the Doctor to resolve.

Sam Moskowitz describes science fiction as “…a brand of fantasy identifiable by the fact that it eases the ‘willing suspension of disbelief’ on the part of its readers by utilizing an atmosphere of scientific credibility for its imaginative speculations in physical science, space, time, social science, and philosophy” (Explorers of the Infinite, 11). Doctor Who uses fictional cultures and time-travel to explore prejudice and fear. The Doctor’s fictional adventures, made believable by well-developed cultures and scientific justification for time-space travel, are used to communicate messages about current sociocultural issues.

The show began as an educational series. The Doctor’s original companions were a history teacher and a science teacher. Historic lessons were taught through time travel into the past. Scientific lessons were taught through stories based in the future or set in space. As the scientific aspect of the show gained popularity in 1967, the historic aspect of the show devolved into a tool for creating believable settings for the science fiction tales. Time-travel is often used to draw correlations between past events and current events; this emphasizes the various ways in which history repeats itself. The show’s fantastical setting creates an entertaining and memorable way to communicate complex ideas and experiences to viewers.

Doctor Who also uses these adventures across time and space as a medium to address the modern struggle for equal rights. In Series 6, Doctor Who has weaved the issue of LGBT Rights into the Doctor’s intricate quests on multiple occasions. In Day of the Moon (Series 6 Episode 2), the show uses a story set in America’s racially segregated past to correlate racism and homophobia. The Doctor encourages Nixon to allow Delaware to marry the person whom he loves. When Delaware requests that Nixon legalize his marriage to his partner, Nixon inquires if “she’s black” to which Delaware responds, “He is.” In The Runaway Bride (Series 3 Christmas Edition), two men are dancing intimately together at the wedding reception. In The Idiot’s Lantern (Series 6 Episode 8), the hero, Tommy, makes a speech at the end of the story to his dad about, among other things, having the freedom to love who you want. Silurian warrior queen, Madame Vastra, and her “cohort,” Jenny, are a time-traveling, crime-fighting, interspecies lesbian couple who star in A Good Man Goes to War and Let’s Kill Hitler. Strax, a friend of the couple, points out that Jenny “gender-bends” and disregards traditional gender roles. In A Good Man Goes to War, it is revealed that Jenny’s family exiled her at a young age out of disgust for her sexual and romantic preferences. Lesbian, gay, bisexual, and transsexual youth represent a large percentage (around 40%) of homeless youths in America and the UK. Doctor Who uses the story of a woman from an alien civilization (as she fights crime across time and space) to bring attention to this issue. The Doctor does not care about the sexuality, gender, or race of his traveling companions. The friends he has made (over nine-hundred years of roaming the universe) are selected for their moral and ethical viewpoints.

The monsters of Doctor Who are used as a platform to explore fear; they’re often embodied forms of the common fears of man. In The Idiot’s Lantern, “the Wire” is an alien that lives in electrical signals and literally consumes the minds of its audience. “The Wire” realizes the fear that an excessive consumption of media will lead to the degradation and eventual loss of individual thought.

In Silence in the Library, the “Vashta Nerada” are microscopic carnivorous creatures which disguise themselves as shadows to hunt and capture their prey. The characteristics of these horrible creatures play off of the common fear of the dark.

The Cybermen were originally wholly organic humanoids until they began to implant more and more artificial parts into their bodies as a means of self-preservation. This led to the race becoming coldly logical and calculating, with emotion removed to “purify” their minds. The race of the Cybermen is a warning against removing emotion from decision making in order to increase functionality. Additionally, in Rise of the Cybermen and Age of Steel, Cybermen reveal their belief that all humans must be “upgraded” to their cyborg form, repeatedly shouting, “Upgrade, or you will be deleted!” The phrase is terrifying, because it builds on our fear of religious terrorism. This terrorism is often driven by the belief that people with differing (“inferior”) belief systems must either convert or be eliminated.

The race of the Silence continues Doctor Who’s trend of using simple psychological concepts to create horrible monsters. Anyone who sees them immediately forgets about the encounter after looking away, but retains all commands made by the Silence to them during said encounter. This ability allows the Silence to have a significant influence across human history while being difficult to resist. The Silence are a double-whammy, because humans fear to be manipulated and we fear to lose control of our actions.

The Daleks were created as an allegory of the Nazis. Their chief role in the plot of the series is to “exterminate” all beings inferior to themselves. The repulsion that viewer’s feel toward their behavior mirror their disgust regarding Nazi Germany’s implementation of eugenics through mass extermination.

Doctor Who is a wonderful example of a science fiction series. The fantastic monsters of Doctor Who are physical representations of common human fears for the protagonists of the show to battle. The possibility of time-travel allows the show to present analogies of current sociocultural issues to those of the past, to raise awareness of present sociocultural issues, and to explore how our current societal standards might evolve in the future. The series uses stories set throughout time and space, with scientific justifications and historical backdrops, to teach its viewers about the various prejudices and fears held by themselves and/or their cultures.

## Matlab: Rotating Sphere Animation

Let’s say you want to make a simple simulation of a sphere spinning in Matlab.
First, you set the pop-up window to have the title ‘Spheres,’ the window to have black background, and specify said window’s position and size.

format compact
'NumberTitle','off','Position',[10,350,400,300], ...
'Color',[0 0 0]);

Matlab has a nice built in “sphere” surface function that you can invoke after you specify where you want it’s axes. Note that if you don’t include the h = axes('Position',[0 0 1 1]); command, the program will run the same except your view of the sphere will be farther away (smaller).

 %Zooms in on sphere h = axes('Position',[0 0 1 1]); %Draws sphere [X Y Z]=sphere(20); C = Z^2 + Y^2; %creates color data to map onto sphere hs = surf(X, Y, Z, C); The sphere function creates a “curved” surface using quadrilaterals. The boundaries of these quadrilaterals can be hidden set(hs,'EdgeColor','None'); or shown set(hs,'EdgeColor',[0.5 0.5 0.5]); %Shows wires set(hs,'EdgeColor',[0.5 0.5 0.5]); %Adjusts transparency alpha('color'); alphamap('rampdown'); %Adjusts lighting camlight right; lighting phong hidden off axis off axis equal Stopping here, you have a static sphere. Depending on whether you wish to just play the animation or if you wish to also save it as an ‘.avi’ file, you approach the animation in different ways. Either way, the animation looks like this: To play the animation without saving it: oh=findobj(gca,'type','surface'); %Spins about z axis. for i = 1:36 axis off; rotate(oh,[0 0 1],10); M(i) = getframe(gca); end %Spins about y axis. for i = 1:36 axis off; rotate(oh,[0 1 0],10); M(i) = getframe(gca); end %Spins about x axis. for i = 1:36 axis off; rotate(oh,[1 0 0],10); M(i) = getframe(gca); end To save the movie as an ‘.avi’ for future use, you can modify the above code section slightly. You create a writer object and write the video to it frame by frame (using writeVideo) as part of each forloop. %Create writerObj writerObj = VideoWriter('sphere.avi'); open(writerObj) %Animated movie of the rotation of the 3D globe oh=findobj(gca,'type','surface'); %Spins about z axis. for i = 1:36 axis off; rotate(oh,[0 0 1],10); M(i) = getframe(gca); frame = getframe; writeVideo(writerObj,frame); end %Spins about y axis. for i = 1:36 axis off; rotate(oh,[0 1 0],10); M(i) = getframe(gca); frame = getframe; writeVideo(writerObj,frame); end %Spins about x axis. for i = 1:36 axis off; rotate(oh,[1 0 0],10); M(i) = getframe(gca); frame = getframe; writeVideo(writerObj,frame); end close(writerObj); Putting it all together: format compact set(gcf,'Menubar','none','Name','Spheres', ... 'NumberTitle','off','Position',[10,350,400,300], ... 'Color',[0 0 0]); h = axes('Position',[0 0 1 1]); %Draws sphere [X Y Z]=sphere(20); C = Z^2 + Y^2; hs = surf(X, Y, Z, C); %sets wireframe to visible set(hs,'EdgeColor',[0.5 0.5 0.5]); %Alters transparency of sphere alpha('color'); alphamap('rampdown'); %Sets lighting of sphere camlight right; lighting phong hidden off axis equal %Create writerObj writerObj = VideoWriter('sphere.avi'); open(writerObj) %Animated movie of the rotation of the 3D globe oh=findobj(gca,'type','surface'); %Spins about z axis. for i = 1:36 axis off; rotate(oh,[0 0 1],10); M(i) = getframe(gca); frame = getframe; writeVideo(writerObj,frame); end %Spins about y axis. for i = 1:36 axis off; rotate(oh,[0 1 0],10); M(i) = getframe(gca); frame = getframe; writeVideo(writerObj,frame); end %Spins about x axis. for i = 1:36 axis off; rotate(oh,[1 0 0],10); M(i) = getframe(gca); frame = getframe; writeVideo(writerObj,frame); end close(writerObj); 

## Trombone Bell Decoration

To celebrate the removal of my braces (a few months ago), I drew on my tenor trombone’s bell.

After looking more closely at these pictures, I suggest that the infamous bathroom-mirror shot be replaced by interestingly-curved-reflective-surface shots.

## Translation of the DrawBraille Phone Ad

I recently saw an add for a product I am excited for (although most blind people I know prefer Siri):

For anyone who is curious:

The “screen” portion says:
welcome
to
red-dot (or redcomdot; probably the former)

1 2 3 4 5 is listed in the column down the left side of the keypad, and 6 7 8 9 0 is listed down the right side.

I’m assuming that typing characters would be done using the 3×2 pad between the two columns of numbers.

## MinutePhysics is Naively Incorrect: Finding the Limit of a Geometric Series

I recently watched a video by MinutePhysics where he seems to prove that infinity = -1.

He took the sum of the infinite series, beginning with 1, where each term is double the previous term.

He claims that S = infinity (so far, so good).
I would argue that S approaches infinity, but this is purely technical tricky business.

Then he doubles S, thus doubling all of it’s terms (still okay).

He then subtracts the two,

terms cancel, leaving S = -1.

This is a geometric series (each term gets multiplied by a common factor; in this case, the common factor is 2). If you take the common factor to be 1/2 instead, then you’ll have

Each term is getting smaller, approaching zero. If you calculate S, you’ll see that the partial sums approach 2:

Thus, the value 2 is the limit of the series. We call this type of series a convergent series, because the sum of the series converges to one number.

However, the example used by MinutePhysics is not a convergent series (the terms double each time). We call this a divergent series.

A divergent series needn’t sum to infinity. Divergent is an umbrella term that covers all series that are non-convergent. This includes periodic series (series that flip between two values), such as

The terms of this series will flip between the two values -1 and 1. Its sum will alternate between 0 and -1.

However, just because a series is divergent doesn’t mean you can’t give its sum a value. This is not the limit, for there is no limit that the sum approaches.

Let’s say you have a general geometric series; each term is being multiplied by a common factor, r.

You can use the same tricks as before to find a general limit for this series:

This reduces to

This trick only finds the limit of convergent series, because the limit of a divergent series doesn’t exist.

In other words, the limit has to exist in order to find it!

For the limit to exist, each term must be smaller than the last (the common ratio must be less than 1).

If you apply this formula to a convergent series, you’ll get the limit. When the common ratio was 1/2, the limit = 2.

If you apply this formula to a divergent series, you’ll get a value. But it won’t be the limit of the series, because the limit doesn’t exist.

Side Note:
When you apply to the original example (the common ratio was 2), you’ll find the value -1. This isn’t the limit, because the limit doesn’t exist, it’s what the limit would be if it was a convergent series.

If the common ratio is -1, the sequence will flip between two values, for example, 6 and -6. When you add up the partial sums, these flip as well. You’ll get 6, then 0, then 6, then 0…
If you apply , you’ll get the average of the partial sums (in this case, 3). Finding the average of partial sums is applicable to all series:

When you find the average of the partial sums of a convergent series, you’ll find that it coincides with the limit.

If you apply it to divergent series, you don’t get the limit; you get this average of partial sums.

Either way, this value has meaning.

So, what was the problem with the video Adding Past Infinity?

He used a method that can be applied to all geometric series.

When you apply this method to a convergent geometric series, you get the limit of the series.

MinutePhysics applied this method to a divergent geometric series (which is fine).

He got a value (which is fine).

But he claimed that this value was the limit of the series (which is not fine, because the limit doesn’t exist)!

I begin by declaring that $$S = 1 + 2 + 4 + … = \lim_{n \rightarrow \infty} \Sigma_{i=0}^n 2^i = \infty$$. This is fine.