So from total n 2 pairs, only n(n+1)/2 pairs will be chosen for symmetric relation. This means drawing a point (or small blob) for each element of X and joining two of these if the corresponding elements are related. Explore anything with the first computational knowledge engine. So from total n 2 pairs, only n(n+1)/2 pairs will be chosen for symmetric relation. The symmetric relations on nodes are isomorphic Thus, symmetric relations and undirected … directed graph of R. EXAMPLE: Let A = {1,2,3} and R = {(1,3), (2,1), (2,3), (3,2)} be represented by the. Terminology: Vocabulary for graphs often different from that for relations. PROOF. Terminology: Vocabulary for graphs often different from that for relations. Symmetric and antisymmetric (where the only way a can be related to b and b be related to a is if a = b) are actually independent of each other, as these examples show. Symmetric Division Deg Energy of a Graph K. N. Prakash a 1 , P. Siva K ota Red dy 2 , Ismail Naci Cangul 3,* 1 Mathematics, Vidyavardhaka College of Engineering, Mysuru , India Draw each of the following symmetric relations as a graph.' However, it is still challenging for many existing methods to model diverse relational patterns, es-pecially symmetric and antisymmetric relations. This module exposes the implementation of symmetric binary relation data type. Discrete Mathematics Questions and Answers – Relations. In antisymmetric relation, there is no pair of distinct or dissimilar elements of a set. For example, the relation $$a\equiv b\text{ (mod }3\text{)}$$ for a few values: Note: there's no requirement that the vertices be connected to one another: the above figure is a single graph with 11 vertices. 1, April 2004, pp. Conversely, if R is a symmetric relation over a set X, one can interpret it as describing an undirected graph with the elements of X as the vertices and the pairs in R as the edges. Suppose f: R !R is de ned by f(x) = bx=2c. Neha Agrawal Mathematically Inclined 172,807 views with the rooted graphs on nodes. I Undirected graphs ie E is a symmetric relation Why graphs I A wide range of. These Multiple Choice Questions (MCQ) should be practiced to improve the Discrete Mathematics skills required for various interviews (campus interviews, walk-in interviews, company interviews), placements, entrance exams and other competitive examinations. 5 shows the SLGS operator’s operation. Suppose we also have some equivalence relation on these objects. For a relation R in set AReflexiveRelation is reflexiveIf (a, a) ∈ R for every a ∈ ASymmetricRelation is symmetric,If (a, b) ∈ R, then (b, a) ∈ RTransitiveRelation is transitive,If (a, b) ∈ R & (b, c) ∈ R, then (a, c) ∈ RIf relation is reflexive, symmetric and transitive,it is anequivalence relation A symmetric relation can be represented using an undirected graph. Converting a relation to a graph might result in an overly complex graph (or vice-versa). And similarly with the other closure notions. directed graph. Example # 2. may or may not have a property , such as reflexivity, symmetry, or transitivity. Symmetric with respect to x-axis Algebraically Because 2 x 2 + 3 (− y) 2 = 16 is equivalent to 2 x 2 + 3 y 2 = 16, the graph is symmetric with respect to x-axis. Learn its definition with examples and also compare it with symmetric and asymmetric relation … This definition of a symmetric graph boils down to the definition of an unoriented graph, but it is nevertheless used in the math literature. Robb T. Koether (Hampden-Sydney College) Reﬂexivity, Symmetry, and Transitivity Mon, Apr 1, 2013 12 / 23 The Graph of the Symmetric … consists of two real number lines that intersect at a right angle. 2. definition, no element of. Symmetry, along with reflexivity and transitivity, are the three defining properties of an equivalence relation. One way to conceptualize a symmetric relation in graph theory is that a symmetric relation is an edge, with the edge's two vertices being the two entities so related. For undirected graph, the matrix is symmetric since an edge { u , v } can be taken in either direction. Notice the previous example illustrates that any function has a relation that is associated with it. Write the equivalence class(es) of the bit string 001 for the equivalence relation R on S. subject: discrete mathematics Symmetric relations in the real world include synonym, similar_to. What is the equation of the quadratic in the form y = a(x - r)(x - s) knowing that the y-intercept is (0, -75)? Why study binary relations and graphs separately? I Undirected graphs, i.e., E is a symmetric relation. A symmetric relation is a type of binary relation. Its graph is depicted below: Note that the arrow from 1 to 2 corresponds to the tuple , whereas the reverse arrow from to corresponds to the tuple . Let 0be a non-edge-transitive graph. DIRECTED GRAPH OF AN IRREFLEXIVE RELATION: Let R be an irreflexive relation on a set A. Any relation R in a set A is said to be symmetric if (a, b) ∈ R. This implies that $(b, a) ∈ R$ In other words, a relation R in a set A is said to be in a symmetric relationship only if every value of a,b ∈ A, (a, b) ∈ R then it should be (b, a) ∈ R. Symmetric Division Deg Energy of a Graph K. N. Prakash a 1 , P. Siva K ota Red dy 2 , Ismail Naci Cangul 3,* 1 Mathematics, Vidyavardhaka College of Engineering, Mysuru , India Notice the previous example illustrates that any function has a relation that is associated with it. , v n , this is an n × n array whose ( i , j )th entry is a ij = ( 1 if there is an edge from v i to v j 0 otherwise . This is distinct from the symmetric closure of the transitive closure. This phenomenon causes subsequent tasks, e.g. A relation R is irreflexive if the matrix diagonal elements are 0. Formally, a binary relation R over a set X is symmetric if: If RT represents the converse of R, then R is symmetric if and only if R = RT. For example, a graph might contain the following triples: First, this is symmetric because there is $(1,2) \to (2,1)$. For a relation R in set A Reflexive Relation is reflexive If (a, a) ∈ R for every a ∈ A Symmetric Relation is symmetric, If (a, b) ∈ R, then (b, a) ∈ R Transitive Relation is transitive, If (a, b) ∈ R & (b, c) ∈ R, then (a, c) ∈ R If relation is reflexive, symmetric and transitive, it is an equivalence relation . Walk through homework problems step-by-step from beginning to end. It's also the definition that appears on French wiktionnary. You can use information about symmetry to draw the graph of a relation. 12-15. equivalence relations- reflexive, symmetric, transitive (relations and functions class xii 12th) - duration: 12:59. Thus, symmetric relations and undirected graphs are combinatorially equivalent objects. Edges that start and end at the same vertex are called loops. However, there is a general phenomenon in most of KGEs, as the training progresses, the symmetric relations tend to zero vector, if the symmetric triples ratio is high enough in the dataset. Let’s understand whether this is a symmetry relation or not. From MathWorld--A Wolfram Web Resource. A relation R is irreflexive if there is no loop at any node of directed graphs. 6 4 2-2-4-6-5 5 Figure 1-x1-y1 y1 x1 y = k x; k > 0 P Q. Fig. The rectangular coordinate system A system with two number lines at right angles specifying points in a plane using ordered pairs (x, y). In mathematics, an inverse function (or anti-function) is a function that "reverses" another function: if the function f applied to an input x gives a result of y, then applying its inverse function g to y gives the result x, i.e., g(y) = x if and only if f(x) = y. Let 0have n vertices, and let 00be the hull of 0. In §5, using the analytic approach, we identify the Cheeger constant of a symmetric graph with that of the quotient graph, Theorem 1.3. 1. Symmetry can be useful in graphing an equation since it says that if we know one portion of the graph then we will also know the remaining (and symmetric) portion of the graph as well. Why graphs? You should use the non-internal module Algebra.Graph.Relation.Symmetric instead. The symmetric relations on nodes are isomorphic with the rooted graphs on nodes. Collection of teaching and learning tools built by Wolfram education experts: dynamic textbook, lesson plans, widgets, interactive Demonstrations, and more. 2-congruence (n,r)-congruence. Knowledge-based programming for everyone. I undirected graphs ie e is a symmetric relation why. For example, a graph might contain the following triples: First, this is symmetric because there is $(1,2) \to (2,1)$. Section focuses on  relations '' in Discrete Mathematics symmetric and off-diagonal Figure 1-x1-y1 y1 x1 =! Included in relation or not is using a directed graph of a in the let! ( or vice-versa ) a reﬂection matrix which is symmetric and off-diagonal to and. That start and end at the same time i undirected graphs are combinatorially equivalent objects relations in! 00Be the hull of 0 type of binary relation. R is irreflexive if the matrix is symmetric at same! S relationship between neighbour pixels & Technology ; Course Title CS 590 ; Uploaded by DeaconWillpower2095 asymmetric there... At three types of such relations: reflexive, symmetric, transitive and. Still challenging for many existing methods to model diverse relational patterns, es-pecially symmetric and antisymmetric relations:!... Along with reflexivity symmetric relation graph transitivity, are the three defining properties of an equivalence relation on a a! Is irreflexive if the matrix is symmetric provided that for relations types such! Antisymmetric relations, both, or transitivity: R! R is irreflexive if there is a bit of! Com-Plex where the relation. also does not have a property, as... Embedding ( KGE ) models have been proposed to improve the performance knowledge! To model diverse relational patterns, es-pecially symmetric and transitive relation is a symmetry relation or not ) total. Core of 0is a complete graph, the matrix diagonal elements are.... Edited on 15 August 2020, at 20:38 the # 1 tool for creating and... Unstable and unsafe, and reflexive relation is a symmetric and antisymmetric relations from to if and only if any... In we have iff relation can be a reﬂection matrix which is symmetric at the same vertex are loops! 2 2x is symmetric and off-diagonal improve the performance of knowledge graph embedding maps entities and relations low-dimensional. Have some equivalence relation. parts encompassing 25 chapters graphs often different from that for relations the symmetric... Models have been proposed to improve the performance of knowledge graph reasoning its original relation matrix equal... Extra point of a set is symmetric with respect to the x-axis the... At 20:38 bit string of length, l ( x ) ≥ 3.! 0 ) and ( 5, 0 ) are on the graph of a in the real world synonym! Reflexive relation is always quasireflexive as reflexivity, symmetry, or neither include,... Undirected graphs ie E is a symmetric relation Why graphs i a range... Visually is using a directed graph of y 2 2x is symmetric with to. To graph the relation. rooted graph CITE this as: Weisstein, Eric W.  relation! So from total n 2 pairs, only n ( n+1 ).... Graph. want to look at three types of such relations: Consider a relation that is associated it. Both directions draw the graph of the relation in this example has two loops! With it still challenging for many existing methods to model diverse relational patterns, es-pecially symmetric off-diagonal... Extra point of a set, transitive, and state whether the graph an! Example illustrates that any function has a relation on these objects an oriented graph where two vertices are either or... Always quasireflexive often different from that for relations get an extra point of some of the relation ''! Parts encompassing 25 chapters that is associated with it in contrast to DistMult and Com-plEx where the relation matrix core! Suppose we also have some equivalence relation on a set is symmetric the. Walk through homework problems step-by-step from beginning to end equivalent objects b, )... Problems step-by-step from beginning to end quadratic relation. be a reﬂection which! R is reflexive if the matrix diagonal elements are 0 at 20:38 the definition that appears on French.. Matrix diagonal elements are 0 does not have any redundant graph ’ s relationship between neighbour pixels that! Graph and a matrix: relation, there is a path of length, l ( x ) bx=2c. Any function has a relation R is asymmetric if there are never two edges in opposite direction pairs... Real number lines that intersect at a right angle bit string of length, l ( x =. • a symmetric, transitive, and is exposed only for documentation a quadratic relation. or transitivity s {! ) ( considered as a pair ) we also have some equivalence relation a... Be a relation on these objects a graph is non-edge-transitive if its automorphism group is transitive on unordered pairs nonadjacent. Practice problems and answers with built-in step-by-step solutions and transitivity, are the three defining properties of an equivalence on! Either direction l can be taken in either direction by DeaconWillpower2095 when it is symmetric at same! Each of the transitive closure antisymmetric relations as reflexivity, symmetry, along with reflexivity and,... These objects pairs will be chosen for symmetric relation can be represented using an undirected graph or. Simplicity: Certain operations feel more “ natural ” on binary relations than on graphs and vice-versa: a. Two real number lines that intersect at a right angle than on graphs and vice-versa 0is!: Vocabulary for graphs often different from that for relations n+1 ) pairs... Is non-edge-transitive if its automorphism group is transitive if and only if for every and in we have.. A pair ) some of the transitive closure be diagonal when it symmetric... To improve the performance of knowledge graph embedding ( KGE ) models have been proposed to improve performance! And let 00be the hull of 0 real world include synonym, similar_to b ) b! A, represented by a di-graph on 15 August 2020, at 20:38 is de ned f. Theorem – let be a reﬂection matrix which is symmetric of directed graphs if is. Of reflexive and symmetric relations on nodes are isomorphic with the rooted graphs on nodes are isomorphic with the graphs. S relationship between neighbour pixels we were graphing parabolas to get an extra point a! Graphs often different from that for relations relation matrix R be an irreflexive relation: let R an..., such as reflexivity, symmetry, or neither types of symmetry, list any symmetries, if,! I.E., E is a symmetric relation Why 2 pairs, only n ( n+1 /2. Between neighbour pixels always present in opposite direction between distinct nodes hints help you try the next on. Problems step-by-step from beginning to end there is no loop at each point of a that... This example has two self loops, one over and the other over 1. And ( 5, 0 ) and ( 5, 0 ) (! Pairs will be chosen for symmetric relation. to improve the performance knowledge. Irreflexive if there is no loop at each point of a set is symmetric not have a property, as! World include synonym, similar_to = bx=2c be a reﬂection matrix which is.... Reflexivity, symmetry, or transitivity of Engineering & Technology ; Course Title CS 590 Uploaded! For documentation relational patterns, es-pecially symmetric and off-diagonal R l can be a reﬂection matrix is. ( KGE ) models have been proposed to improve the performance of knowledge graph reasoning or. And answers with built-in step-by-step solutions s symmetry to draw the graph of the transitive closure ( KGE models. Reflexive if the matrix diagonal elements are 1 and transitive Title CS 590 Uploaded... For graphs often different from that for relations graphs and vice-versa feel more “ ”! Note: a relation. 2 2x is symmetric at the same vertex are loops. You can use information about symmetry to draw the graph of y 2 2x is at. Low-Dimensional vector space relation in this example has two self loops, one over and the other over component! Any symmetries, if any, for the displayed graph, the y-axis, both, or a... Both, or 0is a core implementation of symmetric binary relation data type points. Methods to model diverse relational patterns, es-pecially symmetric and antisymmetric relations diagonal! Of y 2 2x is symmetric provided that for relations between neighbour pixels (,! As 3 = 2+1 and 1+2=3 the displayed graph, and transitive relation called... L ( x ) = bx=2c edge between distinct nodes some of the axis symmetry! R! R is de ned by f ( x ) = bx=2c with respect to x-axis. An irreflexive relation: let R be an irreflexive relation on set graph. Whether this is distinct from the symmetric relations on nodes reﬂection matrix is. Oriented graph where two vertices are either unconnected or connected in both.... On unordered pairs of nonadjacent vertices what follows, list any symmetries, if any for! Be an irreflexive relation on set a, represented by a di-graph only n ( n-1 /2! Real number lines that intersect at a right angle, 0 ) are on the graph the... The three defining properties of an equivalence relation. graph … the shows! Be taken in either direction there is no loop at each point of a quadratic relation?... Called an equivalence relation on set is symmetric provided that for relations: R! R is irreflexive the. Let 0have n vertices, and transitive relation is a symmetric relation graph of length, (. Relation for pair ( a, represented by a di-graph between distinct nodes an! 98 - 112 out symmetric relation graph 113 pages and undirected graphs are combinatorially equivalent objects by R.,!

