Wikipedia:Reference desk/Archives/Mathematics/2010 May 6

= May 6 =

Maclaurin expansion for e^(x^2+x)
Find the first 3 terms of the macluarin expansion for $$e^{x^2+x}$$

I know the first three terms for $$e^x$$ are $$1+x+\frac{x^2}{2}$$

so presumably the first three terms for $$e^{x^2+x}$$ are $$1+(x^2+x)+\frac{(x^2+x)^2}{2} = 1+x+x^2+\frac{x^4+2x^3+x^2}{2}$$

but apparently the answer is $$1+x+\frac{3x^2}{2}$$ --115.178.29.142 (talk) 01:56, 6 May 2010 (UTC)
 * Just combine the x2 terms in the expression you got. You can can generally (meaning with all due attention to convergence issues) manipulate power series like this and then collect like terms to get a new power series.--RDBury (talk) 02:43, 6 May 2010 (UTC)


 * If you are familiar with multiplication of power series you can just multiply the series for exp(x) and the series for exp(x2) and obtain quickly several terms by hand. In fact the resulting series has coefficient an/n! where an is an interesting sequence . --84.221.69.102 (talk) 07:49, 6 May 2010 (UTC)


 * Just to clarify: in the question, "the first three terms of the expansion" refers to monomials like a, bx, cx2. So what you did is correct; just forget about the higher order terms you got (that is, x3 and x4/2). Note that if you further expand ex 2+x you will find (x2+x)3/3! and so on, so there is no more powers of x of degree 0 1 or 2 around. If you wanted the fourth term of the expansion too, you have to consider (x2+x)3/3! too, of course.--pm a 08:56, 6 May 2010 (UTC)


 * Alternative approach:
 * $$e^{x^2+x}=e^xe^{x^2}=\left(1+x+\frac{x^2}{2}+O(x^3)\right) \left( 1+x^2+O(x^3) \right)$$
 * $$ =1+x+\frac{x^2}{2}+x^2+O(x^3) = 1+x+\frac{3x^2}{2}+O(x^3)$$ Gandalf61 (talk) 11:32, 6 May 2010 (UTC)

don't get why I don't get my moment for this disc doesn't become zero
I have half a disc with a hole in it -- the outer border is r=2 and the inner border is r=1, with restriction x>0. The density function given is x/(x^2 + y^2) which I converted to cos t. Setting up the double integral with bounds -pi/2 to pi/2 with respect to t, and 2 to 1 for r, I get a mass of 3. OK.

Using the formulae for two-dimensional moments: M_x = (double integral) y * rho * dy dx = (double integral) r sin t cos t r dr dt = 7/3 * 0.5 * (sin^2 pi/2 - sin^2(-pi/2)) = 7/3

