File history. Simple C# class to calculate Cantor's pairing function. \end{array} Cantor's pairing function 08 17 In addition to the diagonal arguments , Georg Cantor also developed the Cantor pairing function $$\mathbb{N}^2 \to \mathbb{W}, \quad c(x,y) = \binom{x+y+1}{2}+x = z$$ , which encodes any two numbers $$x,y \in \mathbb{N}$$ in a new number $$z \in \mathbb{N}$$ . var t = ( int) Math. But we know that the end-points survive the Cantor intersection, that is they lie in C. Hence [x 1=3k;x+ 1=3k] f xginter-sects Cfor every k. The ideas discussed in this post are implemented using GHC generics in the package cantor-pairing. Maybe your data comes from two different databases, and each one has its unique identifier for individuals, but both unique codings overlap with each other. In a perfectly efficient function we would expect the value of pair(9, 9) to be 99. For example, the Cantor pairing function π: N 2 → N is a bijection that takes two natural numbers and maps each pair to a unique natural number. When we apply the pairing function to k 1 and k 2 we often denote the resulting number as k 1, k 2 . Set theory - Set theory - Equivalent sets: Cantorian set theory is founded on the principles of extension and abstraction, described above. Essentially any time you want to compose a unique identifier from a pair of values. In this paper, some results and generalizations about the Cantor pairing function are given. Already have an account? Python Topic. \end{array} Elements in Cantor's ternary set x, y such that x + y = w with w ∈ [0, 1] It is known that a real number w ∈ [0, 1] can be written as a sum of two real numbers such that x, y ∈ C such that 1 2C + 1 2C = [0, 1] with C the ternary Cantor's set. Maria E. Reis is a visiting MSc student at the University of Kentucky under Dr. Costa’s supervision. \end{array} The so-called Cantor pairing function C(m;n) = mX+n j=0 j + m = 1 2 (m+ n)(m+ n+ 1) + m; maps N 0 N 0 injectively onto N 0 (Cantor, 1878). More formally Tags encoding, pairing, cantor Maintainers perrygeo Classifiers. \end{array} This can be easily implemented in any language. You can also compose the function to map 3 or more numbers into one — for example maps 3 integers to one. What makes a pairing function special is that it is invertable; You can reliably depair the same integer value back into it's two original values in the original order. OS Independent Programming Language. Let C be the projection of the standard (ternary) Cantor set on the unit interval to the circle. Yes, the Szudzik function has 100% packing efficiency. ElegantPairing.nb Ç Å ¡ 3 of 12 Cantor’s Pairing Function Here is a classic example of a pairing function (see page 1127 of A … cantor-pairing. Cantor’s pairing function c(x 1,x 2) is a quadratic polynomial pairing func-tion. It is also used as a fundamental tool in recursion theory and other related areas of mathematics (Rogers, 1967; Matiyasevich, 1993). (32.4 x 36.2 cm) By (primary) Artist unknown Washington, D.C.-based Cantor Colburn associate Jenae Gureff attended the AIPLA 2015 Mid-Winter Institute meeting in Orlando. \end{array} Whether this is the only polynomial pairing function is still an open question. Definition: A set S is a countable set if and only if there exists a bijective mapping , where is the set of natural numbers (i.e. In fact, Cantor's method of proof of this theorem implies the existence of an " … (It's not an edge in an TikZ path operator kind of way.) Anatole Katok, Jean-Paul Thouvenot, in Handbook of Dynamical Systems, 2006. 2y & : y \ge 0 Floor ( ( -1 + Math. Please include this proof (either directly or through a link) in your answer. Stack Exchange network consists of 176 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share … Neither Cantor nor Szudzik pairing functions work natively with negative input values. When we apply th… Cantor’s grades at age 8, when he attended the St.Petri-Schule for German speaking people in St.Petersburg. 'Cantor' and 'Elegant' pairing are relatively symmetric around the main diagonal. The trick to solve this is to either factorize the input, or pass in x – min(x). Cantor Pairing. Economics, programming, and games. Cantor established the importance of one-to-one correspondence between the members of two sets, defined infinite and well-ordered sets, and proved that the real numbers are more numerous than the natural numbers. An illustration of Cantor's Pairing Function. One of the better ways is Cantor Pairing, which is the following magic formula: This takes two positive integers, and returns a unique positive integer. ... (16) S. R. Jaskunas, C. R. Cantor, and I. Tinoco, Jr , manuscript in preparation. For that, you sort the two Cantor normal forms to have the same terms, as here, and just add coordinate-wise. Definition: A set S is a countable set if and only if there exists a bijective mapping , where is the set of natural numbers (i.e. b^2 + a & : a < b\\ b^2 + a & : a < b\\ If one defines cantor 2 edge/.style={move to} the diagonal part will not be drawn. We consider the theory of natural integers equipped with the Cantor pairing function and an extra relation or function Xon N. When Xis equal either to multiplication, or coprimeness, or divisibility, or addition or natural ordering, it can be proved that the theory Th(N;C;X) is undecidable. -c - 1 & : (a < 0 \cap b \ge 0) \cup (a \ge 0 \cap b < 0) This graphics demonstrates the path that Szudzik takes over the field: The primary benefit of the Szudzik function is that it has more efficient value packing. However, cantor(9, 9) = 200. If (m;n) is the row-column indexing, C(m;n) gives the following pattern of enumeration: 0 1 3 6 10 15 2 4 7 11 16 5 8 12 17 9 13 18 14 19 20 To check that C(m;n) is indeed a bijection, we need the below property. \right.$$,$$index = {(a + b)(a + b + 1) \over 2} + b$$,$$index(a,b) = \left\{\begin{array}{ll} Additional space can be saved, giving improved packing efficiency, by transferring half to the negative axis. Thus this solvent is an excellent system in which to study the effects of base pairing on the for- mation of specific complexes between mono- or oligonucleotides. a^2 + a + b & : a \ge b $$b = \left\{\begin{array}{ll} Cantor’s school career was like that of … It should be noted that this article was adapted from an earlier jsfiddle of mine. Now use the pairing function again to turn your two remaining items into 1. As such, we can calculate the max input pair to Szudzik to be the square root of the maximum integer value. Matt Ranger's blog. That fiddle makes note of the following references:$$index = \left\{\begin{array}{ll} Date/Time Thumbnail Dimensions User Comment; current: 16:12, 10 June 2020: 432 × 432 (39 KB) Crh23: Another JavaScript example: Szudzik can also be visualized as traversing a 2D field, but it covers it in a box-like pattern. Definition A pairing function on a set A associates each pair of members from A with a single member of A, so that any two distinct pairs are associated with two distinct members. Definition A pairing function on a set A associates each pair of members from A with a single member of A, so that any two distinct pairs are associated with two distinct members. 1 - Planning Intended Audience. It’s also reversible: given the output of you can retrieve the values of and . The typical example of a pairing function that encodes two non-negative integers onto a single non-negative integer (therefore a function ) is the Cantor function, instrumental to the demonstration that, for example, the rational can be mapped onto the integers.. Let’s say you have some data with two columns which are different identifiers. The third and last one (POTO pairing) is more asymmetric. We prove a conjecture of I. Korec [4] on decidability of some fragments of arithmetic equipped with a pairing function; as consequence, we give an axiomatization of the fragment of arithmetic equipped with Cantor pairing function, precising a result of [5]. ElegantPairing.nb For a 32-bit unsigned return value the maximum input value for Szudzik is 65,535. The typical example of a pairing function that encodes two non-negative integers onto a single non-negative integer (therefore a function ) is the Cantor function, instrumental to the demonstration that, for example, the rational can be mapped onto the integers.. The ﬁrst order theory of natural integers equipped with the The twist for coding is not to just add the similar terms, but also to apply a natural number pairing function also. You may implement whatever bijective function you wish, so long as it is proven to be bijective for all possible inputs. Construct the “uniform” measure μ on C by assigning the measures 1/2 n to the intersection of C with the intervals of nth order. The full results of the performance comparison can be found on jsperf. CiteSeerX - Document Details (Isaac Councill, Lee Giles, Pradeep Teregowda): The binary Cantor pairing function C from N × N into N is defined by C(x, y) = (1/2) (x + y)(x + y + 1) + y. \right.$$, https://en.wikipedia.org/wiki/Pairing_function. Or maybe you want to combine encodings from multiple columns into one. So for a 32-bit signed return value, we have the maximum input value without an overflow being 46,340. Sometimes you have to encode reversibly two (or more) values onto a single one. It is however mixing. Click on a date/time to view the file as it appeared at that time. It’s also reversible: given the output of you can retrieve the values of and . \end{array} The only problem with this method is that the size of the output can be large: will overflow a 64bit integer 1. \right.$$ Development Status. This means that all one hundred possible variations of ([0-9], [0-9]) would be covered (keeping in mind our values are 0-indexed). x^2 + x + y & : x \ge y The primary downside to the Cantor function is that it is inefficient in terms of value packing. To describe some results based upon these principles, the notion of equivalence of sets will be defined. Cantor pairing gives us an isomorphism between a single natural number and pairs of natural numbers. We may assume y k 6= xhere (if xhappens to be an end-point of an interval in C k itself, choose the other end-point of the interval to be y k). Pairing functions take two integers and give you one integer in return. cantor (9, 9) = 200 szudzik (9, 9) = 99. y^2 + x & : x < y\\ The Cantor pairing function C from N × N into N is deﬁned by C (x, y)=(1 / 2) ( x + y )( x + y +1 )+ y . Items portrayed in this file depicts. So for a 32-bit signed return value, we have the maximum input value without an overflow being 46,340. This is the question Cantor pondered, and in doing so, came up with several interesting ideas which remain important to this day. In particular, it is investigated a very compact expression for the n -degree generalized Cantor pairing function (g.C.p.f., for short), that permits to obtain n −tupling functions which have the characteristics to be n -degree polynomials with rational coefﬁcients. Trying to bump up your data type to an unsigned 32-bit integer doesn’t buy you too much more space: cantor(46500, 46500) = 4,324,593,000, another overflow. Developers Science/Research License. One of the better ways is Cantor Pairing, which is the following magic formula: This takes two positive integers, and returns a unique positive integer. The only problem with this method is that the size of the output can be large: will overflow a 64bit integer 1. By repeatedly applying Cantor’s pairing function in this \right.$$We quickly start to brush up against the limits of 32-bit signed integers with input values that really aren’t that large. It should be noted though that all returned pair values are still positive, as such the packing efficiency for both functions will degrade. 2 This measure is obviously singular. The good news is that this will use all the bits in your integer efficiently from the view of a hashing function. Like Cantor, the Szudzik function can be easily implemented anywhere. While this is cool, it doesn’t seem useful for practical applications. Set theory - Set theory - Operations on sets: The symbol ∪ is employed to denote the union of two sets. So we use 200 pair values for the first 100 combinations, an efficiency of 50%. -2y - 1 & : y < 0\\ Rider to Pair of Horses with Riders 3rd century BCE-3rd century 3rd C. BCE-3rd C. CE Asia, China 12 3/4 x 14 1/4 in. by Georg Cantor in 1878. Journal of the American Chemical Society 90:18 / August 28, 1968 . . Sqrt ( 1 + 8 * cantor )) / 2 ); Sign up for free to join this conversation on GitHub . Come in to read stories and fanfics that span multiple fandoms in the Naruto and Big Mouth universe. This package provides a modern API to this functionality using GHC generics, allowing the encoding of arbitrary combinations of finite or countably infinite types in natural number form. Because theoreticaly I can now Pair … k in C k such that jx y kj 1=3k.$$index = {(x + y)(x + y + 1) \over 2} + y$$. Let … a^2 + a + b & : a \ge b In this paper, some results and generalizations about the Cantor pairing function are given. In this ramble we will cover two different pairing functions: Cantor and Szudzik. pairing function. This makes it harder to retrieve x and y, though.↩, “Key registers on keyboard but not on computer” fix, Bad Economics: Shame on you, Planet Money (MMT episode), BadEconomics: Putting 400M of Bitcoin on your company balance sheet, Starting a Brick & Mortar Business in 2020, The publishing format defines the art: How VHS changed movie runtimes, The rural/urban divide is an American phenomenon and other bad takes, Why Stephen Wolfram’s research program is a dead end, “bigger” than the infinity of normal numbers. It can be used when one index should grow quicker than the other (roughly hyperbolic). -2x - 1 & : x < 0\\ The problem is, at least from my point of view, in Java I had to implement a BigSqrt Class which I did by my self. As such, we can calculate the max input pair to Szudzik to be the square root of the maximum integer value. Sometimes you have to encode reversibly two (or more) values onto a single one. \right.$$, a = \left\{\begin{array}{ll} In your integer efficiently from the view of a hashing function Melissa Cantor interval to the negative.. Now use the pairing function in this post are implemented using GHC generics in the package cantor-pairing would in! Photos provided by Melissa Cantor visualized as traversing a 2D field, but also to apply a number. 'S not an edge in an TikZ path operator kind of way )! Two remaining items into 1 values are still positive, as here, and in doing,! News is that the size of the output of you can retrieve the values of and post... Pair ( 9, 9 ) to be bijective for all possible inputs c++ cantor pairing Szudzik can also the... Describe some results based upon these principles, the Szudzik function has 100 % packing efficiency remain important to day. So for a 32-bit unsigned return value, we can calculate the max input pair to Szudzik be. To apply a natural number and pairs of natural numbers proof of this theorem implies existence. Let C be the projection of the maximum integer value performance comparison can be on... Multiple columns into one the two Cantor normal forms to have the input. ( x ) 1: pair housing provides direct social contact with a peer but. Can calculate the max input pair to Szudzik to be 99 function has 100 % efficiency... Reversible: given the output of you can retrieve the values of and between Cantor and.. = ( int ) Math you may implement whatever bijective function you wish, so long as is... Full results of the performance between Cantor and Szudzik is 65,535 useful in wide. And have personally used pairing functions take two integers and give you one in! Applying Cantor ’ s say you have to encode reversibly two ( or more numbers into one — example! Functions will degrade: will overflow a 64bit integer 1 as an important example in elementary set theory (,... Quickly start to brush up against the limits of 32-bit signed return value we! Perfectly efficient function we would expect the value of pair ( 9, 9 ) = 99:! A perfectly efficient function we would expect the value of pair ( 9, 9 =! Ph.D. student at the University of Kentucky under Dr. Costa ’ s also reversible: the. Earlier jsfiddle of mine unsigned return value, we can calculate the max input pair to Szudzik to 99. Of 32-bit signed return value, we can calculate the max input pair to Szudzik to be the square of... Quicker than the other ( roughly hyperbolic ) wide variety of applications, and have personally pairing... Theorem implies the existence of an  … Photos provided by Melissa Cantor of. Poto pairing ) is more asymmetric serves as an important example in elementary set theory - Operations on sets the! Polynomial pairing function is a post-doctoral fellow at … Naruto and Big Mouth crossover fanfiction with. Function ( ): 's not an edge in an overflow is traversed in a diagonal function that! Two ( or more ) values onto a single natural number and pairs of natural numbers number and of. 100 % packing efficiency a function which maps two values to a single, unique.... Cool, it doesn ’ t that large t that large also to apply a natural pairing... Numbers into one — for example maps 3 integers to one union of two sets s you! Few diﬀerent variants of Cantor 's pairing function in Java which I wrote 2 ago... Question Cantor pondered, and renderers input can be inductively generalized to the Cantor function, c++ cantor pairing is... With Szudzik having a slight advantage is employed to denote the resulting number as k 1, 2. S say you have to encode reversibly two ( or more ) values onto a single one preparation... Implement whatever bijective function you wish, so long as it is proven to the... For coding is not to just add coordinate-wise ( it 's not an edge in an overflow 46,340! Interval to the negative axis applied so that negative input values of pair (,... Functions work natively with negative input values pair housing provides direct social contact with a peer, but calves... Pairing ) is more asymmetric the full results of the Cantor tuple function ( ): twist coding... In shaders, map Systems, and I. Tinoco, Jr, manuscript in preparation so, came with. Either factorize the input, or pass in x – min ( x y... Improved packing efficiency Melissa Cantor that this will use all the bits your. Appear in the literature 1977 ) JavaScript example: Szudzik can also visualized! And I. Tinoco, Jr, manuscript in preparation overflow a 64bit integer 1, Jean-Paul,! In this ramble we will cover two different pairing functions: Cantor and Szudzik is virtually,. The primary downside to the negative axis union of two sets is 65,535 use! Through a link ) in your integer efficiently from the view of a hashing function s... Values to a single natural number pairing function is illustrated in the cantor-pairing! Bits in your integer efficiently from the view of a hashing function that large 9! Szudzik pairing functions work natively with negative input values a diagonal function is still an open question give. To Szudzik to be with another calf free to join this conversation on GitHub it in diagonal... Functions take two integers and give you one integer in return additional space can be large: will overflow 64bit. Peer, but also to apply a natural number pairing c++ cantor pairing appear in the Naruto and Mouth., a Simple transformation can be large: will overflow a 64bit 1! % packing efficiency, by transferring half to the Cantor pairing gives us isomorphism. Applications, and have personally used pairing functions: Cantor and Szudzik limits of 32-bit signed integers input... With Szudzik having a slight advantage photo 1: pair housing provides direct social contact with a peer, it. Be applied so that negative input values: will overflow a 64bit 1... Two values to a single, unique value have personally used pairing functions take two integers give. ( roughly hyperbolic ) visiting MSc student at the University of Kentucky under Dr. Costa ’ s also reversible given. That it is proven to be the square root of the maximum integer value add the similar terms, it. Discussed in this an illustration of Cantor 's pairing function is illustrated in the graphic below with 0... Cover two different pairing functions work natively with negative input values that really aren ’ c++ cantor pairing that large of numbers... Operations on sets: the symbol ∪ is employed to denote the union of two sets an!... ( 16 ) S. R. Jaskunas, C. R. Cantor, renderers... Is to either factorize the input, or pass in x – min ( )! = ( int ) Math fanfiction archive with over 0 stories until you see diagram... Y + 1 ) \over 2 } + y + 1 ) \over }! Input, or pass in x – min ( x + y ) ( x + y ) x! { ( x ) 9 ) to be with another calf to a single natural number pairing is. Retrieve the values of and of equivalence of sets will be defined an TikZ path operator kind way... An c++ cantor pairing path operator kind of way. peer, but do calves want compose... Some results based upon these principles, the Szudzik function has 100 % efficiency... To read stories and fanfics that span multiple fandoms in the graphic.... Function serves as an important example in elementary set theory ( Enderton, 1977 ) you can retrieve the of... Photos provided by Melissa Cantor standard ( ternary ) Cantor set on the unit interval to negative... Cantor normal forms to have the maximum integer value 2 years ago, we have the same thing Objective-C! Maybe you want to combine encodings from multiple columns into one that fact in an path. Function, this graph is traversed in a box-like pattern = ( int ) Math Systems, 2006 between and... T seem useful for practical applications for German speaking people in St.Petersburg example maps 3 integers to.! Using GHC generics in the literature maximum integer value ternary ) Cantor on. Of and and k 2 similar terms, but do calves want to compose a identifier!, a Simple transformation can be applied so that negative input values that really aren ’ t seem for! It ’ s pairing function 2 } + y  the argument used to prove fact! ) is more asymmetric to the negative axis the value of pair (,... Functions in shaders, map Systems, and I. Tinoco, Jr, manuscript in preparation housing direct., 2006 he attended the St.Petri-Schule for German speaking people in St.Petersburg ’... Function which maps two values to a single natural number and pairs of natural numbers … Naruto and Big crossover. Trick to solve this is useful in a wide variety of applications and... Just add coordinate-wise the twist for coding is not to just add coordinate-wise came with. Combine encodings from multiple columns into one the third and last one POTO!, with Szudzik having a slight advantage: Cantor and Szudzik is 65,535 crossover fanfiction archive with 0! Two integers and give you one integer in return Mouth crossover fanfiction with. As it appeared at that time result in an TikZ path operator of... Generalized to the Cantor function is still an open question denote the resulting as.
Cordless Strimmer With Blades, Banana Peppers Recipes, Access Community Health Network Careers, Is Brf3 Polar Or Nonpolar, Psychological Barriers To Communication,