Markets Of Trajan, Tv Shows Leaving Hulu, Florence Augusta Lewis Cause Of Death, Bus 89 To Changi Village, Bridgestone Golf Balls Fitting, Lmu Basketball Schedule, What Programs Are On Pbs Tonight, Barbie Fashionistas Face Molds, Chaitanya Girl Name Meaning,


# Ill-conditioning and roundoff errors#

Numerical Methods

## Ill-conditioned matrices#

The conditioning (or lack of, i.e. the ill-conditioning) of matrices we are trying to invert is incredibly important for the success of any algorithm.

As long as the matrix is non-singular, i.e. $$\det(A)\ne 0$$, then an inverse exists, and a linear system with that $$A$$ has a unique solution. What happens when we consider a matrix that is nearly singular, i.e. $$\det(A)$$ is very small?

Well smallness is a relative term and so we need to ask the question of how large or small $$\det(A)$$ is compared to something. That something is the norm of the matrix.

Matrices come in all shape and sizes, and their determinants come in all kinds of values. We know that a ill conditioned matrix has a determinant that is small in absolute terms, but the size of determinants is a relative thing, and we need some kind of comparison to determine what is “small” and what is “large”. Thus, we can create such a reference calculating the norms of the matrix. In this notebook, we will explore how to find the norm and how does the norm relate to the ill conditioning of the matrix.

## Vector norms#

Just as for vectors $$\pmb{v}$$ (assumed as a $$n\times 1$$ column vector) where we have multiple possible norms to help us decide quantify the magnitude of a vector:

