text:
# Processing data with Pandas¶

Now you should know the basics of the data structures in Pandas and how to explore your data using some tools that is provided by Pandas. Next we continue to explore some of the basic data operations that are regularly needed when doing data analysis.

Let’s first read the same data as before into Pandas to have a clean start, and focus on a few new aspects of importing data:

[58]:

import pandas as pd

Please note two things in the code above:

• ‘r’ prefix in front of the filepath string.
• Delimiter to use: parameter sep=',' in the read_csv() function.

In our case, both of these details are not needed (the code works correctly without them), but they might come in handy in the future. The letter ‘r’ makes sure that the filepath is interpreted correctly. Without the r, backslashes are treated as escape characters. With the r, backslashes are treated as literal. This happens often if you define full filepaths as input. What would for example happen here: fp = 'C:\notebooks\L5\Kumpula-June-2016-w-metadata.txt' ? (try it out!)

The default delimiter in the read_csv()-function is logically a comma (,). If needed, you can also define other characers and expressions as delimiter. The correct delimiter in our case however is the comma.

## Calculating with DataFrames¶

One of the most common things to do in Pandas is to create new columns based on calculations between different variables (columns).

Creating a new column into our DataFrame is easy by specifying the name of the column and giving it some default value (in this case decimal number 0.0).

[59]:

# Define a new column "DIFF"
dataFrame['DIFF'] = 0.0

# Print the dataframe
print(dataFrame)

    YEARMODA  TEMP   MAX   MIN  DIFF
0   20160601  65.5  73.6  54.7   0.0
1   20160602  65.8  80.8  55.0   0.0
2   20160603  68.4  77.9  55.6   0.0
3   20160604  57.5  70.9  47.3   0.0
4   20160605  51.4  58.3  43.2   0.0
5   20160606  52.2  59.7  42.8   0.0
6   20160607  56.9  65.1  45.9   0.0
7   20160608  54.2  60.4  47.5   0.0
8   20160609  49.4  54.1  45.7   0.0
9   20160610  49.5  55.9  43.0   0.0
10  20160611  54.0  62.1  41.7   0.0
11  20160612  55.4  64.2  46.0   0.0
12  20160613  58.3  68.2  47.3   0.0
13  20160614  59.7  67.8  47.8   0.0
14  20160615  63.4  70.3  49.3   0.0
15  20160616  57.8  67.5  55.6   0.0
16  20160617  60.4  70.7  55.9   0.0
17  20160618  57.3  62.8  54.0   0.0
18  20160619  56.3  59.2  54.1   0.0
19  20160620  59.3  69.1  52.2   0.0
20  20160621  62.6  71.4  50.4   0.0
21  20160622  61.7  70.2  55.4   0.0
22  20160623  60.9  67.1  54.9   0.0
23  20160624  61.1  68.9  56.7   0.0
24  20160625  65.7  75.4  57.9   0.0
25  20160626  69.6  77.7  60.3   0.0
26  20160627  60.7  70.0  57.6   0.0
27  20160628  65.4  73.0  55.8   0.0
28  20160629  65.8  73.2  59.7   0.0
29  20160630  65.7  72.7  59.2   0.0

Let’s check the datatype of our new column

[60]:

# Check datatypes
dataFrame['DIFF'].dtypes

[60]:

dtype('float64')

Okey, so we see that Pandas created a new column and recognized automatically that the data type is float as we passed a 0.0 value to it.

We can also easily do calculations inside our DataFrame. Let’s update the column DIFF by calculating the difference between MAX and MIN columns to get an idea how much the temperatures have been varying during different days. Calculations can be done with following syntax where we first specify the column that we want to update (i.e. DIFF) and then do the actual calculation using the columns that we have in our dataFrameFrame.

[61]:

#Calculate max min difference
dataFrame['DIFF'] = dataFrame['MAX'] - dataFrame['MIN']

# Print the dataframe
print(dataFrame)

    YEARMODA  TEMP   MAX   MIN  DIFF
0   20160601  65.5  73.6  54.7  18.9
1   20160602  65.8  80.8  55.0  25.8
2   20160603  68.4  77.9  55.6  22.3
3   20160604  57.5  70.9  47.3  23.6
4   20160605  51.4  58.3  43.2  15.1
5   20160606  52.2  59.7  42.8  16.9
6   20160607  56.9  65.1  45.9  19.2
7   20160608  54.2  60.4  47.5  12.9
8   20160609  49.4  54.1  45.7   8.4
9   20160610  49.5  55.9  43.0  12.9
10  20160611  54.0  62.1  41.7  20.4
11  20160612  55.4  64.2  46.0  18.2
12  20160613  58.3  68.2  47.3  20.9
13  20160614  59.7  67.8  47.8  20.0
14  20160615  63.4  70.3  49.3  21.0
15  20160616  57.8  67.5  55.6  11.9
16  20160617  60.4  70.7  55.9  14.8
17  20160618  57.3  62.8  54.0   8.8
18  20160619  56.3  59.2  54.1   5.1
19  20160620  59.3  69.1  52.2  16.9
20  20160621  62.6  71.4  50.4  21.0
21  20160622  61.7  70.2  55.4  14.8
22  20160623  60.9  67.1  54.9  12.2
23  20160624  61.1  68.9  56.7  12.2
24  20160625  65.7  75.4  57.9  17.5
25  20160626  69.6  77.7  60.3  17.4
26  20160627  60.7  70.0  57.6  12.4
27  20160628  65.4  73.0  55.8  17.2
28  20160629  65.8  73.2  59.7  13.5
29  20160630  65.7  72.7  59.2  13.5

The calculations were stored into the DIFF column as planned.

Notice that you can create new columns on-the-fly at the same time when doing the calculation. Let’s test this by calculating the difference between minimum temperature (MIN) and the mean temperature of the day (TEMP).

[62]:

# Calculate difference between temp and min column values
dataFrame['DIFF_Min'] = dataFrame['TEMP'] - dataFrame['MIN']

# Print the dataframe
print(dataFrame)

    YEARMODA  TEMP   MAX   MIN  DIFF  DIFF_Min
0   20160601  65.5  73.6  54.7  18.9      10.8
1   20160602  65.8  80.8  55.0  25.8      10.8
2   20160603  68.4  77.9  55.6  22.3      12.8
3   20160604  57.5  70.9  47.3  23.6      10.2
4   20160605  51.4  58.3  43.2  15.1       8.2
5   20160606  52.2  59.7  42.8  16.9       9.4
6   20160607  56.9  65.1  45.9  19.2      11.0
7   20160608  54.2  60.4  47.5  12.9       6.7
8   20160609  49.4  54.1  45.7   8.4       3.7
9   20160610  49.5  55.9  43.0  12.9       6.5
10  20160611  54.0  62.1  41.7  20.4      12.3
11  20160612  55.4  64.2  46.0  18.2       9.4
12  20160613  58.3  68.2  47.3  20.9      11.0
13  20160614  59.7  67.8  47.8  20.0      11.9
14  20160615  63.4  70.3  49.3  21.0      14.1
15  20160616  57.8  67.5  55.6  11.9       2.2
16  20160617  60.4  70.7  55.9  14.8       4.5
17  20160618  57.3  62.8  54.0   8.8       3.3
18  20160619  56.3  59.2  54.1   5.1       2.2
19  20160620  59.3  69.1  52.2  16.9       7.1
20  20160621  62.6  71.4  50.4  21.0      12.2
21  20160622  61.7  70.2  55.4  14.8       6.3
22  20160623  60.9  67.1  54.9  12.2       6.0
23  20160624  61.1  68.9  56.7  12.2       4.4
24  20160625  65.7  75.4  57.9  17.5       7.8
25  20160626  69.6  77.7  60.3  17.4       9.3
26  20160627  60.7  70.0  57.6  12.4       3.1
27  20160628  65.4  73.0  55.8  17.2       9.6
28  20160629  65.8  73.2  59.7  13.5       6.1
29  20160630  65.7  72.7  59.2  13.5       6.5

As you can see, now we created directly a new column with the calculation. In a similar manner, you can do calculations using as many columns as you need and using any kind of math algebra (e.g. subtracttion, addition, multiplication, division, exponentiation, etc.).

We can for example convert the Fahrenheit temperatures in TEMP column into Celsius using the formula that we have seen already many times:

[63]:

# Create a new column and convert temp fahrenheit to celsius:
dataFrame['TEMP_Celsius'] = (dataFrame['TEMP'] - 32) / (9/5)

#Check output

   YEARMODA  TEMP   MAX   MIN  DIFF  DIFF_Min  TEMP_Celsius
0  20160601  65.5  73.6  54.7  18.9      10.8     18.611111
1  20160602  65.8  80.8  55.0  25.8      10.8     18.777778
2  20160603  68.4  77.9  55.6  22.3      12.8     20.222222
3  20160604  57.5  70.9  47.3  23.6      10.2     14.166667
4  20160605  51.4  58.3  43.2  15.1       8.2     10.777778

## Selecting data using indices¶

One quite common procedure in programming that you want to select only specific rows from your data and possibly apply some operations into those rows only. In Pandas there are different ways of doing this.

One common way of selecting only specific rows from your DataFrame is done via index slicing to extract part of the DataFrame.

Let’s select the first five rows and assign them to a variable called rows5.

[64]:

# Select first five rows of dataframe
rows5 = dataFrame[0:5]

print(rows5)

   YEARMODA  TEMP   MAX   MIN  DIFF  DIFF_Min  TEMP_Celsius
0  20160601  65.5  73.6  54.7  18.9      10.8     18.611111
1  20160602  65.8  80.8  55.0  25.8      10.8     18.777778
2  20160603  68.4  77.9  55.6  22.3      12.8     20.222222
3  20160604  57.5  70.9  47.3  23.6      10.2     14.166667
4  20160605  51.4  58.3  43.2  15.1       8.2     10.777778

As you can see, slicing is done in a similar manner as with normal Python lists, i.e. you specify index range you want to select inside the square brackets selection = dataFrame[start_index:stop_index].

You can also select an individual row from specific position using .loc[] indexing. Here we select all the data values from row 8.

[65]:

# Select one row using index
row8 = dataFrame.loc[8]

print(row8)

YEARMODA        2.016061e+07
TEMP            4.940000e+01
MAX             5.410000e+01
MIN             4.570000e+01
DIFF            8.400000e+00
DIFF_Min        3.700000e+00
TEMP_Celsius    9.666667e+00
Name: 8, dtype: float64

.loc[] indexing returns the values from that position as a pd.Series where the indices are actually the column names of those variables. Hence, you can access the value of an individual column by referring to its index using following format (both should work):

[66]:

#Print one attribute from the selected row
print(row8['TEMP'])

49.4

It is also possible to select multiple rows simultaniously. Here, we select only temperature values (TEMP) between indices of 5-10:

[67]:

# Select temp column values between indices 5 and 10
temps_5to10 = dataFrame.loc[5:10, 'TEMP']

print(temps_5to10)

5     52.2
6     56.9
7     54.2
8     49.4
9     49.5
10    54.0
Name: TEMP, dtype: float64

It is also possible to select multiple columns using those same indices. Here, we select TEMP and the TEMP_Celsius columns by passing them inside a list (.loc[start_index:stop_index, list_of_columns]):

[68]:

# Select temp and temp_celsius column values between indices 5 and 10
temps_5to10 = dataFrame.loc[5:10, ['TEMP', 'TEMP_Celsius']]

print(temps_5to10)

    TEMP  TEMP_Celsius
