# Probability of an event after time has passed

A friend of mine posed this problem and we have had a disagreement on the answer.

The problem:

• There is a 90% chance that some event will happen in the next year.
• There is a 95% chance that the event will happen eventually.
• What is the probability that it happens after this year, if it does not happen in the next year?

Hover over here for a description of our answers and arguments:

I told my friend that it is 95%. My reasoning is that there is a 95% chance that it happens from now to infinity. The probability that it happens from now to infinity minus one year is still 95%. In one year, when it hasn't happened, events that didn't happen don't affect your "eventual" odds.

My friend on the other hand, believes it to be 50%. He had two arguments. First, he said if you flip a coin 4 times, the chance that you get heads the first time is 50%, but the chance that you get heads eventually is 93.75% (15/16). If you don't get it the first time, what is the chance that you get it after the first time? 87.5% (7/8), in other words, it has decreased.

To this I responded that the "eventually" is based on a finite set of events, each with their own probability and after the first event has passed, you have fewer chances. In his problem, on the other hand, it is a summary of the probability of unknown events broken in two time periods.

He continued to insist that it is the same because you have two time periods with known odds. The 95% is the combination of two probabilities, 90% and 50%. Eliminating the first 90%, the probability of the remaining period is 50%.

I agreed that's an accurate way to look at it from now, but I don't think that's accurate once you know it did not happen in that time period.

-

Let's use Bayes' Theorem: $$P(A|B)=\frac{P(B|A) P(A)}{P(B)}.$$ In our case, $B$ is the event whatnot does not occur in year 1 (so with probability $P(B)=.1$, and $A$ is the event whatnot occurs at some point (so with probability $P(A)=0.95$). Of course, $P(B|A)$ is the only thing left to determine, but notice that $P(A|not(B))=1$ since if whatnot occurs in year 1, then it occurs at some point. Therefore, again by Bayes' Theorem $$P(not(B)|A)=\frac{P(A|not(B)) P(not(B))}{P(A)}=\frac{90}{95}.$$ Since $P(not(B)|A)+P(B|A)=1$, we have that $P(B|A)=\frac{5}{95}$. Hence plugging this all in, we find $$P(A|B)=\frac{\frac{5}{95} \frac{95}{100}}{\frac{10}{100}}=\frac{1}{2}.$$ So it looks like your friend was right!

-

Calculate it this way. Given that the probability that it occurs during or after year 2 is $x$%. And the probability it occurs in year 1 is 90%, what is the probability it occurs?

Now, consider $x=0$, then the probability the event occurs is 90%.

If $x=50$, then it is 95%. (because it is $0.9 \times 1 + 0.1 \times 0.5 \times 1= 0.95$)

This informal argument should convince you.

-

After talking about it some more, we came up with this scenario which illustrates why he is correct, and I am wrong.

1. Say I want to give him a 90% chance that he will get $100 this year, 95% chance total, and 5% chance that he gets nothing. 2. So, I take 100 sheets of paper and write dates in the next year on 90 of them, dates after that on 5, and "Bad luck" on the other 5. 3. I draw one at random and keep it a secret. 4. A year passes and my friend got nothing. Now he knows that all 90 dates this year are still in the pile. He now knows I must hold one of the other 10 sheets. That makes a 5/10 chance that I have a sheet with a date on it, and 5/10 chance that the sheet I hold has "Bad luck" on it. 50% chance he will get$100.

-
Nice. Beats Bayes. –  André Nicolas Jan 18 '13 at 21:15

Let $A$ represent the cases in which the event happens eventually. Let $B$ represent the cases in which the event happens next year. You've stipulated $P(A)=0.95$ and $P(B)=0.90$. Because $B$ is a subset of $A$, $P(A\cap B)=P(B)=0.90$, and $$P(A\cap \neg B)=P(A)-P(A\cap B)=0.95-0.90=0.05.$$ By the definition of conditional probability, then, $$P(A|\neg B)=\frac{P(A\cap \neg B)}{P(\neg B)}=\frac{0.05}{0.10}=\frac{1}{2}.$$ So if I propose a deal right now, under the terms of which (a) you'll put in $\$1000$if the event hasn't happened after one year and (b) you'll get back$X$if the event happens after next year, then you should take the deal if$X>\$2000$. In this sense, your friend is right.

Your point, though, is different. You're wondering what deal you should take a year from now if the event hasn't happened by then. The answer is that it depends on probabilities not stipulated in the problem. In particular, you may learn something from the fact that it didn't happen this year, which may raise or lower these odds.

Suppose the event is the earth being hit by a meteor, that this depends on the solar system's meteor density, and that we're building a meteor shield that will be operational in just over a year. Based on what we know now, the meteor density might be high or low, with equal likelihood; if it's high, then the earth will be hit in the next year with probability $1$ (no shield yet!); if it's low, then the earth will be hit next year with probability $0.8$ and eventually with probability $0.9$. A year from now, if the earth hasn't been hit yet, you will know that the meteor density is low, and that the remaining probability that we'll ever be hit is $0.1$. In this case, the odds were lowered.

On the other hand, the choice may be between cases where the event will happen in either eighteen months with certainty (so next year with probability $0$ and eventually with probability $1$), or at some indeterminate time (next year with probability $0.9/(1-\varepsilon)$ and eventually with probability $(0.95-\varepsilon)/(1-\varepsilon)$), based on some unknown variable that might point to the first case (with probability $\varepsilon$) but almost surely points to the second (with probability $1-\varepsilon$). Here, a year from now you'll be much more likely to believe that the unknown variable is pointing to the first case, which will increase the odds that the event is still forthcoming.

-

There could be slight issue with the phrasing of the problem. Your interpretation is that the statement is true no matter what time period you are in. I.e. in 5 years time, there is still a 90% chance that some event will happen in that year. However, you're forgetting to account for the fact that the event didn't happen in the first year.

Your friend's interpretation, is that your statement is true for this year. He has ignored the probability space in which the event occurred this year, and considered the remaining probability space. This now has measure $1-0.9=0.1$, and we know that the event has $0.95 - 0.9 = 0.05$ measure to occur, so it has $\frac {0.05}{0.1} = 50\%$ chance to happen.

For example, consider the event where outcomes are based on drawing a uniform random variable on $[0,1]$. Let $C$ be your favorite number from 0 to 0.9.

If we draw a number from 0 to 0.9, the event happens this year.
If we draw a number from $X$ to 0.95, the event happens next year.
If we draw a number from 0.95 to 1, the event never happens.

A possible scenario describing your interpretation, could be

If we draw a number from 0 to 0.9, the event happens every even year.
If we draw a number from 0.05 to 0.95, the event happens every odd year.
If we draw a number from 0.95 to 1, the event never happens.

Then, it will always be true, that there is a 90% chance of it happening this year, and a 95% chance of it happening eventually. However, not that if we know it doesn't happen in this year (doesn't matter whether it's even or odd), then there's only a 50% chance that it will ever happen again.

-
Thanks for the alternate scenario, that's interesting. This is the kind of thing that made me feel like it's hard to guarantee an answer in the first place. –  NickC Jan 18 '13 at 21:25
@NickC The hard part is considering completely what it means for an event to not occur. You should look at this recent post, which had a lot of different answers initially. –  Calvin Lin Jan 18 '13 at 21:29

In case the mathematical proof already mentioned above isn't enough to convince you, pretend you're a statistician collecting your own results. You have 100 people infected with a disease that has a 95% death rate and a 90% death rate in the first year. Year one is finished, 90 dead, as predicted. 10 people left. We know 95% will be dead at some point. How many more are likely to die if the odds hold true? 5/10. Chances once the first year has passed is 50%. You don't need to be a statistician to see that. It has nothing to do with a finite number of events or an infinite time frame. That part has already been calculated for us in the given 95%.

-

The analysis for this appears to be relatively straightforward. Assume the probability of event in year 2+ is $x$. Next, the probability that the event does not occur in the first year is $0.1$ and that it does not occur any time thereafter is $(1-x)$. The product of the two is the probability that the event never happens, which we know to be $0.05$. So,

$0.1 \times (1-x) = 0.05$

solving for x yields $x=\frac{1}{2}$

-


crossoverman9b

2022-06-20

Changing base of a logarithm by taking a square root from base?
From my homework I found
${\mathrm{log}}_{9}x={\mathrm{log}}_{3}\sqrt{x}$
and besides that an explanation that to this was done by taking a square root of the base. I fail to grasp this completely. Should I need to turn ${\mathrm{log}}_{9}x$ into base 3, I'd do something like
${\mathrm{log}}_{9}x=\frac{{\mathrm{log}}_{3}x}{{\mathrm{log}}_{3}9}=\frac{{\mathrm{log}}_{3}x}{{\mathrm{log}}_{3}{3}^{2}}=\frac{{\mathrm{log}}_{3}x}{2}$
but this is a far cry from what I've given as being the correct answer.
Substituting some values to x and playing with my calculator I can see that the answer given as correct is correct whereas my attempt fails to yield the correct answer.
Now the question is, what are correct steps to derive ${\mathrm{log}}_{3}\sqrt{x}$ from ${\mathrm{log}}_{9}x$? How and why am I allowed to take a square root of the base and the exponent?

mallol3i

You are only one step away!
Note that $a\mathrm{log}b=\mathrm{log}{b}^{a}$, so
$\frac{{\mathrm{log}}_{3}x}{2}=\frac{1}{2}{\mathrm{log}}_{3}x={\mathrm{log}}_{3}{x}^{1/2}={\mathrm{log}}_{3}\sqrt{x}.$

Yesenia Sherman


# Probability a person chosen at random owns an automobile or a house, but not both

A marketing survey indicates that $60\%$ of the population owns an automobile, $30\%$ owns a house, and $20\%$ owns both an automobile and a house. Calculate the probability that a person chosen at random owns an automobile or a house, but not both.

(A) $0.4$

(B) $0.5$

(C) $0.6$

(D) $0.7$

(E) $0.9$

So the answer given for this question is $0.5$, but it doesn't make sense to me from the perspective of addition rule in probability. If we know that $\Pr(\text{Owning Automobile}) = 0.6$ and the $\Pr(\text{Owning a House}) = 0.3$ and the $\Pr(\text{Owning both an automobile and a house}) = 0.2$, according to the formula probability of $\Pr(A)~\text{or}~\Pr(B) = \Pr(A) + \Pr(B) - \Pr(A~\text{and}~B)$, wouldn't the answer be $0.6+0.3-0.2=0.7$?

Is it because the ordering matters? so the last term $\Pr(A~\text{and}~B) = 2 \cdot 0.2$?

• You computed the probability of "owning an automobile or a house." They asked for the probability of "owning an automobile or a house but not both." – angryavian May 30 '18 at 6:16
• @angryavian I still don't get it, I thought "owning an automobile or a house" is the same as "owning an automobile or a house but not both" ?? – pino231 May 30 '18 at 6:20
• Please type your question rather than posting an image. Images cannot be searched. – N. F. Taussig May 30 '18 at 8:54
• @pino231, in fact "owning an automobile or a house" in this case means "owning an automobile, or a house, or both". This usage of the word "or" -- the so-called "inclusive or" -- is standard in mathematics. If we want the opposite (the exclusive or) it is almost always explicitly stated, as it is in your question. – Mees de Vries May 30 '18 at 9:26

Let event $A$ be owning an automobile. Let event $B$ be owning a house.

Consider the diagram below:

If we simply add the probabilities that a person owns an automobile and a person owns a house, we will have added the probability that a person owns both an automobile and a house twice. Thus, to find the probability that a person owns an automobile or a house, we must subtract the probability that a person owns both an automobile and a house from the sum of the probabilities that a person owns an automobile and that a person owns a house.

$$\Pr(A \cup B) = \Pr(A) + \Pr(B) - \Pr(A \cap B)$$

Note that on the left-hand side of your equation, you should have written $\Pr(A \cup B)$ or $\Pr(A~\text{or}~B)$ rather than $\Pr(A)~\text{or}~\Pr(B)$.

Since we are given that $60\%$ of the population owns an automobile, $30\%$ of the populations owns a house, and $20\%$ owns both, $\Pr(A) = 0.60$, $\Pr(B) = 0.30$, and $\Pr(A \cap B) = 0.20$. Hence, the probability that a person owns an automobile or a house is $$\Pr(A \cup B) = \Pr(A) + \Pr(B) - \Pr(A \cap B) = 0.60 + 0.30 - 0.20 = 0.70$$ However, the question asks for the probability that a person owns an automobile or a house, but not both. That means we must subtract the probability that a person owns an automobile and a house from the probability that the person owns an automobile or a house.
$$\Pr(A~\triangle~B) = \Pr(A \cup B) - \Pr(A \cap B) = 0.70 - 0.20 = 0.50$$

In terms of the Venn diagram, $A \cup B$ is the region enclosed by the two circles, while $A~\triangle~B = (A \cup B) - (A \cap B) = (A - B) \cup (B - A)$ is the region enclosed by the two circles except the region where the sets intersect.

Since $A - B = A - (A \cap B)$, $$\Pr(A - B) = \Pr(A) - \Pr(A \cap B) = 0.60 - 0.20 = 0.40$$
Since $B - A = B - (A \cap B)$, $$\Pr(B - A) = \Pr(B) - \Pr(A \cap B) = 0.30 - 0.20 = 0.10$$
Hence,
$$\Pr(A~\triangle~B) = \Pr(A - B) + \Pr(B - A) = 0.40 + 0.10 = 0.50$$ which agrees with the result obtained above.

• ahh so the question is actually asking the probability that a person chosen at random owns an automobile or a house, OR not both – pino231 Jun 1 '18 at 3:20
• Not quite. The word but should be read as and. The question is asking the probability that a person chosen at random owns an automobile or a house and not both: $\Pr(A~\triangle~B) = \Pr(A \cup B) - \Pr(A \cap B)$. – N. F. Taussig Jun 1 '18 at 9:17

There's no ordering in this question. Using the addition rule is fine, but if you want to use it, note that:

$\mathbb{P}(A) + \mathbb{P}(B) = \Big( \mathbb{P}(A \setminus B) + \mathbb{P}(A \cap B) \Big) + \Big( \mathbb{P}(B \setminus A) + \mathbb{P}(A \cap B) \Big)$.

This should probably help.

10 $\%$ of people don't have a house or automobile so you can leave them. There is 90 $\%$ of people left, also 20$\%$ have both a house and a automobile. This 20% of people is included in the 60% and 30%, so you have to substract this percentage. What you get is 40% + 10% = 50%. So you were probably right by assuming that you have to count the last term $P(A \cap B)$ two times.

• If we subtract $\Pr(A \cup B)$ two times, we will obtain a negative answer. Instead, we must subtract $\Pr(A \cap B)$ twice. – N. F. Taussig May 30 '18 at 9:13
• Yes of course, that's what I meant. Will edit! – WarreG May 30 '18 at 9:37


Miscellaneous questions: Part I: tutorial practice for preRMO and RMO

Problem 1:

The sixty four squares of a chess board are filled with positive integers one on each in such a way that each integer is the average of the of the integers on the neighbouring squares. (Two squares are neighbours if they share a common edge or vertex. Thus, a square can have 8,5 or 3 neighbours depending on its position). Show that all sixty four entries are in fact equal.

Problem 2:

Let T be the set of all triples (a,b,c) of integers such that $1 \leq a < b < c \leq 6$. For each triple (a,b,c) in T, take the product abc. Add all these products corresponding to all triples in I. Prove that the sum is divisible by 7.

Problem 3:

In a class of 25 students, there are 17 cyclists, 13 swimmers, and 8 weight lifters and no one in all the three. In a certain mathematics examination, 6 students got grades D or E. If the cyclists, swimmers and weight lifters all got grade B or C, determine the number of students who got grade A. Also, find the number of cyclists, who are swimmers.

Problem 4:

Five men A, B, C, D, E are wearing caps of black or white colour without each knowing the colour of his cap. It is known that a man wearing a black cap always speaks the truth while a man wearing a white cap always lies. If they make the following statements, find the colour of the cap worn by each of them:

A: I see three black and one white cap.
B: I see four white caps.
C: I see one black and three white caps.
D: I see four black caps.

Problem 5:

Let f be a bijective (one-one and onto) function from the set $A=\{ 1,2,3,\ldots,n\}$ to itself. Show that there is a positive integer $M>1$ such that $f^{M}(i)=f(i)$ for each $i \in A$. Note that $f^{M}$ denotes the composite function $f \circ f \circ f \ldots \circ f$ repeated M times.

Problem 6:

Show that there exists a convex hexagon in the plane such that:
a) all its interior angles are equal
b) its sides are 1,2,3,4,5,6 in some order.

