assign function to an existing function

asked 2017-02-07 08:14:56 -0600

maaaaaaartin gravatar image

updated 2017-02-10 08:08:55 -0600

Hi,

Consider the following code:

sage.var('R')

rho = sage.function('rho')(R)

r = rho(R=R).function(R)

Is there a way to assign some function to rho such that r is modified? For instance, if I do:

y = sage.function('y')(R)

rho = sage.desolve(sage.diff(y,R) - y(R), dvar=y, ivar=R, ics=[0,1]).function(R) -> R |--> e^R

Then I get:

r(0) -> rho(0)

rho(0) -> 1

So rho is of course modified, but not r.

Thanks!

Martin

edit retag flag offensive close merge delete

Comments

Sure, in Python (and hence Sage) you can assign anything to r. But we would need to see a more specific example. Also, be aware that some commands have a side effect, but returnNone, so you have to be careful about that - for instance, the bare command show(plot()) might give an empty plot to show, but the actual Python value returned is None, not what you might be looking for.

kcrisman gravatar imagekcrisman ( 2017-02-07 10:18:44 -0600 )edit

Thanks! Just updated my question. Any idea?

maaaaaaartin gravatar imagemaaaaaaartin ( 2017-02-10 08:09:18 -0600 )edit

Ah, this is more of a Python question, which I'll let others answer. By the way, you don't need the sage bits unless you are importing Sage explicitly in Python. Maybe you are.

kcrisman gravatar imagekcrisman ( 2017-02-10 09:42:07 -0600 )edit

Thanks! Yes, I prefer python standalone (makes it easier to use other python libraries) with import sage.all as sage (makes it where each function comes from).

maaaaaaartin gravatar imagemaaaaaaartin ( 2017-02-10 10:12:05 -0600 )edit