Opened 4 years ago
Closed 4 years ago
#25597 closed defect (fixed)
bivariate fricas gamma not interfaced with sage
Reported by:  tmonteil  Owned by:  

Priority:  major  Milestone:  sage8.3 
Component:  interfaces: optional  Keywords:  fricas 
Cc:  mantepse, rws  Merged in:  
Authors:  Martin Rubey  Reviewers:  Frédéric Chapoton 
Report Upstream:  N/A  Work issues:  
Branch:  a6ba957 (Commits, GitHub, GitLab)  Commit:  a6ba9572ad888539e6e1df8e5b0d331fa0abc83f 
Dependencies:  Stopgaps: 
Description (last modified by )
As reported on this ask question, onevariate gamma
is correcly interfaced with Sage:
sage: fricas.Gamma(3/2) 3 Gamma() 2 sage: fricas.Gamma(3/2).sage() 1/2*sqrt(pi)
but not bivariate gamma
:
sage: fricas.Gamma(3/2,2) 3 Gamma(,2) 2 sage: fricas.Gamma(3/2,2).sage() NotImplementedError: The translation of the FriCAS Expression Gamma(3/2,2) to sage is not yet implemented. sage: gamma(3/2,2) gamma(3/2, 2)
The bug in the integration result returned by FriCAS was reported upstream and acknowledged: https://groups.google.com/forum/#!topic/fricasdevel/BhtEiNSW3j4
Change History (15)
comment:1 Changed 4 years ago by
 Keywords fricas added