5   52.2     11.222222
6   56.9     13.833333
7   54.2     12.333333
8   49.4      9.666667
9   49.5      9.722222
10  54.0     12.222222

Of course, you can also get all values from those columns. This, can be done by simply referring to the dataFrame and inserting a list of columns inside the square brackets that you want to include.

[69]:

# Select all rows from temp and temp_celsius columns
temps_only = dataFrame[['TEMP', 'TEMP_Celsius']]

print(temps_only)

    TEMP  TEMP_Celsius
0   65.5     18.611111
1   65.8     18.777778
2   68.4     20.222222
3   57.5     14.166667
4   51.4     10.777778
5   52.2     11.222222
6   56.9     13.833333
7   54.2     12.333333
8   49.4      9.666667
9   49.5      9.722222
10  54.0     12.222222
11  55.4     13.000000
12  58.3     14.611111
13  59.7     15.388889
14  63.4     17.444444
15  57.8     14.333333
16  60.4     15.777778
17  57.3     14.055556
18  56.3     13.500000
19  59.3     15.166667
20  62.6     17.000000
21  61.7     16.500000
22  60.9     16.055556
23  61.1     16.166667
24  65.7     18.722222
25  69.6     20.888889
26  60.7     15.944444
27  65.4     18.555556
28  65.8     18.777778
29  65.7     18.722222

## Filtering and updating data¶

One really useful feature in Pandas is the ability to easily filter and select rows based on a conditional statement. The following example shows how to select rows when the Celsius temperature has been higher than 15 degrees into variable w_temps (warm temperatures).

[70]:

# Select rows with temp celsius higher than 15 degrees
w_temps = dataFrame.loc[dataFrame['TEMP_Celsius'] > 15]
print(w_temps)

    YEARMODA  TEMP   MAX   MIN  DIFF  DIFF_Min  TEMP_Celsius
0   20160601  65.5  73.6  54.7  18.9      10.8     18.611111
1   20160602  65.8  80.8  55.0  25.8      10.8     18.777778
2   20160603  68.4  77.9  55.6  22.3      12.8     20.222222
13  20160614  59.7  67.8  47.8  20.0      11.9     15.388889
14  20160615  63.4  70.3  49.3  21.0      14.1     17.444444
16  20160617  60.4  70.7  55.9  14.8       4.5     15.777778
19  20160620  59.3  69.1  52.2  16.9       7.1     15.166667
20  20160621  62.6  71.4  50.4  21.0      12.2     17.000000
21  20160622  61.7  70.2  55.4  14.8       6.3     16.500000
22  20160623  60.9  67.1  54.9  12.2       6.0     16.055556
23  20160624  61.1  68.9  56.7  12.2       4.4     16.166667
24  20160625  65.7  75.4  57.9  17.5       7.8     18.722222
25  20160626  69.6  77.7  60.3  17.4       9.3     20.888889
26  20160627  60.7  70.0  57.6  12.4       3.1     15.944444
27  20160628  65.4  73.0  55.8  17.2       9.6     18.555556
28  20160629  65.8  73.2  59.7  13.5       6.1     18.777778
29  20160630  65.7  72.7  59.2  13.5       6.5     18.722222

It is also possible to combine multiple criteria at the same time. Here, we select temperatures above 15 degrees that were recorded on the second half of June in 2016 (i.e. YEARMODA >= 20160615). Combining multiple criteria can be done with & operator (AND) or | operator (OR). Notice, that it is often useful to separate the different clauses inside the parentheses ().

[71]:

# Select rows with temp celsius higher than 15 degrees from late June 2016
w_temps2 = dataFrame.loc[(dataFrame['TEMP_Celsius'] > 15) & (dataFrame['YEARMODA'] >= 20160615)]
print(w_temps2)

    YEARMODA  TEMP   MAX   MIN  DIFF  DIFF_Min  TEMP_Celsius
14  20160615  63.4  70.3  49.3  21.0      14.1     17.444444
16  20160617  60.4  70.7  55.9  14.8       4.5     15.777778
19  20160620  59.3  69.1  52.2  16.9       7.1     15.166667
20  20160621  62.6  71.4  50.4  21.0      12.2     17.000000
21  20160622  61.7  70.2  55.4  14.8       6.3     16.500000
22  20160623  60.9  67.1  54.9  12.2       6.0     16.055556
23  20160624  61.1  68.9  56.7  12.2       4.4     16.166667
24  20160625  65.7  75.4  57.9  17.5       7.8     18.722222
25  20160626  69.6  77.7  60.3  17.4       9.3     20.888889
26  20160627  60.7  70.0  57.6  12.4       3.1     15.944444
27  20160628  65.4  73.0  55.8  17.2       9.6     18.555556
28  20160629  65.8  73.2  59.7  13.5       6.1     18.777778
29  20160630  65.7  72.7  59.2  13.5       6.5     18.722222

Now we have a subset of our DataFrame with only rows where the TEMP_Celsius is above 15 and the dates in YEARMODA column start from 15th of June.

Notice, that the index values (numbers on the left) are still showing the positions from the original DataFrame. It is possible to reset the index using reset_index() function that might be useful in some cases to be able to slice the data in a similar manner as above. By default the reset_index() would make a new column called index to keep track on the previous index which might be useful in some cases but here not, so we can omit that by passing parameter drop=True.

[72]:

# Reset index
w_temps2 = w_temps2.reset_index(drop=True)
print(w_temps2)

    YEARMODA  TEMP   MAX   MIN  DIFF  DIFF_Min  TEMP_Celsius
0   20160615  63.4  70.3  49.3  21.0      14.1     17.444444
1   20160617  60.4  70.7  55.9  14.8       4.5     15.777778
2   20160620  59.3  69.1  52.2  16.9       7.1     15.166667
3   20160621  62.6  71.4  50.4  21.0      12.2     17.000000
4   20160622  61.7  70.2  55.4  14.8       6.3     16.500000
5   20160623  60.9  67.1  54.9  12.2       6.0     16.055556
6   20160624  61.1  68.9  56.7  12.2       4.4     16.166667
7   20160625  65.7  75.4  57.9  17.5       7.8     18.722222
8   20160626  69.6  77.7  60.3  17.4       9.3     20.888889
9   20160627  60.7  70.0  57.6  12.4       3.1     15.944444
10  20160628  65.4  73.0  55.8  17.2       9.6     18.555556
11  20160629  65.8  73.2  59.7  13.5       6.1     18.777778
12  20160630  65.7  72.7  59.2  13.5       6.5     18.722222

As can be seen, now the index values goes from 0 to 12.

## Dealing with missing data¶

Next we manipulate the first five values of TEMP_Celsius in our w_temps2 DataFrame to be NaN (not-a-number). This can be done using the loc[] indexing.

[73]:

# Set temp_celsius as none in the first five rows
w_temps2.loc[:4, 'TEMP_Celsius'] = None
print(w_temps2)

    YEARMODA  TEMP   MAX   MIN  DIFF  DIFF_Min  TEMP_Celsius
0   20160615  63.4  70.3  49.3  21.0      14.1           NaN
1   20160617  60.4  70.7  55.9  14.8       4.5           NaN
2   20160620  59.3  69.1  52.2  16.9       7.1           NaN
3   20160621  62.6  71.4  50.4  21.0      12.2           NaN
4   20160622  61.7  70.2  55.4  14.8       6.3           NaN
5   20160623  60.9  67.1  54.9  12.2       6.0     16.055556
6   20160624  61.1  68.9  56.7  12.2       4.4     16.166667
7   20160625  65.7  75.4  57.9  17.5       7.8     18.722222
8   20160626  69.6  77.7  60.3  17.4       9.3     20.888889
9   20160627  60.7  70.0  57.6  12.4       3.1     15.944444
10  20160628  65.4  73.0  55.8  17.2       9.6     18.555556
11  20160629  65.8  73.2  59.7  13.5       6.1     18.777778
12  20160630  65.7  72.7  59.2  13.5       6.5     18.722222

Now we can see that we have some missing data in our DataFrame.

NOTE: Notice here that you don’t necessary need to specify the starting index if you select data starting from the beginning of the file (at index 0), hence you can leave it empty as in the example above.

Having missing data in your datafile is really common situation and typically you want to deal with it somehow. Common procedures to deal with NaN is to either remove them from the DataFrame or fill them with some value. In Pandas both of these options are really easy to do.

Let’s first see how we can remove the NoData values (i.e. clean the data) using dropna() function. Inside the function you can pass with subset parameter a list of column(s) from which the NaN values should be searched from.

[74]:

# Drop no data values based on temp_celsius column
w_temps_clean = w_temps2.dropna(subset=['TEMP_Celsius'])

print(w_temps_clean)

    YEARMODA  TEMP   MAX   MIN  DIFF  DIFF_Min  TEMP_Celsius
5   20160623  60.9  67.1  54.9  12.2       6.0     16.055556
6   20160624  61.1  68.9  56.7  12.2       4.4     16.166667
7   20160625  65.7  75.4  57.9  17.5       7.8     18.722222
8   20160626  69.6  77.7  60.3  17.4       9.3     20.888889
9   20160627  60.7  70.0  57.6  12.4       3.1     15.944444
10  20160628  65.4  73.0  55.8  17.2       9.6     18.555556
11  20160629  65.8  73.2  59.7  13.5       6.1     18.777778
12  20160630  65.7  72.7  59.2  13.5       6.5     18.722222

As you can see, as a result we now have a DataFrame without the NoData values.

Other option is to fill the NoData with some value using fillna() -function. Here we fill it with value 0.

[75]:

# Fill na values with 0
w_temps_na_filled = w_temps2.fillna(0)

print(w_temps_na_filled)

    YEARMODA  TEMP   MAX   MIN  DIFF  DIFF_Min  TEMP_Celsius
0   20160615  63.4  70.3  49.3  21.0      14.1      0.000000
1   20160617  60.4  70.7  55.9  14.8       4.5      0.000000
2   20160620  59.3  69.1  52.2  16.9       7.1      0.000000
3   20160621  62.6  71.4  50.4  21.0      12.2      0.000000
4   20160622  61.7  70.2  55.4  14.8       6.3      0.000000
5   20160623  60.9  67.1  54.9  12.2       6.0     16.055556
6   20160624  61.1  68.9  56.7  12.2       4.4     16.166667
7   20160625  65.7  75.4  57.9  17.5       7.8     18.722222
8   20160626  69.6  77.7  60.3  17.4       9.3     20.888889
9   20160627  60.7  70.0  57.6  12.4       3.1     15.944444
10  20160628  65.4  73.0  55.8  17.2       9.6     18.555556
11  20160629  65.8  73.2  59.7  13.5       6.1     18.777778
12  20160630  65.7  72.7  59.2  13.5       6.5     18.722222

As a result we now have a DataFrame where NoData values are filled with value 0.00000.

Warning: In many cases filling the data with a specific value might be dangerous because you end up modifying the actual data that might affect the results of your analysis. For example in the example above we would have dramatically changed the mean Celsius temperature because the 0 values are dramatically decreasing the average temperature of the month. Hence, use filling carefully.

## Sorting data¶

Quite often it is useful to be able to sort your data (descending/ascending) based on values in some column This can be easily done with Pandas using sort_values(by='YourColumnName') -function.

Let’s first sort the values on ascending order based on the TEMP column:

[76]:

# Sort dataframe, ascending
sorted_temp_a = dataFrame.sort_values(by='TEMP')

print(sorted_temp_a)

    YEARMODA  TEMP   MAX   MIN  DIFF  DIFF_Min  TEMP_Celsius
