Opened 6 years ago
Last modified 23 months ago
#21440 new defect
wrong result of integral
Reported by: | dkrenn | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-7.4 |
Component: | symbolics | Keywords: | wrong result, integration |
Cc: | Merged in: | ||
Authors: | Reviewers: | ||
Report Upstream: | Reported upstream. Developers acknowledge bug. | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
sage: f1 = (2*cos(2*pi*x) - cos(4*pi*x)) / (5 - 4*cos(2*pi*x)) sage: integrate(f1, x, 0, 1) 23/24
but it should be 1/4
:
sage: sage: numerical_integral(f1,0,1) (0.24999999999999997, 4.6160077311221225e-15)
and
sage: e(x)=exp(2*pi*I*x) sage: f2=real(e(x)/(2-e(-x))) sage: (f1-f2).simplify_trig() # f1 equals f2 0 sage: integrate(f2,x,0,1) 1/4
This was reported by Lukas Spiegelhofer on 8/10/2015 16:00:13 via "Sage Notebooks Bugreports".
Attachments (1)
Change History (8)
comment:1 Changed 5 years ago by
- Report Upstream changed from N/A to Reported upstream. No feedback yet.
comment:2 Changed 5 years ago by
- Report Upstream changed from Reported upstream. No feedback yet. to Reported upstream. Developers acknowledge bug.
comment:3 Changed 4 years ago by
Is the following example an instance of the same bug, or a different problem?
sage: (cos(pi*x)*exp(-I*pi*x)).integral(x,-1/2,1/2) # wrong 1 sage: F = (cos(pi*x)*exp(-I*pi*x)).integral(x); F(x=1/2)-F(x=-1/2) # correct 1/2
comment:4 Changed 4 years ago by
Hmmm they look similar to me, although in your example the primitive computed by Maxima is correct, but for the case of the description also the primitive is wrong:
sage: f1 = (2*cos(2*pi*x) - cos(4*pi*x)) / (5 - 4*cos(2*pi*x)) sage: F1 = f1.integrate(x) sage: F1(x=1) - F1(x=0) # yet another result! 5/8 sage: F1_g = f1.integrate(x, algorithm="giac") sage: F1_g(x=1) - F1_g(x=0) 1/4
comment:5 Changed 4 years ago by
I'm not sure integrate
accepts inputs that take non-real values (it should be documented if yes or no):
sage: f(x)=cos(pi*x)*exp(-I*pi*x) sage: f(1/4) -1/2*I + 1/2
Note that:
sage: (cos(pi*x)*exp(-I*pi*x)).real().integral(x,-1/2,1/2) 1/2
comment:6 Changed 23 months ago by
Well, the primitives given by various algo are all different:
sage: f1 = (2*cos(2*pi*x) - cos(4*pi*x)) / (5 - 4*cos(2*pi*x)) sage: i1=f1.integral(x,algorithm='maxima').simplify_trig() sage: i2=f1.integral(x,algorithm='giac').simplify_trig() sage: i3=f1.integral(x,algorithm='fricas').simplify_trig() sage: g1 = f1.simplify_trig() sage: j1=g1.integral(x,algorithm='maxima').simplify_trig() sage: j2=g1.integral(x,algorithm='giac').simplify_trig() sage: j3=g1.integral(x,algorithm='fricas').simplify_trig() sage: i1 1/48*(30*pi*x + 24*cos(pi*x)*sin(pi*x) + 40*arctan(3*sin(pi*x)/cos(pi*x)) - 24*arctan(sin(pi*x)/cos(pi*x)) - 17*arctan2(2*cos(pi*x)*sin(pi*x), 2*cos(pi*x)^2 - 3/2) + 17*arctan2(2*cos(pi*x)*sin(pi*x), 2*cos(pi*x)^2 - 3))/pi sage: i2 1/8*(2*pi*x + 4*cos(pi*x)*sin(pi*x) + arctan(2*cos(pi*x)*sin(pi*x)/(2*sin(pi*x)^2 + 1)))/pi sage: i3 1/16*(2*pi*x + 8*cos(pi*x)*sin(pi*x) + arctan(1/6*(10*sin(pi*x)^2 - 1)/(cos(pi*x)*sin(pi*x))))/pi sage: j1 1/8*(pi*x + 4*cos(pi*x)*sin(pi*x) + arctan(3*sin(pi*x)/cos(pi*x)))/pi sage: j2 1/8*(2*pi*x + 4*cos(pi*x)*sin(pi*x) + arctan(2*cos(pi*x)*sin(pi*x)/(2*sin(pi*x)^2 + 1)))/pi sage: j3 1/16*(2*pi*x + 8*cos(pi*x)*sin(pi*x) + arctan(1/6*(10*sin(pi*x)^2 - 1)/(cos(pi*x)*sin(pi*x))))/pi sage: (i1-j1).simplify_trig() # maxima is not coherent with itself 1/48*(24*pi*x + 34*arctan(3*sin(pi*x)/cos(pi*x)) - 24*arctan(sin(pi*x)/cos(pi*x)) - 17*arctan2(2*cos(pi*x)*sin(pi*x), 2*cos(pi*x)^2 - 3/2) + 17*arctan2(2*cos(pi*x)*sin(pi*x), 2*cos(pi*x)^2 - 3))/pi sage: (i2-j2).simplify_trig() # giac is coherent with itself 0 sage: (i3-j3).simplify_trig() # fricas is coherent with itself 0
and only "giac" returns a continuous primitive ! All the others have a jump at 1/2
see: https://sourceforge.net/p/maxima/bugs/3295/