Think about Euler’s Formula on polyhedron


Let’s think about Euler’s formula in polyhedron.

Euler’s Formula

On polyhedron, the following equation is valid.

(vertex count) – (edge count) + (face count) = 2

This formula is also true to plane figure.

Now, let’s think about this formula on plane figure. Polyhedron can be projected to plane figure, so it is true to polyhedron when it’s true to plane figure.

men

Project Polyhedron to Plane Figure

Polyhedron can be projected to plane figure.

Left is a tetrahedron, and it can be projected to plane figure on the right side. 4 faces of tetrahedron becomes 3 triangle and other, rounding area. Plane is divided into 4 area by vertex and edge.

Proof

Now, think about plain figure composed vertex, edge and face. Vertex is edge’s start and end point. All edge is connected only at vertex, don’t cross.

Think in mathematical induction. Define \( V \) as vertex count , \( E \) as edge count , \( F \) as face count. The goal is \( V – E + F = 2 \) .

Case \( E = 1 \)

Edge \( E \) is 1, face \( F \) is 1, Veftex \( V \) is 2, then

\[ V – E + F = 2 – 1 + 1 = 2 . \]

The formula is true.

Case when \( E = k \in \mathbb{N} \)

Suppose \( E_k \) , \( V_k \) , \( F_k \) as \( E \) , \( V \) , \( F \) when \( E = k \) and the formula is true.

\[ V_k – E_k + F_k = 2 \]

\( V_k \) and \( F_k \) is not unique for \( k \), they are values which meet the formula.

Think of adding a new edge. Edges are connected on vertexes, so new edge should be connected to already existing edges on start or end point

When the new edge connect on one point

Vertex count increases by one then \( V = V_k + 1 \). Edge count increases by one then \( E = E_k + 1 \) . Face count doesn’t change so \( F = F_k \) .

\begin{array}{cl} & V – E + F \\ = & ( V_k + 1 ) – ( E_k + 1 ) + F_k \\ = & V_k – E_k + F_k \\ = & 2 \end{array}

When the new edge connect on two point

Without the new edge, edges are connected so one side or the other is rounded by edges. Then, draw the new edge, and the face count increases by one.

Now, vertex count doesn’t change, \( V = V_k \), edge count increases by one, \( E = E_k + 1 \) , face count increases by one, \( F = F_k + 1 \) . Of course, in the case that start and end point is the same.

\begin{array}{cl} & V – E + F \\ = & V_k – ( E_k + 1 ) + ( F_k + 1 ) \\ = & V_k – E_k + F_k \\ = & 2 \end{array}

From the above, when the formula is true to \( E = k \in \mathbb {N} \), it is also true to \( E = k + 1 \) .

Above all, the formula is always true.

With this Euler’s Formula, we can prove Descartes theorem. I wrote the detail on Prove Descartes Theorem on Polyhedron.


haskell split string by comma, into list


I’ll introduce to you, how to split string into list by comma, make "a,b,c" to ["a", "b", "c"].

Background

You know that there are some function like splitOn in Data.List.Split module, but import Data.List.Split didn’t work on Ideone. So, I, a haskell beginner, thought how to do it without other modules.

Split by comma

The following code do it. It split string, [Char] only by comma.

split "a,b,c" outputs ["a", "b", "c"].

Split by any delimiter

You can specify any delimiter with the following. The delimiter should be a Char.

split ' ' "a b c" outputs ["a", "b", "c"].


Rails How to execute task in seed


Here’s how I executed task in seeds.rb, in Rails.

The Rails 4 Way

Environment

  • Ruby 2.2.2p95
  • Rails 4.1.8
  • Rake 10.4.2

First, create a task with rails g task sample shot. The following code will be generated.

Now, we can execute the task with bundle exec rake sample:shot. The goal is to execute the task when bundle exec rake db:seed is executed. Maybe, it is the same way to execute task in rails code.

Solution

Add the code into seeds.rb, like below.

Environment (test, development, production) is passed, which is valid in rake db:seed. On the above, set 'value' to SOMETHING. It is like FEATURES in rake db:fixture:load FIXTURES=xxxx.


A Life Summary of an Gypsy