Opened 3 years ago

Closed 17 months ago

# Doctest integrating (I*a*tan(d*x + c) + a)*sec(d*x + c)^10 via FriCAS

Reported by: Owned by: Nasser Nasser minor sage-duplicate/invalid/wontfix interfaces integrate symbolic, FriCAS Martin Rubey Nasser Abbasi Martin Rubey Fixed upstream, in a later stable release. u/mantepse/notimplementederror__the_translation_of_the_fricas_object_sage2_to_sage_is_not_yet_implemented fac7faea7ae0c32cbedae596d5dfe41e30a17b4b

### Description (last modified by Samuel Lelièvre)

Using SageMath 8.9 with FriCAS 1.3.5, in one test file I have, I see many integrals fail with same error

```sage: integrate((I*a*tan(d*x + c) + a)*sec(d*x + c)^10,x, algorithm="fricas")
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-7-586bc09b0cfc> in <module>()
----> 1 integrate((I*a*tan(d*x + c) + a)*sec(d*x + c)**Integer(10),x, algorithm="fricas")

/usr/lib/python2.7/site-packages/sage/misc/functional.pyc in integral(x, *args, **kwds)
751     """
752     if hasattr(x, 'integral'):
--> 753         return x.integral(*args, **kwds)
754     else:
755         from sage.symbolic.ring import SR

/usr/lib/python2.7/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.integral (build/cythonized/sage/symbolic/expression.cpp:64032)()
12360                     R = ring.SR
12361             return R(integral(f, v, a, b, **kwds))
> 12362         return integral(self, *args, **kwds)
12363
12364     integrate = integral

/usr/lib/python2.7/site-packages/sage/symbolic/integration/integral.pyc in integrate(expression, v, a, b, algorithm, hold)
910         if not integrator:
911             raise ValueError("Unknown algorithm: %s" % algorithm)
--> 912         return integrator(expression, v, a, b)
913     if a is None:
914         return indefinite_integral(expression, v, hold=hold)

/usr/lib/python2.7/site-packages/sage/symbolic/integration/external.pyc in fricas_integrator(expression, v, a, b, noPole)
393             result = ex.integrate(seg)
394
--> 395     result = result.sage()
396
397     if result == "failed":

/usr/lib/python2.7/site-packages/sage/interfaces/interface.pyc in sage(self, *args, **kwds)
1079             [0 0]
1080         """
-> 1081         return self._sage_(*args, **kwds)
1082
1083     def __repr__(self):

/usr/lib/python2.7/site-packages/sage/interfaces/fricas.pyc in _sage_(self)
1909             return R(unparsed_InputForm)
1910
-> 1911         raise NotImplementedError("the translation of the FriCAS object %s to sage is not yet implemented" % (unparsed_InputForm))
1912
1913

NotImplementedError: the translation of the FriCAS object sage2 to sage is not yet implemented
```

Here are more examples:

```integrate((I*a*tan(d*x + c) + a)*sec(d*x + c)^10, x, algorithm="fricas")

integrate((I*a*tan(d*x + c) + a)*sec(d*x + c)^8, x, algorithm="fricas")
```

There are 10's or 100's of similar integrals, all fail with same error. But they work in FriCAS:

```(6) -> ii:=integrate(cos(d*x+c)/(a+I*a*tan(d*x+c))^2,x);

Type: Union(Expression(Integer),...)
(7) -> unparse(ii::InputForm)

(7)
"((3*I^3*sin(d*x+c)+3*I^2*cos(d*x+c))*log((((-2)*I*cos(d*x+c)*sin(d*x+c)+((I^
2+(-1))*cos(d*x+c)^2+(I^2+2)))*(I^2+1)^(1/2)+((2*I^2+2)*sin(d*x+c)+((-2)*I^3+
(-2)*I)*cos(d*x+c)))/(2*I*cos(d*x+c)*sin(d*x+c)+(((-1)*I^2+1)*cos(d*x+c)^2+I^
2)))+((2*I^2+2)*cos(d*x+c)*sin(d*x+c)+((2*I^3+2*I)*cos(d*x+c)^2+((-4)*I^3+2*I
)))*(I^2+1)^(1/2))/(((2*I^5+4*I^3+2*I)*a^2*d*sin(d*x+c)+(2*I^4+4*I^2+2)*a^2*d
*cos(d*x+c))*(I^2+1)^(1/2))"
```