comment:2 followup: ↓ 3 Changed 4 years ago by
comment:3 in reply to: ↑ 2 Changed 4 years ago by
Replying to ghnasser1:
integrate(sqrt(x + sqrt(x + 1))/((x^2 + 1)*sqrt(x + 1)),x, algorithm="fricas")
This depends on what RootOf
means. Does Sage's complex_root_of
suffice?
comment:4 Changed 4 years ago by
Unrelated but are you sure that FriCAS solves these two correctly? Rubi's solutions do not contain any root expressions:
In[22]:= Int[(x+(1+x)^(1/2))^(1/2)/(1+x^2),x] Out[22]= 1/2 I Sqrt[I+Sqrt[1I]] ArcTan[(2+Sqrt[1I](12 Sqrt[1I]) Sqrt[1+x])/(2 Sqrt[I+Sqrt[1I]] Sqrt[x+Sqrt[1+x]])]1/2 I Sqrt[I+Sqrt[1+I]] ArcTan[(2+Sqrt[1+I](12 Sqrt[1+I]) Sqrt[1+x])/(2 Sqrt[I+Sqrt[1+I]] Sqrt[x+Sqrt[1+x]])]+1/2 I Sqrt[I+Sqrt[1I]] ArcTanh[(2Sqrt[1I](1+2 Sqrt[1I]) Sqrt[1+x])/(2 Sqrt[I+Sqrt[1I]] Sqrt[x+Sqrt[1+x]])]1/2 I Sqrt[I+Sqrt[1+I]] ArcTanh[(2Sqrt[1+I](1+2 Sqrt[1+I]) Sqrt[1+x])/(2 Sqrt[I+Sqrt[1+I]] Sqrt[x+Sqrt[1+x]])] In[21]:= Int[(x+(1+x)^(1/2))^(1/2)/(1+x^2)/(1+x)^(1/2),x] Out[21]= ((I ArcTan[(2+Sqrt[1I](12 Sqrt[1I]) Sqrt[1+x])/(2 Sqrt[I+Sqrt[1I]] Sqrt[x+Sqrt[1+x]])])/(2 Sqrt[(1I)/(I+Sqrt[1I])]))+(I ArcTan[(2+Sqrt[1+I](12 Sqrt[1+I]) Sqrt[1+x])/(2 Sqrt[I+Sqrt[1+I]] Sqrt[x+Sqrt[1+x]])])/(2 Sqrt[((1+I)/(ISqrt[1+I]))])+(I ArcTanh[(2Sqrt[1I](1+2 Sqrt[1I]) Sqrt[1+x])/(2 Sqrt[I+Sqrt[1I]] Sqrt[x+Sqrt[1+x]])])/(2 Sqrt[((1I)/(ISqrt[1I]))])(I ArcTanh[(2Sqrt[1+I](1+2 Sqrt[1+I]) Sqrt[1+x])/(2 Sqrt[I+Sqrt[1+I]] Sqrt[x+Sqrt[1+x]])])/(2 Sqrt[(1+I)/(I+Sqrt[1+I])])
comment:5 Changed 4 years ago by
I am no expert on Fricas nor on Sage. But a quick check shows these are not the same. in sage:
c = complex_root_of(x^6 + x + 1, 1); c complex_root_of(x^6 + x + 1, 1) c.n() 0.790667188814418 + 0.300506920309552*I
But in Fricas, there is no definition for rootOf which takes a polynomial and an integer
There is one unexposed function called rootOf :
[1] (SparseUnivariatePolynomial(D1),Symbol) > D1 from AlgebraicFunction(D4,D1) if D1 has FS(D4) and D4 has Join(COMPAR,INTDOM)
So using
rootOf(x^2 + x + 1, 1)
similar to sage's complex_root_of gives error
(3) > rootOf(x^2 + x + 1, 1) Cannot find a definition or applicable library operation named rootOf with argument type(s) Polynomial(Integer) PositiveInteger
But this works in fricas
rootOf(x^3 + x + 1, x)
So I think it is best to ask the experts in FriCAS group to find what is the best way to translate Fricas rootOf to sage syntax. https://groups.google.com/forum/#!forum/fricasdevel as I am not qualified to answer.
comment:6 Changed 4 years ago by
Concerning Gamma
, it would be necessary to know what the correct definition is. In case you have time, please provide a simple integral which fricas can do, where the result contains a Gamma, and which we can evaluate numerically. In other words, a doctest.
Concerning RootOf
, the translation is probably more tricky, but also doable. I have no clue, but it might be a problem that fricas does not specify which root is meant.
comment:7 followup: ↓ 8 Changed 4 years ago by
The 2 argument Gamma function is the incomplete Gamma function http://functions.wolfram.com/GammaBetaErf/Gamma2/
From http://fricas.github.io/api/FunctionalSpecialFunction.html
Gamma: (F, F) > F Gamma(a, x) returns the incomplete Gamma function applied to a and x Gamma: F > F Gamma(f) returns the formal Gamma function applied to f
So I think it will be safe to translate Fricas Gamma(a,x) to sage's gamma_inc(a,x)
Type: Function_gamma_inc String form: gamma File: /home/sc_serv/sage/local/lib/python2.7/sitepackages/sage/functions/gamma.py Docstring: The upper incomplete gamma function. It is defined by the integral Gamma(a,z)=int_z^infty t^{a1}e^{t},dt
comment:8 in reply to: ↑ 7 Changed 4 years ago by
It is not clear to me whether FriCAS Gamma is the lower or the upper incomplete Gamma function. In any case, there should be a doctest, this is what makes sage reliable.
comment:9 Changed 4 years ago by
I added a simple doctest. However, there is at least a problem with the integral FriCAS returns for the original question mentioned in the ticket description. I'll forward this to the FriCAS mailing list.
Could you please open a different ticket for the rootOf problem?
sage: f = log(x)^(t1) sage: f_int = integrate(f,x, algorithm="fricas"); f_int # optional  fricas cos(pi + pi*t)*gamma(t, log(x)) sage: [(diff(f_int, x)  f).subs(t=k/2).full_simplify() for k in range(5,5)] # optional  fricas [log(x)^(3/2), 0, sqrt(log(x)), 0, 1/sqrt(log(x)), 0, 1/log(x)^(3/2), 0, 1/log(x)^(5/2), 0] sage: f_int = integrate(f,x, algorithm="maxima"); f_int (log(x))^t*log(x)^(t)*gamma(t, log(x)) sage: [(diff(f_int, x)  f).subs(t=k/2).full_simplify() for k in range(5,5)] [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
comment:10 Changed 4 years ago by
 Branch set to u/mantepse/bivariate_fricas_gamma_not_interfaced_with_sage
comment:11 Changed 4 years ago by
 Commit set to 30a4aa804699f4881ef2216b7caf57210a345bc9
 Description modified (diff)
 Status changed from new to needs_review
comment:12 Changed 4 years ago by
 Reviewers set to Frédéric Chapoton
Please remove ;
in var("t");
once done, you can set to positive
comment:13 Changed 4 years ago by
 Commit changed from 30a4aa804699f4881ef2216b7caf57210a345bc9 to a6ba9572ad888539e6e1df8e5b0d331fa0abc83f
Branch pushed to git repo; I updated commit sha1. New commits:
a6ba957  remove semicolon, adapt doctest

comment:15 Changed 4 years ago by
 Branch changed from u/mantepse/bivariate_fricas_gamma_not_interfaced_with_sage to a6ba9572ad888539e6e1df8e5b0d331fa0abc83f
 Resolution set to fixed
 Status changed from positive_review to closed
hi, FYI, these are additional integrals which also generate NotImplementedError? error. I did not know if you need to include these in this bug or open a new bug for them. Here are the commands to use to produce the errors
NotImplementedError?: The translation of the FriCAS Expression
NotImplementedError?: The translation of the FriCAS Expression
I can find more if needed. Both of these integrals work OK using Fricas directly. Thanks you, Nasser