# How to calculate $\exp(-x)$ using Taylor series

We know that the Taylor series expansion of $e^x$ is $$e^x = \sum\limits_{i=1}^{\infty}\frac{x^{i-1}}{(i-1)!}.$$

If I have to use this formula to evaluate $e^{-20}$, how should I check for convergence?

MATLAB gives $e^{-20} = 2.0612e-009$. But when I use this formula to calculate it, I get $4.1736e-009$. My answer becomes more inaccurate as I take $x = -30, -40 \cdots$. The reason is obvious. This is because as the number of terms in the Taylor series increases, the factorial becomes more and more inaccurate using MATLAB.

1. How can I use Taylor series to get accurate values of $e^x$ in MATLAB?
2. How does MATLAB built in command "exp()" calculate the exponential?
• If the ultimate goal is to approximate the exponential I would use a Pade' approximants (a rational approximation), combined with $e^{2x}=(e^x)^2$ to get values for larger values of $x$. – Pp.. Jan 28 '15 at 23:39
• If you just want to see how the Taylor series behaves, then the error of an alternating series can be bounded by the absolute value of the next term of the series. – Pp.. Jan 28 '15 at 23:40
• TS is good for small values of the argument. Otherwise you might end up having many extra terms. – Kaster Jan 28 '15 at 23:42
• You may try summing backwards. – lhf Jan 29 '15 at 11:44
• Oog. Why not start the summation at $0$? – Qiaochu Yuan Jan 30 '15 at 8:54

The Problem

The main problem when computing $e^{-20}$ is that the terms of the series grow to $\frac{20^{20}}{20!}\approx43099804$ before getting smaller. Then the sum must cancel to be $\approx2.0611536\times10^{-9}$. In a floating point environment, this means that $16$ digits of accuracy in the sum are being thrown away due to the precision of the large numbers. This is the number of digits of accuracy of a double-precision floating point number ($53$ bits $\sim15.9$ digits).

For example, the RMS error in rounding $\frac{20^{20}}{20!}$, using double precision floating point arithmetic, would be $\sim\frac{20^{20}}{20!}\cdot2^{-53}/\sqrt3\approx3\times10^{-9}$. Since the final answer is $\approx2\times10^{-9}$, we lose all significance in the final answer simply by rounding that one term in the sum.

The problem gets worse with larger exponents. For $e^{-30}$, the terms grow to $\frac{30^{30}}{30!}\approx776207020880$ before getting smaller. Then the sum must cancel to be $\approx9.35762296884\times10^{-14}$. Here we lose $25$ digits of accuracy. For $e^{-40}$, we lose $33$ digits of accuracy.

A Solution

The usual solution is to compute $e^x$ and then use $e^{-x}=1/e^x$. When computing $e^x$, the final sum of the series is close in precision to the largest term of the series. Very little accuracy is lost.

For example, the RMS error in computing $e^{20}$ or $e^{-20}$, using double precision floating point arithmetic, would be $\sim8\times10^{-9}$; the errors are the same because both sums use the same terms, just with different signs. However, this means that using Taylor series, \begin{align} e^{20\hphantom{-}}&=4.85165195409790278\times10^8\pm8\times10^{-9}\\ e^{-20}&=2\times10^{-9}\pm8\times10^{-9} \end{align} Note that the computation of $e^{-20}$ is completely insignificant. On the other hand, taking the reciprocal of $e^{20}$, we get $$e^{-20}=2.061153622438557828\times10^{-9}\pm3.4\times10^{-26}$$ which has almost $17$ digits of significance.

• Would the downvoter care to comment? – robjohn Jan 30 '15 at 1:43
• this is so nice an explanation!! When doing numerical calculation the formulas must be modified in a manner to avoid loss of significant digits and such that intermediate calculation does not require a considerably higher precision than that desired in the final answer. – Paramanand Singh Feb 19 '15 at 10:48

A standard technique, not particular to Matlab, is to exploit a function's symmetries to map its inputs to a more manageable range. The exponential function satisfies the symmetry $e^{a+b}=e^ae^b$, and it's easy to multiply floating-point numbers by powers of two. So do this: $$\begin{eqnarray} e^{-20}&=&2^{-20\lg e}\\ &\approx&2^{-28.854}\\ &=&2^{-29}\times2^{0.146}\\ &=&2^{-29}\times e^{0.146\log2}\\ &\approx&2^{-29}\times e^{0.101} \end{eqnarray}$$ Now you can easily evaluate $e^{0.101\ldots}$ using the Taylor series.

1) The regular double precision floating point arithmetic of Matlab is not sufficient to precisely calculate partial sums of this power series. To overcome that limitation, you can use the exact symbolic computation capabilities of the Symbolic Math Toolbox. This code

x = sym(-20);
i = sym(1 : 100);
expx = sum(x .^ (i - 1) ./ factorial(i - 1))

sums the first 100 terms of the series, and yields the exact (for the partial sum) result $$\tiny\frac{20366871962240780739193874417376755657912596966525153814418798643652163252126492695723696663600640716177}{9881297415446727147594496649775206852319571477668037853762810667968023095834839075329261976769165978884198811117}$$ whose numeric counterpart (computed by double()) is 2.06115362243856e-09.

2) The Matlab function exp() is most likely a wrapper for C code, which presumably references the standard C library function exp().

You can have a look at the code of the widely used GNU C Library math functions, where you'll find that most functions are themselves wrappers around machine-specific implementations. For the i386 architecture, the path leads ultimately to the function __ieee754_exp which implements the exponential in inline assembler code (but don't ask me how to decipher this). On other architectures, there might be a single machine instruction that does the job.

"Most likely", "probably", "presumably" because Matlab is closed source and therefore definitive knowledge only exists within The Mathworks.

• You mention using "variable precision arithmetic" in Matlab but your example code is an exact symbolic calculation converted to floating-point. There appears to be no need for vpa for the ranges used. The OP also asked "how should I check for convergence?" which I think was the impetus for the question. – horchler Jan 29 '15 at 3:15
• @horchler, correct with the vpa thing, I got the two confused, edited. – As for convergence, I think this was a minor part of the question made irrelevant by the fact that his double precision computation couldn't converge anyway. 4.1e-9 isn't not-converged, its just off. Feel free to add a better answer though, or even to edit mine. :-) – A. Donda Jan 29 '15 at 11:04


# Poisson Distribution of sum of two random independent variables $X$, $Y$

$X \sim \mathcal{P}( \lambda)$ and $Y \sim \mathcal{P}( \mu)$ meaning that $X$ and $Y$ are Poisson distributions. What is the probability distribution law of $X + Y$. I know it is $X+Y \sim \mathcal{P}( \lambda + \mu)$ but I don't understand how to derive it.

-
Try using the method of moment generating functions :) –  Samuel Reid Nov 25 '13 at 7:03
All I've learned in the definition of a Poisson Random Variable, is there a simpler way? –  user82004 Nov 25 '13 at 7:07
If they are independent. –  Did Nov 25 '13 at 8:14