Problem 7:

There are ten objects with total weights 20, each of the weights being a positive integer. Given that none of the weights exceed 10, prove that the ten objects can be divided into two groups that balance each other when placed on the pans of a balance.

Problem 8:

In each of the eight corners of a cube, write +1 or -1 arbitrarily. Then, on each of the six faces of the cube write the product of the numbers written at the four corners of that face. Add all the fourteen numbers so writtein down. Is it possible to arrange the numbers +1 and -1 at the corners initially so that this final sum is zero?

Problem 9:

Given the seven element set $A = \{ a,b,c,d,e,f,g\}$ find a collection T of 3-element subsets of A such that each pair of elements from A occurs exactly in one of the subsets of T.

Try these !!

Regards,
Nalin Pithwa

Towards Baby Analysis: Part I: INMO, IMO and CMI Entrance

$\bf{Reference: \hspace{0.1in}Introductory \hspace{0.1in} Real Analysis: \hspace{0.1in} Kolmogorov \hspace{0.1in} and \hspace{0.1in} Fomin; \hspace{0.1in}Dover \hspace{0.1in }Publications}$

$\bf{Equivalence \hspace{0.1in} of \hspace{0.1in} Sets \hspace{0.1in} The \hspace{0.1in}Power \hspace{0.1in }of \hspace{0.1in }a \hspace{0.1in}Set}$

$\bf{Section 1}$:

$\bf{Finite \hspace{0.1in} and \hspace{0.1in} infinite \hspace{0.1in} sets}$

The set of all vertices of a given polyhedron, the set of all prime numbers less than a given number, and the set of all residents of NYC (at a given time) have a certain property in common, namely, each set has a definite number of elements which can be found in principle, if not in practice. Accordingly, these sets are all said to be $\it{finite}$.$\it{Clearly \hspace{0.1in} we \hspace{0.1in}can \hspace{0.1in} be \hspace{0.1in} sure \hspace{0.1in} that \hspace{0.1in} a \hspace{0.1in} set \hspace{0.1in}is \hspace{0.1in}finite \hspace{0.1in} without \hspace{0.1in} knowing \hspace{0.1in} the \hspace{0.1in} number \hspace{0.1in} of elements \hspace{0.1in}in \hspace{0.1in}it.}$

On the other hand, the set of all positive integers, the set of all points on the line, the set of all circles in the plane, and the set of all polynomials with rational coefficients have a different property in common, namely, $\it{if \hspace{0.1in } we \hspace{0.1in}remove \hspace{0.1in} one \hspace{0.1in} element \hspace{0.1in}from \hspace{0.1in}each \hspace{0.1in}set, \hspace{0.1in}then \hspace{0.1in}remove \hspace{0.1in}two \hspace{0.1in}elements, \hspace{0.1in}three \hspace{0.1in}elements, \hspace{0.1in}and \hspace{0.1in}so \hspace{0.1in}on, \hspace{0.1in}there \hspace{0.1in}will \hspace{0.1in}still \hspace{0.1in}be \hspace{0.1in}elements \hspace{0.1in}left \hspace{0.1in}in \hspace{0.1in}the \hspace{0.1in}set \hspace{0.1in}in \hspace{0.1in}each \hspace{0.1in}stage}$. Accordingly, sets of these kind are called $\it{infinite}$ sets.

Given two finite sets, we can always decide whether or not they have the same number of elements, and if not, we can always determine which set has more elements than the other. It is natural to ask whether the same is true of infinite sets. In other words, does it make sense to ask, for example, whether there are more circles in the plane than rational points on the line, or more functions defined in the interval [0,1] than lines in space? As will soon be apparent, questions of this kind can indeed be answered.

To compare two finite sets A and B, we can count the number of elements in each set and then compare the two numbers, but alternatively, we can try to establish a $\it{one-\hspace{0.1in}to-\hspace{0.1in}one \hspace{0.1in}correspondence}$ between the elements of set A and set B, that is, a correspondence such that each element in A corresponds to one and only element in B, and vice-versa. It is clear that a one-to-one correspondence between two finite sets can be set up if and only if the two sets have the same number of elements. For example, to ascertain if or not the number of students in an assembly is the same as the number of seats in the auditorium, there is no need to count the number of students and the number of seats. We need merely observe whether or not there are empty seats or students with no place to sit down. If the students can all be seated with no empty seats left, that is, if there is a one-to-one correspondence between the set of students and the set of seats, then these two sets obviously have the same number of elements. The important point here is that the first method(counting elements) works only for finite sets, while the second method(setting up a one-to-one correspondence) works for infinite sets as well as for finite sets.

$\bf{Section 2}$:

$\bf{Countable \hspace{0.1in} Sets}$.

The simplest infinite set is the set $\mathscr{Z^{+}}$ of all positive integers. An infinite set is called $\bf{countable}$ if its elements can be put into one-to-one correspondence with those of $\mathscr{Z^{+}}$. In other words, a countable set is a set whose elements can be numbered $a_{1}, a_{2}, a_{3}, \ldots a_{n}, \ldots$. By an $\bf{uncountable}$ set we mean, of course, an infinite set which is not countable.

We now give some examples of countable sets:

$\bf{Example 1}$:

The set $\mathscr{Z}$ of all integers, positive, negative, or zero is countable. In fact, we can set up the following one-to-one correspondence between $\mathscr{Z}$ and $\mathscr{Z^{+}}$ of all positive integers: (0,1), (-1,2), (1,3), (-2,4), (2,5), and so on. More explicitly, we associate the non-negative integer $n \geq 0$ with the odd number $2n+1$, and the negative integer $n<0$ with the even number $2|n|$, that is,

$n \leftrightarrow (2n+1)$, if $n \geq 0$, and $n \in \mathscr{Z}$
$n \leftrightarrow 2|n|$, if $n<0$, and $n \in \mathscr{Z}$

$\bf{Example 2}$:

The set of all positive even numbers is countable, as shown by the obvious correspondence $n \leftrightarrow 2n$.

$\bf{Example 3}$:

The set 2,4,8,$\ldots 2^{n}$ is countable as shown by the obvious correspondence $n \leftrightarrow 2^{n}$.