8   20160609  49.4  54.1  45.7   8.4       3.7      9.666667
9   20160610  49.5  55.9  43.0  12.9       6.5      9.722222
4   20160605  51.4  58.3  43.2  15.1       8.2     10.777778
5   20160606  52.2  59.7  42.8  16.9       9.4     11.222222
10  20160611  54.0  62.1  41.7  20.4      12.3     12.222222
7   20160608  54.2  60.4  47.5  12.9       6.7     12.333333
11  20160612  55.4  64.2  46.0  18.2       9.4     13.000000
18  20160619  56.3  59.2  54.1   5.1       2.2     13.500000
6   20160607  56.9  65.1  45.9  19.2      11.0     13.833333
17  20160618  57.3  62.8  54.0   8.8       3.3     14.055556
3   20160604  57.5  70.9  47.3  23.6      10.2     14.166667
15  20160616  57.8  67.5  55.6  11.9       2.2     14.333333
12  20160613  58.3  68.2  47.3  20.9      11.0     14.611111
19  20160620  59.3  69.1  52.2  16.9       7.1     15.166667
13  20160614  59.7  67.8  47.8  20.0      11.9     15.388889
16  20160617  60.4  70.7  55.9  14.8       4.5     15.777778
26  20160627  60.7  70.0  57.6  12.4       3.1     15.944444
22  20160623  60.9  67.1  54.9  12.2       6.0     16.055556
23  20160624  61.1  68.9  56.7  12.2       4.4     16.166667
21  20160622  61.7  70.2  55.4  14.8       6.3     16.500000
20  20160621  62.6  71.4  50.4  21.0      12.2     17.000000
14  20160615  63.4  70.3  49.3  21.0      14.1     17.444444
27  20160628  65.4  73.0  55.8  17.2       9.6     18.555556
0   20160601  65.5  73.6  54.7  18.9      10.8     18.611111
24  20160625  65.7  75.4  57.9  17.5       7.8     18.722222
29  20160630  65.7  72.7  59.2  13.5       6.5     18.722222
1   20160602  65.8  80.8  55.0  25.8      10.8     18.777778
28  20160629  65.8  73.2  59.7  13.5       6.1     18.777778
2   20160603  68.4  77.9  55.6  22.3      12.8     20.222222
25  20160626  69.6  77.7  60.3  17.4       9.3     20.888889

Of course, it is also possible to sort them in descending order with ascending=False parameter:

[77]:

# Sort dataframe, descending
sorted_temp_d = dataFrame.sort_values(by='TEMP', ascending=False)
print(sorted_temp_d)

    YEARMODA  TEMP   MAX   MIN  DIFF  DIFF_Min  TEMP_Celsius
25  20160626  69.6  77.7  60.3  17.4       9.3     20.888889
2   20160603  68.4  77.9  55.6  22.3      12.8     20.222222
1   20160602  65.8  80.8  55.0  25.8      10.8     18.777778
28  20160629  65.8  73.2  59.7  13.5       6.1     18.777778
29  20160630  65.7  72.7  59.2  13.5       6.5     18.722222
24  20160625  65.7  75.4  57.9  17.5       7.8     18.722222
0   20160601  65.5  73.6  54.7  18.9      10.8     18.611111
27  20160628  65.4  73.0  55.8  17.2       9.6     18.555556
14  20160615  63.4  70.3  49.3  21.0      14.1     17.444444
20  20160621  62.6  71.4  50.4  21.0      12.2     17.000000
21  20160622  61.7  70.2  55.4  14.8       6.3     16.500000
23  20160624  61.1  68.9  56.7  12.2       4.4     16.166667
22  20160623  60.9  67.1  54.9  12.2       6.0     16.055556
26  20160627  60.7  70.0  57.6  12.4       3.1     15.944444
16  20160617  60.4  70.7  55.9  14.8       4.5     15.777778
13  20160614  59.7  67.8  47.8  20.0      11.9     15.388889
19  20160620  59.3  69.1  52.2  16.9       7.1     15.166667
12  20160613  58.3  68.2  47.3  20.9      11.0     14.611111
15  20160616  57.8  67.5  55.6  11.9       2.2     14.333333
3   20160604  57.5  70.9  47.3  23.6      10.2     14.166667
17  20160618  57.3  62.8  54.0   8.8       3.3     14.055556
6   20160607  56.9  65.1  45.9  19.2      11.0     13.833333
18  20160619  56.3  59.2  54.1   5.1       2.2     13.500000
11  20160612  55.4  64.2  46.0  18.2       9.4     13.000000
7   20160608  54.2  60.4  47.5  12.9       6.7     12.333333
10  20160611  54.0  62.1  41.7  20.4      12.3     12.222222
5   20160606  52.2  59.7  42.8  16.9       9.4     11.222222
4   20160605  51.4  58.3  43.2  15.1       8.2     10.777778
9   20160610  49.5  55.9  43.0  12.9       6.5      9.722222
8   20160609  49.4  54.1  45.7   8.4       3.7      9.666667

## Rounding and finding unique values¶

It is possible to round values easily by using round() function. Here we round the Celsius temperatures with 0-decimals

[78]:

# Create new column, and round celsius values
dataFrame['Celsius_rounded'] = dataFrame['TEMP_Celsius'].round(0)
print(dataFrame)

    YEARMODA  TEMP   MAX   MIN  DIFF  DIFF_Min  TEMP_Celsius  Celsius_rounded
0   20160601  65.5  73.6  54.7  18.9      10.8     18.611111             19.0
1   20160602  65.8  80.8  55.0  25.8      10.8     18.777778             19.0
2   20160603  68.4  77.9  55.6  22.3      12.8     20.222222             20.0
3   20160604  57.5  70.9  47.3  23.6      10.2     14.166667             14.0
4   20160605  51.4  58.3  43.2  15.1       8.2     10.777778             11.0
5   20160606  52.2  59.7  42.8  16.9       9.4     11.222222             11.0
6   20160607  56.9  65.1  45.9  19.2      11.0     13.833333             14.0
7   20160608  54.2  60.4  47.5  12.9       6.7     12.333333             12.0
8   20160609  49.4  54.1  45.7   8.4       3.7      9.666667             10.0
9   20160610  49.5  55.9  43.0  12.9       6.5      9.722222             10.0
10  20160611  54.0  62.1  41.7  20.4      12.3     12.222222             12.0
11  20160612  55.4  64.2  46.0  18.2       9.4     13.000000             13.0
12  20160613  58.3  68.2  47.3  20.9      11.0     14.611111             15.0
13  20160614  59.7  67.8  47.8  20.0      11.9     15.388889             15.0
14  20160615  63.4  70.3  49.3  21.0      14.1     17.444444             17.0
15  20160616  57.8  67.5  55.6  11.9       2.2     14.333333             14.0
16  20160617  60.4  70.7  55.9  14.8       4.5     15.777778             16.0
17  20160618  57.3  62.8  54.0   8.8       3.3     14.055556             14.0
18  20160619  56.3  59.2  54.1   5.1       2.2     13.500000             13.0
19  20160620  59.3  69.1  52.2  16.9       7.1     15.166667             15.0
20  20160621  62.6  71.4  50.4  21.0      12.2     17.000000             17.0
21  20160622  61.7  70.2  55.4  14.8       6.3     16.500000             16.0
22  20160623  60.9  67.1  54.9  12.2       6.0     16.055556             16.0
23  20160624  61.1  68.9  56.7  12.2       4.4     16.166667             16.0
24  20160625  65.7  75.4  57.9  17.5       7.8     18.722222             19.0
25  20160626  69.6  77.7  60.3  17.4       9.3     20.888889             21.0
26  20160627  60.7  70.0  57.6  12.4       3.1     15.944444             16.0
27  20160628  65.4  73.0  55.8  17.2       9.6     18.555556             19.0
28  20160629  65.8  73.2  59.7  13.5       6.1     18.777778             19.0
29  20160630  65.7  72.7  59.2  13.5       6.5     18.722222             19.0

Now we have rounded our Celsius temperatures. Sometimes it is useful to extract the unique values that you have in your column. We can do that by using unique_values() -function:

[79]:

# Get unique celsius values
unique = dataFrame['Celsius_rounded'].unique()
unique

[79]:

array([19., 20., 14., 11., 12., 10., 13., 15., 17., 16., 21.])

As a result we get an array of unique values in that column.

Note: Sometimes if you have a long list of unique values, you don’t necessary see all the unique values directly as IPython hides them. It is, however, possible to see all those values by printing them as a list:

[80]:

# unique values as list
print(list(unique))

[19.0, 20.0, 14.0, 11.0, 12.0, 10.0, 13.0, 15.0, 17.0, 16.0, 21.0]

How many days with unique mean temperature did we have in June 2016? We can check that!

[81]:

# Number of unique values
uniq_temp_days = len(unique)
print("There were", uniq_temp_days, "days with unique mean temperatures in June 2016.")

There were 11 days with unique mean temperatures in June 2016.

## Writing data¶

