I was attempting an approximated value of pi through the formula of  pi= 3 + (4/(2*3*4)) - (4/(4*5*6)) + (4/(6*7*8)) - … (and so on). However, my code (shown below) had 2 separate answers (3.1415926535900383 and 3.141592653590042) when:   approx variable started with "0" and "3" respectively  n=10000   Does anyone know why?  def approximate_pi(n):     approx=0     deno=2     if n == 1:         return 3     for x in range(n-1):         if x%2:             approx -= 4/((deno)*(deno+1)*(deno+2))         else:             approx += 4/((deno)*(deno+1)*(deno+2))         deno+=2     return approx+3   and  def approximate_pi(n):     approx=3     deno=2     if n == 1:         return 3     for x in range(n-1):         if x%2:             approx -= 4/((deno)*(deno+1)*(deno+2))         else:             approx += 4/((deno)*(deno+1)*(deno+2))         deno+=2     return approx
27
Consider the following code:   0.1 + 0.2 == 0.3  -&gt;  false   0.1 + 0.2         -&gt;  0.30000000000000004   Why do these inaccuracies happen?
9464
I was having some thought about what would be the syntax to make the end point evaluation of derivatives or integrals. Such as making the | with the two end points of evaluation on the top an bottom of the line. Any suggestions would be wonderful.
115365
It's probably a vey silly question, but I'm confused. Does o(1) simply mean $\lim_{n \to \infty} \frac{f(n)}{\epsilon}=0$ for some $n&gt;N$?
33882
I have been trying around different ranges of summations:  $$ \sum_{(m,n) \in \mathbb{Z}^2} \frac{m^2 - n^2}{(m^2 + n^2)^2} = 0$$  That's not any good.  What about if we restrict to $m, n \in \mathbb{Z}$ as positive integers.    $$ \sum_{m &gt; 0, n &gt; 0} \frac{m^2 - n^2}{(m^2 + n^2)^2} = 0$$  Now here's an anti-symmetry.  I do not like taking out the symmetry, but perhaps I can ask about:   $$ \sum_{m &gt;  n &gt; 0} \frac{m^2 - n^2}{(m^2 + n^2)^2}  = \; ? \tag{$*$} $$  There doesn't seem to be a change of variables that can work.  And we've used symmetry about as much as we can.  This looks related to:  $$  \sum \frac{1}{n^2} = \frac{\pi^2}{6}$$  Perhaps this other series ($*$) also has a special value.
119317
I run into this infinite product today. I don't have that much experience evaluating products therefore I don't have any idea of how to tackle this.   Here is the question. Evaluate (if possible) in a closed form the product:  $$\Pi = \prod_{n=1}^{\infty} \frac{1}{1+\pi^{{\large \frac{1}{2^n}}}}$$  The numerical value seems to be $\Pi= 0.534523$ which is very close to $\frac{\pi}{6}$ taking into account that $\frac{\pi}{6} \approx 0.523598$. In the mean time W|A evaluates it to $0$. I'm lost.   Can the community help?  Edit: Based on the answer we have two products. The product I asked tends to zero and the bonus product provided by @you're in my eye (thanks for that) is $\frac{\ln \pi}{\pi-1}$.   Thanks for the quick response.
68266
I am interested in good integer approximation from below and from above for binary Log(N!).  and  provides only a general idea but not exact values. In other words I need integers A and B so that  A &lt;= Log(N!) &lt;= B
2846
Why does the following behave unexpectedly in Python?  &gt;&gt;&gt; a = 256 &gt;&gt;&gt; b = 256 &gt;&gt;&gt; a is b True           # This is an expected result &gt;&gt;&gt; a = 257 &gt;&gt;&gt; b = 257 &gt;&gt;&gt; a is b False          # What happened here? Why is this False? &gt;&gt;&gt; 257 is 257 True           # Yet the literal numbers compare properly   I am using Python 2.5.2. Trying some different versions of Python, it appears that Python 2.3.3 shows the above behaviour between 99 and 100.  Based on the above, I can hypothesize that Python is internally implemented such that "small" integers are stored in a different way than larger integers and the is operator can tell the difference. Why the leaky abstraction? What is a better way of comparing two arbitrary objects to see whether they are the same when I don't know in advance whether they are numbers or not?
72656
While I was reading the book Exploratory examples for real analysis, I came across this:     to show that : $$\lim_{x\rightarrow x_o}\frac{1}{h(x)} = \frac{1}{\lim_{x\rightarrow x_o}{h(x)}} = \frac{1}{M}$$      Discussion:Let $\epsilon \gt 0$.we want to find $\delta \gt 0$ such that       if  $0 \lt |x-x_0| \lt \delta $,then $\Big|\frac{1}{h(x)}-\frac{1}{M}\Big|\lt \epsilon$.      In order to get expression involving $|h(x)-M|$,we first find the common denominator:        $\Big|\frac{1}{h(x)}-\frac{1}{M}\Big|=\Big|\frac{M-h(x)}{M~h(x)}\Big|$      $~=\Big|\frac{h(x)-M}{|M|~|h(x)|}\Big|$.      As we have to deal with variable term $|h(x)|$ in denominator.We can construct bound .Let $\epsilon =\frac{|M|}{2}$ ,since lim$_{x\to x_o}h(x)=M$,there exists $\delta_1\gt 0~~$ s.t.       if $0 \lt |x-x_0| \lt \delta_1 $,then $|h(x)-{M}|\lt \frac{|M|}{2}$.      As you study steps below,identify that step where $h(x)\neq 0$ for all $0 \lt |x-x_0| \lt \delta_1 $ plays a critical role:      $|M|=|M-h(x)+h(x)|$      $~~~~~~\leq |M-h(x)|+|h(x)|$      $~~~~~~= |h(x)-M|+|h(x)|$      $~~~~~~\lt \frac{M}{2}+|h(x)| \implies$      $\frac{|M|}{2} \lt |h(x)| \implies$      $\frac{1}{h(x)}\lt \frac{2}{|M|}$,where $0 \lt |x-x_0| \lt \delta_1 $.      Now that we've bound for $1/h(x)$,we can apply the definition to term $|h(x)-M|$.      Since     lim$_{x\rightarrow x_o}h(x)=M$,we can find $\delta_2 \gt 0$ such that,       $~~~~~~~~~~~~~~~~~~~~~~~~~~~~$if  $0 \lt |x-x_0| \lt \delta_2$, then $|h(x)-M|\lt \frac{|M|^2 \epsilon }{2}$   The thing I can't understand is for what purpose did the author work with such complicated expression involving $\epsilon $ in the end of the discussion?
13370
I ran into this expression in a paper I was reading, and I'm confused about part of the meaning.  Here $u$ and $v$ are two polynomials.  $$u, v \in \mathbb{R}[x]$$  I'm not really familiar with usage of $[x]$ here, but if it means "nearest integer", then isn't this expression equivalent to simply:  $$u, v \in \mathbb{Z}$$
95629
I have a question that has been bothering me for quite some time. In second order logic sometimes there is an indication that a variable can be both bound and free. The simplest example I can give is using the variable $v_0$ and the constants $c_0, c_1$ who are not equal to one another. How does one interpret the following formula. $$(v_0=c_0)\wedge \left[ \exists v_0 (v_0 = c_1)\right]$$  I see a few possible interpretations:   The statement is not actually valid because variables cannot be both bound and free. The formula will always be false because $(v_0=c_0)$ restricts $v_0$ such that there cannot exist a $v_0=c_1$ The formula is true when $v_0=c_0$ because one essentially treats the free version of a variable differently from the bound version such that even though $v_0=c_0$ in this particular instance, it still theoretically could be that a variable $v_0$ equals the constant $c_1$ and thus the existence clause is satisfied as well.   I also recognize that it could be something completely different from any of these that I have not thought of yet, I was just curious if there was an accepted way to handle variables which are both free and bound because I have not found any satisfying answers as of yet.
17003
I have a function defined as follows: $f(x,y)= \dfrac{x^2-y^2}{\left(x^2+y^2\right)^2}$, if $(x,y)\neq (0, 0)$ and $f(x,y)=0$ if $(x,y)=(0,0)$.  Now, $$\int_0^1\int_0^1 f(x,y)\,\text{d}x~\text{d}y=-\frac{\pi}{4}$$ and $$\int_0^1\int_0^1 f(x,y)\,\text{d}y~\text{d}x=\frac{\pi}{4}.$$   The question I have is this: why does this not contradict Fubini's theorem?    thanks.
226
On page 19 of the textbook  (by James, Witten, Hastie and Tibshirani--it is freely downloadable on the web, and very good), the following is stated:  Consider a given estimate $$\hat{Y} = \hat{f}(x)$$ Assume for a moment that both $$\hat{f}, X$$ are fixed. Then, it is easy to show that: $$\mathrm{E}(Y - \hat{Y})^2 = \mathrm{E}[f(X) + \epsilon - \hat{f}(X)]^2$$ $$ = [f(X) - \hat{f}(X)]^2 + \mathrm{Var}(\epsilon)$$  It is further explained that the first term represents the reducible error, and the second term represents the irreducible error. I am not fully understanding how the authors arrive at this answer. I worked through the calculations as follows: $$\mathrm{E}(Y - \hat{Y})^2 = \mathrm{E}[f(X) + \epsilon - \hat{f}(X)]^2$$ This simplifies to $[f(X) - \hat{f}(X) + \mathrm{E}[\epsilon]]^2 = [f(X) - \hat{f}(X)]^2$ assuming that $\mathrm{E}[\epsilon] = 0$. Where is the $\mathrm{Var}(x)$ indicated in the text coming from? Any suggestions would be greatly appreciated.
2201
I want a to be rounded to 13.95.  &gt;&gt;&gt; a 13.949999999999999 &gt;&gt;&gt; round(a, 2) 13.949999999999999   The  function does not work the way I expected.
99808
I'm looking for a function $m(x,y)$ that smoothly approximates $x \bmod y$, and I'm assuming there would be some $n$ or $\varepsilon$ in the body of $m(x,y)$ that defines the degree of approximation such that as $n$ goes to infinity or $\varepsilon$ goes to zero,  $$ m(x,y)= x \bmod y. $$  I've looked at, for example, $\sin(x/y)$ and have been trying to figure out ways to make $\sin(x)$ more "steep" so that I can apply such techniques to $\sin(x/y)$ in order to perhaps more closely approximate $x \bmod y$.  The analogy I'm looking at is the approximation of $\mid x\mid$ as $\sqrt{x^2 + \varepsilon)}$ where epsilon is some small quantity.  Does a similarly smooth function exist for $x \bmod y$?
107764
This will probably be considered very simple, but I am just a beginner:  I'm developing a software application where temperatures need to be added and subtracted. Some temperatures are in Celsius, some in Kelvin. I know how to convert to/from Kelvin (273.15), but how should one go about adding and subtracting these? Should everything be converted to Celsius first?  For example:  0°C + 0°C = 0°C 0°C + 500°C = 500°C   But:  0°C + 273.15K = ?   If we put everything in Kelvin, we get:  273.15K + 273.15K = 546.3K   If we put everything in Celsius, we get:  0°C + 0°C = 0°C   But obviously, 546.3K isn't equals to 0°C.  Now, you might say I can't add temperature to temperatures (but should be adding energy or something? not sure). But the reason I'm doing this is because we need to interpolate. I have a collection of key-value-pairs, like this:  973K  -&gt; 0.0025 1073K -&gt; 0.0042 1173K -&gt; 0.03 1273K -&gt; 0.03   Now I need to get the value for 828°C. So I need to interpolate, which means adding/subtracting values.  I hope I'm making sense.
28609
I am sure there is something wrong i am doing but i just want someone to point it to me.  Why can't we say that $e^{\frac {\pi i}{3}} = \left(e^{\pi i}\right)^{\frac {1}{3}} = (-1)^{\frac {1}{3}} = -1$ Why do we have to calculate it by the formula as it is (which produces different value)  Another question is why can't we say that $ (-1)^{\frac {1}{2}} = \left(\left (-1\right)^{2}\right)^{\frac {1}{4}} = 1^{\frac {1}{4}} = 1$  Again i have to say that i know this is all wrong i just want to know why it is wrong
19758
I don't understand which R code I am supposed to be using to figure these problems out. I brief explanation of what the code is doing would be amazing. The problems below are two different applications I'm expected to understand and I don't get either. Thank you!  Problem 1. Let Z~N(0,1) For each of the following, find c such that the equation is true.   a) P(Z&lt;c) = 0.8413  b) P(0&lt;Z&lt;c) = 0.3051  c) P(-c&lt;Z&lt;c) = 0.8664   Problem 2. X~N(3,4) compute  a) P(X&gt;3)  b) P(1&lt;X&lt;8)  c) P(-1.5&lt;X&lt;1)