Wikipedia:Reference desk/Archives/Mathematics/2007 July 20

= July 20 =

Investment and interest calculations
If I were to invest $300 in a bank account with 3% compound interest per annum and I add $300 every year, what is the amount of money I get in 20 years? I have used the arithmetic and geometric progression, but I found it lengthy. Is there a shorter method? Thanks. —Preceding unsigned comment added by 124.82.78.95 (talk • contribs) 07:38, 20 July 2007


 * There are many methods to solve this. Can you show us what you have tried to do? See if you can find a recurrence relation between the amount of money between successive years and solve it. -- Meni Rosenfeld (talk) 14:48, 20 July 2007 (UTC)


 * (After Edit Conflict) A relatively easy approach is to express annual the interest and deposit as a recurrence relation (as in an+1 = 1.03an + 300) and then solve the recurrence relation for a closed form expression. Explanations and examples of solving such recurrence relations (in this case an inhomogeneous one) are give on the recurrence relation page. -- Leland McInnes 14:53, 20 July 2007 (UTC)

I actually did this manually. By multiplying the compound interest with the initial value, I worked my way through each year until I get year 20. But I found it extremely time-consuming so I was hoping that there was a simpler method to obtain a similar answer. I also do not understand what the unknown Ax represents in the recurrence relation. Thanks.


 * Well, if you treat each individual payment separately, the first one has 20 years' worth of interest, the 2nd payment has 19 year's worth of interest, 3rd one 18 years, etc. 20th payment just 1 year of interest.
 * You can write this out as; 300 x 1.0320 + 300 x 1.0319 + ..... + 300 x 1.031
 * Factor out the 300 and you get 300(1.031 + 1.032 + 1.033 + 1.034 + ... +1.0320)
 * Now look at Geometric progression, and see if there's anything on that page which will solve the above expression.Richard B 14:13, 21 July 2007 (UTC)

After 20 years you have made 21 payments, the first having 20 years of interest, the last having zero. Bo Jacoby 22:16, 21 July 2007 (UTC).
 * That would depend on a more precise specification of the problem. I find it more plausible that the first payment is at the beginning of 1st year, 20th payment at the beginning of 20th year, and at the end of 20th year, instead of an additional deposit, we make a withdrawal.
 * As for the solution... See if you can follow Richard's suggestion. If you are familiar with sequences and recursion, you can also try Leland's and my suggestion - assuming the problem is as I stated, you can denote by $$a_n$$ the amount of money at the end of nth year, before an additional deposit. Then you have $$a_1=309$$ and $$a_{n+1}=1.03(a_n+300)$$. Solving this means finding a way to express $$a_n$$ without relying on previous terms. There are several ways to do this - my favorite is letting $$b_n=\frac{a_n}{1.03^n}$$ and proceeding naturally. -- Meni Rosenfeld (talk) 23:52, 21 July 2007 (UTC)

Funny that you should ask this question because I have written some notes in my notebook two months ago about how to turn the problem you just described into a differential equation which can then be solved just once (to get the solution). 211.28.131.44 06:53, 22 July 2007 (UTC)


 * M[t] = (principle + inst_deposit/inst_rate) × Exp[inst_rate × t] - (inst_deposit/inst_rate)

The trick of course is to convert discrete_rate into inst_rate and to convert discrete_deposit into inst_deposit

For your case:


 * discrete_rate is 0.03
 * discrete_deposit is 300
 * principle is 300

After the calculations, the instatanous rate and deposit are


 * inst_rate is 0.0295588
 * inst_deposit is 295.588

So the formula becomes


 * $$Money[t] = \left(300+\frac{295.588}{0.0295588}\right) e^{0.0295588\, t}-\frac{295.588}{0.0295588}$$
 * $$Money[0] = 300$$
 * $$Money[1] = 609$$
 * $$Money[2] = 927.27$$
 * $$Money[3] = 1255.09$$
 * $$Money[4] = 1592.74$$
 * $$Money[5] = 1940.52$$
 * $$Money[5] = 1940.52$$

The secret is


 * a[0] = 1 + discrete_rate
 * b[0] = discrete_deposit
 * a[n] = Sqrt[a[n-1]]
 * b[n] = b[n-1]/(a[n]+1)
 * inst_rate = 2^16 * (a[16]-1)
 * inst_deposit = 2^16 * b[16]

Of course this is an converging approximation,
 * inst_rate = 2^ bignumber * (a[bignumber] - 1)
 * inst_deposit = 2^bignumber * b[bignumber]

I find that 16 iterations is enough for most purposes.

211.28.131.44 06:53, 22 July 2007 (UTC)


 * I have no idea what you have tried to do here - I don't think our purpose is to confuse the OP. You did, however, remind me of another subtle issue: All of our responses are based on the assumption that the annual interest is actually 3%. If the interest is what some would call "3% per year, compunded continuously", we should use $$\mathrm{e}^{0.03}$$ instead of 1.03. -- Meni Rosenfeld (talk) 10:56, 22 July 2007 (UTC)


 * I think the vast majority of banks would quote x% per annum as, if you invest £100 now, then in 1 year's time there will be £10x in your account, so I would have thought the problem would be as we originally had it. But I agree that "16 iterations" and differential equations looks to be overcomplicating the problem. Richard B 11:10, 22 July 2007 (UTC)
 * Should the £10x be £(100+x) or something?
 * By the way, 211's "iterations" are nothing more than a very obfuscated way of calculating the logarithm of 1.03, and the "differential equation" is an attempt to reinvent the solution to the continuous problem (where the original problem is supposedly discrete). This is what I would call "stopping in Japan on the way from France to Spain". -- Meni Rosenfeld (talk) 11:30, 22 July 2007 (UTC)


 * Yes, sorry, £10x should indeed be £(100+x) Richard B 22:39, 22 July 2007 (UTC)