Lastly, it is of course important to be able to write the data that you have analyzed into your computer. This is really handy in Pandas as it supports many different data formats by default (see more info here <pandas-overview.html#supports-data-read-write-from-multiple-formats>__). The most typical output format by far is CSV file. Function to_csv() can be used to easily save your data in CSV format.

Let’s first save the data from our data DataFrame into a file called Kumpula_temp_results_June_2016.csv .

[82]:

# define output filename
output_fp = "Kumpula_temps_June_2016.csv"

# Save dataframe to csv
dataFrame.to_csv(output_fp, sep=',')

Nice, now we have the data from our DataFrame saved to a file:

As you can see, the first value in the datafile contains now the index value of the rows. There are also quite many decimals present in the new columns that we created. Let’s deal with these and save the temperature values from w_temps DataFrame without the index and with only 1 decimal in the floating point numbers.

[83]:

output_fp2 = "Kumpula_temps_above15_June_2016.csv"
w_temps.to_csv(output_fp2, sep=',', index=False, float_format="%.1f")

Omitting the index can be with index=False parameter. Specifying how many decimals should be written can be done with float_format -parameter where text %.1f defines Pandas to use 1 decimals in all columns when writing the data to a file (changing the value 1 to 2 would write 2 decimals etc.)

As a results you have a “cleaner” output file without the index column, and with only 1 decimal for floating point numbers.

It is quite common that people (especially non-programmers) want you to deliver data in MS Excel format. Saving DataFrame into Excel is also straightforward in Pandas. First, you need to initialize a specific ExcelWriter object, and then you specify the filename and the spreadsheet name where you want to save the DataFrame. Optionally, you can also omit the index and specify the float formatting as in our earlier examples:

[84]:

# Specify output filename
excel_output_fp = "Kumpula_temps_above15_June_2016.xlsx"

# Initialize ExcelWriter
writer = pd.ExcelWriter(excel_output_fp)

#Write data to excel
w_temps.to_excel(writer, sheet_name="Kumpula_temperatures", index=False, float_format="%.1f")

As a result you have the DataFrame in Excel format in your working directory:

That’s it for this week. We will dive deeper into data analysis with Pandas in the following Lesson. Next, you can continue with Exercise 5 (for Pandas).


text:
• 0 Vote(s) - 0 Average
• 1
• 2
• 3
• 4
• 5
 Rational sums of inverse powers of fixed points of e jaydfox Long Time Fellow Posts: 440 Threads: 31 Joined: Aug 2007 11/20/2007, 07:55 PM (This post was last modified: 11/21/2007, 01:24 AM by jaydfox.) This post doesn't have much if anything to do with tetration, but I discovered it while analyzing logarithms at the fixed points. I had mentioned this previously: http://math.eretrandre.org/tetrationforu...php?tid=59 The fixed points of e are irrational. However, the sums of the inverse n-th powers are rational. For example, the sum of the inverse third powers of all the fixed points of e is -1/2: $\sum_{k=0}^{\infty} \left(\frac{1}{\hspace{5}(c_k)^3\hspace{5}}+\frac{1}{\hspace{5} (\overline{c_k})^3 \hspace{5}}\right)=\frac{-1}{2}$ Note: Here, $c_k$ is the fixed point in the kth branch of the natural logarithm, i.e., $\ln(z)+2\pi k i$. If there were a single fixed point in the 0th branch of the natural logarithm, we could use $c_{-k}=\overline{c_k}$ and run our sum from negative infinity to positive. Alas, with two fixed points in the 0th branch, I thought it clearer to use complex conjugates, but perhaps we could still run the sum from negative to positive infinity if we had a way to account for both points in the 0th branch. Continuing with a couple more examples, the sum of the inverse fifth powers is 3/8. The sum of the inverse eighth powers is -29/630. Well, as it turns out, the denominators roughly increase as factorials. For example, the denominator of the 7th sum (i.e., the sum of the inverse 8th powers) is 630. This is 7!/8. The denominator of the 10th sum is 10!/3. So, here's a list of the numerators for the first 26 sums (inverse 2nd to 27th powers), when using the factorials as the denominators (starting with 1!, not 0!): Code:-1 -1 2 9 -6 -155 -232 3969 20870 -118779 -1655028 1610257 1436977220 522358005 -13332842416 -138189937791 1128293525646 29219838555781 -17274118159180 -5993074252801839 -38541972209299966 1179892974640047669 19460524014823618872 -187430579164971912575 -7757827302592891768426 -3443729183055238386555 I've currently got a program running to calculate the first 100,000 fixed points to 5120 bits of precision, to allow me to calculate the first few hundred sums. I'll then use continued fraction expansion, and look for the first "very large" number, which indicates that the previous fraction would most likely be exact. Using only the first 5,000 fixed points, I had typically seen situations where the subsequent convergent fraction would have a denominator with three to four times as many digits, e.g., 14 digits versus 50. I can't provide a specific example at the moment because SAGE is still crunching numbers (takes a good fraction of a second to calculate a fixed point to the desired precision, so 100,000 of them will take a good fraction of a day [Edit: It took 47200 seconds!]). With 100,000 digits, I'm hoping to make the difference something like 14 digits versus 60 or 70. Anyway, in the meantime, I wanted to try to figure out how to calculate the numerators. It seems to me that they deserve their own Sloane sequence, considering how surprising it was (to me) to get rational sums. ~ Jay Daniel Fox « Next Oldest | Next Newest »

 Messages In This Thread Rational sums of inverse powers of fixed points of e - by jaydfox - 11/20/2007, 07:55 PM RE: Rational sums of inverse powers of fixed points of e - by jaydfox - 11/20/2007, 08:11 PM RE: Rational sums of inverse powers of fixed points of e - by Gottfried - 11/20/2007, 08:14 PM RE: Rational sums of inverse powers of fixed points of e - by jaydfox - 11/20/2007, 08:31 PM RE: Rational sums of inverse powers of fixed points of e - by jaydfox - 11/20/2007, 08:43 PM RE: Rational sums of inverse powers of fixed points of e - by jaydfox - 11/20/2007, 09:31 PM RE: Rational sums of inverse powers of fixed points of e - by jaydfox - 11/21/2007, 01:15 AM RE: Rational sums of inverse powers of fixed points of e - by jaydfox - 11/21/2007, 08:14 AM RE: Rational sums of inverse powers of fixed points of e - by Gottfried - 11/21/2007, 08:50 AM RE: Rational sums of inverse powers of fixed points of e - by jaydfox - 11/21/2007, 09:35 AM RE: Rational sums of inverse powers of fixed points of e - by Gottfried - 11/21/2007, 12:52 PM RE: Rational sums of inverse powers of fixed points of e - by jaydfox - 11/21/2007, 06:20 PM RE: Rational sums of inverse powers of fixed points of e - by Gottfried - 11/22/2007, 06:25 PM RE: Rational sums of inverse powers of fixed points of e - by jaydfox - 11/22/2007, 08:32 PM

 Possibly Related Threads... Thread Author Replies Views Last Post tetration from alternative fixed point sheldonison 22 29,203 12/24/2019, 06:26 AM Last Post: Daniel Thoughts on hyper-operations of rational but non-integer orders? VSO 2 647 09/09/2019, 10:38 PM Last Post: tommy1729 Inverse Iteration Xorter 3 2,568 02/05/2019, 09:58 AM Last Post: MrFrety Inverse super-composition Xorter 11 13,189 05/26/2018, 12:00 AM Last Post: Xorter Are tetrations fixed points analytic? JmsNxn 2 3,015 12/14/2016, 08:50 PM Last Post: JmsNxn the inverse ackerman functions JmsNxn 3 5,975 09/18/2016, 11:02 AM Last Post: Xorter Rational operators (a {t} b); a,b > e solved JmsNxn 30 40,026 09/02/2016, 02:11 AM Last Post: tommy1729 Removing the branch points in the base: a uniqueness condition? fivexthethird 0 1,573 03/19/2016, 10:44 AM Last Post: fivexthethird Inverse power tower functions tommy1729 0 1,910 01/04/2016, 12:03 PM Last Post: tommy1729 Derivative of exp^[1/2] at the fixed point? sheldonison 10 10,518 01/01/2016, 03:58 PM Last Post: sheldonison

Users browsing this thread: 1 Guest(s)

format: plain


text:
## CryptoDB

### Paper: Prolific Codes with the Identifiable Parent Property

Authors: Simon R. Blackburn Tuvi Etzion Siaw-Lynn Ng URL: http://eprint.iacr.org/2007/276 Search ePrint Search Google Let C be a code of length n over an alphabet of size q. A word d is a descendant of a pair of codewords x,y if d_i lies in \{x_i ,y_i \} for 1 <= i <= n. A code C is an identifiable parent property (IPP) code if the following property holds. Whenever we are given C and a descendant d of a pair of codewords in C, it is possible to determine at least one of these codewords. The paper introduces the notion of a prolific IPP code. An IPP code is prolific if all q^n words are descendants. It is shown that linear prolific IPP codes fall into three infinite (trivial') families, together with a single sporadic example which is ternary of length 4. There are no known examples of prolific IPP codes which are not equivalent to a linear example: the paper shows that for most parameters there are no prolific IPP codes, leaving a relatively small number of parameters unsolved. In the process the paper obtains upper bounds on the size of a (not necessarily prolific) IPP code which are better than previously known bounds.
##### BibTeX
@misc{eprint-2007-13557,
title={Prolific Codes with the Identifiable Parent Property},
booktitle={IACR Eprint archive},
keywords={combinatorial cryptography},
url={http://eprint.iacr.org/2007/276},
note={ s.blackburn@rhul.ac.uk 13712 received 18 Jul 2007},
author={Simon R. Blackburn and Tuvi Etzion and Siaw-Lynn Ng},
year=2007
}
`


text:
## Quantum Wronskian approach to six-point gluon scattering amplitudes at strong coupling

### Abstract

We study the six-point gluon scattering amplitudes in N $$\mathcal{N}$$ = 4 super Yang-Mills theory at strong coupling based on the twisted ℤ 4 -symmetric integrable model. The lattice regularization allows us to derive the associated thermodynamic Bethe ansatz (TBA) equations as well as the functional relations among the Q-/T-/Y-functions. The quantum Wronskian relation for the Q-/T-functions plays an important role in determining a series of the expansion coefficients of the T-/Y-functions around the UV limit, including the dependence on the twist parameter. Studying the CFT limit of the TBA equations, we derive the leading analytic expansion of the remainder function for the general kinematics around the limit where the dual Wilson loops become regular-polygonal. We also compare the rescaled remainder functions at strong coupling with those at two, three and four loops, and find that they are close to each other along the trajectories parameterized by the scale parameter of the integrable model

Year: 2014
DOI identifier: 10.1007/JHEP08(2014)162
OAI identifier: oai:www.openaccessrepository.it:8215

### Suggested articles

To submit an update or takedown request for this paper, please submit an Update/Correction/Removal Request.


text:
# sine of angle of triangle

The cosines law allows to express the cosine of an angle of triangle through the sides:

 $\displaystyle\cos\alpha=\frac{b^{2}+c^{2}-a^{2}}{2bc}.$ (1)

Substituting this to the “fundamental formula of trigonometry”,

 $\sin^{2}\alpha+\cos^{2}\alpha\;=\;1,$

we can calculate as follows:

 $\displaystyle\sin\alpha$ $\displaystyle\;=\;+\sqrt{1-\left(\frac{b^{2}+c^{2}-a^{2}}{2bc}\right)^{2}}$ $\displaystyle\;=\;\sqrt{\frac{(2bc)^{2}-(b^{2}+c^{2}-a^{2})^{2}}{(2bc)^{2}}}$ $\displaystyle\;=\;\frac{\sqrt{(2bc+b^{2}+c^{2}-a^{2})(2bc-b^{2}-c^{2}+a^{2})}}% {2bc}$ $\displaystyle\;=\;\frac{\sqrt{[(b+c)^{2}-a^{2}][a^{2}-(b-c)^{2}]}}{2bc}$ $\displaystyle\;=\;\frac{\sqrt{(b+c+a)(b+c-a)(a+b-c)(a-b+c)}}{2bc}$

Thus we have the beautiful formula

 $\sin\alpha\;=\;\frac{\sqrt{(-a\!+\!b\!+\!c)(a\!-\!b\!+\!c)(a\!+\!b\!-\!c)(a\!+% \!b\!+\!c)}}{2bc}.$

Substituting (1) similarly to the general formula for the sine of half-angle (http://planetmath.org/GoniometricFormulae)

 $\sin\frac{\alpha}{2}=\pm\sqrt{\frac{1-\cos\alpha}{2}},$

one can obtain the formula

 $\sin\frac{\alpha}{2}\;=\;\sqrt{\frac{(a\!-\!b\!+\!c)(a\!+\!b\!-\!c)}{4bc}}.$
Title sine of angle of triangle SineOfAngleOfTriangle 2013-03-22 18:27:16 2013-03-22 18:27:16 pahio (2872) pahio (2872) 5 pahio (2872) Derivation msc 51M04 DifferenceOfSquares


text:
Cheap and Secure Web Hosting Provider : See Now

# [Solved]: How to modify semantic actions when removing left-recursion from a grammer

, ,
Problem Detail:

Is there any algorithm that tells us how to modify semantic actions associated with a left-recursive grammar? For example, we have the following grammar, and its associated semantic actions:

$S \rightarrow id = expr$ { S.s = expr.size }

S $\rightarrow$ if expr then $S_1$ else $S_2$ { $S_1.t = S.t + 2;$ $S_2.t = S.t + 2;$ $S.s = expr.size + S_1.size + S_2.size + 2;$ }

S $\rightarrow$ while expr do $S_1$ { $S_1.t = S.t + 4;$ $S.s = expr.size + S_1.s + 1;$ }

S $\rightarrow$ $S_1$ ; $S_2$ {$S_1.t = S_2.t = S.t;$ $S.s = S_1.s + S_2.s;$ }

Clearly the non-recursive version of the grammer is:

S $\rightarrow$ id = expr T

S $\rightarrow$ if expr then $S_1$ else $S_2$ T

S $\rightarrow$ while expr do $S_1$ T

T $\rightarrow$ ; $S_2$ T

T $\rightarrow$ $\epsilon$

But we also need to change the semantic actions accordingly. Any ideas how this can be done?

From what I have discovered, there is no general technique to modify the semantic actions while removing left-recursion. Instead, the best method is to take a representative example, draw its parse tree, and then checking which semantic actions give us the same result as the previous grammar.


text:
# Gibbs Free Energy Formula

Willard Gibbs defined a function known as Gibbs energy (G), to calculate the changes in entropy and enthalpy values. The maximum work done is the amount of energy produced, given by the decrease in the thermodynamic property called Gibbs free energy.

Gibbs Free energy formula is given below.

$\Delta G=\Delta H-(T\times \Delta S)$

ΔG=Gibbs free energy

ΔH = change in enthalpy

ΔS=change in entropy

T=temperature

Gibbs free energy has extensive property and a function with a single value.

Example 1

Determine the standard Gibbs free energy change for the creation of methane from carbon and hydrogen at 298 K. Given ΔH = -74.9KJ/mol and ΔS = -80.7J/K.mol

Solution

change in enthalpy,ΔH = -74.9 KJ/mol

change in entropy,ΔS = -80.7J/Kmol

ΔS = -0.0807 KJ/Kmol (1KJ=1000J)

We have the equation

ΔG = ΔH – T ΔS

Substitute the above values in this equation

ΔG =( -74.9 ) – (298 ) (-0.0807)

ΔG = -50.9KJ/mole

Example 2

Determine the standard free energy change for the following reaction at 25oC.

N2 + 3H2 —> 2NH3

Given ΔH and ΔS are -91.8KJ and -198.0J/K

Solution

We have an equation

ΔG = ΔH – T ΔS

change in enthalpy,ΔH = -91.8 KJ/mol

change in entropy,ΔS = -198.0J/Kmol

ΔS = -0.198 KJ/Kmol (1KJ=1000J)

Substitute the above values in this equation

ΔG = (-91.8 )– (298 ) (-0.1980)

ΔG = -32.8KJ

To refer more problems and questions on Gibbs Free energy Formula, please visit Byju’s.com


text:
# Topological defect

(Redirected from Soliton (topological))
See also topological excitations and the base concepts: topology, topological manifold, differential equations, quantum mechanics and condensed matter physics.

In mathematics and physics, a topological soliton or a topological defect is a solution of a system of partial differential equations or of a quantum field theory homotopically distinct from the vacuum solution.

## Overview

A topological defect can be proven to exist[when?] because the boundary conditions entail the existence of homotopically distinct solutions. Typically, this occurs because the boundary on which the conditions are specified has a non-trivial homotopy group which is preserved in differential equations; the solutions to the differential equations are then topologically distinct, and are classified by their homotopy class. Topological defects are not only stable against small perturbations, but cannot decay or be undone or be de-tangled, precisely because there is no continuous transformation that will map them (homotopically) to a uniform or "trivial" solution.

## Examples

Topological defects occur in partial differential equations and are believed[according to whom?] to drive[how?] phase transitions in condensed matter physics.

The authenticity[further explanation needed] of a topological defect depends on the nature of the vacuum in which the system will tend towards if infinite time elapses; false and true topological defects can be distinguished if the defect is in a false vacuum and a true vacuum, respectively.[clarification needed]

### Solitary wave PDEs

Examples include the soliton or solitary wave which occurs in exactly solvable models, such as

### Lambda transitions

Main article: Lambda transition

Topological defects in lambda transition universality class[clarification needed] systems including:

### Cosmological defects

Topological defects, of the cosmological type, are extremely high-energy[clarification needed] phenomena[why?], which are deemed impractical to produce[according to whom?] in Earth-bound physics experiments. Observation of proposed topological defects that formed during the universe's formation could theoretically be observed without significant energy expenditure, however.

In the Big Bang theory, the universe cools from an initial hot, dense state triggering a series of phase transitions[which?] much like what happens in condensed-matter systems.[clarification needed] Certain[which?] grand unified theories predict the formation of stable topological defects in the early universe[why?], during these phase transitions.

#### Symmetry breakdown

Depending[how?] on the nature of symmetry breakdown, various solitons are believed to have formed in the early universe according to the Kibble-Zurek mechanism. The well-known topological defects are:

Other more complex hybrids of these defect types are also possible.

As the universe expanded and cooled, symmetries in the laws of physics began breaking down in regions that spread at the speed of light[clarification needed]; topological defects occur at the boundaries of adjacent regions[how?]. The matter composing these boundaries is in the an ordered phase, which persists after the phase transition to the disordered phase is completed for the surrounding regions.

### Biochemistry

Defects[which?] have also been found in biochemistry, notably in the process of protein folding.

### Formal classification

An ordered medium is defined as a region of space described by a function f(r) that assigns to every point in the region an order parameter, and the possible values of the order parameter space constitute an order parameter space. The homotopy theory of defects uses the fundamental group of the order parameter space of a medium to discuss the existence, stability and classifications of topological defects in that medium.[1]

Suppose R is the order parameter space for a medium, and let G be a Lie group of transformations on R. Let H be the symmetry subgroup of G for the medium. Then, the order parameter space can be written as the Lie group quotient[2] R=G/H.

If G is a universal cover for G/H then, it can be shown[2] that πn (G/H)=πn-1 (H), where πi denotes the i-th homotopy group.

Various types of defects in the medium can be characterized by elements of various homotopy groups of the order parameter space. For example, (in three dimensions), line defects correspond to elements of π1 (R), point defects correspond to elements of π2 (R), textures correspond to elements of π3 (R). However, defects which belong to the same conjugacy class of π1 (R) can be deformed continuously to each other,[1] and hence, distinct defects correspond to distinct conjugacy classes.

Poénaru and Toulouse showed that[3] crossing defects get entangled if and only if they are members of separate conjugacy classes of π1 (R).

## Observation

Topological defects have not been observed by astronomers, however certain types are not compatible with current observations. In particular, if domain walls and monopoles were present in the observable universe, they would result in significant deviations[which?] from what astronomers can see.

Because of these observations, the formation of defects within the observable universe is highly constrained, requiring special circumstances (see: inflation). On the other hand, cosmic strings have been suggested as providing the initial 'seed'-gravity around which the large-scale structure of the cosmos of matter has condensed. Textures are similarly benign[clarification needed]. In late 2007, a cold spot in the cosmic microwave background provided evidence of a possible texture.[4]

## Condensed matter

Classes of stable defects in biaxial nematics

In condensed matter physics, the theory of homotopy groups provides a natural setting for description and classification of defects in ordered systems.[1] Topological methods have been used in several problems of condensed matter theory. Poénaru and Toulouse used topological methods to obtain a condition for line (string) defects in liquid crystals can cross each other without entanglement. It was a non-trivial application of topology that first led to the discovery of peculiar hydrodynamic behavior in the A-phase of superfluid helium-3.[1]

### Stable defects

Homotopy theory is deeply related to the stability of topological defects. In the case of line defect, if the closed path can be continuously deformed into one point, the defect is not stable, and otherwise, it is stable.

Unlike in cosmology and field theory, topological defects in condensed matter have been experimentally observed.[5] Ferromagnetic materials have regions of magnetic alignment separated by domain walls. Nematic and bi-axial nematic liquid crystals display a variety of defects including monopoles, strings, textures etc.[1]

## Images

A static solution to ${\displaystyle {\mathcal {L}}=\partial _{\mu }\phi \partial ^{\mu }\phi -(\phi ^{2}-1)^{2}}$ in 1+1 dimensional spacetime.
A soliton and an antisoliton colliding with velocities ±sinh(0.05) and annihilating.


text:
# How to make a single action run for two objects in GAME MAKER?

Think of a traffic light that only turns green or red.

If it is green, the next car passing through the detection point (pink square) will be directed to the green path and will cause the traffic light to turn red.

This way the next car that passes, will be directed to the red path, also making the green light, and so on.

Let's assume that two cars are in the same place and at the same speed and thus collide with the pink square at the same time. How can we make both directions to the same path be green or red and so that the light of the traffic light changes only once?

Considering "obj_BolaAzul" as "obj_blueCar", "obj_BolaRoxa" as "obj_purpleCar" and "obj_Cannon" as "obj_trafficLight".

The codes are basically:

obj_traficLight collision with obj_blueCar

if greenLight==true{
obj_blueCar.move_towards_point(x+1,y,manSpeed); //go to right
testGreen=true;
}

if redLight==true{
obj_blueCar.move_towards_point(x-1,y,manSpeed); //go to left
testRed=true;
}

if testGreen==true{
greenLight=false;
redLight=true
}

if testRed==false{
redLight=false;
greenLight=true
}

There are more things besides in code, but it has no relation to the problem.

I'm sorry again for the translation errors, I'm still not speaking English.

• I'm not sure if that's available on GMS1, but have you taken a look at scripts? Scripts allows you to use the same piece of code for multiple objects, it's like how methods works in C# – Steven Jul 30 '18 at 6:07

The solution is to add a value to a variable x after the collision of any of the cars, so that it will only modify the traffic light after all cars have passed the traffic light.

Then you makes equal the value of the variable that modifies the semaphore y to that of the variable x in the step event.

In code:

collision event:

if y==10{
car to red way;
x=20;
}

if y==20{
car to green way;
x=10;
}

----------------------------------------------------------------------------------------------
step event:

if x==10{
y=10;
}

if x==20{
y=20;
}


text:
# How to determine if this function is one-to-one, onto, or bijection?

I have a function $f_2: \mathbb Z \times \mathbb Z \to \mathbb Z$ defined by $f_2(m,n)=m^2+n$.

How do I know if it is one-to-one, onto or both?

What I am most confused about is what $\mathbb Z \times \mathbb Z \to \mathbb Z$ means and how that is different from just $\mathbb Z \to \mathbb Z$.

I know one-to-one means every $x$ has a unique $y$ and onto means for all $y$, there exists an $x$ such that $f(x)=y$.

Thanks!

-
Your explanation of one-to-one is very misleading (I cannot make out if you understood the definition of the term or not). A function $f: X \to Y$ is one-to-one if $f(x_1) = f(x_2) \implies x_1 = x_2$ for all $x_1, x_2 \in X$. You can think of it as: distinct $x$'s in $X$ are mapped to distinct images in $Y$. –  Srivatsan Oct 21 '11 at 14:40
That's exactly what I meant. You made it much clearer though, thanks! –  switz Oct 21 '11 at 14:42
For one-to-one, informally, you could say that for any $y$, there is at most one $x$. –  André Nicolas Oct 21 '11 at 18:30

This notation means that the "x" in your function is a pair of integers $(m,n)$.

So the question is: Do you know two pairs $(m_1,n_1)$ and $(m_2,n_2)$ of integers that give the same $m_1^2+n_1=m_2^2+n_2$?

The two pairs count as distinct if at least one element changes.

1. one-to-one?

Choose two different $m$s and try to find $n$s such that the image of the function is the same for the two pairs.

1. onto?

Try $m=0$.

-
Okay, that makes sense. So does that mean it will be onto? I'm not sure how to actually prove which one it is. –  switz Oct 21 '11 at 14:36

For "onto" you need to answer this: Given any integer $y$, can you find a pair $(m,n)$ so that $m^2+n = y$?

-
m = 0, n = y -- so yes. therefore it is onto. –  switz Oct 21 '11 at 14:50


text:
# Applying hybrid-pi model of an npn-BJT to a pnp BJT in small signal analysis

When doing the small signal analysis of a circuit containing a pnp BJT connected to either the emitter or collector (or base?) of a npn BJT, is it possible to apply the hybrid-pi model for the npn-BJT and apply a minus sign to the current as in -gmVbe since current flows opposite?

simulate this circuit – Schematic created using CircuitLab

• I1 is 19 amps? Dang, that's going to produce some seriously high voltages in that circuit. – alex.forencich Nov 9 '13 at 2:16

## 1 Answer

simulate this circuit – Schematic created using CircuitLab

The model of each transistor is not dependent on what it will be connected.

Yes it is possible, but you must have into account the sign of the currents and which voltage controls the collector source current, Vbe or Veb.

You can take the NPN model and apply Vbe = -Veb (that's by definition). Then, on the equations for the NPN model you'll have ib = -Veb/rb, ic = -gm Veb and ie = ib + ie;

But now all currents are negative and the arrows pointing against the flow. Since that's not intuitive and we're free to choose the signs, we consider positive the currents that flow outwards and turn around the current source. That translates to the equations to multiply the right members of the equations by -1. This way, you have the PNP model.

As you see, It's a matter of avoiding minus signs. Just like in large signal analysis we say VEB = 0.6V instead VBE = -0.6V for a PNP transistor.


text:
Donor challenge: Your generous donation will be matched 2-to-1 right now. Your $5 becomes$15! Dear Internet Archive Supporter,. I ask only. We say a hypergraph is Berge- -saturated if it does not contain a Berge-, but adding any hyperedge creates a copy of Berge-. The -uniform. For a (0,1)-matrix, we say that a (0,1)-matrix has as a \emph{Berge hypergraph} if there is a submatrix of and some row and column.

 Author: Arakus Duktilar Country: Bangladesh Language: English (Spanish) Genre: Business Published (Last): 15 December 2009 Pages: 500 PDF File Size: 11.97 Mb ePub File Size: 12.34 Mb ISBN: 588-7-96476-697-9 Downloads: 84558 Price: Free* [*Free Regsitration Required] Uploader: Dajin

Generalization of graph theory.

## Hypergraph

Conversely, any bipartite graph with fixed parts and no unconnected nodes in the second part represents some hypergraph in the manner described above.

A hypergraph is also called a set system or a family of sets drawn from the universal set X. Hypergraphs have been extensively used in machine learning tasks as the data model and classifier regularization mathematics. By augmenting a class of hypergraphs with replacement rules, graph grammars can be generalised to allow hyperedges.

In one, the edges consist not only of a set of vertices, but may also contain subsets of vertices, subsets of subsets of vertices and so on ad infinitum. When the vertices of a hypergraph are explicitly labeled, one has the notions of equivalenceand also of equality.

A hypergraph automorphism is an isomorphism hyperhraphs a vertex set into itself, that is a relabeling of vertices. In mathematicsa hypergraph is a generalization of a graph in which an edge can join any number of vertices. The collection of hypergraphs is a category with hypergraph homomorphisms as morphisms.

DEHUMANIZED MARK SLOUKA PDF

## Mathematics > Combinatorics

Dauber, in Graph theoryed. Harary, Addison Wesley, p. Hypergraphs have many other names. A connected graph G with the same vertex set as a connected hypergraph H is a host graph for H if every hyperedge of H induces a connected hypefgraphs in G. A transversal T is called minimal if no proper hypergrahs of T is a transversal. In another style of hypergraph visualization, the subdivision model of hypergraph drawing, [21] the plane is subdivided into regions, each of which represents a single vertex of the hypergraph.

Minimum number of used distinct colors over all colorings is called the chromatic number of a hypergraph. The degree d v of a vertex v is the number of edges that contain it.

### Graphs And Hypergraphs : Claude Berge : Free Download, Borrow, and Streaming : Internet Archive

The transversal hypergraph of H is the hypergraph XF whose edge set F consists of all minimal transversals of H. If a hypergraph is both edge- and vertex-symmetric, then the hypergraph is simply transitive. Views Read Edit Hyperrgaphs history. A general criterion for uncolorability is unknown.

However, it is hypergrwphs desirable to study hypergraphs where all hyperedges have the same cardinality; a k – uniform hypergraph is a hypergraph such that all its hyperedges have size k.

Note that, with this definition of equality, graphs are self-dual:. For such a hypergraph, set membership then provides an ordering, but the ordering is neither a partial order nor a preordersince it is not transitive.

The 2-section or clique graphrepresenting graphprimal graphGaifman graph of a hypergraph is the graph with the same vertices of the hypergraph, and edges between all pairs of vertices contained in the same hyperedge. One of them is the so-called mixed hypergraph coloring, when monochromatic edges are allowed.

EN 14532-1 PDF

In one possible visual representation for hypergraphs, similar to the standard graph drawing style in which curves in the plane are used to depict graph edges, a hypergraph’s vertices are depicted as points, disks, or boxes, and its hyperedges are depicted as trees that have the vertices as their leaves.

However, the transitive closure of set membership for such hypergraphs does induce a partial orderand “flattens” the hypergraph into a partially ordered set.

In some literature edges are referred to as hyperlinks or connectors. In essence, every edge is just an internal node of a tree or directed acyclic graphand hypergrsphs are the leaf nodes.

The hyperedges of the hypergraph are represented by contiguous subsets of these regions, which may be indicated by coloring, by drawing outlines around them, or both. The difference between a set hylergraphs and a hypergraph is in the questions being asked. One possible generalization of a hypergraph is to allow edges to point at other edges.

In other projects Wikimedia Commons.


text:
# HET Seminar | Atish Dabholkar, Abdus Salam ICTP, Trieste | "Three Avatars of Mock Modularity" | PCTS, Jadwin 407

Fri, Feb 7, 2020, 1:45 pm
Location:
In particular, I will derive  a holomorphic anomaly equation for the indexed partition function of a two-dimensional CFT2 dual to AdS3 that counts the black hole degeneracies,  and for Vafa-Witten partition function for twisted four dimensional N=4 super Yang-Mills theory on CP2 for the gauge group SO(3) that counts instantons.  The holomorphic kernel of this equation is not modular but mock modular’ and one obtains correct modular properties  only after including certain anomalous’ nonholomorphic boundary contributions. This phenomenon can be related to the holomorphic anomaly of  the elliptic genus of a two-dimensional noncompact supersymmetric sigma model, and in a simpler context of quantum mechanics to the Atiyah-Patodi-Singer  eta invariant.


text:
# Lesson 8

Round Decimals

## Warm-up: Estimation Exploration: Number Line (10 minutes)

### Narrative

The purpose of this Estimation Exploration is for students to use their experience with the number line, decimals, and fractions to estimate the value of a number located on the number line. Students may answer with a fraction but are likely to write a decimal since they have been working with decimals for the last several lessons. In the synthesis, students reflect on how having tick marks for each tenth would help improve their estimate.

### Launch

• Groups of 2
• Display the image.
• “What is an estimate that’s too high?” “Too low?” “About right?”
• 1 minute: quiet think time

### Activity

• 1 minute: partner discussion
• Record responses.

### Student Facing

What number might be represented on the number line?

Record an estimate that is:

too low about right too high
$$\phantom{\hspace{2.5cm} \\ \hspace{2.5cm}}$$ $$\phantom{\hspace{2.5cm} \\ \hspace{2.5cm}}$$ $$\phantom{\hspace{2.5cm} \\ \hspace{2.5cm}}$$

### Student Response

For access, consult one of our IM Certified Partners.

### Activity Synthesis

• “Would having tick marks for each tenth on the number line help improve your estimate? Why or why not?” (Yes, because I could see if it is one of the tenths and if not, where it is relative to those numbers.)

## Activity 1: Name that Number (15 minutes)

### Narrative

The purpose of this activity is for students to use place value understanding to accurately label number lines and then estimate the value of a labeled point. When they label the tick marks students will use their knowledge that a tenth is a tenth of one and a hundredth is a tenth of a tenth. When they estimate the value of the labeled point, students will also use their understanding that there are ten thousandths in each hundredth. This gives students an opportunity to make sense of each quantity and place it accurately on the number line (MP2).

The activity begins with a group discussion about how Jada labeled a number on the number line. This prepares students for the work of the activity by:

• highlighting how a decimal with a digit in the thousandths place is located between two decimals to the hundredths on the number line
• highlighting that the digits in a number of thousandths give information about which hundredths the decimal is between

As students discuss and justify their decisions, they share a mathematical claim and the thinking behind it (MP3).

MLR8 Discussion Supports. Display sentence frames to support small-group discussion: “I noticed _____ so I . . . .”, and “I agree/disagree because . . . .”

### Launch

• Groups of 2
• Display the first image from workbook.
• “Jada locates 15.53 on the number line. Do you think Jada accurately located the number? Explain your reasoning.” (She placed 15.53 between 15.5 and 15.6 which is correct. She placed 15.53 closer to 15.6 than to 15.5 and this is not correct.)
• 1 minute: independent think time
• 1 minute: partner discussion time
• Make sure students identify that 15.53 should be closer to 15.5 than to 15.6.

### Activity

• 5 minutes: independent work time
• 2 minutes: partner discussion
• Monitor for students who:
• accurately label the tick marks using their understanding of place value and the values of the end tick marks
• use their understanding of place value to estimate each number

### Student Facing

Jada locates 15.53 on the number line. Do you think Jada accurately located the number?

A number is located between two tick marks on each number line. Label those tick marks and then estimate the number.

### Student Response

For access, consult one of our IM Certified Partners.

### Activity Synthesis

• Ask previously selected students to share.
• Display first image.
• “How did you know how to label the tick marks?” (Since the ends of the number line are whole numbers, the tick marks are tenths. It’s the second and third tick marks so that meant they are 3.2 and 3.3.)
• “How did you estimate the value of the number?” (It is halfway between 3.2 and 3.3 so that’s 3.25.)
• Display the last number line.
• “How did you estimate this number?” (The tick marks are 1.71 and 1.72 and it is really close to 1.72. So I put 1.719 which is just 1 thousandth from 1.72.)

## Activity 2: Which Number is Closest? (15 minutes)

### Narrative

The purpose of this activity is for students to round a decimal number to the nearest whole number, tenth, and hundredth. Number lines are provided for the first set of problems but not for the second set. Monitor for students who
• use the given number lines or draw number lines for the second set of problems
• use place value reasoning
Action and Expression: Internalize Executive Functions. Invite students to verbalize their strategy for determining proximity before they begin. Students can speak quietly to themselves, or share with a partner.
Supports accessibility for: Organization, Conceptual Processing, Language

• Groups of 2

### Activity

• 5 minutes: independent work
• 2 minutes: partner discussion
• Monitor for who students:
• who are using the number lines to determine proximity
• who are using the digits in the number (place value reasoning)

### Student Facing

1. Round 6.273 to the nearest whole number, tenth, and hundredth. Use the number lines if they are helpful. Explain or show your reasoning.

2. Round 4.158 to the nearest whole number, tenth, and hundredth.

### Student Response

For access, consult one of our IM Certified Partners.

### Activity Synthesis

• Ask previously selected students to share. Have the student who used the number line share first.

## Activity 3: Round the Numbers [OPTIONAL] (15 minutes)

### Narrative

The purpose of this activity is for students to practice rounding numbers to the nearest whole, tenth, or hundredth. Students may choose to use a number line or any other strategy that makes sense to them.

• Groups of 2

### Activity

• 5 minutes: independent work
• 2 minutes: partner discussion
• Monitor for students who:
• use a number line to round
• reason using the digits and place value to round

### Student Facing

Round each number to the nearest whole number, tenth, and hundredth.
nearest whole number nearest tenth nearest hundredth
34.482 $$\phantom{\hspace{2.5cm} \\ \hspace{2.5cm}}$$
99.909 $$\phantom{\hspace{2.5cm} \\ \hspace{2.5cm}}$$
5.555 $$\phantom{\hspace{2.5cm} \\ \hspace{2.5cm}}$$
19.509 $$\phantom{\hspace{2.5cm} \\ \hspace{2.5cm}}$$

### Student Response

For access, consult one of our IM Certified Partners.

### Activity Synthesis

• Ask previously selected to students to share.

## Lesson Synthesis

### Lesson Synthesis

“Today we rounded decimals to the nearest whole, tenth, and hundredth.”

Display:
“Tyler said that 0.345 rounds to 0.3. Jada said 0.345 rounds to 0.35.”

“Who do you agree with? Why?” (If we’re rounding to the tenths place then I agree with Tyler. If we’re rounding to the hundredths place, I agree with Jada.)

“Write three other numbers that round to 0.3 to the nearest tenth and three other numbers that round to 0.35 to the nearest hundredth.” (0.342, 0.32, 0.299 round to 0.3, and 0.351, 0.349, 0.352 round to 0.35.)

## Cool-down: Round to the Nearest Tenth and Thousandth (5 minutes)

### Cool-Down

For access, consult one of our IM Certified Partners.


text:
How can we write a piecewise function in the form $u(t-a)f(t-a)$?

Given a piecewise function, such as

$$f(t) = \begin{cases} 2, & \text{if }t \lt a \\ t^2, & \text{if }t \geq a \end{cases}$$

Or some other piecewise function, how can we write it in the form $u(t-a)f(t-a)$ for $$u(t-a) = \begin{cases} 0, & \text{if }t \lt a \\ 1, & \text{if }t \geq a \end{cases}$$

A simple explanation that doesn't involve too much math knowledge is preferable, but I would still like to generalize this across other functions that I may come across.

Thank you.

-

Think of $u(t-a)$ as simply a "switch" that is "off" for $t<a$ and so has a value of $0$, but turns on at $t=a$ with a value of $1$ and remains "on" for $t\ge a$. This is why the function is called the unit step function (activated at $t=a$): unit because it has a value of one and step because it instantaneously steps up from a value of zero to a value of $1$ at $t=a$. Many students find it helpful to think about unit step functions as switches.

Hopefully this helps you see how a piecewise defined function can be written as a linear combination of products involving unit step functions. In your example, the function has the value $2$ for $t<a$ but at $t=a$ a switch is flipped which results in a value of $t^2$ for $t\ge a$. This last part is represented as $u(t-a)(-2+t^2)$ or if you prefer, $u(t-a)(t^2-2)$. Thus, we can write the original function as $$f(t)=2+u(t-a)(t^2-2).$$

(Note how we had to include a $-2$ there in order to eradicate the value of 2 that was "on" by default.) You might find the examples here helpful.

Techniques like this are useful when you want to rewrite a piecewise defined function as a unit step times another function, e.g., when you want to perform Laplace transforms in a differential equations course.

-

\begin{align} f(t)&=2(u(t)-u(t-a))+t^2u(t-a)\\ &=2u(t)-2u(t-a)+(t-a+a)^2u(t-a)=\ldots \end{align}

-
Can you perhaps elaborate a little? Particularly, how does this apply for a problem like $f(t) = \begin{cases} \cos2t, & \text{if }0\leq t \lt 2\pi \\ 0, & \text{if }t\geq 2\pi \end{cases}$ – Bailor Tow Dec 13 '12 at 1:16
$f(t)=\cos 2t (u(t)-u(t-2\pi))=\cos 2t u(t)+\cos (2(t-2\pi))u(t-2\pi)$ because $\cos$ is a periodic function with period $2\pi$. – Artem Dec 13 '12 at 1:18
@BailorTow Plotting $u(t)-u(t-2\pi)$ might help to understand how this works. – Artem Dec 13 '12 at 1:19
What does $u(t)-u(t-2\pi)$ represent? Is the second equation you've written above a general formula that I can follow? – Bailor Tow Dec 13 '12 at 1:23
This formula is for your particular example. – Artem Dec 13 '12 at 1:25


text:
singular matrix

Singular Matrix
Noninvertible Matrix

A square matrix which does not have an inverse. A matrix is singular if and only if its determinant is zero.


text:
# The Unapologetic Mathematician

## Convergence of Complex Series

Today, I want to note that all of our work on convergence of infinite series carries over — with slight modifications — to complex numbers.

First we have to get down an explicit condition on convergence of complex sequences. In any metric space we can say that the sequence $z_n$ converges to a limit $z$ if for every $\epsilon>0$ there is some $N$ so that $d(z_n,z)<\epsilon$ for all $n>N$. Of course, here we’ll be using our complex distance function $|z_n-z|=\sqrt{(z_n-z)\overline{(z_n-z)}}$. Now we just have to replace any reference to real absolute values with complex absolute values and we should be good.

Cauchy’s condition comes in to say that the series $\sum\limits_{k=0}^\infty a_k$ converges if and only for every $\epsilon>0$ there is an $N$ so that for all $n\geq m>N$ the sum $\left|\sum\limits_{k=m}^na_k\right|<\epsilon$.

Similarly, we say that the series $\sum\limits_{k=0}^\infty a_k$ is absolutely convergent if the series $\sum\limits_{k=0}^\infty|a_k|$ is convergent, and this implies that the original series converges.

Since the complex norm is multiplicative, everything for the geometric series goes through again: $\sum\limits_{k=0}^\infty c_0r^k=\frac{c_0}{1-r}$ if $|r|<1$, and it diverges if $|r|>1$. The case where $|r|=1$ is more complicated, but it can be shown to diverge as well.

The ratio and root tests are basically proven by comparing series of norms with geometric series. Since once we take the norm we’re dealing with real numbers, and since the norm is multiplicative, we find that the proofs go through again.


text:
# Introduction to Geometric Algebra, Part 1

Geometric Algebra (GA) is one of those things that we should have all learned in high school because it would have made physics and mathematics in college so much easier.

The fact that we did not learn it in high school is probably because GA appears to only have been known by mathematicians studying Clifford Algebras. Mathematicians may be 100 years ahead of everybody else in so many ways, but they are not always the best at communicating their subject to non-mathematicians. The physics community, at least, seems to have figured out that GA is useful, and since physicists are 20 years ahead of the rest of the sciences in the adoption of good tools and methods, it seems safe to predict that in the future engineers will start seeing GA in school in a couple of decades, or even sooner!

Geometric Algebra could be taught in high school immediately after basic algebra. Not only is GA not particularly difficult to learn, it provides a unified perspective for several areas:

• GA lets you easily perform 2D and 3D vector transformations. It is simpler to perform spatial rotations than using matrices, sines, and inverse trigonometric operations, and it generalizes to more dimensions in a straightforward way.
• GA gives a clear geometric meaning to the imaginary number – or all 3 imaginary numbers, in the case of quaternions.
• GA replaces div, grad, curl, with a single vector derivative. To an electrical engineer like myself, it is frankly amazing to see the four Maxwell Equations reduced into a single equation!
• GA is coordinate-free and can let you make analytic conclusions without first choosing a basis
• GA is a framework applicable to dozens of different fields of physics and engineering, including classical and quantum mechanics.

While I am far from being an expert in Geometric Algebra, I wanted to write an accessible, bare-bones introduction to the subject so that people can follow my use of it in a future post on hyperbolic geometry. For this reason, this post will just focus on 2D operations, and perhaps in a later post I can talk about rotations in 3D space or 4D spacetime, differential equations, Maxwell’s Equations, and other applications.

# Preparation: Basic Concepts

Before introducing Geometric Algebra, I’m going to briefly review coordinate systems, basis vectors, and the inner and outer products. As an engineer and not a mathematician, I will focus on examples and developing intuition rather than rigor, entirely symbolic notation, or the capacity to generalize expressions. Checking correctness with a proof must follow the intuition that there is something there to prove!

## Concept: Properties of Algebras

Most people have a vague idea what algebra is: it is a set of rules to add and multiply objects of different quantities, often represented in school using the variables $x$ and $y$. The operations you perform usually satisfy the properties of being

• associative, meaning that you can reorder operations $(qr)s=q(rs)$; and
• distributive, meaning that you can expand like $q(r+s)=qr+qs$.

The algebra you learned in school had one other property:

• commutative multiplication, meaning that you can reorder terms $qr = rq$.

This is not so in Geometric Algebra and matrix algebras, in which the ordering of terms being multiplied matters and generally speaking $qr \ne rq$.

If you are wondering why some operations are not commutative, consider where you would end up navigating if you start in a given orientation and:

• Walk forward 100 paces ($q$) and then turn right ($r$); or
• Turn right ($r$) and then walk forward 100 paces ($q$).

Another example is to consider the commutivity of addition and subtraction: $4+3=3+4$, but does $4-3=3-4$?

## Concept: Coordinate System and References

To introduce GA we need to define a coordinate system with two things:

1. A way to measure distance (hopefully evenly!)
2. Reference directions (hopefully independent!)

Let us consider our options first. If we are drawing on a sheet of paper, we could measure distances using the number of marks passed on a grid. This grid could be:

 Arbitrary or Curvilinear coordinates. We could draw any bunch of curved lines unevenly over the page in a wavy grid as long as the lines parallel to each other did not intersect. This sounds crazy, but sometimes you need to account for some distortion in a space and this type of coordinate system can be very useful as a transformation. In most cases, however, it would be a poor choice for most problems because one unit of distance is not exactly “equal” to another unit elsewhere on the page. Polar. We could use we could use an angle (from a reference direction) and a distance or angle from an origin to define where a point is, as is often done on spherical surfaces like the surface of the Earth. While useful in certain circumstances, but again suffer from the problem that distances at different areas on the page are not easily compared. Rectangular Coordinates. Known as the familiar “XY” coordinate system for most people, we could (and will!) use a grid of straight, parallel lines to find the coordinates of a point. Most problems that are not on highly distorted surfaces are most simply considered in this way – and even on curved surfaces, if you “zoom in” far enough, most surfaces begin to look “locally flat” and begin to resemble straight lines.

Now that we are measuring distances evenly with a Cartesian grid, we need to choose a basis, which are essentially the directions that we reference. The choice of the directions is partly arbitrary, and partly not. For example, we can rotate the grid to be in any orientation and still get the same results. What other options do we have?

 Non-orthogonal basis. We could choose any two directions to draw our parallel lines in, which would probably our grid skewed, but we would soon notice that moving along $x$ also moves you along $y$ in some important sense. This seems like a problem, so we must add another constraint! Orthogonal. If we make the two vectors orthogonal (i.e. 90 degrees to each other) we can now move independently in each direction. But what if we accidentally spaced our parallel lines different distances apart along each axis? If we do not add a constraint that both reference directions be of the same magnitude, we might accidentally measure distances along X in units of meters and distances along Y in distances of feet. Orthonormal. If your basis is orthogonal and are equal in magnitude (i.e. distances on each are measured in the same way), we call the basis “orthonormal”.

One of the advantages of GA is that the exact choice of basis often does not matter – it could be rotated to any number of crazy angles or different scales – and that you can find relationships without choosing a basis at all.

## Concept: Vectors

Using our new coordinate space, let us now draw two example vectors $a$ and $b$, which are mixtures of the basis directions $e_1$ and $e_2$. We will use these same two vectors over and over again to keep the number of symbols low.

Rather than than using matrices or vector notation, which would do more harm than good because they would obfuscate important quantities, we will instead use simple algebraic forms to express vectors. Let us define

In plain english, the vector $a$ means a direction that, for each three units you move along $e_1$, you must also move one unit along $e_2$. Note that we cannot “add” apples $e_1$ and oranges $e_2$; the $+$ symbol here means something like the word “and” for the terms with different basis vectors. We can reduce expressions with $e_1$, but not combine them with $e_2$ in a way that is further reduced than this notation.

What is $a + b$?

## Concept: Vector Magnitude

Since trigonometry is familiar to most people, we will define the magnitude of a vector $a=\alpha_1 e_1 + \alpha_2 e_2$ in the same way as was used the Pythagorean Theorem.

#### Example: Vector Magnitudes

What are the magnitudes of $a$ and $b$?

## Concept: Projections and the Inner Product

If you move along $a$, how much do you also move along $b$?

The answer to this question is given by the inner product (a.k.a. dot product). It is called the “inner” product because the answer is “inside” or “along” the vector to which you are projecting.

Most people remember trigonometry pretty well, in which case the single most important thing to remember about the inner product is:

What can we discover about the consequences of this equation?

• The inner product must be commutative ($a\cdot b = b \cdot a$), because the cosine function is symmetric (a.k.a “even”), which is the property that $\cos(\theta)=\cos(-\theta)$. All this means is that the value of $\cos(...)$ will be the same whether we measure from $a$ to $b$, which is $\cos(\theta)$, or from $b$ to $a$, which is $\cos(-\theta)$.

• If $\|a\|=1$, then $a \cdot a = 1$ because there is zero angle between $a$ and itself, and $\cos(0)=1$. We will use this property for basis vectors extensively, specifically that $e_1 \cdot e_1 = 1$ and $e_2 \cdot e_2 = 1$.

• Orthogonal things must have an inner product of zero, because if $\theta=\pm 90^\circ$, $\cos(\pm 90^\circ)=0$, and thus $a\cdot b=0$. This definitely applies to our basis vectors, where we see that $e_1 \cdot e_2 = e_2 \cdot e_1 = 0$.

• The inner product must be related closely to magnitudes. It is easy to prove that $\|a\| = \sqrt{a \cdot a}$; can you see why? Geometrically, we could think of this definition of magnitude as being akin to “What do we get if we move in the direction of $a$ by a number of units equal to the length of $a$? The magnitude of $a$.”

It will also help to think the types of objects that enter and exit a “black box functional specification” of the inner product operation. The two “inputs” were vectors and the “output” was a scalar that measures the how much you move along one if you move along the other.

#### Example: Inner Product

What is $a \cdot b$ using the above values of $a$ and $b$?

# Concept: Rotations and the Outer Product

If you start pointed in the direction of $a$, how much do you need to rotate to point in the direction of $b$?

The outer product (a.k.a. wedge product) is what gives us the answer to this question.

As before, the easiest way to understand this is via trigonometry, in which case the most important fact is:

This equation has several important consequences:

• The outer product is not commutative. In fact, the outer product is a kind of multiplication that is called anti-symmetric, which means that commuting the inputs flips the sign ($a\wedge b = - b \wedge a)$. This is fundamentally because $\sin()$ is an odd function and $\sin(\theta)=-\sin(-\theta)$. There are also geometric reasons for rotations to not be commutative: if we start at $a$, we need to rotate counterclockwise to get to $b$, but we start at $b$, we need to rotate clockwise to get to $a$. The choice of which reference direction you measure from matters to the sign of the answer.

• The outer product is closely related to rotation by 90 degrees, because that is the point at which $\sin(\theta)$ is maximized and minimized. This is so important that we will right now assign the symbol $R$ to a 90 degree counterclockwise rotation. We can think of smaller or larger rotations as being $R$ multiplied by some scalar to adjust “how big” the rotation is. Under this idea, a 45 degree counterclockwise rotation would be $0.5R$, and a 90 degree clockwise rotation would be $-R$.

• The outer product of two orthonormal vectors must be either $1R$ or $-1R$. Why? Because if $\theta=\pm 90^\circ$, then $\sin(\pm 90^\circ)=\pm 1$. For the basis vectors, this means that $R = e_1 \wedge e_2$ is a 90 degree counterclockwise rotation, and $-R = e_2 \wedge e_1$ is a 90 degree clockwise rotation.

Once again, it will help to consider the black box specification of the outer product operation. The two “inputs” were vectors and the “output” is a scaled amount of a 90 degree rotation $R$, which is neither a vector nor a scalar. What, exactly, is the type of this output object? After defining the geometric product, we will give it a better name.

#### Example: Outer Product

What is $a \cdot b$ using the above values of $a$ and $b$?

# Geometric Algebra

With the preliminaries out of the way, we can now define the geometric product and actually start doing geometric algebra!

## The Geometric Product

In the same way that we introduced the inner and outer products by asking a question, we will introduce the geometric product by asking a very general question:

How do you transform $a$ into $b$?

Or equivilently, in terms of what we already know,

How much do you need to rescale and rotate $a$ so that it is equal to $b$?

The intuition that we need both a rotation and a rescaling is key to understanding the geometric product. We will write the geometric product of $a$ and $b$ as $ab$, as we would write scalar multiplication of two variables in high school algebra. We can define the geometric product as:

But in some ways, this definition puts the cart before the horse! We can discover this equation if just try to multiply $a$ and $b$ together and be very careful about how we do so. Let us explore what happens when we try to compute $ab$ using high school rules of algebra (sans commutative multiplication of nonscalars).

Hmm. What should we do with the products of the unit vectors $e_1 e_1, e_1 e_2, e_2 e_1, e_2 e_2$? We can reason it out:

• $e_1 e_1$ asks, “How do I transform $e_1$ into $e_1$?”. The answer, of course, is that nothing needs to be done! We can express this by scaling by one, the identity object, and write that $e_1 e_1 = 1$. If we recall the properties of dot and wedge products for unit length vectors, $e_1\cdot e_1=1$ and $e_1\wedge e_1=0$, then this assumption also agrees with our definition of the geometric product, $e_1e_1=e_1\cdot e_1 + e_1 \wedge e_1 = 1 + 0R = 1$. No rotation was needed.

• $e_2 e_2$ must also equal 1, for the same reasons.

• $e_1 e_2$ is asking how do I transform $e_1$ into $e_2$? We know that our basis vectors are orthonormal, so this must equal a 90 degree clockwise rotation $R$. $e_1e_2=e_1\cdot e_2 + e_1 \wedge e_2 = 0 + 1R = R$, and no rescaling is needed.

• $e_2 e_1$ must thus equal $-R$, using similar reasoning.

We can now finish the simplification process.

If you compare this results to what we found earlier ($a\cdot b=10$ and $a\wedge b=5R$), we can indeed see that in this case $ab=a\cdot b + a\wedge b$. Now that you have the intuition, it would be a good time to prove this to yourself more generally for all $a,b$.

Speaking of intuition, what does the result $ab=10+5R$ really mean? Does it mean that we should scale vector $a$ by 10 times and go 5 quarter turns counterclockwise to end up at $b$? That seems obviously incorrect! So our interpretation has led us slightly astray.

We will correct this intuition of this just a moment, but now is a good time to introduce some simplying notation that will carry us beyond just two dimensions.

## Simplifying Geometric Products of Basis Vectors

For brevity, if you have fewer than 10 dimensions, it is often convenient to combine the subscripts of basis vectors. That is, with this notational convention, $e_1 e_2 = e_{12}$, or $e_1 e_2 e_3 = e_{123}$.

As for simplifying more complex geometric product expressions with orthonormal vectors, we have already learned the only two rules that we need to know:

1. $e_i e_i = e_{ii} = 1$.
2. $e_i e_j = e_{ij} = - e_{ji}$.

That’s it! Let’s try an example to make sure this is completely obvious.

#### Example: Simplifying Geometric Products

Simplify the quantity $e_2 e_3 e_2 e_1 e_3 e_2 e_2$.

Let us make a table of the different types of objects we have seen up to this point, and add a new column called grade that more or less describes the dimensionality of the object.

Scalar 1,2,3,4,5… 1 0 Magnitude
Vector $a,b$ $e_1, e_2$ 1 Direction
Bivector / Rotation $5R$ $e_{12}$ 2 Rotation

Common parlance is to call $e_{12}$ a bivector, and when we get to 3D, $e_{123}$ is the trivector.

## The meaning of Geometric Products

Let us look one more time at the vectors $a$ and $b$, but this time let us include all four of the basis vectors we have seen thus far: $1, e_1, e_2, e_{12}$.

In general, we will call this new compound object a “Multivector”. Multivector $a$ has four components:

• An amount of “0” of a scalar quantity
• An amount of “2” in direction $e_1$
• An amount of “1” in direction $e_2$
• An amount of “0” is the bivector (90 degree rotation) direction

As we know by now, we cannot simplify this expression any further, because we cannot “add” apples and oranges and pears and bananas. All four objects are independent, different measurement units: the scalar values, the two basis values, and the bivector ($e_{12}$) value.

The only thing left to do in this post is to explore a few examples.

#### Example: On the Order of Multiplication ($ab$ vs $ba$)?

What is the relationship between $ab$ and $ba$?

where $^{\dagger}$ means the complex conjugate. In physical terms, this means rotating clockwise instead of counterclockwise, which is consistent with our understanding thus far.

#### Example: How do we move from $a$ to $b$?

If $ab$ represents a transformation from $a$ to $b$, how do we show it? Keeping in mind that geometric product operations are not commutative, should we pre- or post- multiply $a$ with $ab$ to transform it into $b$?

If we pre-multiply,

Which is not equal to $b$. Perhaps we should try post-multiplying?

Aha! That is just $b$ multiplied by a factor of 5. Where did that factor of 5 come from? Well, If we normalized $a$ and $b$ to have unit length (i.e. $\frac{a}{\|a\|}$ and $\frac{b}{\|b\|}$), then the factor of 5 disappears. Now is a good time to grab a sheet of paper and a pen and prove that $aab=b$ for unit length vectors, and then read on:

If you can see that $r$ represents a pure rotation (a.k.a. a rotor), then the transform from $a$ to $b$ could be described as: “normalize $a$, rotate by $r$, and then scale by $\|b\|$ to reach $b$. In math, this is quite simply several products written from left to right:

And we can see that the factor of 5 we saw earlier came from the fact that $\|a\|^2=5$. The true way to go from $a$ to $b$ is thus to multiply $a$ by $\frac{ab}{\|a\|^2}$.

# Conclusion

For those with prior experience in engineering and physics, you have probably noticed by now that the bivector $e_{12}$ is playing the role of the imaginary number $i=\sqrt{-1}$, and that this is all just complex mathematics in another form. However, you may agree after seeing the results in higher dimensions that it is perhaps more valid to say that complex mathematics is just a special case of geometric algebra!

# References

I found the following papers useful while learning about Geometric Algebra. Ordering from easiest to hardest,

• Geometric Algebra Primer, by Jaap Suter.
• Imaginary Numbers are not Real – the Geometric Algebra of Spacetime, by Stephen Gull, Anthony Lasenby, and Chris Doran.
• A Survey of Geometric Algebra and Geometric Calculus, by Alan Macdonald.
• Oersted Medal Lecture 2002: Reforming the Mathematical Language of Physics by David Hestenes.
• An Introduction to Geometric Algebra and Calculus, by Alan Bromborsky.
• Geometric Algebra, by Eric Chisolm.
• Spacetime Physics with Geometric Algebra 1, by David Hestenes.