M_y = (double integral) x * rho * dy dx = (double integral) r (cos t)^2 r dr dt    = 7/3 * 0.5 (t + (sin pi/2 * cos pi/2 - cos(-pi/2) * sin(-pi/2))  = 7/6

Center of mass is then: (7/18, 7/9)

This puzzles me, since x-component of the center of mass appears to be quite firmly in a whole, but the density should be biased towards the end of the disc. The y-component isn't zero.

It's the trig function part that I think is responsible.... integrating cos t sin t can yield 0.5 (sin t)^2 or -0.5(cos t)^2. Using the latter formula gives me an M_x value that is quite zero. They appear to differ by a constant... which should disappear in an indefinite integral ... except when cos(pi/2) is involved. Help? John Riemann Soong (talk) 04:38, 6 May 2010 (UTC)
 * Is the density $$\frac{x}{x^2+y^2}$$ or $$\frac{x}{\sqrt{x^2+y^2}}$$? The latter is $$\cos t$$, the former is $$\cos t/r$$. -- Meni Rosenfeld (talk) 06:28, 6 May 2010 (UTC)
 * More importantly, $$\sin^2\tfrac{\pi}{2} - \sin^2\tfrac{-\pi}{2} = 0$$, not 2. -- Meni Rosenfeld (talk) 09:01, 6 May 2010 (UTC)

Random walk oddity
I have a non-gaussian distribution that I made up to model the steps in a stochastic time series. As such, it fits the actual histogram quite well. The distribution has a sharper, taller peak and fatter tails than the normal distribution, and it has infinite kurtosis.

So I use the inverse cumulative form of my distribution to create my own random walk. That works fine too. I get a bunch of steps distributed according to my distribution.

Then I decide that each step should be made of 100 smaller steps having 1/100 the variance of the larger steps. Each of those smaller steps is distributed according to my distribution.

When I look at the histogram of the larger steps, the distribution looks gaussian! The peak and tails fit a gaussian distribution. If I use, say, 20 steps per large step, the resulting distribution is something in between mine and a gaussian. It seems the more small steps I use to build a large step, the more gaussian the resulting large steps appear.

Why? Does that make sense? What would I do to ensure that the larger steps maintain the same distribution as the smaller steps? ~Amatulić (talk) 05:52, 6 May 2010 (UTC)


 * Surely you are familiar with the Central limit theorem? As long as the variance is finite, adding many independent copies will give something that is roughly Gaussian.
 * However, the situation may not be that bad - it may look like Gaussian for small values of x, but it will still have infinite kurtosis and hence, black swans that are significantly more probable than in Gaussian.
 * Stable distributions usually have infinite variance, so you may not be able to find exactly what you are looking for. -- Meni Rosenfeld (talk) 06:38, 6 May 2010 (UTC)


 * Central Limit Theorem -- looking at the article, it looks familiar, like something I learned 27 years ago when I was in college and never encountered since. OK, I get it now. So much to re-learn.... I'm basically a layman again.


 * Actually, adding many independent copies looks exactly like a gaussian, tails and all, so black swans are really no more probable than with a gaussian. I mean, my distribution at 5-sigma from the mean is 100K more likely to generate black swan events than this.


 * Stable distributions -- that's another topic I looked at before I spent all this effort rolling my own. Can't be written out analytically? Need numerical methods for everything? I honestly gave up trying to work with such a thing. All I'd need is a general expression for β=0 and α<2.


 * Here's what I'm trying to simulate. Take any time series of prices for any market: could be soybeans, copper, Euro currency, Dow Jones index, NASDAQ, orange juice, whatever. Sample the step sizes between log prices 10,000 times at any interval, you get a distribution similar in appearance to mine (see picture - I did a lot of tests, I believe that one shown is the S&amp;P 500 index). Sample it at any other interval, and you get the same distribution. Always.


 * So I spent a couple weeks inventing this beautifully tractable distribution that seems to fit the data almost perfectly. It's integrable, it's invertible, it's closed-form. You helped me out in characterizing variance and kurtosis (thanks). Then I used my distribution to generate a random walk. Its histogram of step sizes practically overlays that of the actual market I'm simulating. Visually it looks the same, tails and all. But when I sample the step size at any interval other than 1, it isn't the same, and approaches a gaussian distribution at high sample intervals.


 * Now, I understand that what I observe is because my distribution has a finite variance. OK, fine. My observations imply that the actual underlying market distribution has infinite variance.
 * But this is where I stumble: I have a finite data set (say 12,000 samples), and you said yourself to me that a finite data set often results in benign values for variance and kurtosis because it can't contain all the possible outliers. Yet, I built my own distribution to characterize the market's, using all the data I have, so it should model this finite data set rather well. What I'd like to know is, why does this finite data set exhibit the same non-normal distribution at any sample interval? I hope I stated the problem clearly through my befuddled brain. ~Amatulić (talk) 06:16, 7 May 2010 (UTC)
 * The simplest explanation I can think of is that the differences between successive days are not independent - that is, if it increases one day it has a higher probability than usual to increase the next. You should try to find this dependence and generate your random walk accordingly. -- Meni Rosenfeld (talk) 08:19, 7 May 2010 (UTC)


 * Hmm, but then that would have to be true on any time frame -- minutes, hours, days, weeks, months. A fractal dependency, if you will. I can investigate, but I have doubts. If one knows such a dependency, one could become wealthy quite easily and quickly. I rather doubt the dependency exists (or is discoverable) considering the efforts people have put into technical analysis of markets over the past several decades to find such a "holy grail". All I'm trying to do here is generate an artificial time series with the same characteristics as a real time series. ~Amatulić (talk) 16:48, 7 May 2010 (UTC)

All right, that took all day! I figured out an algorithm to generate random walks with my distribution such that it gets past the Central Limit Theorem. If I want daily steps made up of n smaller steps, and both daily steps and smaller steps must be distributed according to my distribution, then the mean value used for the smaller steps must be varied by my distribution. That is:
 * Update:

$$\sigma_s=\frac{\sigma_L}{n}$$

$$\mu_s = \frac{\mu_L + F^{-1}(Z, 0, \sigma_L)} {n}$$

where Then, each new small step vs is:
 * Subscript L indicates the large step
 * Subscript s indicates the small steps making up the large step
 * F&minus;1 is my inverse cumulative distribution
 * Z is a uniformly distributed random number between 0 and 1
 * n is the number of steps that make up a large step

$$v_s=F^{-1}(Z, \mu_s, \sigma_s)$$

and the sum of n small steps equals one large step. I have verified that the large steps have the desired probability density function $$f(x, \mu_L, \sigma_L)$$.

As for the question if there's a dependency from one step to the next: Yes, slightly. I found that in the market data, a large step has a tendency to be followed by another large step with greater frequency than steps generated randomly. I observed no directional dependency; both the market and randomly-generated steps looked the same in that regard. ~Amatulić (talk) 01:35, 8 May 2010 (UTC)
 * Ok, there's not much more I can add. If you haven't already, make sure to take a close look at the Wiener process (aka Brownian motion), in particular Construction of Brownian Motion - the way it's constructed is reminiscent of what you've done here. Brownian Motion is a more detailed discussion. -- Meni Rosenfeld (talk) 18:58, 8 May 2010 (UTC)
 * Thank you for your help and the links. I especially like the easy informal tone of the more detailed PDF document. ~Amatulić (talk) 22:16, 8 May 2010 (UTC)

Problem with product rule and second derivatives
I'm having problem in understanding the result of differentiating two times a compostion, that is

D^2(F \circ G)[h,k] $$ I can't understand wheter (and why) the result should be

((D^2 F) \circ G) [DG[h],DG[k]]+((DF) \circ G) [D^2G[h,k]] $$ rather than

((D^2 F) \circ G) [h,DG[DG[k]]]+((DF) \circ G) [D^2G[h,k]] $$ I just start with
 * $$D(F\circ G)[h]=(DF\circ G)[DG[h]]$$

and apply the rule
 * $$ D(M[v])[h]=(DM[h])[v]+M[Dv[h]] $$

to $$M[\cdot]:=D(F\circ G)[\cdot]$$ and $$v:=DG[h]$$ but at a certain point I'm not able to evaluate $$ D(M[v])[h]$$ because I've to decide wheter

D(((DF)\circ G)[h])[v]=((D^2 F) \circ G)[DG[h],v] $$ or

D(((DF)\circ G)[h])[v]=((D^2 F) \circ G)[h,DG[v]] $$ and this whould make a great difference since I have $$v=DG[k]$$.

What am I missing?--Pokipsy76 (talk) 15:20, 6 May 2010 (UTC)


 * Is D an arbitrary differential operator? I may be being stupid, but why are G and D2G functions of two variables and DG a function of one? --Tango (talk) 15:29, 6 May 2010 (UTC)


 * Maybe I've not been very clear. Well D is the usual differential operator in an euclidean (or a Banach) space (so D2G(x) is a bilinear operator and DG(x) is a linear operator), F(x) and G(x) are differentiable functions from a vector space U to itself and their variables are never considered in the formulas above: the only variables which appear are the variables of the linear operators. I'm using the notation which can be found also here. Thank you for your attention.--Pokipsy76 (talk) 15:45, 6 May 2010 (UTC)


 * You want to differentiate the map $$M(x)[v(x)]$$, where $$M(x):=DF(G(x))$$ and $$ v(x):=DG(x)[h]$$ as you said. (I'll keep the x, even if it makes a bit heavier the notation). Applying your rule $$D(M(x)[v(x)])[k]=(DM(x)[k])[v(x)]+ M(x)[Dv(x)[k]]$$ you get
 * $$D^2F(G(x))[DG(x)k,DG(x)h]+ DF(G(x)[D^2G(x)[k,h]],$$
 * and this is $$D^2(F\circ G)(x)[k,h]$$ (note that the result is symmetric in h,k as it has to be).
 * POssibly you mixed a bit the role of h and k; in all the computation h is fixed. Remark: I think we agree that $$D^2 B(x)[k,h]$$ coincides with the differential of $$x\mapsto DB(x)[h]$$ evaluated in k (we used this more that once). Indeed you may apply again your product rule for M(x)[v(x)] with M(x):=DB(x) and v(x):=h; or consider $$x\mapsto DB(x)[h]$$ directly as a composition of $$x\mapsto DB(x)$$ and $$L\mapsto L[h]$$; the latter is the evaluation at h and is linear. Is everything ok? --pm a 06:04, 7 May 2010 (UTC)
 * I'm not sure... I need to think about it.--Pokipsy76 (talk) 15:56, 7 May 2010 (UTC)


 * In any case, the second possibility you wrote at the beginnning is not symmetric in h,k, and couldn't be correct. As to the term
 * $$D(((DF)\circ G)[h])[v]

$$
 * that you want (where v is fixed), observe that it represents the differential of the map $$((DF)\circ G)(x))[v]$$, evaluated in the variation h; this is different from the differential of the map $$((DF)\circ G)(x))[h]$$ evaluated in v as variation. The notation may have confused you a bit, but the point is that the former object is exactly what is wanted by the computation, not the latter (whatever notation you adopt). Now, the map $$x\mapsto DF(G(x))[v]$$   is a composition of three maps: G, DF, "evaluation at v": $$x \mapsto G(x)\mapsto DF(G(x))\mapsto DF(G(x))[v]$$, and the last (evaluation at v) is linear. Therefore the differential of this composed map computed in the variation h, is the composition of differentials: $$h\mapsto DG(x)[h]\mapsto D^2F(G(x))[DG(x)[h]]\mapsto  D^2F(G(x))[DG(x)[h], v]$$. --pm a  08:42, 8 May 2010 (UTC)

Algebra question
Hey I was playing around with math a bit and I was wondering if it was possible to solve certain types of equations for $$x$$ by algebraic means (i.e. - no calculator graphing and finding points of intersection). Specifically, I was wondering about ones where $$x$$ might appear within a trig function and outside the trig function. Also, the same question applies for ones containing logarithms and exponentials. For example, would it be possible to solve the equation $$5=\frac{e^x}{x^2+4}$$ without a calculator? Thanks!!! — Trevor K. — 20:54, 6 May 2010 (UTC)  —Preceding unsigned comment added by Yakeyglee (talk • contribs)
 * Generally, the answer is that there is no elementary analytical solution. An equation like the one you posted can probably be solved in terms of the Lambert W function, but to say that the solution to x = y*e^y is y = W(x) isn't really a genuine solution, since that's just the definition of the W function. The same goes for equations that include logarithms, and probably trigonometric functions (since they can generally be written in terms of complex exponentiation). Confusing Manifestation (Say hi!) 23:56, 6 May 2010 (UTC)
 * "The solution to $$x=ye^y$$ is $$y=W(x)$$" isn't any less of a genuine solution than "The solution to $$x=e^y$$ is $$y=\log x$$", since that's just the definition of the log function.
 * Anyway, the solution to the OP's particular example apparently cannot be expressed even with Lambert's W (it doesn't handle addition very well). This goes for trigonometric functions too, as their reduction to exponentiation requires addition.
 * The OP should note that there are root-finding algorithms significantly more sophisticated than "calculator graphing", which can even be done by hand with some work. -- Meni Rosenfeld (talk) 05:40, 7 May 2010 (UTC)

No, you cannot do it algebraically, and I don't think you can do it by hand either, but you can expand the exponential (or the trig functions) into a polynomial of degree, say, 19. Download the J (programming language) and type   |.{:>p.(^-20 0 5&p.)t.i.20 and get the real root 4.96444. There are also nonreal complex roots such as 0.0465684+2.02331i. Check that 4.96444 is a solution to the original equation by typing (^%4 0 1&p.)4.96444 and get the result 5, which is what you wanted. Bo Jacoby (talk) 16:00, 7 May 2010 (UTC).