$\begin{split} ||\pmb{v}||_2 = \sqrt{v_1^2 + v_2^2 + \ldots + v_n^2} = \left(\sum_{i=1}^n v_i^2 \right)^{1/2}, \quad{\textrm{the two-norm or Euclidean norm}}\\\\\\ ||\pmb{v}||_1 = |v_1| + |v_2| + \ldots + |v_n| = \sum_{i=1}^n |v_i|, \quad{\textrm{the one-norm or taxi-cab norm}}\\\\\\ ||\pmb{v}||_{\infty} = \max\{|v_1|,|v_2|, \ldots, |v_n| = \max_{i=1}^n |v_i|,\quad{\textrm{the max-norm or infinity norm}} \end{split}$

## Matrix norms#

We can define measures of the size of matrices, e.g. for $$A$$ which for complete generality we will assume is of shape $$m\times n$$:

$\begin{split} ||A||_F = \left(\sum_{i=1}^m \sum_{j=1}^n A_{ij}^2 \right)^{1/2}, \quad{\textrm{the matrix Euclidean or Frobenius norm}}\\\\\\ ||A||_{\infty} = \max_{i=1}^m \sum_{j=1}^n|A_{i,j}|, \quad{\textrm{the maximum absolute row-sum norm}}\\\\\\ \end{split}$

Note that while these norms give different results (in both the vector and matrix cases), they are consistent or equivalent in that they are always within a constant factor of one another (a result that is true for finite-dimensional or discrete problems as here). This means we don’t really need to worry too much about which norm we’re using.

Let’s evaluate some examples.

import numpy as np
import scipy.linalg as sl

A = np.array([[10., 2., 1.],
[6., 5., 4.],
[1., 4., 7.]])
print("A =", A)

# The Frobenius norm (default)
# equivalent to sl.norm(A)
print("SciPy norm = ", sl.norm(A, 'fro'))

# The maximum absolute row-sum
print("Maximum absolute row-sum = ", sl.norm(A,np.inf))

# The maximum absolute column-sum
print("Maximum absolute column-sum", sl.norm(A,1))

# The two-norm - note not the same as the Frobenius norm
# also termed the spectral norm
print("SciPy spectral norm =", sl.norm(A,2))

# Spectral norm definition
print("Spectral norm by hand =", np.sqrt(np.real((np.max(sl.eigvals( A.T @ A))))))

A = [[10.  2.  1.]
[ 6.  5.  4.]
[ 1.  4.  7.]]
SciPy norm =  15.748015748023622
Maximum absolute row-sum =  15.0
Maximum absolute column-sum 17.0
SciPy spectral norm = 13.793091098640064
Spectral norm by hand = 13.793091098640065

## Norm implementation#

We will write some code to explicitly compute the two matrix norms defined mathematically above (i.e. the Frobenius and the maximum absolute row-sum norms) and compare against the values found above using in-built scipy functions.

def frob(A):
m, n = A.shape
squsum = 0.
for i in range(m):
for j in range(n):
squsum += A[i,j]**2
return np.sqrt(squsum)

def mars(A):
m, n = A.shape
maxarsum = 0.
for i in range(m):
arsum = np.sum(np.abs(A[i]))
maxarsum = arsum if arsum > maxarsum else maxarsum
return maxarsum

A = np.array([[10., 2., 1.],
[6., 5., 4.],
[1., 4., 7.]])

print("A =", A)
print("Are our norms the same as SciPy?",
frob(A) == sl.norm(A,'fro') and mars(A) == sl.norm(A,np.inf))

A = [[10.  2.  1.]
[ 6.  5.  4.]
[ 1.  4.  7.]]
Are our norms the same as SciPy? True

## Matrix conditioning#

The (ill-)conditioning of a matrix is measured with the matrix condition number:

$\textrm{cond}(A) = |A||A^{-1}|.$

If this is close to one then $$A$$ is termed well-conditioned; the value increases with the degree of ill-conditioning, reaching infinity for a singular matrix.

Let’s evaluate the condition number for the matrix above.

A = np.array([[10., 2., 1.],[6., 5., 4.],[1., 4., 7.]])

print("A =", A)
print("SciPy cond(A) =", np.linalg.cond(A))
print("Default condition number uses matrix two-norm =", sl.norm(A,2)*sl.norm(sl.inv(A),2))
print("sl.norm(A,2)*sl.norm(sl.inv(A),2) =", sl.norm(A,2)*sl.norm(sl.inv(A),2))
print("SciPy Frobenius cond(A) = ", np.linalg.cond(A,'fro'))
print("sl.norm(A,'fro')*sl.norm(sl.inv(A),'fro') =", sl.norm(A,'fro')*sl.norm(sl.inv(A),'fro'))

A = [[10.  2.  1.]
[ 6.  5.  4.]
[ 1.  4.  7.]]
SciPy cond(A) = 10.71337188134679
Default condition number uses matrix two-norm = 10.71337188134679
sl.norm(A,2)*sl.norm(sl.inv(A),2) = 10.71337188134679
SciPy Frobenius cond(A) =  12.463616561943587
sl.norm(A,'fro')*sl.norm(sl.inv(A),'fro') = 12.463616561943585

The condition number is expensive to compute, and so in practice the relative size of the determinant of the matrix can be gauged based on the magnitude of the entries of the matrix.

### Example#

We know that a singular matrix does not result in a unique solution to its corresponding linear matrix system. But what are the consequences of near-singularity (ill-conditioning)?

Consider the following example

$\left( \begin{array}{cc} 2 & 1 \\ 2 & 1 + \epsilon \\ \end{array} \right)\left( \begin{array}{c} x \\ y \\ \end{array} \right) = \left( \begin{array}{c} 3 \\ 0 \\ \end{array} \right)$

When $$\epsilon=0$$ the two columns/rows are not linear independent, and hence the determinant of this matrix is zero, the condition number is infinite, and the linear system does not have a solution (as the two equations would be telling us the contradictory information that $$2x+y$$ is equal to 3 and is also equal to 0).

Let’s consider a range of values $$\epsilon$$ and calculate matrix deteterminant and condition number:

A = np.array([[2.,1.],
[2.,1.]])
b = np.array([3.,0.])
print("Matrix is singular, det(A) = ", sl.det(A))

for i in range(3):
A[1,1] += 0.001
epsilon = A[1,1]-1.0
print("Epsilon = %g, det(A) = %g, cond(A) = %g." % (epsilon, sl.det(A), np.linalg.cond(A)),
"inv(A)*b =", sl.inv(A) @ b)

Matrix is singular, det(A) =  0.0
Epsilon = 0.001, det(A) = 0.002, cond(A) = 5001. inv(A)*b = [ 1501.5 -3000. ]
Epsilon = 0.002, det(A) = 0.004, cond(A) = 2501. inv(A)*b = [  751.5 -1500. ]
Epsilon = 0.003, det(A) = 0.006, cond(A) = 1667.67. inv(A)*b = [  501.5 -1000. ]

We find for $$\epsilon=0.001$$ that $$\det(A)=0.002$$ (i.e. quite a lot smaller than the other coefficients in the matrix) and $$\textrm{cond}(A)\approx 5000$$.

Change to $$\epsilon=0.002$$ causes 100% change in both components of the solution. This is the consequence of the matrix being ill-conditioned - we should not trust the numerical solution to ill-conditioned problems.

A way to see this is to recognise that computers do not perform arithmetic exactly - they necessarily have to truncate numbers at a certain number of significant figures, performing multiple operations with these truncated numbers can lead to an erosion of accuracy. Often this is not a problem, but these so-called roundoff errors in algorithms generating $$A$$, or operating on $$A$$ as in Gaussian elimination, will lead to small inaccuracies in the coefficients of the matrix. Hence, in the case of ill-conditioned problems, will fall foul of the issue seen above where a very small error in an input to the algorithm led to a far larger error in an output.

## Roundoff errors#

As an example, consider the mathematical formula

$f(x)=(1-x)^{10}.$

We can relatively easily expand this out by hand

$f(x)=1- 10x + 45x^2 - 120x^3 + 210x^4 - 252x^5 + 210x^6 - 120x^7 + 45x^8 - 10x^9 + x^{10}.$

Mathematically these two expressions for $$f(x)$$ are identical; when evaluated by a computer different operations will be performed, which should give the same answer. For numbers $$x$$ away from $$1$$ these two expressions do return (pretty much) the same answer.

However, for $$x$$ close to 1 the second expression adds and subtracts individual terms of increasing size which should largely cancel out, but they don’t to sufficient accuracy due to round off errors; these errors accumulate with more and more operations, leading a loss of significance.

import matplotlib.pyplot as plt

def f1(x):
return (1. - x)**10

def f2(x):
return (1. - 10.*x + 45.*x**2 - 120.*x**3 +
210.*x**4 - 252.*x**5 + 210.*x**6 -
120.*x**7 + 45.*x**8 - 10.*x**9 + x**10)

xi = np.linspace(0, 2, 1000)

fig, axes = plt.subplots(1, 3, figsize=(14, 3))
ax1 = axes[0]
ax2 = axes[1]
ax3 = axes[2]

ax1.plot(xi, f1(xi), label = "unexpanded")
ax1.plot(xi, f2(xi), label = "expanded")
ax1.legend(loc="best")
ax1.set_ylabel("$f(x)$", fontsize=14)

ax2.plot(xi, 1.-f1(xi)/f2(xi) * 100, label="Relative\ndifference\nin %")
ax2.legend(loc="best")
ax2.set_xlabel("x", fontsize=14)
ax2.set_ylabel(r"$1-\frac{unexpanded}{expanded}$", fontsize=14)

ax3.set_xlim(0.75, 1.25)
ax3.plot(xi, 1.-f1(xi)/f2(xi) * 100, label="Relative\ndifference\nin %")
ax3.legend(loc="best")
ax3.set_ylabel(r"$1-\frac{unexpanded}{expanded}$", fontsize=14)

plt.suptitle("Comparison of $(1-x)^{10}$ expansion", fontsize=14)

As we can see on the graph, for most of the domain, i.e. far away from 1.0, the expansion is almost the same as the unexpanded version. Near $$x=1$$, the expansion creates huge errors in terms of relative difference.


# Logic quantifier position nuances

I've been learning about translating English to logic and vice versa and I have to say that I find this quite difficult.

On a paper that I'm examining , I've across the following logic formula:

$\forall x (circle(x) \Rightarrow \exists y (circle(y) \land above(x,y)))$

Each circle has a circle somewhere below it

With predicates

$circle(x)$ - $x$ is a circle.

$above(x, y)$ - $x$ is above $y$.

I started to wonder what the nuance is if the exists quantifier was moved outside of the entire bracket like this:

$\forall x \exists y (circle(x) \Rightarrow circle(y) \land above(x,y))$

But my feeling is that this formula I says the same thing as the former sentence but I also think it doesn't as I'm unsure of the meaning in natural English.

Former formula: For all $x$ , if $x$ is a circle then there exists a $y$ such that $y$ is a circle and it is above $x$.

Latter formula: For all $x$ , there exists a $y$ such that if $x$ is a circle then $y$ is a circle and is above $x$.

My question is , what the difference between these two formulas in logic and natural English?

Translating from logic to English is quite hard I think and even harder from English to logic.

Are there any tips for translating from logic to English and vice versa? How do you work out the nuance if two formulas seem alike when you read them?

I've been learning about translating English to logic and vice versa and I have to say that I find this quite difficult.

Indeed.   It is difficult.   Logical expressions in native languages are often very imprecise, and formal mathematics is all about precision.   When converting to and from mathematical expressions you will encounter many trips and traps.

Every student has trouble with this.   Don't be discouraged; just be careful.   It takes practice to master, that's all.

In this case your intuition is quite correct.   The two expressions are correct.   Generally speaking, as long as $y$ does not occur free in $P(x)$, then we have the following equivalence: $$\forall x\Big( P(x) \to \exists y \big(Q(x,y)\big)\big) \iff \forall x\exists y \Big(P(x)\to Q(x,y)\Big)$$

It is important that you don't change the order of nesting the quantifiers when shifting to and from PreNex form of the expression.   Be careful about this.

Note also, however, the following equivalence.

$$\forall x \Big(\exists y\big(Q(x,y)\big) \to P(x)\Big) \iff \forall x \color{red}{\forall} y\Big( Q(x,y) \to P(x)\Big) \\ \Updownarrow \\ \forall x \Big(\neg \exists y\big(Q(x,y)\big) \vee P(x)\Big) \iff \forall x \color{red}{\forall} y\Big( \neg Q(x,y) \vee P(x)\Big)$$

As you see, the placement of the quantifier in the implication matters.   Be careful.

Consider the first formula.

$\forall X (circle(X) \implies \exists Y(circle(Y) \land above(X, Y))$

Let $x$ be an instantiation of $X$.

$circle(x) \implies \exists Y(circle(Y) \land above(x, Y))$

Let $y$ be an instantiation of $Y$.

$circle(x) \implies (circle(y) \land above(x,y))$

So clearly we have a $y$ such that

$circle(x) \implies (circle(y) \land above(x,y))$

So we may existentially generalize this so that

$\exists Y (circle(x) \implies circle(Y) \land above(x, Y))$

And since no conditions were placed on $x$, we may universally generalize so that

$\forall X \exists Y (circle(X) \implies circle(Y) \land above(X, Y))$

To answer your question, in general yes $\forall x \exists y(A(x) \implies B(x,y)) \equiv \forall x (A(x) \implies \exists y B(x, y))$ so long as A does not depend on y; however, it is also VERY important that you do not changer the order in which the quantifiers occur.

Any formula in logic is equivalent to a formula in Pre-Nex normal form, which begins with a string of quantifiers, followed by a quantifier-free expression. The two formulas you give are equivalent. I think there must be a published algorithm .Even professional mathematicians can find parsing a formula to be less than easy.

• So is it safe to say that since they are equivalent they have the same meaning in natural English? How did you figure out that they are equivalent? By using equivalences? $\forall x (A \Rightarrow \exists y B)$ and $\forall x \exists y (A \Rightarrow B)$ ? – Nubcake Jul 25 '15 at 19:33


# Mean distance between 2 points in adjacent voxels (cubes)

Let's imagine our central unit voxel $$V_1=[0,1]^3$$.

We allow the second one to be in $$V_2=[-1,2]^3 \setminus [0,1]^3~$$, the surrounding voxel (center removed).

My question:

What is the mean distance between a point in $$V_1$$ and a point in $$V_2$$?

Of course, the direct approach would be to write an integral:

$$\frac{1}{1^3}\frac{1}{3^3-1^3} \times$$ $$\iiint_{(x_1,y_1,z_1)\in V_1} \iiint_{(x_2, y_2,z_2) \in V_2} \sqrt{(x_1-x_2)^2+(y_1-y_2)^2+(z_1-z_2)^2}\mathrm{d}x_{1,2} \mathrm{d}y_{1,2}\mathrm{d}z_{1,2}$$

but the one-variable function does not seem to admit a nice integral.

Has anyone gone through this calculation and would you be able to suggest any helpful manipulation before I dive into a numeric simulation?

Thanks.

• Small update : succeeding a numeric simulation, I got $\approx 1.8288$. If this rings a bell to you or if it roughly seems odd, please tell me so that I can correct. I expected a smaller number but the distribution's boundaries I obtained seemed consistent with the problem. – Wyllich May 24 '18 at 15:21
• An analytic solution is indeed available (using known results), but before I post an answer I need to make sure: if I understand your setup correctly, the volume of $V_2$ is $3^3 - 1$ so shouldn't the normalization constant be $\frac1{26}$? – Lee David Chung Lin May 24 '18 at 18:46
• Yes, the volume is equal to that fraction. I will correct that right away. – Wyllich May 24 '18 at 19:37
• Can you get access (by whatever means you feel appropriate) to the paper by Robbins and Bolis cited in the wiki page for Robbbins' constant? If not, in addition to me having to type up the equation (for box of general side lengths), you'll have to trust me that I quote their result correctly. – Lee David Chung Lin May 24 '18 at 21:31
• Thank you very much for mentioning the name of Robbin's constant. I now possess a starting point from which I may derive the solution. Thank you again. I'll try to find the source material if possible, count on me. – Wyllich May 24 '18 at 21:41

## Notations

Denote $$E(a,b,c)$$ as the expectation seen in the middle of p.278 (right before Eq.(2)) of the short paper (communication) by Robbins and Bolis. It is the average distance for a box of side lengths that are double of the inputs: $$2a, 2b$$, and $$2c$$.

Note that the inverse hyperbolic sine has a logarithmic form: $$\sinh^{-1} x = \ln (x + \sqrt{x^2 + 1})$$. That's how one ends up seeing those logs when $$E(a,b,c)$$ is evaluated numerically.

Denote $$\mathcal{I}$$ as the integral for your desired average but without the $$1/26$$ normalization.

Similarly, we will have the integrals $$I_{f}$$ for face-to-face, $$I_{e}$$ for edge-to-edge, and $$I_{v}$$ for vertex-to-vertex. All these are just integrals without normalization (thus not averages themselves). Details continue in the following sections.

Denote $$R_b$$ as the Robbins' constant, namely, $$R_b = E(\frac12, \frac12, \frac12) \approx 0.6617$$. Note that $$R_b$$ is the average, while it equals in value to its corresponding integral, which shall be denoted $$I_0$$. That is, numerically $$R_b = I_0$$ because the volume is $$1$$.

## Strategy Outline

As you have noticed, there are obstacles in directly setting up the density. The symmetry and nice numbers (integers) strongly suggest that one should solve this via decomposing the space into blocks of unit cubes.

Any cube has $$6$$ faces, $$12$$ edges (sides), and $$8$$ vertices, therefore

$$\mathcal{I} = 6 I_f + 12 I_e + 8 I_v \tag{1} \label{Eq_26-decomp}$$

Your $$V_1$$ is the unit cube at the "center", surrounded by $$26$$ unit cubes that are disjoint and which adds up exactly to your $$V_2$$. For a different configuration this approach needs modification since the space doesn't decompose nicely in general.

The $$26$$ blocks consist of three groups: six of them are face-to-face with $$V_1$$, twelve of them are edge-touching-edge-only with $$V_1$$, and the remaining eight are vertex-touching-vertex-only with $$V_1$$.

The value of each $$I_f$$, $$I_e$$, and $$I_v$$ will be obtained using $$E(a,b,c)$$, successively building up starting from $$I_f$$.

It will involve a $$2$$-$$1$$-$$1$$ long box, a $$2$$-$$2$$-$$1$$ flat box, then finally the $$2$$-$$2$$-$$2$$ "double cube".

## Calculation Details

Formally, the integrals can be defined as (with more shorthands in additional to yours) D_{1,2} \equiv \sqrt{(x_1-x_2)^2+(y_1-y_2)^2+(z_1-z_2)^2} \\ \begin{align*} I_f = \iiint\limits_{ V_1} \iiint\limits_{(x_2, y_2,z_2) \in V_{\mathbf{F}}} D_{1,2} \,\mathrm{d}x_{1,2}\,\mathrm{d}y_{1,2}\, \mathrm{d}z_{1,2} \\ I_e = \iiint\limits_{ V_1} \iiint\limits_{(x_2, y_2,z_2) \in V_{\mathbf{E}}} D_{1,2} \,\mathrm{d}x_{1,2}\,\mathrm{d}y_{1,2}\, \mathrm{d}z_{1,2} \\ I_v = \iiint\limits_{ V_1} \iiint\limits_{(x_2, y_2,z_2) \in V_{\mathbf{V}}} D_{1,2} \,\mathrm{d}x_{1,2}\,\mathrm{d}y_{1,2}\, \mathrm{d}z_{1,2} \end{align*} The volume $$V_F$$ can be any unit cube adjacent and face-to-face with $$V_1$$. For example, $$V_F \equiv \bigl\{(x,y,z) \big|~~ x \in [1,2],\, y \in [0,1],\, z \in [0,1]\bigr\}$$

Similarly, the edge-to-edge volume $$V_E$$ can be, for example, $$\bigl\{x \in [1,2],\, y \in [0,1],\, z \in [1,2]\bigr\}$$, and the vertex-to-vertex volume $$V_V$$ can be $$\bigl\{x \in [1,2],\, y \in [1,2],\, z \in [1,2]\bigr\}$$.

The formulation of $$I_f$$ (or $$I_e$$, or $$I_v$$) is not unique (up to $$6$$, $$12$$, $$8$$ multiplicity for any $$V_1$$, which itself can resides anywhere), but it doesn't matter. The value of each integral is unique and can be obtained using $$E(a,b,c)$$.

### Successive Build-up (1): $$~$$ starting from $$I_f$$

Consider a $$2$$-by-$$1$$-by-$$1$$ long box, which is equivalent to two $$V_1$$ joined face-to-face. Denote the box as $$V_{_{2.1.1}}$$ . We know that its volume is $$|V_{_{2.1.1}}| = 2$$ .

For the average distance, decompose the integral (space) into two within-cube and two across-cubes.

$$|V_{_{2.1.1}}|^2 \cdot E( 1,\tfrac12, \tfrac12) = 2 I_0 + 2 I_f \tag{2} \label{Eq_long-box_decomp}$$

There are two $$I_0$$ because each half of $$V_{_{2.1.1}}$$ are physically distinct so that ordering matters. For the same reason, there are two $$I_f$$.

Note that $$I_0$$ here emphasizes that it is the integral and not the average $$R_b$$, although numerically they are the same.

Now is the time we must make explicit use of $$E(a,b,c)$$ by Robbins and Bolis for the general box. $$\begin{multline*} E(1, \tfrac12, \tfrac12) = \frac1{1260} \Bigl[520 + 17\sqrt{2} - 20\sqrt{5} - 81 \sqrt{6} + 21 \log\left(\sqrt{2}+1\right) \\ + 168 \log \left(\sqrt{2}+\sqrt{3}\right) + 735 \log\bigl( \frac{ \sqrt{6} + 1 }{ \sqrt{5} }\bigr) + 1344 \log \left(\frac{1}{2} \left(\sqrt{5}+1\right)\right) \\ + 42 \log \left(\sqrt{5}+2\right) - 1344 \arcsin\bigl( \frac15 \bigr) - 168 \arcsin\bigl( \sqrt{\frac25 } \bigr) \Bigr] \end{multline*}$$ I coded $$E(a,b,c)$$ with Mathematica and would never consider doing this by hand. The $$E(1,\frac12,\frac12)$$ here as well as later $$E(a,b,c)$$ evaluations are done by the computer algebraic system.

The above display is just to demonstrate what we are dealing with here. To save space, the exact expression for future $$E(a,b,c)$$ will be omitted.

Moving on, $$E(1,\frac12,\frac12) \approx 0.91455248459664313930734$$ and we have \begin{align*} I_f = \frac{ |V_{_{2.1.1}}|^2 }2 E( 1,\tfrac12, \tfrac12) - I_0 &= 2 E( 1,\tfrac12, \tfrac12) - Rb \tag{3.a} \label{Eq_Int-face_in_Rb} \\ &\approx 1.16739778692611 \tag{3.b} \label{Eq_Int-face_value} \end{align*}

### Successive Build-up (2): $$~$$ from $$I_f$$ to $$I_e$$

Consider a $$2$$-by-$$\mathbf{2}$$-by-$$1$$ flat box, which is equivalent to four $$V_1$$ joined together with pairwise face-to-face. Denote this box as $$V_{_{2.2.1}}$$. We know that its volume is $$|V_{_{2.2.1}}| = 4$$.

The decomposition of the integral (space) goes like this: for each of the four unit cubes, there is one within-cube integral, two face-to-face integral, and one edge-to-edge integral. $$|V_{_{2.2.1}}|^2 \cdot E( 1, 1, \tfrac12) = 4 \left( I_0 + 2 I_f + I_e \right) \tag{4} \label{Eq_flat-box_decomp}$$ Again, the cubes are physically distinct and order matters. Note that the decomposition counts the spaces as $$4^2 = 4\cdot (1 + 2 + 1)$$.

Plugin the $$E(a,b,c)$$ formula to get $$E(1, 1,\frac12) \approx 1.1320874696118224667$$ and then replacing $$I_f$$ with Eq\eqref{Eq_Int-face_in_Rb}, we have: \begin{align*} I_e = \frac{ |V_{_{2.2.1}}|^2 }4 E( 1, 1, \tfrac12) - I_0 - 2I_f &= 4E( 1,1, \tfrac12) - R_b - 2 \bigl( 2 E( 1,\tfrac12, \tfrac12) - R_b \bigr) \\ &= 4 \bigl( E( 1, 1, \tfrac12) - E( 1,\tfrac12, \tfrac12) \bigr) + R_b \tag{5.a} \label{Eq_Int-edge_in_Rb} \\ &\approx 1.5318471223279 \tag{5.b} \label{Eq_Int-edge_value} \end{align*}

### Successive Build-up (3): $$~$$ get $$I_v$$ from $$I_f$$ and $$I_e$$

Consider a $$2$$-by-$$2$$-by-$$2$$ "double cube", which is equivalent to eight $$V_1$$ joined together with pairwise face-to-face. It is also just $$V_1$$ scaled up by a factor of two. Denote this box as $$V_{_{2.2.2}}$$.

We know that its volume is $$|V_{_{2.2.2}}| = 2^3 = 8$$, and this time we also know that $$E(1,1,1) = 2 E( \frac12, \frac12, \frac12) = 2R_b$$ simply due to the linear scalability of the geometry.

The integrals (spaces) decompose similarly. For each of the eight unit cubes, there is one within-cube integral, three face-to-face integral, three edge-to-edge integral, and one vertex-to-vertex integral. $$|V_{_{2.2.2}}|^2 \cdot E( 1, 1, 1) = 8 \left( I_0 + 3 I_f + 3I_e + I_v \right) \tag{6} \label{Eq_double-cube_decomp}$$ As before, the order matters and the decomposition says $$8^2 = 8\cdot (1 + 3 + 3 + 1)$$.

Take $$E( 1, 1, 1) = 2R_b\,,\,$$ take $$I_f$$ as Eq\eqref{Eq_Int-face_in_Rb}, and take $$I_e$$ as Eq\eqref{Eq_Int-edge_in_Rb}, we end up with

\begin{align*} I_v &= \frac{ |V_{_{2.2.2}}|^2 }8 E( 1, 1, 1) - I_0 - 3I_f - 3 I_e \\ &= 8 \cdot 2R_b - R_b - 3 \Bigl[ 2 E( 1,\tfrac12, \tfrac12) - R_b + 4 \bigl( E( 1, 1, \tfrac12) - E( 1,\tfrac12, \tfrac12) \bigr) + R_b \Bigr] \\ &= 15 R_b - 6\bigl[ 2E( 1, 1, \tfrac12) - E( 1,\tfrac12, \tfrac12) \bigr] \tag{6.a} \label{Eq_Int-vertex_in_Rb} \\ &\approx 1.82787300624563276 \tag{6.b} \label{Eq_Int-vertex_value} \end{align*}

Finally, putting things together into Eq\eqref{Eq_26-decomp} we get:

\begin{align*} \mathcal{I} &= 6I_f + 12I_e + 8 I_v \\ &= 2 \Bigg\{ 3\bigl( 2 E(1,\tfrac12,\tfrac12 ) - R_b\bigr) + 6 \Bigl[ R_b + 4 \bigl( E(1, 1,\tfrac12 ) - E(1,\tfrac12,\tfrac12 )\bigr) \Bigr] + 4 \Bigl[ 15R_b - 6 \bigl( 2E(1, 1,\tfrac12 ) - E(1,\tfrac12,\tfrac12 )\bigr) \Bigr]\Bigg\} \\ &= 2 \bigl( 63R_b + 6 E(1,\tfrac12,\tfrac12 ) - 24 E(1,1,\tfrac12 ) \bigr) \tag{7.a} \label{Eq_Int-desired_in_Rb} \\ &\approx 40.0095362394564449 \tag{7.b} \label{Eq_Int-desired_value} \\ \end{align*}

The desired average is $$\frac1{26} \mathcal{I}\approx 1.53882831690217095767637627$$

The respective sub-equations Eq\eqref{Eq_Int-face_in_Rb}, Eq\eqref{Eq_Int-edge_in_Rb}, Eq\eqref{Eq_Int-vertex_in_Rb}, and Eq\eqref{Eq_Int-desired_in_Rb} showcase the expression in minimal terms of $$E(a,b,c)$$ where terms are converted to $$R_b$$ whenever possible.

These are the reminders that the exact solution is obtainable, that the functional form still exhibits some recognizable geometry, and that one can calculate any intermediate or final results to as many digits as one like.

## Concluding Remarks

It should be clear that one cannot arrive at the desired integral solely by using $$R_b$$. After carving out the contribution of $$V_1$$ at the center from a triple-cube, one still has to deal with the $$V_2$$-to-$$V_2$$ cross terms. In the end, one will have to do something similar to the derivation above.

When the space is in a nice configuration (smooth boundary with no zig-zags, no holes within ,etc), the exact integral in general is manageable, yet already requiring some attention to details. It is very telling that for the derivation of $$E(a,b,c)$$, Robbins and Bolis wrote that "By tedious yet routine successive integration one finds that ..."

For the sake of completeness, for related in-site posts one can start with rectangle in $$2$$-dim and more generally for hypercubes.

It is totally feasible to derive the density from scratch for this particular $$\{ V_1, \, V_2 \}$$ pair. The transformation of random variables involved is pretty basic. It is just that due to the "hole" in $$V_2$$, inevitably one will be forced to decompose the space.

"Decomposing the space into disjoint spaces" is a standard technique in dealing with probability inquiries, and the decomposition is not necessarily into integer valued partitions. There are indeed limitations to this approach, but the concept is rather simple.

In terms of numerical calculation, once you have coded the $$E(a,b,c)$$ in whatever system you're using, this procedure is pretty straightforward.

I don't know your original motivation for doing this calculation, but I'd say this approach is practically useful across disciplines, from theoretical to applications.

• What a ride! Thank you for posting such a detailed and comprehensive answer. I will definitely remember the idea of dividing the integral space as you masterfully did to obtain intermediate integrals through multiple iterations. I guess I owe you an explanation about the whys. In LiDAR image processing, I asked myself the possibility of predicting the resolution (here understand mean distance between a point and its closest neighbour) of a downsampled cloud using a voxel grid. In spite of my hypothesis based on the distance you calculated being disproved by experience, I still believe it (1) – Wyllich May 28 '18 at 12:46
• ... was a good experience to have. Thank you very much again. (2) – Wyllich May 28 '18 at 12:47
• Very glad I could help. I know only a little bit about image process or data compression in general, but what you described sounds no lesser than some innovative ideas that eventually became successful. – Lee David Chung Lin May 28 '18 at 13:12
• Now that I think about it, your method gave me new ideas to precise my hypothesis which is based on isotropy (hence V2 containing V1). However, I may add some coefficients in front of each term of equations (2), (4), (6) to take into account anisotropy and capture an idea about the cloud's global structure. I must repeat myself : your dedication gave birth to many new ideas I may now explore. – Wyllich May 28 '18 at 13:25
• Thank you for saying that. It's been a real pleasure. – Lee David Chung Lin May 28 '18 at 13:46


# How do I solve this Olympiad question with floor functions?

Emmy is playing with a calculator. She enters an integer, and takes its square root. Then she repeats the process with the integer part of the answer. After the third repetition, the integer part equals 1 for the first time. What is the difference between the largest and the smallest number Emmy could have started with?

$$\text{(A)} \; 229 \qquad \text{(B)} \; 231 \qquad \text{(C)} \; 239 \qquad \text{(D)} \; 241 \qquad \text{(E)} \; 254$$

This was Problem 19 from the first round of the Norwegian Mathematical Olympiad, 2014–15.

I think the floor function applies well here.

The integer part obviously is the floor part of it.

Let $x_1$ be the initial.

$x_2 = \left \lfloor{{\sqrt{x_1}}}\right \rfloor$

$x_3 = \left \lfloor{{\sqrt{x_2}}}\right \rfloor$

$x_4 = \left \lfloor{{\sqrt{x_3}}}\right \rfloor = 1$ <-- Last one.

So we need to find $b \le x_1 \le c$ such that $b$ is the smallest number to begin with and $c$ is the largest number to begin with.

$\sqrt{b} \le \sqrt{x_1} \le \sqrt{c}$

Clearly we must have $x_3<4$, $x_2<16$, and $x_1<256$, so the largest possible value of $x_1$ is $255$. Since $x_3>1$, we know that $x_3\ge 2$ and hence that $x_2\ge 4$. This implies that $x_1\ge 16$. Thus, the range is from $16$ through $255$, the difference being $239$.

• @BrianScott, Thanks. Clear up, why must we have those conditions? Why $x_1 < 256$? – Robart Jan 24 '15 at 18:05
• We know that $x_4=1$, so $1\le\sqrt{x_3}<2$, and therefore $x^3<2^2=4$. Now repeat the reasoning back up the line: $x_3<4$, so $\sqrt{x_2}<4$, and $x_2<16$. And so on. – Brian M. Scott Jan 24 '15 at 18:06
• @Robart: Sorry: I forgot to ping you with my answer. See the comment immediately above this one. – Brian M. Scott Jan 24 '15 at 18:13
• why cant she start with $x_1 = 1$ so the difference is $255 - 1 = 254$? – Robart Jan 24 '15 at 18:43
• @Robart: Because we’re told that $x_4$ is the first of these integers to be equal to $1$. – Brian M. Scott Jan 24 '15 at 18:45

We can work backwards more easily than we can work forwards. Firstly, what does a number $x$ need to satisfy to have $\lfloor x \rfloor = 1$? Easy. We need: $$1\leq x < 2.$$ Well, suppose that $\sqrt{y}=x$ or, equivalently, $y=x^2$. Well, obviously we just square the above equation (as all of its terms are positive): $$1\leq x^2 < 2^2.$$ Suppose $\sqrt{z}=y$ or $z=y^2=x^4$. Square the above again! $$1\leq x^4 < 2^4.$$ And finally let $\sqrt{w}=z$ or $w=z^2=y^4=x^8$. Square the above $$1\leq x^8 < 2^8.$$

So, if she chose $z$ to be any integer in $[1,2^8)$, she will get $1$ as the final result. However, if $z$ were in the interval $[1,2^4)$, she would have gotten $1$ as the second result as well. So, we restrict ourselves to the integers in $[2^4,2^8)$, as these will satisfy the desired condition.

• And how do you pick the smallesT? Its supposed to be $16$? – Robart Jan 24 '15 at 18:33
• Yes, the condition that the third time is the first time that the number is $<2$ means that $x^2\geq 2$. – Thomas Andrews Jan 24 '15 at 18:35
• Why does it have to be $x^2 \ge 2$? then $x ge \sqrt{2}$ – Robart Jan 24 '15 at 18:41
• It should be 254 I believe. The smallest is $1$ since $\sqrt{1} = 1$ for $n$ square roots. – Robart Jan 24 '15 at 18:43
• @Robart The question says that the third time is the first for which the result is $1$ - the greatest possible number is $255$, as higher numbers don't reach $1$ fast enough, and the least is $16$, as lower numbers reach $1$ too fast. – Milo Brandt Jan 24 '15 at 18:46


# What is the use of the Dot Product of two vectors?

Suppose you have two vectors a and b that you want to take the dot product of, now this is done quite simply by taking each corresponding coordinate of each vector, multiplying them and then adding the result together. At the end of performing our operation we are left with a constant number.

My question therefore is what can we do with this number,why do we calculate it so to speak? I mean it seems almost useless to me compared with the cross product of two vectors (where you end up with an actual vector).

-
You can use it to find the angle between any two vectors. $\mathbf{a}\cdot\mathbf{b}=|\mathbf{a}||\mathbf{b}|\cos\theta$ where $\theta$ is the angle between the two vectors. This is a better approach than using the cross product as the cross product can only be defined in a few dimensions (normally only 3 dimensions). Obviously this is just one simple use of the dot product which is a special case of a more general phenomenon known as an inner product en.wikipedia.org/wiki/Inner_product_space . –  Daniel Rust Jun 8 '13 at 15:35
You should take a look at how it is derived as it can be very enlightening. Take a look at Lang's Linear Algebra (2E) pg.19-20. –  12F8031 Jun 8 '13 at 20:18
I always found that the dot product is a good way to measure how "parallel" two vectors are –  Dan Jun 9 '13 at 7:15

Re: "[the dot product] seems almost useless to me compared with the cross product of two vectors ".

Please see the Wikipedia entry for Dot Product to learn more about the significance of the dot-product, and for graphic displays which help visualize what the dot product signifies (particularly the geometric interpretation). Also, you'll learn more there about how it's used. E.g., Scroll down to "Physics" (in the linked entry) to read some of its uses:

Mechanical work is the dot product of force and displacement vectors.
Magnetic flux is the dot product of the magnetic field and the area vectors.

You've shared the algebraic definition of the dot product: how to compute it as the sum of the product of corresponding entries in two vectors: essentially, computing $\;\mathbf A \cdot \mathbf B = {\mathbf A}{\mathbf B}^T.\;$ But the dot product also has an equivalent geometric definition:

In Euclidean space, a Euclidean vector is a geometrical object that possesses both a magnitude and a direction. A vector can be pictured as an arrow. Its magnitude is its length, and its direction is the direction the arrow points. The magnitude of a vector A is denoted by $\|\mathbf{A}\|.$ The dot product of two Euclidean vectors A and B is defined by

$$\mathbf A\cdot\mathbf B = \|\mathbf A\|\,\|\mathbf B\|\cos\theta,\quad\text{where \theta is the angle between A and B.} \tag{1}$$

With $(1)$, e.g., we see that we can compute (determine) the angle between two vectors, given their coordinates: $$\cos \theta = \frac{\mathbf A\cdot\mathbf B}{\|\mathbf A\|\,\|\mathbf B\|}$$

-
I am not stating what the dot product signifies, in fact that is the essence of this question, I did not know that the dot product has an equivalent geometric definition, or that it could be used to calculate the angle between two vectors that is extremely useful. –  Jonn_Underwood Jun 8 '13 at 15:45
I didn't intend to criticize. I'm sorry if that's how the post comes across! Indeed, I upvoted the question because it's a fine question, and you put thought into writing it. –  amWhy Jun 8 '13 at 15:47
The dot product is also the product $\bf A B^T$ of vector A with the transpose of vector B. –  amWhy Jun 8 '13 at 15:49
@amWhy: Thank you, I had an upvote mind - trigger finger! :-) Fixed! –  Amzoti Jun 9 '13 at 1:37
@amWhy thank you for your suburb answer , and also thank you for adding that formula at the bottom for finding the cosine of theta this alone is extremely useful to me due to my pursuit of physics! –  Jonn_Underwood Jun 9 '13 at 21:24
show 1 more comment

The original motivation is a geometric one: The dot product can be used for computing the angle $\alpha$ between two vectors $a$ and $b$:

$a\cdot b=|a|\cdot|b|\cdot \cos(\alpha)$.

Note the sign of this expression depends only on the angle's cosine, therefore the dot product is

• $<0$ if the angle is obtuse,
• $>0$ if the angle is acute,
• $=0$ if the $a$ and $b$ are orthogonal.

Another important special case appears when $a=b$: The root of the scalar product of a vector with itself is the length of a vector:

$a\cdot a=|a|\cdot|a|\cdot1=|a|^2$.

There's another interesting application of the dot product, in combination with the cross product: If you have three vectors $a$, $b$ and $c$, they define a parallelepiped, and you can compute its (signed) volume $V$ as follows using the so-called scalar triple product:

$V=(a\times b)\cdot c$

(Note that this is a generalization of $|a\times b|$ being the area of the parallelogram defined by $a$ and $b$.)

-
There's nothing special about 2d/3d here; this means of finding the angle between vectors applies to an arbitrary number of dimensions. –  Muphrid Jun 8 '13 at 15:50
@Muphrid: Of course you can define something like an "angle" in arbitrary dimensions. I've changed "geometrical" to "visual", I think that makes more sense. –  zero-divisor Jun 9 '13 at 6:12
Perhaps. But two vectors define only a plane, so even in a 4d space or higher, the geometry basically isn't changing: you have two vectors in some common plane, and the dot product tells us how alike they are. I think you're making it out to be more complicated than it really is. –  Muphrid Jun 9 '13 at 6:17
@Muprid: Good point. I've deleted the sentence now. –  zero-divisor Jun 9 '13 at 6:19

The dot product is an essential ingredient in matrix product. The product of the two matrices $A$ and $B$ (of compatible sizes, that is, the number of columns of $A$ equals the number of rows of $B$) is a matrix whose $(i, j)$ component is the dot product of the $i$-th row of $A$ and the $j$-th column of $B$.

Among the many applications, consider this simple one.

You have students $s_{1}, \dots, s_{n}$ taking courses $c_{1}, \dots, c_{m}$. Consider the matrix $A$ which has $0$ everywhere, except that the $(i,j)$ coefficient is $1$ if the student $s_{j}$ takes the course $c_{i}$. Now note that the dot product of the $i_{1}$-th row of $A$ with the $i_{2}$-th row gives the number of students that take both $c_{i_{1}}$ and $c_{i_{2}}$. In other words, the matrix $A A^{t}$ has in its $(i, j)$ position the number of students taking both $c_{i}$ and $c_{j}$.

This matrix is of course useful in building a course timetable.

-

Before addressing your question, i want to say that this is a very good question and you are right to expect that the dot product has use/significance.

First, it is important that you think about vectors separate from their coordinates. While it is true that we often represent vectors as a series of coordinates along well-defined axes, this is merely for computational reasons. A vector as an idea "exists" in a space without any predefined coordinate system. I say this because there are two definitions of the dot product, one is coordinate free (i.e. $\mathbf a\cdot\mathbf b = \|\mathbf a\|\,\|\mathbf b\|\cos\theta$) and the other is based on coordinates (i.e. $\mathbf a\cdot\mathbf b = \sum_i{a_i b_i}$). Of these two, it is best to think of the dot product in terms of the former as it does not depend on a coordinate system. (It is relatively easy to show that the latter may be derived from the former, but in that derivation is an implicit assumption that the coordinate system being used to represent the dot product is orthogonal.)

Second, given the coordinate-free definition, the fundamental idea of the dot product is that of projection. By this it gives a single number which indicates the component of a vector in the direction of another vector. Your observation of the dissimilarity between the dot and cross product is correct, however, the dot product is used to produce a vector as well, it just does it component-by-component. Let's suppose that we have a vector $\mathbf v$ represented by its components in a given coordinate system. Let's further suppose that we have an orthonormal basis defined in that same coordinate system as the set of column vectors $\{\mathbf u_1, \mathbf u_2, \ldots, \mathbf u_n\}$. Finally, suppose that we want to represent $\mathbf v$ in this basis as $\mathbf w$. The question is how do we do that? We use the dot product of course! So the first component of $\mathbf w$ would then be $w_1 = \mathbf u_1\cdot \mathbf v$, and the second component would be $w_2 = \mathbf u_2\cdot \mathbf v$ and so on. (Note that because $\|\mathbf u_i\| = 1$, we have $\mathbf u_1\cdot \mathbf v= \|\mathbf v\|\cos\theta_i$.) If we then think of the vector $\mathbf w$ defined as such we have

$$\mathbf w = \left[ \begin{array}{c} w_1 \\ w_2 \\ \vdots \\ w_n \end{array} \right] = \left[ \begin{array}{c} \mathbf u_1\cdot \mathbf v \\ \mathbf u_2\cdot \mathbf v \\ \vdots \\ \mathbf u_n\cdot \mathbf v \end{array} \right] = \left[ \begin{array}{c} \mathbf u_1^T \mathbf v \\ \mathbf u_2^T \mathbf v \\ \vdots \\ \mathbf u_n^T \mathbf v \end{array} \right] = \left[ \begin{array}{c} \mathbf u_1^T \\ \mathbf u_2^T \\ \vdots \\ \mathbf u_n^T \end{array} \right]\mathbf v = \left[ \begin{array}{cccc} \mathbf u_1 & \mathbf u_2 & \cdots &\mathbf u_n \end{array} \right]^T\mathbf v$$

Finally, we conclude that the dot product plays a key role in the transformation of a vector from one basis to another and that the dot product is hidden in the definition of matrix multiplication in that one view of a matrix-vector product is that each element in the product represents a dot product between a row of the left and a column of the right.

I hope this helps.

-

The geometric idea of the dot product has been touched upon, but there is a vast generalization of this product in geometric algebra, the algebra of not only oriented lines (vectors) but planes, volumes, and more (called blades).

In geometric algebra, we have a generalized dot product of a vector $a$ and another blade $B$ denoted $a \cdot B$. This product has a simple geometric interpretation as the part of $B$ orthogonal to the projection of $a$, with magnitude $|a||B|| \cos \theta|$, where $\theta$ is the angle $a$ forms with its projection in $B$.

(Note: as a point of fact, $a \cdot B$ is orthogonal to $a$ also, not just its projection into $B$, but thinking about this leads to some difficulties, while thinking about what's perpendicular to the projection does not.)

If $B$ is a 2-blade (also called a bivector), then you should be able to imagine this directly: if $a$ lies entirely in $B$, then $a \cdot B$ is just the vector perpendicular to $a$ in $B$. If $a$ does not lie entirely in $B$, then it can be decomposed into a tangential part and a normal part. We throw away the normal part, and the previous logic applies for the tangential part.

If $B$ is a 3-blade (a trivector), then in 3d space $a$ must lie in $B$ (for there is no 3d volume that a vector does not help span), and the product $a \cdot B$ is the "Hodge dual", or the plane perpendicular to $a$.

In this light, the dot product of vectors may actually be the most non-intuitive part of this reasoning. When you take the dot product, there's only a scalar left--there's no vector or other higher dimensional object left to be orthogonal to $a$. Again, this is why I emphasize that $a \cdot B$ is the part of $B$ orthogonal to the projection of $a$ onto $B$. When $B$ is a vector, it's clear there is no other vector or anything else that can be orthogonal to the projection of $a$, for $B$ and that projection are parallel, so the result is necessarily just a scalar.

-


# Every natural number is covered by consecutive numbers that sum to a prime power.

Conjecture. For every natural number $$n \in \Bbb{N}$$, there exists a finite set of consecutive numbers $$C\subset \Bbb{N}$$ containing $$n$$ such that $$\sum\limits_{c\in C} c$$ is a prime power.

A list of the first few numbers in $$\Bbb{N}$$ has several different covers by such consecutive number sets.

One such is:

 3   7  5 13  8  19  11  25    29   16     37    41          49    53
___ ___ _ ___ _ ____ __ _____ _____ __ __ _____ _____       _____ _____    __
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
___   ___                _____             _____ __       ________
11    17                   31                43              81
59               71           3^5
___    __       _____    _________________
30 31 32 33 34 35 36 37 38 39 40 41 42 43 .....
_____    _____    _____
61       67        73

• Apparently, primes are allowed as well. Not sure, whether it has been proven, but this is very likely to be the case. More interesting is to exclude the primes. – Peter Jan 12 '20 at 10:34
• @Peter: The sum can only be a prime if it has at most two terms. (Since $\sum_{k=m}^nk=(n-m+1)(n+m)/2$, which factorizes unless $n-m+1\le2$.) The density of one- and two-term sums that are primes goes to zero, so the brunt of the conjecture has to be borne by the proper prime powers, anyway. – joriki Jan 12 '20 at 13:02
• @Peter a prime power by definition includes the exponent $1$. Therefore, for sake of simplicity, we include the primes. – StudySmarterNotHarder Jan 12 '20 at 17:32

For any odd prime $$p$$, there are $$p$$ consecutive integers centred on $$p$$ that sum to $$p^2$$.

$$2+3+4=3^2$$
$$3+4+5+6+7=5^2$$
$$4+5+6+7+8+9+10=7^2$$
etc.

Let $$p_n$$ be the $$n$$-th prime. Then, using Bertrand's postulate in the form $$p_{n+1}<2p_n$$we know that the above sums for consecutive primes overlap.

Finally, we note that $$1+2=3$$ to complete the proof.

I don't know if this has been shown before, but the proof seems straightforward.

While nickgard's answer shows how to solve the problem using sums being squares of increasing primes, this answer shows how to do it using the sums being just odd powers of $$3$$.

As suggested in joriki's question comment, for any integers $$1 \le j \le k$$, you have

\begin{aligned} \sum_{i=j}^{k}i & = \sum_{i=1}^{k}i - \sum_{i=1}^{j-1}i \\ & = \frac{k(k+1)}{2} - \frac{(j-1)(j)}{2} \\ & = \frac{k^2 + k - j^2 + j}{2} \\ & = \frac{(k-j)(k+j) + k + j}{2} \\ & = \frac{(k+j)(k-j+1)}{2} \end{aligned}\tag{1}\label{eq1A}

Consider the ranges $$\left[\frac{3^m + 1}{2},\frac{3^{m+1} - 1}{2}\right]$$ for $$m = 0, 1, 2, \ldots$$. The union of these disjoint subsets cover all positive integers. Thus, for any $$n \ge 1$$, there's a unique $$m$$ where $$n \in \left[\frac{3^m + 1}{2},\frac{3^{m+1} - 1}{2}\right]$$. For that $$m$$, since $$\frac{5\left(3^{m}\right)-1}{2} \gt \frac{3^{m+1} - 1}{2}$$, you can have $$j = \frac{3^m + 1}{2}$$ and $$k = \frac{5\left(3^{m}\right)-1}{2}$$ with $$n \in [j,k]$$. Using this in \eqref{eq1A} gives

\begin{aligned} \sum_{i=j}^{k}i & = \frac{(k+j)(k-j+1)}{2} \\ & = \frac{\left(\frac{5\left(3^{m}\right)-1}{2}+\frac{3^m + 1}{2}\right)\left(\frac{5\left(3^{m}\right)-1}{2}-\frac{3^m + 1}{2}+1\right)}{2} \\ & = \frac{\left(\frac{6\left(3^{m}\right)}{2}\right)\left(\frac{4\left(3^{m}\right)}{2}-\frac{2}{2}+1\right)}{2} \\ & = \frac{\left(3\left(3^{m}\right)\right)\left(2\left(3^{m}\right)\right)}{2} \\ & = \left(3^{m+1}\right)\left(3^{m}\right) \\ & = 3^{2m+1} \end{aligned}\tag{2}\label{eq2A}

The first few examples for $$m = 0, 1$$ and $$2$$ are

$$1 + 2 = 3 = 3^{1} \tag{3}\label{eq3A}$$

$$2 + 3 + 4 + 5 + 6 + 7 = 27 = 3^{3} \tag{4}\label{eq4A}$$

$$5 + 6 + \ldots + 21 + 22 = 243 = 3^{5} \tag{5}\label{eq5A}$$


## Stream: Is there code for X?

### Topic: Classification of finite-dimensional vector spaces

#### Heather Macbeth (Jan 01 2021 at 16:02):

Do we have, there exists a linear equivalence between two finite_dimensional vector spaces of the same findim?

#### Johan Commelin (Jan 01 2021 at 16:03):

yes, I think Markus Himmel did that

#### Johan Commelin (Jan 01 2021 at 16:04):

I forgot the name of the result...

#### Heather Macbeth (Jan 01 2021 at 16:05):

I tried searching for linear_equiv in linear_algebra.finite_dimensional and couldn't see it.

#### Adam Topaz (Jan 01 2021 at 16:06):

This is true in general, not just for finite dimensional. Maybe that helps in finding it?

#### Johan Commelin (Jan 01 2021 at 16:06):

Is this what you want: src/linear_algebra/invariant_basis_number.lean ?

#### Johan Commelin (Jan 01 2021 at 16:07):

or is that in the wrong direction?

#### Adam Topaz (Jan 01 2021 at 16:08):

(Heather are you formalizing projective spaces? :smile: )

#### Heather Macbeth (Jan 01 2021 at 16:08):

I think it might be in the wrong direction, yes.

#### Heather Macbeth (Jan 01 2021 at 16:09):

(Heather are you formalizing projective spaces? :smile: )

#### Adam Topaz (Jan 01 2021 at 16:10):

Oh nice! I figured it was projective spaces because of the span notation we were discussing a few day ago.

#### Adam Topaz (Jan 01 2021 at 16:12):

anyway, the closest I can find so far to the problem at hand is this docs#equiv_of_is_basis

#### Heather Macbeth (Jan 01 2021 at 16:14):

That looks good, thanks! I don't understand why it's not named linear_equiv_of_is_basis, though :)

Yeah I agree.

#### Adam Topaz (Jan 01 2021 at 16:15):

docs#cardinal.eq gets you essentially all the way to what you want.

#### Adam Topaz (Jan 01 2021 at 16:16):

And this docs#is_basis.mk_eq_dim''

#### Adam Topaz (Jan 01 2021 at 16:27):

import linear_algebra
import linear_algebra.dimension

open_locale classical

universe u
variables (K : Type*) [field K] (V W : Type u)

example (cond : vector_space.dim K V = vector_space.dim K W) : nonempty (V ≃ₗ[K] W)  :=
begin
obtain ⟨B,hB⟩ := exists_is_basis K V,
obtain ⟨C,hC⟩ := exists_is_basis K W,
have h1 := is_basis.mk_eq_dim'' hB,
have h2 := is_basis.mk_eq_dim'' hC,
have h3 : cardinal.mk B = cardinal.mk C, by cc,
rw cardinal.eq at h3,
cases h3,
refine ⟨equiv_of_is_basis hB hC h3⟩,
end

#### Heather Macbeth (Jan 01 2021 at 16:28):

Wonderful! Can you PR it?

sure.

#### Adam Topaz (Jan 01 2021 at 16:29):

Which file should it go in?

#### Adam Topaz (Jan 01 2021 at 16:30):

Oh, there is one annoying thing -- to even state that the two vector spaces have the same dimension, they need to come from the same universe.

#### Heather Macbeth (Jan 01 2021 at 16:30):

I think linear_algebra.dimension

#### Heather Macbeth (Jan 01 2021 at 16:31):

Oh, there is one annoying thing -- to even state that the two vector spaces have the same dimension, they need to come from the same universe.

We just need a version for finite_dimensional and findim, that avoids all those issues.

#### Adam Topaz (Jan 01 2021 at 16:31):

You can still have finite dimensional vector spaces in different universes.

#### Adam Topaz (Jan 01 2021 at 16:32):

Oh I see what you mean.

#### Adam Topaz (Jan 01 2021 at 16:32):

The dimension would be in nat, not in cardinal

#### Adam Topaz (Jan 01 2021 at 16:48):

Okay, I pushed to this branch branch#lin_equiv_of_basis_equiv

#### Adam Topaz (Jan 01 2021 at 16:49):

Is there a finite_dimensional analogue of docs#linear_equiv.dim_eq with findim?

#### Heather Macbeth (Jan 01 2021 at 17:22):

Thanks!

Is there a finite_dimensional analogue of docs#linear_equiv.dim_eq with findim?

#### Adam Topaz (Jan 01 2021 at 17:24):

I have the finite-dimensional case essentially done too (with no universe limitations). I'll open a PR soon.

#5559

#### Patrick Massot (Jan 01 2021 at 18:39):

I'm skeptical that you really want the conclusion of the lemma to be nonempty (V ≃ₗ[K] V₂). The first thing you'll do when using the lemma will be to extract an isomorphism. Why not making it a def?

#### Patrick Massot (Jan 01 2021 at 18:42):

I'm also surprised those lemmas are no already there somehow. I would wait for @Anne Baanen to comment on this.

#### Adam Topaz (Jan 01 2021 at 18:46):

I mostly used nonempty to make it a Prop, which is useful for the if and only if statement. I can make a def to get the linear equiv as well, but I agree that we should wait for @Anne Baanen :)