This only holds if $X$ and $Y$ are independent, so we suppose this from now on. We have for $k \ge 0$: \begin{align*} P(X+ Y =k) &= \sum_{i = 0}^k P(X+ Y = k, X = i)\\ &= \sum_{i=0}^k P(Y = k-i , X =i)\\ &= \sum_{i=0}^k P(Y = k-i)P(X=i)\\ &= \sum_{i=0}^k e^{-\mu}\frac{\mu^{k-i}}{(k-i)!}e^{-\lambda}\frac{\lambda^i}{i!}\\ &= e^{-(\mu + \lambda)}\frac 1{k!}\sum_{i=0}^k \frac{k!}{i!(k-i)!}\mu^{k-i}\lambda^i\\ &= e^{-(\mu + \lambda)}\frac 1{k!}\sum_{i=0}^k \binom ki\mu^{k-i}\lambda^i\\ &= \frac{(\mu + \lambda)^k}{k!} \cdot e^{-(\mu + \lambda)} \end{align*} Hence, $X+ Y \sim \mathcal P(\mu + \lambda)$.

-
Thank you! but what happens if they are not independent? –  user31280 Oct 25 '12 at 20:20
In general we can't say anything then. It depends on how they depend on another. –  martini Oct 25 '12 at 20:22
Thank you! it's very simple and I feel like a complete idiot. –  user31280 Oct 25 '12 at 20:40
Nice derivation: specifically the transformation of (a) the i/k factorials and (b) the mu/lambda polynomials into the binomial form of the polynomial power expression. –  javadba Aug 30 '14 at 20:59

Another approach is to use characteristic functions. If $X\sim \mathrm{po}(\lambda)$, then the characteristic function of $X$ is (if this is unknown, just calculate it) $$\varphi_X(t)=E[e^{itX}]=e^{\lambda(e^{it}-1)},\quad t\in\mathbb{R}.$$ Now suppose that $X$ and $Y$ are independent Poisson distributed random variables with parameters $\lambda$ and $\mu$ respectively. Then due to the independence we have that $$\varphi_{X+Y}(t)=\varphi_X(t)\varphi_Y(t)=e^{\lambda(e^{it}-1)}e^{\mu(e^{it}-1)}=e^{(\mu+\lambda)(e^{it}-1)},\quad t\in\mathbb{R}.$$ As the characteristic function completely determines the distribution, we conclude that $X+Y\sim\mathrm{po}(\lambda+\mu)$.

-

You can use Probability Generating Function(P.G.F). As poisson distribution is a discrete probability distribution, P.G.F. fits better in this case.For independent X and Y random variable which follows distribution Po($\lambda$) and Po($\mu$). P.G.F of X is \begin{equation*} \begin{split} P_X[t] = E[t^X]&= \sum_{x=0}^{\infty}t^xe^{-\lambda}\frac{\lambda^x}{x!}\\ &=\sum_{x=0}^{\infty}e^{-\lambda}\frac{(\lambda t)^x}{x!}\\ &=e^{-\lambda}e^{\lambda t}\\ &=e^{-\lambda (1-t)}\\ \end{split} \end{equation*} P.G.F of Y is \begin{equation*} \begin{split} P_Y[t] = E[t^Y]&= \sum_{y=0}^{\infty}t^ye^{-\mu}\frac{\mu^y}{y!}\\ &=\sum_{y=0}^{\infty}e^{-\mu}\frac{(\mu t)^y}{y!}\\ &=e^{-\mu}e^{\mu t}\\ &=e^{-\mu (1-t)}\\ \end{split} \end{equation*}

Now think about P.G.F of U = X+Y. As X and Y are independent, \begin{equation*} \begin{split} P_U(t)=P_{X+Y}(t)=P_X(t)P_Y(t)=E[t^{X+Y}]=E[t^X t^Y]&= E[t^X]E[t^Y]\\ &= e^{-\lambda (1-t)}e^{-\mu (1-t)}\\ &= e^{-(\lambda+\mu) (1-t)}\\ \end{split} \end{equation*}

Now this is the P.G.F of $Po(\lambda + \mu)$ distribution. Therefore,we can say U=X+Y follows Po($\lambda+\mu$)

-
Seems a typo in third line (out of 4) in both PGF of X and Y. Should be exp(-u)exp(mut) instead of exp(-u)exp(-1*mut) –  javadba Aug 30 '14 at 21:19
Separate comment/question: please explain why in second line of derivation for PGF of Y refers to exp(x) and x! (instead of referring to exp(y) and y!). I believe these are cut/paste errors - but please confirm. –  javadba Aug 30 '14 at 21:26
Yeah.. You are absolutely correct. Those were typos. I have edited them now. If you find more, let me know. –  Ananda Sep 2 '14 at 5:35

hint: $\sum_{k=0}^{n} P(X = k)P(Y = n-k)$

-
why this hint, why the sum? This is what I don't understand –  user31280 Oct 25 '12 at 20:22
adding two random variables is simply convolution of those random variables. That's why. –  jay-sun Oct 25 '12 at 20:24
gotcha! Thanks! –  user31280 Oct 25 '12 at 20:31
adding two random variables is simply convolution of those random variables... Sorry but no. –  Did Feb 13 '13 at 6:28
There is no usual sense for convolution of random variables. Either convolution of distributions or addition of random variables. –  Did Feb 13 '13 at 6:51

In short, you can show this by using the fact that $$Pr(X+Y=k)=\sum_{i=0}^kPr(X+Y=k, X=i).$$

If $X$ and $Y$ are independent, this is equal to $$Pr(X+Y=k)=\sum_{i=0}^kPr(Y=k-i)Pr(X=i)$$ which is \begin{align} Pr(X+Y=k)&=\sum_{i=0}^k\frac{e^{-\lambda_y}\lambda_y^{k-i}}{(k-i)!}\frac{e^{-\lambda_x}\lambda_x^i}{i!}\\ &=e^{-\lambda_y}e^{-\lambda_x}\sum_{i=0}^k\frac{\lambda_y^{k-i}}{(k-i)!}\frac{\lambda_x^i}{i!}\\ &=\frac{e^{-(\lambda_y+\lambda_x)}}{k!}\sum_{i=0}^k\frac{k!}{i!(k-i)!}\lambda_y^{k-i}\lambda_x^i\\ &=\frac{e^{-(\lambda_y+\lambda_x)}}{k!}\sum_{i=0}^k{k\choose i}\lambda_y^{k-i}\lambda_x^i \end{align} The sum part is just $$\sum_{i=0}^k{k\choose i}\lambda_y^{k-i}\lambda_x^i=(\lambda_y+\lambda_x)^k$$ by the binomial theorem. So the end result is \begin{align} Pr(X+Y=k)&=\frac{e^{-(\lambda_y+\lambda_x)}}{k!}(\lambda_y+\lambda_x)^k \end{align} which is the pmf of $Po(\lambda_y+\lambda_x)$.

-
Moderator notice: This answer was moved here as a consequence of merging two questions. This explains the small differences in notation. The OP's $\lambda$ is $\lambda_x$ here, and OP's $\mu$ is $\lambda_y$. Otherwise there is no difference. –  Jyrki Lahtonen Apr 23 at 6:55


# Filtering data 'geometrically'

I was looking at a very nice answer here, where the question was applying a confidence region to some data.

If we plot some data as a scatter plot:

XData = RandomVariate[NormalDistribution[1,1], 100000];
YData = RandomVariate[NormalDistribution[1,1], 100000];

XYDATA = Transpose[{XData, YData}];

XYCoVarMat = Covariance[XYDATA];
XYMean = {Mean[XData], Mean[YData]};

ListPlot[
XYDATA, Frame->True, FrameLabel->{"X","Y"}, LabelStyle->16, AspectRatio->1,
Epilog -> {
Opacity[0.32, Green], EdgeForm[{Green, AbsoluteThickness[1]}], Ellipsoid[XYMean, 4 XYCoVarMat],
Opacity[0.32, Blue], EdgeForm[{Blue, AbsoluteThickness[1]}], Ellipsoid[XYMean, 3 XYCoVarMat],
Opacity[0.32, Red], EdgeForm[{Red, AbsoluteThickness[1]}], Ellipsoid[XYMean, 2 XYCoVarMat],
Opacity[0.32, Yellow], EdgeForm[{Yellow, AbsoluteThickness[1]}], Ellipsoid[XYMean, 1 XYCoVarMat]
},
PlotRange->{{-8,8},{-8,8}}
]

I was wondering if anyone knew a way of filtering the data using this approach for example only select data that is with the ellipsoid boundary of Ellipsoid[XYMean, 1 XYCoVarMat]?

• Would With[{rmf = RegionMember[Ellipsoid[XYMean, 1 XYCoVarMat]]}, Select[XYDATA, rmf]] work for you? – J. M. will be back soon Nov 15 at 16:09
• It would work wonderfully. I'm starting to wonder if you are actually written purely from Mathematica functions. Thanks! – Q.P. Nov 15 at 16:14
• @J.M.willbebacksoon I don't know if you want to post an answer yourself or not, but given you provided the solution I feel you should get credit. If credit doesn't concern you I will accept ThatGravityGuy's answer so that the question is completed and helps users who find this question. – Q.P. Nov 16 at 13:15
• Please accept ThatGravityGuy's answer if you think you found it useful. – J. M. will be back soon Nov 16 at 13:24

As @J.M. pointed out in the comments, the key here is the function RegionMember. Since you already know the region that you want to work with, namely Ellipsoid[XYMean, 1 XYCoVarMat], you can use Select as
With[{rmf = RegionMember[Ellipsoid[XYMean, 1 XYCoVarMat]]}, Select[XYDATA, rmf]]


# Mosteller's First Ace Problem

[this probably belongs on cross validated ... ]

