> sage: def h(x):
> : return y.subs(globals())
Oops, this is probably not what you want, becaus h(3) would not give
the expected result. This may be better:
sage: var('a b x')
(a, b, x)
sage: def h(x):
: return y.subs(locals()).subs(globals())
:
sage: a=2
sage: b=3
sage: h(x)
Dear Simon,
Thanks a lot for that! I haven't noticed the difference between
subs(locals()) and subs(globals()). This helps a lot.
Stan
On Aug 25, 1:13 pm, Simon King <[EMAIL PROTECTED]> wrote:
> Dear Stan
>
> On Aug 25, 11:59 am, Stan Schymanski <[EMAIL PROTECTED]> wrote:
>
> > I wondered how p
Dear Stan
On Aug 25, 11:59 am, Stan Schymanski <[EMAIL PROTECTED]> wrote:
> I wondered how python handles assigned variables in function
> definitions.
As much as i understood a recent thread on sage-devel, several people
would like to have a powerful substitution mechanism in Sage.
Concerning
Thanks for that! I can do it using the python function now. I think it
would be very useful to have a command to replace symbolic variables
by pre-defined values or terms whenever they are called.
The .subs(locals()) functionality helps a lot with this respect. I am
not registered for the TRAC sys
On Jun 10, 2008, at 10:58 AM, Stan Schymanski wrote:
>
> Dear all
>
> I have been using the .subs(locals()) functionality extensively, but
> now I found out that this does not work for piecewise defined
> functions.
>
> Example:
>
> sage: var('x a b')
> (x, a, b)
> sage: f1=a*sin(x)
> sage: f2=b*
Dear all
I have been using the .subs(locals()) functionality extensively, but
now I found out that this does not work for piecewise defined
functions.
Example:
sage: var('x a b')
(x, a, b)
sage: f1=a*sin(x)
sage: f2=b*sin(x)
sage: f = Piecewise([[(0,pi/2),f1],[(pi/2,pi),f2]])
sage: a=1
sage: b=
Thanks a lot, that should work. I will have to do the symbolic
derivations first and then convert the results into python functions
before doing numerical computations.
Cheers
Stan
On Jun 5, 1:23 pm, Marshall Hampton <[EMAIL PROTECTED]> wrote:
> Here is a somewhat different solution that you mig
Here is a somewhat different solution that you might like more:
sage: var('x,a,b')
sage: def f(x):
return 2*x^a + b
sage: f(x)
2*x^a + b
sage: a = 2; f(x)
2*x^2 + b
sage: b = 1; f(x)
2*x^2 + 1
The fact that f is a python function instead of a SymbolicArithmetic
object has both ad
Dear Robert,
Thanks a lot for the quick solution. That's a whole new support
experience!
I was hoping I could define
z=y.subs(locals())
so that z would automatically adapt if the local variables change, but
it does not. Every time I change the local variables, I have to
redefine z=y.subs(locals(
On Jun 5, 2008, at 2:34 AM, Stan wrote:
> Dear all,
>
> I would like to use Sage as an alternative to Mathematica and I am
> quite amazed about the demonstrated functionality of Sage. I just have
> a very basic problem with the way I am used to do calculations. Often,
> I define a set of equation
10 matches
Mail list logo