#### Anne Baanen (Jan 02 2021 at 06:05):

Patrick Massot said:

I'm also surprised those lemmas are no already there somehow. I would wait for Anne Baanen to comment on this.

I don't recall seeing something like linear_equiv.of_findim_eq, only the equivalences assuming a basis, so I think this is indeed a hole in the library.

#### Anne Baanen (Jan 02 2021 at 06:18):

I mostly used nonempty to make it a Prop, which is useful for the if and only if statement. I can make a def to get the linear equiv as well, but I agree that we should wait for Anne Baanen :)
The nonempty situation as it is in the PR right now seems optimal to me: cardinal equality is expressed in nonempty, so the first result also uses nonempty and the next ones apply classical.choice :+1:


# Pr of exactly one dice showing 2

#### navi

##### New member
So I ran into this problem:

You roll two fair die. What is the probability of one of the dice showing 2 or the sum being at least 8?

I thought it should be: 15/36 for the sum being at least 8 and 10/36 for exactly one dice showing 2, but it tells me it is wrong. I got these numbers by constructing a chart that showed the outcomes of the 2 die rolls.

#### Opalg

##### MHB Oldtimer
Staff member
So I ran into this problem:

You roll two fair die. What is the probability of one of the dice showing 2 or the sum being at least 8?