$\bf{Example 4}: The set$latex \mathscr{Q}$of rational numbers is countable. To see this, we first note that every rational number $\alpha$ can be written as a fraction $\frac{p}{q}$, with $q>0$ with a positive denominator. (Of course, p and q are integers). Call the sum $|p|+q$ as the “height” of the rational number $\alpha$. For example, $\frac{0}{1}=0$ is the only rational number of height zero, $\frac{-1}{1}$, $\frac{1}{1}$ are the only rational numbers of height 2, $\frac{-2}{1}$, $\frac{-1}{2}$, $\frac{1}{2}$, $\frac{2}{1}$ are the only rational numbers of height 3, and so on. We can now arrange all rational numbers in order of increasing “height” (with the numerators increasing in each set of rational numbers of the same height). In other words, we first count the rational numbers of height 1, then those of height 2 (suitably arranged), then those of height 3(suitably arranged), and so on. In this way, we assign every rational number a unique positive integer, that is, we set up a one-to-one correspondence between the set Q of all rational numbers and the set $\mathscr{Z^{+}}$ of all positive integers. $\it{Next \hspace{0.1in}we \hspace{0.1in} prove \hspace{0.1in}some \hspace{0.1in}elementary \hspace{0.1in}theorems \hspace{0.1in}involving \hspace{0.1in}countable \hspace{0.1in}sets}$ $\bf{Theorem1}$. $\bf{Every \hspace{0.1in} subset \hspace{0.1in}of \hspace{0.1in}a \hspace{0.1in}countable \hspace{0.1in}set \hspace{0.1in}is \hspace{0.1in}countable}$. $\bf{Proof}$ Let set A be countable, with elements $a_{1}, a_{2}, a_{3}, \ldots$, and let set B be a subset of A. Among the elements $a_{1}, a_{2}, a_{3}, \ldots$, let $a_{n_{1}}, a_{n_{2}}, a_{n_{3}}, \ldots$ be those in the set B. If the set of numbers $n_{1}, n_{2}, n_{3}, \ldots$ has a largest number, then B is finite. Otherwise, B is countable (consider the one-to-one correspondence $i \leftrightarrow a_{n_{i}}$). $\bf{QED.}$ $\bf{Theorem2}$ $\bf{The \hspace{0.1in}union \hspace{0.1in}of \hspace{0.1in}a \hspace{0.1in}finite \hspace{0.1in}or \hspace{0.1in}countable \hspace{0.1in}number \hspace{0.1in}of \hspace{0.1in}countable \hspace{0.1in}sets \hspace{0.1in}A_{1}, A_{2}, A_{3}, \ldots \hspace{0.1in}is \hspace{0.1in}itself \hspace{0.1in}countable.}$ $\bf{Proof}$ We can assume that no two of the sets $A_{1}, A_{2}, A_{3}, \ldots$ have any elements in common, since otherwise we could consider the sets $A_{1}$, $A_{2}-A_{1}$, $A_{3}-(A_{1}\bigcup A_{2})$, $\ldots$, instead, which are countable by Theorem 1, and have the same union as the original sets. Suppose we write the elements of $A_{1}, A_{2}, A_{3}, \ldots$ in the form of an infinite table $\begin{array}{ccccc} a_{11} & a_{12} & a_{13} & a_{14} &\ldots \\ a_{21} &a_{22} & a_{23} & a_{24} & \ldots \\ a_{31} & a_{32} & a_{33} & a_{34} & \ldots \\ a_{41} & a_{42} & a_{43} & a_{44} & \ldots \\ \ldots & \ldots & \ldots & \ldots & \ldots \end{array}$ where the elements of the set $A_{1}$ appear in the first row, the elements of the set $A_{2}$ appear in the second row, and so on. We now count all the elements in the above array “diagonally”; that is, first we choose $a_{11}$, then $a_{12}$, then move downwards, diagonally to “left”, picking $a_{21}$, then move down vertically picking up $a_{31}$, then move across towards right picking up $a_{22}$, next pick up $a_{13}$ and so on ($a_{14}, a_{23}, a_{32}, a_{41}$)as per the pattern shown: $\begin{array}{cccccccc} a_{11} & \rightarrow & a_{12} &\hspace{0.1in} & a_{13} & \rightarrow a_{14} & \ldots \\ \hspace{0.1in} & \swarrow & \hspace{0.1in} & \nearrow & \hspace{0.01in} & \swarrow & \hspace{0.1in} & \hspace{0.1in}\\ a_{21} & \hspace{0.1in} & a_{22} & \hspace{0.1in} & a_{23} \hspace{0.1in} & a_{24} & \ldots \\ \downarrow & \nearrow & \hspace{0.1in} & \swarrow & \hspace{0.1in} & \hspace{0.1in} & \hspace{0.1in} & \hspace{0.1in}\\ a_{31} & \hspace{0.1in} & a_{32} & \hspace{0.1in} & a_{33} & \hspace{0.1in} & a_{34} & \ldots \\ \hspace{0.1in} & \swarrow & \hspace{0.1in} & \hspace{0.1in} & \hspace{0.1in} & \hspace{0.1in} & \hspace{0.1in} & \hspace{0.1in}\\ a_{41} & \hspace{0.1in} & a_{42} &\hspace{0.1in} & a_{43} &\hspace{0.1in} &a_{44} &\ldots\\ \ldots & \hspace{0.1in} & \ldots & \hspace{0.1in} & \ldots & \hspace{0.1in} & \ldots & \hspace{0.1in} \end{array}$ It is clear that this procedure associates a unique number to each element in each of the sets $A_{1}, A_{2}, \ldots$ thereby establishing a one-to-one correspondence between the union of the sets $A_{1}, A_{2}, \ldots$ and the set $\mathscr{Z^{+}}$ of all positive integers. $\bf{QED.}$ $\bf{Theorem3}$ $\bf{Every \hspace{0.1in}infinite \hspace{0.1in}subset \hspace{0.1in}has \hspace{0.1in}a \hspace{0.1in}countable \hspace{0.1in}subset.}$ $\bf{Proof}$ Let M be an infinite set and $a_{1}$ any element of M. Being infinite, M contains an element $a_{2}$ distinct from $a_{1}$, an element $a_{3}$ distinct from both $a_{2}$ and $a_{1}$, and so on. Continuing this process, (which can never terminate due to “shortage” of elements, since M is infinite), we get a countable subset $A= \{ a_{1}, a_{2}, a_{3}, \ldots, a_{n}, \ldots\}$ of the set $M$. $\bf{QED.}$ $\bf{Remark}$ Theorem 3 shows that countable sets are the “smallest” infinite sets. The question of whether there exist uncountable (infinite) sets will be considered below. $\bf{Section3}$ $\bf{Equivalence \hspace{0.1in} of \hspace{0.1in} sets}$ We arrived at the notion of a countable set M by considering one-to-one correspondences between set M and the set $\mathscr{Z^{+}}$ of all positive integers. More generally, we can consider one-to-one correspondences between any two sets M and N. $\bf{Definition}$ Two sets M and N are said to be $\bf{equivalent}$ (written $M \sim N$) if there is a one-to-one correspondence between the elements of M and the elements of N. The concept of equivalence is applicable both to finite and infinite sets. Two finite sets are equivalent if and only if they have the same number of elements. We can now define a countable set as a set equivalent to the set $\mathscr{Z^{+}}$ of all positive integers. It is clear that two sets are equivalent to a third set are equivalent to each other, and in particular that any two countable sets are equivalent. $\bf{Example1}$ The sets of points in any two closed intervals$[a,b]$and$[c,d]\$ are equivalent; you can “see’ a one-to-one correspondence by drawing the following diagram: Step 1: draw cd as a base of a triangle. Let the third vertex of the triangle be O. Draw a line segment “ab” above the base of the triangle; where “a” lies on one side of the triangle and “b” lies on the third side of the third triangle. Note that two points p and q correspond to each other if and only if they lie on the same ray emanating from the point O in which the extensions of the line segments ac and bd intersect.

$\bf{Example2}$

The set of all points z in the complex plane is equivalent to the set of all points z on a sphere. In fact, a one-to-one correspondence $z \leftrightarrow \alpha$ can be established by using stereographic projection. The origin is the North Pole of the sphere.

$\bf{Example3}$

The set of all points x in the open unit interval $(0,1)$ is equivalent to the set of all points y on the whole real line. For example, the formula $y=\frac{1}{\pi}\arctan{x}+\frac{1}{2}$ establishes a one-to-one correspondence between these two sets. $\bf{QED}$.

The last example and the examples in Section 2 show that an infinite set is sometimes equivalent to one of its proper subsets. For example, there are “as many” positive integers as integers of arbitrary sign, there are “as many” points in the interval $(0,1)$ as on the whole real line, and so on. This fact is characteristic of all infinite sets (and can be used to define such sets) as shown by:

$\bf{Theorem4}$

$\bf{Every \hspace{0.1in} infinite \hspace{0.1in} set \hspace{0.1in}is \hspace{0.1in} equivalent \hspace{0.1in} to \hspace{0.1in}one \hspace{0.1in}of \hspace{0.1in}its \hspace{0.1in}proper \hspace{0.1in}subsets.}$

$\bf{Proof}$

According to Theorem 3, every infinite set M contains a countable subset. Let this subset be $A=\{a_{1}, a_{2}, a_{3}, \ldots, a_{n}, \ldots \}$ and partition A into two countable subsets $A_{1}=\{a_{1}, a_{3}, a_{5}, \ldots \}$ and $A_{2}=\{a_{2}, a_{4}, a_{6}, \ldots \}$.

Obviously, we can establish a one-to-one correspondence between the countable subsets A and $A_{1}$ (merely let $a_{n} \leftrightarrow a_{2n-1}$). This correspondence can be extended to a one-to-one correspondence between the sets $A \bigcup (M-A)=M$ and $A_{1} \bigcup (M-A)=M-A_{2}$ by simply assigning x itself to each element $x \in M-A$. But $M-A_{2}$ is a proper subset of M. $\bf{QED}$.

More later, to be continued,

Regards,
Nalin Pithwa

Find a flaw in this proof: RMO and PRMO tutorial

What ails the following proof that all the elements of a finite set are equal?

The following is the “proof”;

All elements of a set with no elements are equal, so make the induction assumption that any set with n elements has all its elements equal. In a set with n elements, the first and the last n are equal by induction assumption. They overlap at n, so all are equal, completing the induction.

End of “proof:

Regards,

Nalin Pithwa

Problem Solving approach: based on George Polya’s opinion: Useful for RMO/INMO, IITJEE maths preparation

I have prepared the following write-up based on George Polya’s classic reference mentioned below:

UNDERSTANDING THE PROBLEM

First. “You have to understand the problem.”

What is the unknown ? What are the data? What is the condition?

Is it possible to satisfy the condition? Is the condition sufficient to determine the unknown? Or is it insufficient? Or redundant ? Or contradictory?

Draw a figure/diagram. Introduce a suitable notation. Separate the various parts of the condition. Can you write them down?

Second.

DEVISING A PLAN:

Find the connection between the data and the unknown. You may be obliged to consider auxiliary problems if an immediate connection cannot be found. You should eventually obtain a plan for the solution.”

Have you seen it before? Or have you seen the problem in a slightly different form? Do you know a related problem? Do you know a theorem that could be useful? Look at the unknown! And try to think of a familiar problem having the same or a similar unknown. Here is a problem related to yours and solved before. Could you use it? Could you use its result? Could you use its method? Should you restate it differently? Go back to definitions.

If you cannot solve the proposed problem, try to solve some related problem. Could you imagine a more accessible related problem? A more general problem? A more special problem? An analogous problem? Could you solve a part of the problem? Keep only a part of the condition, drop the other part, how far is the unknown then determined, how can it vary? Could you derive something useful from the data? Could you think of other data appropriate to determine the unknown? Could you change the unknown of the data, or both, if necessary, so that the new unknown and the new data are nearer to each other? Did you use all the data? Did you use the whole condition? Have you taken into account all essential notions involved in the problem?

Carrying out your plan of the solution, check each step. Can you clearly see that the step is correct? Can you prove that it is correct?

Fourth. LOOKING BACK.

Examine the solution.

Can you check the result? Can you check the argument? Can you derive the result differently? Can you see it at a glance? Can you see the result, or the method, for some other problem?

**************************************************************************

Reference:

How to Solve It: A New Aspect of Mathematical Method — George Polya.

https://www.amazon.in/How-Solve-Aspect-Mathematical-Method/dp/4871878309/ref=sr_1_1?crid=2DXC1EM1UVCPW&keywords=how+to+solve+it+george+polya&qid=1568334366&s=books&sprefix=How+to+solve%2Caps%2C275&sr=1-1

The above simple “plan” can be useful even to crack problems from a famous classic, Problem Solving Strategies, by Arthur Engel, a widely-used text for training for RMO, INMO and IITJEE Advanced Math also, perhaps.

Reference: Problem-Solving Strategies by Arthur Engel; available on Amazon India

Concept of order in math and real world

