1

What I want is to create an indexed function. Something of the form:

f_i(x)

Where i is an integer and x is real. The idea is then to be able to integrate or take the x derivative:

sum of f_i(x)

I've been looking everywhere how to do it, unsuccessfully.

For example, I attempted the following code:

import sympy as sy

x, n = sy.symbols('x n', real=True, integer=True)
f = sy.Function('f')
f_n = sy.Indexed(f(x), n)
f_n

Only to obtain the following error:

TypeError: 
The base can only be replaced with a string, Symbol, IndexedBase or an
object with a method for getting items (i.e. an object with a
`__getitem__` method).

I've tried the next alternative:

import sympy as sy

x, n = sy.symbols('x n', real=True, integer=True)
f = sy.IndexedBase(sy.Function('f'))
f_n = sy.Indexed(f, n)
f_n

But then I get this error:

SympifyError: SympifyError: f

Any help is greatly appreciated!

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.