#8624: integral of abs(cos(x))*sin(x) gives false results
-----------------------------+----------------------------------------------
Reporter: jeroen | Owner: burcin
Type: defect | Status: needs_work
Priority: minor | Milestone: sage-4.4.3
Component: calculus | Keywords:
Author: Jason Grout | Upstream: N/A
Reviewer: Burcin Erocal | Merged:
Work_issues: |
-----------------------------+----------------------------------------------
Changes (by burcin):
* status: needs_review => needs_work
* reviewer: => Burcin Erocal
Comment:
It's exciting to see that we can handle one more of the Wester tests.
Thanks for the patch Jason.
I get the following errors after applying attachment:trac-8624-abs-
integration.patch to 4.4.2:
{{{
**********************************************************************
File ".../devel/sage-t/sage/functions/piecewise.py", line 780:
sage: f.integral()
Expected:
Piecewise defined function with 1 parts, [[(-Infinity, +Infinity), x
|--> -integrate(e^(-abs(x)), x, x, +Infinity)]]
Got:
Piecewise defined function with 1 parts, [[(-Infinity, +Infinity), x
|--> -1/2*((sgn(x) - 1)*e^(2*x) - 2*e^x*sgn(x) + sgn(x) + 1)*e^(-x) - 1]]
**********************************************************************
}}}
Maple simply gives 2 for this one:
{{{
> integrate(exp(-abs(x)), x=-infinity..infinity);
memory used=3.8MB, alloc=3.1MB, time=0.15
2
}}}
----
{{{
**********************************************************************
File ".../devel/sage-t/sage/misc/functional.py", line 705:
sage: h = integral(sin(x)/x^2, (x, 1, pi/2)); h
Expected:
integrate(sin(x)/x^2, x, 1, 1/2*pi)
Got:
1/2*gamma(-1, -1/2*I*pi) + 1/2*gamma(-1, 1/2*I*pi) - 1/2*gamma(-1, -I)
- 1/2*gamma(-1, I)
**********************************************************************
File ".../devel/sage-t/sage/misc/functional.py", line 707:
sage: h.n()
Expected:
0.339447940978915...
Got:
0.339447940978884
**********************************************************************
}}}
Here's the Maple output:
{{{
> integrate(sin(x)/x^2, x=1..1/2*Pi);
memory used=7.6MB, alloc=5.1MB, time=0.33
Pi
sin(1) Pi - Ci(1) Pi + Ci(----) Pi - 2
2
--------------------------------------
Pi
}}}
It would be interesting to see how this is transformed to the expression
with the incomplete gamma function above.
----
{{{
**********************************************************************
File ".../devel/sage-t/sage/symbolic/integration/integral.py", line 429:
sage: A = integral(1/ ((x-4) * (x^3+2*x+1)), x); A
Expected:
1/73*log(x - 4) - 1/73*integrate((x^2 + 4*x + 18)/(x^3 + 2*x + 1), x)
Got:
1/73*log(x - 4) - 1/73*integrate(x^2/(x^3 + 2*x + 1), x) -
4/73*integrate(x/(x^3 + 2*x + 1), x) - 18/73*integrate(1/(x^3 + 2*x + 1),
x)
}}}
This just distributes the integral to the polynomial in the numerator.
It's interesting to see that maxima cannot handle results with algebraic
numbers.
----
{{{
**********************************************************************
File ".../devel/sage-t/sage/symbolic/integration/integral.py", line 464:
sage: integrate(sin(x)*cos(10*x)*log(x), x)
Expected:
1/18*log(x)*cos(9*x) - 1/22*log(x)*cos(11*x) -
1/18*integrate(cos(9*x)/x, x) + 1/22*integrate(cos(11*x)/x, x)
Got:
1/198*(11*cos(9*x) - 9*cos(11*x))*log(x) + 1/44*Ei(-11*I*x) -
1/36*Ei(-9*I*x) - 1/36*Ei(9*I*x) + 1/44*Ei(11*I*x)
}}}
Here is the result from Maple:
{{{
> integrate(sin(x)*cos(10*x)*log(x), x);
1/18 ln(x) cos(9 x) - 1/22 ln(x) cos(11 x) - 1/18 Ci(9 x) - 1/198 I Pi
+ 1/198 I Pi csgn(x) + 1/22 Ci(11 x)
}}}
This looks OK to me.
----
{{{
**********************************************************************
File ".../devel/sage-t/sage/symbolic/integration/integral.py", line 186:
sage: h = definite_integral(sin(x)/x^2, x, 1, 2); h
Expected:
integrate(sin(x)/x^2, x, 1, 2)
Got:
1/2*gamma(-1, -2*I) - 1/2*gamma(-1, -I) - 1/2*gamma(-1, I) +
1/2*gamma(-1, 2*I)
**********************************************************************
File ".../devel/sage-t/sage/symbolic/integration/integral.py", line 188:
sage: h.n() # indirect doctest
Expected:
0.4723991772689525...
Got:
0.472399177268906
**********************************************************************
}}}
We saw this in `sage/misc/functional.py` already.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/8624#comment:9>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
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-trac?hl=en.