Skip to main content

Posts

Showing posts with the label math

Floating point reproducibility in parallel processing

The floating point reproducibility problem On a typical computer, the results of floating point operations can differ from the mathematical result. In general, floating point operations like addition may not satisfy all mathematical properties for that operation. For example, the associativity property of addition may not hold for all numerical values: $(x + y) + z \stackrel{?}{=} x + (y + z)$ A decimal representation of a number cannot always be represented by a finite binary representation in computer hardware. For example, the computed result of $0.1 + 0.01 - 0.1 - 0.01$ is not equal to $0$, but mathematically these values should be equivalent. For example, you can demonstrate this using the Python interpreter (Python 3.8.5): >>> 0.1 + 0.01 - 0.1 - 0.01 -5.204170427930421e-18 But mathematical properties do hold in other cases. For example, the result of $0.1 - 0.1 + 0.01 - 0.01$ is equal to $0$. >>> 0.1 - 0.1 + 0.01 - 0.01 0.0 Another problem results from rounding...

Gauss's quote for positive, negative, and imaginary number

Recently I watched the following great videos about imaginary numbers by Welch Labs. https://youtu.be/T647CGsuOVU?list=PLiaHhY2iBX9g6KIvZ_703G3KJXapKkNaF I like this article about naming of math by Kalid Azad. https://betterexplained.com/articles/learning-tip-idea-name/ Both articles mentioned about Gauss, who suggested to use other names of positive, negative, and imaginary numbers. Gauss wrote these names are wrong and that is one of the reason people didn't get why negative times negative is positive, or, pure positive imaginary times pure positive imaginary is negative real number. I made a few videos about explaining why -1 * -1 = +1, too. Explanation: why -1 * -1 = +1 by pattern https://youtu.be/uD7JRdAzKP8 Explanation: why -1 * -1 = +1 by climbing a mountain https://youtu.be/uD7JRdAzKP8 But actually Gauss's insight is much powerful. The original is in the Gauß, Werke, Bd. 2, S. 178 . Hätte man +1, -1, √-1) nicht positiv, negative, imaginäre (oder gar um...

How to count zombis in Japanese?

``I don't know how to count zombies in Japanese.'' I voluntarily translate mathematics exercises in Khan academy ( https://www.khanacademy.org/ ) from English to Japanese/German.  You can learn anything on Khan academy. When I translate the following question: Liliana used 4 dark power crystals to raise 14 zombie soldiers. She wants to know how many zombie soldiers (z) she can raise with 10 dark power crystals... In Japanese, when you count, you added postfix depends on what you count. I know how to count people: 1人,2人, 3人. But, is a zombie a person? A zombie could be an animal, then, I should count them 1匹,2匹, 3匹.  Wait, is a zombie a dead body? Then I should count them 1体,2体, 3体. A zombie could be a novel ghost, then 1柱,2柱... The question told me they are zombie soldiers. Soldiers are the same as the people, then 1 人,2人, 3人. In the end, I decided to translate them as 1人,2人, 3人, this means a zombie is a person. I like translation work like this, quite interesting. Y...

The meaning of ``Get together'': Part 3

I like to make a quiz like in the last article. But some of my friends said to me ``Many can live without knowing such things.'' That would be true. I even thought that it is natural that many people don't care about that. But recently I found some people deceive others by using this kind of wrong math. I feel sad when the honest people were deceived. Especially when I read a newspaper article that someone used this kind of wrong logic and stole some money from people. I think it may be good to know these kind of things not to be deceived by malicious people. The problem here is actually not exactly a mathematical problem, it is rather a language problem. If you understand the meaning of the problem, actually this is not so much math in there. Since the question is described in a language (originally in Japanese, here in English. I found it is interesting this worked for both languages), we need to understand what the problem means. Here we need to know what is the ...

The meaning of ``Get together'': Part 2

