Now consider this case:
var('x y z t a d')
def n(t):
cos(a*t),sin(a*t),0
def p(t):
d*n(t)[0],d*n(t)[1],d*n(t)[2]
When I try p(0) I get error. Why?
On Jun 19, 10:17 pm, Harald Schilly <[email protected]> wrote:
> Functions can have several arguments. For g, you can define a python
> function that returns multiple arguments - this is then a tuple that you can
> unwrap with "*". Look carefully at the following session:
>
> sage: var('a b c x y z')
> (a, b, c, x, y, z)
>
> sage: f(x,y,z) = a*x^2+b*x+c
>
> sage: f(1,2,3)
> a + b + c
>
> sage: f(2,3,4)
> 4*a + 2*b + c
>
> sage: def g(x,y,z):
> ....: return x^2, y^2, z^2
> ....:
>
> sage: f(*g(tan(x), sin(x), cos(x)))
> a*tan(x)^4 + b*tan(x)^2 + c
>
> sage: f(*g(tan(x), sin(2*x), 2*cos(x)))
> a*tan(x)^4 + b*tan(x)^2 + c
>
> H
>
> PS: your definition of f might be wrong, because there is a y and z but it
> is not used on the right-hand side!
--
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
URL: http://www.sagemath.org