Re: sum

Patrick Dupre <[email protected]> Wed, 9 Nov 2022 17:40:35 +0100
Newsgroups gmane.comp.graphics.gnuplot.user
Message-ID <trinity-ad9f809c-0c6b-4def-a376-fb30c97f2b4b-1668012035053@3c-app-mailcom-bs02>
Hello,

would it possible to pass the function (here f(x)) as a parameter
or a pointer to the function f(x) ?

Thank

===========================================================================
 Patrick DUPRÉ                                 | | email: [email protected]
 Laboratoire interdisciplinaire Carnot de Bourgogne
 9 Avenue Alain Savary, BP 47870, 21078 DIJON Cedex FRANCE
 Tel: +33 (0)380395988                    | | Room# D114A
===========================================================================


> Sent: Tuesday, November 01, 2022 at 10:35 PM
> From: "theozh" <[email protected]>
> To: [email protected]
> Subject: Re: [Gnuplot-info] sum
>
> maybe something like this...?
> 
> mySum(xmin,xmax,N) = sum[i=0:N-1] (x0=xmin+real(xmax-xmin)/(N-1)*i,f(x0))
> 
> f(x) = x
> print mySum(1,100,100)
> 
> f(x) = x**2
> print mySum(-10,10,2001)
> 
> Results: 5050.0 and 66766.7
> 
> You need real() to avoid gnuplot's integer division.
> Alternatively, you have to ensure that xmin or xmax are floating point numbers.
> 
> Am 01.11.2022 um 20:55 schrieb Patrick Dupre:
> > set samples 2001
> >
> > f(x)= ..
> >
> > I wish to get the sum of f(x) from [-10:10]
> >
> 
> 
> _______________________________________________
> gnuplot-info mailing list
> [email protected]
> Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info
>


_______________________________________________
gnuplot-info mailing list
[email protected]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info