A while ago, I taught mathematics to a thirteen years old boy. His family moved to another city, so we could not have more sessions, but I liked to teach him. In the last session, we discussed about addition of fractions. If we get a half cake (\(\frac{1}{2}\)) and a half cake (\(\frac{1}{2}\)) together, \begin{eqnarray*}  \frac{1}{2} + \frac{1}{2} = \frac{1+1}{2} = \frac{2}{2} = 1, \end{eqnarray*} it becomes 1. If we add fractions with like denominators, we only add numerators. We discussed why we did in this way and what this meant. Then I told him a story. The boy's favorite soccer player tried to shoot the goal twice in a game, and he succeeded once. His goal ratio of this game is \(\frac{1}{2}\). (Two shoots, one goal) The next game, again he tried to shoot the goal twice in the game, and again he succeeded once. His goal ratio of the game is again \(\frac{1}{2}\). Let's think about his goal ratio to get two games together. For these two games, he tried four goal...

The meaning of ``Get together'': Part 1

Every person thinks by words. Thus words are important for me, too. Especially I need to write programs to realize an idea through the words. We can easily find that one word has sometimes a few meanings. People make a joke from it. I think one word has a few meaning is quite natural. For instance, ``run'' has a few meaning. I run as I move fast by foot. I can run a shop. A movie is now running at the theater. In English, it has more meanings with a short word (run after, run away, run out, ...), however, you have already seen the ``run'' itself has a few meanings. When we used only one language, we hardly noticed this multiple meaning of a word. However, when we learn foreign languages, we need to notice this through the translation. We can easily see one word usually has more than one translation in a dictionary. When we learn a foreign language, we can usually see the deepness of both our own language and the foreign language. In literature, especially in poems, us...

Math objects on programming (2)

