Opened 3 years ago

# wrong result of integral

Reported by: Owned by: dkrenn major sage-7.4 symbolics wrong result, integration Reported upstream. Developers acknowledge bug.

### 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".

### comment:1 Changed 3 years ago by mforets

• Report Upstream changed from N/A to Reported upstream. No feedback yet.

### comment:2 Changed 3 years ago by mforets

• Report Upstream changed from Reported upstream. No feedback yet. to Reported upstream. Developers acknowledge bug.

### comment:3 Changed 15 months ago by SimonKing

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 15 months ago by mforets

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 15 months ago by zimmerma

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
```
Note: See TracTickets for help on using tickets.