> > sage: f(u) = u^2
> > sage: f(4)
> > 16
> > sage: integrate(sin(u),u,2,11)
> > cos(2) - cos(11)
> > sage: diff(u*y,u)
> > y
> > sage: def g(n):
> > ....:     return n*n
> > ....:
> > sage: g(9)
> > 81

> f(u) = u^2 implicitly declares a variable.  More precisely, this is
> what happens:
>
> sage: preparse('f(u) = u^2')
> '_ = var("u"); f = symbolic_expression(u**Integer(2)).function(u)'


Incidentally, that is a good argument for always declaring your
functions as callable; it relieves one of this tedious var business.
I will make a mental note of it for intro material in Sage.

Yes, I realize I realize this shoots some of my earlier arguments
about calling symbolic expressions in the foot :)

>
> > When must you absolutely need to declare vars?  My examples above give
> > the impression you can avoid declaring them for a good long time.
>

Did this question get answered?  Apparently the answer is, "only when
you want to manipulate symbolic expressions that are not callable".
At least that's how I understand it.  E.g.

sage: integrate(z^2,z)

yields an error about z if you don't define z.  Incidentally, so does

sage: diff(z*x^2,x)

where I assume I already defined x to be a variable, so you must have
already had y defined above.  But

sage: z=3
sage: diff(z*x^2,x)
6*x

so if you assign a value to a variable then you don't have to declare
it either (though of course it ceases to be a variable in the
mathematical sense).

- kcrisman
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to