everyone!
I know this is probably a dumb question, but I'm having a lot of trouble with Sage, and it's frustrating the hell out of me. To give a bit of an explanation, I code entirely in pari-gp. I don't have a single problem with my code in pari-gp, I'm just having trouble with interfacing my code with Sage. Which, this is something Sage bolsters, that you can run pari-gp code within sage. I essentially want to run all my processes in pari-gp, but I want to exploit all of Sage's graphing protocols.
What I want to do couldn't be easier. I have a well working function test(x,y)
, which produces a real number. I don't have any problems running this in pari, everything is kosher. All I want to do is make a graph of test(x,y) = z
. Now I know how to run this command in sage, but I don't know how to interface such that test
is actually a program running from Pari code.
I'd love to program all my stuff in Sage, but that's just impossible. I need the language Pari, so before you say that I could just translate everything in Sage, it's impossible. I just can't wrap my head around how to interface Pari with Sage. I know it's possible; hell, they advertise it on the main website. I'm just very unclear about how to do the following:
1.) Read a file from my pari-gp root directory: gp.read("myfile.gp")
.
2.) Inherit the functions, such that gp("test(x,y)")
, now runs as though it runs in the GP terminal.
3.) Graph said function test(x,y)
using Sage's graphing protocols.
Any help is greatly appreciated. I know I'm just forgetting to do something dumb, or I'm missing a step in how I'm doing it.
Any help is greatly appreciated!
Let us start with:
So the printed version of
gp("test(1, 1)")
looks like a number, but it is not a float instance. Note that py3 has some f-strings, so we can easily plug in values of variablesx
,y
inside thegp("test(...)")
. I will use f-strings to define the sage function...And we are not far away from the final plot: