Bill Allombert on Tue, 18 Feb 2014 23:15:07 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Export points coordinates produced by


On Tue, Feb 18, 2014 at 10:02:31PM +0100, Emmanuel Royer wrote:
> Hello,
> 
> Given a function f, Pari-Gp has nice algorithms to select the abscissas
> x_1,...,x_n needed to produce the graph of f.
> 
> How can I use these algorithms to produce a graph with another program
> (like asymptote e.g.)? In other words, how can I export the coordinates
> (x_1,f(x_1)),...,(x_n,f(x_n)) in a text files?

I think the best solution is simply to save the values directly inside
the ploth function:

for example rewrite ploth(x=1,10,sin(x)) as:

sav(x,fx)=write("points",[x,fx]);fx
ploth(x=1,10,sav(x,sin(x)))

You get a file 'points' with all the points.

If you need a specific file format as output, you can use Strprintf:
for example
sav(x,fx)=write1("points",Strprintf("(%.9g,%.9g), ",x,fx));fx

Cheers,
Bill