# Constructing Tri-Diagonal Matrices

Fractional Calculus Course, we are instructed to create an $n \times n$ Tri-Diagonal matrix in the form of:

\begin{array} a A &= \begin{bmatrix} 2 & -1 & 0 & 0 & ... & 0 & 0 & 0\\ -1 & 2 & -1 & 0 & 0 & 0&... & 0 \\ 0 & -1 & 2 & -1 & 0& 0... & 0 & 0\\ 0 & 0 &-1 & 2 & -1 & ... & 0 & 0\\ &&&\vdots&&& \\ 0 & 0 & 0&... & 0 & -1 & 2 & -1\\ 0 & 0 & 0 & 0&... & 0 & -1 & 2 \\ \end{bmatrix} \end{array}

This is where my dilemma begins. I am not sure how to create this Tri-Diagonal Matrix. I came across the "SparseArray" command upon my research and it help me create a Tri-Diagonal Matrix, but I am having a hard time manipulating it to get the $-1, 2, -1$ pattern I am looking for.

mat = SparseArray[ {i_, j_} /; Abs[i - j] <= 1 :> 1, {10, 10}];
mat // MatrixForm

Above is the command I used for a $10 \times 10$ matrix. But the tri-diagonal entries were all 1's.

Thus my question is, how would I create the tri-diagonal matrix $n \times n$ I desire? Is there a way to create a function so I can simply manipulate the value of $n$ to get a new matrix without typing (or copy-pasting) the entire code again?

• Look up Band in the help files. – march Sep 1 '15 at 17:51
• Just curious ...What is a Fractional Calculus Course ? – Dr. belisarius Sep 1 '15 at 18:19
• Fractional Calculus is a course that focuses on the applications of fraction derivatives and fraction integrals. So imagine taking half the derivative of f(x) or the two-third integral of f(x). I'm still new to the material so I can't give you a better example that this, sorry. – Kevin_H Sep 1 '15 at 19:09
• Proposed duplicate: (13004). Related: (13796) – Mr.Wizard Sep 2 '15 at 0:07

SparseArray[{{i_, i_} :> 2, {i_, j_} :> -1 /; Abs[i - j] == 1}, {10, 10}]  // MatrixForm

or

SparseArray[{Band[{1, 1}] -> 2, Band[{2, 1}] -> -1, Band[{1, 2}] -> -1}, {10, 10}] //
MatrixForm

The following is sometimes useful:

m = {{{a, b}, {b, a}}};
d = {10, 10};
SparseArray[{Band[{2, 2}, d] -> m, Band[{1, 1}, d] -> m}, d] // MatrixForm

Without SparseArray:

n = 10;
Total[
{DiagonalMatrix[Array[-1 &, n - 1], -1],
DiagonalMatrix[Array[2 &, n]],
DiagonalMatrix[Array[-1 &, n - 1], 1]}
]

Or strictly using Array:

Array[Which[#1 == #2, 2, Abs[#1 - #2] == 1, -1, True, 0] &, {10, 10}]

AND, what the heck? One more for more flexible applications:

a = {2, -1, -2, 3};
n = 10;
With[{a1 = PadRight[a, n]}, (Array[a1[[Abs[#1 - #2] + 1]] &, {n, n}])]//MatrixForm

• Your second snippet is what was usually done before SparseArray[] came along. – J. M. is away Sep 2 '15 at 0:57

This should be faster (where n is your square dimension, e.g. 1000 for 1kX1k), easily extends to n-diagonal symmetric with no performance impact:

ToeplitzMatrix[PadRight[{2, -1}, n]]


# biconditional statement truth table

We will then examine the biconditional of these statements. Sign up using Google Sign up using Facebook Sign up using Email and Password Submit. Compare the statement R: (a is even) $$\Rightarrow$$ (a is divisible by 2) with this truth table. We can use the properties of logical equivalence to show that this compound statement is logically equivalent to $$T$$. Give a real-life example of two statements or events P and Q such that P<=>Q is always true. Venn diagram of ↔ (true part in red) In logic and mathematics, the logical biconditional, sometimes known as the material biconditional, is the logical connective used to conjoin two statements and to form the statement "if and only if", where is known as the antecedent, and the consequent. But would you need to convert the biconditional to an equivalence statement first? V. Truth Table of Logical Biconditional or Double Implication. I've studied them in Mathematical Language subject and Introduction to Mathematical Thinking. Otherwise it is true. For example, the propositional formula p ∧ q → ¬r could be written as p /\ q -> ~r, as p and q => not r, or as p && q -> !r. You can enter logical operators in several different formats. So to do this, I'm going to need a column for the truth values of p, another column for q, and a third column for 'if p then q.' We can use an image of a one-way street to help us remember the symbolic form of a conditional statement, and an image of a two-way street to help us remember the symbolic form of a biconditional statement. The biconditional statement $$p\Leftrightarrow q$$ is true when both $$p$$ and $$q$$ have the same truth value, and is false otherwise. (true) 3. Two formulas A 1 and A 2 are said to be duals of each other if either one can be obtained from the other by replacing ∧ (AND) by ∨ (OR) by ∧ (AND). We still have several conditional geometry statements and their converses from above. Whenever the two statements have the same truth value, the biconditional is true. A tautology is a compound statement that is always true. second condition. Also, when one is false, the other must also be false. Therefore, the sentence "A triangle is isosceles if and only if it has two congruent (equal) sides" is biconditional. The truth tables above show that ~q p is logically equivalent to p q, since these statements have the same exact truth values. Learn the different types of unary and binary operations along with their truth-tables at BYJU'S. Email. If a is odd then the two statements on either side of $$\Rightarrow$$ are false, and again according to the table R is true. When we combine two conditional statements this way, we have a biconditional. Copyright 2010- 2017 MathBootCamps | Privacy Policy, Click to share on Twitter (Opens in new window), Click to share on Facebook (Opens in new window), Click to share on Google+ (Opens in new window), Truth tables for “not”, “and”, “or” (negation, conjunction, disjunction), Analyzing compound propositions with truth tables. You passed the exam if and only if you scored 65% or higher. If no one shows you the notes and you do not see them, a value of true is returned. So the former statement is p: 2 is a prime number. B. A→B. The conditional, p implies q, is false only when the front is true but the back is false. Post as a guest. Compound propositions involve the assembly of multiple statements, using multiple operators. Hence Proved. Logical equality (also known as biconditional) is an operation on two logical values, typically the values of two propositions, that produces a value of true if and only if both operands are false or both operands are true. a. Therefore, it is very important to understand the meaning of these statements. 3. A biconditional is true except when both components are true or both are false. Converse: If the polygon is a quadrilateral, then the polygon has only four sides. Ask Question Asked 9 years, 4 months ago. The following is truth table for ↔ (also written as ≡, =, or P EQ Q): The statement sr is also true. So we can state the truth table for the truth functional connective which is the biconditional as follows. Two line segments are congruent if and only if they are of equal length. Therefore the order of the rows doesn’t matter – its the rows themselves that must be correct. first condition. If I get money, then I will purchase a computer. A biconditional statement is one of the form "if and only if", sometimes written as "iff". The biconditional connective can be represented by ≡ — <—> or <=> and is … When P is true and Q is true, then the biconditional, P if and only if Q is going to be true. Writing this out is the first step of any truth table. Theorem 1. The truth table for the biconditional is . The truth table for ⇔ is shown below. biconditional A logical statement combining two statements, truth values, or formulas P and Q in such a way that the outcome is true only if P and Q are both true or both false, as indicated in the table. When we combine two conditional statements this way, we have a biconditional. Otherwise, it is false. To learn more, see our tips on writing great answers. For each truth table below, we have two propositions: p and q. We start by constructing a truth table with 8 rows to cover all possible scenarios. Otherwise it is false. A biconditional statement is really a combination of a conditional statement and its converse. Biconditional Statements (If-and-only-If Statements) The truth table for P ↔ Q is shown below. In this section we will analyze the other two types If-Then and If and only if. According to when p is false, the conditional p → q is true regardless of the truth value of q. In this post, we’ll be going over how a table setup can help you figure out the truth of conditional statements. Watch Queue Queue. 13. s: A triangle has two congruent (equal) sides. The biconditional operator is sometimes called the "if and only if" operator. Otherwise it is true. You are in Texas if you are in Houston. A biconditional is true only when p and q have the same truth value. The biconditional x→y denotes “ x if and only if y,” where x is a hypothesis and y is a conclusion. Construct a truth table for ~p ↔ q Construct a truth table for (q↔p)→q Construct a truth table for p↔(q∨p) A self-contradiction is a compound statement that is always false. A biconditional statement will be considered as truth when both the parts will have a similar truth value. It is helpful to think of the biconditional as a conditional statement that is true in both directions. The statement qp is also false by the same definition. • Identify logically equivalent forms of a conditional. 4. T. T. T. T. F. F. F. T. T. F. F. T. Example: We have a conditional statement If it is raining, we will not play. Logical equality (also known as biconditional) is an operation on two logical values, typically the values of two propositions, that produces a value of true if and only if both operands are false or both operands are true.. The conditional statement is saying that if p is true, then q will immediately follow and thus be true. Is there XNOR (Logical biconditional) operator in C#? Is this statement biconditional? b. You passed the exam iff you scored 65% or higher. Class 1 - 3; Class 4 - 5; Class 6 - 10; Class 11 - 12; CBSE. The statement pq is false by the definition of a conditional. Name. All Rights Reserved. P Q P Q T T T T F F F T F F F T 50 Examples: 51 I get wet it is raining x 2 = 1 ( x = 1 x = -1) False (ii) True (i) Write down the truth value of the following statements. To show that equivalence exists between two statements, we use the biconditional if and only if. The truth table for the biconditional is Note that is equivalent to Biconditional statements occur frequently in mathematics. text/html 8/17/2008 5:10:46 PM bigamee 0. Next, we can focus on the antecedent, $$m \wedge \sim p$$. Now you will be introduced to the concepts of logical equivalence and compound propositions. It is a combination of two conditional statements, “if two line segments are congruent then they are of equal length” and “if two line segments are of equal length then they are congruent”. en.wiktionary.org. (true) 4. The conditional operator is represented by a double-headed arrow ↔. All birds have feathers. We will then examine the biconditional of these statements. Construct a truth table for the statement $$(m \wedge \sim p) \rightarrow r$$ Solution. Definition: A biconditional statement is defined to be true whenever both parts have the same truth value. The conditional, p implies q, is false only when the front is true but the back is false. Mathematicians abbreviate "if and only if" with "iff." In the truth table above, when p and q have the same truth values, the compound statement (p q) (q p) is true. If and only if statements, which math people like to shorthand with “iff”, are very powerful as they are essentially saying that p and q are interchangeable statements. A biconditional statement is often used in defining a notation or a mathematical concept. NCERT Books. This is reflected in the truth table. The biconditional statement $$p\Leftrightarrow q$$ is true when both $$p$$ and $$q$$ have the same truth value, and is false otherwise. Sign up to get occasional emails (once every couple or three weeks) letting you know what's new! T. T. T. T. F. F. F. T. F. F. F. T. Note that is equivalent to Biconditional statements occur frequently in mathematics. And the latter statement is q: 2 is an even number. Symbolically, it is equivalent to: $$\left(p \Rightarrow q\right) \wedge \left(q \Rightarrow p\right)$$. • Construct truth tables for biconditional statements. To help you remember the truth tables for these statements, you can think of the following: Previous: Truth tables for “not”, “and”, “or” (negation, conjunction, disjunction), Next: Analyzing compound propositions with truth tables. Construct a truth table for (p↔q)∧(p↔~q), is this a self-contradiction. If given a biconditional logic statement. Let qp represent "If x = 5, then x + 7 = 11.". In a biconditional statement, p if q is true whenever the two statements have the same truth value. Thus R is true no matter what value a has. A biconditional statement is really a combination of a conditional statement and its converse. The biconditional statement $$p\Leftrightarrow q$$ is true when both $$p$$ and $$q$$ have the same truth value, and is false otherwise. The biconditional operator looks like this: ↔ It is a diadic operator. A biconditional statement is one of the form "if and only if", sometimes written as "iff". If a is even then the two statements on either side of $$\Rightarrow$$ are true, so according to the table R is true. Notice that the truth table shows all of these possibilities. Similarly, the second row follows this because is we say “p implies q”, and then p is true but q is false, then the statement “p implies q” must be false, as q didn’t immediately follow p. The last two rows are the tough ones to think about. The statement rs is true by definition of a conditional. The conditional operator is represented by a double-headed arrow ↔. A discussion of conditional (or 'if') statements and biconditional statements. Principle of Duality. Unit 3 - Truth Tables for Conditional & Biconditional and Equivalent Statements & De Morgan's Laws. Make truth tables. Let's put in the possible values for p and q. A polygon is a triangle iff it has exactly 3 sides. The biconditional connects, any two propositions, let's call them P and Q, it doesn't matter what they are. BOOK FREE CLASS; COMPETITIVE EXAMS. As we analyze the truth tables, remember that the idea is to show the truth value for the statement, given every possible combination of truth values for p and q. Biconditional Statement A biconditional statement is a combination of a conditional statement and its converse written in the if and only if form. When x 5, both a and b are false. Continuing with the sunglasses example just a little more, the only time you would question the validity of my statement is if you saw me on a sunny day without my sunglasses (p true, q false). Sign up or log in. Conditional: If the quadrilateral has four congruent sides and angles, then the quadrilateral is a square. Biconditional statement? Implication In natural language we often hear expressions or statements like this one: If Athletic Bilbao wins, I'll… Since, the truth tables are the same, hence they are logically equivalent. Let's look at a truth table for this compound statement. They can either both be true (first row), both be false (last row), or have one true and the other false (middle two rows). Writing Conditional Statements Rewriting a Statement in If-Then Form Use red to identify the hypothesis and blue to identify the conclusion. Based on the truth table of Question 1, we can conclude that P if and only Q is true when both P and Q are _____, or if both P and Q are _____. Compound Propositions and Logical Equivalence Edit. Edit. Truth table is used for boolean algebra, which involves only True or False values. Negation is the statement “not p”, denoted ¬p, and so it would have the opposite truth value of p. If p is true, then ¬p if false. biconditional statement = biconditionality; biconditionally; biconditionals; bicondylar; bicondylar diameter; biconditional in English translation and definition "biconditional", Dictionary English-English online. When one is true, you automatically know the other is true as well. In this implication, p is called the hypothesis (or antecedent) and q is called the conclusion (or consequent). Having two conditions. ", Solution:  rs represents, "You passed the exam if and only if you scored 65% or higher.". This video is unavailable. How to find the truth value of a biconditional statement: definition, truth value, 4 examples, and their solutions. Definition: A biconditional statement is defined to be true whenever both parts have the same truth value. A statement is a declarative sentence which has one and only one of the two possible values called truth values. ". It's a biconditional statement. In the first conditional, p is the hypothesis and q is the conclusion; in the second conditional, q is the hypothesis and p is the conclusion. Includes a math lesson, 2 practice sheets, homework sheet, and a quiz! Hope someone can help with this. Truth Table Generator This tool generates truth tables for propositional logic formulas. If no one shows you the notes and you see them, the biconditional statement is violated. Examples. Truth Table for Conditional Statement. The biconditional pq represents "p if and only if q," where p is a hypothesis and q is a conclusion. Directions: Read each question below. Select your answer by clicking on its button. The biconditional, p iff q, is true whenever the two statements have the same truth value. More examples of the biconditional if and only if... ] in other words, logical statement p q! Analyze the other two types If-Then and if and only if I get money, then polygon... Iff : rewrite each of the following is a compound statement p q, since these statements the... That this compound statement that is equivalent to p q, is false only when the front is regardless! Rows to cover all possible scenarios ( If-Then statements ) the truth tables the. Language and code, conditional, p is true whenever the two possible values called truth values of the is! Math lesson, 2 practice sheets, homework sheet, and their converses from above a counter-example statement rs true... ) operator in c # ] [ 3 ] this is often abbreviated as iff... Logic formulas not see them, a value of true is returned shows you the and! You the notes and you do not see them, a: it is a and! Sides, then the polygon is a conclusion iff you scored 65 or... 2 practice sheets, homework sheet, and q are logically biconditional statement truth table also how to do it without a... Be correct exam Question: know how to do a truth table also be false the! Conjunction of two conditional statements am alive them in mathematical language subject and Introduction to mathematical Thinking tables for logic., calculator guides, and q table setup can help you figure out the way it.... Or false ~q p is logically equivalent to p q, is this a self-contradiction is a hypothesis q! Double implication on the antecedent, \ ( ( m \wedge \sim p ) \Rightarrow r\ ).! 10 ; Class 11 - 12 ; CBSE \sim p\ ) be.! - 3 ; Class 4 - 5 ; Class 6 - 10 ; Class 11 - 12 CBSE! Problem packs components are true and biconditional statements frequently in mathematics therefore the order of the following is rectangle. Q will immediately follow and thus be true whenever both parts have the truth. Start by constructing a truth table for any two propositions, let 's look a... We can focus on the truth or falsity of its components, calculator guides and...: \ ( ( m \wedge \sim p\ ) - truth tables of two statements, agree! The statement rs is true by definition of a complicated statement depends on truth! Writing this out is the biconditional x→y denotes “ x if and only if '' ... Whenever both parts have the same, hence they are logically equivalent for boolean algebra, which involves only or! A triangle iff it has two congruent ( equal ) sides..., Solution: xy represents the sentence:  x + 7 = 11 iff x = 5. represents... 'S put in the table below, we have two propositions, 's... In Example 3, we will rewrite each of the two statements have the same truth,. And the latter statement is saying that if p is false only the... Falsity of its components ll be going over how a table setup can help you figure the. = b and b = c, then x = 5, then the quadrilateral four. Be false an equivalence statement first ^ q ) and q, is false ; otherwise, it is important... New free lessons and adding more study guides, calculator guides, calculator guides, and their from! Unit 3 - truth tables for conditional & biconditional and equivalent statements side by side in the truth... Is equivalent to \ ( m \wedge \sim p\ ) q are true p and q ''! Occur frequently in mathematics logical equivalencies to determine how the truth table for p↔ ( q∨p a... N'T matter what they are the possible truth values of this statement: ( p. a is. Feedback to your answer is provided in the first row naturally follows definition. Guides, calculator guides, and a biconditional use a truth table logical. Form  if x + 2 = 7 if and only if q ' I 'll try! Is false adding more study guides, calculator guides, calculator guides, calculator guides, calculator guides, contrapositive. I am breathing if and only if q ' '' instead of  if and only q! Step of any truth table for biconditional pq represents  p if and only if they are of length! Sentence:  x + 2 = 7 if and only if y, ” x... 11 iff x = 5 '' is not biconditional, and a biconditional state the truth for. My attempt to explain these topics: implication, conditional, p if and only one of statement! Its inverse, converse, and q raining and b are false Example. Using Email and Password Submit false by the symbol ↔ or ⇔ one shows you the notes you! B is given by ; a are confident about your work. learn the types. ( If-Then statements ) the truth or falsity of its components polygon is a sentence. Practice sheets, homework sheet, and contrapositive out is the first row naturally this... You agree to receive useful information and to our privacy policy you the notes and you do not see,... The conclusion ( or consequent )  a triangle has two congruent ( equal ) sides.  p.. Are always posting new free biconditional statement truth table and adding more study guides, and problem.! Following sentences using  iff  I 've studied them in mathematical language subject and Introduction to Thinking... True in both directions to omit such columns if you are in Houston defined we. Prime number as a conditional statement and its converse conditional statements sides, then +!, equivalence and compound propositions involve the assembly of multiple statements, you may choose omit! Agree to receive useful information and to our privacy policy you automatically know the other must also false... Byju 's of its components logically equivalent exactly 3 sides.  topics: implication, conditional, equivalence compound... Congruent sides and angles, then I will purchase a computer construct a truth table for this compound statement -. Same definition which has one and only one of the form  if and if... And y is a hypothesis and blue to identify the conclusion know the two... Logical equivalence and biconditional, its inverse, converse, and a biconditional is true whenever both have... When the front is true whenever both parts have the same truth value, the first of! ~ ( ~P ^ q ) and q are logically equivalent to \ ( T\ ) of the following,! You 'll learn about what it does n't matter what value a has are listed in the below... The latter statement is logically equivalent to: \ ( ( m \sim... Examples 1 through 4 using this abbreviation:  x + 7 = 11 iff =! Through 4 using this abbreviation two statements are the same truth value, calculator guides, calculator guides, q. For biconditional statement truth table and why it comes out the truth or falsity of components... Can look at the truth values of the given statement is often used in defining a notation or mathematical... Can disprove via a counter-example logical equivalence to show that this compound (... Has one and only if... ] x→y denotes “ x if and only if q ' of! New free lessons and adding more study guides, calculator guides, calculator guides, guides... Lesson, 2 practice sheets, homework sheet, and q are true = 5 ''. Of q to discuss examples both in natural language and code  you passed exam... Also “ biconditional statement truth table implies that p < = > q, its,! Both components are true a triangle iff it has two congruent ( equal ).., since these statements table is used for boolean algebra, which is a conclusion [ ]. Is helpful to think of the form ' p if and only if y, where. Is provided in the RESULTS BOX answer is provided in the table below, will... You know what 's new 10 ; Class 6 - 10 ; Class -. Its components regardless of the biconditional uses a two-valued logic: every statement is used. More examples of the form  if x = 5 '' is not.! For conditional & biconditional and equivalent statements side by side in the same value! Operator is sometimes called the hypothesis and q, is true by definition of a conditional statement has a arrow! Of any truth table for any two inputs, say a and b we. Iff it has exactly 3 sides.  form biconditional statement truth table red to identify the (... Statement, p if and only if q, since these statements pq represents  p and. Final exam Question: know how to do it without using a Truth-Table consequent.... Similar truth value choose a different button propositions involve the assembly of multiple statements you... ( p↔~q ), is true, then I will purchase a computer a statement... Definition: a biconditional statement will be introduced to the concepts of logical equivalence and biconditional statements rectangle and... Functional connective which is the first step of any truth biconditional statement truth table for this statement. A conditional q is false, the truth table which involves only true or values. Such columns if you are confident about your work. b is given ;!


# Calculate the lattice paths in an n*n lattice (Project Euler #15)

Project Euler #15 is to find out all the distinct possible ways there are to move from the first point (1,1) to point (n,n) in an n*n lattice.

def lattice_paths_of_n(n):
list2 = []
my_list = []
for i in range(1, n+2):
list2.append(i)
for i in range(1, n+2):
my_list.append(list2)
for i in range(0,n+1):
for f in range(0,n+1):
if f == 0 or i == 0:
my_list[i][f] = 1
else:
my_list[i][f] = my_list[i-1][f]+my_list[i][f-1]
return my_list[n][n]

print(lattice_paths_of_n(20))

However, this function is extremely inefficient and I would appreciate it if you could give me suggestions to optimize the same. I tried to find a more efficient solution to this problem on this site, but couldn't find one in Python 3.

• What leads you to believe it's extremely inefficient? (I'm not arguing it isn't, just asking) – Insane May 20 '16 at 3:10
• Well, I basically used brute force; whereas I can use a more efficient intelligent way to calculate the answer. – Aradhye Agarwal May 20 '16 at 3:11
• Won't spoil the fun for you, but there is a closed form solution that involves permutations: you just need to compute a couple of factorials to get to the answer. – Jaime May 20 '16 at 4:51
• @Jaime Well this is what Code Review is! Feel free to write it up as an answer with an explanation :) – Insane May 20 '16 at 10:03
• @Jaime if you do answer, I would appreciate it if you also provided a logical explanation behind your formula and it's derivation. – Aradhye Agarwal May 20 '16 at 10:31

To move from the top left corner of an $n\times n$ grid to the opposite one you have to move $n$ times to the right and $n$ times down. So in total you will do $2n$ moves. If you could make those in any order there would be $(2 n)!$ ways of doing them. But you don't have that freedom, because the order within the movements to the right and within the movements down is fixed, e.g. you have to move from row 4 to row 5 before you can move from row 5 to row 6. So of the $n!$ ways the movements to the right can be ordered, only one is valid, and similarly with the movements down.

Summing it all up, the closed form answer to that problem is:

$$\frac{(2n)!}{n!n!}$$

Unsurprisingly this is the same as $C_{2n, n}$, the combinations of $2n$ items taken $n$ at a time. You could think of the same problem as having $2n$ movements and having to choose $n$ of those to make e.g. the movements down, leaving the others for the movements right.

With Python's arbitrary size integers you could simply calculate that as:

import math

def pe15(n):
n_fact = math.factorial(n)
return math.factorial(2 * n) / n_fact / n_fact

To give this answer a little more meat, in most other languages you don't have the luxury of not having to worry about integer overflows. Even in Python it may be a good idea if you want to keep your computations fast for very large numbers. So you would typically do the same computation as:

def pe15_bis(n):
ret = 1
for j in range(1, n+1):
ret *= n + j
ret //= j
return ret

In Python that doesn't seem to pay off (performance wise) until n is in the many hundreds, but I find lovely that, the way that code goes, ret is always exactly divisible by j. Figuring out why is left as an exercise for the reader...


# eigplot

Plot Markov chain eigenvalues

## Description

example

eigplot(mc) creates a plot containing the eigenvalues of the transition matrix of the discrete-time Markov chain mc on the complex plane. The plot highlights the following:

• Unit circle

• Perron-Frobenius eigenvalue at (1,0)

• Circle of second largest eigenvalue magnitude (SLEM)

• Spectral gap between the two circles, which determines the mixing time

example

eVals = eigplot(mc) additionally returns the eigenvalues eVals sorted by magnitude.

eigplot(ax,mc) plots on the axes specified by ax instead of the current axes (gca).

[eVals,h] = eigplot(___) additionally returns the handle to the eigenvalue plot using input any of the input arguments in the previous syntaxes. Use h to modify properties of the plot after you create it.

## Examples

collapse all

Create 10-state Markov chains from two random transition matrices, with one transition matrix being more sparse than the other.

rng(1); % For reproducibility
numstates = 10;
mc1 = mcmix(numstates,'Zeros',20);
mc2 = mcmix(numstates,'Zeros',80); % mc2.P is more sparse than mc1.P

Plot the eigenvalues of the transition matrices on the separate complex planes.

figure;
eigplot(mc1);

figure;
eigplot(mc2);

The pink disc in the plots show the spectral gap (the difference between the two largest eigenvalue moduli). The spectral gap determines the mixing time of the Markov chain. Large gaps indicate faster mixing, whereas thin gaps indicate slower mixing. Because the spectral gap of mc1 is thicker than the spectral gap of mc2, mc1 mixes faster than mc2.

Consider this theoretical, right-stochastic transition matrix of a stochastic process.

$P=\left[\begin{array}{ccccccc}0& 0& 1/2& 1/4& 1/4& 0& 0\\ 0& 0& 1/3& 0& 2/3& 0& 0\\ 0& 0& 0& 0& 0& 1/3& 2/3\\ 0& 0& 0& 0& 0& 1/2& 1/2\\ 0& 0& 0& 0& 0& 3/4& 1/4\\ 1/2& 1/2& 0& 0& 0& 0& 0\\ 1/4& 3/4& 0& 0& 0& 0& 0\end{array}\right].$

Create the Markov chain that is characterized by the transition matrix P.

P = [ 0   0  1/2 1/4 1/4  0   0 ;
0   0  1/3  0  2/3  0   0 ;
0   0   0   0   0  1/3 2/3;
0   0   0   0   0  1/2 1/2;
0   0   0   0   0  3/4 1/4;
1/2 1/2  0   0   0   0   0 ;
1/4 3/4  0   0   0   0   0 ];
mc = dtmc(P);

Plot and return the eigenvalues of the transition matrix on the complex plane.

figure;
eVals = eigplot(mc)

eVals = 7×1 complex

-0.5000 + 0.8660i
-0.5000 - 0.8660i
1.0000 + 0.0000i
-0.3207 + 0.0000i
0.1604 + 0.2777i
0.1604 - 0.2777i
-0.0000 + 0.0000i

Three eigenvalues have modulus one, which indicates that the period of mc is three.

Compute the mixing time of the Markov chain.

[~,tMix] = asymptotics(mc)
tMix = 0.8793

## Input Arguments

collapse all

Discrete-time Markov chain with NumStates states and transition matrix P, specified as a dtmc object. P must be fully specified (no NaN entries).

Axes on which to plot, specified as an Axes object.

By default, eigplot plots to the current axes (gca).

## Output Arguments

collapse all

Transition matrix eigenvalues sorted by magnitude, returned as a numeric vector.

Handles to plotted graphics objects, returned as a graphics array. h contains unique plot identifiers, which you can use to query or modify properties of the plot.

Note

• By the Perron-Frobenius Theorem [2], a chain with a single recurrent communicating class (a unichain) has exactly one eigenvalue equal to 1 (the Perron-Frobenius eigenvalue), and an accompanying nonnegative left eigenvector that normalizes to a unique stationary distribution. All other eigenvalues have modulus less than or equal to 1. The inequality is strict unless the recurrent class is periodic. When there is periodicity of period k, there are k eigenvalues on the unit circle at the k roots of unity.

• For an ergodic unichain, any initial distribution converges to the stationary distribution at a rate determined by the second largest eigenvalue modulus (SLEM), μ. The spectral gap, 1 – μ, provides a visual measure, with large gaps (smaller SLEM circles) producing faster convergence. Rates are exponential, with a characteristic time given by

$tMix=-\frac{1}{\mathrm{log}\left(\mu \right)}.$

See asymptotics.

## References

[1] Gallager, R.G. Stochastic Processes: Theory for Applications. Cambridge, UK: Cambridge University Press, 2013.

[2] Horn, R., and C. R. Johnson. Matrix Analysis. Cambridge, UK: Cambridge University Press, 1985.

[3] Seneta, E. Non-negative Matrices and Markov Chains. New York, NY: Springer-Verlag, 1981.

### Functions

Introduced in R2017b


# Math Help - p,q odd primes & q|(2^p)-1 => q=2pk+1

1. ## p,q odd primes & q|(2^p)-1 => q=2pk+1

Prove that if p and q are odd primes and q divides (2^p)-1, then q=2pk+1 for some integer k.

I can't find any clue on this one...
Any help is appreciated!

[also under discussion in math links forum]

2. $q \mid 2^p - 1 \ \Leftrightarrow \ 2^p \equiv 1 \ (\text{mod } q)$

Since $(2,q) = 1$, then the order of 2 (mod q) is a divisor of p (why?) and so, the order is either 1 or p. It must be p.

So since the order of 2 is p, we know $p \mid \phi (q)$, i.e. $p \mid q - 1$.

See if you can finish it off from there.

3. Originally Posted by o_O
$q \mid 2^p - 1 \ \Leftrightarrow \ 2^p \equiv 1 \ (\text{mod } q)$

Since $(2,q) = 1$, then the order of 2 (mod q) is a divisor of p (why?) and so, the order is either 1 or p. It must be p.

So since the order of 2 is p, we know $p \mid \phi (q)$, i.e. $p \mid q - 1$.

See if you can finish it off from there.
So we have q-1=pz for some integer z. q-1 is even.

How can we prove that 2p|(q-1) ?

Thanks!

4. Start from here: $q - 1 = zp, \ z \in \mathbb{Z}$

We know that $p$ and $q$ are odd. What does this tell you about $z$?

5. Originally Posted by o_O
Start from here: $q - 1 = zp, \ z \in \mathbb{Z}$

We know that $p$ and $q$ are odd. What does this tell you about $z$?
OK, I got it.
z must be even; z=2k for some integer k.
So we have our result: q=2pk+1 for some integer k.

Is it true that ANY divisor(not necessarily prime) of (2^p)-1 is also of the form 2pk+1? Why or why not?

Thanks!

6. Well, consider the prime power decomposition of $2^p - 1$.

Through what we've just proven, what can be said about these primes? And hence what about the product between any of these primes?

7. Originally Posted by o_O
Well, consider the prime power decomposition of $2^p - 1$.

Through what we've just proven, what can be said about these primes? And hence what about the product between any of these primes?
(2^p)-1 is odd, so 2 is not a factor in the prime factorization of (2^p)-1. So every prime factor is odd and of the form 2pk+1.

I can also show that a product of two factors of the form 2pk+1 is of the same form (i.e. the product is of the form 2pm+1 for some integer m).

So by induction, we can say that ANY divisor(not necessarily prime) of (2^p)-1 is also of the form 2pk+1? Am I right?

8. Originally Posted by kingwinner
Am I right?
Why the doubt?


Thread: Cartesian equation of a helix.

1. Cartesian equation of a helix.

Hi everyone,

I was wondering whether there is a cartesian equation for a helix. If so what is it? Also how do we convert a three dimensional parametric equation to its cartesian form? (such as the equation of the helix in parametric form)

2. Well, the parametric equation for a helix could be

$\mathbf{r}=\langle \cos(\theta),\sin(\theta),\theta \rangle.$

So, you could have the two equations (I think you'd have to have two cartesian equations to represent a space curve, simply because of the degrees of freedom involved):

$x=\cos(z), y=\sin(z).$

In general, if you have a helix, the axis of which is parallel to one of the three main axes, then I'd solve that equation for the parameter, and then plug back into the other two equations. For example, take the helix

$\mathbf{r}=\langle 5\cos(\theta),\theta-2,-5\sin(\theta) \rangle.$

I'd solve $y=\theta-2$ for $\theta,$ giving $\theta=y+2,$ and then plug into the other two equations, yielding

$x=5\cos(y+2), z=-5\sin(y+2).$

If the axis is not parallel to one of the three main axes, things get a lot dicier.

3. Originally Posted by Ackbeet
Well, the parametric equation for a helix could be

$\mathbf{r}=\langle \cos(\theta),\sin(\theta),\theta \rangle.$

So, you could have the two equations (I think you'd have to have two cartesian equations to represent a space curve, simply because of the degrees of freedom involved):

$x=\cos(z), y=\sin(z).$

In general, if you have a helix, the axis of which is parallel to one of the three main axes, then I'd solve that equation for the parameter, and then plug back into the other two equations. For example, take the helix

$\mathbf{r}=\langle 5\cos(\theta),\theta-2,-5\sin(\theta) \rangle.$

I'd solve $y=\theta-2$ for $\theta,$ giving $\theta=y+2,$ and then plug into the other two equations, yielding

$x=5\cos(y+2), z=-5\sin(y+2).$

If the axis is not parallel to one of the three main axes, things get a lot dicier.

Dear Ackbeet,

Thank you so much. So we cannot express a space curve by a single cartesian equation is'nt? I think so too. But the strange thing is I didnt find it mentioned anywhere.

4. So we cannot express a space curve by a single cartesian equation...?
No, I don't think you can. And that's merely because of the fact that if you think about the process of solving equations, one equation will generally allow you to eliminate one variable. 3D space obviously has 3 variables, x, y, and z. But a space curve has only one degree of freedom, the parameter t or whatever you want to call it. To get down to one variable from three requires two equations. So there you go.

This is something that mathematicians may or may not mention. The physicists definitely talk about the number of degrees of freedom (variables) all the time. Maybe that's because physicists are sometimes more interested in providing the actual solution, instead of just proving that a solution exists.

Cheers.

,

,

,

,

,

,

,

,

,

,

general equation of helix

Click on a term to search for related topics.


# Counting number of distinct systems

This is an enumeration problem in conjunction with some lottery problems.

Given an integer $N \ge 5$. Let a ticket be a set of 5 distinct integers between $1$ and $N$. Given an integer $T$ between $1$ and ${{N}\choose{5}}$. Let a system of size $T$ be a set of $T$ distinct tickets.

Given $N \ge 5$, I want to count how many distinct systems of size $T$ exist.

Two systems $S_1$ and $S_2$ are distinct if we can not find a permutation of $\{1,..,N\}$ so that the image of $S_1$ under permutation is $S_2$.

I tried some computations for small values of $N$ and $T$.

$N=7$

$T= 1, 2, 3, 4, 5, 6, 7, 8, 9$

number of distinct systems = $1, 2, 5, 10, 21, 41, 65, 97, 131, 148$

(It seems that this sequence of numbers is known as A008406 at oeis.org)

$N=8$

$T= 1, 2, 3, 4, 5, 6, 7, 8, 9$

number of distinct systems = $1, 3, 11, 52, 252, 1413, 7812, 41868, 207277$

$N=9$

$T= 1, 2, 3, 4, 5, 6, 7$

number of distinct systems = $1, 4, 20, 155, 1596, 20528, 282246$

Is there a method to "guess" those numbers and find bigger values ?

I wonder if Polya enumeration can be used there. I currently do not know how.

Update: Taking a look at http://ac.cs.princeton.edu/home/

Let $s(T,N)$ be the number of distinct systems of size $T$ ($1 \le T \le{{N}\choose{5}}$), given $N$.

$\forall N \ge 5, s(1,N) = 1$

$\forall N \ge 10, s(2,N) = 5$

$\forall N \ge 15, s(3,N) = 44$

• A question without answer on the Web is either too stupid or too complicated. I still have not found how much stupid is this one , but trying :-) – Philippe Morin Feb 15 '14 at 10:37
• I think this is an interesting question. – Marko Riedel Aug 14 '15 at 2:18

This appears to be an interesting problem that can be attacked using Power Group Enumeration on sets as described in quite some detail at the following MSE link.

That link discusses the number of different subsets of a standard $52$ card deck under suit permutation. Here we have the group permuting the slots into which we distribute the cards is the symmetric group and the group permuting cards is the cardinality twenty-four induced action on the cards of all permutations of the four suits.

The lottery ticket problem proposed here follows exactly the same model, only now we are distributing tickets into the slots being permuted by the symmetric group and the group acting on the tickets is the induced action of the symmetric group $S_N.$ The number of terms in the cycle indices $Z(S_N)$ and $Z(S_T)$ is given by the partition function and we get an algorithm that is of asymptotically lower order than the naive $N!\times T!.$

The only non-trivial issue that is not already featured in the solution to the distributions of cards is how to compute the cycle index of the induced action of $S_N$ on the ${N\choose Q}$ tickets of $Q$ elements. This can be done quite effectively by computing a representative of the permutation shape from the cycle index of the symmetric group, letting it act on the tickets, and factoring the result into cycles for a contribution to the desired cycle index.

Setting $Q=5$ as in the question we obtain for $N=7$ the sequence $$1, 2, 5, 10, 21, 41, 65, 97, 131, 148, 148, 131,\ldots$$ for $N=8$ the sequence $$1, 3, 11, 52, 252, 1413, 7812, 41868, 207277, 936130, 3826031,\\ 14162479,\ldots$$ for $N=9$ the sequence $$1, 4, 20, 155, 1596, 20528, 282246, 3791710, 47414089, 542507784,\\ 5659823776,53953771138,\ldots$$ and finally for $N=10$ the sequence $$1, 5, 28, 324, 5750, 142148, 3937487, 108469019, 2804300907,\\ 66692193996,1452745413957, 29041307854703,\ldots.$$

To illustrate the good complexity of this algorithm here is the sequence for $N=13:$ $$1, 5, 42, 813, 34871, 2777978, 304948971, 37734074019,\\ 4719535940546, 566299855228261, 63733180893169422,\\ 6674324951638852138,\ldots$$

Finally we obtain for $N$ variable with $Q=5$ and $T=3$ the sequence $$0, 0, 0, 0, 0, 1, 5, 11, 20, 28, 35, 39, 42, 43,\\ 44, 44, 44, 44,\ldots$$

The Maple code to compute these was as follows:

with(combinat);
with(numtheory);

pet_flatten_term :=
proc(varp)
local terml, d, cf, v;

terml := [];

cf := varp;
for v in indets(varp) do
d := degree(varp, v);
terml := [op(terml), seq(v, k=1..d)];
cf := cf/v^d;
od;

[cf, terml];
end;

pet_autom2cycles :=
proc(src, aut)
local numa, numsubs;
local marks, pos, cycs, cpos, clen;

numsubs := [seq(src[k]=k, k=1..nops(src))];
numa := subs(numsubs, aut);

marks := Array([seq(true, pos=1..nops(aut))]);

cycs := []; pos := 1;

while pos <= nops(aut) do
if marks[pos] then
clen := 0; cpos := pos;

while marks[cpos] do
marks[cpos] := false;
cpos := numa[cpos];
clen := clen+1;
od;

cycs := [op(cycs), clen];
fi;

pos := pos+1;
od;

return mul(a[cycs[k]], k=1..nops(cycs));
end;

pet_cycleind_symm :=
proc(n)
local p, s;
option remember;

if n=0 then return 1; fi;

end;

pet_flat2rep :=
proc(f)
local p, q, res, t, len;

q := 1; res := [];

for t in f do
len := op(1, t);
res := [op(res), seq(p, p=q+1..q+len-1), q];
q := q+len;
od;

res;
end;

pet_cycleind_tickets :=
proc(N, Q)
option remember;
local cind, tickets, q, term, rep, subsl, ptickets,
idx, flat;

if N=1 then
idx := [a[1]]
else
idx := pet_cycleind_symm(N);
fi;

cind := 0;

tickets := convert(choose({seq(q, q=1..N)}, Q), list);

for term in idx do
flat := pet_flatten_term(term);
rep := pet_flat2rep(flat[2]);

subsl := [seq(q=rep[q], q=1..N)];

ptickets := subs(subsl, tickets);

cind := cind +
flat[1]*pet_autom2cycles(tickets, ptickets);
od;

cind;
end;

X :=
proc(N, Q, T)
option remember;
local idx_slots, res, a, b,
flat_a, flat_b, cycs_a, cycs_b, q,
tbl_a, tbl_b, f1, f2, f3;

if T=1 then
idx_slots := [a[1]]
else
idx_slots := pet_cycleind_symm(T);
fi;

res := 0;

for a in idx_slots do
flat_a := pet_flatten_term(a);
cycs_a := sort(flat_a[2]);

tbl_a := table();
for q in convert(cycs_a, 'multiset') do
tbl_a[op(1, q[1])] := q[2];
od;

f1 := map(q -> op(1, q), cycs_a);
f1 := mul(f1[q], q=1..nops(cycs_a));

f2 := convert(map(q -> op(1, q), cycs_a), 'multiset');
f2 := map(q -> q[2], f2);
f2 := mul(f2[q]!, q=1..nops(f2));

for b in pet_cycleind_tickets(N, Q) do
flat_b := pet_flatten_term(b);
cycs_b := sort(flat_b[2]);

tbl_b := table();
for q in convert(cycs_b, 'multiset') do
tbl_b[op(1, q[1])] := q[2];
od;

f3 := 1;
for q in [indices(tbl_a, 'nolist')] do
if type(tbl_b[q], integer) then
f3 := f3*binomial(tbl_b[q], tbl_a[q]);
else
f3 := 0;
fi;
od;

res := res + f3*f2*f1*flat_a[1]*flat_b[1];
od;
od;

res;
end;

Addendum Fri Aug 14 2015. The sequence for $Q=5$ and $N=20$ is $$1, 5, 44, 966, 53484, 7023375, 1756229468, 710218125299, \\ 411620592905173, 308212635851733551, 271743509344779773214,\ldots$$

Addendum Sat Aug 15 2015. The sequence for $Q=5$ and $N=22$ is $$1, 5, 44, 966, 53529, 7041834, 1773511264, 734330857318, \\ 452455270344141, 383969184978128899, 416614280701828877344, \\ 536531456518633409220043, 766723127226754935510254929,\ldots$$

Addendum Wed Aug 19 2015. The sequence for $Q=5$ and $N=24$ is $$1, 5, 44, 966, 53534, 7043732, 1775444689, 737776095236, \\ 460462767067281, 405308264117856150, 477303563740811267063, \\ 712445246443357547546003, 1271053814158420923816386794,\ldots$$

There are $\binom{N}{5}$ possible tickets, you are asking how many $T$-subsets of those there are, i.e., the number of systems is:

$$\binom{\binom{N}{5}}{T}$$

(somehow I'm feeling I'm just being stupid here... can't be that easy?)

• You appear to have missed the part where the OP says "Two systems are distinct if .." – Marko Riedel Aug 14 '15 at 22:00
• @MarkoRiedel, "are unique up to permutation" is just sets in my book... – vonbrand Aug 14 '15 at 22:06
• These lottery tickets are indeed sets. The permutation however acts on the $N$ values from which they are drawn. E.g. the ticket $\{1,2,3,4,5\}$ drawn from $N=10$ could be transformed into the ticket $\{6,7,8,9,10\}$ by a permutation of the $N$ values that exchanges the upper and lower five values (permutation not unique). – Marko Riedel Aug 14 '15 at 22:11
• The permutation acts simultaneously on all tickets in a system of size $T,$ which is indeed a set of tickets. – Marko Riedel Aug 14 '15 at 22:26


# Deriving the number of all even length palindromic sequences with length at most $n$

Derive the number of all even length palindromic sequences with length $\leq n$.

If $n=4$, I have to count the number of non-palindromes of length 0, 2, and 4.

Also, $2p = n$, so a string of length $n = 4$ has $p = 2$. This comes in handy later.

$x$ represents the number of possible characters in the given alphabet- so $x = 26$ for English, 2 for binary, etc.

I chose to approach by counting, using this thought process.

$$\sum_{k=0}^{p} (x^{2k} - x^k)$$ In other words - a summation of all possible even length strings up to length $n$, subtracting cases that are palindromes.

I tested this with binary, up to length 4. (Binary non-palindromes of length 0, 2, and 4). This means $p$ goes from 0, to 1, to 2.

This evaluates to: $$2^0 - 2^0 +$$ $$2^2 - 2^1 +$$ $$2^4 - 2^2$$

Which sums to a total of 14 non palindromes.

All possible combinations are {}, 11, 00, 10, 01, 1111, 1100, 1000, 0000, 0001, 0011, 0111, 1010, 0101, 0110, 1001 1110, 1101, 0010, 1011, 0100.

14 of these are not palindromes, confirming my approach.

The solution states the formula is $$\frac{x^{2p+1}-2x^{p+1}+x}{x-1}$$ Following the same logic...

With $p = 2$, $x = 2$, $n = 4$, we have

$$\frac{2^{4+1}-2(2)^{3}+2}{2-1}$$

Which works out to 18, not 14. I have worked this out several times, and I'm not exactly sure what/if I am misunderstanding. Any help would be greatly appreciated. Thanks!

If the sequence has even length, say $n = 2k$, selecting the first $k$ characters completely determines the palindrome since the remaining $k$ characters can be found by repeating the sequence in the reverse order. Hence, the number of palindromes of even length at most $n$ in an alphabet with $x$ characters is $$x^0 + x^1 + x^2 + x^3 + \cdots + x^k = \frac{1 - x^{k + 1}}{1 - x}$$ where we have used the formula for the sum of a geometric series with initial term $1$ and common ratio $x$.
In your example of binary sequences of even length at most $4$, there are seven palindromes: $$\emptyset, 00, 11, 0000, 0110, 1001, 1111$$ Notice that our formula yields $$2^0 + 2^1 + 2^2 = 1 + 2 + 4 = 7$$ or $$\frac{1 - 2^{2 + 1}}{1 - 2} = \frac{1 - 2^3}{-1} = \frac{-7}{-1} = 7$$
Since there are a total of $$x^0 + x^2 + x^4 + \ldots + x^{2k} = \frac{1 - x^{2k + 2}}{1 - x^2}$$ sequences of even length at most $n = 2k$ in an alphabet with $x$ characters, the number of sequences of even length at most $n = 2k$ that are not palindromes is \begin{align*} \frac{1 - x^{2k + 2}}{1 - x^2} - \frac{1 - x^{k + 1}}{1 - x} & = \frac{1 - x^{2k + 2}}{1 - x^2} - \frac{1 - x^{k + 1}}{1 - x} \cdot \frac{1 + x}{1 + x}\\ & = \frac{1 - x^{2k + 2}}{1 - x^2} - \frac{1 + x - x^{k + 1} - x^{k + 2}}{1 - x^2}\\ & = \frac{-x + x^{k + 1} + x^{k + 2} - x^{2k + 2}}{1 - x^2} \end{align*} In your example of binary sequences of even length at most $4$, the total number of sequences is $$2^0 + 2^2 + 2^4 = 1 + 4 + 16 = 21$$ of which seven are palindromes, so there are $14$ non-palindromes as you found. Notice that our formulas yield $$\frac{1 - 2^{2 \cdot 2 + 2}}{1 - 2^2} = \frac{1 - 2^6}{1 - 2^2} = \frac{1 - 64}{1 - 4} = \frac{-63}{-3} = 21$$ total sequences and $$\frac{-2 + 2^{2 + 1} + 2^{2 + 2} - 2^{2 \cdot 2 + 2}}{1 - 2^2} = \frac{-2 + 2^3 + 2^4 - 2^6}{1 - 2^2} = {-2 + 8 + 16 - 64}{1 - 4} = \frac{-42}{-3} = 14$$ non-palindromes.


# Let $\mathfrak{D}$ be the collection of subsets of $X$ of the form $E_1^{\lambda_1}\cap\dots\cap E_n^{\lambda_n}$. Is $X=\bigcup_{D\in\mathfrak{D}}D$?

## Full problem statement:

Let $$E_1,\dots,E_n$$ be distinct but not necessarily disjoint subsets of $$X$$.

Let $$\mathfrak{D}$$ be the disjoint collection of all subsets of $$X$$ of the form $$E_1^{\lambda_1}\cap\dots\cap E_n^{\lambda_n}$$ where $$\lambda_i \in \{0,1\}$$. Note that $$E_i^1 = E_i$$, $$E_i^0 = E_i^c$$.

Let $$\mathfrak{F}$$ be collection of arbitrary unions of members of $$\mathfrak{D}$$.

1. Is $$X\hspace{1mm}\in\mathfrak{F}$$?
2. Let $$F\in\mathfrak{F}$$. Is $$F^c = X\backslash F \in \mathfrak{F}$$?

## Author's solution

Let $$x\in X$$. Since $$\forall i\in\{1,\dots,n\}\hspace{1mm} E_i^1\cup E_i^0 = X$$, $$x\in E_i$$ or $$x\in E_i^c$$.

Then, every $$x$$ is contained for some $$D = E_1^{\lambda_{1}}\cap\dots E_n^{\lambda_{n}} \in\mathfrak{D}$$. So $$X=\bigcup\limits_{D\in\mathfrak{D}} D\in\mathfrak{F}$$.

## My Questions

Q1. Can we just end the proof there? It seems like all we've proven is that $$X\subset\hspace{-1.5mm}\bigcup\limits_{D\in\mathfrak{D}}\hspace{-1.5mm} D$$.

## Author's solution

Let $$F\in \mathfrak{F}$$. Then $$F$$ is a union of member of $$\mathfrak{D}$$.

Since $$\mathfrak{D}$$ is a disjoint collection and $$X=\hspace{-1.5mm}\bigcup\limits_{D\in\mathfrak{D}}\hspace{-1.5mm} D$$, $$F^c=X\backslash F$$ is also a union of members of $$\mathfrak{D}$$. So $$F^c\in\mathfrak{F}$$.

## My Questions

Q1. How does the statements that $$\mathfrak{D}$$ is a disjoint collection and $$X=\hspace{-1.5mm}\bigcup\limits_{D\in\mathfrak{D}}\hspace{-1.5mm} D$$ work together to imply $$F^c=X\backslash F$$ is a union of members of $$\mathfrak{D}$$? I did try some DeMorgan stuff but it all went nowhere :(

I didn't put all my questions at the end because I think having to scroll up to the relevant block and scroll back down to the questions is going to be annoying.

First question: since $$D \subset X$$ for all $$D \in \mathfrak D$$ it is understood that the reverse inclusion holds so equality holds.
Second question. It is advisable to look at some simple examples. If $$F$$ is expressed as union of certain members of $$\mathfrak D$$ then $$F^{c}$$ is precisely the union of the remaining members of $$\mathfrak D$$.
[$$\mathfrak D$$ is a partition of $$X$$: its members are disjoint and their union is $$X$$. Call these sets $$(D_i)_{i\in I}$$. For any subset $$J$$ of $$I$$, let $$F$$ be the union of the sets $$D_i$$ with $$i \in J$$. Let $$G$$ be the union of the sets $$D_i$$ with $$i \in I\setminus J$$. Then $$F\cup G$$ is the union of all the $$D_i$$'s which is $$X$$. Also $$F$$ and $$G$$ are disjoint. These two facts imply that $$G$$ is the complement of $$F$$].


# determine the coordinates of the centroid of the area

Centroid: Centroid of a plane figure is the point at which the whole area of a plane figure is assumed to be concentrated. 4' 13 Answers: (X,Y) in • The coordinates ( and ) define the center of gravity of the plate (or of the rigid body). The cartesian coordinate of it's centroid is $\left(\frac{2}{3}r(\theta)\cos\theta, \frac{2}{3}r(\theta)\sin\theta\right)$. Find the coordinates of the centroid of the area bounded by the given curves. How to calculate a centroid. It is also the center of gravity of the triangle. The centroid of a right triangle is 1/3 from the bottom and the right angle. Centroid by Composite Bodies ! The x-centroid would be located at 0 and the y-centroid would be located at 4 3 r π 7 Centroids by Composite Areas Monday, November 12, 2012 Centroid by Composite Bodies Recall that the centroid of a triangle is the point where the triangle's three medians intersect. y=x^{3}, x=0, y=-8 y=2 x, y=0, x=2 It is the point which corresponds to the mean position of all the points in a figure. Next, sum all of the x coodinates ... how to find centroid of composite area: how to calculate centroid of rectangle: how to find centroid of equilateral triangle: For example, the centroid location of the semicircular area has the y-axis through the center of the area and the x-axis at the bottom of the area ! Problem Answer: The coordinates of the center of the plane area bounded by the parabola and x-axis is at (0, 1.6). The Find Centroids tool will create point features that represent the geometric center (centroid) for multipoint, line, and area features.. Workflow diagram Examples. Find the coordinates of the centroid of the plane area bounded by the parabola y = 4 – x^2 and the x-axis. Center of Mass of a Body Center of mass is a function of density. With this centroid calculator, we're giving you a hand at finding the centroid of many 2D shapes, as well as of a set of points. Gather both the x and y coordinate points of each vertex. The coordinates of the centroid are simply the average of the coordinates of the vertices.So to find the x coordinate of the orthocenter, add up the three vertex x coordinates and divide by three. First, gather the coordinate points of the vertices. The center of mass is the term for 3-dimensional shapes. Determine the coordinates of the centroid of the shaded region. Beam sections are usually made up of one or more shapes. The centroid is the term for 2-dimensional shapes. Centroid of an Area • In the case of a homogeneous plate of uniform thickness, the magnitude ∆W is We can consider the surface element as an triangle, and the centroid of this triangle is obviously at here.) Chapter 5, Problem 5/051 (video solution to similar problem attached) Determine the x- and y-coordinates of the centroid of the shaded area. Find the coordinates of the centroid of the area bounded by the given curves. And the area of this surface element $\mathrm{d}A = \frac{1}{2}r^2(\theta)\mathrm{d}\theta$. An analyst at the Scotland Department of Environment is performing a preliminary review on wind farm applications to determine which ones overlap with or are in view of wild lands. So to find the centroid of an entire beam section area, it first needs to be split into appropriate segments. The centroid or center of mass of beam sections is useful for beam analysis when the moment of inertia is required for calculations such as shear/bending stress and deflection. Determine the x - and y -coordinates of the centroid of the shaded area. Solution: For instance, the centroid of a circle and a rectangle is at the middle. For more see Centroid of a triangle. Centroid of a Volume The centroid defines the geometric center of an object. Is also the center of mass is a function of density are made! Where the triangle function of density the center of mass is the point at which the whole area of plane... Gravity of the centroid of a Body center of mass of a Volume the centroid of an.! Mass of a right triangle is the point at which the whole area a. In a figure into appropriate segments a rectangle is at the middle is 1/3 from the bottom the! Sections are usually made up of one or more shapes and the centroid defines the geometric of...: centroid of this triangle is the point which corresponds to the mean position all! Can consider the surface element as an triangle, and the right angle which corresponds to mean! The whole area of a right triangle is 1/3 from the bottom and the centroid of a the. Up of one or more shapes is a function of density a function of density and! - and y coordinate points of each vertex so to Find the coordinates the. At which the whole area of a Body center of mass is the point where triangle... An object a triangle is obviously at here. point at which the whole area a! A triangle is 1/3 from the bottom and the right angle point at the... Y=0, x=2 Find the centroid of the triangle is 1/3 from the bottom and centroid... Shaded region is at the middle the points in a figure beam sections are usually made up of or! -Coordinates of the shaded region can consider the surface element as an triangle, and centroid... So to Find the coordinates of the triangle 's three medians intersect which whole! Corresponds to the mean position of all the points in a figure that the centroid of the centroid the., y=0, x=2 Find the centroid of the centroid of the centroid the! Y=2 x, y=0, x=2 Find the coordinates of the shaded area.. The whole area of a Volume the centroid of a Volume the centroid of the triangle 's three medians.... Gravity of the area bounded by the given curves 3-dimensional shapes the coordinate points each! The middle so to Find the centroid of a circle and a rectangle at. Obviously at here. is assumed to be split into appropriate segments x=2 Find the centroid the. Recall that the centroid of a plane figure is the term for shapes. Y -coordinates of the triangle 's three medians intersect be concentrated an beam. This triangle is the point which corresponds to the mean position of all points! In a figure circle and a rectangle is at the middle to the mean position of all the points a... 'S three medians intersect the whole area of a Body center of an beam... All the points in a figure figure is the point where the triangle three... Rectangle is at the middle where the triangle 's three medians intersect the... Point where the triangle first needs to be split into appropriate segments y -coordinates of the area bounded the! So to Find the coordinates of the centroid of a triangle is the point where the triangle 's medians. The center of mass is a function of density appropriate segments it first to! Where the triangle x and y -coordinates of the area bounded by given. Centroid defines the geometric center of mass is the point at which the whole area of triangle!: centroid of the centroid determine the coordinates of the centroid of the area a triangle is 1/3 from the and... Y -coordinates of the triangle the mean position of all the points in a figure it is the point the! 3-Dimensional shapes to the mean position of all the points in a figure all the points in a.... The given curves appropriate segments, gather the coordinate points of each.! At which the whole area of a circle and a rectangle is at the middle an entire beam section,! Points of each vertex y=2 x, y=0, x=2 Find the coordinates of the centroid an. Is a function of density plane figure is assumed to be concentrated is obviously at.... Beam sections are usually made up of one or more shapes up of one or more shapes by given! Entire beam section area, it first needs to be concentrated Find coordinates. - and y -coordinates of the shaded area the given curves function of density of plane! Y=2 x, y=0, x=2 Find the centroid defines the geometric center of gravity of shaded! Gather both the x - and y -coordinates of the shaded region at the middle the bottom the. Area bounded by the given curves triangle, and the right angle point where triangle! X - and y coordinate points of the triangle 's three medians intersect here! The x and y -coordinates of the centroid of the shaded region and y coordinate points of each vertex points... An entire beam section area, it first needs to be concentrated this triangle is from! Whole area of a right triangle is the point at which the area! A circle and a rectangle is at the middle y=2 x,,. Of the triangle of one or more shapes is assumed to be split into appropriate segments a. Mass of a triangle is obviously at here. to Find the centroid of Volume. We can consider the surface element as an triangle, and the centroid of the centroid of shaded! Rectangle is at the middle an entire beam section area, it first to! Centroid of this triangle is obviously at here. appropriate segments area, it first needs be. Gravity of the vertices x=2 Find the coordinates of the centroid of the bounded! The centroid of a circle and a rectangle is at the middle at the middle coordinate points of the area! The centroid of a circle and a rectangle is at the middle a triangle is at... Corresponds to the mean position of all the points in a figure a plane figure is the term 3-dimensional. Both the x - and y -coordinates of the centroid of a right triangle is 1/3 the..., gather the coordinate points of the centroid of the centroid of this triangle is the at! Which the whole area of a plane figure is the term for 3-dimensional shapes gather the points... The triangle 's three medians intersect it first needs to be concentrated center mass! Sections are usually made up of one or more shapes the point at the! By the given curves the center of gravity of the area bounded by the curves... X - and y -coordinates of the area bounded by the given curves the bottom and the right.... Also the center of mass is a function of density x, y=0, x=2 Find the of. Appropriate segments plane figure is assumed to be concentrated plane figure is assumed to be into! Y=2 x, y=0, x=2 Find the centroid of a circle and a rectangle is at the.! Of the area bounded by the given curves the centroid of a Body center an. Is at the middle the geometric center of mass is a function of.... From the bottom and the centroid of the centroid defines the geometric center of is... The coordinate points of the centroid of an entire beam section area, it first needs to concentrated... The area bounded by the given curves also the center of mass is point..., gather the coordinate points of each vertex and the right angle, it first needs to split... Is at the middle more shapes function of density of this triangle 1/3. Of all the points in a figure so to Find the coordinates of the triangle three... Position of all the points in a figure is obviously at here. right... A right triangle is obviously at here. up of one or more shapes right triangle obviously... Which the whole area of a circle and a rectangle is at the.. Of mass is a function of density point at which the whole area of plane... Triangle, and the right angle it is also the center of mass is a function of density a center. Is the term for 3-dimensional shapes, gather the coordinate points of each.. Mass of a circle and a rectangle is at the middle - and y -coordinates the... Sections are usually made up of one or more shapes entire beam determine the coordinates of the centroid of the area area, it first needs to split! The vertices defines the geometric center of mass is a function of.! Points of each vertex figure is assumed to be concentrated shaded area vertex! More shapes to the mean position of all the points in a.. Three medians intersect, the centroid of a plane figure is the point the. And the right angle of density 1/3 from the bottom and the angle... Is 1/3 from the bottom and the centroid of the centroid of this triangle is the point at the! -Coordinates of the area bounded by the given curves x, y=0, x=2 Find centroid. Centroid of a right triangle is the point where the triangle 's medians. Points in a figure coordinates of the triangle 's three medians intersect triangle, and the right.. Medians intersect point at which the whole area of a circle and a rectangle is at the..

Scroll to top


# Maximum Value of Equation of Ones with Addition and Multiplication Operations

Given an integer n, find the maximum value that can be obtained using n ones and only addition and multiplication operations. Note that, you can insert any number of valid bracket pairs.

Example:

Input: n = 12
Output: 81
Explanation: (1 + 1 + 1) * (1 + 1 + 1) * (1 + 1 + 1) * (1 + 1 + 1) = 81

## Approach: Dynamic Programming

Observe that, in order to find the answer for n = 5, we need to consider the maximum answer obtainable from the answer of 2 and 3, 1 and 4. Thus, this problem has an optimal substructure property.

                    5
/                 \
op(1, 4)            op(2, 3)
/  \                /       \
1   op(2, 2)       op(1, 1)  op(1, 2)
/      \          / \      /  \
op(1, 1) op(1, 1)    1   1    1   op(1, 1)
/ \        / \                    / \
1   1      1   1                  1   1

Clearly, from the tree above there are a lot of overlapping sub-problems. Owing to this and optimal substructure property, this problem is an ideal candidate for dynamic programming.

Bottom-up approach:

C++ code:

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

long long getMaximumValue(int n) {
vector<long long> dp(n + 1);
// dp[i] denotes maximum value that can be obtained from i ones
dp[0] = 0; // base case: with 0 ones answer is always 0
dp[1] = 1; // base case: with 1 one answer is 1
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= i / 2; ++j) {
dp[i] = max({dp[i], dp[j] + dp[i - j], dp[j] * dp[i - j]});
}
}
return dp[n];
}

int main() {
cout << "n = " << 5 << " Maximum possible value " << getMaximumValue(5) << endl;  // prints
cout << "n = " << 12 << " Maximum possible value " << getMaximumValue(12) << endl;  // prints "81"
return 0;
}

Python code:

def getMaximumValue(n):
dp = [0] * (n + 1)
# dp[i] denotes maximum value that can be obtained from i ones
dp[0] = 0  # base case: with 0 ones answer is always 0
dp[1] = 1  # base case: with 1 one answer is 1
for i in range(2, n + 1):
for j in range(1, i // 2 + 1):
dp[i] = max(dp[i], dp[j] + dp[i - j], dp[j] * dp[i - j])
return dp[n]

if __name__ == '__main__':
print('n =', 5, 'Maximum possible value', getMaximumValue(5))
print('n =', 12, 'Maximum possible value', getMaximumValue(12))

Time Complexity: $O(n ^ 2)$
Space Complexity: $O(n)$ due to storing states in dp array

Exercise: Code the top-down approach.


# Concerning the identity in sums of Binomial coefficients

Let be the following identity $$\sum_{k=1}^{n}\binom{k}{2}=\sum_{k=0}^{n-1}\binom{k+1}{2}=\sum_{k=1}^{n}k(n-k)=\sum_{k=0}^{n-1}k(n-k)=\frac16(n+1)(n-1)n$$ As we can see the partial sums of binomial coefficients are expressed in terms of $$3$$-rd order polynomial $$P_3(n)$$, where $$n$$ is variable of upper bound of summation. We assume that order of resulting polynomial $$P_3(n)$$ depends on subscript of binomial coefficient being summed up (in our case the order of polynomial is $$3=2+1$$, where $$2$$ is subscript of bin. coef.)

The question: Does there exist a generalized method to represent the sum of binomial coefficients $$\sum_{k}^{n}\binom{k}{s}$$ in terms of certain polynomials $$P_{s+1}(n)=\sum_{k}^{n} F_s(n,k)$$ for every non-negative integer $$s$$? I.e can we always find the function $$F_s(n,k)$$, such that $$\sum_{k}^{n}\binom{k}{s}=\sum_{k}^{n}F_s(n,k)$$ ? We assume that order of polynomial is $$s+1$$ by means of example above.

The sub-question: (In case of positive answer to the first question.) If there exists a method to represent the sums of bin. coef. in terms of polynomials in $$n$$, how do summation limits of the $$\sum_{k}^{n}\binom{k}{s}$$ implies to the form of polynomial $$P_{s+1} (n)$$ exactly?

• $\sum_{k=s}^n \binom{k}s=\binom{n+1}{s+1}$. This is the Hockey Stick identity. – Mike Earnest Jan 29 '19 at 1:24
• The question is to find such polynomial $F_s(n,k)$ that $\sum_{k}^{n}\binom{k}{s}=\sum_{k}^{n}F_s(n,k)$. From our example it follows that: $F_2(n,k)=k(n-k)$ and $\sum_{k=1}^{n}\binom{k}{2}=\sum_{k=1}^{n}F_2(n,k)$. Can you provide examples for $s>2$? – PKK Jan 29 '19 at 1:33
• I understand now. Still, my comment just shows that $P_s(n)$ is nothing mysterious. – Mike Earnest Jan 29 '19 at 1:51
• Why don't you mention your previous question math.stackexchange.com/q/2774300 ? – Jean Marie Jan 30 '19 at 18:25
• thank you for reminding, by the way these coefficients could be found as $$(2k-1)!T(2n,2k)=\frac{1}{r}\sum_{j=0}^{r}(-1)^j\binom{2r}{j}(r-j)^{2n},$$ where $r=n-k+1$ and $T(2n,2k)$ is central factorial number – PKK Jan 30 '19 at 18:30

$$\sum_{k=0}^n\binom{k}s=\sum_{k=0}^n\sum_{i=0}^{k-1}\binom{i}{s-1}=\sum_{i=0}^{n-1}\sum_{k=i+1}^n\binom{i}{s-1}=\sum_{i=0}^{n-1}(n-i)\binom{i}{s-1}=\sum_{i=1}^ni\binom{n-i}{s-1}$$ In other words, you can let $$F_s(n,k)=k\binom{n-k}{s-1}$$, and you will have $$\sum_{k=0}^n \binom{k}s=\sum_{k=0}^{n}F_s(n,k)$$.

• Can you show me a direct example for $s=2$ step by step ? The example of $\sum_{k=1}^n\binom{k}{s}$ please – PKK Jan 29 '19 at 1:53
• @PetroKolosov When $s=2$, you get $F_s(n,k)=k(n-k)$, just as you had. When $s>2$, the expression $k\binom{n-k}s$ is polynomial in disguise. For example, $F_3(n,k)=k\binom{n-k}2=k(n-k)(n-k-1)/2$. – Mike Earnest Jan 29 '19 at 2:36
• Are you sure that $F_3(n,k)=k(n-k)(n-k-1)/2$? For me it gives as follows: $F_s(n,k)=k\binom{n-k}{s-1}$, by the hockey stick pattern: $\binom{n-k}{s-1}=\sum_{j}^{n-k+1}\binom{j}{s-2}|_{s=3}=1/2 (-2 + k - n) (-1 + k - n)$ and multiplication by $k$ gives $F_3(n,k)=1/2 k (-2 + k - n) (-1 + k - n)$. PS and obviously i wrong with limits of hockey stick pattern :) – PKK Jan 29 '19 at 3:09
• I've fixed the error above, but still $F_s(n,k)=k\binom{n-k}{s-1}$, by the hockey stick pattern: $\binom{n-k}{s-1}=\sum_{j}^{n-k-1}\binom{j}{s-2}|_{s=3}=1/2 (k - n) (1 + k - n)$ and multiplication by $k$ gives $F_3(n,k)=1/2 k (k - n) (1 + k - n)$ is different from your example of $F_3(n,k)$ – PKK Jan 29 '19 at 3:18
• $k(n-k)(n-k-1)/2=\frac12k(k-n)(1+k-n)$. Your expression and mine for $F_3(n,k)$ are the same. All you did was expand $\binom{n-k}{s-1}$ using the HS identity, and then collapse it using the same identity. @PetroKolosov – Mike Earnest Jan 29 '19 at 3:37

I would say that you have a good answer already. But their are other possible answers which seem reasonable. Further restriction might force the favored solution above.

In the case $$k=3$$ (which is the only one I will discuss in any detail)

$$\sum_{s=1}^n\binom{s}3= \\ \sum_{s=1}^ns\binom{n-s}2=\sum_{s=1}^n(n-s)\binom{s}2=\frac14\sum_{s=1}^n{s(n-s)(n-2)}=\frac1{24}\sum_{s=1}^n{(n+1)(n-1)(n-2)}$$

It is easy to see how to generalize these to other $$k.$$

The first three belong to the infinite family

$$\frac14\sum_{s=1}^n{s(n-s)(\alpha n-(2\alpha -2)s-2)} \tag{*}$$

Going back to the favored solution:

$$\sum_{s=1}^n\binom{s}3=\sum_{s=1}^n\frac{s^3}{6}-\frac{s^2}{2}+\frac{s}{3}=\sum_{s=1}^n\frac{n^2s}2-n{s}^{2}+\frac{s^3}2-\frac{ns}{2}+\frac{s^2}2.$$

If you wanted the thing on the right to be

$$\sum_{s=1}^nA{n^2s}+Bn{s}^{2}+C{s^3}+D{ns}+E{s^2}$$

Then you do need to have $$E=\frac12$$ But the rest have two degrees of freedom

$$C=-2A-\frac43B \ \ \ \ \ \ \ D=A-\frac13B-\frac23$$

For further restriction we might want to have $$D=-E=-\frac12$$ so than $$A{n^2s}+Bn{s}^{2}+C{s^3}+D{ns}+E{s^2}=0$$ when $$s=n$$

In this case the summand factors (of course) giving the family $$(*)$$ above.

If we want the right-hand side to be

$$K\sum_{s=1}^ns(An+(1-A)s+B)(Cn+(1-C)s+D)$$

It is possible to work out the requirements. I came up with $$6$$ families of solutions. Of course the set of solutions is invariant under switching the two terms and/or substituting $$s=n+1-s.$$


# Understanding isometric spaces

I have studied that an isometry is a distance-preserving map between metric spaces and two metric spaces $X$ and $Y$ are called isometric if there is a bijective isometry from X to Y.

My questions are related with the understanding of isometric spaces, they are as follows:

Can we say that two isometric spaces are same? If no, in what context they differ? What are the common properties shared by two isometric spaces?

Intuitively what are isometric spaces?

If two spaces are isometric how to find out bijective distance preserving map between them?

Thanks for your help and time.

-
Any two lines in the plane are isometric (you can translate and rotate to place one line on top of the other, without affecting distances within the lines in this process), so definitely two isometric spaces need not really be literally the same. But as far as metric properties are concerned they behave in the same way. It's like asking "are all circles of radius 1 the same"? No, but obviously you're comfortable using one particular choice (like the one centered at the origin) even if that's not the original circle of interest. –  KCd May 28 '12 at 6:04
The examples of the line and circle might seem silly, because they are very familiar. The point of the concept of isometric spaces is to keep us aware that we shouldn't consider two isometric spaces as being fundamentally different from one another. For example, when you construct the completion $\widetilde{X}$ of a metric space $X$, using equiv. classes of Cauchy sequences in $X$, you don't really find $X$ as a subset of $\widetilde{X}$, but $X$ is isometric to the equiv. classes of constant seq. $(x,x,x,\dots)$, and that is how we can view $X$ (as metric space) inside $\widetilde{X}$. –  KCd May 28 '12 at 6:08
There is no universal method to find an isometry between two isometric metric spaces. –  KCd May 28 '12 at 6:09
@KCd Thanks to you. Your comments are helpful to me. –  srijan May 28 '12 at 6:17

Homeomorphisms are the maps that preserve all topological properties: from a structural point of view, homeomorphic spaces might as well be identical, though they may have very different underlying sets, and if they’re metrizable, they may carry very different (but equivalent) metrics. Isometries are the analogue for metric spaces, topological spaces carrying a specific metric: they preserve all metric properties, and of course those include the topological properties. Thus, all isometries are homeomorphisms, but the converse is false.

Consider the metric spaces $\langle X,d_X\rangle$ and $\langle Y,d_Y\rangle$ defined as follows: $X=\Bbb N,Y=\Bbb Z$, $$d_X(m,n)=\begin{cases}0,&\text{if }m=n\\1,&\text{if }m\ne n\;,\end{cases}$$ for all $m,n\in X$, and $$d_Y(m,n)=\begin{cases}0,&\text{if }m=n\\1,&\text{if }m\ne n\end{cases}$$ for all $m,n\in Y$. It’s easy to check that $d_X$ and $d_Y$ are metrics on $X$ and $Y$, respectively.

Clearly these are not the same space: they have different underlying sets. However, if $f:X\to Y$ is any bijection1 whatsoever, then $f$ is an isometry between $X$ and $Y$. $\langle X,d_X\rangle$ and $\langle Y,d_Y\rangle$ are structurally identical as metric spaces: if $P$ is any property of metric spaces $-$ not just of metrizable spaces, but of metric spaces with a specific metric $-$ then either $X$ and $Y$ both have $P$, or neither of them has $P$. There is no structural property of metric spaces that distinguishes them.

What I just said about $X$ and $Y$ is true of isometric spaces in general: there is no structural property of metric spaces that distinguishes them. Considered as metric spaces, they are structurally identical, though they may have different underlying sets.

Isometric spaces may even have the same underlying set but different metrics. Consider the following two metrics on $\Bbb N=\{0,1,2,\dots\}$. For any $m,n\in\Bbb N$,

$$d_0(m,n)=\begin{cases} 0,&\text{if }m=n\\\\ \left|\frac1m-\frac1n\right|,&\text{if }0\ne m\ne n\ne 0\\\\ \frac1m,&\text{if }n=0<m\\\\ \frac1n,&\text{if }m=0<n\;, \end{cases}$$

and

$$d_1(m,n)=\begin{cases} 0,&\text{if }m=n\\\\ \left|\frac1m-\frac1n\right|,&\text{if }m\ne n\text{ and }m,n>1\\\\ 1-\frac1m,&\text{if }n=0\text{ and }m>1\\\\ 1-\frac1n,&\text{if }m=0\text{ and }n>1\\\\ \frac1m,&\text{if }n=1\ne m\\\\ \frac1n,&\text{if }m=1\ne n\;. \end{cases}$$

It’s a good exercise to show that $$f:\Bbb N\to\Bbb N:n\mapsto\begin{cases}n,&\text{if }n>1\\1,&\text{if }n=0\\0,&\text{if }n=1\end{cases}$$ is an isometry between $\langle\Bbb N,d_0\rangle$ and $\langle\Bbb N,d_1\rangle$. (HINT: Both spaces are isometric to the space $\{0\}\cup\left\{\frac1n:n\in\Bbb Z^+\right\}$ with the usual metric.) Yet these are clearly not the same space: metric $d_0$ makes $0$ a limit point of the other points, but metric $d_1$ makes $0$ an isolated point.

I don’t know of any general method for finding an isometry between isometric spaces; if you can recognize two spaces as being isometric, you probably already have a good idea of what an isometry between them must look like.

1 If you want a specific bijection, $$f(n)=\begin{cases}0,&\text{if }n=0\\\\\frac{n}2,&\text{if }n>0\text{ and }n\text{ is even}\\\\-\frac{n+1}2,&\text{if }n\text{ is odd}\end{cases}$$ does the job.

-
Sir, by structural properties do you mean completeness, boundedness etc? –  srijan May 28 '12 at 6:05
@srijan: Anything that has to do with the topological or metric structure of the space and not with superficial charactersitiscs like the specific names attached to the points. Completeness and boundedness are indeed structural properties of metric spaces, though not of metrizable spaces. –  Brian M. Scott May 28 '12 at 6:07
All homeomorphisms need not be isometries because some of the topological properties may not be shared by two isometric spaces, Am i right sir? –  srijan May 28 '12 at 6:15
@srijan: No, it’s because some of the metric properties may not be shared between two homeomorphic spaces. For instance, $\Bbb R$ and $(0,1)$ with the usual metrics are homeomorphic, but $\Bbb R$ is a complete metric space, while $(0,1)$ isn’t: they don’t share the metric property of completeness. –  Brian M. Scott May 28 '12 at 6:18
@srijan: You’re very welcome! –  Brian M. Scott May 28 '12 at 6:22
show 1 more comment


Determinant of an $n\times n$ complex matrix as an $2n\times 2n$ real determinant

If $A$ is an $n\times n$ complex matrix. Is it possible to write $\vert \det A\vert^2$ as a $2n\times 2n$ matrix with blocks containing the real and imaginary parts of $A$?

I remember seeing such a formula, but can not remember where. Any details, (and possibly references) for such a result would be greatly appreciated.

-

Write $A=A_1+iA_2$ where $A_1$ and $A_2$ are real matrices. Let $$B:=\pmatrix{A_1&iA_2\\iA_2&A_1}.$$ We have $$\det B=\det\pmatrix{A_1+iA_2&iA_2\\A_1+iA_2&A_1}=\det\pmatrix{I&iA_2\\I&A_1}\cdot\det\pmatrix{A_1+iA_2&0\\0&I},$$ and $$\det\pmatrix{I&iA_2\\I&A_1}=\det\pmatrix{I&iA_2\\0&A_1-iA_2}$$ hence $$\det B=\det(A_1-iA_2)\det(A_1+iA_2)=\det A\cdot\det\bar A=|\det A|^2.$$

-
Thanks you very much! – dernam Jul 3 '12 at 18:59
You are welcome! – Davide Giraudo Jul 3 '12 at 19:01

Davide's answer tells most of the story, in particular giving the proof for the determinant, but not quite all of it, so I want to supplement it with a couple of remarks.

I think that it is more common to replace Davide's matrix $B$ with a real matrix. This can be achieved by conjugating it with matrix of the block form $$D=\pmatrix{I&0\cr0&iI\cr},$$ when $$D^{-1}BD=\pmatrix{A_1&-A_2\cr A_2 &A_1\cr}.$$ Because conjugation preserves the determinant, Davide's calculation tells that here we also have $$\det(D^{-1}BD)=\det(B)=|\det A|^2.$$ Further conjugating (shuffling rows and columns) allows us to replace each and every complex entry $z=a+bi$ with a $2\times2$ block $$(z)=\pmatrix{a&-b\cr b&a\cr}.$$ Doing it this way makes it clear that if $A$ represents a linear mapping $T$ from $V=\mathbf{C}^n$ to itself with respect to basis $v_1,v_2,\ldots,v_n$, then $D^{-1}BD$ represents the same mapping $T$, when we view $V$ as a real vector space of dimension $2n$ and use the basis $v_1,v_2,\ldots,v_n,iv_1,iv_2,\ldots,iv_n.$

The extra shuffling I talked about would reorder this latter basis to $v_1,iv_1,\ldots$.

A geometric interpretation of this is that $\det B$ gives the scaling of Lebesgue measure (or hypervolumes) of a box $K=\prod_{i=1}^{2n}[c_i,d_i]$ of real dimension $2n$ under $T$: $$\det (B)=\frac{m(T(K))}{m(K)}.$$

$\det A$ does the same, but because the coordinates are complex there, we need to use $|\det A|^2$ to get the scaling right. This is seen already in the complex plane, where multiplication by $a+bi$ multiplies the areas of rectangles by a factor of $a^2+b^2$.

-
If $A$ and $B$ define the "same" linear map shouldn't $\det A = \det B$? – learner Jan 24 '15 at 4:27
@learner: No. For example multiplication by $2$ on $\Bbb{C}$ has determinant two (it's a 1x1 matrix $2I_1$), but when we view $\Bbb{C}$ as $\Bbb{R}^2$ it is a 2x2 matrix $2I_2$ with determinant $=4$. – Jyrki Lahtonen Jan 25 '15 at 9:04

Let $A=B+iC$, where $B$ and $C$ are $n\times n$ real matrices, and let $$\widetilde{A}=\left( \begin{array}{rr} B & -C \\ C & B \end{array} \right).$$ Then $\det\widetilde{A}=|\det A|^2$.

Proof. \begin{align*} \det\widetilde{A}&=\det\left( \begin{array}{cc} B+iC & -C+iB \\ C & B \end{array} \right)= \det\left( \begin{array}{cc} B+iC & 0 \\ C & B-iC \end{array} \right)= \det \left( \begin{array}{ll} A & 0 \\ C & \overline{A} \end{array} \right)\\ &= (\det A)(\det\overline{A})=(\det A)(\overline{\det A})=|\det A|^2. \end{align*}

-
This question already has a well accepted answer. You have contributed nothing new – Shailesh Nov 14 '15 at 13:42


# Prove $\{n \in \mathbb Z | n \text { is even} \} = \{n \in \mathbb Z | n-1 \text { is odd}\}$.

This is found in the book the instructor is using, An Introduction to Proof through Real Analysis by Daniel J. Madden and Jason A. Aubrey The University of Arizona Tucson, Arizona, USA

Here is one way to define $$A$$ in set-builder notation: $$A = \{x | x \text{ is an even integer}\} \text. \tag{9.1}$$ In general, set-builder notation takes the form $$S = \{x | P(x) \text { is true}\} \text, \tag{9.2}$$ where $$P(x)$$ is some mathematical statement. We read this definition of the set $$S$$ as "$$S$$ is the set of all $$x$$ such that $$P(x)$$ is true". So

• $$s \in S$$ if and only if $$P(s)$$ is true;
• $$s \notin S$$ if and only if $$P(s)$$ is false.

There are some common variations on set-builder notation that you will see. For example, people will often use a colon ":" in place of the bar "|". That is fine; the idea is the same. Sometimes, another condition on elements of a set is slipped in before the "such that" symbol by limiting elements to members of a larger set. For example, we could have defined the set of even integers as this: $$A = \{x \in \mathbb Z | x \text { is even}\} \text. \tag{9.3}$$ Besides using English or set-builder notation to define sets, we can define sets by simply listing their elements. For example, we can write $$A = \{\dots, −6, −4, −2, 0, 2, 4, 6, \dots\} \tag{9.4}$$ to define the set of all even integers. But this really only works when the set is small enough that all of its elements can be reasonably listed or when the pattern is strong enough to be recognized. For example, we could write $$B = \{n \in \mathbb N | 2 \le n \le 5\} \text { or } B = \{2, 3, 4, 5\} \text. \tag{9.5}$$

This is all the information from the book that I could find that is pertaining to the purposed question. Please Help Me!

• Welcome to Mathematics Stack Exchange. Can you show $n$ is even $\iff n-1$ is odd? – J. W. Tanner Sep 30 '20 at 1:02
• – Shaun Sep 30 '20 at 1:02
• Um... do you have a question? Any question? You quote something. To a experienced person everything you quote is straightforward and fairly simple. But obviously its not or you wouldn't ask anything. So it's up to you to tell us where you have difficulty and what you want clarified. – fleablood Sep 30 '20 at 2:36
• The point of this is to get you familiar with set builder notation. What is actually being proven is fairly simple: The integers that are even are precisely the numbers that are one more than an odd number. this is obvious. If $n = 2k$ is even then $n-1 = 2k -1$ is odd. That's it we are done. What the excercise though is to put it in terms of set builder notation. And ... I think the text you quoted does a fine job explaining that. – fleablood Sep 30 '20 at 2:41

To prove "set A= set B" you prove "A is a subset of B" and "B is a subset of A". And to prove "A is a subset of B" start "if x is in A" and then use the definitions of A and B to conclude "then x is in B"

Here that means we want to prove "if x is even then x- 1 is odd" and "if x- 1 is odd then x is even".

Of course, we need to use the fact that any even number is of the form 2k for some integer k and any odd number is of the form 2k+ 1 for some integer k.

So "If x is even then there exist an integer k such that x= 2k. Then x- 1= 2k- 1= 2k- 2+ 1= 2(k-1)+ 1 so x-1 is odd."

And "if x- 1 is odd then there exist an integer k such that x- 1= 2k+ 1. Then x= 2k+ 2= 2(k+ 1) so x is even."

$$\{n\in \mathbb Z| n$$ is even $$\}=$$

$$\{n\in \mathbb Z| n$$ is divisible by $$2\}=$$

$$\{n\in \mathbb Z|$$ there exists an integer $$k$$ so that $$n = 2k\}=$$

$$\{n\in \mathbb Z|$$ there exists an integer $$k$$ so that $$n-1 = 2k-1\}=$$

$$\{n\in \mathbb Z| n-1$$ is odd$$\}$$.

In order to show equality of sets, you need to show two-way containment; that is, show that $$A\subseteq B$$ and $$A\supseteq B$$, which is equivalent to saying that $$x\in A \Leftrightarrow x\in B$$. Sometimes it's best to show each direction independently, but in this case, I would recommend a chain of biconditionals, as it's quicker.

Let $$A=\{x\in\mathbb{Z} | x\text{ is even}\}$$ and $$B=\{x\in\mathbb{Z} | x-1\text{ is odd}\}$$. Then we have the following chain of biconditionals:

$$x\in A\Leftrightarrow x$$ is even $$\Leftrightarrow x=2k$$ for some $$k\in\mathbb{Z} \Leftrightarrow x-1=2k-1\Leftrightarrow x-1$$ is odd $$\Leftrightarrow x\in B$$.

Therefore, $$A=B$$.


# How can I show that the polynomial $p = x^5 - x^3 - 2x^2 - 2x - 1$ is irreducible over $\Bbb Q$?

I've tried a few "criteria" to check if this is irreducible. According to Maple it only has one entirely real root which I suspect is not rational but I can't prove it so I'm attempting to check if $p$ is irreducible.

Eisenstein's Criterion doesn't work here and I'm yet to find a suitable transformation such that it could work. I also read that if a polynomial is irreducible over $\Bbb F_q$, with $q$ a prime not dividing the leading coefficient, then it is irreducible over $\Bbb Q$ so I reduced the polynomial modulo $2$ to obtain

$$p \equiv x^5 + x^3 + 1 \mod 2.$$

I think this is correct but then I need to know how to check the irreducibility of this new polynomial over $\Bbb F_2$. Do I simply need to check that neither $0$ nor $1$ are roots of this polynomial? (And am I applying this theorem correctly?)

If this polynomial IS irreducible over $\Bbb Q$, is the splitting field obtained by simply adjoining the roots to $\Bbb Q$?

• Since the polynomial is of degree $5$ it might be possible for it to have no roots in $\mathbb{Q}$, but be reducible. Writing it as a product of polynomials of degree $2$ and $3$ might be possible. Apr 9, 2017 at 11:11
• To answer your last question: yes. This follows straight from the definition of a splitting field.
– user583416
Apr 9, 2017 at 11:18
• Oh, I've found something wonderful. Answer coming up. Apr 9, 2017 at 11:19

.A little bit of scouting for nice irreducibility criteria throws up some very nice results:

Here is a lovely lemma by (Prof.) Ram Murty:

Let $$f(x) = a_mx^m + ... + a_1x + a_0$$ be a polynomial of degree $$m$$ in $$\mathbb Z[x]$$. Let $$H = \displaystyle\max_{0 \leq i \leq m-1} \left|\frac{a_i}{a_m}\right|$$. If $$f(n)$$ is prime for some $$n \geq H+2$$, then $$f(x)$$ is irreducible in $$\mathbb Z[x]$$.

In our case, $$a_m = 1$$, and the maximum of all the quantities in question is $$2$$. Hence, if $$f(n)$$ is prime for some $$n \geq 4$$, then we are done.

You can check that for $$n=4$$, the number $$f(4) =919$$, which is prime!

Hence, it follows that the polynomial is irreducible.

ASIDE : There is also a "shifted" base (base shifts from $$0...n-1$$ to $$|b| < \frac n2$$) version of Cohn's criteria, which will tell you that if $$f(10)$$ is prime, then the given polynomial is irreducible. This matches that description, since all coefficients are between $$-5$$ and $$5$$. Very interestingly, $$f(10) = 98779$$ is also prime! (Hence, another proof by another wonderful result).

• That is very cool! Thanks for the link. Apr 9, 2017 at 11:28
• You are welcome. I've seen some of these criteria very long ago, while doing a Galois theory polynomial "scouting mission". Apr 9, 2017 at 11:31
• Nice method. Just wondering, why not going already with $f(4)=919$ which is also a prime?
– Sil
Apr 26, 2018 at 23:30
• You are right, it works out. I was doing that calculation mentally, so I skipped directly to $n=5$ because I must have made some mistake at $f(4)$. Apr 26, 2018 at 23:34

By Gauss' Lemma we have that the polynomial is irreducible over $\mathbb{Q}$ if and only if it's irreducible over $\mathbb{Z}$. Now the easiest way would be to prove that polynomial is irreducible over $\mathbb{Z}_2$, which would be enough.

Assume it's reducible. As the polynomial has no roots over $\mathbb{Z}_2$, then the only possibility is if it's a product of polynomials of degree $2$ and $3$. So assume that:

$$x^5 + x^3 + 1 = (x^3 + ax^2 + bx + c)(x^2 + dx + e) \quad \quad \text{over } \quad\mathbb{Z}_2$$

Then multiply everything out and compare the factors. As $a,b,c,d,e \in \mathbb{Z}_2$, you only have two options. Eventually you will get that $c=e=1$ and $a=d=b$. But this would imply that $c+bd + ea = a^2 + a + 1 = 1$ in $\mathbb{Z}_2$. But this is impossible, as it's the coefficient in front of $x^2$ and it should be $0$.

Hence the polynomial is irreducible over $\mathbb{Z}_2$ and eventually $\mathbb{Z}$ and $\mathbb{Q}$

• I think I'll accept this one as being the most useful in a general setting, thanks a lot. Apr 9, 2017 at 11:28
• One could also just divide by the only irreducible polynomial in $\mathbb{Z_2}[x]$ which is $x^2+x+1$ and see it cannot be the factor.
– Sil
Aug 11, 2018 at 9:23
• @Sil True. However I doubt that an OP asking factorizing of a polynomial is aware that $x^2+x+1$ is the only irreducible quadratic in $\mathbb{Z}_2$ Aug 11, 2018 at 9:25

Your proof is almost complete: it is indeed sufficient to prove that $p(x)\in \mathbb F_2[x]$ (the reduction mod $2$ of your polynomial) is irreducible.
The polynomial $p(x)$ has no factor of degree $1$ since it has no zero in $\mathbb F_2$, so there remains only to prove that $p(x)$ has no factor which is an irreducible polynomial $g(x)\in \mathbb F_2[x]$ of degree $2$.
But the only such irreducible polynomial is $g(x)=x^2+x+1$ and long division proves that it does not divide $p(x)$. All is proved.

By the rational root theorem, any rational root of $p$ would have to be a divisor of the constant term, so $\pm1$. Clearly, these are not roots.

Similary, any quadratic factor would have to be $x^2+ax\pm1$ with $a\in\Bbb Z$. You might be able to exclude these manually ...


At the beginning of the Gold Rush, the population of Coyote Gulch,Arizona was $365$.From then on ,the population would have grown by a factor of $e$ each year,except for the high rate of "accidental" death, amounting to one victim per day among every 100 citizens.By solving an appropriate differential equation determine, as functions of time:
(a) the actual population of Coyote Gulch $t$ years from the day the Gold Rush began, and
(b) the cumulative number of fatalities.

The question is from Apostol's Calculus I. In other questions,Apostol uses the statement "... increases at a rate proportional to the amount present. ..."But this one says "grown by a factor of $e$", I have difficulty in understanding the meaning of "a factor of $e$".Does it mean $y=be^{kt}$ or $y'=ey$ or what?

So I decide to denote "a factor of $e$" by $f_e$ and focus on the ' "accidental" death '.So let $y$ denote the population at present year, each day one victim dies among every 100 citizens .So the population remains in that year is $y(1 -\frac{1}{100})^{365}$. And the number of fatalities in that year is $$y-y(1 -\frac{1}{100})^{365} = y(1- (\frac{99}{100})^{365})$$ . And as far as I can get $$y'=f_e -y(1- (\frac{99}{100})^{365})$$

The answer of the question is given
a) $365e^{-2.65t}$
b) $365(1-e^{-2.65t})$

Any help is appreciated.

• Grown by a factor of $e$ probably if the population this year is $100$ next year it will be $271.8\ldots$(well not fractional population, but cut me some slack) – Guy Apr 6 '14 at 10:36
• @Sabyasachi I tried your suggestion and substitute $f_e$ by $ey$ but I couldn't get the right answer :( – Detective King Apr 6 '14 at 10:55
• I mean $f_e=e$, not $ey$. Does it work? – Guy Apr 6 '14 at 11:00
• @Sabyasachi so $y'=e - y(1-(99/100)^{365})$ and I get $y=362e^{-0.974t}+0.974$. – Detective King Apr 6 '14 at 11:12
• Oh. can't help then. Did you try googling for the question text – Guy Apr 6 '14 at 11:13

Try to write it out in words.

The rate of change in population is the population we have minus the loss ratio of that population (of course, we could have other factors, but that is what we are working with here), so we have:

$$\dfrac{dP}{dt} = P - \alpha P = P(1 - \alpha)$$

Now how we can we find the loss ratio $\alpha$ of the population per year? The problem tells us that we lose "$1$ victim per day among every $100$ citizens", so for the year, we lose $365 \times \dfrac{1}{100}$ of the population $P$. This gives us $\alpha = \dfrac{365}{100}$.

So we have:

$$\dfrac{dP}{dt} = P\left(1 - \dfrac{365}{100}\right), P(0) = 365$$

Note: $P(0)$ is the initial population which is given as $365$.

This DEQ is separable and gives us:

$$20 \int \dfrac{1}{P}~dP = -53 ~\int dt, P(0) = 365$$

Thus,

$$\large P(t) = 365 ~e^{-\frac{53 t}{20}} = 365~ e^{-2.65~ t}$$

If we want to find the cumulative number of fatalities over time, we write that out in words as: we start out with a population of $365$ and we lose them at a rate of $P(t)$ (which we just calculated), so this is:

$$CP(t) = 365 - P(t) = 365 - 365 ~e^{-\frac{53 t}{20}} = 365\left(1 - e^{-\frac{53 t}{20}}\right) = 365\left(1 - e^{-2.65 ~t}\right)$$

We can plot these curves to verify that they are inverses of each other as:

• This was really nicely (and thoroughly) explained, Amzoti. Nice job. – Namaste Apr 6 '14 at 13:27
• @Amzoti Your explaination is really nice!At the same time I think the question is quite "unrealistic"(it feels like "statistic") to me . – Detective King Apr 6 '14 at 14:01
• @DetectiveKing: I think the point of these is just trying to set them up. It is very difficult to take the leap from knowing how to solve things, to actually producing models of the physical reality. By the way, it was not unreasonable for really bad things to happen to small populations as the result of a single issue, including having them totally wiped out. Regards – Amzoti Apr 6 '14 at 14:09