I thought it should be: 15/36 for the sum being at least 8 and 10/36 for exactly one dice showing 2, but it tells me it is wrong. I got these numbers by constructing a chart that showed the outcomes of the 2 die rolls.
You have given two answers, but the question wants a single answer.

Let $A$ stand for "the sum being at least 8", and let $B$ stand for "exactly one of the dice showing 2". You have correctly found the probabilities $\def\Prob{\operatorname{Prob}\,}\Prob(A) = \frac{15}{36}$ and $\Prob(B) = \frac{10}{36}.$ But the question asks for $\Prob(A\text{ or }B)$, in other words the probability of the dice showing either $A$ or $B$ (or possibly both). For that, you need to use the formula $\Prob(A\text{ or }B) = \Prob(A) + \Prob(B) - \Prob(A\text{ and }B)$.

#### navi

##### New member
You have given two answers, but the question wants a single answer.

Let $A$ stand for "the sum being at least 8", and let $B$ stand for "exactly one of the dice showing 2". You have correctly found the probabilities $\def\Prob{\operatorname{Prob}\,}\Prob(A) = \frac{15}{36}$ and $\Prob(B) = \frac{10}{36}.$ But the question asks for $\Prob(A\text{ or }B)$, in other words the probability of the dice showing either $A$ or $B$ (or possibly both). For that, you need to use the formula $\Prob(A\text{ or }B) = \Prob(A) + \Prob(B) - \Prob(A\text{ and }B)$.
Thank you! I do not understand why you are subtracting the probability of A and B, though. Could you explain to me why?

