Wikipedia:Reference desk/Archives/Mathematics/2009 March 3

= March 3 =

Conditional convergence of complex series
The harmonic series $$\Sigma1^n/n$$ diverges. I'm guessing that replacing the 1 with any other "unit circle" complex number in the numerator $$e^{i\theta}$$ would lead to convergence, a special case being the alternating harmonic series $$\Sigma(-1)^n/n$$. In this case the Taylor series for the complex Log function makes it easy to solve.

Question is, does this work in general? Given a real alternating sequence which is conditionally convergent but not absolutely convergent, is it always the case that replacing the (-1) with $$e^{i\theta}$$ results in a complex sequence that is conditionally convergent? Zunaid 08:59, 3 March 2009 (UTC)


 * No, you can see this by altering your example slightly. just put in two zeros ( or something that converges rapidly if you dont like 0) after every second term as in
 * 1 - 1/2 + 0 - 0 + 1/3 - 1/4 + 0 - 0 + 1/5 - 1/6 + 0 - 0
 * Then put in ei&pi;/2=i
 * You'll see you get both the real and imaginary part going infinite. You're quite right about the original sequence though, anything within on on the unit circle except 1 will make it converge. Dmcq (talk) 10:43, 3 March 2009 (UTC)

Ah but wait! Let's force the sequence of terms to be "absolutely decreasing" i.e. abs(an+1) <= abs(an) (perhaps the inequality needs to be strict?) so that you can't "cheat" by inserting throw-away rapidly-converging terms as in your counter-example. Where does that leave us? Zunaid 13:44, 3 March 2009 (UTC)


 * That's a much better question, and in fact it is a quite important theorem, see Abel's test. Dmcq (talk) 15:27, 3 March 2009 (UTC)

Thanks! That was perfect. Zunaid 16:47, 3 March 2009 (UTC)

why is financial charts plotted on logarithmic scale
why is financial charts plotted on logarithmic scale pls —Preceding unsigned comment added by 92.230.67.192 (talk) 16:31, 3 March 2009 (UTC)


 * Charts are generally plotted on a logarithmic scale when there is a large range of values to be plotted so a linear scale would have to be very small. This means small variations would be invisible. The other reason, often related, is when the values being plotted high an exponential trend - plotting such a trend logarithmically results in a straight line, which is easy to recognise. Financial charts aren't always plotted logarithmically, but those that are are done so for one of these reasons. --Tango (talk) 18:18, 3 March 2009 (UTC)


 * What makes a log scale appropriate is not just that the range of values is large, but that the relative size of variations is important and not the absolute size. For example, say that in 1990, something went from 2 to 5; but in 2000, it went from 10 to 15.  If the 1990 increase is considered the larger one (because the relative increase is 150% rather than 50%), a log scale is appropriate.  This is typical with things like prices, although they are often shown on a linear scale for other reasons.  But if the 2000 increase is considered larger (because 5 points is more than 3 points), then you want a linear scale.  This is typical with things like interest rates or unemployment rates.  --Anonymous, 03:55 UTC, March 4, 2009.
 * To be perfectly honest, what matters if what you are trying to prove with your statistics. You choose a scale that makes the graph look like it shows what you are saying it should show. --Tango (talk) 13:30, 4 March 2009 (UTC)


 * Suppose you want to show the exchange rates between (say) the Italian lira and the Swiss franc from 1861 to 1999, during which time I believe the lira dropped by two orders of magnitude while the franc was relatively firm. If the number of lire to a franc is displayed linearly, it appears that the rate was nearly constant in the early period and much more volatile at the end, but this impression is (most likely) false.  If the value of a thousand lire in francs is shown linearly, it gives an equally false impression the other way around. — Stock prices are usefully shown on a log scale because what interests the investor is the ratio between prices at different dates: you want to know what you'd have if you bought $1000 worth of FooCorp in 2001 and sold it in 2002, regardless of the nominal price.  —Tamfang (talk) 18:35, 4 March 2009 (UTC)


 * I seem to remember reading that a log scale approximates to the rate of increase. 89.240.206.60 (talk) 22:27, 7 March 2009 (UTC)


 * A graph on a log scale shows the same slope for the same rate of proportional increase, regardless of the absolute amount of the variable in question. —Tamfang (talk) 04:43, 8 March 2009 (UTC)

ramanujan nested radicals problem
His article says that for this problem
 * $$\sqrt{1+2\sqrt{1+3 \sqrt{1+\cdots}}}.$$

He offered the solution
 * $$x+n+a = \sqrt{ax+(n+a)^2 +x\sqrt{a(x+n)+(n+a)^2+(x+n) \sqrt\mathrm{\cdots}}}$$

