On Thu, Mar 26, 2009 at 11:09 AM, [email protected]
<[email protected]> wrote:
>
> A student in my class can get very far in Sage without needing to
> declare variables....
>
> 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
>
> When must you absolutely need to declare vars? My examples above give
> the impression you can avoid declaring them for a good long time.
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)'
William
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---