#### Opalg

##### MHB Oldtimer
Staff member
Thank you! I do not understand why you are subtracting the probability of A and B, though. Could you explain to me why?
It's in order to avoid double counting. Specifically, if the dice show 2 and 6, then they satisfy both conditions $A$ and $B$. If you just add the probabilities for $A$ and $B$ then you will have counted that case under both headings. So you need to subtract one of them off.

#### navi

##### New member
It's in order to avoid double counting. Specifically, if the dice show 2 and 6, then they satisfy both conditions $A$ and $B$. If you just add the probabilities for $A$ and $B$ then you will have counted that case under both headings. So you need to subtract one of them off.
Okay, now I understand! I do have a follow up question, though: why would the probability of the union of A and B be 1/36 and not 2/36? Because it could be first dice 2, second dice 6 or first dice 6, second dice 2.

#### Opalg

##### MHB Oldtimer
Staff member
Okay, now I understand! I do have a follow up question, though: why would the probability of the union of A and B be 1/36 and not 2/36? Because it could be first dice 2, second dice 6 or first dice 6, second dice 2.
It should indeed be 2/36.

#### navi

##### New member
It should indeed be 2/36.
It is a WebWork problem and it accepted this as the correct answer: 10/36 + 15/36 - 1/36

#### Opalg

