Maybe the following is similar to what you're looking for?
At the start, we can try to only work symbolically. s
is the basic variable. c
is a function of s
, in this case writing c = s + 200
makes c
such a function.
f=c*exp(lanr*s)*sin(lani*s)
is a more complicated function of s
. print(f)
gives -(s+200)*exp(-4.56*s)*sin(2.33*s)
.
Now, you seem to be interested in the integral of f
for s
going from 0
till some value. Let's call that value t
. Then, that integral would be a function g
of t
.
from sympy import exp, sin, symbols, integrate, lambdify
s, t = symbols('s t')
lanr = -4.56
lani = -2.33
c = s + 200
f = c * exp(lanr * s) * sin (lani * s)
g = integrate(f, (s, 0, t))
If only 101 values are needed, we can stay inside sympy:
values = [g.subs(t, ti).evalf() for ti in range(0, 101)]
If more numeric calculations are needed, lambdify()
can convert g
from sympy to numpy.
Then numpy can also calculate the first 101 values (this works much faster than in sympy, but that is only important if many more calculations are needed):
g_np = lambdify(t, g)
import numpy as np
x = np.arange(0,100)
y = g_np(x)
In this case the result would be
array([ 0. , -17.66531171, -17.80584637, -17.80185932,
-17.8019015 , -17.80190133, -17.80190133, -17.80190133,
-17.80190133, -17.80190133, -17.80190133, -17.80190133,
-17.80190133, -17.80190133, -17.80190133, -17.80190133,
...
This looks quite strange. Maybe there is some misunderstanding somewhere? Or maybe the original formula has some mistake?