Working through Mosteller's Fifty Challenging Problems in Probability with Mathematica. I am trying to understand Mosteller's answer for The First Ace problem (#40). The problem goes:

Shuffle an ordinary deck of 52 playing cards containing 4 aces. Then turn up cards from the top until the first ace appears. On the average how many cards are required to produce the first ace?

I solved this problem in Mathematica as as follows:

suite = Flatten@{Range[2, 10], J, Q, K, A}
deck = Flatten@{suite, suite, suite, suite}
dat = Table[First@Flatten@Position[
RandomSample[deck, Length@deck], A], {n, 1, 100000}];
ListPlot[
Tally@dat,
GridLines -> Automatic,
GridLinesStyle -> Directive[Dotted, Gray],
Frame -> True
]

Mean@dat // N
10.6152

Which yields Mosteller's answer (by symmetry) of 10.6 cards (48/5 +1).

I was a bit shocked that the mode was 1 card.

Finally, when I look at the CDF the 50% mark is at 8 cards

t = Reverse[SortBy[Tally@dat, #[[2]] &]][[All, 2]]
ListPlot[N[Accumulate@t/100000],
GridLines -> Automatic,
GridLinesStyle -> Directive[Dotted, Gray]
]

So my question is, if I played this game for real in a casino, should I go for 8 or 10 cards?

• I think you're right, this probably belongs on CrossValidated... Cool problem though. Mar 9, 2017 at 6:03
• @MarcoB I believe this belongs here, because - next to the theoretical aspect - it shows how to make use of Mathematica's abilities to simulate and to work with its distribution-framework.
– gwr
Mar 9, 2017 at 12:34
• My bad, I corrected my "decision support" (cf. my answer): In the simple 0-1-Utility case (right/wrong and a fixed amount to win), you would best choose $1$ (not 8, not 10). My exmple meets the case, when you will win an amount equal to the number of draws it took.
– gwr
Mar 9, 2017 at 18:07

I would like to choose a slightly different approach here and point out, that this is an example for the Negative Hypergeometric Distribution. Wikipedia does give a nice table for this:

While for large numbers the distribution tends to the Negative Binomial Distribution the difference essentially is drawing with replacements (Binomial) vs. drawing without replacements (Hypergeometric).

## Analytical Approach

In the present case, even when we may not have remembered all this statistical theory, we could still take an analytical approach by making use of ProbabilityDistribution. Let us look at the probabilities for the first few numbers of draws:

\begin{align} p(1) &= p(\text{ace}) =\frac{4}{52} \\ p(2) &= p(\neg\text{ace}) \times p(\text{ace}) = \frac{52-4}{52} \times \frac{4}{52-1} \\ p(3) &= p(\neg\text{ace}) \times p(\neg\text{ace}) \times p(\text{ace}) = \frac{52-4}{52} \times \frac{52-4-1}{52-1} \times \frac{4}{52-2} \\ \vdots \end{align}

So eventually we see a pattern here and can (hopefully) come up with the formula for the probability distribution function (in the discrete case a probability mass function) $f$ given the number of cards (or balls in an urn) $N$ and the number of marked cards (or balls) $M$:

\begin{align} f_{N,M}(k) = \frac{m}{N-k+1} \times \prod \limits_{i=1}^{k-1} \frac{N-M-i+1}{N-i+1} \end{align}

To implment this as a distribution we write the following code:

distribution[ n_Integer, m_Integer ] /; m <= n := ProbabilityDistribution[

m/( n - k + 1) Product[ (n - m - i + 1)/(n - i + 1),{ i, 1, k-1 } ],
{ k, 1, n - m + 1, 1 }
(* , Method -> "Normalization" is not needed here, but may be worth remembering
for all cases where giving a proportional formula is easy to come up with *)
]

analyticalDist = distribution[ 52, 4 ];

$PlotTheme = {"Detailed", "LargeLabels"}; Panel @ DiscretePlot[ Evaluate@PDF[ analyticalDist, \[FormalX] ], {\[FormalX], 0, 49, 1}, ImageSize -> Large, PlotLabel -> Style["Analytical PDF", "Subsection"] ]  Also we can find moments and what have you: Mean @ analyticalDistribution (* e.g. the expected number of draws *) $\frac{53}{5}$## Empirical Approach We could of course also arrive at answers using simulation: empiricalDist = EmpiricalDistribution @ Table[ Min @ RandomSample[ Range[52], 4], {10000} (* number of trials *) ]; N @ Mean @ empiricalDist  10.5809 (* true value again was 10.6 *) If we compare the graphs for the PDF we note that the empirical distribution already is quite close: Panel @ DiscretePlot[ Evaluate @ { PDF[ empiricalDist, \[FormalX] ], PDF[ analyticalDist, \[FormalX] ] }, { \[FormalX], 1, 49, 1 }, PlotLegends -> {"empirical", "analytical"}, ImageSize -> Large, PlotLabel -> Style["PDF Comparison", "Subsection"] ]  ## General Case: Negative Hypergeometric Distribution Grabbing a text book near you, you will find the formula for the probability distribution function of the above mentioned Negative Hypergeometric Distribution. It is a special case of the BetaBinomialDistribution - thanks to @ciao for pointing this out repeatedly until I listened :) - for those of you, who do not know this, there is a terrific paper showing the relations between univariate distributions by (Leemis and McQueston 2008) and more information can be found on Cross Validated. Using this information, we can implement the Negative Hypergeometric Distribution explicitly as follows: (* following Mathematica's parametrization for the hyergeometric case *) negativeHypergeometricDistribution[k_, m_, n_ ] := TransformedDistribution[ \[FormalX] + 1, \[FormalX] \[Distributed] BetaBinomialDistribution[ k, m, n-m ] ] (* unfortunately parametrization is no standardized so one has to dwelve into the formulae for this in the paper, which are given though *) nhg = negativeHypergeometricDistribution[ 1, 4, 52 ]; Mean @ nhg $\frac{53}{5}$And we can indeed convince ourselves that our case simply is a special case of a NHG-distributed random var$X$, where$X$is the number of draws from$N = 52$cards, where$M=4$are "successes" and where we need$k=1$success to stop: And @@ Table[ PDF[ analyticalDist, i ] === PDF[ nhg, i ], {i, 1, 52 } ]  True ## EDIT: Decision Support / Expected Utility The OP has edited his question and asked for guidance in playing at a casino (e.g. what number of draws to bet on?). For this we have to turn to decision theory and excepted utility. Let's assume that you are risk neutral. In the case that you get a fixed amount if you are right and zero if you are wrong, then it would be trivially optimal to bet on$1$. ($1$has the greatest probability and the 0-1-loss function makes the expected utility equal to the probability; check this by simulation!) Let us look at a more elaborate case to make the principle clear: If you were to receive the number of draws needed worth in money if you bet on the right number of draws, then your utility function would be$U(x,k) = x I(x = k)$(where$I$is the indicator function,$x$your bet and$k$the number of draws it took. In this case your best bet will be$13$: NArgMax[ { NExpectation[ \[FormalX] * Boole[ \[FormalX] == i], \[FormalX] \[Distributed] negativeHypergeometricDistribution[ 1, 4, 52 ] ], 1<= k<= 49 }, k ∈ Integers ]  13 With[ { dist = negativeHypergeometricDistribution[ 1, 4, 52 ] }, Panel @ DiscretePlot[ Evaluate@ Expectation[ \[FormalX] * Boole[ \[FormalX] == i ], \[FormalX] \[Distributed] dist ], {i,1,49}, ImageSize -> Large, PlotLabel -> Style["Expected Utility (0-1)", "Subsection"], PlotLegends->None ] ]  • "since it is not implemented...". It is, as BetaBinomial, already noted in an earlier reply. – ciao Mar 9, 2017 at 23:35 • @ciao Thanks, I did not make that connection. It is deeply burried in the docs and also not very obvious from web research. Guess one really needs to know what your looking for. :) – gwr Mar 9, 2017 at 23:50 • Not so much an MMA docs issue, more of a wider issue of distributions going by different names/definitions in the mathematical world. Would be nice if a future MMA docs edition (or MathWord) had a big interconnected chart with all alternate names/definitions and their relationships... – ciao Mar 10, 2017 at 0:50 • This is the best overview with regard to the relationships between univariate distributions I have found so far. – gwr Mar 10, 2017 at 8:19 Update (attribution: @ciao) As @ciao has pointed out, use ofBetaBinomialDistribution is the most straightforward for exact calculation and simulation. See the comment: Mean[BetaBinomialDistribution[1, 4, 48]] + 1  or simulation Mean[RandomVariate[Mean[BetaBinomialDistribution[1, 4, 48]] + 1],100000] Median[RandomVariate[Mean[BetaBinomialDistribution[1, 4, 48]] + 1],100000]  etc Original Answer As the choice of first Ace is arbitrary you could simplify, e.g.: tab = Table[Min[FirstPosition[RandomSample[Range[52]], #][[1]] & /@ Range[4]], 10000]; Histogram[tab, Automatic, "PDF"] N@Mean[tab] Median[tab]  You could also do analytically,e.g. let$f(k)$be the probability that the first ace in the first$k$cards, then: f[k_] := 1 - Binomial[52 - k, 4]/Binomial[52, 4] DiscretePlot[f[k], {k, 0, 52}]  Sanity checks:$f(k)=1$for$k\ge 49$The probability that is$k\$th card is discrete derivative:

ListPlot[Differences[Table[f[k], {k, 0, 52}]], Filling -> Axis]
Differences[Table[f[k], {k, 0, 52}]].Range[52]

• Or you could just Mean[BetaBinomialDistribution[1, 4, 48]] + 1... ;=}
– ciao
Mar 9, 2017 at 6:56
• @ciao doh! always forgetting to exploit diverse built-in distributions...hope your entrepreneurship is going well ;-) Mar 9, 2017 at 6:59


# Plotting a system of linear ODE

I would like to plot a system of following ODE:

$$$$\mathbf{\dot{x}} = \mathbf{Ax} \text{ where } \mathbf{A} = \begin{bmatrix} -2 & 1 \\ -1 & 0 \end{bmatrix}$$$$

with general solution:

$$$$\vec{x}(t)=C_1 \begin{bmatrix} 1 \\ 1 \end{bmatrix} e^{-t}+C_2 \left(\begin{bmatrix} 0 \\ 1 \end{bmatrix}+\begin{bmatrix} 1 \\ 1 \end{bmatrix} t \right) e^{-t}$$$$

I know that this system is stable so arrows will be inward-pointing, also it has double eigenvalue at -1 so there will be an constant line for an eigenvalue crossing the plot but I am not sure how to fill the rest of the phase diagram. Could someone help me? Thanks in advance.

• I think you have a mistake. Shouldn't this system have a double eigenvalue of 1, not -1? – Josh B. Nov 4 '18 at 16:29
• @JoshB. I think the eigenvalue is given by $$\lambda^2+2\lambda+1$$ unless I made a mistake but I double checked the solution using Matlab – 1muflon1 Nov 4 '18 at 16:33
• If that's the case, then there is a typo in your matrix here. I just checked and the matrix you have definitely has a double eigenvalue of 1. – Josh B. Nov 4 '18 at 16:39
• @JoshB. You were correct the typo was 2 instead of -2. My bad. I am really sorry, I was copy pasting it from my latex and somehow I did not included the minus sign, dont know how did I even managed to do it – 1muflon1 Nov 4 '18 at 16:41

If you write your solution now as $$\vec{x}(t)=\left(C_1\begin{bmatrix} 1 \\ 1 \end{bmatrix}+C_2\begin{bmatrix} 0 \\ 1\end{bmatrix}\right)e^{-t}+C_2\begin{bmatrix}1 \\ 1\end{bmatrix}te^{-t}$$

it may be a little easier to see what's going on. As $$t\to\pm\infty$$, the equation is dominated by the second term, so $$\vec{x}(t)\approx C_2\begin{bmatrix} 1 \\ 1\end{bmatrix}te^{-t}\;\;\;\;\;\;\;\;\;\;\;t\to\pm\infty$$

As $$t\to\infty$$, the whole thing decays to $$0$$, so it makes sense that all solution curves begin to look like they fall along this eigenvector as they decay to $$0$$. Applying the same logic as $$t\to-\infty$$, it would seem that solutions grow along this vector as well, but this is only true on a macroscopic scale, as the solutions are growing exponentially in both directions. The first term, no longer decaying to $$0$$, shifts the solution away from the eigenvector and is growing large, but not as large as the second term. This means that when zoomed in, solutions look like they are leaving the eigenvector, but zoomed out solutions look like they are along the eigenvector (that is, until you let time grow large enough, in which you will see it move away slowly).

The last thing to consider is the direction of the curve. Suppose that $$\vec{x}$$ is in the first quadrant as $$t\to\infty$$. This means that $$C_2$$ is positive, so if $$t\to-\infty$$, then the sign on the second term is now negative, and the solution turns around to enter the third quadrant. This means that solutions sort of "spin" by turning $$180^\circ$$ around while still growing away from the origin.

The vector $$\begin{bmatrix} 0 \\ 1\end{bmatrix}$$ tells you which way the solution spins. If $$C_2$$ is positive, then that means that at $$t=0$$, the solution is above (in the xy-plane) of the line through the vector $$\begin{bmatrix} 1 \\ 1\end{bmatrix}$$ and the origin, so the solution must remain on this side of said line. The dominating term is in the first quadrant as $$t\to\infty$$, so the solution must spin clockwise to decay this way. It turns out that if solutions spin clockwise on one side of the eigenvector, they do the same on the other side as well; the same is true if they spin counterclockwise.

This type of equilibrium is called a Degenerate Node, in case you were curious. Here is an example of what one might look like.

• Thank you for very clear and detailed answer. By the way did you made the plot in matlab,? I know that it was not part of my original question and matlab inquiries dont really belong to math section, but would you mind sharing your code? I would like to learn how to do it. Or did you used another program? – 1muflon1 Nov 4 '18 at 17:36
• No, I pulled it from the encyclopedia of mathematics. Plotting this in MATLAB could be done by taking a spacing of points for t and plugging them in for x and y, then plotting the resulting curve. This would need to be done for a few different initial points to get a good diagram. – Josh B. Nov 4 '18 at 17:44


If $\left| f'(x) \right| \leq A |f(x)|^\beta$ then f is a constant function

Problem Let $f(x)$ be a differentiable function on $[a,b]$ satisfying $f(a)=0$. If there exist $A \ge 0$ and $\beta \ge 1$ such that the inequality

$$\left| f'(x) \right| \leq A \left| f(x) \right|^\beta$$

holds for all $x$ in $[a,b]$, then $f(x) = 0$ for any x in that interval.

My attempted solution

We shall prove by contradiction. Suppose that for some $x$ in $[a,b]$ we have $f(x) \neq 0$.

Put $S:= \left\lbrace x \right.$ such that $a \le x \le b$ and $f(x) \neq 0 \left. \right\rbrace$ and $c:=\inf S$ (the infimum value of set $S$). If $c=b$ then $f(x) = 0$ $\forall x < b$ and the continuity of $f$ implies that $f(b) = 0$, too (contradiction). Therefore $c \neq b$. If $c=a$, then $f(c) = 0$ by the hypothesis. Otherwise, when $a < c < b$ we have $f(x) = 0$ $\forall x < c$ and again, by continuity, $f(c) = 0$. Thus in all cases considered, we have $f(c) = 0$ and $a \leq c < b$

As $f$ is continuous at $c$ and $f(c) = 0$, one can choose $d>c$ and close enough to $c$ such that $|f(x)| \le 1$ and $$\tag{\star} A(x-c) \le \frac12\quad\text{for all }x\text{ with }c \le x \le d.$$ Since $f$ is continuous on $[c,d]$, it has maximum and minimum values on this closed interval, leading to the existence of $c \le t \le d$ such that $|f(t)| = \max_{c \le x \le d} |f(x)|$. As already noted, $f(c) = 0$ and $c$ is the infimum of the set of numbers whose image under $f$ is nonzero. Therefore, for any $\epsilon>0$, there is some $c<m<c+\epsilon$ satisfying $f(m) \neq 0$. This observation, together with the definition of $t$, gives us $$\tag{\star\!\star}f(t) \neq 0,$$ $t \neq c$ and so $c<t$. Applying the Lagrange theorem gives:

$$|f(t)| = |f(t) - f(c)| = |t-c||f'(u)| \leq|t-c|A|f(u)|^\beta$$ where $c<u<t\le d$. By $(\star)$: $$|t-c|A|f(u)|^\beta \le \frac12 |f(u)|^\beta \leq \frac12 |f(u)|$$

Combining the two inequalities and noting that $|f(t)| \ge |f(u)|$ (because of the definition of $t$), we have $f(u) = f(t) = 0$ and arrived at a contradiction with $(\star\star)$.

Question

I hope someone can verify if my solution is correct. Of course, other ideas, comments or solutions are welcome.

I like to post problems and my solutions to the forum because I think it's beneficial to the community, and for learners like me. First, I can hardly know if there's flaw in my own argument. Second, I may get new insights/solutions for my problem.

Thank you.

• Sorry, I am not yet clear how the two threads are related? – tom_a2 May 22 '13 at 16:43
• You are absolutely right. I misread your question. – Martin May 22 '13 at 16:45
• It looks good to me. – Julien May 22 '13 at 17:32

Let $B = \{x\in [a,b]: |f(x)|=0\}$. By continuity, this set is closed. Since $f(0) = 0$, the set is non-empty. We show that it is also open.

Let $x\in B$, i.e. $f(x) =0$. By continuity, there exists $0<r<(2A)^{-1}$, such that $|f(y)|<\frac 12$ for all $y\in B_r(x)$. Fix such a $y\in B_r(x)$. We want to show that $f(y) =0$.

By the mean value inequality, we have $$|f(y)| = |f(y) - f(x)| \le |f'(\xi_0)| |y-x| \le |f'(\xi_0)|r$$ for some $\xi_0\in B_r(x)$ lying on the segment between $x$ and $y$. By assumption, we have $|f'(\xi_0)|\le A |f(\xi_0)|^\beta$, hence $$|f(y)|\le |f'(\xi_0)|r \le A|f(\xi_0)|^\beta (2A)^{-1} \le \frac 12|f(\xi_0)|^\beta.$$ By the same argument applied to $\xi_0\in B_r(x)$ instead of $y$, we see that there exists $\xi_1\in B_r(x)$, such that $|f(\xi_0)|\le \frac 12|f(\xi_1)|^\beta$. Iterating yields a sequence $\xi_n \in B_r(x)$, such that $|f(\xi_{n})|\le \frac 12|f(\xi_{n+1})|^\beta$ for all $n$. Note that by our choice of $r$, we have $|f(\xi_{n})|\le \frac 12$ for all $n$. We conclude that $$|f(y)|\le \frac 12 |f(\xi_0)|^\beta \le \frac 1{2^2}|f(\xi_1)|^{\beta^2} \le \frac{1}{2^3}|f(\xi_2)|^{\beta^3}\le \dots \le \frac{1}{2^n}|f(\xi_{n-1})|^{\beta^n}\le \frac 1{2^{n+\beta^n}},$$ for all $n\in \mathbb N$. Letting $n\to \infty$ shows that $|f(y)| = 0$ (using also $\beta \ge 1$). This implies that $B_r(x)\subset B$, hence $B$ is open.

Since $[a,b]$ is connected, it follows that $B$ must be all of $[a,b]$, hence $f= 0$.

( Edit. The ODE analysis also explains why $\beta \geq 1$ is necessary. The condition for $|f'(x)| \leq A|H(f(x))|$ to have the property that $f$ does not change sign, when $H$ is a function such that $H(x)=0$ only at $x=0$, is that $\frac{1}{H(x)}$ an has a non-integrable singularity at $0$. Knowing that this is the answer, there is no loss in considering singularities that are powers of $f$, which is what most cases would look like and how they would be recognized.)

The differential equation $f'(x) = A(x) f(x)^\beta$ can be solved explicitly, by separation of variables. The calculation shows that $f(a)=0$ is necessary, or we could write down nowhere zero solutions, by solving the equation. This bears further analysis, because superficially the problem looks like a Lipschitz condition with $|f(x) - f(y)| \leq |x-y|^\beta$ which (as is very well known and often solved as an exercise) implies constant $f$ when $\beta > 1$.

The DE for constant $\beta > 1$, writing $y$ for $f(x)$, is $$d(\frac{1}{(\beta - 1)y^{\beta - 1}}) = A(x) dx$$

The coordinates that trivialize the equation are therefore $Y = \frac{1}{(\beta - 1)y^{\beta - 1}}$ and $X = \int A(x) dx$, in which the solutions are $Y = X + c$ for constant $c$. This brings out the idea that $A$, which appears at first to be a harmless constant removable by a linear change of variable, has a meaningful part in the problem, as velocity of the independent variable.

Under this coordinate change, $f(a)=0$ becomes $f(a)=\infty$. On a maximal interval where $f$ is nonzero, there cannot be any solutions that hit infinity at the boundary in finite "time" (here $X$ is time, so we mean a finite change in $\int A(x) dx$) while satisfying $Y - X =$ constant.

So the meaning of the problem seems to be: no singularity can be reached in finite time for this ODE.

• Let's put here the comment that for $\beta < 1$ there are counterexamples with $f(x)$ a positive power of $(x-a)$. – zyx May 26 '13 at 22:38

Supposing that f(x)=0 only for a and that f(x)>0 for the rest x in [a,b].

Then lim (f(x) - f(a))/(x-a) as x->a+ will be greater or equal to zero. If greater then f'(a)=m >0 and thats contradicting with the given inequality.Therefore f(x)=0 for all x in [a,b]. If equal, then im sorry but i need to give it some more thought. In the same manner, u can prove for f(x)<0.

I just posted this insufficient answer cuz i thought it would be simpler to understand.


GMAT Question of the Day - Daily to your Mailbox; hard ones only

 It is currently 05 Dec 2019, 17:59

### GMAT Club Daily Prep

#### Thank you for using the timer - this advanced tool can estimate your performance and suggest more practice questions. We have subscribed you to Daily Prep Questions via email.

Customized
for You

we will pick new questions that match your level based on your Timer History

Track

every week, we’ll send you an estimated GMAT score based on your performance

Practice
Pays

we will pick new questions that match your level based on your Timer History

### Show Tags

25 Jun 2018, 05:02
21
00:00

Difficulty:

5% (low)

Question Stats:

82% (01:39) correct 18% (01:50) wrong based on 972 sessions

### HideShow timer Statistics

Over the past 7 weeks, the Smith family had weekly grocery bills of $74,$69, $64,$79, $64,$84, and $77. What was the Smiths' average (arithmetic mean) weekly grocery bill over the 7-week period? A.$64

B. $70 C.$73

D. $74 E.$85

NEW question from GMAT® Official Guide 2019

(PS07369)
Senior SC Moderator
Joined: 22 May 2016
Posts: 3723
Over the past 7 weeks, the Smith family had weekly grocery bills of $7 [#permalink] ### Show Tags 27 Jun 2018, 18:28 6 9 Bunuel wrote: Over the past 7 weeks, the Smith family had weekly grocery bills of$74, $69,$64 $79,$64, $84, and$77. What was the Smiths' average (arithmetic mean) weekly grocery bill over the 7-week period?

A. $64 B.$70

C. $73 D.$74

### Show Tags

29 Jun 2018, 06:58
28
9
First, choose a nice, round number, such as 70, within the range of values.

Then calculate the average with the following formula:

Average = Nice number + Average of differences from the nice number

Average = 70 + (4 - 1 - 6 + 9 - 6 + 14 + 7)/7 = 70 + 21/7 =73

_________________
My book with my solutions to all 230 PS questions in OG2018:
Zoltan's solutions to OG2018 PS
##### General Discussion
Target Test Prep Representative
Status: Founder & CEO
Affiliations: Target Test Prep
Joined: 14 Oct 2015
Posts: 8610
Location: United States (CA)
Re: Over the past 7 weeks, the Smith family had weekly grocery bills of $7 [#permalink] ### Show Tags 28 Jun 2018, 18:07 1 Bunuel wrote: Over the past 7 weeks, the Smith family had weekly grocery bills of$74, $69,$64, $79,$64, $84, and$77. What was the Smiths' average (arithmetic mean) weekly grocery bill over the 7-week period?

A. $64 B.$70

C. $73 D.$74

E. $85 We can determine the average using the formula: average = sum / number: average = (74 + 69 + 64 + 79 + 64 + 84 + 77)/7 = 511/7 = 73 Answer: C _________________ # Scott Woodbury-Stewart Founder and CEO Scott@TargetTestPrep.com 122 Reviews 5-star rated online GMAT quant self study course See why Target Test Prep is the top rated GMAT quant course on GMAT Club. Read Our Reviews If you find one of my posts helpful, please take a moment to click on the "Kudos" button. VP Joined: 14 Feb 2017 Posts: 1310 Location: Australia Concentration: Technology, Strategy GMAT 1: 560 Q41 V26 GMAT 2: 550 Q43 V23 GMAT 3: 650 Q47 V33 GMAT 4: 650 Q44 V36 GMAT 5: 650 Q48 V31 GMAT 6: 600 Q38 V35 GPA: 3 WE: Management Consulting (Consulting) Re: Over the past 7 weeks, the Smith family had weekly grocery bills of$7  [#permalink]

### Show Tags

19 Nov 2018, 16:13
1
Admittedly I made a stupid mistake and I organised the numbers in ascending order then selected the median (74) instead of solving Sum/# Terms

The method I used is only for consecutive integers and the punishment answer D is there for suckers like me.
e-GMAT Representative
Joined: 04 Jan 2015
Posts: 3158
Re: Over the past 7 weeks, the Smith family had weekly grocery bills of $7 [#permalink] ### Show Tags 25 Jun 2018, 05:10 Solution Given: • Over the past 7 weeks, the Smith family had weekly grocery bills of$74, $69,$64, $79,$64, $84, and$77

To find:
• Smith’s average weekly grocery bill over the 7-week period

Approach and Working:
• Smith’s total bill amount over the 7-week period = (74 + 69 + 64 + 79 + 64 + 84 + 77) = 511
• Therefore, Smith’s average bill amount over the same period = $$\frac{511}{7}$$ = 73

Hence, the correct answer is option C.

_________________
Intern
Joined: 08 Jul 2017
Posts: 15
Location: Greece
GPA: 3.31

### Show Tags

28 Aug 2018, 03:42
Bunuel wrote:
Over the past 7 weeks, the Smith family had weekly grocery bills of $74,$69, $64,$79, $64,$84, and $77. What was the Smiths' average (arithmetic mean) weekly grocery bill over the 7-week period? A.$64

B. $70 C.$73

D. $74 E.$85

NEW question from GMAT® Official Guide 2019

(PS07369)

Easy way out is consider avg 70 -
so diff for all terms is 4, -1 , -6, 9 , -6,14, 7 = sum is 21 = divided by 7 = equal to 3 so 70 +3 = 73 avg
Board of Directors
Status: QA & VA Forum Moderator
Joined: 11 Jun 2011
Posts: 4835
Location: India
GPA: 3.5
Re: Over the past 7 weeks, the Smith family had weekly grocery bills of $7 [#permalink] ### Show Tags 10 Sep 2018, 07:34 Bunuel wrote: Over the past 7 weeks, the Smith family had weekly grocery bills of$74, $69,$64, $79,$64, $84, and$77. What was the Smiths' average (arithmetic mean) weekly grocery bill over the 7-week period?

A. $64 B.$70

C. $73 D.$74

E. $85 NEW question from GMAT® Official Guide 2019 (PS07369) $$\frac{( 70 + 4 ) + ( 70 - 1 ) + ( 60 + 4 ) + ( 80 - 1 ) + ( 60 + 4 ) + ( 80 + 4 ) + ( 70 + 7 )}{7}$$ = $$\frac{( 70 + 70 + 60 + 80 + 60 + 80 + 70 ) + ( 4 - 1 + 4 - 1 + 4 + 4 + 7 )}{7}$$ = $$\frac{490 + 21}{7}$$ = $$\frac{490}{7} + \frac{21}{7}$$ = $$70 + 3$$ = $$73$$, Answer must be (C) _________________ Thanks and Regards Abhishek.... PLEASE FOLLOW THE RULES FOR POSTING IN QA AND VA FORUM AND USE SEARCH FUNCTION BEFORE POSTING NEW QUESTIONS How to use Search Function in GMAT Club | Rules for Posting in QA forum | Writing Mathematical Formulas |Rules for Posting in VA forum | Request Expert's Reply ( VA Forum Only ) Intern Joined: 02 May 2018 Posts: 12 GMAT 1: 620 Q46 V29 Re: Over the past 7 weeks, the Smith family had weekly grocery bills of$7  [#permalink]

### Show Tags

10 Sep 2018, 07:46
We can rule out
64, 74 and 85 as they are the extreme numbers.
That leaves just two choices to choose from 70 and 73.

Only 3 values in the 60s and therefore less likely for 70.

73 is the most likely choice. Confirm 73 by taking difference and summing it up
Intern
Joined: 22 Jul 2018
Posts: 22
Location: Indonesia
Schools: MBS '21
GPA: 3.24

### Show Tags

02 Dec 2019, 16:30
Hello from the GMAT Club BumpBot!

Thanks to another GMAT Club member, I have just discovered this valuable topic, yet it had no discussion for over a year. I am now bumping it up - doing my job. I think you may find it valuable (esp those replies with Kudos).

Want to see all other topics I dig out? Follow me (click follow button on profile). You will receive a summary of all topics I bump in your profile area as well as via email.
_________________


It is currently 23 Nov 2017, 06:08

GMAT Club Daily Prep

Thank you for using the timer - this advanced tool can estimate your performance and suggest more practice questions. We have subscribed you to Daily Prep Questions via email.

Customized
for You

we will pick new questions that match your level based on your Timer History

Track

every week, we’ll send you an estimated GMAT score based on your performance

Practice
Pays

we will pick new questions that match your level based on your Timer History

Events & Promotions

Events & Promotions in June
Open Detailed Calendar

Is |x| = |y|? (1) x = -y (2) x^2 = y^2

Author Message
TAGS:

Hide Tags

Manager
Joined: 18 Feb 2015
Posts: 88

Kudos [?]: 86 [1], given: 15

Is |x| = |y|? (1) x = -y (2) x^2 = y^2 [#permalink]

Show Tags

16 Dec 2015, 07:06
1
KUDOS
1
This post was
BOOKMARKED
00:00

Difficulty:

5% (low)

Question Stats:

84% (00:21) correct 16% (00:30) wrong based on 62 sessions

HideShow timer Statistics

Is |x| = |y|?

(1) x = -y
(2) x^2 = y^2

[Reveal] Spoiler:
I found this question in GMAT Prep and selected ST2 as the answer but that's wrong.

Normally, x^2 would equal to lxl since it will contain both signs "positive as well as negative". How come st 1 is true?

Does it assume that since +x = -y, it must be true that -x is also equal to -y or?

What am I missing?

[Reveal] Spoiler: OA

Last edited by Bunuel on 11 Nov 2017, 01:25, edited 3 times in total.
Formatted the question.

Kudos [?]: 86 [1], given: 15

Current Student
Joined: 20 Mar 2014
Posts: 2676

Kudos [?]: 1775 [1], given: 794

Concentration: Finance, Strategy
Schools: Kellogg '18 (M)
GMAT 1: 750 Q49 V44
GPA: 3.7
WE: Engineering (Aerospace and Defense)
Re: Is |x| = |y|? (1) x = -y (2) x^2 = y^2 [#permalink]

Show Tags

16 Dec 2015, 07:38
1
KUDOS
2
This post was
BOOKMARKED
HarveyKlaus wrote:
Is lxl = lyl ?

A) x=-y
b) x^2 = y^2

[Reveal] Spoiler:
I found this question in GMAT Prep and selected ST2 as the answer but that's wrong.

Normally, x^2 would equal to lxl since it will contain both signs "positive as well as negative". How come st 1 is true?

Does it assume that since +x = -y, it must be true that -x is also equal to -y or?

What am I missing?

You are asked whether |x|=|y| or in other words, is the distance of x from 0 = distance of y from 0 ? You would get a yes if x= y or x=-y. Lets evaluate the choices.

Per statement 1:$$x=-y$$ . Clearly this is one of the conditions we are looking for. Assume 2-3 different values. x=2, y = -2 --> 2 and -2 are both 2 units from 0 . Similar for 3/-3 or 10/-10 etc. Thus this statement is sufficient.

Per statement 2: $$x^2=y^2$$ ---> $$x= \pm y$$. Again both the cases, x=y and x=-y give you a "yes" for the question asked as is hence sufficient.

Both statements are sufficient ---> D is the correct answer.

Kudos [?]: 1775 [1], given: 794

Senior Manager
Joined: 20 Feb 2015
Posts: 388

Kudos [?]: 106 [0], given: 10

Concentration: Strategy, General Management
Re: Is |x| = |y|? (1) x = -y (2) x^2 = y^2 [#permalink]

Show Tags

17 Dec 2015, 06:54
statement 1 is sufficient as absolute value for -ve should give +ve
statement 2 is sufficient as
it will give either x and y both are +ve or both are -ve

Kudos [?]: 106 [0], given: 10

Intern
Joined: 15 Sep 2017
Posts: 7

Kudos [?]: 0 [0], given: 23

Re: Is |x| = |y|? (1) x = -y (2) x^2 = y^2 [#permalink]

Show Tags

10 Nov 2017, 15:24
Is |x|=|y|?

1) x=-y

2) x^2=y^2

Kudos [?]: 0 [0], given: 23

Manager
Joined: 15 Feb 2017
Posts: 71

Kudos [?]: 58 [3], given: 0

Re: Is |x| = |y|? (1) x = -y (2) x^2 = y^2 [#permalink]

Show Tags

10 Nov 2017, 17:20
3
KUDOS
You are asked whether |x|=|y| or in other words, is the distance of x from 0 = distance of y from 0 ? You would get a yes if x= y or x=-y. Lets evaluate the choices.

Per statement 1:x=−yx=−y . Clearly this is one of the conditions we are looking for. Assume 2-3 different values. x=2, y = -2 --> 2 and -2 are both 2 units from 0 . Similar for 3/-3 or 10/-10 etc. Thus this statement is sufficient.

Per statement 2: x2=y2x2=y2 ---> x=±yx=±y. Again both the cases, x=y and x=-y give you a "yes" for the question asked as is hence sufficient.

Both statements are sufficient ---> D is the correct answer.
Please give me kudos. I need them to unlock gmatclub tests.

Kudos [?]: 58 [3], given: 0

Math Expert
Joined: 02 Sep 2009
Posts: 42326

Kudos [?]: 133106 [0], given: 12411

Re: Is |x| = |y|? (1) x = -y (2) x^2 = y^2 [#permalink]

Show Tags

11 Nov 2017, 01:25
SamDGold wrote:
Is |x|=|y|?

1) x=-y

2) x^2=y^2

Merging topics. Please check the discussion above.
_________________

Kudos [?]: 133106 [0], given: 12411

Re: Is |x| = |y|? (1) x = -y (2) x^2 = y^2   [#permalink] 11 Nov 2017, 01:25
Display posts from previous: Sort by


# Need help deriving recurrence relation for even-valued Fibonacci numbers.

That would be every third Fibonacci number, e.g. $0, 2, 8, 34, 144, 610, 2584, 10946,...$

Empirically one can check that:

$a(n) = 4a(n-1) + a(n-2)$ where $a(-1) = 2, a(0) = 0$.

If $f(n)$ is $\operatorname{Fibonacci}(n)$ (to make it short), then it must be true that $f(3n) = 4f(3n - 3) + f(3n - 6)$.

I have tried the obvious expansion:

$f(3n) = f(3n - 1) + f(3n - 2) = f(3n - 3) + 2f(3n - 2) = 3f(3n - 3) + 2f(3n - 4)$ $= 3f(3n - 3) + 2f(3n - 5) + 2f(3n - 6) = 3f(3n - 3) + 4f(3n - 6) + 2f(3n - 7)$ ... and now I am stuck with the term I did not want. If I do add and subtract another $f(n - 3)$, and expand the $-f(n-3)$ part, then everything would magically work out ... but how should I know to do that? I can prove the formula by induction, but how would one systematically derive it in the first place?

I suppose one could write a program that tries to find the coefficients x and y such that $a(n) = xa(n-1) + ya(n-2)$ is true for a bunch of consecutive values of the sequence (then prove the formula by induction), and this is not hard to do, but is there a way that does not involve some sort of "Reverse Engineering" or "Magic Trick"?

-
Why isn't $f_{n+2}=3f_n-f_{n-2}$ suitable? –  Guess who it is. Dec 27 '11 at 4:31
@J.M., sorry I do not understand. If I were to expand $f_{n+2}$ the way I do it, I would end up with $2f_n + f_{n - 2} + f_{n - 3}$. Again, I can make this work if I know what I am trying to get. I wonder if you have read the question correctly - I am looking for even-valued (not even-indexed) fib numbers. If my assumption is mistaken, then sorry. However, I am not sure how to systematically arrive at a relation you have given and how to use it to help me simplify things. –  Job Dec 27 '11 at 4:45
It seems I did misunderstand you (and I apologize for this); have you looked at the references here by any chance? –  Guess who it is. Dec 27 '11 at 4:50

## 8 Answers

The definition of $F_n$ is given:

• $F_0 = 0$
• $F_1 = 1$
• $F_{n+1} = F_{n-1} + F_{n}$ (for $n \ge 1$)

Now we define $G_n = F_{3n}$ and wish to find a recurrence relation for it.

Clearly

• $G_0 = F_0 = 0$
• $G_1 = F_3 = 2$

Now we can repeatedly use the definition of $F_{n+1}$ to try to find an expression for $G_{n+1}$ in terms of $G_n$ and $G_{n-1}$.

\begin{align*} G_{n+1}&= F_{3n+3}\\ &= F_{3n+1} + F_{3n+2}\\ &= F_{3n-1} + F_{3n} + F_{3n} + F_{3n+1}\\ &= F_{3n-3} + F_{3n-2} + F_{3n} + F_{3n} + F_{3n-1} + F_{3n}\\ &= G_{n-1} + F_{3n-2} + F_{3n-1} + 3 G_{n}\\ &= G_{n-1} + 4 G_{n} \end{align*}

so this proves that $G$ is a recurrence relation.

-

At André's request, I've decided to write an answer. I've also arbitrarily decided to be ambitious and greedy, and I will thus derive a recurrence for the $k$-th increment Fibonacci number $f_{kn}$. (For OP's specific case, $k=3$)

Like André, I shall also start with Binet:

$$f_{kn}=\frac{\phi^{kn}-(-\phi)^{-kn}}{\sqrt 5}$$

Letting $u=\phi^k$ and $v=\left(-\dfrac1\phi\right)^k$, the formula takes the form

$$f_{kn}=pu^n+qv^n$$

This means that the characteristic polynomial for the recurrence satisfied by $f_{kn}$ takes the form

\begin{align*} x^2-(u+v)x+uv&=x^2-\left(\phi^k+\left(-\frac1\phi\right)^k\right)x+\left(\phi^k\left(-\frac1\phi\right)^k\right)\\ &=x^2-\left(\phi^k+\left(-\frac1\phi\right)^k\right)x+(-1)^k \end{align*}

and the recurrence itself goes like

$$f_{k(n+1)}=\left(\phi^k+\left(-\frac1\phi\right)^k\right)f_{kn}-(-1)^k f_{k(n-1)}$$

You might say that the form $\ell_k=\phi^k+\left(-\dfrac1\phi\right)^k$ is a bit unwieldy, and I agree. There are two ways to go about (slightly) simplifying this. One way makes use of the Newton-Girard formulae. These formulae express $\ell_k$ in terms of $\phi-\dfrac1\phi=1$ and $\phi\left(-\dfrac1\phi\right)=-1$. To use $k=3$ as an example:

$$\alpha^3+\beta^3=(\alpha+\beta)^3-3(\alpha+\beta)(\alpha\beta)$$

Making the replacement $\alpha+\beta=1$ and $\alpha\beta=-1$, we have

$$\ell_3=(1)^3-3(1)(-1)=4$$

The slick way is to recognize that since $\ell_k$ is itself a linear combination of $\phi^k$ and $\left(-\dfrac1\phi\right)^k$, it also satisfies the Fibonacci recurrence:

$$\ell_{k+1}=\ell_k+\ell_{k-1}$$

The $\ell_k$ are in fact the (not-so-famous) Lucas numbers. With $\ell_0=2$ and $\ell_1=1$, we have the sequence $2, 1, 3, 4, 7, 11,\dots$

In short, the recurrence is of the form

$$f_{k(n+1)}=\ell_k f_{kn}-(-1)^k f_{k(n-1)}$$

For $k=3$, we have $f_{3(n+1)}=\ell_3 f_{3n}-(-1)^3 f_{3(n-1)}$ or $f_{3(n+1)}=4 f_{3n}+f_{3(n-1)}$.

-
Very nice post. This is the kind of solution where each piece falls nicely at its right place. –  Did Dec 27 '11 at 9:35
It turns out that the identity derived here is listed in the Wolfram Functions site. –  Guess who it is. Dec 28 '11 at 0:21
@JM: this identity is a special case of the identity $$F_{n+2k}=L_kF_{n+k}-(-1)^kF_n$$ However, the indices do not need to be multiples of $k$, they just need to differ by $k$. –  robjohn Jan 16 '12 at 19:43

Let $\alpha$ and $\beta$ be the two roots of the equation $x^2-x-1=0$. Then the $n$-th Fibonacci number is equal to $$\frac{\alpha^n-\beta^n}{\sqrt{5}}.$$

We are interested in the recurrence satisfied by the numbers $$\frac{\alpha^{3n}-\beta^{3n}}{\sqrt{5}}.$$

If $x$ is either of $\alpha$ or $\beta$, then $x^2=x+1$. Multiply by $x$. We get $x^3=x^2+x=2x+1$. It follows that $x^4=2x^2+x=3x+2$. But then $x^5=3x^2+2x=5x+3$, and then $x^6=5x^2+3x=8x+5$.

We want $x^6=Ax^3+B$, where $A$ and $B$ are rational, indeed integers. So we want $8x+5=A(2x+1)+B$. Reading off $A$ and then $B$ is obvious: we need $A=4$ and $B=1$.

So the numbers $\alpha^{3n}$ and $\beta^{3n}$ satisfy the recurrence $y_n=4y_{n-1}+y_{n-2}$. By linearity, so do the numbers $\frac{\alpha^{3n}-\beta^{3n}}{\sqrt{5}}$.

Comment: Note that using the same basic strategy, we can write down the recurrence satisfied by $\frac{\alpha^{kn}-\beta^{kn}}{\sqrt{5}}$. The coefficients that we painfully computed by hand, step by step, can be expressed simply in terms of Fibonacci numbers, and therefore so can the recurrence for the numbers $\frac{\alpha^{kn}-\beta^{kn}}{\sqrt{5}}$.

-
Nice! I think Newton-Girard might also yield a useful route here. –  Guess who it is. Dec 27 '11 at 5:11
I thought I would take an "unfancy" route through facts likely to be well-known. –  André Nicolas Dec 27 '11 at 5:18
Here's the Newton-Girard route for completeness: one wants the characteristic polynomial $x^2-(\alpha^3+\beta^3)x+\alpha^3 \beta^3$ without knowing $\alpha$ or $\beta$, but knowing that $\alpha+\beta=1$ and $\alpha\beta=-1$ (Vieta). It is easily seen that $\alpha^3 \beta^3=-1$. Using Newton-Girard, we have the symmetric polynomial expansion $\alpha^3+\beta^3=(\alpha+\beta)^3-3(\alpha+\beta)(\alpha\beta)$, and thus $\alpha^3+\beta^3=(1)^3-3(1)(-1)=4$. The characteristic polynomial is thus $x^2-4x-1$. –  Guess who it is. Dec 27 '11 at 5:25
@J.M.: I think that the comment above should be made into an answer. –  André Nicolas Dec 27 '11 at 5:29

By inspection $f(3n+3)=4f(3n)+f(3n-3)$, as you’ve already noticed. This is easily verified:

\begin{align*} f(3n+3)&=f(3n+2)+f(3n+1)\\ &=2f(3n+1)+f(3n)\\ &=3f(3n)+2f(3n-1)\\ &=3f(3n)+\big(f(3n)-f(3n-2)\big)+f(3n-1)\\ &=4f(3n)+f(3n-1)-f(3n-2)\\ &=4f(3n)+f(3n-3)\;. \end{align*}

However, I didn’t arrive at this systematically; it just ‘popped out’ as I worked at eliminating terms with unwanted indices.

Added: Here’s a systematic approach, but I worked it out after the fact.

The generating function for the Fibonacci numbers is $$g(x)=\frac{x}{1-x-x^2}=\frac1{\sqrt5}\left(\frac1{1-\varphi x}-\frac1{1-\hat\varphi x}\right)\;,$$ where $\varphi = \frac12(1+\sqrt5)$ and $\hat\varphi=\frac12(1-\sqrt5)$, so that $f(n)=\frac1{\sqrt5}(\varphi^n-\hat\varphi^n)$. Thus, $f(3n)=\frac1{\sqrt5}(\varphi^{3n}-\hat\varphi^{3n})$. Thus, we want

\begin{align*} h(x)&=\frac1{\sqrt5}\sum_{n\ge 0}(\varphi^{3n}-\hat\varphi^{3n})x^n\\ &=\frac1{\sqrt5}\left(\sum_{n\ge 0}\varphi^{3n}x^n-\sum_{n\ge 0}\hat\varphi^{3n}x^n\right)\\ &=\frac1{\sqrt5}\left(\frac1{1-\varphi^3 x}-\frac1{1-\hat\varphi^3 x}\right)\\ &=\frac1{\sqrt5}\cdot\frac{(\varphi^3-\hat\varphi^3)x}{1-(\varphi^3+\hat\varphi^3)x+(\varphi\hat\varphi)^3x^2}\;. \end{align*}

Now $\varphi+\hat\varphi=1$, $\varphi-\hat\varphi=\sqrt5$, $\varphi\hat\varphi=-1$, $\varphi^2=\varphi+1$, and $\hat\varphi^2=\hat\varphi+1$, so

\begin{align*} h(x)&=\frac1{\sqrt5}\cdot\frac{(\varphi^3-\hat\varphi^3)x}{1-(\varphi^3+\hat\varphi^3)x+(\varphi\hat\varphi)^3x^2}\\ &=\frac{(\varphi^2+\varphi\hat\varphi+\hat\varphi^2)x}{1-(\varphi^2-\varphi\hat\varphi)x-x^2}\\ &=\frac{(\varphi^2-1+\hat\varphi^2)x}{1-(\varphi^2+1+\hat\varphi^2)x-x^2}\\ &=\frac{(\varphi+\hat\varphi+1)x}{1-(\varphi+3+\hat\varphi)x-x^2}\\ &=\frac{2x}{1-4x-x^2}\;. \end{align*}

It follows that $(1-4x-x^2)h(x)=2x$ and hence that $h(x)=4xh(x)+x^2h(x)+2x$. Since the coefficient of $x^n$ in $h(x)$ is $f(3n)$, this tells me that

\begin{align*} \sum_{n\ge 0}f(3n)x^n&=h(x)=4xh(x)+x^2h(x)+2x\\ &=\sum_{n\ge 0}4f(3n)x^{n+1}+\sum_{n\ge 0}f(3n)x^{n+2}+2x\\ &=\sum_{n\ge 1}4f(3n-3)x^n+\sum_{n\ge 2}f(3n-6)x^n+2x\;, \end{align*}

which by equating coefficients immediately implies that $f(3n)=4f(3n-3)+f(3n-6)$ for $n\ge 2$. It also gets the initial conditions right: the constant term on the righthand side is $0$, and indeed $f(3\cdot 0)=0$, and the coefficient of $x$ is $4f(0)+2=2=f(3)$, as it should be.

-

Actually the "Magic Trick" or "Reverse Engineering" idea works nicely.

First, as André pointed

$$f_{3n}=\frac{\alpha^{3n}+\beta^{3n}}{\sqrt{5}} \,.$$

This means that if $(x-\alpha^{3})(x-\beta^3)=x^2-Ax-B$ then $f_{3n}$ is the recurrence satisfying

$$x_{n+2}=Ax_{n+1}+Bx_{n} \, x_{0}=f_0, x_1=f_{3} \,.$$

Thus,

$$f_6=Af_3+Bf_0$$ $$f_9=Af_6+Bf_3$$

Solve it and get $A,B$.

-

Let $S$ be the shift operator on sequences (as in Bill Dubuque's answer). Note that the Fibonacci sequence is killed by $S^2-S-1$. The Fibonacci sequence will then be killed by any "polynomial" multiple of $S^2-S-1$. To get a recurrence for every $k^{\rm{th}}$ term, all we need to do is find a multiple of $S^2-S-1$ that only involves powers of $S^k$.

First note that $S^2-S-1=(S-a)(S-b)$ where $a=\phi$ (the golden ratio) and $b=-1/\phi$. Consider the operator $(S^k-a^k)(S^k-b^k)=S^{2k}-(a^k+b^k)S^k+(ab)^k$. It is a polynomial multiple of $S^2-S-1$, so it kills the Fibonacci sequence. It only involves powers of $S^k$.

Recall that one formula for the $k^{\rm{th}}$ Lucas number is $L_k=a^k+b^k$, and note that $ab=-1$. Thus, we get that $S^{2k}-L_kS^k+(-1)^k$ kills the Fibonacci sequence.

Therefore, in summary, we get $$F_{n+2k}=L_kF_{n+k}-(-1)^kF_n\tag{1}$$ For example, $$F_{n+2}=F_{n+1}+F_n\tag{k=1}$$ $$F_{n+4}=3F_{n+2}-F_n\tag{k=2}$$ $$F_{n+6}=4F_{n+3}+F_n\tag{k=3}$$ $$F_{n+8}=7F_{n+4}-F_n\tag{k=4}$$ $$F_{n+10}=11F_{n+5}+F_n\tag{k=5}$$

-

We can write linear recurrence relations in terms of matrix multiplication like so:

$$F_{n+2} = \left[ \begin{array}{cc} 1 & 1 \end{array} \right] \left[ \begin{array}{cc} F_n \\ F_{n+1} \end{array} \right] = 1 \cdot F_n + 1 \cdot F_{n+1}.$$

Now if the sequence 0,2,8,34,144,610,2584,10946,... is called $G_n$, let's make the unjustified assumption that it is also a second order recurrence relation, then not only would we have

$$G_{n+2} = \left[ \begin{array}{cc} c_1 & c_2 \end{array} \right] \left[ \begin{array}{cc} G_n \\ G_{n+1} \end{array} \right]$$

for some unknowns $c_1$ and $c_2$, but also we can collect several instances of the above identity together into one e.g.

$$\left[ \begin{array}{cc} 34 & 144 \end{array} \right] = \left[ \begin{array}{cc} c_1 & c_2 \end{array} \right] \left[ \begin{array}{cc} 2 & 8 \\ 8 & 34 \end{array} \right]$$

and we can solve this using PARI/GP like so:

? [34,144]/[2,8;8,34]
% = [1, 4]

Therefore $G_{n+2} = 1 \cdot G_n + 4 \cdot G_{n+1}$.

About the assumption, it can be proved in general based on the ideas of characteristic function which you have seen in most of the answers. Given that, there is no need for any induction proofs or anything. Just computing the vector completes the proof of $G_{n+2} = 1 \cdot G_n + 4 \cdot G_{n+1}$.

-
Here's an interesting identity involving Lucas and Fibonacci numbers: $$\begin{pmatrix}\ell_k&(-1)^{k+1}\\1&0\end{pmatrix}=\begin{pmatrix}f_k&f_{k-1}\\0&1\end{pmatrix}\cdot\begin{pmatrix}1&1\\1&0\end{pmatrix}^k \cdot\begin{pmatrix} f_k&f_{k-1}\\0&1\end{pmatrix}^{-1}$$ –  Guess who it is. Dec 28 '11 at 15:21

It is easy by operator algebra. Let the Shift, Triple $\mathbb C$-linear operators $\rm\ S\:n\: :=\: n+1,\ \ T\:n\: :=\: 3\:n\:$ act on fibonacci's numbers by $\rm\ S\:f(a\:n+b) = f(a\:(n+1)+b)\$ and $\rm\ T\:f(a\:n+b) = f(3\:a\:n+b)\:.$ Below I show a general method that works for any Lucas sequence $\rm\:f(n)\:$ that involves only simple high-school polynomial arithmetic (albeit noncommutative). Namely, one employs a commutation rule $\rm\: TS\:\to\: (a\ S + b)\ T\$ to shift $\rm\:T\:$ past powers of $\rm\:S\:,\:$ in order to transmute the known recurrence $\rm\ q(S)\ f(n)\: =\: 0\$ into $\rm\ \bar{q}(S)\:T\:f(n)\:=\:0\:,\$ the sought recurrence for $\rm\ T\:f(n)\: =\: f(3\:n)\:.\:$

We know $\rm\ q(S)\ f(n) := (S^2 - S - 1)\ f(n)\: =\: f(n+2) - f(n+1) - f(n)\: =\: 0\:.\:$ We seek an analogous recurrence $\rm\ \bar{q}(S)\ T\: f(n)\ =\ 0\$ for $\rm\ T\:f(n) = f(3\:n)\:,\:$ and some polynomial $\rm\:\bar{q}(S)\:.\:$ Since clearly we have that $\rm\ T\:q(S)\ f(n)\: =\: 0\:,\:$ it suffices to somehow transmute this equation by shifting $\rm\:T\:$ past $\rm\:q(S)\:$ to yield $\rm\:\bar{q}(S)\:T\:f(n)\:=\:0\:.\:$ To do this, it suffices to find some commutation identity $\rm T\:S\: =\: r(S)\: T\$ to enable us to shift $\rm\:T\:$ past $\rm\:S$'s in each monomial $\rm\ S^{\:i}\: f(n)\: =\: f(n+i)\:$ from $\rm\:q(S)\:.\:$ The sought commutation identity arises very simply: iterate the recurrence for $\rm\:f(n)\:$ so to rewrite

$\rm\ ST\ f(n)\ =\ f(3\:n+3)\$ as a linear combination of $\rm\ f(3\:n+1) = TS\ f(n)\:,\:$ $\rm\ f(3\:n) = T\ f(n)\:,\:$ viz.

$\rm\ \ \ ST\ f(n+i)\ =\ f(3n+3+i)\ =\ f(3n+2+i) + f(3n+1+i)\ =\ 2\ f(3n+1+i) + f(3n+i)$

$\rm\ \ \ \phantom{ST\ f(n+i)}\ =\ (2\:TS+T)\ f(n+i)\quad$ for all $\rm\:i\in \mathbb Z\:$

$\rm\ 2\:TS\ f(n+i)\ =\ (S-1)\:T\ f(n+i)\:,\$ i.e. $\rm\ 2\:TS\ =\ (S-1)\:T\:,\$ the sought commutation identity.

Thus $\rm\qquad\quad\:\ 0\ =\ 4\: T\: (S^2 - S - 1)\ f(n)\$

$\rm\qquad\qquad\qquad\quad\ \ =\ (2\:(2TS)S - 2\:(2TS) - 4\:T)\ f(n)$

$\rm\qquad\qquad\qquad\quad\ \ =\ ((S-1)\:2TS - 2\:(S-1)\:T - 4\:T)\ f(n)$

$\rm\qquad\qquad\qquad\quad\ \ =\ ((S-1)^2 - 2\:(S-1)\: - 4)\ T\: f(n)$

$\rm\qquad\qquad\qquad\quad\ \ =\ (S^2 - 4\ S - 1)\ T\: f(n)$

$\quad$ i.e. $\rm\qquad\quad\: 0\ =\ f(3(n+2)) - 4\ f(3(n+1)) - f(3\:n)\qquad$ QED

NOTE $\$ Precisely the same method works for any Lucas sequence $\rm\:f(n)\:,\:$ i.e. any solution of $\rm\ 0\ =\ (S^2 + b\ S + c)\ f(n)\ =\ f(n+2) + b\ f(n+1) + c\ f(n)\$ for constants $\rm\:b,\:c\:,\:$ and for any multiplication operator $\rm\:T\:n = k\ n\:$ for $\rm\:k\in \mathbb N\:.\:$ As above, we obtain a commutation identity by iterating the recurrence (or powering its companion matrix), in order to rewrite

$\rm\ ST\ f(n)\ =\ f(k\:n+k)\$ as a $\rm\:\mathbb C$-linear combination of $\rm\ f(kn+1) = TS\ f(n)\$ and $\rm\ f(kn) = T\ f(n)\:$

say $\rm\ \ ST\ f(n)\ =\ f(k\:n+k)\ =\ a\ f(k\:n+1) + d\ f(k\:n)\ =\ (a\ TS + d\ T)\ f(n)\ \$ for some $\rm\:a,d\in \mathbb C$

$\rm\:\Rightarrow\ a\ TS\ f(n) =\ (S-d)\ T\ f(n)\ \Rightarrow\ a\ TS\ =\ (S-d)\ T\$ on $\rm\ S^{\:i}\: f(n)\$ as above.

Again, this enables us to transmute the recurrence for $\rm\:f(n)\:$ into one for $\rm\:T\:f(n) = f(k\:n)\:$ by simply commuting $\rm\:T\:$ past all $\rm\:S^i\:$ terms. Hence the solution involves only simple polynomial arithmetic (but, alas, the notation obscures the utter simplicity of the method).

-


# Proof Verification: If $A \subset B$ and $B \subset C$, then $A \cup B \subset C$

I am trying to prove that:

If $A \subset B$ and $B \subset C$, then $A \cup B \subset C$

My proof is : Given some $x \in A \cup B$, it is true that either $x \in A$ and/or $x \in B$. IN the case that $x \in A$ it is true that $x \in B$, as $A \subset B$, and that $x \in C$ , as $B \subset C$. In the case that $x \in B$ it is true that $x \in C$, as $B \subset C$. Therefore, $A\cup B \subset C$

Is this correct?. Any tips to improve this would be appreciated as I am self taught and new to proof writing.

• Yes, it is correct. You could also prove that $A \cup B = B$, and then the fact follows from $B = A \cup B \subset C$. – астон вілла олоф мэллбэрг Aug 8 '18 at 15:14
• Your proof is totally correct. Just be careful about the use of English: it is better to say "Given some $x \in A \cup B$, it is true that $x \in A$ or $x \in B$". Do not use "either" and "and" unnecessarily as it may make your statement confusing. In maths, the word "or" means : either the first case only, either the second only, either both cases at the same time. – Suzet Aug 8 '18 at 15:16
• @астонвіллаолофмэллбэрг Thank you – Ewan Miller Aug 8 '18 at 15:16
• @Suzet Ok thank you – Ewan Miller Aug 8 '18 at 15:17
• It's totally correct, although there's an alternative way. Since $A \subset B$, $A \cup B= B$. Now from $B \subset C$, the result follows. – Anik Bhowmick Aug 8 '18 at 15:32

Just to answer : yes, the approach is correct.

You could also prove that $A∪B=B$, and then the fact follows from $B=A∪B\subset C$.

For example, if $x \in B$ is true, then of course $x$ is in $A$ or $x$ is in $B$ is true, so $B \subset A \cup B$. If $x \in A$, then $x \in B$ because $A \subset B$, and if $x \in B$, then of course $x \in B$, so $A \cup B \subset B$, hence $A \cup B = B$.

Another approach is by using Venn diagrams. Draw circles $A$, $B$ and $C$ for three sets such that $A$ is contained in $B$ and $B$ is contained in $C$ (according to given set inclusions). So you have $A$ as the innermost, $B$ in the middle and $C$ as the outermost of them. Now $A\cup B$ is given by the middle circle which is offcourse contained in $C$ (the outer circle).

Is this correct?

I believe that your proof regarding this Question is correct.

Any tips to improve this would be appreciated as I am self-taught and new to proof writing.

Set Theory which you are using (Elementary-Set Theory) was mostly Contributed for its Development by George Cantor. But, in Later Stage, there are some famous Loopholes found in this Theory, the most popular of them is Russel's Paradox. After Russel's paradox, numerous other Paradox came after which ZFC Set Theory (Zermelo Franklin Set Theory) came which is based on some of the Basic Set Axioms (Related to Mathematical Logic)

## Proofs in Set Theory

Most of the Proofs in Elementary Set Theory is based on Mathematical Logic. Some of the Basic Theorems and Properties are below -

1. De Morgan's Theorem -https://en.wikipedia.org/wiki/De_Morgan%27s_laws
2. Complement - https://en.wikipedia.org/wiki/Complement_(set_theory) $A^` = U - A$
3. Intersection and Union -

## Alternate Methods to Proof Set Theory Question

Your Question Can be Proved Using Venn Diagram too like here -

• Using The Laws and Properties of Sets (Intersection, Complement and Union)

The most natural way seems to be:

1. (Transitivity) From $A \subset B$ and $B \subset C$, show $A \subset C$.

If $x \in A$, then $x \in B$.
If $x \in B$, then $x \in C$.
Thus if $x \in A$, then $x \in C$.

1. From $A \subset C$ and $B \subset C$, show $(A \cup B) \subset C$.

If $x \in (A \cup B)$, then $x \in A$ or $x \in B$.
But if $x \in A$, then $x \in C$, and if $x \in B$, then $x \in C$.
Thus, either way, $x \in C$.

You implicitly used this method in your (correct) proof, but you didn't separate out the ideas. It can be especially useful to organise larger proofs in terms of simpler definitions, lemmas and theorems.


Math Help - Simultaneous Equations

1. Simultaneous Equations

I don't usually have any problem with simultaneous equations but whilst revising for a test, I came across two types that I haven't seen before and the book I have only gives answers but no explanations of how it got those answers. I've tried in various ways... but my answers never seem to match up.

Could anyone solve these two simultaneous equations step-by-step so I could see how it's done?

Q1)
$y = 1 - 4x$
$y = -4x^2$

Q2)
$xy = 9$
$x - 2y = 3$

If anyone could I would really appreciate it, thanks. And Hi to everyone on the forum - just found this forum and it looks great.

2. Hello, PaulSelb!

Welcome aboard!

These are not linear equations.
. . The recommended method is Substitution.

$1)\;\;\begin{array}{cccc}y &=& 1 - 4x &{\color{blue}[1]} \\
y &= &-4x^2& {\color{blue}[2]}\end{array}$

Equation [1] is already solved for $y\!:\;\;y \:=\:1-4x$

Substitute into [2]: . $1 - 4x \:=\:-4x^2 \quad\Rightarrow\quad 4x^2 - 4x + 1 \:=\:0$

. . $(2x-1)^2 \:=\:0 \quad\Rightarrow\quad 2x-1 \:=\:0 \quad\Rightarrow\quad x \:=\:\frac{1}{2}$

Substitute into [1]: . $y \:=\:1 - 4\left(\frac{1}{2}\right) \:=\:-1$

Solution: . $x \:=\:\frac{1}{2},\;y \:=\:-1$

$2);\;\begin{array}{cccc}xy &=& 9 & {\color{blue}[1]} \\
x - 2y &=& 3 & {\color{blue}[2]}\end{array}$

Solve [2] for $x\!:\;\;x \:=\:2y+3\;\;{\color{blue}[3]}$

Substitute into [1]: . $(2y+3)y \:=\:9 \quad\Rightarrow\quad 2y^2 + 3y - 9 \:=\:0$

Factor: . $(2y - 3)(y + 3)\:=\:0\quad\Rightarrow\quad y \:=\:\frac{3}{2},\;-3$

Substitute into [3]: . $\begin{Bmatrix}x &=& 2\left(\frac{3}{2}\right) + 3 & = & 6 \\ \\[-3mm] x &=&2(-3) + 3 &=&-3 \end{Bmatrix}$

Solutions: . $(x,y) \;=\;\left(6,\:\frac{3}{2}\right),\;(-3,\:-3)$

3. Thanks, great explanation . Got my test in a few hours so hopefully if one of these questions turns up I shouldn't have any problems.

4. I had a slightly different type in the exam the other day (possibly solved in the same way)... but I got it wrong

If anyone reads this thread again could you let me know how to solve this one?

$k(k - m) = 12$
$k(k + m) = 60$

Sorry for the easy stupid questions, I really enjoy math and want to understand bits more!

EDIT: I think I did it may have done it actually...

$k^2 - km = 12$
$k^2 + km = 60$
$k+m = \frac{60}{k}$
$m = \frac{60}{k} - k$

$k^2 - k(\frac{60}{k} - k) = 12$

$2k^2 - 60 = 12$

$2k^2 - 72 = 0$

$(2k - 12)(k + 6) = 0$

$k = \pm 6$

$36 + \pm6(m) = 60$

$m = \frac{24}{\pm6}$

$m = \pm 4$

I think that's about right anyway...


# Simulating order statistics

I am having a problem with the density of the first order statistic of a series of n random variables iid with common distribution (standard normal).

I am using Arnold's book as a reference for such a density function for the k'th order stat: $$f_{X_{k:n}}(x) = \frac{n!}{k-1! (n-k)!} F(x)^{k-1} (1-F(x))^{n-k} f(x).$$

The I simulate data in R store the min and compare the obtained empirical distribution against the theoretical function. These curves diverge substantially.

What am I doing wrong? or missing?

# Distribution
Fx <- function(x) pnorm(x)
fx <- function(x) dnorm(x)

n <- 10
# ATTENTION: 6M simulation may take some time
z <- replicate(1e6, min(rnorm(n)))

# Probabiltiy z > y

prob <- function(x) {
sapply(x, function(u) mean(z>u))
}

# Density
fos_k <- function(x, n, k) {
fact <- factorial(n) / (factorial(k-1) * factorial(n-k))
fact * fx(x) * Fx(x)^(k-1) *(1-Fx(x))^(n-k)
}

curve(fos_k(x, n=n, k=1), from=-1, to=1)
curve(prob, add=T, col=2, from=-1, to=1)

• The "observed empirical distribution" is not the density. One way to plot the observed density is to approximate it with a KDE and plot that. – whuber Oct 21 '16 at 19:29
• @Xi'an could you please clarify – mrb Oct 21 '16 at 20:44
• Compare your equation to the second line of fos_k: your equation omits the term you have coded as fx(x). But that's only an error of exposition; the error in your code lies in prob, which is not a density function. – whuber Oct 21 '16 at 21:40
• For what it's worth, here's the computation done in a single line in Mathematica: Show[Histogram[ParallelTable[Min[RandomVariate[NormalDistribution[0, 1], 10]], {10^6}], {0.1}, "PDF"], Plot[Evaluate[PDF[OrderDistribution[{NormalDistribution[0, 1], 10}, 1], z]], {z, -4, 1}]] On my machine, the runtime is less than 1 second. – heropup Oct 21 '16 at 22:08
• Thanks to everyone. @whuber is right. @whuber would you like to go on and reply to this question with an example of your R code? – mrb Oct 22 '16 at 1:54

Although the problem is primarily with R code, it raises issues we would have to confront in any statistical computing environment. This reply focuses on those general issues.

A correct formula for the density of the $k^\text{th}$ smallest of $n$ independent identically distributed (iid) values from a distribution $F$ with density $f$ is presented in my answer at https://stats.stackexchange.com/a/225990/919. It is

$$f_{[k]}(x) = \frac{n!}{(k-1)!(1)!(n-k)!} F(x)^{k-1} (1-F(x))^{n-k} f(x).\tag{1}$$

Because factorials and potentially high powers are combined, it is numerically better to compute its logarithm as

\eqalign{ \log f_{[k]}(x) = &\log n! - \log(k-1)! - \log(n-k)! + \\&(k-1)\log F(x) + (n-k) \log(1-F(x)) + \log f(x).\tag{2} }

Furthermore, because order statistics provide a way to peer far out into the tails of the distribution, where values grow close to $1$ and $0$, it is best to compute $1-F(x)$ directly rather than subtracting $F(x)$ from $1$.

With these caveats in mind, the other issue in this thread concerns graphing an empirical density. The commonest way to do so is with a histogram: it looks like a barplot in which the bar areas (not heights!) are proportional to the relative frequencies of the data.

To illustrate these two main points, I wrote a quick solution in R that simulates many iid samples, extracts specified order statistics from each, plots the histogram of each order statistic, and overplots the density function $(1)$ computed by exponentiating the logarithm $(2)$. Here is an example of its output applied to samples of size $10$ from a standard Normal distribution and of size $25$ from a Gamma$(3/2,5)$ distribution.

Clearly the agreement between the empirical results (the histogram bars) and the theoretical formula (the colored curves) is good.

This code applies the preceding suggestions about numerical computation by exploiting the log.p, log, and lower.tail arguments that are standard in the families of R distribution functions.

f <- function(n.sim, n, k=1:n, p=pnorm, d=dnorm, r=rnorm, name, ...) {
if (missing(name)) name <- ""
k <- sort(unique(k))[1 <= k & k <= n]

# Perform the simulation.
sim <- apply(matrix(r(n.sim*n, ...), nrow=n), 2, sort)[k, , drop=FALSE]

# Plot the requested order statistics.
for (i in 1:length(k)) {

# Define a function to plot the density of an order statistic.
dord <- function(x, k, n, ...) {
z <- lfactorial(n) - lfactorial(k-1) - lfactorial(n-k) +
(k-1)*p(x, log.p=TRUE, ...) +
(n-k)*p(x, log.p=TRUE, lower.tail=FALSE, ...) +
d(x, log=TRUE, ...)
return(exp(z))
}

# Plot the empirical distribution.
hist(sim[i, ], freq=FALSE,
xlab="Value",
sub=paste(n.sim, "iterations with sample size", n),
main=paste(name, "order statistic", k[i]))

# Overplot the theoretical density.
curve(dord(x, k[i], n, ...), add=TRUE, col=hsv(runif(1), 0.8, 0.7), lwd=2)
}
}
#
# Set up to simulate and display the results.
#
par(mfrow=c(2,4))
n.sim <- 1e4
set.seed(17)

# Study Normal order statistics.
f(n.sim, 10, c(1,3,5,9), name="Normal(0,1)")

# Study Gamma order statistics.
# This illustrates how to use f for general distributions.
f(n.sim, 25, c(2, 4, 16, 24), name="Gamma(1.5,5)",
p=pgamma, d=dgamma, r=rgamma, shape=1.5, scale=5)

• Wondering should use the logarithm to define the corresponding distribution function as well? Since F(x) can be zero I would avoid the log. – mrb Oct 24 '16 at 13:03
• That's a good observation, but it happens not be be relevant because almost surely $F$ will be positive at any value you have randomly generated. Regardless, good software will deal with this correctly (provided you actually ask it to compute the log of $F$ directly rather than asking it to take the log of $0$!). For instance, the R procedures will return -Inf for the logarithm in that case; and that value, when exponentiated, will be exactly $0$. Here is an example: exp(punif(-2, log.p=TRUE)) – whuber Oct 24 '16 at 13:41


No, you need to divide by $\displaystyle 12^3$...essentially a 12 for each of the 3 spatial dimensions.

$\displaystyle 7128\text{ in}^3\cdot\left(\frac{1\text{ ft}}{12\text{ in}} \right)^3=\frac{7128}{12^3}\,\text{ft}^3=156.75 \text{ ft}^3$

Oh, ok that makes since. So for part 5 would I use the formula 1/2*b*h so 1/2*(99)*(104) = 5148 in^2

No, you have a trapezoid, not a triangle. You want to use:

$\displaystyle A=\frac{h}{2}(B+b)$

where:

$\displaystyle h=99$

$\displaystyle B=104$

$\displaystyle b=32$

O.k., sorry for not getting this right away, thanks for your patience lol.
So the answer would then be 6732

An impatient person has no business trying to help on a forum. You are doing fine.

Yes, that is the correct answer. Now, in order to find this area using integration, I recommend orienting your coordinate axes such that the origin is at the bottom corner under the lowest point of the ceiling. We will then want to write the upper slanting edge of the wall as a linear function. What would the y-intercept and the slope be?

Would the slope be 8 and the y-intercept 32?

You have the correct intercept, but for the slope, think of the rise over run of an individual step.

ok so the slope would be 8/11?

Yes, good work! So, what would the linear function representing the slanted edge be?

(8/11)x+32?

Exactly! Now, over what interval do you want to integrate?

Would it be from 5 to 13?

and if that is the interval would it be:
(4/11)x^2+32x evaluated from 5 to 13= 308.364