I borrowed/adapted the following code for carrying out a line integral from a published notebook

   var('x,y,t')
   F=vector([x^2,x*y])
   r=vector([cos(t), sin(t)])
   tstart=0
   tend=2*pi
   integrand = F(x=r[0], y=r[1])*diff(r,t)

As one may observe, integrand is identically 0. The idea is now to carry out the command

   numerical_integral(integrand, tstart, tend)

but that results in the error:

Traceback (most recent call last):
  File "", line 1, in <module>

  File "/tmp/tmpsnEB5U/___code___.py", line 11, in <module>
    numerical_integral(integrand, tstart, tend)
  File "", line 1, in <module>

File "integration.pyx", line 207, in sage.gsl.integration.numerical_integral (sage/gsl/integration.c:1535)
ValueError: Integrand has wrong number of parameters

What is odd is that, if I do a commands like

  g(t) = sin(t)^2 + cos(t)^2 - 1
  print type(g)
  print type(integrand)
  numerical_integral(g, tstart, tend)

Sage will tell me both integrand and g are of the same type, and evaluate the numerical integral for g just fine. I tried also doing the following: adding an argument on the left-hand side of the definition for integrand

   integrand(t) = F(x=r[0], y=r[1])*diff(r,t)
   numerical_integral(integrand, tstart, tend)

which seems to make things suddenly work, and then dropping the argument on the left side of the definition of g, as in

  g = sin(t)^2 + cos(t)^2 - 1
  numerical_integral(g, tstart, tend)

which I might have presumed would result in an error, but produced a value as well. I'm afraid I've gotten very confused about the role of an argument in the definition of a function. Could someone illuminate me?

Also, is this a question better suited for sage-edu or some other group?

Thomas L. Scofield
--------------------------------------------------------
Associate Professor
Department of Mathematics and Statistics
Calvin College
--------------------------------------------------------

--
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to