Ask Your Question
2

why this integral fail using "fricas" algorithm?

asked 2019-10-19 22:47:16 +0100

Nasser gravatar image

updated 2023-01-09 23:59:52 +0100

tmonteil gravatar image

Using sagemath 8.9 on Linux, with Fricas 1.5 installed

>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 8.9, Release Date: 2019-09-29                     │
│ Using Python 2.7.16. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var('x')
x
sage: integrate(sqrt(2)*x^2 + 2*x,x, algorithm="fricas")
  File "<string>", line unknown
SyntaxError: Malformed expression

sage: integrate(sqrt(2)*x^2 + 2*x,x, algorithm="maxima")
1/3*sqrt(2)*x^3 + x^2

But it works when using Fricas 1.5 directly

2) -> ii:=integrate(sqrt(2)*x^2 + 2*x,x);
                                            Type: Polynomial(AlgebraicNumber)
(3) -> unparse(ii::InputForm)    
   (3)  "((2^(1/2))/3)::AlgebraicNumber()*x^3+1::AlgebraicNumber()*x^2"
                                                                 Type: String

Is this a bug in the sagemath <---> Fricas interface?

Thanks --Nasser

edit retag flag offensive close merge delete

Comments

There is a problem in the conversion back to sage

ipdb> p result
 +-+
\|2   3    2
---- x  + x
  3
ipdb> p result.sage()
*** SyntaxError: Malformed expression
ipdb> p result._sage_()
*** SyntaxError: Malformed expression
FrédéricC gravatar imageFrédéricC ( 2019-10-20 11:39:39 +0100 )edit

This can be traced to the following bug

sage: t = fricas(sqrt(2)*x)
sage: t.sage()
  File "<string>", line unknown
SyntaxError: Malformed expression
FrédéricC gravatar imageFrédéricC ( 2019-10-20 11:41:31 +0100 )edit

It's worse than that (on Python3-based Sage 9.0.beta1):

sage: t=fricas(sqrt(2)*x);t
 +-+
\|2 x
sage: t^2
   2
2 x
sage: (t^2).sage()
  File "<string>", line unknown
SyntaxError: Malformed expression

This lets think that Sage has stored the "character representation" of t as its value, rather than a FriCAS expression.

It seems distinct from Trac28630. It might be related to Trac#27268.

Inn any case, the Sage<-->Fricas interface seems to need revision.

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2019-10-20 12:31:07 +0100 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2019-10-20 15:36:50 +0100

FrédéricC gravatar image
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-10-19 22:47:16 +0100

Seen: 406 times

Last updated: Oct 20 '19