feat: a little more math
This commit is contained in:
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