ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 03 Aug 2024 01:41:01 +0200Interface to custom pari/GPhttps://ask.sagemath.org/question/78575/interface-to-custom-parigp/Hi, I would like to interface pari with a developing branch of pari/GP.
1) Is this possible?
2) It looks to me that between diifferent calls the variables do not change. Does Sage somehow opens a pari session?
Thank you if you have some suggestion
GuidoLSat, 03 Aug 2024 01:41:01 +0200https://ask.sagemath.org/question/78575/Pari-Gp on Jupyterhttps://ask.sagemath.org/question/78418/pari-gp-on-jupyter/I have installed Pari-gp on Jupyter lab via "mamba install pari_jupyter", and it runs fine, but it's missing the keyboard shortcuts like Tab for autocomplete, which are really convenient. Is there any way to include them?
In more detail, I am using a Windows laptop and I have installed Sage-Jupyter through conda/mambda, Ubuntu.
Thanks in advance for any help!fhnWed, 24 Jul 2024 01:05:48 +0200https://ask.sagemath.org/question/78418/How to write Pari GP script in Sagehttps://ask.sagemath.org/question/70742/how-to-write-pari-gp-script-in-sage/I'm new to Sage and Pari-GP. There does not seem to be any application which can act as a Pari interface nicely. In Sage the only solution is to use %%gp to write a pari-gp script. Is there a way to write a whole script without having to use %%gp at the start of every cell? Alternatively, if you have any suggestions for a GUI for Pari scripts, please let me know.adityaghosh2001Sun, 23 Jul 2023 07:55:50 +0200https://ask.sagemath.org/question/70742/set precision for pari in Sagehttps://ask.sagemath.org/question/61582/set-precision-for-pari-in-sage/ In the pari program, we can use \pb 256 to set the precision. For the pari in Sage, how to use this command ?LeeWed, 23 Mar 2022 08:37:44 +0100https://ask.sagemath.org/question/61582/Lower-level Singular interface / turn off unneeded PARI calculationshttps://ask.sagemath.org/question/58159/lower-level-singular-interface-turn-off-unneeded-pari-calculations/I am trying to implement an efficient elimination and substitution procedure for calculating the solution set of a zero-dimensional ideal $I \subseteq \mathbb{Q}[x_1, \ldots, x_n]$ over $\bar{\mathbb{Q}}$. (I know there is `ideal.variety(QQbar)` but would also like to compute directly the smallest number field over which each solution point is defined - `number_field_elements_from_algebraics(..., minimal=True)` can be very slow.)
The algorithm finds the irreducible factors $f_i$ of a generator of $I \cap \mathbb{Q}[x_n]$. These determine algebraic solutions for $x_n$ which can be plugged in to the remaining polynomials to inductively extend them to solutions of $I$.
The base field is thus extended from $\mathbb{Q}$ to the number field $\mathbb{Q}[x]/(f_i(x))$ (and iteratively to further extensions.)
When running the code, I observed that the construction of the field extensions is actually one of the main performance bottlenecks, in particular `_pari_integral_basis`. I assume that PARI's additional number field structure like the ring of integers is not necessary for Singular's Groebner algorithms and therefore wonder if these calculations can be turned off?
Working over Sage's quotient rings
QQ['x'].quotient(f)
does not seem to work together with Singular:
TypeError: Cannot call Singular function 'eliminate' with ring parameter of type '<class 'sage.rings.polynomial.multi_polynomial_ring.MPolynomialRing_polydict_domain_with_category'>'
**TL;DR** It currently seems impossible to call Singular's Groebner methods on an ideal in a polynomial ring defined over a number field *without calling PARI's `nfinit`* (which may spend a lot of time calculating an integral basis for the number field).FabianGFri, 30 Jul 2021 10:12:42 +0200https://ask.sagemath.org/question/58159/Issue on numerical_integral with a Pari/GP functionhttps://ask.sagemath.org/question/56235/issue-on-numerical_integral-with-a-parigp-function/Hello there,
I tried to evaluate the integral of a Pari/GP function but failed so far. Here is an example code on (SageMath version 8.9, Release Date: 2019-09-29 and windows 10):
sage: lchi4 = DirichletGroup(4).list()[1].lfunction(); lchi4
PARI L-function associated to Dirichlet character modulo 4 of conductor 4 mapping 3 |--> -1
sage: numerical_integral(lambda t: lchi4(t).real(), 2,3)
---------------------------------------------------------------------------
SystemError Traceback (most recent call last)
/opt/sagemath-8.9/local/lib/python2.7/site-packages/sage/all_cmdline.pyc in <module>()
----> 1 numerical_integral(lambda t: lchi4(t).real(), Integer(2),Integer(3))
/opt/sagemath-8.9/local/lib/python2.7/site-packages/sage/calculus/integration.pyx in
sage.calculus.integration.numerical_integral (build/cythonized/sage/calculus/integration.c:4061)()
353 _b = b
354 W = <gsl_integration_workspace*> gsl_integration_workspace_alloc(n)
--> 355 sig_on()
356 gsl_integration_qag(&F,_a,_b,eps_abs,eps_rel,n,rule,W,&result,&abs_err)
357 sig_off()
SystemError: calling remove_from_pari_stack() inside sig_on()
However, for the Riemann zeta function, numerical_integral works fine as below:
sage: numerical_integral(lambda t: zeta(t), 2,3)
(1.3675256886839795, 1.518258506343328e-14)
It looks like it would work for lchi4 if it can be coerced into a symbolic expression like zeta(x) as shown below:
sage: type(lchi4(3))
<type 'sage.rings.complex_number.ComplexNumber'>
sage: type(zeta(3))
<type 'sage.symbolic.expression.Expression'>
Can you please let me know how to evaluate the integral numerically for a Pari/GP function as lchi4?
Thank you in advance.jbThu, 18 Mar 2021 22:37:39 +0100https://ask.sagemath.org/question/56235/How to load local PARI/GP script in Sage notebook?https://ask.sagemath.org/question/43681/how-to-load-local-parigp-script-in-sage-notebook/I have a PARI/GP script which I want to load and run locally on my laptop inside a Sage notebook. I tried to open a new notebook in the same directory where my script is located, and run this:
%default_mode gp
But, it throws the following error:
> UsageError: Line magic function '%default_mode` not found.
Please note that I'm using Sage 8.3. How can I run a PARI/GP script locally?ninhoSat, 15 Sep 2018 23:50:41 +0200https://ask.sagemath.org/question/43681/Pari error when factoring polynomialhttps://ask.sagemath.org/question/42742/pari-error-when-factoring-polynomial/ I ran the following code to factor a polynomial over a number field:
U.<z> = CyclotomicField(32)
P.<x> = PolynomialRing(U)
f = x^16-256
print f.factor()
This code works for all substitutions of 256 by another value I have tried, but this one gives an error:
Traceback (most recent call last):
File "p_is_2_test.sage.py", line 10, in <module>
print f.factor()
File "sage/rings/polynomial/polynomial_element.pyx", line 4199, in sage.rings.polynomial.polynomial_element.Polynomial.factor (build/cythonized/sage/rings/polynomial/polynomial_element.c:39418)
File "cypari2/auto_gen.pxi", line 17246, in cypari2.gen.Gen_auto.nffactor
File "cypari2/handle_error.pyx", line 196, in cypari2.handle_error._pari_err_handle
cypari2.handle_error.PariError: inconsistent concatenation t_COL (8 elts) , t_VEC (8 elts)
This seems like some bug in sage, but I am not quite sure what to make of the error. Does anyone know how to deal with this error and to properly let sage factor this polynomial?MadPidgeonTue, 26 Jun 2018 21:58:15 +0200https://ask.sagemath.org/question/42742/Using multiple lines of pari/gp code in a Sage notebookhttps://ask.sagemath.org/question/41758/using-multiple-lines-of-parigp-code-in-a-sage-notebook/I am struggling to get multiple lines of pari/gp code working in a Jupyter Sage notebook.
When I enter:
%%gp
for(x=1,10,print(x))
it all works fine, however when I for instance write:
%%gp
for(x=1,10,{
print(x);
})
the system just 'hangs' and doesn't return any output. The same issue occurs in the Cocalc Sage cloud environment. I also tried 'pari/gp in your browser' and there it works fine.
Am I doing something wrong or isn't the multi-line pari/gp option supported in Sage?RuudHSun, 25 Mar 2018 22:58:41 +0200https://ask.sagemath.org/question/41758/Using Sage plotting capability on data from PARI/GPhttps://ask.sagemath.org/question/41029/using-sage-plotting-capability-on-data-from-parigp/I am trying to plot data in Sage that is generated by a function in PARI/GP, however keep getting type errors.
I use this simple example to illustrate the point:
f=(gp("Z(s)=zeta(s)"))
f(2)
This gives the correct output 1.6449340668482264364724151666460251892 and appears to be a 'normal' floating point number that I can indeed multiply/add with.
However, when I try the following:
plot(f,(2,6))
It keeps coming back with
TypeError: Error executing code in GP
I have studied most of the (limited) info on the Pari/GP interface and did read that PARI/GP always returns a string. I therefore tried to convert the returned value into a float, int etc., however nothing works. I very likely do something wrong (or not allowed) and would be grateful for any advice on what could be the issue here (esp. since f(2) gives the correct numerical floating point result).
Thanks!
RuudHThu, 08 Feb 2018 12:49:41 +0100https://ask.sagemath.org/question/41029/Change Precision of complex_roots()https://ask.sagemath.org/question/39987/change-precision-of-complex_roots/I am trying to find the complex roots of the polynomial
poly = x^7 - 6*x^6 + 15*x^5 - 20*x^4 + 15*x^3 - 6*x^2 + x
But when I do poly.complex_roots(), the system gives:
PariError: overflow in expo()
Apparently there are options for how much precision you want when computing roots -- one option is to use Pari, which is the high-precision option, and the other NumPy, which is the low-precision option. The default is set to use Pari, which apparently overloads when I try to compute the roots of this polynomial (and many others as well, this polynomial is just one example).
How do I change the complex_roots() function to get lower-precision roots?cshiringThu, 07 Dec 2017 06:10:52 +0100https://ask.sagemath.org/question/39987/Change Precision on complex_roots()https://ask.sagemath.org/question/39988/change-precision-on-complex_roots/ I am trying to find the complex roots of the polynomial
poly = x^7 - 6*x^6 + 15*x^5 - 20*x^4 + 15*x^3 - 6*x^2 + x
But when I do poly.complex_roots(), the system gives:
PariError: overflow in expo()
Apparently there are options for how much precision you want when computing roots -- one option is to use Pari, which is the high-precision option, and the other NumPy, which is the low-precision option. The default is set to use Pari, which apparently overloads when I try to compute the roots of this polynomial (and many others as well, this polynomial is just one example).
How do I change the complex_roots() function to get lower-precision roots?
Alternatively, how do I deal with the PariError?
cshiringThu, 07 Dec 2017 06:13:28 +0100https://ask.sagemath.org/question/39988/RuntimeError when starting pari/library not foundhttps://ask.sagemath.org/question/33725/runtimeerror-when-starting-parilibrary-not-found/ Hello,
I am using a binary distribution of sage 7.1 for debian jessie and "installed" it to /opt.
Now, when I want to use pari, I get a runtime error:
```
sage: %gp
```
```
--> Switching to PARI/GP interpreter <--
```
```
pari: sqrt(4)
```
```
RuntimeError: unable to start pari
```
The full backtrace can be found here: paste.kde.org/pvqeoh3ve
however, the following works:
```
LD_LIBRARY_PATH=/opt/sage-7.1/local/lib sage
```
It seems that sage is unable to find that library when starting pari.
Setting SAGE_ROOT does not help. Did I miss some configuration file to set the library path for sage?
fxrhThu, 09 Jun 2016 14:58:27 +0200https://ask.sagemath.org/question/33725/Number field arithmetic in Pari/gphttps://ask.sagemath.org/question/32487/number-field-arithmetic-in-parigp/Hi all,
I would like to do number field arithmetic in Pari. To be more precise, I would like let Pari do the following job as Sage does,
K.<a> = NumberField(f(x))
L.<b> = NumberField(g(x))
where f(x), g(x) are irreducible polynomials over the rational. I would like to do arithmetic with a,b. This is easily done in Sage. How can I do this by Pari?
ThanksDianbin BaoMon, 08 Feb 2016 00:04:39 +0100https://ask.sagemath.org/question/32487/Define a big matrix in Sagehttps://ask.sagemath.org/question/32473/define-a-big-matrix-in-sage/Hi all,
I would like to define a big matrix E (130$\times$ 30) with entries being a list like E[11,1] = [x, [1,-2]];
E[14,1] = [x, [1,-1,-2,1]];
or 0.
These entries are stored in a separate file which is readable by Pari but not Sage.
How do I define it by Sage?Dianbin BaoSat, 06 Feb 2016 20:47:22 +0100https://ask.sagemath.org/question/32473/write output of for loop in pari to filehttps://ask.sagemath.org/question/32491/write-output-of-for-loop-in-pari-to-file/Hi all,
I would like to write the output of a for loop in Pari to a file named 'foo', However the output of a for loop has no numbering contrast with other output. If I look at the numbers labeling the outputs before and after the for loop and use that number in the following command
\w n foo
Then what I get in foo is 0. What happened and how can this be fixed?
Dianbin BaoMon, 08 Feb 2016 03:36:16 +0100https://ask.sagemath.org/question/32491/save gp object to sage readable sobjhttps://ask.sagemath.org/question/32470/save-gp-object-to-sage-readable-sobj/Hi all,
I am doing computation with a Pari readable table. Since I am a beginner to Pari, I would like to know that after defining a number field for example $K=nfinit(x^2-76)$, how do I play around with the generator $x$? This is super easy in Sage and may be silly question for people familiar with Pari. It also solve my problem if you know how to save a big matrix defined in Pari to an object readable by Sage.
Dianbin BaoFri, 05 Feb 2016 22:34:25 +0100https://ask.sagemath.org/question/32470/Plotting parametric matrix discriminantshttps://ask.sagemath.org/question/24881/plotting-parametric-matrix-discriminants/Greetings, I am struggling with the problem concerting characteristic polynomial determinants. I'm intending to plot curves in the (a,b)-plane of parametric matrices, which signal the points of some eigenvalues being zero. To this end, I use the following code
var('a b')
A = matrix([[a+sqrt(-1)b,-1,0],[-1,0,-1],[0,-1,a-sqrt(-1)b]])
p=A.charpoly('t')
d=p.discriminant()
region_plot(d>=0, (a,-4,1), (b,-4,1),incol='gray',figsize=5,axes=true)
which however produces the error
File "handle_error.pyx", line 90, in sage.libs.pari.handle_error._pari_handle_exception (build/cythonized/sage/libs/pari/handle_error.c:1178) sage.libs.pari.gen.PariError: incorrect type in gtofp
Printing the discriminant explicitly and then plotting it works fine
var('a b')
A = matrix([[a+sqrt(-1)*b,-1,0],[-1,0,-1],[0,-1,a-sqrt(-1)*b]])
p=A.charpoly('t')
d=p.discriminant()
d2=-4*b^2*a^4 + (-8*b^4 - 40*b^2 + 4)*a^2 + (-4*b^6 + 24*b^4 - 48*b^2 + 32)
region_plot(d2>=0, (a,-2,2), (b,-2,2),incol='gray',figsize=5,axes=true)
although both quantities seem to be of the same type
<type 'sage.symbolic.expression.Expression'>
any ideas about what am I missing?mamuteekSun, 16 Nov 2014 12:35:12 +0100https://ask.sagemath.org/question/24881/newton's method for multiple variables / arbitrary precisionhttps://ask.sagemath.org/question/11367/newtons-method-for-multiple-variables-arbitrary-precision/I am trying to find a numerical approximation with arbitrary precision to a real solution to a system of multivariate polynomial equations.
I start out with an approximation which is somewhat close to solving the system, up to an precision of about 1e-05. (Meaning that the equations that I try to evaluate are not zero, but smaller than 1e-05 for my starting value)
In [this question](http://ask.sagemath.org/question/3974/solving-system-of-polynomial-equations-over-reals) is it recommended to use scipy's fmin_tnc method, which is what I did. This works out very nicely and it quickly gave a new solution which now solves my system with precision 1e-07. In the [Scipy doc](http://docs.scipy.org/doc/scipy-0.13.0/reference/generated/scipy.optimize.fmin_tnc.html) it is stated that one can set the "epsilon" parameter, but not smaller than machine precision. So it seems like I can't get much more precision with this method?!
Let's say I want to solve my system with precision 1e-250. My questions are:
1. Can I use the fmin_tnc function to find solutions with higher precision?
2. I there another way in sage to find real solutions to polynomial systems locally (e.g. with the pari/gp)?mfTue, 20 May 2014 18:25:59 +0200https://ask.sagemath.org/question/11367/pariError when computing discriminanthttps://ask.sagemath.org/question/9233/parierror-when-computing-discriminant/Consider the following piece of code:
Qx.<x> = PolynomialRing(Rationals())
K = NumberField(x^2+1, 'a')
OOK = K.ring_of_integers() #K.maximal_order() has same effect
OOa = OOK.extension(x^3+2, 'alpha'); OOa
This returns "`Univariate Quotient Polynomial Ring in alpha over Maximal Order in Number Field in a with defining polynomial x^2 + 1 with modulus alpha^3 + 2`". Why is this the case? I would have expected it to have the same effect as
Qx.<x> = PolynomialRing(Rationals())
00b = ZZ.extension([x^3+2,x^2+1], 'beta,b'); OOb
Namely, that it returns `"Relative Order in Number Field in beta with defining polynomial x^3 + 2 over its base field`".
Moreover, and perhaps more interestingly, when one tries to run the command `OOa.discriminant()` after the first piece of code, "`PariError: (5)`" is returned. Running the analogous command, `OOb.absolute_discriminant()` after the second piece of code, one gets -746496. I presume the fact that these two commands return different results is explained in [Quotients of Univariate Polynomial Rings](http://www.sagemath.org/doc/reference/sage/rings/polynomial/polynomial_quotient_ring.html "Quotients of Univariate Polynomial Rings") when it says
> The discriminant of the quotient polynomial ring need not equal the discriminant of the corresponding number field, since the discriminant of a number field is by definition the discriminant of the ring of integers of the number field.
even though we are not computing the discriminant of a number field in the second piece of code. However, why is a pariError returned when trying to compute the discriminant of `OOa`? Surely this must be somehow linked to the fact that the two blocks of code return completely different things. Is this indeed the case? Any help would be appreciated.
Leonhard MoosbruggerTue, 14 Aug 2012 09:58:15 +0200https://ask.sagemath.org/question/9233/Implementing PARI/GP scriptshttps://ask.sagemath.org/question/23138/implementing-parigp-scripts/ Hello, I have the following `gp` script which I would like to use in SAGE.
Script: http://pages.cs.wisc.edu/~yeoh/nt/satoh-fgh.gp
Description: http://pari.math.u-bordeaux.fr/archives/pari-users-0011/msg00005.html
This script is used to find cardinality of an elliptic curve over binary fields. I've also taken a look at
http://trac.sagemath.org/ticket/11548
but was unable to implement either.
I thought that just copying and pasting the codes would enable me to call the functions used, but I was wrong. I'm using SAGE on VirtualBox on Windows. Any help will be appreciated!BlackadderMon, 30 Jun 2014 03:01:58 +0200https://ask.sagemath.org/question/23138/Zeta function gone wild?https://ask.sagemath.org/question/8418/zeta-function-gone-wild/Playing with number fields we reached some weird numerical results. Investigating the problem boiled down to weird output of zeta functions at odd positive integers from 7 onward.
For example,
sage: K.<a> = NumberField(x^2-2)
sage: K.zeta_function()(7)
82.7603619399160
sage: K.zeta_function(prec=100)(7)
45333.379954778857657650185188
sage: K.zeta_function(prec=200)(7)
5.6555192254423051174292272646037247772094677139829119697339e8
These answers seem to be all erroneous. Close values behave fine:
sage: K.zeta_function()(7.0000001)
1.00787667933529
sage: K.zeta_function()(7.00000001)
1.00787667982152
sage: K.zeta_function()(7.000000001)
1.00787669344227
sage: K.zeta_function()(7.0000000001)
1.00787388932573
(the problem begins afterwards).
Another way to obtain this value is
sage: quadratic_L_function__exact(7,2)*zeta(7)
TypeError: n must be a critical value!
which doesn't work. It turns out that this does work:
sage: quadratic_L_function__numerical(7,2)*zeta(7).n()
1.00787667988590
but this does not help us for general number fields (only quadratic).
The same happens with Riemann zeta function, which is the Dedekind zeta function of $\mathbb{Q}$:
sage: K.<a> = NumberField(x)
sage: K.zeta_function()(7)
verbose -1 (371: dokchitser.py, __call__) Warning: Loss of 2 decimal digits due to cancellation
52.5237126027390 # Wrong!
sage: zeta(7).n() # Checking Riemann directly
1.00834927738192 # okie dokie
sage: K.zeta_function()(7.00001)
verbose -1 (371: dokchitser.py, __call__) Warning: Loss of 2 decimal digits due to cancellation
1.00834921704698 # correct
so we get a warning here, and the value at 7 is wrong, but at 7.00001 things are fine.
We are guessing that this relates to zeros/poles of Gamma in the functional equation for zeta. However, since `zeta(7)` and `quadratic_L_function__numerical` do work fine, perhaps there is a way to calculate other zeta functions there as well?
parzanThu, 27 Oct 2011 12:01:44 +0200https://ask.sagemath.org/question/8418/algebraic integer - PARI/GPhttps://ask.sagemath.org/question/9174/algebraic-integer-parigp/in sage you check if an algebraic number is an algebraic integer with is_integral. If I have a number(s) in an algebraic number field, and I want to check if it is an algebraic integers how do I do it in Pari/GP. Please help! Excuse me for using the forum for sage for questions about Pari/GP.paussseMon, 23 Jul 2012 19:11:12 +0200https://ask.sagemath.org/question/9174/gp and sagehttps://ask.sagemath.org/question/10299/gp-and-sage/From gp I have some result and then define a function with 2 variables (using this result). Now I would like to plot this function in 3D- space. The problem is there in only 2D- plot functions in gp, so, I would like to use "sage" for plotting.
Could you please show me how to import the result from gp to sage?
Thank you so much.
Phuong Ha.
Phuong HaSun, 30 Jun 2013 13:33:40 +0200https://ask.sagemath.org/question/10299/Pari source codehttps://ask.sagemath.org/question/10189/pari-source-code/I'm terribly sorry for asking such a basis question, but can anyone tell me I may be able to find an online access to PARI source code similar to the one we have for sage?
http://hg.sagemath.org/sage-main/src/1077314f4166?at=default
If there isn't one, is there an easy way to view the source code?BlackadderTue, 04 Jun 2013 13:06:39 +0200https://ask.sagemath.org/question/10189/Arbitrary precision BesselYhttps://ask.sagemath.org/question/9679/arbitrary-precision-bessely/Hi,
I consider using Sage for some calculations which contain Bessel functions of complex arguments. Since I have to mix Bessel functions with very small and very large arguments I require precision higher than 15 digits.
Unfortunately, I recognized that BesselY is not implemented in PARI. But BesselJ and BesselH1 are. My physicists understanding of math tells me, I could just use "(BesselH1-BesselJ)/i". But I am surprised that this has not been discussed before (at least I couldn't find it), since this would allow a quick implementation of BesselY. Am I missing something that's obvious for math experts? Or can I just use above definition to get an arbitrary precision BesselY?
Many thanks
Frank
FrankStThu, 03 Jan 2013 09:52:57 +0100https://ask.sagemath.org/question/9679/Accessing functions inside .gp fileshttps://ask.sagemath.org/question/9058/accessing-functions-inside-gp-files/I am newbie thus please forgive me if my request is trivial! I want to read a
file of gp extension. And in that file, I have functions. How could call these
functions when I want to use it? </br>
Example: In sage notebook() </br>
1. pari.allocatemem(90000000)</br>
2. Z.<x>=GF(2)[] </br>
3. p = x^163 + x^7 + x^6 + x^3 + 1</br>
4. b = 0x423d0900aeb5645491fee539c297946cbc6a4f1f5</br>
5. p1 = p.polynomial(x)</br>
6. bb = Z(b.digits(2))</br>
7. a1 = gp.Mod(bb._pari_(), p)</br>
8. pari.read(get_remote_file("http://pages.cs.wisc.edu/~yeoh/nt/satoh-fgh.gp"))</br>
9. gp.ecpc(p1, a1)</br>
When, I try the above code in a terminal, it works fine. But when I try it in
sage notebook(), it works till line 8. And when it reaches 9, it says </br>
Traceback (click to the left of this block for traceback)</br>
...</br>
*** not a function in function call</br>
That means, I am unable to call the function ecpc inside the file. Thus, could
you help me how to access that function being outside?twoforoneMon, 11 Jun 2012 04:55:47 +0200https://ask.sagemath.org/question/9058/Running PARI/GP and Sagehttps://ask.sagemath.org/question/7839/running-parigp-and-sage/Suppose I have a function a(i) in PARI/GP code. To evaluate something like a(5) in sage code I write pari('a[5]'). However, running the for loop on pari('a[i]') doesn't seem to work. Is there a work around for this?805801Thu, 30 Jun 2011 04:35:14 +0200https://ask.sagemath.org/question/7839/coerce pari type or string to rational function workaround?https://ask.sagemath.org/question/8114/coerce-pari-type-or-string-to-rational-function-workaround/I am getting some rational functions from pari/gp and want to work with them in Sage. I can't figure out how to do the coercion. I tried coercing them directly, and even via a string.
Here's what I've tried:
Make a pari type rational function:
sage: test = gp.simplify((x+y)/y)
This is the field I want to put it in:
sage: R.<x,y> = PolynomialRing(QQ)
sage: S = R.fraction_field()
coercing directly doesn't work:
sage: S(test)
Traceback (most recent call last):
...
TypeError: unable to convert 1/y*x + 1 to a rational
So I tried making a string out of it:
sage: str(test)
'1/y*x + 1'
Of course, sage would accept that string if I typed it in directly:
sage: S(1/y*x + 1)
(x + y)/y
But it won't accept it as a string:
sage: S(str(test))
Traceback (most recent call last):
...
TypeError: no canonical coercion from Fraction Field of Multivariate Polynomial Ring in x, y over Rational Field to Rational Field
sage: S('1/y*x + 1')
Traceback (most recent call last):
...
TypeError: no canonical coercion from Fraction Field of Multivariate Polynomial Ring in x, y over Rational Field to Rational Field
All of this works fine for polynomials (just remove the denominator of y from the example above). I think these are bugs and I will report them as such, if you agree. But in the meantime, does anyone have a workaround I can use?Kate StangeSun, 22 May 2011 16:11:39 +0200https://ask.sagemath.org/question/8114/