On Feb 12, 7:50 am, kcrisman <kcris...@gmail.com> wrote:
> Oh, I don't think this is as much of a bug as people think - rjf was
> quite wise to ask what my command was!
>
> sage: t=var('t')
> sage: sqrt((-m*sin(m*t))^2+(n*cos(n*t))^2).nintegral(x,0,2*pi)
>
> where m, n were determined in an interact.  But I used the wrong
> variable in nintegral!  In addition,

I see, you meant to integrate with respect to t,  not x.

>
> sage: t=var('t')
> sage: assume(sin(t)^2 + cos(t)^2 > 0)
> sage: sqrt((sin(t))^2+(cos(t))^2).nintegral(x,0,2*pi)
> Traceback (click to the left for traceback)
> ...
> ValueError: Maxima (via quadpack) cannot compute the integral to that
> precision

This is bizarre.  quadpack was written in Fortran.  It was
automatically translated into Lisp and compiled, then loaded in to
Maxima.  It is a purely numerical program.  Sage calls Maxima to run
this?

>
> which seems okay, though no other natural "assume" command got me
> there.

Since quadpack is a purely numerical program, any information that
Maxima might have about assumptions is not conveyed to quadpack.  I do
not expect this will change.



>  Now, perhaps it should still be smarter than this following
> example:
>
> sage: t=var('t')
> sage: forget()
> sage: assume(t==pi/2)
> sage: sqrt((-2*sin(2*t))^2+(3*cos(3*t))^2).nintegral(x,0,2*pi)
> Traceback (click to the left for traceback)
> ...
> Is  9*cos(3*t)^2+4*sin(2*t)^2  positive or zero?
>
> But at least it's asking the right question, since a numerical
> integral is indeed possible here if t=pi/2 and so the integrand is
> zero.  And this works:
>
> sage: t=var('t')
> sage: forget()
> sage: sqrt((-2*sin(2*t))^2+(3*cos(3*t))^2).nintegral(t,0,2*pi)[0]
> 15.209210627602969

This looks awfully clumsy.
I tried this in maxima:

 romberg(sqrt((-2*sin(2*t))^2+(3*cos(3*t))^2),t,0,2*%pi);

  and I immediately got this:

 15.20920996328813

romberg is the name of a simple numerical integration program that is
included in Maxima.

Maybe you would have fewer problems (and more informative error
messages)
if you were just using Maxima.


>
> Still, I suppose that it would seem natural to check for the most
> common things of this kind like sin^2+cos^2.  Even WeBWorK, a Perl
> homework checker, checks for this sort of thing in its (non-CAS-based)
> algorithm.

There are all kinds of heuristics for doing homework.  Unfortunately
some of them
don't work for real  calculations.   Here's a heuristic: No integer
has more than 3 digits.
It worked for me in a graduate course in complex variables.  If you
compute an answer
and there is an integer with more than 3 digits, you made a mistake.


>
> At the very least we know Sage has its work cut out for it if it ever
> wants to remove dependence on the slow-slow interface to Maxima and
> Lisp issues, because these are (in general) very thorny questions.

The solution for you is to use Maxima, not Sage :)

> Even if they're amusing on occasion!

All in clean fun.
RJF


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

Reply via email to