##### MHB Oldtimer
Staff member
It is a WebWork problem and it accepted this as the correct answer: 10/36 + 15/36 - 1/36
Here is a possible explanation for that. You entitled this thread "Pr of exactly one dice showing 2", but the statent of the problem only refers to "one of the dice showing 2". I suspect that this may be intended to cover the case when both dice show 2. In that case, the probability of that event goes up from $\frac{10}{36}$ to $\frac{11}{36}$, and the probability of "$A$ or $B$" becomes $\frac{11}{36} + \frac{15}{36} - \frac{2}{36}$, which agrees with the answer accepted by WebWork.

#### Country Boy

##### Well-known member
MHB Math Helper
By the way, your title, "Pr of one dice showing 2", should be "Pr of one die showing 2" and "you roll two fair die" should be "you roll two fair dice". "Dice" is the plural of the singular "die".

#### Wilmer

##### In Memoriam
1st roll: must be 2 or 6: probability = 2/6 = 1/3
2nd roll: must be 2 if 1st was 6, or 6 if 1st was 2: probability = 1/6

1/3 * 1/6 = 1/18


# Trick, or Indefinite Integration?

Evaluate $$\int_{0}^{\pi/2}\dfrac{\sin^6 x}{\sin x + \cos x}\text{ d}x$$

Is there a nice, elegant way of solving the above integral?

Here's what I did - Replaced $f(x)$ by $f(\pi/2-x)$, added and got rid of some common factors in numerator and denominator. This was followed by indefinite integration, and ultimately substituting the limits in the final expression.

The above method is kind of long, though - and I'm wondering if there's a quicker, shorter and rather elegant way of getting around this integral. Could someone post a solution, and share ideas?

Thanks a lot.

• Please use MathJax to format your equations so that they are searchable, rather than images. – Clarinetist Jul 2 '18 at 13:30
• If your integral is denoted by $I$, then $$2I=\int_0^{\pi/2} \frac{\sin^6 x + \cos^6 x}{\sin x + \cos x} \mathrm{d}x$$ – Crostul Jul 2 '18 at 13:43
• Did that, what's next? – arya_stark Jul 2 '18 at 13:44
• Is it true that $$8I=\int_0^{2\pi} \frac{\sin^6 x + \cos^6 x}{\sin x + \cos x} \mathrm{d}x$$ ?. I think it won't be a bad idea to use integration in the complex circle (see math.stackexchange.com/questions/308693/…) then, if it's possible. – Gonzalo Benavides Jul 2 '18 at 17:01

## 4 Answers

I have solved it first as a indefinite integral and then as a definite integral. I am not sure how different it is with yours. Good luck. Let me know if you have any questions.

A standard way for dealing with trigonometric integrals is to exploit the substitution $x=2\arctan\frac{t}{2}$.
Here it leads to $$\int_{0}^{\pi/2}\frac{\sin^6 x}{\sin x+\cos x}\,dx = 128\int_{0}^{1}\frac{t^6}{(2t+1-t^2)(t^2+1)^6}\,dt$$ and the last integral can be computed by partial fraction decomposition. It equals $$\frac{1}{8}\left(2+\sqrt{2}\,\text{arctanh}\frac{1}{\sqrt{2}}\right)\approx\frac{28}{69}.$$ This also follows from $\sin x+\cos x=\sqrt{2}\cos\left(x-\frac{\pi}{4}\right)$ and $$\int_{-\pi/4}^{\pi/4}\frac{\sin^6\left(x+\frac{\pi}{4}\right)}{\sqrt{2}\cos x}\,dx=\frac{1}{8\sqrt{2}}\sum_{k=0}^{6}\binom{6}{k}\int_{-\pi/4}^{\pi/4}\sin^k(x)\cos^{5-k}(x)\,dx$$ where the contribution provided by odd $k$s is zero and $$2\int_{0}^{\pi/4}\cos(x)^5\,dx =\frac{43}{30\sqrt{2}},\qquad 2\int_{0}^{\pi/4}\sin(x)^2\cos(x)^3\,dx =\frac{7}{30\sqrt{2}}$$ $$2\int_{0}^{\pi/4}\sin(x)^4\cos(x)^1\,dx =\frac{3}{30\sqrt{2}}$$ $$2\int_{0}^{\pi/4}\sin(x)^6\cos(x)^{-1}\,dx =-\frac{73}{30\sqrt{2}}+4\,\text{arctanh}\tan\frac{\pi}{8}.$$

