Ask Your Question

substitute function for an array of functions

asked 2015-11-09 21:38:01 +0200

Shashank gravatar image

Hello, I have an array of functions defined as

arr = [function("y%d" % i,x) for i in [0..(2)]]

I also have a function of function

def square(x):

If I use substitute_function on the function of function it works.


However, the following command does not work,


The reason I think is that arr[0] has an argument by y0 does not. Is it possible to use substitute_function where the arguments have arguments?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-11-09 22:29:50 +0200

nbruin gravatar image

The problem is that the value of arr[0] is y0(x), which is an expression consisting of a function evaluated at x. That's not the kind of functions that substitute_function deals with. You can use subs for that:

sage: square(arr[0]).subs(arr[0]==temp(x))

You are not the first person who get tripped up by the confusing fact that function('f',x) doesn't return a function but a function evaluated at (something). To get something that actually is a function, use function('f'). You can still evaluate that at x by writing function('f')(x). See .

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-11-09 21:38:01 +0200

Seen: 492 times

Last updated: Nov 09 '15