I am trying to write a function which approximates the exponential series of input up to a given exponent. I wrote something quick in Python, but the output is of string type instead of the input type that I can use later in Cadabra.
def factFun(i): ## Define Factorial functio
if i >= 2:
return i * factFun(i-1)
else:
return 1
def strExpFun(*a,n):
sumStr = [str(aX) for aX in list(a)]
sumFun = '(' + '+'.join(sumStr) + ')'
expOutputSteps = [sumFun + '**' + str(i) +
'/' + str(factFun(i)) for i in range(1,n+1)]
expOutput = '1+' + '+'.join(expOutputSteps)
return expOutput
How can I convert the output to something Cadabra understands? Of course if there's a better way, I'm all ears.