Ask Your Question

Function composition not working

asked 2021-03-18 03:32:41 +0100

tarix29 gravatar image

updated 2023-01-09 23:59:54 +0100

tmonteil gravatar image

I'm experiencing some strange behavior when composing two basic functions. My OS is Windows 10. Here is an example:

sage: r=var('r')
sage: s=var('s')
sage: f(r)=r**2
sage: g(r)=r**(1/2)
sage: f(g(r))
sage: f(g(s))

Whenever I evaluate the functions at the variable they were defined with (or even if just the outer function was defined with it), Sage returns the inner function as the result. This seems to happen only when the two functions are inverses of each other, since it behaves as expected with $f(r)=r^2$ and $g(r)=r^{1/3}$, returning $r^{2/3}$.

Is this a known issue? Is this somehow expected behavior? Thanks for any help.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-03-18 12:47:09 +0100

slelievre gravatar image

This bug was recently fixed.

In Sage 9.3.beta9:

sage: r, s = SR.var('r, s')
sage: f(r) = r**2
sage: g(r) = r**(1/2)
sage: f(g(r))
sage: f(g(s))
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: 2021-03-18 03:32:41 +0100

Seen: 316 times

Last updated: Mar 18 '21