|   | 1 |  initial version  | 
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))
sin(x)^2
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 http://trac.sagemath.org/ticket/17447 .
 Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.
 
                
                Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.