I was asked by my boss to create a module for calculating reverse compound.
我的老板要求我创建一个计算反向化合物的模块。
The question is: if I want to achieve $1.000.000,00 in 24 months with interest rate 18%/year (or 1.5%/month). how much money do I have to save every month?
问题是:如果我想在24个月内实现$ 1.000.000,00,利率为18%/年(或1.5%/月)。我每个月要节省多少钱?
I searched on the internet, but found nothing except people referring to the Excel formula. Do you know what the mathematical formula is for this case?
我在互联网上搜索,但除了人们提到Excel公式之外什么都没找到。你知道这个案例的数学公式是什么吗?
I am using Java for this module. Is there any Java library or API?
我在这个模块中使用Java。有没有Java库或API?
4 个解决方案
#1
14
Let us say that you are investing D
dollars at the beginning of each month for M
months earning an interest rate of r
compounded monthly. We will set i = r / 12
. At the end of M
months you will have
让我们说你是在每个月初投资D美元,为M个月赚取每月复利的利率。我们将设置i = r / 12.在M个月结束时,您将拥有
D * (1 + i)^M + D * (1 + i)^(M - 1) + D * (1 + i)^(M - 2) + ...
D * (1 + i)
in your account. This is because the D
dollars in the first month are invested for M
months, the D
dollars in the second month are invested for M-1
months, and so on. This is a geometric progression and simplifies to
在您的帐户中。这是因为第一个月的D美元投资了M个月,第二个月的D美元投资了M-1个月,依此类推。这是几何级数并简化为
D * (1 + i) * ((1 + i)^M - 1) / i.
Therefore, if you want X
in your account at the end of M
months you solve
因此,如果您想在M个月结束时在帐户中使用X,则需要解决问题
X = D * (1 + i) * ((1 + i)^M - 1) / i
for D
to obtain
为D获得
D = X * i / ((1 + i) * ((1 + i)^M - 1)).
You don't really need an API here to solve this as you can see the solution is quite simple. The concept that you might want to read about here is that of annuities.
您现在不需要API来解决此问题,因为您可以看到解决方案非常简单。您可能想要阅读的概念是年金。
#2
4
If you are not doing it for lending purposes, the simple formulae posted in other answers will probably be good enough.
如果您不是出于贷款目的,那么在其他答案中发布的简单公式可能就足够了。
If this is for any kind of financial activity, beware of any simple calculation for compound interest. If it is for any lending you are probably required to conform to strict rules (e.g in the UK the rate must be quoted in the form of an APR).
如果这是针对任何类型的金融活动,请注意复利的任何简单计算。如果是任何贷款,您可能需要遵守严格的规定(例如在英国,费率必须以APR的形式引用)。
The calculations need to take into account:
计算需要考虑到:
- the variable days in a month
- whether interest is applied daily or monthly
- what day the borrowing was drawn down
- the day of the month payment has been taken.
- other stuff I can't remember but you'd better look up for your contract to be legally binding
一个月内的变量天数
是否每日或每月应用利息
借款被取消的那一天
已经支付了当天的付款日期。
其他我不记得的东西,但你最好查看你的合同是否具有法律约束力
In practice this needs a form of iteration to find the regular and final payments.
在实践中,这需要一种迭代形式来查找常规和最终付款。
#3
4
The formula you want is S = R * [(1+i)^n - 1] / i
where
你想要的公式是S = R * [(1 + i)^ n - 1] / i其中
S = the required amount at the end (1,000,000)
R = the regular payment (what you want)
i = the periodic rate of interest (0.015)
n = the number of time periods (24)
so your answer R = 1000000 * .015 / (1.015^24 - 1) (~= 34924.10)
所以答案R = 1000000 * .015 /(1.015 ^ 24 - 1)(〜= 34924.10)
EDIT:
This assumes payments are at the end of each period, if payments are made at the beginning of each period, then divide your answer by (1+i)
假设付款是在每个期间结束时,如果在每个期间开始时付款,则将您的答案除以(1 + i)
#4
2
I think this gets you what you want. Its even LGPL, even though if you are getting 18% returns on your money, price shouldn't matter ;-).
我认为这可以满足你的需求。它甚至是LGPL,即使你的钱获得18%的回报,价格也无所谓;-)。
#1
14
Let us say that you are investing D
dollars at the beginning of each month for M
months earning an interest rate of r
compounded monthly. We will set i = r / 12
. At the end of M
months you will have
让我们说你是在每个月初投资D美元,为M个月赚取每月复利的利率。我们将设置i = r / 12.在M个月结束时,您将拥有
D * (1 + i)^M + D * (1 + i)^(M - 1) + D * (1 + i)^(M - 2) + ...
D * (1 + i)
in your account. This is because the D
dollars in the first month are invested for M
months, the D
dollars in the second month are invested for M-1
months, and so on. This is a geometric progression and simplifies to
在您的帐户中。这是因为第一个月的D美元投资了M个月,第二个月的D美元投资了M-1个月,依此类推。这是几何级数并简化为
D * (1 + i) * ((1 + i)^M - 1) / i.
Therefore, if you want X
in your account at the end of M
months you solve
因此,如果您想在M个月结束时在帐户中使用X,则需要解决问题
X = D * (1 + i) * ((1 + i)^M - 1) / i
for D
to obtain
为D获得
D = X * i / ((1 + i) * ((1 + i)^M - 1)).
You don't really need an API here to solve this as you can see the solution is quite simple. The concept that you might want to read about here is that of annuities.
您现在不需要API来解决此问题,因为您可以看到解决方案非常简单。您可能想要阅读的概念是年金。
#2
4
If you are not doing it for lending purposes, the simple formulae posted in other answers will probably be good enough.
如果您不是出于贷款目的,那么在其他答案中发布的简单公式可能就足够了。
If this is for any kind of financial activity, beware of any simple calculation for compound interest. If it is for any lending you are probably required to conform to strict rules (e.g in the UK the rate must be quoted in the form of an APR).
如果这是针对任何类型的金融活动,请注意复利的任何简单计算。如果是任何贷款,您可能需要遵守严格的规定(例如在英国,费率必须以APR的形式引用)。
The calculations need to take into account:
计算需要考虑到:
- the variable days in a month
- whether interest is applied daily or monthly
- what day the borrowing was drawn down
- the day of the month payment has been taken.
- other stuff I can't remember but you'd better look up for your contract to be legally binding
一个月内的变量天数
是否每日或每月应用利息
借款被取消的那一天
已经支付了当天的付款日期。
其他我不记得的东西,但你最好查看你的合同是否具有法律约束力
In practice this needs a form of iteration to find the regular and final payments.
在实践中,这需要一种迭代形式来查找常规和最终付款。
#3
4
The formula you want is S = R * [(1+i)^n - 1] / i
where
你想要的公式是S = R * [(1 + i)^ n - 1] / i其中
S = the required amount at the end (1,000,000)
R = the regular payment (what you want)
i = the periodic rate of interest (0.015)
n = the number of time periods (24)
so your answer R = 1000000 * .015 / (1.015^24 - 1) (~= 34924.10)
所以答案R = 1000000 * .015 /(1.015 ^ 24 - 1)(〜= 34924.10)
EDIT:
This assumes payments are at the end of each period, if payments are made at the beginning of each period, then divide your answer by (1+i)
假设付款是在每个期间结束时,如果在每个期间开始时付款,则将您的答案除以(1 + i)
#4
2
I think this gets you what you want. Its even LGPL, even though if you are getting 18% returns on your money, price shouldn't matter ;-).
我认为这可以满足你的需求。它甚至是LGPL,即使你的钱获得18%的回报,价格也无所谓;-)。