assign function to an existing function

asked 8 years ago

maaaaaaartin gravatar image

updated 8 years ago

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

Preview: (hide)

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 ( 8 years ago )

Thanks! Just updated my question. Any idea?

maaaaaaartin gravatar imagemaaaaaaartin ( 8 years ago )

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 ( 8 years ago )

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 ( 8 years ago )