More such examples at this integrals page.

Looking at the table above, under FriCAS, each entry which says F(-2), means it failed due to this error.

This ended up coming from a bug in FriCAS rather than in translating results from FriCAS.

Fixed in FriCAS 1.3.6, to which we upgraded in #27309. This ticket adds a doctest.

### comment:1 Changed 3 years ago by Martin Rubey

Please always use the "FriCAS" keyword for tickets on this topic, otherwise I might not see it.

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

Owner: set to Nasser

### comment:3 Changed 3 years ago by Nasser

this was a bug in Fricas. not sagemath need to close

### comment:4 Changed 3 years ago by Martin Rubey

Report Upstream: N/A → Fixed upstream, but not in a stable release. → Martin Rubey new → needs_review

### comment:5 Changed 3 years ago by Martin Rubey

Authors: → Nasser Abbasi needs_review → positive_review

### comment:6 Changed 3 years ago by Frédéric Chapoton

Status: positive_review → needs_work

this would need a doctest, once in a stable release

### comment:7 Changed 3 years ago by Matthias Köppe

Milestone: sage-9.1 → sage-9.2

Moving tickets to milestone sage-9.2 based on a review of last modification date, branch status, and severity.

### comment:8 Changed 2 years ago by Matthias Köppe

Milestone: sage-9.2 → sage-9.3

### comment:9 Changed 22 months ago by Matthias Köppe

Milestone: sage-9.3 → sage-9.4

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.

### comment:10 Changed 19 months ago by Martin Rubey

Branch: → u/mantepse/notimplementederror__the_translation_of_the_fricas_object_sage2_to_sage_is_not_yet_implemented

### comment:11 Changed 19 months ago by Martin Rubey

Commit: → f18b8218f1e95348fb78aaeebc4b857c9a06fd9b needs_work → needs_review

New commits:

 ​f18b821 `add doctest`

### comment:12 Changed 19 months ago by Martin Rubey

Status: needs_review → positive_review

### comment:13 Changed 19 months ago by Samuel Lelièvre

Description: modified (diff) Fixed upstream, but not in a stable release. → Fixed upstream, in a later stable release. NotImplementedError: the translation of the FriCAS object sage2 to sage is not yet implemented → Doctest integrating (I*a*tan(d*x + c) + a)*sec(d*x + c)^10 via FriCAS

### comment:14 Changed 18 months ago by git

Commit: f18b8218f1e95348fb78aaeebc4b857c9a06fd9b → b6724769ff4f335504333d8775e3f5645718cb46 positive_review → needs_review

Branch pushed to git repo; I updated commit sha1 and set ticket back to needs_review. New commits:

 ​e780764 `Merge branch 'develop' of git://trac.sagemath.org/sage into t/29043/notimplementederror__the_translation_of_the_fricas_object_sage2_to_sage_is_not_yet_implemented` ​b672476 `fix ticket number`

### comment:15 Changed 18 months ago by git

Commit: b6724769ff4f335504333d8775e3f5645718cb46 → fac7faea7ae0c32cbedae596d5dfe41e30a17b4b

Branch pushed to git repo; I updated commit sha1. New commits:

 ​fac7fae `fix doctest, expressions are equal`

### comment:16 Changed 17 months ago by Martin Rubey

Milestone: sage-9.4 → sage-duplicate/invalid/wontfix

The doctest is added by #28630.

### comment:17 Changed 17 months ago by Martin Rubey

Status: needs_review → positive_review

### comment:18 Changed 17 months ago by Frédéric Chapoton

Resolution: → duplicate positive_review → closed
Note: See TracTickets for help on using tickets.