feat: a little more math
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
/venv
|
||||
/venv/*
|
||||
__pycache__/
|
||||
|
||||
7
Makefile
7
Makefile
@@ -3,8 +3,15 @@ install:
|
||||
pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
|
||||
save:
|
||||
pip freeze > requirements.txt
|
||||
|
||||
run:
|
||||
python src/main.py
|
||||
|
||||
test:
|
||||
python -m pytest -v
|
||||
|
||||
setenv:
|
||||
python -m venv venv
|
||||
source venv/bin/activate
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
iniconfig==2.1.0
|
||||
mpmath==1.3.0
|
||||
numpy==2.3.3
|
||||
packaging==25.0
|
||||
pandas==2.3.3
|
||||
pluggy==1.6.0
|
||||
Pygments==2.19.2
|
||||
pytest==8.4.2
|
||||
python-dateutil==2.9.0.post0
|
||||
pytz==2025.2
|
||||
six==1.17.0
|
||||
sympy==1.14.0
|
||||
tzdata==2025.2
|
||||
|
||||
19
src/main.py
19
src/main.py
@@ -1,4 +1,14 @@
|
||||
from modules.math import t_compound_interest, t_compound_interest_algorigthm, t_exponent
|
||||
from modules.math import (
|
||||
t_calculate_e,
|
||||
t_calculate_e_limit,
|
||||
t_compound_interest,
|
||||
t_compound_interest_algorigthm,
|
||||
t_compound_interest_continious,
|
||||
t_compound_interest_continious_exp,
|
||||
t_exponent,
|
||||
t_limit,
|
||||
t_logarithm_natural,
|
||||
)
|
||||
from modules.strings import t_strings
|
||||
|
||||
if __name__=="__main__":
|
||||
@@ -6,3 +16,10 @@ if __name__=="__main__":
|
||||
t_exponent(2,8)
|
||||
print(t_compound_interest(100, 20 / 100, 2, 12))
|
||||
print(t_compound_interest_algorigthm(100, 20 / 100, 2, 12))
|
||||
print(t_compound_interest_continious(100, 20 / 100, 2))
|
||||
print(t_compound_interest_continious_exp(100, 20 / 100, 2))
|
||||
print(t_calculate_e(1000000000000))
|
||||
print(t_logarithm_natural(10))
|
||||
print(t_limit())
|
||||
print(t_calculate_e_limit())
|
||||
print(t_calculate_e_limit().evalf())
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
from cmath import log as complex_log # used for complex numbers
|
||||
from math import log
|
||||
from math import e, exp, log
|
||||
|
||||
# Sympy is powerful since it does not make aproximations, it keeps every primitive as it is, this means that it's slower but more precisse
|
||||
from sympy import limit, oo, symbols
|
||||
|
||||
|
||||
def t_summ():
|
||||
@@ -24,3 +27,26 @@ def t_compound_interest_algorigthm(input, interest, span, periods):
|
||||
for _ in range(0, periods):
|
||||
result += result * (interest / periods)
|
||||
return result
|
||||
|
||||
def t_compound_interest_continious(input, interest, span):
|
||||
return input * (e ** (interest * span))
|
||||
|
||||
def t_compound_interest_continious_exp(input,interest, span):
|
||||
return input * exp(interest * span)
|
||||
|
||||
def t_calculate_e(precission):
|
||||
return (1 + 1 / precission) ** precission
|
||||
|
||||
def t_logarithm_natural(value):
|
||||
return log(value) # The default base is e
|
||||
|
||||
def t_limit():
|
||||
x = symbols("x")
|
||||
f = 1 / x
|
||||
result = limit(f, x, oo)
|
||||
return result
|
||||
|
||||
def t_calculate_e_limit():
|
||||
x = symbols("x")
|
||||
f = (1 + 1 / x) ** x
|
||||
return limit(f, x, oo)
|
||||
|
||||
Reference in New Issue
Block a user