Blog

  • Triangle Trigonometry

    Triangle Script Image

    I haven’t forgotten about my pledge to focus more content here towards some of the areas I’ve been asked to tutor on recently. This latest one is designed to help users understand the properties of triangles. It is based on two laws that we learn in trigonometry: the law of sines and the law of cosines. Assume that we have a triangle with sides of lengths a, b, and c and respective angles A, B and C (where the angle A does not touch the side a, the angle B does not touch the side b, and the angle C does not touch the side c). These laws are as stated as follows:

    Law of Sines

    a
    sin(A)
    =
    b
    sin(B)
    =
    c
    sin(C)

    Law of Cosines
    c2 = a2 + b2 – 2*a*b*cos(C)

    We can use these laws to determine the sides of a triangle given almost any combination of sides and angles of that triangle (the only one we cannot determine properties from is if we are given all three angles, as this leads to many solutions).

    The script generates random triangles, with different combinations of sides and angles revealed and the user’s job is to try to determine the missing sides. There is a button to reveal the solution, or if you’d like to see how we arrive at these values, you can check the “Show work” box.

    Hope you enjoy.

    Other Blogs covering this topic:
    Mathematical!
    Algebra 2 Trig

  • Sudoku Program Updates

    Picture of Sudoku Page

    Here in DC, we recently had an unexpected snow day. By the word unexpected, I don’t mean that the snow wasn’t forecast – it was definitely forecast. It just never came. However due to the forecast I decided to avoid traffic just in case the predictions were correct. So while staying at home, I began thinking about some things that I’ve been wanting to update on the site and one thing that came up was an update to my Sudoku program. Previously, it contained about 10000 sample puzzles of varying difficulty. However, I told myself that I would return to the idea of generating my own Sudoku puzzles. I decided to tackle that task last week.

    The question was how would I do this. The Sudoku solver itself works through the dancing links algorithm which uses backtracking, so this was the approach that figured as most likely to get me a profitable result in generating new puzzles (I have also seen alternative approaches discussed where people start with an initial Sudoku and swap rows and columns to generate a new puzzle). The next question was how to actually implement this method.

    Here is an overview of the algorithm. I went from cell to cell (left to right, and top to bottom starting in the top left corner) attempting to place a random value in that cell. If that value can be a part of a valid Sudoku (meaning that there exists a solution with the current cells filled in as is), then we continue and fill in the next cell. Otherwise, we will try to place a different value in the current cell. This process is continued until all cells are filled in.

    The next step was to create a puzzle out of a filled in Sudoku. The tricky about this step is that if too many cells are removed then we wind up generating a puzzle that has multiple solutions. If too few cells are removed though, then the puzzle will be too easy to solve. Initially, I went repeatedly removed cells from the locations that were considered the most beneficial. This generally results in a puzzle with about 35-40 values remaining. To remove additional cells, I considered each of the remaining values and questioned whether hiding the cell would result in the puzzle having multiple solutions. If this was the case, then the cell value was not removed. Otherwise it was. As a result I now have a program that generates Sudoku puzzles that generally have around 25 hints.

    You should give it a try.

  • The PageRank Algorithm

    I think one of the best recent examples of the importance of mathematics is the rise of the search engine Google. I remember the world of search engines before Google and it was dominated by names like AltaVista, Yahoo, WebCrawler, Excite, and the likes. The standard way these search engines ranked the order that pages would be listed on a search query was basically to count the number of times that query appeared on pages in their database. The pages with the most listings were considered the most important, the second most listings were second most important and so on and so forth.

    This sounds like a feasible way of doing things but let me show you an example of how this can be tricked. Suppose I wrote my first web page and it looked like the following:

    That’s a basic web page that may not garner much attention, and it wouldn’t rank highly in most search engines as no work appears more than once. Suppose that, this being a math web page, I wanted it to rank higher on the query “math”. Then I could just edit the source code of the page to be as follows:

    This second page says not much more than the first, but the fact that the word math appears 9 additional times would increase the ranking of this page among math pages. This is a very simple example, but it shows how these search engine rankings did not have a useful metric for determining the important sites on the web.

    Enter Google.

    The way Google solved this problem of determining the importance of a web page is basically by counting the number of links into a web page – the theory being that the more important a web page is, the more people will be talking about it and thus linking to it. Also, the more important the people talking about (linking to) a web site, the more important that site is. This can be expressed mathematically by the following formula:

    In the above formula, the variable d is called the damping factor, which helps to capture some of the random nature of the internet by saying that every site should have at least some minimal worth because of the idea that a random surfer could still get to these sites.

    I have written a script to implement the algorithm here.

    Other Blogs that have covered this topic
    Blue Onion

  • The Risk of Competition

    The Risk of Competition

    I’m not a competitive person. Let me correct that. I try not to be a competitive person. I’ve recently been playing some of my favorite games from childhood like Monopoly, Chess, Spades, and Madden and I’ve been reminded of the competitive streak in me that hates losing. This streak has been relaxed in much of my adult life, and I tend to think that’s been to my benefit. Two pieces come to mind as I write this. One is a piece written by Slim Jackson of Single Black Male on the importance of asking questions. The second is what I heard on WAMU’s “Tell Me More” while driving home from work regarding the competitive nature generally assumed by (or dictated to) men.

    These two concepts go hand in hand in my opinion because I’ve found that at times where I see a person as “my competition” I’m less likely to seek advice or help from that person. Doing this limits my resources and the set of people who can help me. I know that one of the hardest things to do while playing a game like Madden is asking my competition “how’d you just make that play” or listen to this competition explain how he knew to make such a play. However, its just this ability to swallow my pride and ask these questions that I’ve gotten better in Madden. I will admit that I’m not the most humble person on the face of the earth and so there are some things that I haven’t asked how to do. Generally in those things, I’ve found myself repeatedly playing the game trying to figure things out for myself.

    There are applications of both sides of this to the real world. Some who love competition will say that it brings out the best in us, and they’d be sure to point out the feeling of satisfaction we get by working independently on a problem. As I look through my lists of inspirational quotes, I’m reminded of this with often repeated statements like “failure is the key to success”.

    As rewarding as a competition can be, there’s also an important saying that we don’t need to re-invent the wheel. And what often gets lost in the do-it-yourself nature of competition is the ability to utilize all possible resources available to us. In particular, the skills of how to acknowledge the things we do not understand and how to formulate questions aimed at gaining understanding.

    This brings us to is the other side of the competitive spirit. As rewarding as it is to be able to say, “wow, I can’t believe I was able to figure that out on my own”, it is also a stressful situation and there are many who are never able to say those words. Should these people be satisfied with failure?

    I do not ask this in some devil’s advocate type of way. I ask coming from the point of view of a mathematician, an educator, and as a former student. I had a pretty dark moment in graduate school where I realized that my mere “love” of mathematics would not get me through qualifying exams. It wouldn’t suddenly make text books and academic papers instantly understandable. Suddenly I was placed in an uncomfortable position. Instead of always being the one who was the first to get the concept and who was leading the study groups on it, I’d be the one asking the questions. Looking at this in a “competitive” frame of mind (as I did then), I felt like I was losing the game.

    This same moment though, is where my thinking was really changed. There was one thing, and one thing only that I would consider a failure and that was not finishing. I view everything else as a matter of swallowing my pride and readjusting my thought process to help get to that point.

    Unfortunately though, many others do not get to this point. Many get lost in the scramble of the competition and do the equivalent of folding your hand in poker. They realize that at their current pace there is little to no chance that they’d win and so they just leave the game. And this is a real risk that we’re running with competition, particularly as STEM fields are becoming more and more important and we’re trying to encourage students to focus on these areas. What may be necessary to bring this about is a more cooperative approach to these things.

  • Nonogram Puzzles

    A friend introduced me to a type of puzzles called Nonograms and I enjoyed them so much that I wrote a script that automatically generates these puzzles.

    Nonograms are grid puzzles based on discovering the hidden pattern based on the clues provided. This hidden pattern is the answer to the question of which cells of this grid should be shaded black, and which ones should be shaded grey. The clues come in the form of lists at the beginning of each row and column. The list represents the sizes and order of the groups of shaded cells in that line. For example, if there is a list with the numbers “4 2”, then it says that the group has 4 shaded cells, then one or more unshaded cell, then two shaded cells. Because 4 becomes before 2 in the list, the 4 shaded cells would become before the 2 shaded cells in the line of the grid. Also there must be at least one unshaded cell in between the groups because if there wasn’t, then the “4 2” list would actually be a group of 6 shaded cells.

    So have fun with these and let me know what you think.

    Other Blogs that have covered this topic:
    MINIGAMESCLUB

  • Geometric Sequences

    I’ve added a script which helps to understand geometric sequences.

    Suppose you were to draw an equilateral triangle on a sheet of paper. It might look something like this:

    Now suppose that you draw lines connecting the midpoints of each of the edges of this triangle. This will dissect the larger triangle into four smaller triangles, each of which are equilateral. Three of these smaller triangles will be oriented in the same direction as the original triangle, whereas one will not. Consider the second image below, with the three triangles with the same orientation as the original triangle numbered.

    We can continue to draw lines connecting the midpoints of the edges of the marked triangles and counting the resulting triangles that have the same orientation as the original triangle and we see that a pattern emerges.

    What one notices is that each time we draw a new triangle by connecting the midpoints of the marked edges, we wind up with three times the number of triangles that were in the previous picture. So (assuming we had enough space) we could draw out the figure that would be the result of doing any number of these dissections. However, if we are only interested in knowing the number of triangles that each image will contain, we can take advantage of the fact that this pattern represents a geometric sequence.

    A geometric sequence is a sequence with an initial term, a1 and a common ration, r, where each term after the initial term is obtained by multiplying the previous term by the ratio (a1 cannot be zero, and r cannot be zero or one).

    In a geometric sequence, if we know the first term and the ratio, we can determine the nth term by the formula

    an = a1*rn – 1

    Similarly, if we know the first term and the ratio, we can determine the sum of the first n terms in a geometric sequence by the formula:

    Sn =
    a1(1 – rn)
    1 – r

    For the previous example with the triangles pointed in the same direction, we can show the results in the following table:

    Drawing Number Number of Triangles ratio sum number sum value
    a1 1 3 S1 1
    a2 3 3 S2 4
    a3 9 3 S3 13
    a4 27 3 S4 40
    a5 81 3 S5 121

    The script is available at http://www.learninglover.com/examples.php?id=34

    Other Blogs that have covered this topic:
    Study Math Online

  • Arithmetic Sequences

    Arithmetic Sequences

    I’ve added a script which helps to understand arithmetic sequences.

    At a previous job of mine, there was a policy of holding a dinner party for the company each time we hired a new employee. At these dinners, each employee was treated to a $20 dinner at the expense of the company. There was also a manager responsible for keeping track of the costs of these dinners.

    In computing the costs, the manager noticed that each time there is a new dinner, it was $20 more expensive than the last one. So if we let a1 represent the cost of the first dinner, and let ai represent the cost of the ith dinner, then we see that ai = ai-1 + 20. Sequences like this, where t arise quite often in practice and are called arithmetic sequences. An arithmetic sequence is a list of numbers where the difference between any two consecutive numbers is constant.

    For the example above, the term an will represent the cost of dinner after the nth employee has joined the company (assuming that no employees have left the company over this time period). Also the term Sn will represent the total cost the company has paid towards these dinners.

    Before we continue with this example, consider the following table which lists the first five terms of an arithmetic sequence as well as the common difference and the first five sums of this sequence.

    term number term value diff sum number sum value
    a1 4 3 S1 4
    a2 7 3 S2 11
    a3 10 3 S3 21
    a4 13 3 S4 34
    a5 16 3 S5 50

    One of the beauties of arithmetic sequences is that if we know the first term (a1) and the common difference (d), then we can easily calculate the terms an and Sn for any n with the following formulas:

    an = a1 + d*(n – 1), where d is the common difference.
    Sn = n*(a1 + an)/2

    We can use these formulas to derive more information about the sequence. For example, if my manager wanted to estimate the cost of dinners once we had added 30 new employees, this would be term a30 of the sequence, which we can evaluate with the above formula by a30 = a1 + d*(n – 1) = 0 + 20*(30 – 1) = 0 + 20 * 29 = 580.

    The script is available at http://www.learninglover.com/examples.php?id=33.

    Other Blogs that have covered this topic:
    Study Math Online

  • Learn to Solve Single Variable Linear Equations

    In keeping with my new years resolution of making this site more accessible to my nieces and nephews, I’ve added a script that generates random single variable linear equations that ask the user to solve for x. The script also has a “Compute” button that will give the answer, as well as an option to to show the step by step procedure that is used to reach this solution.

    In many instances, solving single variable linear equations are a person’s first introduction into variables, or solving for unknown values. This concept, though, remains very important in our daily lives, with questions such as “how many paychecks do I need to save before I can afford to buy a new car?” or “how long will it take me to get home?”

    Both of these questions can be represented by a linear equation. For example if each of my paychecks is for $500, and the car I wish to purchase has a listed price of $4500, then the question of “how many paychecks do I need to save before I can afford to buy a new car” can be represented by the following equation, which we would like to solve for x:

    500 x = 4500

    As a second example, suppose that out of each $500 paycheck $100 must go towards paying my bills. Suppose also that I have already begun saving and have an initial amount of $1300 saved already. Then the question of “how many paychecks do I need to save before I can afford to buy a new car can be represented by the following equation, which we’d also like to solve for x:

    500 x + 1300 = 4500 - 100 x

    The goal when solving an equation of this form is to isolate the variable, which in the case of these examples, means to get the x on one side of the equals sign ( = ) by itself and some number on the other side of the equals sign. We can do this by remembering a simple rule, Whatever you do to change one side of the equation, you must make the same changes on the other side of the equation. We do this because initially if we have two things being equal, the only way that they can stay equal is if we do the same things to both these things. We decide what to do by looking at what has already been done and performing the inverse operation of that action.

    If there was initially addition of some number, we will subtract that same number.
    If there was initially subtraction of some number, we will add that same number.
    If there was initially multiplication by some number, we will divide by that same number.
    If there was initially division by some number, we will multiply by that same number.

    While there is no rule as to what the first step should be, it is generally easiest to try to keep reducing the number of terms in the equation, while trying to place all the terms with an x on one side of the equation and all the terms without an x on the other side of the equation. For instance, in the example earlier that states

    500 x + 1300 = 4500 - 100 x

    We notice that on the left hand side (LHS), x has been multiplied by 500 and the term 1300 has been added. So as a first step, we could either divide both sides by 500 or subtract 1300 from both sides. Likewise, on the right hand side (RHS), x has been multiplied by (-100) and the number 4500 has been added to it. So we could also divide both sides by by (-100) or subtract 4500 from both sides of the equation. We could also add 100 x or 500 x to both sides of the equation.

    Initially there are four terms in this equation and division (by 500 or -100) will keep the number of terms in the equation at 4, whereas subtraction of 1300 or 4500 or 500 x or (-100 x) will reduce the number of terms to three. So we choose to do one of these actions. Lets go with subtraction of 1300 from both sides of the equation.

    It can now be represented by

    500 x + 1300 - 1300 = 4500 - 100 x - 1300

    This simplifies to

    500 x = 3200 - 100 x

    Again we are faced with many options regarding what to do next. However, to get all the terms with an x on one side of the equation, we can add 100 x to both sides of this equation, which then becomes

    500 x + 100 x = 3200 - 100 x + 100 x

    This simplifies to
    600 x = 3200

    Now we notice that x is being multiplied by 600. So to solve for x, we only need to divide both sides by 600 which gives us that

    x = 3200 / 600

    Relating this to fraction arithmetic and Euclid’s Algorithm, we can reduce this fraction by noticing that 3200 = 200 * 16 and 600 = 200 * 3, so 3200 / 600 can be reduced to 16 / 3.

    So x = 16 / 3

    Since we’re looking for the number of paychecks I would need to save, this needs to be a whole number. 16 / 3 is greater than 5, so 5 paychecks will not be enough. So in order to make this purchase, I would need 6 paychecks.

    The script also gives the option to generate a new problem to gain more practice with these types of problems.

  • Fraction Arithmetic

    Fraction Arithmetic

    I hope everyone had a good holiday season. I certainly enjoyed mine. Over this season, I had a chance to speak with some youth and their parents. Funny that whenever we discuss that I have a PhD in applied mathematics, the topics of the children struggling in mathematics and the possibility of tutoring their children always seem to come up. I have no problem with tutoring and I actively participate in such sessions in my spare time. However I will say that it is sometimes a difficult task to do this job over such a short time period. Needless to say, I felt bad that I couldn’t have been of more assistance.

    So, this being the holiday season and all, I decided to make somewhat of a new years resolution to focus this site more towards some of the things that the youth struggle with to hopefully be able to answer some of their questions.

    With that being said, the first area that I decided to look at was fractions. This is one of the first areas where the youth begin to dislike mathematics. I feel like regardless of how much teachers and professors speak of the importance of understanding these processes, many students simply never grasp the procedures involved, partially because they never get used to the rules associated with these matters.

    In this first script on fractions, I’ve focused on four types of problems corresponding to the four basic operations of arithmetic: Addition, Subtraction, Multiplication and Division.

    To add two fractions of the form

    num1
    den1
    +
    num2
    den2

    We use the formula

    num1
    den1
    +
    num2
    den2
    =
    num1
    den1
    +
    num2
    den2
    =
    num1*den2 + num2*den1
    den1*den2

    Lets take a moment to consider where this formula comes from. In order to be able to add fractions we first need to obtain a common denominator for the two fractions. One way that always works to obtain a common denominator is to multiply the denominators of the two fractions. So in the formula above, the denominator on the right hand side of the equals sign is the product of the two denominators on the left hand side. Once we have a common denominator, we need to rewrite each of the two fractions in terms of this common denominator.

    num1
    den1
    +
    num2
    den2
    =
    num1*den2
    den1*den2
    +
    num2*den1
    den1*den2

    The formula for subtracting fractions is similar, with the notable difference of a subtraction in the place of addition.

    num1
    den1
    num2
    den2
    =
    num1*den2 – num2*den1
    den1*den2

    To multiply two fractions (also known as taking the product of two fractions, the resulting numerator is the product of the two initial numerators, and likewise the resulting denominator is the product of the two initial denominators.

    num1
    den1
    *
    num2
    den2
    =
    num1*num2
    den1*den2

    Finally, remembering that division is the inverse of multiplication, we can derive the formula to divide two fractions by multiplying by the inverse of the fractions:

    num1
    den1
    ÷
    num2
    den2
    =
    num1
    den1
    *
    den2
    num2
    =
    num1*den2
    den1*num2

    The next step in each of these operations is to reduce the fraction to lowest terms. One way of doing this is by considering Euclid’s GCD algorithm which is available here.

    The script is available to practice your work on fractions at
    http://www.learninglover.com/examples.php?id=31

  • Learn About “the Other” Algebra

    When I visit family for the holidays, the topic of my being a mathematician always seems to come up, and there’s always a child in the family struggling with maths, and when I ask the subject of their struggles the word “algebra” is always the culprit. I’ll save for another post my ideas on how this subject should be taught in high school and some of the main problems facing students.

    I want to concentrate this post on a topic that few outside the mathematical world know about, but which many inside this world (myself included) hold dearly – the topic of modern or abstract algebra. I refer to this as “the other” algebra because a general conversation about the word “algebra” will generally revolve around concepts such as systems of equations, slopes, intercepts, intersection, rise-over-run, point-slope, and other terminology that limits algebra to a specific domain (the set of real or complex numbers) while at the same time ignoring the underlying beauty associated with this area.

    I wrote previously about the area of set theory and the beauty associated with taking math out of the scope of a basic number line and into a much more undefined space. Abstract algebra is a continuation of set theory where in addition to our set, we have a (binary) operation defined on any two elements of this set. The inclusion of this binary operation allows us to consider several different structures based on the properties that this binary operation holds.

    The structures I’d like to write about today are called groups. A group is a set along with an operation (or function) defined on any two elements of the set with the following properties:
    – It is closed. This means that any time we run this function on two elements on the set, the function gives us a member of the set. In mathematical terms, for all a, b in the set A, f(a, b) must also be a member of A.
    – There is an identity element. An identity element is defined as an element where is we include it in the binary operator with any other element, the operator will always return the other element. So if the element i is the identity element, then f(i, a) = a and f(a, i) = a for any other a in the set A. Any group must have an identity element.
    – Every element has an inverse. Inverse elements are based on the identity element. What the inverse says is that for every element, there is a way to use the binary operator to get to the identity element. So for all elements a in the set A, there is an element b in the set A such that f(a, b) = i, where i is the identity element.
    – The binary operator is associative. I described the associative property when I discussed the functions and relations of set theory. A function is associative if the way we group things (aka associate them) doesn’t matter. This means that for any elements a, b, and c of the set A, f(f(a, b), c) must be the same as f(a, f(b, c)).

    If these four properties hold for a set A and a binary function f, then we say that the pair (A, f) is a group. We will generally use a common notation such as a · b, or a * b or simply ab to represent f(a, b).

    Another important concept in group theory is the idea of a Cayley table. These are similar to multiplication tables that we drew out when we were first learning our “times tables”. For a group with n elements, we form a table with n rows and n columns. Each element of the group is written out to the left of each row and above each column (so really we can think of it as an n+1 by n+1 table with the first row and column being descriptive rows). Each cell of the table is the binary operator applied to the two elements indicated by the row and column (with an understanding of whether we have row before column or vice versa). Obviously, we can only do this for finite groups as we cannot write out all the elements of an infinite set.

    The script I’ve added is a tester to allow users to input the information for a possible group (size, name of each element, and a Cayley table) and with this information the user is informed whether or not it forms a group. If it does not form a group, the reasons why it does not form one are also given. There are also some sample groups given to give insight into this area.