assign function to an existing function

asked 2017-02-07 15:14:56 +0100

maaaaaaartin gravatar image

updated 2017-02-10 15:08:55 +0100

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 17:18:44 +0100 )edit

Thanks! Just updated my question. Any idea?

maaaaaaartin gravatar imagemaaaaaaartin ( 2017-02-10 15:09:18 +0100 )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 16:42:07 +0100 )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 17:12:05 +0100 )edit