Last article, I showed a simple enumeration generator. But I needed one more flexibility. In my job, I use GPU, that is a fast processing unit, but the available memory size is one order of magnitude small compare to a decent workstation. (E.g, GPU's memory size is 2GB to 6GB, a decent workstation can have 24GB to 256GB main memory.) In this pseudo code example, the unit of memory size is GB. 64GB or 512 GB are too much to the current stare of the art GPUs in 2013.  512GB is too much for the best workstation. Therefore, our product uses a cluster, many workstations are cooperates to do a single job. Almost every customer wants to see how our products scales regarding to the number of workstations. Because they have their needs and they want to know how many workstations and how many GPU are needed for their task. Therefore, we need to demonstrate how the performance changes depends on the number of nodes. Here one more parameter, the number of nodes are added as the following. ...

Math objects on programming (1)

Abstract: Using mathematical objects often makes a program simpler. This time I have such experience and write it down here. Mathematical object and programming In a program test, we often need to generate a combination of input parameter sets. One of the most easy method to generate a combination is using nested loops. In this article, I use pseudo code based on the Python language. I will provide the real implementation of the program in the appendix. For example, we have following two parameter sets:  data_size_list = [ 5, 64, 512, ]  screen_resolution_list = [     '2560x1440', '3840x2160', ]. The following program can generate the combination of them:   for d in data_size_list:     for s in screen_resolution_list:       print_comb(d, s) # output This method is simple and straightforward, however, less flexible in some cases. For example, we don't know which sets are necessary to generate a combination whe...

Authors in a Markov matrix: Which author do people find most inspiring? (7)

The adjacency matrix A matrix  is a two-dimensional rectangular array of numbers arranged in rows and columns. It looks like a table of numbers. The readers who want to more about matrix, see the Appendix A (will be shown up the later blog) in this document as a short introduction, or to know more deeply, see [7]. I would like to show how a matrix can be used to describe a graph. My motivation is to be able to write down a graph. Following some rules, we can write down a graph in matrix form. Let me introduce such a method for representing a graph here. The matrix I will describe is called an adjacency matrix . Definition :  An adjacency matrix \(A\) of a graph of \(N\) vertices is an \(N \times N\) matrix where the element \(a_{i,j}\) is 1 when there is a directed edge from node \(i\) of the graph to node \(j\), otherwise 0. That's all there is to it. An element in an adjacency matrix that represents a connection is a 1; an element that represents the lack of a con...

Graph theory for railfans: A side story of Authors in a Markov matrix

This is a side story of ``Authors in a Markov matrix: Which author inspires the people most?'' What relationship do railfans and Graph theory have? is the theme of this story. ( Japanese version ) My colleague Dietger asked me, ``Do you know how to traverse the all the edges in a graph?'' I asked back, ``Isn't it a Hamiltonian path problem ?'' He answered, ``No. Hamiltonian path is the problem to traverse all the nodes only once. Instead of the nodes, I want to know how to visiting all the edges once.'' I intuitively answered, ``Can we solve it on the dual graph?'' But this was wrong. Figures 1, 2, 3 show the what is the face-vertex dual graph, and Figure 3 shows there is no edge dual graph.  For instance, in a triangle mesh, vertices are connected via edges, faces are also connected via edges. Therefore, vertex (node) and face can be (so called) dual. Then, what is the connection between edges? There is no connection between edges, or e...

Authors in a Markov matrix: Which author do people find most inspiring? (6)

In mathematics, we usually only think about these node numbers.  The numbers are only used to distinguish the nodes. When we apply the idea of a graph to a concrete problem, these numbers corresponds to different kinds of objects. Let me show two examples to give you some idea. Example 1: Nodes represent authors Assume we are describing the following authors: William Shakespeare Lewis Carroll Raymond Smullyan Martin Gardner There could be many different opinions about what kinds of relationships these authors have. Here I assume Shakespeare inspires Carroll, and Carroll inspires Smullyan and Gardner. Such graph can be shown in Figure 6. Figure 5. Graph example 1. Each node is an English author. Example 2: Nodes represent train stations Assume each node represents a train station. The followings are stations in Berlin, Germany. Weinmeisterstr Alexanderplatz Hackescher Markt Jannowitzbruecke When two stations are next to each other (the next station), we...

The connection 0 and other

A boy (T.) is working on 7. The question is what two numbers make 7. The material using here is shown in Figure 1. This is called ``Zahlenhaus''. One house has two rooms and each room has some people. How many people are in the house? is the question and the students think about addition. Figure 1. Zahlenhaus: 7 = 4 + 3 Figure 2. Zahlenhaus: Questions Beside the house figure, there is a equation (Figure 2), usually missing one part. For example, 7 = 3 + ? 7 = 4 + ?. The leaner fills in ?. T. has no problem to fill in those questions. However, he doesn't understand the following. 7 = 0 + ? By the way, this is a easy case. Since he understands what he doesn't understand. I, myself, have a problem to find when I lost in a mathematics book. If I know where I lost, it is rather easy to return to the track. But, in many cases, I didn't know where I lost. Then I first need to find out where to return in the book. OK, let's back to the Zahlenh...

Authors in a Markov matrix: Which author do people find most inspiring? (5)

What is a graph? A graph is a set of nodes connected by edges. When there is a relation between two nodes, these nodes are connected by an edge. Figure 4 shows a graph example that has four nodes. In the figure, the node 1 (\(N_1\)) and the node 2 (\(N_2\)) is connected by the edge \(E_{1,2}\). A graph is only concerned with the connections between nodes, so how the nodes are arranged in a figure doesn't matter. Figure 5 has three graphs, but all the graphs are considered to be the same in graph theory. Figure 4. Edges connect nodes. Figure 5. The same graphs. Graph only cares the connections between nodes. I will show you some examples next time.

Authors in a Markov matrix: Which author do people find most inspiring? (4)

Introduction to graph theory In mathematics and computer science, graph theory is the study of graphs.  A graph represents relationship between objects. I am going to use this theory to represent relationship between authors. It is straightforward to use graph theory to understand the relationships between objects. In that sense, this is nothing new, but I am curious about the application of this method to understand an aspect of literature --- the relationship between authors. Fundamental objects of graph Graph theory has two fundamental objects: a node (also called a vertex ) and an edge . A graph , then, is a set of nodes connected by edges. If two nodes are connected by an edge, these two nodes are defined to have a relationship. Figure 1 shows these fundamental objects. Graph theory only thinks about these two objects. You might think that this is simple, since there are only two types of objects. However, we will see that complexity is still possible. Figure...

Authors in a Markov matrix: Which author do people find most inspiring? (3)

Problem statement: Analyzing author relationships (2) I would like to suggest we start with a simpler problem. Let's forget about the contents of a book and how much it influences others. Our model only concerns the existence  of an influence. Fortunately, there is a mathematical method based on the existence of a relationship, called graph theory .  One of the tools used by graph theory is linear algebra. Graph theory has been widely used for a long time.  When the World Wide Web era came, this method was also applied to the principles of web search to implement a basic idea.  If you can find the most influential web page, you should list these results on top of the search results. There is also a lot of research to find a method to automatically compute the influence between web pages. Probably the most frequently used method for such a web page ranking only considers the linking relationship between web pages. Since this method only uses link information, i...

Authors in a Markov matrix: Which author do people find most inspiring? (2)

Problem statement: Analyzing author relationships (1) Let's start thinking about what is the problem. One of my friends who studies literature asked me how I would analyze the relationships between authors. For instance, ``How can we measure the influence of Shakespeare in English literature compared to other writers?'' The discussion of which literary works are canonical and the attempts to define the boundaries of the canon are endless ( http://en.wikipedia.org/wiki/Western_canon ).  Typically, a specific individual or group has defined the boundaries of the canon. If we consider creating a ranking system using numbers, I wouldn't even know how to begin such a discussion. It is easy to imagine such discussions raising an even more generic question: ``What is art?'' Answering that question is clearly beyond my ability! If nobody can agree on such a ranking system for authors, I could at least start by creating an incomplete definition, hoping to improv...

Authors in a Markov matrix: Which author do people find most inspiring? (1)

Introduction One of my friends who studies literature asked me how I would analyze the relationships between authors. I answered that if you could represent these relationships by a graph, you could use a mathematical method called ``eigenanalysis'' for that.  Google determines the relationship between web pages using this method in a software program called ``PageRank.'' I am interested in this method as a problem in a new approach to literary analysis called ``computational literature.'' In this paper I describe the results of my research. I will describe this in the following blog entries.

Vector projection and directional cosine

Abstract When I compute something, I see it is correct, but sometimes my intuition doesn't work. Especially, I am not good at statistics, though, sometimes I don't see geometry also. I can show you such example this time. Vector projection and directional cosine My friend Dietger asked me a problem. Figure 1 shows the problem. Let \(\mathbf{h}'\) is a projected vector of \(\mathbf{h}\) on the \(\mathbf{e}_1,\mathbf{e}_2\) plane of an orthogonal coordinate system. Where \(\mathbf{h}\) is an arbitrary unit vector. Let \(\mathbf{h}_1\) is the projection of \(\mathbf{h}\) on the axis \(\mathbf{e}_1\). Then show \[  \cos \alpha = |\mathbf{h}'| \cos \phi. \] It's intuitively odd for me that there is a length ratio \(h'\) between \(\cos \alpha\) and \( \cos \phi\). Figure 1. Two projections of an unit vector \(\mathbf{h}\). However, these are projections, therefore some \(\cos\)  relationships. Let's start with  \(\mathbf{h}_1\).  \(\mathbf{h}_1\)...