But how do you find those constants x,n,a? Equating the parts of the problem to the solution, it looks like there are no solutions. Particularly:
 * $$ax+(n+a)^2 = 1$$
 * $$a(x+n)+(n+a)^2 = 1$$

n is nonzero because equating the scalar multiples from the problem to those of the solution
 * $$x = 2$$
 * $$(x+n) = 3$$

So what are x,n,a for the problem he offered? The article says that the answer is x+n+a=3. .froth. (talk) 18:28, 3 March 2009 (UTC)


 * Not sure what you're saying as you've already done most of the work, am I missing something? You'd have x=2, n=1 and a=0. They're nice these nested radical problems I think. Dmcq (talk) 19:22, 3 March 2009 (UTC)


 * Oh a=0 wowwwww .froth. (talk) 20:59, 3 March 2009 (UTC)
 * Yes, see zero. It's an interesting new idea from India so I guess that's where Ramanujan heard about it ;-) Dmcq (talk) 15:05, 4 March 2009 (UTC)

Comparing MATLAB and C++
I have written up a few simulations in MATLAB but they take forever to run. Each simulation takes about 30 hours on a dual processor 14GB RAM linux station. My questions is that if I programmed and ran the simulation in C++, would it really be faster? Does anyone have an idea of by what factor will this increase? Someone told me it will speed up by a factor of 10 but that sounds like an exaggeration.

On another note, can anybody recommend a good random number generator for C++? The built in srand and rand are crap. I need something with a uniform distribution for some serious SERIOUS number crunching. Even in the simplest case, I will call the random generator more than 10,000 times so I don't want the numbers to be biased or start repeating. Thanks!-Looking for Wisdom and Insight! (talk) 19:49, 3 March 2009 (UTC)


 * I've used a pseudorandom number generator (PRNG) based on the one in Numerical Recipes in C++ a lot, but I won't recommend it. Not because it isn't good (it is), but because (1) it is non-free software, and (2) NR in C++ is an excellent example of Fortran in any language - I had to spend quite a while to de-uglify it. Our article on the Numerical Recipes books states that the GNU Scientific Library provides many of the same functions, I'd be surprised if a good PRNG wasn't one of them. The Art of Computer Programming has an excellent chapter on pseudorandom number generators if you want to write your own. If you do, I'd also like to recommend the program ENT for testing it (and for testing other PRNG's as well). --NorwegianBluetalk 21:21, 3 March 2009 (UTC)


 * Note that the best choice of PRNG depends heavily on your requirements, and what sort of "bias" you're trying to avoid. Any halfway decent one will not have any detectable deviation from uniformity in the long run, so it's going to be more subtle than that.  The known flaw, for example, in the linear congruential RNGs (besides their modest period) is that successive tuples taken from them "fall mainly in the planes" — there are some discrete hyperplanes that will capture most such tuples.
 * If your top two requirements are, in either order, speed and long period, then an excellent RNG is the Tausworthe one (hmm, that seems to be a redlink, but Google should help you out). It also gives excellent results in terms of autocorrelation.  It begins to get into trouble when you start looking at third-moment measures — if you have a run of high numbers, then numbers soon after that are more likely to be anti-correlated, and if you have a run of low numbers, then numbers soon after that are more likely to be positively correlated.
 * If you want real unassailable lack of any detectable nonrandomness, you need to use something with cryptographic strength; say, MD5. These RNGs have excellent properties, but are slow as molasses compared to Tausworthe and even to linear congruential. --Trovatore (talk) 21:47, 3 March 2009 (UTC)


 * Depends on the application. I've moved code from MATLAB to C++ and seen as much as a factor of 30 improvement. Most of that probably came from the way C++ allowed me to more intelligently manage the allocation and deallocation of memory (MATLAB can be fairly dumb about this some times, and it can get to be a major source of overhead). For virtually any application compiled C++ will be faster than MATLAB, but whether it is a little faster or lot faster will often depend on how clever and thoughtful you are as a programmer. If your MATLAB code is already highly optimised (e.g. using matrix operations rather than for loops whenever possible, limiting the creation and destruction of large intermediate variables, etc.), then you will probably see smaller gains, i.e. a factor of 2 or 3. Dragons flight (talk) 21:53, 3 March 2009 (UTC)
 * Mersenne twister is a popular high-speed PRNG for numerical simulations, that has a very long period and is proven free of a bunch of statistical biases that plague some of the awful generators of olden times. It has a C implementation and may be callable from Matlab.  The BSD random(3) function is not too bad either.  None of these are built to withstand adversarial analysis though (i.e. they are not supposed to be cryptographically secure).  The gold, er, standard if you require resistance to malicious attack is the Advanced Encryption Standard but you probably want to study some crypto theory (in addition to traditional numerical methods) if you are faced with that type of problem. 207.241.239.70 (talk) 05:00, 4 March 2009 (UTC)