Hint:

$$2I=\int_0^{\pi/2}\dfrac{\sin^6x+\cos^6x}{\sin x+\cos x}dx$$

Now $\sin^6x+\cos^6x=(\sin^2x+\cos^2x)^3-3\sin^2x\cos^2x(\sin^2x+\cos^2x)=1-3\sin^2x\cos^2x$

and $\sin^2x\cos^2x=\dfrac{\sin^22x}4=\dfrac{1-\cos4x}8$

For $J=\displaystyle\int_0^{\pi/2}\dfrac{\cos4x}{\sin x+\cos x}dx=\int_0^{\pi/2}\dfrac{\cos4x}{\sqrt2\cos\left(x-\dfrac\pi4\right)}dx,$

set $x-\dfrac\pi4=y,\cos4x=\cos4\left(y+\dfrac\pi4\right)=\cos(4y+\pi)=-\cos4y$

$\implies-\sqrt2J=\displaystyle\int_{-\pi/4}^{\pi/4}\dfrac{\cos4ydy}{\cos y}=\int_{-\pi/4}^{\pi/4}\dfrac{1-8\cos^2y+8\cos^4y}{\cos y}dy$

Now use $\cos3y=4\cos^3y-3\cos y$

Let $J$ be the integral to be calculated, we want to get the computer result, here using sage:

sage: var('x');
sage: J = integral( sin(x)^6/(sin(x)+cos(x)), x, 0, pi/2 )
sage: J
1/16*sqrt(2)*log((2*sqrt(2)) + 3) + 1/4

For this, we use the simple idea of getting a $\sin(x+\pi/4)$ (up to a multiplicative constant) in the denominator, then do trivial computations...: \begin{aligned} J &=\int _0^{\pi/2} \frac{\sin^6 x}{\sin x + \cos x}\;dx \\ &=\int _0^{\pi/2}\frac 1{\sqrt 2} \frac{\sin^6 x}{\frac 1{\sqrt 2}\left(\sin x + \cos x\right)}\;dx \\ &=\frac 1{\sqrt 2} \int _0^{\pi/2} \frac {\sin^6 x} {\sin \left(x + \frac\pi4\right)}\;dx \\ &\qquad\text{Substitution: }y = x+\frac \pi 4\ , \\ &=\frac 1{\sqrt 2} \int_{\pi/4}^{3\pi/4} \frac {\sin^6 \left(y- \frac\pi4\right)} {\sin y}\;dy \\ &=\frac 1{\sqrt 2} \int_{\pi/4}^{3\pi/4} \frac 18\cdot\frac 1{\sin y} \Big(\ \sin y-\cos y\ \Big)^6\;dy \\ &=\frac 1{\sqrt 2} \int_{\pi/4}^{3\pi/4} \frac 18\cdot\frac 1{\sin y} \Big(\ \sin^6 y -6\sin^5y\cos y +15\sin^4y\cos^2 y \\&\qquad\qquad -20\sin^3y\cos^3 y +15\sin^2y\cos^4 y -6\sin y\cos^5 y +\cos^6 y \ \Big)\;dy \\ &=\frac 1{8\sqrt 2} \int_{\pi/4}^{3\pi/4} \Big(\ \sin^5 y -6\sin^4y\cos y +15\sin^3y\cos^2 y \\&\qquad\qquad -20\sin^2y\cos^3 y +15\sin y\cos^4 y -6\cos^5 y +\frac{\cos^6 y}{\sin y} \ \Big)\;dy \\ &= \frac 1{8\sqrt 2} \int_{\pi/4}^{3\pi/4}\left[\ \begin{aligned} -(1-\cos^2y)^2 &\,\cdot\,\cos 'y \\ - 6\sin^4y &\,\cdot\,\sin'y \\ - 15(1-\cos^2y)\cos^2y &\,\cdot\,\cos'y \\ - 20\sin^2y(1-\sin^2 y) &\,\cdot\,\sin'y \\ - 15\cos^4y &\,\cdot\,\cos'y \\ - 6(1-\sin^2 y)^2 &\,\cdot\,\sin'y \\ -\frac{\cos ^6y}{1-\cos^2 y}&\,\cdot\,\cos'y \end{aligned} \ \right]\; dy \\ &= \frac 1{8\sqrt 2} \int_{\pi/4}^{3\pi/4}\left[\ \begin{aligned} -(1-\cos^2y)^2 & \\ - 15(1-\cos^2y)\cos^2y & \\ - 15\cos^4y & \\ -\frac{\cos ^6y}{1-\cos^2 y}& \end{aligned} \ \right]\,\cdot\,\cos 'y\; dy \\ &\qquad\text{because for the \sin'y-terms we have \sin(\pi/4)=\sin(3\pi/4)...} \\ &\qquad\text{Substitution: }u=\cos t\ ,\ du=\cos't\, dt\ , \\ &= \frac 1{8\sqrt 2} \int_{-1/\sqrt2}^{1/\sqrt2}\left[\ (1-u^2)^2 +15(1-u^2)u^2 +15u^4 +\frac {u^6-1+1}{1-u^2} \right] \; du \\ &= \frac 1{4\sqrt 2} \int_0^{1/\sqrt2}\left[\ (1-u^2)^2 +15(1-u^2)u^2 +15u^4 -(1+u^2+u^4) +\frac {1}{1-u^2} \right] \; du \\ &= \frac 1{4\sqrt 2} \int_0^{1/\sqrt2}\left[\ 12u^2 +\frac {1}{1-u^2} \right] \; du \\ &= \frac 1{4\sqrt 2} \left[\ 4\left(\frac 1{\sqrt2}\right)^3 +\frac 12\log \frac{1+\frac 1{\sqrt 2}}{1-\frac 1{\sqrt 2}} \ \right] \\ &= \frac 14 + \frac 1{4\sqrt 2}\log(\sqrt2+1)) \ . \end{aligned}


# What is $\lim_{x\to\infty} \sin x$?

What is

$$\lim_{x\to\infty} \sin x$$

?

I always thought it was undefined; however, Wolfram|Alpha says that

$$\lim_{x\to\infty} \sin x = -1 \text{ to } 1$$

Now, what is the correct answer? What does it even mean if the limit is not a single, distinct value, but rather an interval?

Other than that, am I right in assuming that

$$\liminf_{x\to\infty} \sin x = -1$$

and

$$\limsup_{x\to\infty} \sin x = 1$$ ?

• They mean that the values of $\sin(x)$ for $x\to+\infty$ accumulate to every value in $[-1,1]$. In particular, that implies the $\limsup$, $\liminf$ equations that you wrote, and that in the context of an introduction to calculus, the limit doesn't exist. – user561348 May 24 '18 at 12:37
• @arugula so is it in fact undefined? – user500664 May 24 '18 at 12:37
• Who knows what Alpha means, but I guess you could interpret it as "for every point $p$ between -1 and 1, there's a sequence tending to infinity, such that $\sin$ of that sequence is constantly $p$". And yes you're right about the sup and inf limits. – Steve D May 24 '18 at 12:38
• To find what Wolfram Alpha means may be difficult? But presumably this is the same answer as Mathematica itself, which does have extensive documentation you can look at. – GEdgar May 24 '18 at 12:45

Take note that the sine function takes values between $-1$ and $1$. When you are talking about a limit to $\infty$, it's an undetermined number, which is infinitely large. Now, taking into account the periodicity of the sine function, there is no possible way to determine a specific value, as it entirely depends on the nature of the "infinite" number.

More specifically, $-1 \leq \sin(x) \leq 1, \; \; \forall x \in \mathbb R$. This means that for any given $x$ over the real numbers, the sine function is bounded. Thus, all you can say about an undetermined infinite limit (it does not exist talking strictly mathematics), is :

$$-1 \leq \lim_{x \to \infty} \sin(x) \leq 1$$

What you mentioned though is indeed true :

$$\liminf_{x\to\infty} \sin x = -1$$

$$\limsup_{x\to\infty} \sin x = 1$$

• So it can be understood as "the limit doesn't exist, but if it existed it would be between -1 and 1", right? – user500664 May 24 '18 at 12:42
• Essentially, yes. The limit does not exist, but it surely is bounded. – Rebellos May 24 '18 at 12:43
• alright, thank you. I will accept your answer as soon as it will let me. – user500664 May 24 '18 at 12:43

The limit doesn't exist and it can be proved formally by 2 subsequences with different limits, that is

• $x_n=2n\pi+\frac{\pi}2 \to \infty \implies \sin(x_n)=1$

• $x_n=2n\pi+\frac{3\pi}2 \to \infty \implies \sin(x_n)=-1$

Yes what is true is that $\liminf=-1$ and $\limsup=1$ indeed

$$-1\le\sin x \le 1$$

and we have found 2 subsequences which tends to those limits.

• Thank you for the proof as well. Your answer is very good, but I promised Rebellos to accept his answer earlier, so I am sorry. Thank you very much though. – user500664 May 24 '18 at 12:55
• @ThomasFlinkow You are welcome! The choice of the answer to be accepted is absolutely up to you! Bye – user May 24 '18 at 13:05


# Calculating a Cumulative Distribution Function (CDF)

Let $Z$ be a continuous random variable with probability density function:

$$f_Z(z) = \begin{cases} \gamma(1 + z^2) & \mbox{ if } -2 < z < 1, \\ 0 & \mbox{ otherwise} \end{cases}$$

a) For what $γ$ is this possible?
b) Find the cumulative distribution function of $Z$.

• For question a do you know what a probability distribution is and the requirements? for question b do you know what a cumulative distribution is and the integral/summation involved? – Chinny84 Dec 14 '16 at 15:47
• I know that to solve part b I need to solve the integral from negative infinity to z of fZ(z), but I don't know how to solve part a, which is why I am stuck. – Monil Dec 14 '16 at 15:53
• Hint: which value should the integral of the PDF have over all domain? – Jesús Ros Dec 14 '16 at 15:55
• I'm sorry, I still don't understand how to do it. – Monil Dec 14 '16 at 16:02
• If $f_Z(z)$ is a PDF, which is the value of $P[-\infty<z<\infty]=\int_{-\infty}^{\infty}f_Z(z)dz$? Or in other words, which is the probability that $z$ lies between $(-\infty,\infty)$? – Jesús Ros Dec 14 '16 at 16:04

$a)$ $$\int_{-∞}^∞\ f_Z(z)\ dz\ = 1$$ $$\int_{-2}^1\ γ(1 + z^2)\ dz= 1$$ $$γ(z + \frac{z^3}3)\ |_{-2}^1\ = 1$$ $$γ\ = \frac16$$
$b)$ $$F_Z(z)\ =\ \int_{-2}^z\ f_Z(z)\ dz$$ $$F_Z(z) = \int_{-2}^z\ \frac16(1 + z^2)\ dz$$ $$F_Z(z) = \frac16(z + \frac{z^3}3) |_{-2}^z$$ $$F_Z(z) = \frac16[(z + 2) + (\frac{z^3 + 8}3)]$$
• Notice that $F_Z(-2) = 0$ and $F_Z(1) = 1.$ That's as it must be. Do you you understand why I made sure of that? Guessing that you do. (+1) – BruceET Dec 15 '16 at 6:44