MathJax Test

It's bit cumbersome to create an image for each equation every time. So  I try MathJax here. This is a great software! To enable MathJax, Add <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> </script> in the blog text in blogger. Now some equation here. \[  |\mathbf{h}_1| =  \mathbf{h}\cdot \mathbf{e}_1  = |\mathbf{h}| |\mathbf{e}_1| \cos \alpha  = \cos \alpha \] becomes \[  |\mathbf{h}_1| =  \mathbf{h}\cdot\mathbf{e}_1  = |\mathbf{h}| |\mathbf{e}_1| \cos \alpha  = \cos \alpha \] Awesome.

Why is the normal transformation a inverse transpose? (9)

Conclusion I think it is not exactly correct that the normal transform is an inverse transpose. A normal vector is not a column vector, the transform is a left inverse as Equation 5 shows. The transpose comes from the implementation of the vector class. This should be a left inverse as a rigorous formulation. I don't say the references [2,3,6] are incorrect, but I prefer the references [4,5] since they distinguish these two kind of vectors. However, the references [2,3,6] have an easier to understand explanations. Especially, [2,3,6] shows why normal transformation doesn't work with applying A intuitively. I like these explanations more. Here I would like to highlight the difference of a usual vector and a normal vector, they are a column vector or a row vector. By the way, contravariant vector means doesn't-change-vector, but, its representation can change. It seems I should explain the difference of these vectors are related with inner product. I would like to stud...