Assuming that there are 20 payments at yearly intervals and the final one earns one year's interest, i.e. the expression to be evaluated is 300 x 1.0320 + 300 x 1.0319 + ..... + 300 x 1.031, as given in an earlier post, then the answer will come from summing a GP with first term 300 X 1.03 and common ratio 1.03, giving $8302.95, I believe. Surely the OP will prefer this to a lot of flannel about recurrence relations and the continuous case.…81.132.237.25 12:56, 22 July 2007 (UTC)
 * Please do not insult recurrence relations. In this case, they are easier to understand intuitively and just as easy to solve mathematically. Also, please do not give end results for a question which might be homework. Providing a complete solution is easy; hinting at a solution is hard. -- Meni Rosenfeld (talk) 13:03, 22 July 2007 (UTC)

Always begin with the simplest examples. The problem posed is: "If I were to invest $300 in a bank account with 3% compound interest per annum and I add $300 every year, what is the amount of money I get in 20 years?". A simpler example is "If I were to invest $1 in a bank account with 3% compound interest per annum and I add $1 every year, what is the amount of money I get in 20 years?". If you can do this one then you can do the former one by multiplying by 300. A still simpler example is: "If I were to invest $1 in a bank account with 0% compound interest per annum and I add $1 every year, what is the amount of money I get in 0 years?" It seems that the result is $1, but there is no consensus on this one. Bo Jacoby 14:18, 22 July 2007 (UTC).
 * There's a nice explanation of how to solve this problem here . Donald Hosek 16:02, 26 July 2007 (UTC)

Fitting the 2D sinc funtion to 2D data
I'm doing sub-pixel image registration via the cross-correlation method. Matlab code:

% Subtract out DC

im1 = (im1 - mean(im1)); im2 = (im2 - mean(im2));

% Take the 2D fft of each image

im1_fft = fft2(im1); im2_fft = fft2(im2);

% Multiply the first by the complex conjugate of the second

mult = im1_fft .* conj(im2_fft);

% Take the inverse 2D fft of the multiplied matrix and fftshift

peak = real(ifft2(mult)); peak = fftshift(peak);

I was fitting a second order 2D function to the peak sub-region, but references indicate that the correct function is a sinc. My problem is that while I know how to formulate the A matrix for the 2D 'bowl' in c = A\y:

A = [ones(length(rv),1) rv.*cv rv rv.^2 cv cv.^2];

I can't figure out how to formulate it for a sinc function. Is there perhaps a better way to do this via a transform in the Fourier domain? Not having done Fourier undergrad, I'm in deep water here.

Any other advice on sub-pixel image registration?

196.2.111.133 14:39, 20 July 2007 (UTC)

Differentiating
Am I correct in workings to say that

$$\frac{d}{dx}(x^x)=e^{x\ln x}(1+\ln x)=x^x(1+\ln x)$$ yes

and also do any of the following have real values

$$y=x^x,x<0\,$$ yes $$y=e^{x\ln x},x<0\,$$ no $$y=e^{x\ln x}(1+\ln x),x<0\,$$ no

thank you. Philc 16:23, 20 July 2007 (UTC)
 * Your derivative is correct, but you can't really make a meaningful definition of $$f(x):\mathbb R\to\mathbb R, f(x)=x^x$$ for $$x<0$$. It works for negative integers, sure, but what do you do with, say, $$-\pi^{-\pi}$$? So you're incorrect in thinking that $$y=(x^x),x<0\,$$ is real valued. There was some extensive discussion about the function $$x^x$$ a couple weeks ago. Donald Hosek 16:54, 20 July 2007 (UTC)

Those commentaries were mine(should have said so), for x^x, I guess the simple answer would be it has real values, but it does not have real values for all real numbers. Unfortunately, I can't find the particular archive that goes into more depth.--Cronholm144 17:03, 20 July 2007 (UTC)


 * Why does $$y=x^x,x<0\,$$ have real negative values and $$y=e^{x\ln x},x<0\,$$ not, when they are effectively re-arrangements of each other? Philc  17:16, 20 July 2007 (UTC)


 * ln(x) not defined in the reals for x<0--Cronholm144 17:18, 20 July 2007 (UTC)


 * (after edit conflict) Well, if you choose a branch of ln over $$\mathbb C$$ that doesn't exclude the negative reals, then you can get real values for select negative rational numbers $$\{a/b\in\mathbb Q^-:a,b\in\mathbb Z, b\mbox{ is odd}\}$$. The discussion I referenced is at last question. Donald Hosek 17:21, 20 July 2007 (UTC)