| 1 | initial version |
The w in sin(t*w) does not refer to whatever the object with identifier w in the current scope. There isn't a way to get Python to work like this. You need to do something like:
sage: var('t w')
(t, w)
sage: f(t) = sin(w*t)
sage: f.subs(w=2).function(t)
t |--> sin(2*t)
| 2 | Change to accommodate the author's revision. |
The w in sin(t*w) does not refer to whatever the object with identifier w in the current scope. There isn't a way to get Python to work like this. You need to do something like:
sage: var('t var('t, w')
(t, w)
sage: f(t) f(a,b,c,d,e,f,g,t) = sin(w*t)
sin(t*w)
sage: f.subs(w=2).function(t)
t f.subs(w=2).function(*f.arguments())
(a, b, c, d, e, f, g, t) |--> sin(2*t)
| 3 | No.3 Revision |
The w in sin(t*w) does not refer to whatever the object with identifier w in the current scope. There isn't a way to get Python to work like this. You need to do something like:
sage: var('t, w')
(t, w)
sage: params = {w: 2}
sage: f(a,b,c,d,e,f,g,t) = sin(t*w)
sage: f.subs(w=2).function(*f.arguments())
f.subs(params).function(*f.arguments())
(a, b, c, d, e, f, g, t) |--> sin(2*t)
You just have to define the replacements you want once in a dictionary. You still have to call subs once for every function you want to change.
| 4 | Took kcrisman's answer into account. |
The w in sin(t*w) does not refer to whatever the object with identifier w in the current scope. There isn't a way to get Python to work like this. You need to do something like:
sage: var('t, w')
(t, w)
sage: params = {w: 2}
sage: f(a,b,c,d,e,f,g,t) = sin(t*w)
sage: f.subs(params).function(*f.arguments())
f.subs(params)
(a, b, c, d, e, f, g, t) |--> sin(2*t)
You just have to define the replacements you want once in a dictionary. You still have to call subs once for every function you want to change.
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.