Last active
January 16, 2018 15:45
-
-
Save nhubbard/f3bacf4f3e5ceecfdb885775b20c4860 to your computer and use it in GitHub Desktop.
Applications of Euler's number using continually compounded interest.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Applications of Euler's Number: Continuously Compounding Interest\n", | |
"When interest is compounded continuously, the amount **A** in an account after **t** years is given by the formula $A=Pe^{rt}$, where **P** is the amount invested or borrowed and **r** is the annual interest rate expressed as a decimal.\n", | |
"\n", | |
"### Example Problems\n", | |
"If you invest $500 at an annual interest rate of 10% compounded continuously, calculate the final amount you will have in the account after five years." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"You will have $824.36 in your account.\n" | |
] | |
} | |
], | |
"source": [ | |
"import math\n", | |
"def continually_compounded_interest(P, r, t):\n", | |
" return P*(math.e**(r*t))\n", | |
"print(\"You will have $%.2f in your account.\" % round(continually_compounded_interest(500, .1, 5), 3))" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"If you invest $2,000 at an annual interest rate of 13% compounded continuously, calculate the final amount you will have in the account after 20 years." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"You will have $26,927.48 in your account.\n" | |
] | |
} | |
], | |
"source": [ | |
"import math\n", | |
"def continually_compounded_interest(P, r, t):\n", | |
" return P*(math.e**(r*t))\n", | |
"final = '${:,.2f}'.format(continually_compounded_interest(2000, .13, 20))\n", | |
"print(\"You will have %s in your account.\" % final)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"If you invest $20,000 at an annual interest rate of 1% compounded continuously, calculate the final amount you will have in the account after 20 years." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"You will have $24,428.06 in your account.\n" | |
] | |
} | |
], | |
"source": [ | |
"import math\n", | |
"def continually_compounded_interest(P, r, t):\n", | |
" return P*(math.e**(r*t))\n", | |
"final = '${:,.2f}'.format(continually_compounded_interest(20000, .01, 20))\n", | |
"print(\"You will have %s in your account.\" % final)" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.3" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment