You can simplify your function as k * 1.05^(-x), where k = a * b / c. ( mathjax support would be handy here)
Lets suppose that k = 5 and you want to integrate over interval [1,5].
You can use scipy's
quad()
- its arguments are function's definition (as a python function) and lower and upper limit:
Output:
In [1]: from scipy import integrate
In [2]: k, a, b = 5, 1, 5
In [3]: integrate.quad(lambda x: k * 1.05**(-x), a, b)
Out[3]: (17.30418300357802, 1.9211502392899616e-13)
output is the result and an estimation of error.
You can use sympy's
integrate()
, where first argument is a function definition and second is a tuple, with elements being variable you integrate by, lower limit, upper limit. With sympy you can write your function almost "naturally", but you need to specify that x has a special meaning (a symbol). If you are interested only in numerical result, scipy's quad is probably easier to use.
Output:
In [4]: from sympy import integrate, Symbol
In [5]: x = Symbol('x')
In [6]: integrate(k * 1.05**(-x), (x, a, b))
Out[6]: 17.3041830035780
And finally, you can use a piece of paper (and a brain) and realize that the primitive function of k * 1.05^(-x) is -k / log(1.05) * 1.05^(-x). After that its just
Output:
In [7]: from math import log
In [8]: -k / log(1.05) * ( 1.05**-b - 1.05**-a )
Out[8]: 17.304183003578018
As python is not a domain-specific language for math/symbol manipulation, using python for calculus would require atleast basic understanding of python and basic understanding of a calculus, you likely need to spend some effort and study both a little.