1. Rise and Shine algorithm: This is crazy-sounding, but quite a perfect example of the need for “order” in the real-world: when we get up in the morning, we first clean our teeth, finish all other ablutions, then go to the bathroom and first we have to remove our pyjamas/pajamas and then the shirt, and then enter the shower; we do not first enter the shower and then remove the pyjamas/shirt !! 🙂
2. On the number line, as we go from left to right: $a, that is any real number to the left of another real number is always “less than” the number to the right. (note that whereas the real numbers form an “ordered field”, the complex numbers are only “partially ordered”…we will continue this further discussion later) .
3. Dictionary order
4. Alphabetical order (the letters $A \hspace{0.1in} B \ldots Z$ in English.
5. Telephone directory order
6. So a service like JustDial certainly uses “order” quite intensely: let us say that you want to find the telephone clinic landline number of Dr Mrs Prasad in Jayanagar 4th Block, Bengaluru : We first narrow JustDial to “Location” (Jayanagar 4th Block, Bengaluru), then narrow to “doctors/surgeons” as the case may be, and then check in alphabetic order, the name of Dr Mrs Prasad. So, we clearly see that the “concept” and “actual implementation” of order (in databases) actually speeds up so much the time to find the exact information we want.
7. So also, in math, we have the concept of ordered pair; in Cartesian geometry, $(a,b)$ means that the first component $a \in X-axis$ and $b \in Y-axis$. This order is generalized to complex numbers in the complex plane or Argand’s diagram.
8. There is “order” in human “relations” also: let us $(x,y)$ represents x (as father) and y (as son). Clearly, the father is “first” and the son is “second”.
9. So, also any “tree” has a “natural order”: seed first, then roots, then branches.

Regards,

Nalin Pithwa.

Why do we need proofs? In other words, difference between a mathematician, physicist and a layman

Yes, I think it is a very nice question, which kids ask me. Why do we need proofs? Well, here is a detailed explanation (I am not mentioning the reference I use here lest it may intimidate my young enthusiastic, hard working students or readers. In other words, the explanation is not my own; I do not claim credit for this…In other words, I am just sharing what I am reading in the book…)

Here it goes:

What exactly is the difference between a mathematician, a physicist, and a layman? Let us suppose that they all start measuring the angles of hundreds of triangles of various shapes, find the sum in each case and keep a record. Suppose the layman finds that with one or two exceptions, the sum in each case comes out to be 180 degrees. He will ignore the exceptions and say “the sum of the three angles in a triangle  is 180 degrees.” A physicist will be more cautious in dealing with the exceptional cases. He will examine them more carefully. If he finds that the sum in them is somewhere between 179 degrees to 180 degrees, say, then he will attribute the deviation to experimental errors. He will then state a law: The sum of three angles of any triangle is 180 degrees. He will then watch happily as the rest of the world puts his law to test and finds that it holds good in thousands of different cases, until somebody comes up with a triangle in which the law fails miserably. The physicist now has to withdraw his law altogether or else to replace it by some other law which holds good in all cases tried. Even this new law may have to be modified at a later date. And, this will continue without end.

A mathematician will be the fussiest of all. If there is even a single exception he will refrain from saying anything. Even when millions of triangles are tried without a single exception, he will not state it as a theorem that the sum of the three angles in ANY triangle is 180 degrees. The reason is that there are infinitely many different types of triangles. To generalize from a million to infinity is as baseless to a mathematician as to generalize from one to a million. He will at the most make a conjecture and say that there is a strong evidence suggesting that the conjecture is true. But that is not the same thing as a proving a theorem. The only proof acceptable to a mathematician is the one which follows from earlier theorems by sheer logical implications (that is, statements of the form : If P, then Q). For example, such a proof follows easily from the theorem that an external angle of a triangle is the sum of the other two internal angles.

The approach taken by the layman or the physicist is known as the inductive approach whereas the mathematician’s approach is called the deductive approach. In the former, we make a few observations and generalize. In the latter, we deduce from something which is already proven. Of course, a question can be raised as to on what basis this supporting theorem is proved. The answer will be some other theorem. But then the same question can be asked about the other theorem. Eventually, a stage is reached where a certain statement cannot be proved from any other earlier proved statement(s) and must, therefore, be taken for granted to be true. Such a statement is known as an axiom or a postulate. Each branch of math has its own axioms or postulates. For examples, one of the axioms of geometry is that through two distinct points, there passes exactly one line. The whole beautiful structure of geometry is based on 5 or 6 axioms such as this one. Every theorem in plane geometry or Euclid’s Geometry can be ultimately deduced from these axioms.

PS: One of the most famous American presidents, Abraham Lincoln had read, understood and solved all of Euclid’s books (The Elements) by burning mid-night oil, night after night, to “sharpen his mental faculties”. And, of course, there is another famous story (true story) of how Albert Einstein as a very young boy got completely “addicted” to math by reading Euclid’s proof of why three medians of a triangle are concurrent…(you can Google up, of course).

Regards,

Nalin Pithwa


Rhianna has learned the SSS and SAS congruence tests for triangles and she wonders if these tests might work for parallelograms. Diagonals of a Parallelogram Bisect Each Other. A tip from Math Bits says, if we can show that one set of opposite sides are both parallel and congruent, which in turn indicates that the polygon is a parallelogram, this will save time when working a proof. parallelogram, because opposite sides are congruent and adjacent sides are not perpendicular. Theorem 1 : If both pairs of opposite sides of a quadrilateral are congruent, then the quadrilateral is a parallelogram. Also interesting in this case is that to the eye The first is to use congruent triangles to show the corresponding angles are congruent, the other is to use theAlternate Interior Angles Theoremand apply it twice. Congruent trianglesare triangles that have the same size and shape. So we’re going to put on our thinking caps, and use our detective skills, as we set out to prove (show) that a quadrilateral is a parallelogram. Jenn, Founder Calcworkshop®, 15+ Years Experience (Licensed & Certified Teacher). When we think of parallelograms, we usually think of something like this. Note that the vertex $D$ is obtained by rotating $B$ 180 degrees about the midpoint $M$ of $\overline{AC}$. vidDefer[i].setAttribute('src',vidDefer[i].getAttribute('data-src')); We can look at what happens in the special case where all 4 sides of both $ABCD$ and $EFGH$ are congruent to one another. Theorem 6.2.1 If a quadrilateral is a parallelogram, then the two pairs of opposite sides are congruent. Each theorem has an example that will show you how to use it in order to prove the given figure. To show these two triangles are congruent we’ll use the fact that this is a parallelogram, and as a result, the two opposite sid… 2. A quadrilateral that has opposite sides equal and parallel and the opposite angles are also equal is called a parallelogram. One Pair of Opposite Sides are Both Parallel and Congruent, Consecutive Angles in a Parallelogram are Supplementary. yes, one pair of sides are congruent and parallel . Both pairs of opposite sides are congruent. Triangle congruence criteria have been part of the geometry curriculum for centuries. If both pairs of opposite angles of a quadrilateral are congruent, then it’s a parallelogram (converse of a property). Just as with a triangle it takes three pieces of information (ASA, SAS, or SSS) to determine a shape, so with a quadrilateral we would expect to require four pieces of information. THEOREM:If a quadrilateral has 2 sets of opposite sides congruent, then it is a parallelogram. They are called the SSS rule, SAS rule, ASA rule and AAS rule. function init() { Opposite Sides Parallel and Congruent & Opposite Angles Congruent. So what are we waiting for. B) The diagonals of the parallelogram are congruent. yes, diagonals bisect each other. Take Calcworkshop for a spin with our FREE limits course. Since ABCD is a parallelogram, segment AB ≅ segment DC because opposite sides of a parallelogram are congruent. For quadrilaterals, on the other hand, these nice tests seem to be lacking. 2 Looking at a special case for part (a): the rhombus. In order to see what happens with the parallelograms $ABCD$ and $EFGH$ we focus first on $ABCD$. If the quadrilateral has two pairs of opposite, congruent sides, it is a parallelogram. Well, if a parallelogram has congruent diagonals, you know that it is a rectangle. Attribution-NonCommercial-ShareAlike 4.0 International License. Solution: It turns out that knowing all four sides of two quadrilaterals are congruent is not enough to conclude that the quadrilaterals are congruent. Prove that the figure is a parallelogram. Finally, you’ll learn how to complete the associated 2 column-proofs. If one angle is 90 degrees, then all other angles are also 90 degrees. We can tell whether two triangles are congruent without testing all the sides and all the angles of the two triangles. if(vidDefer[i].getAttribute('data-src')) { If the diagonals of a quadrilateral bisect each other, then it’s a parallelogram (converse of a property). Suppose $ABCD$ and $EFGH$ are two parallelograms with a pair of congruent corresponding sides, $|AB| = |EF|$ and $|BC| = |FG|$. We begin by drawing or building a parallelogram. If a parallelogram has perpendicular diagonals, you know it is a rhombus. We might find that the information provided will indicate that the diagonals of the quadrilateral bisect each other. Theorems. The diagonal of a parallelogram separates it into two congruent triangles. side $\overline{EH}$ does not appear to the eye to be congruent to side $\overline{AD}$: this could be an optical illusion or it could be that the eye is distracted by the difference in area. SURVEY . Here is what we need to prove: segment AB ≅ segment CD and segment BC ≅ AD. Draw the diagonal BD, and we will show that ΔABD and ΔCDB are congruent. Thus it provides a good opportunity for students to engage in MP3 ''Construct Viable Arguments and Critique the Reasoning of Others.'' When a parallelogram is divided into two triangles we get to see that the angles across the common side( here the diagonal) are equal. If the quadrilateral has one set of opposite parallel, congruent sides, it is a parallelogram. Both of these facts allow us to prove that the figure is indeed a parallelogram. Complete the two-column proof Given: triangle SVX is congruent to triangle UTX and Line SV is || to line TU Prove: VUTS is a parallelogram Image: It's a parallelogram, with one line going from corner S to corner U and a line going . This task addresses this issue for a specific class of quadrilaterals, namely parallelograms. Well, we must show one of the six basic properties of parallelograms to be true! Find missing values of a given parallelogram. We will learn about the important theorems related to parallelograms and understand their proofs. We all know that a parallelogram is a convex polygon with 4 edges and 4 vertices. Solution: More generally, a quadrilateral with 4 congruent sides is a rhombus. Which of the following cannot be used to prove a shape is a parallelogram? yes,opposite sides are congruent. First prove ABC is congruent to CDA, and then state AD and BC are corresponding sides of the triangles. Triangles can be used to prove this rule about the opposite sides. Creative Commons The opposite sides of a parallelogram are congruent. In this lesson, we will consider the four rules to prove triangle congruence. Note that a rhombus is determined by one side length and a single angle: the given side length determines all four side lengths and For example, for squares one side is enough, for rectangles two adjacent sides are sufficient. Engage your students with effective distance learning resources. This means that the corresponding sides are equal and the corresponding angles are equal. Let’s begin! A description of how to do a parallelogram congruent triangles proof. In this mini-lesson, we will explore the world of parallelograms and their properties. The only parallelogram that satisfies that description is a square. Parallelogram and Congruent triangles Parallelogram. $\triangle ABC$. If … Another approach might involve showing that the opposite angles of a quadrilateral are congruent or that the consecutive angles of a quadrilateral are supplementary. In this section, you will learn how to prove that a quadrilateral is a parallelogram. This proves that the opposite angles in a parallelogram are also equal. What about for arbitrary quadrilaterals? Which statement explains how you could use coordinate geometry to prove the diagonals of a quadrilateral are perpendicular? More specifically, how do we prove a quadrilateral is a parallelogram? Walking trails run from points A to C and from points B to D. Here are the theorems that will help you prove that the quadrilateral is a parallelogram. In today’s geometry lesson, you’re going to learn the 6 ways to prove a parallelogram. for (var i=0; i


# What is the distribution of a random variable with pdf proportional to the product of two normal pdf's

I'm working my way through a nice e-book on Kalman filters, translating to Mathematica as I go and I've hit an interesting problem. In this section: https://nbviewer.jupyter.org/github/rlabbe/Kalman-and-Bayesian-Filters-in-Python/blob/master/03-Gaussians.ipynb#Computational-Properties-of-Gaussians - the author gives a formula to compute a product of Gaussian PDFs that is also Gaussian. Googling around will tell you that the product of two Gaussian PDFs is not itself Gaussian, but is proportional to a Gaussian with mean and standard deviation as in the image below (see proof here: http://www.tina-vision.net/docs/memos/2003-003.pdf for source) -- I have implemented his function and it works fine, but I'm curious if TransformedDistribution can be used to arrive at the same distribution.

To make it concrete

d1 = NormalDistribution[m1, s1];
d2 = NormalDistribution[m2, s2];
(* Works perfectly *)
TransformedDistribution[
x + y, {x \[Distributed] d1, y \[Distributed] d2}]

(* Not a Normally Distributed *)
TransformedDistribution[
x*y, {x \[Distributed] d1, y \[Distributed] d2}]

(* This doesn't work, but I'm wondering if there is something like \
this that would produce the normal distribution cited in the question \
*)
TransformedDistribution[
Normalize[x*y, Total], {x \[Distributed] d1, y \[Distributed] d2}]

Edit to add example multiplication using the proposed function.

MultiplyGaussian[g1_, g2_] :=
Module[{mean1, var1, mean2, var2, mean, variance},
{mean1, var1} = g1 /. NormalDistribution[m_, s_] :> {m, s^2};
{mean2, var2} = g2 /. NormalDistribution[m_, s_] :> {m, s^2};
mean = (var1*mean2 + var2*mean1) / (var1 + var2);
variance = (var1 * var2) / (var1 + var2);
NormalDistribution[mean, Sqrt[variance]]
]
z1 = NormalDistribution[3, 0.7];
z2 = NormalDistribution[4.5, 1];
Plot[{Legended[PDF[z1, x], "N(3,0.7)"],
Legended[PDF[z2, x], "N(4.5,2)"] ,
Legended[PDF[MultiplyGaussian[z1, z2], x], "Product"]}, {x, 1, 10}]

• I'm not sure your source is right: mathworld.wolfram.com/NormalProductDistribution.html Sep 5 '19 at 23:13
• Edited to add code showing that the proposal seems to work and clarify that the 2nd link is a proof that I at least couldn't find a problem with after a quick look.
– Dan
Sep 5 '19 at 23:34
• I think my terminology is sloppy and that has caused the problem (as pointed out by this MathOverflow answer: math.stackexchange.com/questions/101062/…). The result here is for the product of PDFs (where I sloppily said random variable). Does this clarification help see a way to get there in Mathematica?
– Dan
Sep 5 '19 at 23:41
• Please clean-up the "rv" vs "pdf" confusion in the text and the title. Your title should probably be something like "What is the distribution of a random variable with pdf proportional to the product of two normal pdf's?"
– JimB
Sep 6 '19 at 0:40

(* Get product of two normal pdf's *)
prod= PDF[NormalDistribution[μ1, σ1], x]*PDF[NormalDistribution[μ2, σ2], x];

(* Normalize so that the pdf integrates to 1 *)
pdf = prod/Integrate[prod, {x, -∞, ∞}, Assumptions -> {σ1 > 0, σ2 > 0}];

(* Construct associated distribution *)
d = ProbabilityDistribution[pdf, {x, -∞, ∞}, Assumptions -> {σ1 > 0, σ2 > 0}];

(* Find mean and variance *)
Mean[d]
(* (μ2 σ1^2+μ1 σ2^2)/(σ1^2+σ2^2) *)

Variance[d]
(* (σ1^2 σ2^2)/(σ1^2+σ2^2) *)

This matches what the article says the mean and variance should be. But is it a normal distribution? If the moment generating function is of the same form as for a normal distribution, then it has a normal distribution. (We could also use the characteristic function to do this for this particular distribution.)

(* The log of the moment generating function will be in the following form *)
logCF = Expectation[Exp[t z], z \[Distributed] NormalDistribution[μ, σ]] /.
Power[E, x_] -> x // Expand
(* t μ+(t^2 σ^2)/2 *)

(* So we look to see if the moment generating function of distribution d is of the same form *)
Collect[Expectation[Exp[t z], z \[Distributed] d] /. Power[E, x_] -> x // Expand, t]
(* (t^2 σ1^2 σ2^2)/(2 (σ1^2+σ2^2))+t ((μ2 σ1^2)/(σ1^2+σ2^2)+(μ1 σ2^2)/(σ1^2+σ2^2)) *)

And it is.

d1 = NormalDistribution[m1, s1];
d2 = NormalDistribution[m2, s2];

These distributions require that

assume = And @@
(DistributionParameterAssumptions /@ {d1, d2})

(* m1 ∈ Reals && s1 > 0 && m2 ∈ Reals && s2 > 0 *)

As pointed out by @JimB, the PDF formed by the product of the normal PDFs is

PDFprod = Assuming[assume, PDF[d1, x]*PDF[d2, x]/
Integrate[PDF[d1, x]*PDF[d2, x],
{x, -Infinity, Infinity}] // Simplify]

(* (E^(-((m2 s1^2 + m1 s2^2 - (s1^2 + s2^2) x)^2/(
2 s1^2 s2^2 (s1^2 + s2^2)))) Sqrt[s1^2 + s2^2])/(Sqrt[2 π] s1 s2) *)

Comparing with the PDF of the expected normal distribution

PDFprod == Assuming[assume, PDF[NormalDistribution[
(m1*s2^2 + m2*s1^2)/(s1^2 + s2^2),
Sqrt[s1^2*s2^2/(s1^2 + s2^2)]], x] // Simplify]

(* True *)


# Open maps which are not continuous

What is an example of an open map $(0,1) \to \mathbb{R}$ which is not continuous? Is it even possible for one to exist? What about in higher dimensions? The simplest example I've been able to think of is the map $e^{1/z}$ from $\mathbb{C}$ to $\mathbb{C}$ (filled in to be $0$ at $0$). There must be a simpler example, using the usual Euclidean topology, right?

• Since $(0,1)$ and $\mathbb R$ are homeomorphic via a linear map composed with $\arctan$, it suffices to find a map $\mathbb R \to \mathbb R$ that is open but not continuous. Googling that gives you mathforum.org/library/drmath/view/62395.html – lhf Oct 25 '11 at 0:55
• this is obviously not much help, but if you can find a continuous bijection $f$ with discontinuous inverse, then $f^{-1}$ will do. – user12014 Oct 25 '11 at 1:13
• One can build such a function from a Cantor set $C$ (the usual "middle thirds" set will do). Send each point in $C$ to $0$, and map each connected component of the complement of $C$ homeomorphically to the interval $(-1,1)$. Then the image of any open set intersecting $C$ will be $(-1,1)$ (thus open), and the image of any open set not meeting $C$ will also be open, since it's a union of homeomorphic images of open sets. Of course, each point of $C$ will be a discontinuity. – user83827 Oct 25 '11 at 1:16
• @PZZ for instance the map wrapping [0,1) around the unit circle. – JSchlather Oct 25 '11 at 1:37
• @PZZ: In fact there are no counterexamples of the type you're suggesting: if $I$ and $J$ are intervals in $\mathbb{R}$ and $f: I \rightarrow J$ is a continuous bijection, then $f^{-1}$ is necessarily continuous. By coincidence this is exactly where I am in my Spivak calculus course, so see e.g. Theorem 37 in $\S 6.4$ of math.uga.edu/~pete/2400calc2.pdf. (Or see Spivak's text!) – Pete L. Clark Oct 25 '11 at 3:18

Explicit examples are moderately difficult to construct, but it’s not too hard to come up with non-constructive examples; here’s one such.

For $x,y\in\mathbb{R}$ define $x\sim y$ iff $x-y\in \mathbb{Q}$; it’s easy to check that $\sim$ is an equivalence relation on $\mathbb{R}$. For any $x\in\mathbb{R}$, $[x] = \{x+q:q\in\mathbb{Q}\}$, where $[x]$ is the $\sim$-equivalence class of $x$. In particular, each equivalence class is countable. For any infinite cardinal $\kappa$, the union of $\kappa$ pairwise disjoint countably infinite sets has cardinality $\kappa$, so there must be exactly as many equivalence classes as there are real numbers. Let $h$ be a bijection from $\mathbb{R}/\sim$, the set of equivalence classes, to $\mathbb{R}$. Finally, define $$f:(0,1)\to\mathbb{R}:x\mapsto h([x])\;.$$

I claim that if $V$ is any non-empty open subset of $(0,1)$, $f[V]=\mathbb{R}$, which of course ensures that $f$ is open. To see this, just observe that every open interval in $(0,1)$ intersects every equivalence class. (It should be no trouble at all to see that $f$ is wildly discontinuous!)

• Just curious: Is the axiom of choice used anywhere in your proof? – YoTengoUnLCD Jan 17 '17 at 8:14
• I think I'm going to start calling $\sim$ the "Vitali equivalence relation"... $x$ and $y$ are Vitali equivalent iff $x-y \in \mathbb{Q}$, etc. Honestly, this thing is useful enough to deserve a name. – goblin Mar 2 '17 at 13:54
• is $f$ injective? – David Feng Feb 16 at 21:37
• @DavidFeng: No. All $x$ from the same equivalence class give the same value. For example, $f(\frac12)=f(\frac13)$ since $\frac12-\frac13\in\mathbb Q$ – celtschk Mar 2 at 21:55

Let me conceptualize around Brian's answer a bit.

Definition 0. If $X$ and $Y$ are topological spaces, a function $f:X→Y$ is said to be strongly Darboux iff for all non-empty open sets $A⊆X$, we have $f(A)=Y$.

Here's the basic facts:

Proposition.

1. Every strongly Darboux function is an open function.
2. If $X$ is non-empty, every Darboux function $X \rightarrow Y$ is surjective.
3. If $X$ is non-empty and $f : X \rightarrow Y$ is a continuous Darboux mapping, then $Y$ carries the indiscrete topology.

Proofs.

1. Trivial.

2. Since $X$ is open and non-empty, hence $f(X)=Y.$ That is, $f$ is surjective.

3. Let $B \subseteq Y$ denote a non-empty open set. Our goal is to show that $B=Y$. Since $f$ is surjective, $f^{-1}(B)$ is non-empty. Since $f$ is continuous, $f^{-1}(B)$ is open. Hence $f(f^{-1}(B))=Y$. But since $f$ is surjecive, hence $f(f^{-1}(B))=B.$ So $B=Y$.

Putting these together, we see that every strongly Darboux function $f:\mathbb{R} \rightarrow \mathbb{R}$ is a discontinuous open mapping.

• $f$ is an open mapping by (1).

• $f$ is discontinuous by (3), because it's domain is non-empty and it's codomain doesn't carry the indiscrete topology.

And, of course, Brian's answer guarantees the existence of a strongly Darboux function $\mathbb{R} \rightarrow \mathbb{R}$. This completes the proof.

There is in fact a rather easy example of a function $$\mathbb R \to \mathbb R$$ such that the image of every open set is $$\mathbb R$$: Let $$(x_i)_{i\in\mathbb Z_+}$$ be the binary decimal expansion of $$x$$, so that each $$x_i \in \{0,1\}$$. Let then $$f(x) = \sum_{k=1}^\infty\frac{(-1)^{x_k}}k\quad \textrm{if the series converges}$$ $$f(x) = 0\quad \textrm{otherwise.}$$ Since the harmonic series (or a tail of it) can be made to converge to any real number by changing signs in the appropriate way, this function has $$f((a,b)) = \mathbb R$$ for any real $$a,b$$. Hence this function is open, though clearly not continuous at any point.

The harmonic series can be substituted with any other unbounded series where the summand goes to zero.


CoCalc Public Filesweek 5 / assignment / FindRoots.ipynb
Authors: Boyuan Qi, Rajvir Sidhu
Views : 31
Compute Environment: Ubuntu 20.04 (Default)

# Assignment 2: Polynomial Root Finding

## Markdown

Give the address (url) for a website that has documentation for markdown, including tables (i.e. a webpage, not a pdf or other document, that describes how you use markdown to create a table). Enter your answer as a variable named website='http://url.goes.here'

Marks: 1
In [ ]:
# YOUR CODE HERE

markdownWebsite='https://www.markdownguide.org/cheat-sheet'

Test your code from above here(1 point), ID: validate_website
In [ ]:
#test that it's a suitable website link you've given

Work out the solutions to the following questions long-hand (i.e. you should not be coding anything at this point). In the first box, set the appropriate variable equal to your answer (there's no need to define any functions). For example, to answer the last question, you will simply type polyRoots=[4-math.sqrt(3),4,4+math.sqrt(3)]

1. Define the polynomial $p(x)=x^3-12x^2+45x-52$. How do you express $p(x)$ as a list, such as will be input to our algorithms? Set the variable polyX equal to this.
2. What is the derivative, $p'(x)$ (as a list called polyDeriv) and the root(s) of $p'(x)$ (as a list, in increasing order, called derivRoots)?
3. What is the Lagrange bound as applied to the polynomial $p(x)$? Your answer should be a real, positive number, called lagrange. (In case you missed it, this was an exercise in the workshops)
4. Pretend that you don't know the roots of $p(x)$, but you know the roots of $p'(x)$. Use this information to explain why we know that there is no more than one root in each of the ranges: $(-109,3),(3,5),(5,109)$ You should do this without evaluating $p(x)$ at any point. Write your solution in the free text box below (this will be manually graded).
5. What are the roots of $p(x)$? Give your answer as a list in increasing order called polyRoots. Make sure that all the roots of $p(x)$ appear in exactly one of the above ranges.
Marks: 5
In [ ]:
import math

polyX=[-52,45,-12,1]
polyDeriv=[45,-24,3]
derivRoots=[3,5]
lagrange=109
polyRoots=[4-math.sqrt(3),4,4+math.sqrt(3)]

Test your code from above here(1 point), ID: polyRoots_correct
In [ ]:
#the question told you how to answer this, so no point in hiding the test
assert polyRoots==[4-math.sqrt(3),4,4+math.sqrt(3)]

Test your code from above here(1 point), ID: polyX_correct
In [ ]:
#check that polyX is correct

Test your code from above here(1 point), ID: polyDeriv_correct
In [ ]:
#check that polyDeriv is correct

Test your code from above here(1 point), ID: derivRoots_correct
In [ ]:
#check that derivRoots is correct

Test your code from above here(1 point), ID: lagrange_bound_correct
In [ ]:
#check that lagrange is correct

This is where you give your answer to (4) above: Explain why we know that there is no more than one root in each of the ranges: $(-109,3),(3,5),(5,109)$ You should do this without evaluating $p(x)$ at any point.

Marks: 2

Given any two roots b>a of p(x), f is continuous and differentiable on [a,b]. Using Rolle's theorem, there exists exactly one root, 'k', such that f'(k)=0 and a<c<b. Due to p'(x) having 2 roots, p(x) therefore has at most 3 roots. The roots of p'(x) are 3 and 5 which means p(x) must have a root within the interval [3,5]. Also, the limits of the function are 109 and -109, so if there are 3 roots, then exactly one root must exist in the each of the intervals [-109,3] and [5,109]. This means there that no more than one root can exist in each of the intervals [-109,3],[3,5] and [5,109]

## Collecting our work so far

In working through the lab sessions, we have built up a library of subroutines that will be useful for finding the roots of a polynomial. Those that we have already produced are given first.

In [ ]:
from math import sqrt

def EvaluatePoly(polynomial,x):
'''evaluate a polynomial at a value x
input: polynomial as a list, value x to evaluate at
output: value of polynomial'''
return(sum(val*x**n for n,val in enumerate(polynomial)))
def DifferentiatePoly(polynomial):
'''return the derivative of polynomial'''
return [(i+1)*val for i,val in enumerate(polynomial[1:])]
def EnsureStandardForm(polynomial):
'''make sure that the highest order of the polynomial has non-zero coefficient by removing all higher order zeros'''
while not polynomial[-1]:
del polynomial[-1]
return polynomial
def DescartesSigns(polynomial):
'''Descartes rules of signs returns an upper bound on the number of positive roots and the number of negative roots'''
PosList=list(polynomial)
NegList=[((-1)**i)*val for i,val in enumerate(polynomial)]
while 0 in PosList:
PosList.remove(0)
NegList.remove(0)
return([sum([i[0]*i[1]<0 for i in zip(PosList[1:],PosList[:-1])]),sum([i[0]*i[1]<0 for i in zip(NegList[1:],NegList[:-1])])])
def FindZeroInInterval(polynomial,range_lower,range_upper):
'''perform an interval bisection on polynomial between the values range_lower<range_upper
return x such that polynomial(x)=0 (or a good enough approximation to it)'''
#this is slightly modified compared to what we presented.
assert range_lower<=range_upper,"second argument should be smaller than first"
accuracy=10**(-15)
value_lower=EvaluatePoly(polynomial,range_lower)
value_upper=EvaluatePoly(polynomial,range_upper)
if value_lower==0: # an exact root on the lower boundary
return(range_lower)
elif abs(value_upper/value_lower)<accuracy and abs(value_upper)<accuracy: #define this as being close enough to being a root on the upper boundary
return(range_upper)
elif abs(value_lower/value_upper)<accuracy and abs(value_lower)<accuracy: #close enough to root on lower boundary
return(range_lower)
if (range_lower==range_upper):#we already know it's not a root.
return('')
extent=2*(range_upper-range_lower)     #initialise with a dummy variable larger than anything that will ver be calculated

while range_upper-range_lower>max(abs(range_upper),abs(range_lower),1)*accuracy and extent>(range_upper-range_lower):#stopping criteria based on numerical accuracy
if value_upper*value_lower>0:      #we don't seem to have a root in this range
return('')
range_mid=(range_upper+range_lower)/2    #bisection
value_mid=EvaluatePoly(polynomial,range_mid)
extent=range_upper-range_lower

if value_mid==0:              #we have found the root
return range_mid
elif value_mid*value_lower>0: #the root is between value_mid and value_upper. redefine range and repeat
range_lower=range_mid
value_lower=value_mid
else:
range_upper=range_mid
value_upper=value_mid

return range_mid

return range_mid
def Smooth(mylist):
'''remove all the empty entries in a list'''
assert len(mylist)>0,'Should not smooth an empty list'
while '' in mylist:
mylist.remove('')
return mylist
def ZeroTest(mylist):
"fudge the fact that it's hard to tell if a very small number is actually 0"
return([(not abs(a)<10**(-14))*a for a in mylist])
def RootLocationBound(polynomial):
'use a Lagrange bound to crudely limit where the roots can be found'
return max(1,sum(abs(a/polynomial[-1]) for a in polynomial[:-1]))

def QuickTests():
#tests for the above code
assert EnsureStandardForm([1,1,1])==[1,1,1]
assert EnsureStandardForm([1,1,1,0,0,0])==[1,1,1]
assert [EvaluatePoly([24,-50,35,-10,1],i)-(24-50*i+35*i*i-10*i**3+i**4) for i in range(-5,5,1)]==[0,0,0,0,0,0,0,0,0,0]
assert DifferentiatePoly([24,-50,35,-10,1])==[-50,70,-30,4]
assert ZeroTest([-1,0.1,10**(-15),2])==[-1,0.1,0,2]
assert DescartesSigns([-1,-1,1,1])==[1,2]
assert DescartesSigns([-1,0,0,1])==[1,0]
return True

assert QuickTests()

Let's say you were given a polynomial as a list polynomial and had found the roots of its derivative, as an ordered list: deriv_roots. Write a function root_bounds that returns a list of pairs of numbers between which there is no more than one root of the polynomial. The list should be ordered, going from smallest to largest, and the pairs of values should also be ordered smallest to largest.

Hint: If you did the free text box above (question 4) clearly and correctly, this should be straightforward.

Hint: Look at the first test to understand the input and output format.

Marks: 4
In [10]:
def root_bounds(deriv_roots,upper):
'''return the pairs of numbers which bound individual roots (or none at all)
in: deriv_roots: a list of roots of the deriviative of a polynomial, in increasing order, repeated according to their multiplicity
in: upper. if x is a root of polynomial, |x|<=upper
'''

assert upper>=0
assert all([val1<=val2 for val1,val2 in zip (deriv_roots[:-1],deriv_roots[1:])])
assert isinstance (deriv_roots,list)
assert len(deriv_roots)>0  # This is needed to actually apply Rolle's Theorem
emptyList=[]   # A list which is used later on in the interation
if deriv_roots[-1]>upper:
for x in range(len(deriv_roots)-1):
listAdd=[deriv_roots[x],deriv_roots[x+1]]  # A nested listed will be added to the interval that contains the root
if deriv_roots[-1]<=upper:
lower=[-upper]
high=[upper]
z=list(deriv_roots)
bigList=lower+z+high  # The completed list which has the upper and lower bounds of the function
for x in range(len(bigList)-1):
listAdd=[bigList[x],bigList[x+1]]   # A nested listed will be added to the interval that contains the root
return emptyList

print(root_bounds([-1,0,0,1],5))

[[-5, -1], [-1, 0], [0, 0], [0, 1], [1, 5]]
Test your code from above here(2 points), ID: root_bounds_code_visible
In [ ]:
#test the root_bounds function
assert list(root_bounds([-1,0,0,1],5))==[[-5,-1],[-1,0],[0,0],[0,1],[1,5]] or list(root_bounds([-1,0,0,1],5))==[(-5,-1),(-1,0),(0,0),(0,1),(1,5)]

Test your code from above here(1 point), ID: root_bounds_with_float
In [ ]:
#a basic test

Test your code from above here(1 point), ID: root_bounds_preconditions
In [ ]:
#check some preconditions

The function FindZeroInInterval (above) is a little different to the code that we presented in the notes (given as OriginalFindZeroInInterval in cell below). Aside from the assert statement, how is it different? (explanation not required.)

To demonstrate the difference, give a set of parameters as input that gives a different outcome between the two functions. Give your answer as 3 variables poly, below and above.

Marks: 1

In [ ]:
# YOUR CODE HERE

poly=[3,1,0,0]
above=0
below=-3

Test your code from above here(2 points), ID: difference_FindZero
In [ ]:
def OriginalFindZeroInInterval ( polynomial , range_lower , range_upper ):
''' perform an interval bisection on polynomial between the values
range_lower < range_upper
return x such that polynomial (x)=0 (or a good enough approximation to it)
'''
value_lower = EvaluatePoly ( polynomial , range_lower )
value_upper = EvaluatePoly ( polynomial , range_upper )

while range_upper - range_lower >10**( -15) :
if value_upper * value_lower >0: #we don 't seem to have a root in this range
return('')
range_mid =( range_upper + range_lower )/2 # bisection
value_mid = EvaluatePoly ( polynomial , range_mid )
if value_mid ==0: #we have found the 0, so return itsposition
return range_mid
elif value_mid * value_lower >0: # crossing between range_mid andrange_upper
range_lower = range_mid
value_lower = value_mid
else : # crossing between range_lower and
range_mid
range_upper = range_mid
value_upper = value_mid
return range_mid

assert above>below
assert FindZeroInInterval(poly,below,above)!=OriginalFindZeroInInterval(poly,below,above)

## The Final Root Finder

Using the previous functions (and defining any additional functions that wish in the cell below), complete the function FindRealZeros which accepts a polynomial as a list and returns a list of the roots of the polynomial, in increasing order, appearing as many times as they are repeated.

You might structure your algorithm by considering:

• How did you work out the solution by hand?
• What bits of code do you have to hand that could replace some of the by-hand calculation.
• Are there any simple types of polynomial for which you can immediately give the root?
• Is there a minimum size of polynomial that has a solution?
• Can you give a set of ranges between which no more than 1 root of the polynomial lies, given the roots of the derivative?
• For a polynomial of a given degree, $n$, what's the maximum number of ranges there could be? How many real roots could there be for a degree $n$ polynomial?

You need to make use of the functions we've already defined, particularly FindZeroInInterval, DifferentiatePoly and RootLocationBound

In [ ]:
def EvaluatePoly(polynomial,x):
'''evaluate a polynomial at a value x
input: polynomial as a list, value x to evaluate at
output: value of polynomial'''
return(sum(val*x**n for n,val in enumerate(polynomial)))

def RootLocationBound(polynomial):
'use a Lagrange bound to crudely limit where the roots can be found'
return max(1,sum(abs(a/polynomial[-1]) for a in polynomial[:-1]))

def root_bounds(deriv_roots,upper):
'''return the pairs of numbers which bound individual roots (or none at all)
in: deriv_roots: a list of roots of the deriviative of a polynomial, in increasing order, repeated according to their multiplicity
in: upper. if x is a root of polynomial, |x|<=upper
'''

assert upper>=0
assert all([val1<=val2 for val1,val2 in zip (deriv_roots[:-1],deriv_roots[1:])])
assert isinstance (deriv_roots,list)
assert len(deriv_roots)>0  # This is needed to actually apply Rolle's Theorem
emptyList=[]   # A list which is used later on in the interation
if deriv_roots[-1]>upper:
for x in range(len(deriv_roots)-1):
listAdd=[deriv_roots[x],deriv_roots[x+1]]  # A nested listed will be added to the interval that contains the root
if deriv_roots[-1]<=upper:
lower=[-upper]
high=[upper]
z=list(deriv_roots)
bigList=lower+z+high  # The completed list which has the upper and lower bounds of the function
for x in range(len(bigList)-1):
listAdd=[bigList[x],bigList[x+1]]   # A nested listed will be added to the interval that contains the root
return emptyList

print(root_bounds([-1,0,0,1],5))

def EvaluatePoly(polynomial,x):
'''evaluate a polynomial at a value x
input: polynomial as a list, value x to evaluate at
output: value of polynomial'''
return(sum(val*x**n for n,val in enumerate(polynomial)))

def DifferentiatePoly(polynomial,order=1):
'''return the derivative of polynomial of order n'''
derivative=[(i+1)*val for i,val in enumerate(polynomial[1:])]
if order==1:
return derivative
else:
return DifferentiatePoly(derivative, order-1)

def DescartesSigns(polynomial):
'''Descartes rules of signs returns an upper bound on the number of positive roots and the number of negative roots'''
PosList=list(polynomial)
NegList=[((-1)**i)*val for i,val in enumerate(polynomial)]
while 0 in PosList:
PosList.remove(0)
NegList.remove(0)
return([sum([i[0]*i[1]<0 for i in zip(PosList[1:],PosList[:-1])]),sum([i[0]*i[1]<0 for i in zip(NegList[1:],NegList[:-1])])])

DescartesSigns([-52,45,-12,1])

In [58]:
import numpy
from math import sqrt
import math

def EvaluatePoly(polynomial,x):
'''evaluate a polynomial at a value x
input: polynomial as a list, value x to evaluate at
output: value of polynomial'''
return(sum(val*x**n for n,val in enumerate(polynomial)))

def FindZeroInInterval(polynomial,range_lower,range_upper):
'''perform an interval bisection on polynomial between the values range_lower<range_upper
return x such that polynomial(x)=0 (or a good enough approximation to it)'''
#this is slightly modified compared to what we presented.
assert range_lower<=range_upper,"second argument should be smaller than first"
accuracy=10**(-15)
value_lower=EvaluatePoly(polynomial,range_lower)
value_upper=EvaluatePoly(polynomial,range_upper)
if value_lower==0: # an exact root on the lower boundary
return(range_lower)
elif abs(value_upper/value_lower)<accuracy and abs(value_upper)<accuracy: #define this as being close enough to being a root on the upper boundary
return(range_upper)
elif abs(value_lower/value_upper)<accuracy and abs(value_lower)<accuracy: #close enough to root on lower boundary
return(range_lower)
if (range_lower==range_upper):
return('')
extent=2*(range_upper-range_lower)     #initialise with a dummy variable larger than anything that will ver be calculated

while range_upper-range_lower>max(abs(range_upper),abs(range_lower),1)*accuracy and extent>(range_upper-range_lower):#stopping criteria based on numerical accuracy
if value_upper*value_lower>0:
return('no zero')
range_mid=(range_upper+range_lower)/2    #bisection
value_mid=EvaluatePoly(polynomial,range_mid)
extent=range_upper-range_lower

if value_mid==0:
return range_mid
elif value_mid*value_lower>0: #the root is between value_mid and value_upper. redefine range and repeat
range_lower=range_mid
value_lower=value_mid
else:
range_upper=range_mid
value_upper=value_mid

return range_mid

def RemoveTrailingZero(list):
"Remove the '.0' of a float to transform it in integer"
trail=[]
for x in list:
print(x)
if (x!=0 and x%1==0):
idk=int(x)
trail.append(idk)
elif x==0.0:
idk=0
trail.append(idk)
else:
trail.append(x)
return trail

def FindRealZeros(polynomial):
'''return the zeros of the polynomial in an ordered list'''

ReversePoly=list(reversed(polynomial)) #Reverse the order of the list 'polynomial' for numpy because numpy consider the first entry the lower degree
ListRoot=numpy.roots(ReversePoly) #list of root(s) of the polynomial found by numpy with a 'okay' precision
print(ListRoot)
newPrecision=[]
output=[]
Final=[]
nestedList=[]
withoutImaginary=[]

for x in range(len(ListRoot)):
newPrecision+=[numpy.around(ListRoot[x],decimals=7,out=None)]
for x in newPrecision: #get rid of complex numbers if present in the previous list
if x.imag==0: #keep the real numbers and remove the "0j" part
i=x.real
withoutImaginary.append(i)
for x in withoutImaginary: #Determine intervals around the roots with great precision
DetermineIntervals=[x-0.0000001,x+0.0000001]
output+=DetermineIntervals #Create a list whose entries are end points of intervals
i=0
while i<len(output): #Create a nested list
nestedList.append(output[i:i+2])
i+=2
print (nestedList)
for x in nestedList:
Zeropolynomial=FindZeroInInterval(polynomial,x[0],x[1]) #The upper bound and lower bound correspond to the endpoints of each interval in the nested list
if Zeropolynomial =='no zero':
pass
else:
Final.append(Zeropolynomial)
IncreasingOrder=list(sorted(Final,key=float)) #Reorganized the roots found by increasing order
end=RemoveTrailingZero(IncreasingOrder) #In the case where one of the root/multiple roots are supposed integer(s), we need to remove the '.0' part

print(end)
return end

We will test if your solution works by comparing ideal solutions to your calculated solutions via the function EqualityWithinTolerance, which aims to tolerate numerical inaccuracy. Some examples are given below. There will be further tests that have to be passed.

Marks: 10
Test your code from above here(3 points), ID: root_finder
In [59]:
#basic testing examples
def EqualityWithinTolerance(list1,list2,epsilon):
"""since we don't have perfect accuracy, cannot just test equality of two lists in our tests.
return true if all elements are close enough (within epsilon)"""
assert len(list1)==len(list2),'cannot compare lists of different lengths'
return sum([abs(i[0]-i[1])<=epsilon for i in zip(list1,list2)])==len(list1)

#integer solutions
assert EqualityWithinTolerance(FindRealZeros([24,-50,35,-10,1]),[1,2,3,4],2*10**(-10))
assert EqualityWithinTolerance(FindRealZeros([-16,0,0,0,1]),[-2,2],10**(-10))
#irrational solutions
assert EqualityWithinTolerance(FindRealZeros([70,-60,12]),[(15-sqrt(15))/6,(15+sqrt(15))/6],10**(-10))
#no real solutions
assert EqualityWithinTolerance(FindRealZeros([16,0,0,0,1]),[],10**(-10))
assert EqualityWithinTolerance(FindRealZeros([16,0,1]),[],10**(-10)),"You should not be returning complex roots"
#roots very close to 0
assert EqualityWithinTolerance(FindRealZeros([-10**(-12),0,1]),[-10**(-6),10**(-6)],10**(-10))
#try a longer polynomial to make sure it's not just an explicit formula going up to degree 3 or 4
assert EqualityWithinTolerance(FindRealZeros([-362880, 1026576, -1172700, 723680, -269325, 63273, -9450, 870, -45,1]),[1,2,3,4,5,6,7,8,9],10**(-10))

[4. 3. 2. 1.] [[3.9999999, 4.0000001], [2.9999999, 3.0000001], [1.9999999, 2.0000001], [0.9999999, 1.0000001]] 1.0 2.0 3.0 4.0 [1, 2, 3, 4] [-2.00000000e+00+0.j 1.66533454e-16+2.j 1.66533454e-16-2.j 2.00000000e+00+0.j] [[-2.0000001, -1.9999999], [1.9999999, 2.0000001]] -2.0 2.0 [-2, 2] [3.14549722 1.85450278] [[3.1454971, 3.1454972999999997], [1.8545026999999998, 1.8545029]] 1.8545027756320966 3.145497224367904 [1.8545027756320966, 3.145497224367904] [-1.41421356+1.41421356j -1.41421356-1.41421356j 1.41421356+1.41421356j 1.41421356-1.41421356j] [] [] [-0.+4.j 0.-4.j] [] [] [-1.e-06 1.e-06] [[-1.1e-06, -9e-07], [9e-07, 1.1e-06]] -1e-06 1e-06 [-1e-06, 1e-06] [9. 8. 7. 6. 5. 4. 3. 2. 1.] [[8.9999999, 9.0000001], [7.9999999, 8.0000001], [6.9999999, 7.0000001], [5.9999999, 6.0000001], [4.9999999, 5.0000001], [3.9999999, 4.0000001], [2.9999999, 3.0000001], [1.9999999, 2.0000001], [0.9999999, 1.0000001]] 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 [1, 2, 3, 4, 5, 6, 7, 8, 9]
In [ ]:
#check that there's a reasonable number of pre- and post-conditions inside FindRealZeros and plenty of commenting

Test your code from above here(1 point), ID: find_large_roots
In [ ]:
#here follow some hidden tests.
#very large roots

Test your code from above here(1 point), ID: root_finder_hidden_tests1
In [ ]:
#a few more general tests, not checking anything in particular, just keeping you honest

Test your code from above here(1 point), ID: root_finder_hidden_tests2
In [ ]:
#a few more general tests, not checking anything in particular, just keeping you honest

Test your code from above here(1 point), ID: root_finder_repeated
In [ ]:
#what happens when there are repeated roots?

Test your code from above here(1 point), ID: root_finder_uses_helpers
In [ ]:
#Ensure that the correct helper functions are being used

Test your code from above here(1 point), ID: root_finder_no_external
In [ ]:
#check that FindRealZeros does not rely on external functions

Explain how your function FindRealZeros works. Each member of the pair programming pair should write their own explanation, independently, in a separate copy of the file (which will contain the same solutions to the programming questions).

Marks: 3


# Evaluate the indefinite integral $\int \frac{1}{x^2} \sin\left(\frac{6}{x}\right) \cos\left(\frac{6}{x}\right) \, dx$

Evaluate the indefinite integral:

$$\int \frac{1}{x^2} \sin\left(\frac{6}{x}\right) \cos\left(\frac{6}{x}\right) \, dx$$

(using substitution)

The answer is: $$\frac {1}{24} \cos\left(\frac{12}{x}\right) + C$$

Whereas I get a slightly different one.

Here's my solution:

$$u = \frac{6}{x}$$

$$du = - \frac{6}{x^2} \cdot dx$$

$$-\frac {1}{6} du = \frac {1}{x^2} \cdot dx$$

Making substitution:

$$\int -\frac{1}{6} du \sin (u) \cos (u)$$

adding a new variable for substitution:

$$s = \cos (u)$$

$$ds = -sin(u) du$$

Making substitution:

$$\frac {1}{6} \int ds \cdot s$$

Evaluating:

$$\frac{1}{6} \cdot \frac{s^2}{2} = \frac{s^2}{12} = \frac{\cos^2(u)}{12} = \frac{\cos^2(\frac{6}{x})}{12}$$

Then using a half angle formula for $$\cos^2$$:

$$\frac {\frac{1}{2} \cdot (1 + \cos(\frac{12}{x}))}{12} = \frac{1}{24} + \frac{1}{24} \cdot \cos\left(\frac{12}{x}\right) + C$$

As you can see I have an additional $$\frac{1}{24}$$ in my answer... so what did I do wrong?

• Did you notice the +C in the original answer there? The constant absorbs that $+1/24$! Apr 27 '15 at 4:18
• @Jesse P Francis So are you saying there's never a constant in the answers for integrals that were evaluated? I wonder why is that? I already integrated the function... why does my constant need to disappear... because of C... Apr 27 '15 at 4:20
• @dramadeur It doesn't disappear per se; in this case Jesse is defining a new constant $C' := C + \frac{1}{24}$ and then renaming $C'$ as $C$. Apr 27 '15 at 4:23
• @Travis, he edited the question and added constant, anyway, dramadeur, I think what Travis said is what you are confused with!:) Apr 27 '15 at 4:25

You missed the constant of integration all the way! It "absorbs" the $\frac{1}{24}$!

Spot the difference:

Evaluating:

$\displaystyle \frac{1}{6} \cdot \frac{s^2}{2} +c= \frac{s^2}{12} +c= \frac{\cos^2(u)}{12} +c= \frac{\cos^2(\frac{6}{x})}{12}+c$, where c is the constant of integration.

Then using a half angle formula for $\cos^2$:

$\displaystyle \frac {\frac{1}{2} \cdot (1 + \cos(\frac{12}{x}))}{12} +c$ = $\frac{1}{24} \cdot \cos(\frac{12}{x}) + C$, where $C=c+\frac{1}{24}$

You did everything right, but you're constant of integration "absorbs" the $\frac{1}{24}$

$$\frac{1}{24}+C=C$$

The $C$ is an arbitrary constant meaning that it could be anything (depending on our initial conditions). So, what's a constant plus an arbitrary constant? It's just another arbitrary constant!

If it helps, you could do something like:

$$\frac{1}{24}+C=D$$


+0

# If there were 3 skiers on plane of 17 and 4 people on the plane died of a crash, what is the chance that all 3 skiers survive?

0
529
21

If there were 3 skiers on plane of 17 and 4 people on the plane died of a crash, what is the chance that all 3 skiers survive?

Guest May 21, 2014

#16
+889
+8

There are just about always two methods for dealing with problems like this, a counting method and a probability method, (and often one is more convenient than the other.)

The counting method has been used for both of the correct answers so far,  so here's the probability method.

Suppose that all 17 were injured, some of them critically, and that 4 of them subsequently die, (at intervals of several minutes say). The probability that the first to die is a non-skier is 14/17, that the second third and fourth to die are also non-skiers 13/16, 12/15 and 11/14 respectively. The required probability will be the product of these, 24024/57120 = 143/340.

Bertie  May 21, 2014
#1
+996
0

Well, three skiiers on a plane of 17. Considering that one person dies each time, the number decreases by 1 in both the numerator and the denominator.

$$\left({\frac{{\mathtt{3}}}{{\mathtt{17}}}}\right){\mathtt{\,\times\,}}\left({\frac{{\mathtt{2}}}{{\mathtt{16}}}}\right){\mathtt{\,\times\,}}\left({\frac{{\mathtt{1}}}{{\mathtt{15}}}}\right) = {\frac{{\mathtt{1}}}{{\mathtt{680}}}} = {\mathtt{0.001\: \!470\: \!588\: \!235\: \!294\: \!1}}$$

The odds are 1/680

GoldenLeaf  May 21, 2014
#2
+92775
+8

Probability is not my strong suit but this is what i think.

P= number of ways 4 can be chosen from 14 / number of ways 4 can be chosen from 17

P= 14C4 / 17C4

P = 1001 / 2380

$$\mbox{P(all 3 survive) }=\frac{1001}{2380}=\frac{143}{340}$$

$${\frac{{\mathtt{1\,001}}}{{\mathtt{2\,380}}}} = {\frac{{\mathtt{143}}}{{\mathtt{340}}}} = {\mathtt{0.420\: \!588\: \!235\: \!294\: \!117\: \!6}}$$

Can another mathematician please check this - I'm fairly confident that it is correct.

Melody  May 21, 2014
#3
+87294
+8

Probabilty isn't my strong point, but I'll take a run at this one.

So, basically, we first want to count the sets of people who might die - what a morbid problem!!

The total number of people who could die is given by choosing some group of 4 from the 17 =  C(17,4) = 2380

Now, let's look at the possible sets where 1 skier dies. This is given by C(3,1)*C(13,3) = 858 sets

Now, let's look at the possible sets where 2 skiers die - C(3,2) *C(13,2) = 234 sets

Now let's consider the sets where all three skiers die = C(3,3) * C (13,1) = 13

So, the total number of sets containing any of the skiers = 1105

Thus, the chances that all three survive are given by:

1 - (the number of sets containing any of the skiers)/(the total number of possible sets)

=  1 - (858 + 234 + 13)/2380 ≈ 53.6 %

OOPS !!    Melody pointed out a math error  I made....let me correct this...and as she indicated recently, she DOES believe in "do-overs"....I still like my logic, though!

Now, let's look at the possible sets where 1 skier dies. This is given by C(3,1)*C(14,3) = 1092 sets

Now, let's look at the possible sets where 2 skiers die - C(3,2) *C(14,2) = 273 sets

Now let's consider the sets where all three skiers die = C(3,3) * C (14,1) = 14

So, the total number of sets containing any of the skiers = 1379

Thus, the chances that all three survive are given by:

1 - (the number of sets containing any of the skiers)/(the total number of possible sets)

==  1 - (1379)/2380 ≈ 42.1 %

Thanx, Melody!!

CPhill  May 21, 2014
#4
+92775
0

Okay, we have 3 answers - all different

We need an arbitrator - preferably one who knows what he/she is talking about.

also if possible please explain what is wrong with our logic.

Thank you.

Melody  May 21, 2014
#5
+92775
+8

Okay Chris,

I am taking a look at yours.

Now, let's look at the possible sets where 1 skier dies. This is given by C(3,1)*C(13,3) = 858 sets

shouldn't this be 3C1*14C3 = 3*364=1092 ?

Melody  May 21, 2014
#6
+87294
+8

We both got the same result...now, let's figure the probability that 2 board members out of (n) board members could arrive at the same (possibly) correct answer!!

CPhill  May 21, 2014
#7
+92775
0

EXCELLENT!!!!!

Melody  May 21, 2014
#8
+87294
0

HAHA!!!...and 57 minutes ago...you were looking for someone who knew what they were doing!!! (an arbitrator, I believe??)

Are we "sure" our answers are correct??

(Actually....I think they might be)

CPhill  May 21, 2014
#9
+92775
0

Yes I am sure.

Because

Two out of three ain't bad!

Melody  May 21, 2014
#10
+87294
0

But 2/3 = 66%

That leaves 1/3 chance = 33% = that we might not be!!

I say...let's call in the "troll" as a referee.....HE KNOWS ALL !!!

LOL!!

CPhill  May 21, 2014
#11
+92775
0

Okay

Where's 'our' KNOW-IT-ALL TROLL when we need him?

He's probably AWOL with Sir Cumference!

Melody  May 21, 2014
#12
+87294
0

I'm thinking he was on that plane...and maybe he doesn't ski, either......

Mmmmmmm......maybe we've solved a forum "problem"

(At least there's about a 58% chance of it....)

CPhill  May 21, 2014
#13
+92775
0

NOW that is a percentage that I would very seriously challenge!

P(troll gone)=P(troll was on plane)*P(troll died) $$\rightarrow 0$$

Melody  May 21, 2014
#14
+87294
0

Yeah...we couldn't be that fortunate, huh??

CPhill  May 21, 2014
#15
+92775
0

That's not nice Chris.  So long as we keep him on a tight leash he is fun to have around.

You know that just as well as I do!

Melody  May 21, 2014
#16
+889
+8

There are just about always two methods for dealing with problems like this, a counting method and a probability method, (and often one is more convenient than the other.)

The counting method has been used for both of the correct answers so far,  so here's the probability method.

Suppose that all 17 were injured, some of them critically, and that 4 of them subsequently die, (at intervals of several minutes say). The probability that the first to die is a non-skier is 14/17, that the second third and fourth to die are also non-skiers 13/16, 12/15 and 11/14 respectively. The required probability will be the product of these, 24024/57120 = 143/340.

Bertie  May 21, 2014
#17
+2353
0

But what if the plane was carrying 4 people that died in a crash in coffins in the cargo room. Then the plane might not have crashed at all and the skiers survive

Unless the skiers died in a skiing accident off course

reinout-g  May 21, 2014
#18
0

If there were 3 skiers on plane of 17 and 4 people on the plane died of a crash, what is the chance that all 3 skiers survive?

----

This probability is trickier than it looks.

Four (4) will die and at most only three (3) can be skiers.

By deduction one (1) will die and not be a skier.

Now 16 remain, three (3) of whom are skiers.

From this calculate the probability of selecting (Z) correct out of (R) draws from (N) numbers. (Z) (in this case) defines the probability of a skier dying.

Probability= (R!/(Z!*(R-Z)!) * (N-R)!/(((N-R)-(R-Z))!*(R-Z)!)/(N!/((R!)*((N-R)!)))

$${Probability =}\frac{\frac{R!}{Z!*(R-Z)!} * \frac{(N-R)!}{((N-R)-(R-Z))!*(R-Z)! }}{\frac{N!}{R!*(N-R)!}}$$

Column ID’s: A= (R!)/(Z!(R-Z)!)

B= (N-R)!/(((N-R)-(R-Z))!*(R-Z)!)

C= N!/((R!)*((N-R)!))

D= Probability of (Z) skiers dying.

E= 1/Probability

N     R     Z     A     B      C                   D                            E

16   3      3     1     1      560     0.001785714285714     560.0000000000

16   3      2     3    13     560     0.069642857142857       14.3589743590

16   3      1     3    78     560     0.417857142857143        2.3931623932

16   3      0     1  286     560     0.510714285714286        1.9580419580

-----------

Probability of zero skiers dying ~ 0.511 (51.1%)

(Professional help provided by Francis and Frances)

by: Someone Who Knows Everything

Guest May 21, 2014
#19
+92775
0

deleted deleted

Melody  May 21, 2014
#20
+26745
0

My view is:

Probability that 4 non-skiers died (hence 3 skiers survived) is:

$${\frac{{\mathtt{14}}{\mathtt{\,\times\,}}{\mathtt{13}}{\mathtt{\,\times\,}}{\mathtt{12}}{\mathtt{\,\times\,}}{\mathtt{11}}}{\left({\mathtt{17}}{\mathtt{\,\times\,}}{\mathtt{16}}{\mathtt{\,\times\,}}{\mathtt{15}}{\mathtt{\,\times\,}}{\mathtt{14}}\right)}} = {\frac{{\mathtt{143}}}{{\mathtt{340}}}} = {\mathtt{0.420\: \!588\: \!235\: \!294\: \!117\: \!6}}$$

Oops! Just noticed that this is the same as Bertie's reply (though Bertie did a more complete job by including an explanation).

Alan  May 22, 2014
#21
+92775
0

It is the same as mine and Chris's as well!!

Melody  May 22, 2014


# Asymptotes as the lines y=x an y=-x

Hi there.

I'm a maths teacher and today was having a discussion with my Head of Department about asymptotes (as you do!)

She was me if I could think on an equation of a graph(s) which has an asymptotes at the line y=x and another at y=-x.

Thinking about it, neither of us could come up with anything. It's really bugging me now. I ain't too sure if there is such a function...though it seems silly there not being.

The only way I managed to get a graph like what I wanted was to rotate the graph of y=1/x by various angles.

So can such a graph exist? Is it possible to transform equations of graphs via rotations (something I can't ever remember doing)?

Hope I can come up with an answer by tomorrow :)

$$y = x \tanh{x}$$ ?

as

$$x \tanh{x} = x \frac{e^x - e^{-x}}{e^x + e^{-x}}$$

therefore, for large positive x,

$$x \tanh{x} \approx x \frac{e^x}{e^x} = x$$

and for large negative x

$$x \tanh{x} \approx x (\frac{-e^{-x}}{e^{-x}}) = -x$$

arildno
Homework Helper
Gold Member
Dearly Missed
Dogtanian said:
Hi there.

I'm a maths teacher and today was having a discussion with my Head of Department about asymptotes (as you do!)

She was me if I could think on an equation of a graph(s) which has an asymptotes at the line y=x and another at y=-x.

Thinking about it, neither of us could come up with anything. It's really bugging me now. I ain't too sure if there is such a function...though it seems silly there not being.

The only way I managed to get a graph like what I wanted was to rotate the graph of y=1/x by various angles.

So can such a graph exist? Is it possible to transform equations of graphs via rotations (something I can't ever remember doing)?

Hope I can come up with an answer by tomorrow :)
You certainly can rotate curves!

For example, the curve described by the equation:
$$x^{2}-y^{2}=1$$
has asymptotes y=x and y=-x.

Note, however, that in this case, there exists no function of x, by which the y-coordinates of the curve could be computed, and the curve in question cannot be regarded as the graph of some function, i.e, the set of points describable as (x,f(x)), where f is some function.

robphy
Homework Helper
Gold Member
Doesn't one branch of that hyperbola still have those lines as asymptotes?
In a physics context, the worldline of a uniformly accelerated observer [which can be regarded as function (t,x(t)), where x(t)=sqrt(1+t^2)] is asymptotic to a light cone.

Thanks for the help guys :D

My head of department was so sure you could each of the 4 sections between the said asymptotes filled with a curve.

Using what the first two posts said, I drew the graphs of

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

to get what I needed (at least I think that is what I i if I remember correctly back to last night....)

But I only went and forgot all about this today until just now...so I never i speak to my HofD about it...never mind :D

Hurkyl
Staff Emeritus
Gold Member
You can combine the four curves to get one that fills the whole thing.

x² - y² = 1

fills in two sections, and

y² - x² = 1

fills in the other two.

We can combine them into one equation:

(x² - y² - 1) (y² - x² - 1) = 0

which will fill in all four quadrants.

robphy