feat: a little more math

This commit is contained in:
2025-11-15 14:08:20 +01:00
parent 90f0e44e22
commit 83723d1db7
5 changed files with 60 additions and 2 deletions

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
/venv /venv
/venv/* /venv/*
__pycache__/

View File

@@ -3,8 +3,15 @@ install:
pip install --upgrade pip pip install --upgrade pip
pip install -r requirements.txt pip install -r requirements.txt
save:
pip freeze > requirements.txt
run: run:
python src/main.py python src/main.py
test: test:
python -m pytest -v python -m pytest -v
setenv:
python -m venv venv
source venv/bin/activate

View File

@@ -1,6 +1,13 @@
iniconfig==2.1.0
mpmath==1.3.0
numpy==2.3.3 numpy==2.3.3
packaging==25.0
pandas==2.3.3 pandas==2.3.3
pluggy==1.6.0
Pygments==2.19.2
pytest==8.4.2
python-dateutil==2.9.0.post0 python-dateutil==2.9.0.post0
pytz==2025.2 pytz==2025.2
six==1.17.0 six==1.17.0
sympy==1.14.0
tzdata==2025.2 tzdata==2025.2

View File

@@ -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 from modules.strings import t_strings
if __name__=="__main__": if __name__=="__main__":
@@ -6,3 +16,10 @@ if __name__=="__main__":
t_exponent(2,8) t_exponent(2,8)
print(t_compound_interest(100, 20 / 100, 2, 12)) print(t_compound_interest(100, 20 / 100, 2, 12))
print(t_compound_interest_algorigthm(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())

View File

@@ -1,5 +1,8 @@
from cmath import log as complex_log # used for complex numbers 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(): def t_summ():
@@ -24,3 +27,26 @@ def t_compound_interest_algorigthm(input, interest, span, periods):
for _ in range(0, periods): for _ in range(0, periods):
result += result * (interest / periods) result += result * (interest / periods)
return result 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)